libav-11.7.ebuild 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
  5. if [[ ${PV} == *9999 ]] ; then
  6. : ${EGIT_REPO_URI:="git://git.libav.org/libav.git"}
  7. if [[ ${PV%9999} != "" ]] ; then
  8. : ${EGIT_BRANCH:="release/${PV%.9999}"}
  9. fi
  10. inherit git-r3
  11. fi
  12. DESCRIPTION="Complete solution to record, convert and stream audio and video"
  13. HOMEPAGE="https://libav.org/"
  14. if [[ ${PV} == *9999 ]] ; then
  15. SRC_URI=""
  16. elif [[ ${PV%_p*} != ${PV} ]] ; then # Gentoo snapshot
  17. SRC_URI="https://dev.gentoo.org/~lu_zero/libav/${P}.tar.xz"
  18. else # Official release
  19. SRC_URI="https://libav.org/releases/${P}.tar.xz"
  20. fi
  21. # 9999 does not have fate-*.tar.xz
  22. [[ ${PV%9999} != "" ]] && SRC_URI+=" test? ( https://dev.gentoo.org/~lu_zero/libav/fate-${PV%%.*}.tar.xz )"
  23. LICENSE="LGPL-2.1 gpl? ( GPL-3 )"
  24. SLOT="0/11"
  25. [[ ${PV} == *9999 ]] || \
  26. KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
  27. IUSE="aac alsa amr bs2b +bzip2 cdio cpudetection custom-cflags debug doc +encode faac fdk
  28. frei0r fontconfig +gpl gsm +hardcoded-tables ieee1394 jack jpeg2k libressl mp3
  29. +network openssl opus oss pic pulseaudio rtmp schroedinger sdl speex ssl
  30. static-libs test theora threads tools truetype twolame v4l vaapi vdpau vorbis vpx X
  31. wavpack webp x264 x265 xvid +zlib"
  32. # String for CPU features in the useflag[:configure_option] form
  33. # if :configure_option isn't set, it will use 'useflag' as configure option
  34. CPU_FEATURES="altivec armv5te armv6 armv6t2 armvfp:vfp neon"
  35. X86_CPU_FEATURES="3dnow:amd3dnow 3dnowext:amd3dnowext mmx mmxext sse sse2 sse3 ssse3 sse4_1:sse4 sse4_2:sse42 avx xop fma3 fma4 avx2"
  36. for i in ${X86_CPU_FEATURES} ; do
  37. CPU_FEATURES+=" cpu_flags_x86_${i%:*}:${i#*:}"
  38. done
  39. for i in ${CPU_FEATURES} ; do
  40. IUSE+=" ${i%:*}"
  41. done
  42. RDEPEND="
  43. !media-video/ffmpeg:0
  44. alsa? ( >=media-libs/alsa-lib-1.0.27.2[${MULTILIB_USEDEP}] )
  45. amr? ( >=media-libs/opencore-amr-0.1.3-r1[${MULTILIB_USEDEP}] )
  46. bs2b? ( >=media-libs/libbs2b-3.1.0-r1[${MULTILIB_USEDEP}] )
  47. bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
  48. cdio? ( >=dev-libs/libcdio-paranoia-0.90_p1-r1[${MULTILIB_USEDEP}] )
  49. encode? (
  50. aac? ( >=media-libs/vo-aacenc-0.1.3[${MULTILIB_USEDEP}] )
  51. amr? ( >=media-libs/vo-amrwbenc-0.1.2-r1[${MULTILIB_USEDEP}] )
  52. faac? ( >=media-libs/faac-1.28-r3[${MULTILIB_USEDEP}] )
  53. mp3? ( >=media-sound/lame-3.99.5-r1[${MULTILIB_USEDEP}] )
  54. theora? (
  55. >=media-libs/libtheora-1.1.1[encode,${MULTILIB_USEDEP}]
  56. >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
  57. )
  58. twolame? ( >=media-sound/twolame-0.3.13-r1[${MULTILIB_USEDEP}] )
  59. vorbis? (
  60. >=media-libs/libvorbis-1.3.3-r1[${MULTILIB_USEDEP}]
  61. >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
  62. )
  63. webp? ( >=media-libs/libwebp-0.3.0[${MULTILIB_USEDEP}] )
  64. wavpack? ( >=media-sound/wavpack-4.60.1-r1[${MULTILIB_USEDEP}] )
  65. x264? ( >=media-libs/x264-0.0.20130506:=[${MULTILIB_USEDEP}] )
  66. x265? ( >=media-libs/x265-1.2:=[${MULTILIB_USEDEP}] )
  67. xvid? ( >=media-libs/xvid-1.3.2-r1[${MULTILIB_USEDEP}] )
  68. )
  69. fdk? ( >=media-libs/fdk-aac-0.1.2[${MULTILIB_USEDEP}] )
  70. frei0r? ( media-plugins/frei0r-plugins )
  71. gsm? ( >=media-sound/gsm-1.0.13-r1[${MULTILIB_USEDEP}] )
  72. ieee1394? (
  73. >=media-libs/libdc1394-2.2.1[${MULTILIB_USEDEP}]
  74. >=sys-libs/libraw1394-2.1.0-r1[${MULTILIB_USEDEP}]
  75. )
  76. jack? ( >=media-sound/jack-audio-connection-kit-0.121.3-r1[${MULTILIB_USEDEP}] )
  77. jpeg2k? ( >=media-libs/openjpeg-1.5.0:0[${MULTILIB_USEDEP}] )
  78. opus? ( >=media-libs/opus-1.0.2-r2[${MULTILIB_USEDEP}] )
  79. pulseaudio? ( >=media-sound/pulseaudio-2.1-r1[${MULTILIB_USEDEP}] )
  80. rtmp? ( >=media-video/rtmpdump-2.4_p20131018[${MULTILIB_USEDEP}] )
  81. ssl? (
  82. openssl? (
  83. !libressl? ( >=dev-libs/openssl-1.0.1h-r2:0[${MULTILIB_USEDEP}] )
  84. libressl? ( dev-libs/libressl[${MULTILIB_USEDEP}] )
  85. )
  86. !openssl? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}] )
  87. )
  88. sdl? ( >=media-libs/libsdl-1.2.15-r4[sound,video,${MULTILIB_USEDEP}] )
  89. schroedinger? ( >=media-libs/schroedinger-1.0.11-r1[${MULTILIB_USEDEP}] )
  90. speex? ( >=media-libs/speex-1.2_rc1-r1[${MULTILIB_USEDEP}] )
  91. truetype? ( >=media-libs/freetype-2.5.0.1:2[${MULTILIB_USEDEP}] )
  92. fontconfig? ( >=media-libs/fontconfig-2.10[${MULTILIB_USEDEP}] )
  93. vaapi? ( >=x11-libs/libva-1.2.1-r1[${MULTILIB_USEDEP}] )
  94. vdpau? ( >=x11-libs/libvdpau-0.7[${MULTILIB_USEDEP}] )
  95. vpx? ( >=media-libs/libvpx-1.2.0_pre20130625[${MULTILIB_USEDEP}] )
  96. X? (
  97. >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
  98. >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
  99. >=x11-libs/libXfixes-5.0.1[${MULTILIB_USEDEP}]
  100. )
  101. zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
  102. "
  103. DEPEND="${RDEPEND}
  104. >=sys-devel/make-3.81
  105. doc? ( app-text/texi2html )
  106. ieee1394? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  107. cpu_flags_x86_mmx? ( dev-lang/yasm )
  108. rtmp? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  109. schroedinger? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  110. ssl? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  111. test? ( sys-devel/bc )
  112. truetype? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  113. fontconfig? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
  114. v4l? ( sys-kernel/linux-headers )
  115. "
  116. RDEPEND="${RDEPEND}
  117. abi_x86_32? ( !<=app-emulation/emul-linux-x86-medialibs-20140508-r3
  118. !app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)] )"
  119. # faac can't be binary distributed
  120. # openssl support marked as nonfree
  121. # faac and aac are concurent implementations
  122. # amr and aac require at least lgpl3
  123. # x264 requires gpl2
  124. REQUIRED_USE="
  125. rtmp? ( network )
  126. amr? ( gpl ) aac? ( gpl ) x264? ( gpl ) X? ( gpl ) cdio? ( gpl ) x265? ( gpl )
  127. test? ( encode zlib )
  128. fontconfig? ( truetype )
  129. "
  130. RESTRICT="faac? ( bindist ) fdk? ( bindist ) openssl? ( bindist )"
  131. MULTILIB_WRAPPED_HEADERS=(
  132. /usr/include/libavutil/avconfig.h
  133. )
  134. src_unpack() {
  135. [[ ${PV} == *9999 ]] && git-r3_src_unpack
  136. # 9999 does not have fate-*.tar.xz
  137. [[ ${PV%9999} != "" ]] && default_src_unpack
  138. }
  139. src_prepare() {
  140. epatch_user
  141. epatch "${FILESDIR}"/libav-11.3-libvpx-1.5.0.patch #565696
  142. # if we have snapshot then we need to hardcode the version
  143. if [[ ${PV%_p*} != ${PV} ]]; then
  144. sed -i -e "s/UNKNOWN/DATE-${PV#*_pre}/" "${S}/version.sh" || die
  145. fi
  146. TOOLS=( aviocat graph2dot ismindex pktdumper qt-faststart trasher )
  147. use zlib && TOOLS+=( cws2fws )
  148. MAKEOPTS+=" V=1"
  149. }
  150. multilib_src_configure() {
  151. local myconf=( ${EXTRA_LIBAV_CONF} )
  152. local uses i
  153. # 9999 does not have fate-*.tar.xz
  154. [[ ${PV%9999} != "" ]] && use test && myconf+=( --samples="${WORKDIR}/fate" )
  155. myconf+=(
  156. $(use_enable gpl)
  157. $(use_enable gpl version3)
  158. # It is a security concern and removed in the next version
  159. --disable-protocol=concat
  160. )
  161. # enabled by default
  162. uses="debug doc network zlib"
  163. for i in ${uses}; do
  164. use ${i} || myconf+=( --disable-${i} )
  165. done
  166. use bzip2 || myconf+=( --disable-bzlib )
  167. use sdl || myconf+=( --disable-avplay )
  168. if use ssl; then
  169. use openssl && myconf+=( --enable-openssl --enable-nonfree ) \
  170. || myconf+=( --enable-gnutls )
  171. fi
  172. use custom-cflags && myconf+=( --disable-optimizations )
  173. use cpudetection && myconf+=( --enable-runtime-cpudetect )
  174. use vdpau || myconf+=( --disable-vdpau )
  175. use vaapi && myconf+=( --enable-vaapi )
  176. # Encoders
  177. if use encode; then
  178. use faac && myconf+=( --enable-nonfree )
  179. use mp3 && myconf+=( --enable-libmp3lame )
  180. use amr && myconf+=( --enable-libvo-amrwbenc )
  181. use aac && myconf+=( --enable-libvo-aacenc )
  182. uses="faac theora twolame vorbis wavpack webp x264 x265 xvid"
  183. for i in ${uses}; do
  184. use ${i} && myconf+=( --enable-lib${i} )
  185. done
  186. else
  187. myconf+=( --disable-encoders )
  188. fi
  189. # libavdevice options
  190. use cdio && myconf+=( --enable-libcdio )
  191. use ieee1394 && myconf+=( --enable-libdc1394 )
  192. use pulseaudio && myconf+=( --enable-libpulse )
  193. # Indevs
  194. # v4l1 is gone since linux-headers-2.6.38
  195. myconf+=( --disable-indev=v4l )
  196. use v4l || myconf+=( --disable-indev=v4l2 )
  197. for i in alsa oss jack; do
  198. use ${i} || myconf+=( --disable-indev=${i} )
  199. done
  200. use X && myconf+=( --enable-x11grab )
  201. # Outdevs
  202. for i in alsa oss ; do
  203. use ${i} || myconf+=( --disable-outdev=${i} )
  204. done
  205. # libavfilter options
  206. use bs2b && myconf+=( --enable-libbs2b )
  207. multilib_is_native_abi && use frei0r && myconf+=( --enable-frei0r )
  208. use truetype && myconf+=( --enable-libfreetype )
  209. use fontconfig && myconf+=( --enable-libfontconfig )
  210. # Threads; we only support pthread for now
  211. use threads && myconf+=( --enable-pthreads )
  212. # Decoders
  213. use amr && myconf+=( --enable-libopencore-amrwb --enable-libopencore-amrnb )
  214. use fdk && myconf+=( --enable-nonfree --enable-libfdk-aac )
  215. uses="gsm opus rtmp schroedinger speex vpx"
  216. for i in ${uses}; do
  217. use ${i} && myconf+=( --enable-lib${i} )
  218. done
  219. use jpeg2k && myconf+=( --enable-libopenjpeg )
  220. # CPU features
  221. for i in ${CPU_FEATURES}; do
  222. use ${i%:*} || myconf+=( --disable-${i#*:} )
  223. done
  224. # pass the right -mfpu as extra
  225. use neon && append-cflags -mfpu=neon
  226. # disable mmx accelerated code if PIC is required
  227. # as the provided asm decidedly is not PIC for x86.
  228. if use pic && [[ ${ABI} == x86 ]]; then
  229. myconf+=( --disable-mmx --disable-mmxext )
  230. fi
  231. # Option to force building pic
  232. use pic && myconf+=( --enable-pic )
  233. # cross compile support
  234. if tc-is-cross-compiler ; then
  235. myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- )
  236. case ${CHOST} in
  237. *freebsd*)
  238. myconf+=( --target-os=freebsd )
  239. ;;
  240. mingw32*)
  241. myconf+=( --target-os=mingw32 )
  242. ;;
  243. *linux*)
  244. myconf+=( --target-os=linux )
  245. ;;
  246. esac
  247. fi
  248. # Misc stuff
  249. use hardcoded-tables && myconf+=( --enable-hardcoded-tables )
  250. # Specific workarounds for too-few-registers arch...
  251. if [[ ${ABI} == x86 ]]; then
  252. local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}
  253. filter-flags -fforce-addr -momit-leaf-frame-pointer
  254. append-flags -fomit-frame-pointer
  255. is-flag -O? || append-flags -O2
  256. if use debug; then
  257. # no need to warn about debug if not using debug flag
  258. ewarn ""
  259. ewarn "Debug information will be almost useless as the frame pointer is omitted."
  260. ewarn "This makes debugging harder, so crashes that has no fixed behavior are"
  261. ewarn "difficult to fix. Please have that in mind."
  262. ewarn ""
  263. fi
  264. fi
  265. set -- "${S}"/configure \
  266. --prefix="${EPREFIX}"/usr \
  267. --libdir="${EPREFIX}"/usr/$(get_libdir) \
  268. --shlibdir="${EPREFIX}"/usr/$(get_libdir) \
  269. --mandir="${EPREFIX}"/usr/share/man \
  270. --enable-shared \
  271. --cc="$(tc-getCC)" \
  272. --ar="$(tc-getAR)" \
  273. --optflags="${CFLAGS}" \
  274. --extra-cflags="${CFLAGS}" \
  275. $(use_enable static-libs static) \
  276. "${myconf[@]}"
  277. echo "${@}"
  278. "${@}" || die
  279. }
  280. multilib_src_compile() {
  281. emake
  282. if use tools; then
  283. tc-export CC
  284. emake ${TOOLS[@]/#/tools/}
  285. fi
  286. }
  287. multilib_src_install() {
  288. emake DESTDIR="${D}" install install-man
  289. use doc && dodoc doc/*.html
  290. if use tools; then
  291. dobin ${TOOLS[@]/#/tools/}
  292. fi
  293. }
  294. multilib_src_install_all() {
  295. dodoc Changelog README.md INSTALL
  296. }
  297. multilib_src_test() {
  298. local _libs="$(for i in lib*/;do echo -n "${BUILD_DIR}/${i%/}:";done)"
  299. einfo "LD_LIBRARY_PATH is set to \"${_libs}\""
  300. LD_LIBRARY_PATH="${_libs}" emake -k -j1 fate
  301. }