gstreamer.eclass 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: gstreamer.eclass
  4. # @MAINTAINER:
  5. # gstreamer@gentoo.org
  6. # @AUTHOR:
  7. # Michał Górny <mgorny@gentoo.org>
  8. # Gilles Dartiguelongue <eva@gentoo.org>
  9. # Saleem Abdulrasool <compnerd@gentoo.org>
  10. # foser <foser@gentoo.org>
  11. # zaheerm <zaheerm@gentoo.org>
  12. # @BLURB: Helps building core & split gstreamer plugins.
  13. # @DESCRIPTION:
  14. # Eclass to make external gst-plugins emergable on a per-plugin basis
  15. # and to solve the problem with gst-plugins generating far too much
  16. # unneeded dependencies.
  17. #
  18. # GStreamer consuming applications should depend on the specific plugins
  19. # they need as defined in their source code. Usually you can find that
  20. # out by grepping the source tree for 'factory_make'. If it uses playbin
  21. # plugin, consider adding media-plugins/gst-plugins-meta dependency, but
  22. # also list any packages that provide explicitly requested plugins.
  23. inherit eutils multilib multilib-minimal toolchain-funcs versionator xdg-utils
  24. case "${EAPI:-0}" in
  25. 5|6)
  26. ;;
  27. 0|1|2|3|4)
  28. die "EAPI=\"${EAPI:-0}\" is not supported anymore"
  29. ;;
  30. *)
  31. die "EAPI=\"${EAPI}\" is not supported yet"
  32. ;;
  33. esac
  34. # @ECLASS-VARIABLE: GST_PLUGINS_BUILD
  35. # @DESCRIPTION:
  36. # Defines the plugins to be built.
  37. # May be set by an ebuild and contain more than one indentifier, space
  38. # seperated (only src_configure can handle mutiple plugins at this time).
  39. : ${GST_PLUGINS_BUILD:=${PN/gst-plugins-/}}
  40. # @ECLASS-VARIABLE: GST_PLUGINS_BUILD_DIR
  41. # @DESCRIPTION:
  42. # Actual build directory of the plugin.
  43. # Most often the same as the configure switch name.
  44. : ${GST_PLUGINS_BUILD_DIR:=${PN/gst-plugins-/}}
  45. # @ECLASS-VARIABLE: GST_TARBALL_SUFFIX
  46. # @DESCRIPTION:
  47. # Most projects hosted on gstreamer.freedesktop.org mirrors provide
  48. # tarballs as tar.bz2 or tar.xz. This eclass defaults to xz. This is
  49. # because the gstreamer mirrors are moving to only have xz tarballs for
  50. # new releases.
  51. : ${GST_TARBALL_SUFFIX:="xz"}
  52. # Even though xz-utils are in @system, they must still be added to DEPEND; see
  53. # https://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
  54. if [[ ${GST_TARBALL_SUFFIX} == "xz" ]]; then
  55. DEPEND="${DEPEND} app-arch/xz-utils"
  56. fi
  57. # @ECLASS-VARIABLE: GST_ORG_MODULE
  58. # @DESCRIPTION:
  59. # Name of the module as hosted on gstreamer.freedesktop.org mirrors.
  60. # Leave unset if package name matches module name.
  61. : ${GST_ORG_MODULE:=$PN}
  62. # @ECLASS-VARIABLE: GST_ORG_PVP
  63. # @INTERNAL
  64. # @DESCRIPTION:
  65. # Major and minor numbers of the version number.
  66. : ${GST_ORG_PVP:=$(get_version_component_range 1-2)}
  67. DESCRIPTION="${BUILD_GST_PLUGINS} plugin for gstreamer"
  68. HOMEPAGE="https://gstreamer.freedesktop.org/"
  69. SRC_URI="https://gstreamer.freedesktop.org/src/${GST_ORG_MODULE}/${GST_ORG_MODULE}-${PV}.tar.${GST_TARBALL_SUFFIX}"
  70. LICENSE="GPL-2"
  71. case ${GST_ORG_PVP} in
  72. 0.10) SLOT="0.10"; GST_MIN_PV="0.10.36-r2" ;;
  73. 1.*) SLOT="1.0"; GST_MIN_PV="1.2.4-r1" ;;
  74. *) die "Unkown gstreamer release."
  75. esac
  76. S="${WORKDIR}/${GST_ORG_MODULE}-${PV}"
  77. RDEPEND="
  78. >=dev-libs/glib-2.38.2-r1:2[${MULTILIB_USEDEP}]
  79. >=media-libs/gstreamer-${GST_MIN_PV}:${SLOT}[${MULTILIB_USEDEP}]
  80. "
  81. DEPEND="
  82. >=sys-apps/sed-4
  83. >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
  84. "
  85. # Export common multilib phases.
  86. multilib_src_configure() { gstreamer_multilib_src_configure; }
  87. if [[ ${PN} != ${GST_ORG_MODULE} ]]; then
  88. # Do not run test phase for invididual plugin ebuilds.
  89. RESTRICT="test"
  90. RDEPEND="${RDEPEND}
  91. >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]"
  92. # Export multilib phases used for split builds.
  93. multilib_src_compile() { gstreamer_multilib_src_compile; }
  94. multilib_src_install() { gstreamer_multilib_src_install; }
  95. multilib_src_install_all() { gstreamer_multilib_src_install_all; }
  96. else
  97. IUSE="nls"
  98. DEPEND="${DEPEND} nls? ( >=sys-devel/gettext-0.17 )"
  99. fi
  100. if [[ ${SLOT} == "0.10" ]]; then
  101. RDEPEND="${RDEPEND}
  102. abi_x86_32? (
  103. !app-emulation/emul-linux-x86-gstplugins[-abi_x86_32(-)]
  104. )"
  105. fi
  106. DEPEND="${DEPEND} ${RDEPEND}"
  107. # @FUNCTION: gstreamer_environment_reset
  108. # @INTERNAL
  109. # @DESCRIPTION:
  110. # Clean up environment for clean builds.
  111. # >=dev-lang/orc-0.4.23 rely on environment variables to find a place to
  112. # allocate files to mmap.
  113. gstreamer_environment_reset() {
  114. xdg_environment_reset
  115. }
  116. # @FUNCTION: gstreamer_get_plugins
  117. # @INTERNAL
  118. # @DESCRIPTION:
  119. # Get the list of plugins requiring external dependencies.
  120. gstreamer_get_plugins() {
  121. # Must be called from src_prepare/src_configure
  122. GST_PLUGINS_LIST=$(sed -rn 's/^AG_GST_CHECK_FEATURE\((\w+),.*/ \1 /p' \
  123. "${ECONF_SOURCE:-${S}}"/configure.* | LC_ALL='C' tr '[:upper:]' '[:lower:]')
  124. }
  125. # @FUNCTION: gstreamer_get_plugin_dir
  126. # @USAGE: gstreamer_get_plugin_dir [<build_dir>]
  127. # @INTERNAL
  128. # @DESCRIPTION:
  129. # Finds plugin build directory and output it.
  130. # Defaults to ${GST_PLUGINS_BUILD_DIR} if argument is not provided
  131. gstreamer_get_plugin_dir() {
  132. local build_dir=${1:-${GST_PLUGINS_BUILD_DIR}}
  133. if [[ ! -d ${S}/ext/${build_dir} ]]; then
  134. if [[ ! -d ${S}/sys/${build_dir} ]]; then
  135. ewarn "No such plugin directory"
  136. die
  137. fi
  138. einfo "Building system plugin in ${build_dir}..." >&2
  139. echo sys/${build_dir}
  140. else
  141. einfo "Building external plugin in ${build_dir}..." >&2
  142. echo ext/${build_dir}
  143. fi
  144. }
  145. # @FUNCTION: gstreamer_system_link
  146. # @USAGE: gstreamer_system_link gst-libs/gst/audio:gstreamer-audio [...]
  147. # @DESCRIPTION:
  148. # Walks through makefiles in order to make sure build will link against system
  149. # libraries.
  150. # Takes a list of path fragments and corresponding pkgconfig libraries
  151. # separated by colon (:). Will replace the path fragment by the output of
  152. # pkgconfig.
  153. gstreamer_system_link() {
  154. local pdir directory libs pkgconfig pc tuple
  155. pkgconfig=$(tc-getPKG_CONFIG)
  156. for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
  157. pdir=$(gstreamer_get_plugin_dir ${plugin_dir})
  158. for tuple in $@ ; do
  159. directory=${tuple%:*}
  160. pc=${tuple#*:}-${SLOT}
  161. libs="$(${pkgconfig} --libs-only-l ${pc} || die)"
  162. sed -e "s:\$(top_builddir)/${directory}/.*\.la:${libs}:" \
  163. -i "${pdir}"/Makefile.{am,in} || die
  164. done
  165. done
  166. }
  167. # @FUNCTION: gstreamer_multilib_src_configure
  168. # @DESCRIPTION:
  169. # Handles logic common to configuring gstreamer plugins
  170. gstreamer_multilib_src_configure() {
  171. local plugin gst_conf=() ECONF_SOURCE=${ECONF_SOURCE:-${S}}
  172. gstreamer_get_plugins
  173. gstreamer_environment_reset
  174. for plugin in ${GST_PLUGINS_LIST} ; do
  175. if has ${plugin} ${GST_PLUGINS_BUILD} ; then
  176. gst_conf+=( --enable-${plugin} )
  177. else
  178. gst_conf+=( --disable-${plugin} )
  179. fi
  180. done
  181. if grep -q "ORC_CHECK" "${ECONF_SOURCE}"/configure.* ; then
  182. if in_iuse orc ; then
  183. gst_conf+=( $(use_enable orc) )
  184. else
  185. gst_conf+=( --disable-orc )
  186. fi
  187. fi
  188. if grep -q "AM_MAINTAINER_MODE" "${ECONF_SOURCE}"/configure.* ; then
  189. gst_conf+=( --disable-maintainer-mode )
  190. fi
  191. if grep -q "disable-schemas-compile" "${ECONF_SOURCE}"/configure ; then
  192. gst_conf+=( --disable-schemas-compile )
  193. fi
  194. if [[ ${PN} == ${GST_ORG_MODULE} ]]; then
  195. gst_conf+=( $(use_enable nls) )
  196. fi
  197. einfo "Configuring to build ${GST_PLUGINS_BUILD} plugin(s) ..."
  198. econf \
  199. --with-package-name="Gentoo GStreamer ebuild" \
  200. --with-package-origin="https://www.gentoo.org" \
  201. "${gst_conf[@]}" "${@}"
  202. }
  203. # @FUNCTION: gstreamer_multilib_src_compile
  204. # @DESCRIPTION:
  205. # Compiles requested gstreamer plugin.
  206. gstreamer_multilib_src_compile() {
  207. local plugin_dir
  208. for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
  209. emake -C "$(gstreamer_get_plugin_dir ${plugin_dir})"
  210. done
  211. }
  212. # @FUNCTION: gstreamer_multilib_src_install
  213. # @DESCRIPTION:
  214. # Installs requested gstreamer plugin.
  215. gstreamer_multilib_src_install() {
  216. local plugin_dir
  217. for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
  218. emake -C "$(gstreamer_get_plugin_dir ${plugin_dir})" \
  219. DESTDIR="${D}" install
  220. done
  221. }
  222. # @FUNCTION: gstreamer_multilib_src_install_all
  223. # @DESCRIPTION:
  224. # Installs documentation for requested gstreamer plugin, and removes .la
  225. # files.
  226. gstreamer_multilib_src_install_all() {
  227. local plugin_dir
  228. for plugin_dir in ${GST_PLUGINS_BUILD_DIR} ; do
  229. local dir=$(gstreamer_get_plugin_dir ${plugin_dir})
  230. [[ -e ${dir}/README ]] && dodoc "${dir}"/README
  231. done
  232. prune_libtool_files --modules
  233. }