1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: gst-plugins10.eclass
9 # Gilles Dartiguelongue <eva@gentoo.org>
10 # Saleem Abdulrasool <compnerd@gentoo.org>
11 # foser <foser@gentoo.org>
12 # zaheerm <zaheerm@gentoo.org>
13 # @BLURB: Manages build for invididual ebuild for gst-plugins.
15 # Eclass to make external gst-plugins emergable on a per-plugin basis and
16 # to solve the problem with gst-plugins generating far too much unneeded
19 # GStreamer consuming applications should depend on the specific plugins they
20 # need as defined in their source code.
22 # In case of spider usage, obtain recommended plugins to use from Gentoo
23 # developers responsible for gstreamer <gstreamer@gentoo.org> or the application
26 inherit eutils multilib toolchain-funcs versionator
31 GST_EXPF="src_configure src_compile src_install"
34 GST_EXPF="src_compile src_install"
37 die "EAPI=\"${EAPI:-0}\" is not supported anymore"
40 die "EAPI=\"${EAPI}\" is not supported yet"
43 EXPORT_FUNCTIONS ${GST_EXPF}
45 # @ECLASS-VARIABLE: GST_LA_PUNT
47 # Should we delete all the .la files?
48 # NOT to be used without due consideration.
49 # Defaults to no for EAPI < 5.
50 if has "${EAPI:-0}" 0 1 2 3; then
51 : ${GST_LA_PUNT:="no"}
53 : ${GST_LA_PUNT:="yes"}
56 # @ECLASS-VARIABLE: GST_PLUGINS_BUILD
58 # Defines the plugins to be built.
59 # May be set by an ebuild and contain more than one indentifier, space
60 # seperated (only src_configure can handle mutiple plugins at this time).
61 : ${GST_PLUGINS_BUILD:=${PN/gst-plugins-/}}
63 # @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
65 # Actual build directory of the plugin.
66 # Most often the same as the configure switch name.
67 : ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
69 # @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
71 # Most projects hosted on gstreamer.freedesktop.org mirrors provide tarballs as
72 # tar.bz2 or tar.xz. This eclass defaults to bz2 for EAPI 0, 1, 2, 3 and
73 # defaults to xz for everything else. This is because the gstreamer mirrors
74 # are moving to only have xz tarballs for new releases.
75 if has "${EAPI:-0}" 0 1 2 3; then
76 : ${GST_TARBALL_SUFFIX:="bz2"}
78 : ${GST_TARBALL_SUFFIX:="xz"}
81 # Even though xz-utils are in @system, they must still be added to DEPEND; see
82 # https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
83 if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
84 DEPEND="${DEPEND} app-arch/xz-utils"
87 # @ECLASS-VARIABLE: GST_ORG_MODULE
89 # Name of the module as hosted on gstreamer.freedesktop.org mirrors.
90 # Leave unset if package name matches module name.
91 : ${GST_ORG_MODULE:=$PN}
93 # @ECLASS-VARIABLE: GST_ORG_PVP
96 # Major and minor numbers of the version number.
97 : ${GST_ORG_PVP:=$(get_version_component_range 1-2)}
100 DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
101 HOMEPAGE="http://gstreamer.freedesktop.org/"
102 SRC_URI="http://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
105 case ${GST_ORG_PVP} in
108 *) die "Unkown gstreamer release."
111 S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"
114 >=dev-libs/glib-2.6:2
115 media-libs/gstreamer:${SLOT}
122 if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
123 # Do not run test phase for invididual plugin ebuilds.
125 RDEPEND="${RDEPEND} >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}"
128 DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )"
131 #if [[ ${SLOT} == "0.10" ]]; then
132 # XXX: verify with old ebuilds.
133 # DEPEND="${DEPEND} dev-libs/liboil"
136 DEPEND="${DEPEND} ${RDEPEND}"
138 # @FUNCTION: gst-plugins10_get_plugins
141 # Get the list of plugins requiring external dependencies.
142 gst-plugins10_get_plugins() {
143 # Must be called from src_prepare/src_configure
144 GST_PLUGINS_LIST=$(sed -rn 's/^AG_GST_CHECK_FEATURE\((\w+),.*/ \1 /p' \
145 "${S}"/configure.* | LC_ALL='C' tr '[:upper:]' '[:lower:]')
148 # @FUNCTION: gst-plugins10_find_plugin_dir
149 # @USAGE: gst-plugins10_find_plugin_dir [<build_dir>]
152 # Finds plugin build directory and cd to it.
153 # Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
154 gst-plugins10_find_plugin_dir() {
155 local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
157 if [[ ! -d ${S}/ext/${build_dir} ]]; then
158 if [[ ! -d ${S}/sys/${build_dir} ]]; then
159 ewarn "No such plugin directory"
162 einfo "Building system plugin in ${build_dir}..."
163 cd "${S}"/sys/${build_dir}
165 einfo "Building external plugin in ${build_dir}..."
166 cd "${S}"/ext/${build_dir}
170 # @FUNCTION: gst-plugins10_system_link
171 # @USAGE: gst-plugins10_system_link gst-libs/gst/audio:gstreamer-audio [...]
173 # Walks through makefiles in order to make sure build will link against system
175 # Takes a list of path fragments and corresponding pkgconfig libraries
176 # separated by colon (:). Will replace the path fragment by the output of
178 gst-plugins10_system_link() {
179 local directory libs pkgconfig pc tuple
180 pkgconfig=$(tc-getPKG_CONFIG)
182 for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
183 gst-plugins10_find_plugin_dir ${plugin_dir}
186 directory="$(echo ${tuple} | cut -f1 -d':')"
187 pc="$(echo ${tuple} | cut -f2 -d':')-${SLOT}"
188 libs="$(${pkgconfig} --libs-only-l ${pc})"
189 sed -e "s:\$(top_builddir)/${directory}/.*\.la:${libs}:" \
190 -i Makefile.am Makefile.in || die
195 # @FUNCTION: gst-plugins10_remove_unversioned_binaries
198 # Remove the unversioned binaries gstreamer provides to prevent file collision
199 # with other slots. DEPRECATED
200 gst-plugins10_remove_unversioned_binaries() {
203 for gst_bins in *-${SLOT} ; do
204 [[ -e ${gst_bins} ]] || continue
205 rm ${gst_bins/-${SLOT}/}
206 einfo "Removed ${gst_bins/-${SLOT}/}"
210 # @FUNCTION: gst-plugins10_src_configure
212 # Handles logic common to configuring gstreamer plugins
213 gst-plugins10_src_configure() {
214 local plugin gst_conf
216 if has ${EAPI:-0} 0 1 2 3 ; then
217 gst_conf="${gst_conf} --disable-dependency-tracking"
220 if has ${EAPI:-0} 0 1 2 3 4 ; then
221 gst_conf="${gst_conf} --disable-silent-rules"
224 gst-plugins10_get_plugins
226 for plugin in ${GST_PLUGINS_LIST} ; do
227 if has ${plugin} ${GST_PLUGINS_BUILD} ; then
228 gst_conf="${gst_conf} --enable-${plugin}"
230 gst_conf="${gst_conf} --disable-${plugin}"
234 if grep -q "ORC_CHECK" configure.* ; then
235 if in_iuse orc ; then
236 gst_conf="${gst_conf} $(use_enable orc)"
238 gst_conf="${gst_conf} --disable-orc"
242 if grep -q "AM_MAINTAINER_MODE" configure.* ; then
243 gst_conf="${gst_conf} --disable-maintainer-mode"
246 if grep -q "disable-schemas-compile" configure ; then
247 gst_conf="${gst_conf} --disable-schemas-compile"
250 if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
251 gst_conf="${gst_conf} $(use_enable nls)"
254 einfo "Configuring to build ${GST_PLUGINS_BUILD} plugin(s) ..."
256 --with-package-name="Gentoo GStreamer ebuild" \
257 --with-package-origin="https://www.gentoo.org" \
261 # @FUNCTION: gst-plugins10_src_compile
263 # Compiles requested gstreamer plugin.
264 gst-plugins10_src_compile() {
267 has ${EAPI:-0} 0 1 && gst-plugins10_src_configure "$@"
269 for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
270 gst-plugins10_find_plugin_dir ${plugin_dir}
272 if has "${EAPI:-0}" 0 1 2 3 ; then
280 # @FUNCTION: gst-plugins10_src_install
282 # Installs requested gstreamer plugin.
283 gst-plugins10_src_install() {
286 for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
287 gst-plugins10_find_plugin_dir ${plugin_dir}
289 if has "${EAPI:-0}" 0 1 2 3 ; then
290 emake install DESTDIR="${D}" || die
291 [[ -e README ]] && dodoc README
297 [[ ${GST_LA_PUNT} = "yes" ]] && prune_libtool_files --modules