libav-9999.ebuild 11 KB

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