1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
9 if [[ ${PV} == *9999 ]] ; then
10 : ${EGIT_REPO_URI:="git://git.libav.org/libav.git"}
11 if [[ ${PV%9999} != "" ]] ; then
12 : ${EGIT_BRANCH:="release/${PV%.9999}"}
17 DESCRIPTION="Complete solution to record, convert and stream audio and video"
18 HOMEPAGE="https://libav.org/"
19 if [[ ${PV} == *9999 ]] ; then
21 elif [[ ${PV%_p*} != ${PV} ]] ; then # Gentoo snapshot
22 SRC_URI="https://dev.gentoo.org/~lu_zero/libav/${P}.tar.xz"
23 else # Official release
24 SRC_URI="https://libav.org/releases/${P}.tar.xz"
26 # 9999 does not have fate-*.tar.xz
27 [[ ${PV%9999} != "" ]] && SRC_URI+=" test? ( https://dev.gentoo.org/~lu_zero/libav/fate-${PV%%.*}.tar.xz )"
29 LICENSE="LGPL-2.1 gpl? ( GPL-3 )"
31 [[ ${PV} == *9999 ]] || KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64
32 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos
33 ~x64-solaris ~x86-solaris"
34 IUSE="aac alsa amr bs2b +bzip2 cdio cpudetection custom-cflags debug doc +encode faac fdk
35 frei0r fontconfig +gpl gsm +hardcoded-tables ieee1394 jack jpeg2k mp3
36 +network openssl opus oss pic pulseaudio rtmp schroedinger sdl speex ssl
37 static-libs test theora threads tools truetype twolame v4l vaapi vdpau vorbis vpx X
38 wavpack webp x264 x265 xvid +zlib"
40 # String for CPU features in the useflag[:configure_option] form
41 # if :configure_option isn't set, it will use 'useflag' as configure option
42 CPU_FEATURES="altivec armv5te armv6 armv6t2 armvfp:vfp neon"
43 X86_CPU_FEATURES="3dnow:amd3dnow 3dnowext:amd3dnowext mmx mmxext sse sse2 sse3 ssse3 sse4_1:sse4 sse4_2:sse42 avx xop fma3 fma4 avx2"
44 for i in ${X86_CPU_FEATURES} ; do
45 CPU_FEATURES+=" cpu_flags_x86_${i%:*}:${i#*:}"
47 for i in ${CPU_FEATURES} ; do
53 alsa? ( >=media-libs/alsa-lib-1.0.27.2[${MULTILIB_USEDEP}] )
54 amr? ( >=media-libs/opencore-amr-0.1.3-r1[${MULTILIB_USEDEP}] )
55 bs2b? ( >=media-libs/libbs2b-3.1.0-r1[${MULTILIB_USEDEP}] )
56 bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
57 cdio? ( >=dev-libs/libcdio-paranoia-0.90_p1-r1[${MULTILIB_USEDEP}] )
59 aac? ( >=media-libs/vo-aacenc-0.1.3[${MULTILIB_USEDEP}] )
60 amr? ( >=media-libs/vo-amrwbenc-0.1.2-r1[${MULTILIB_USEDEP}] )
61 faac? ( >=media-libs/faac-1.28-r3[${MULTILIB_USEDEP}] )
62 mp3? ( >=media-sound/lame-3.99.5-r1[${MULTILIB_USEDEP}] )
64 >=media-libs/libtheora-1.1.1[encode,${MULTILIB_USEDEP}]
65 >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
67 twolame? ( >=media-sound/twolame-0.3.13-r1[${MULTILIB_USEDEP}] )
69 >=media-libs/libvorbis-1.3.3-r1[${MULTILIB_USEDEP}]
70 >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
72 webp? ( >=media-libs/libwebp-0.3.0[${MULTILIB_USEDEP}] )
73 wavpack? ( >=media-sound/wavpack-4.60.1-r1[${MULTILIB_USEDEP}] )
74 x264? ( >=media-libs/x264-0.0.20130506:=[${MULTILIB_USEDEP}] )
75 x265? ( >=media-libs/x265-1.2:=[${MULTILIB_USEDEP}] )
76 xvid? ( >=media-libs/xvid-1.3.2-r1[${MULTILIB_USEDEP}] )
78 fdk? ( >=media-libs/fdk-aac-0.1.2[${MULTILIB_USEDEP}] )
79 frei0r? ( media-plugins/frei0r-plugins )
80 gsm? ( >=media-sound/gsm-1.0.13-r1[${MULTILIB_USEDEP}] )
82 >=media-libs/libdc1394-2.2.1[${MULTILIB_USEDEP}]
83 >=sys-libs/libraw1394-2.1.0-r1[${MULTILIB_USEDEP}]
85 jack? ( >=media-sound/jack-audio-connection-kit-0.121.3-r1[${MULTILIB_USEDEP}] )
86 jpeg2k? ( >=media-libs/openjpeg-1.5.0:0[${MULTILIB_USEDEP}] )
87 opus? ( >=media-libs/opus-1.0.2-r2[${MULTILIB_USEDEP}] )
88 pulseaudio? ( >=media-sound/pulseaudio-2.1-r1[${MULTILIB_USEDEP}] )
89 rtmp? ( >=media-video/rtmpdump-2.4_p20131018[${MULTILIB_USEDEP}] )
91 openssl? ( >=dev-libs/openssl-1.0.1h-r2[${MULTILIB_USEDEP}] )
92 !openssl? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}] )
94 sdl? ( >=media-libs/libsdl-1.2.15-r4[sound,video,${MULTILIB_USEDEP}] )
95 schroedinger? ( >=media-libs/schroedinger-1.0.11-r1[${MULTILIB_USEDEP}] )
96 speex? ( >=media-libs/speex-1.2_rc1-r1[${MULTILIB_USEDEP}] )
97 truetype? ( >=media-libs/freetype-2.5.0.1:2[${MULTILIB_USEDEP}] )
98 fontconfig? ( >=media-libs/fontconfig-2.10[${MULTILIB_USEDEP}] )
99 vaapi? ( >=x11-libs/libva-1.2.1-r1[${MULTILIB_USEDEP}] )
100 vdpau? ( >=x11-libs/libvdpau-0.7[${MULTILIB_USEDEP}] )
101 vpx? ( >=media-libs/libvpx-1.2.0_pre20130625[${MULTILIB_USEDEP}] )
103 >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
104 >=x11-libs/libxcb-1.9.1[${MULTILIB_USEDEP}]
106 zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
110 >=sys-devel/make-3.81
111 doc? ( app-text/texi2html )
112 ieee1394? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
113 cpu_flags_x86_mmx? ( dev-lang/yasm )
114 rtmp? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
115 schroedinger? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
116 ssl? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
117 test? ( sys-devel/bc )
118 truetype? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
119 fontconfig? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] )
120 v4l? ( sys-kernel/linux-headers )
124 abi_x86_32? ( !<=app-emulation/emul-linux-x86-medialibs-20140508-r3
125 !app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)] )"
127 # faac can't be binary distributed
128 # openssl support marked as nonfree
129 # faac and aac are concurent implementations
130 # amr and aac require at least lgpl3
134 amr? ( gpl ) aac? ( gpl ) x264? ( gpl ) X? ( gpl ) cdio? ( gpl ) x265? ( gpl )
135 test? ( encode zlib )
136 fontconfig? ( truetype )
138 RESTRICT="faac? ( bindist ) fdk? ( bindist ) openssl? ( bindist )"
140 MULTILIB_WRAPPED_HEADERS=(
141 /usr/include/libavutil/avconfig.h
145 [[ ${PV} == *9999 ]] && git-r3_src_unpack
146 # 9999 does not have fate-*.tar.xz
147 [[ ${PV%9999} != "" ]] && default_src_unpack
153 # if we have snapshot then we need to hardcode the version
154 if [[ ${PV%_p*} != ${PV} ]]; then
155 sed -i -e "s/UNKNOWN/DATE-${PV#*_pre}/" "${S}/version.sh" || die
158 TOOLS=( aviocat graph2dot ismindex pktdumper qt-faststart trasher )
159 use zlib && TOOLS+=( cws2fws )
164 multilib_src_configure() {
165 local myconf=( ${EXTRA_LIBAV_CONF} )
168 # 9999 does not have fate-*.tar.xz
169 [[ ${PV%9999} != "" ]] && use test && myconf+=( --samples="${WORKDIR}/fate" )
173 $(use_enable gpl version3)
178 uses="debug doc network zlib"
180 use ${i} || myconf+=( --disable-${i} )
182 use bzip2 || myconf+=( --disable-bzlib )
183 use sdl || myconf+=( --disable-avplay )
186 use openssl && myconf+=( --enable-openssl --enable-nonfree ) \
187 || myconf+=( --enable-gnutls )
190 use custom-cflags && myconf+=( --disable-optimizations )
191 use cpudetection && myconf+=( --enable-runtime-cpudetect )
193 use vdpau || myconf+=( --disable-vdpau )
195 use vaapi && myconf+=( --enable-vaapi )
199 use faac && myconf+=( --enable-nonfree )
200 use mp3 && myconf+=( --enable-libmp3lame )
201 use amr && myconf+=( --enable-libvo-amrwbenc )
202 use aac && myconf+=( --enable-libvo-aacenc )
203 uses="faac theora twolame vorbis wavpack webp x264 x265 xvid"
205 use ${i} && myconf+=( --enable-lib${i} )
208 myconf+=( --disable-encoders )
211 # libavdevice options
212 use cdio && myconf+=( --enable-libcdio )
213 use ieee1394 && myconf+=( --enable-libdc1394 )
214 use pulseaudio && myconf+=( --enable-libpulse )
217 # v4l1 is gone since linux-headers-2.6.38
218 myconf+=( --disable-indev=v4l )
219 use v4l || myconf+=( --disable-indev=v4l2 )
220 for i in alsa oss jack; do
221 use ${i} || myconf+=( --disable-indev=${i} )
223 use X && myconf+=( --enable-libxcb )
225 for i in alsa oss ; do
226 use ${i} || myconf+=( --disable-outdev=${i} )
228 # libavfilter options
229 use bs2b && myconf+=( --enable-libbs2b )
230 multilib_is_native_abi && use frei0r && myconf+=( --enable-frei0r )
231 use truetype && myconf+=( --enable-libfreetype )
232 use fontconfig && myconf+=( --enable-libfontconfig )
234 # Threads; we only support pthread for now
235 use threads && myconf+=( --enable-pthreads )
238 use amr && myconf+=( --enable-libopencore-amrwb --enable-libopencore-amrnb )
239 use fdk && myconf+=( --enable-nonfree --enable-libfdk-aac )
240 uses="gsm opus rtmp schroedinger speex vpx"
242 use ${i} && myconf+=( --enable-lib${i} )
244 use jpeg2k && myconf+=( --enable-libopenjpeg )
247 for i in ${CPU_FEATURES}; do
248 use ${i%:*} || myconf+=( --disable-${i#*:} )
251 # pass the right -mfpu as extra
252 use neon && append-cflags -mfpu=neon
254 # disable mmx accelerated code if PIC is required
255 # as the provided asm decidedly is not PIC for x86.
256 if use pic && [[ ${ABI} == x86 ]]; then
257 myconf+=( --disable-mmx --disable-mmxext )
260 # Option to force building pic
261 use pic && myconf+=( --enable-pic )
263 # cross compile support
264 if tc-is-cross-compiler ; then
265 myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- )
268 myconf+=( --target-os=freebsd )
271 myconf+=( --target-os=mingw32 )
274 myconf+=( --target-os=linux )
280 use hardcoded-tables && myconf+=( --enable-hardcoded-tables )
282 # Specific workarounds for too-few-registers arch...
283 if [[ ${ABI} == x86 ]]; then
284 local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}
285 filter-flags -fforce-addr -momit-leaf-frame-pointer
286 append-flags -fomit-frame-pointer
287 is-flag -O? || append-flags -O2
289 # no need to warn about debug if not using debug flag
291 ewarn "Debug information will be almost useless as the frame pointer is omitted."
292 ewarn "This makes debugging harder, so crashes that has no fixed behavior are"
293 ewarn "difficult to fix. Please have that in mind."
298 set -- "${S}"/configure \
299 --prefix="${EPREFIX}"/usr \
300 --libdir="${EPREFIX}"/usr/$(get_libdir) \
301 --shlibdir="${EPREFIX}"/usr/$(get_libdir) \
302 --mandir="${EPREFIX}"/usr/share/man \
306 --optflags="${CFLAGS}" \
307 --extra-cflags="${CFLAGS}" \
308 $(use_enable static-libs static) \
314 multilib_src_compile() {
320 emake ${TOOLS[@]/#/tools/}
324 multilib_src_install() {
325 emake DESTDIR="${D}" install install-man
326 use doc && dodoc doc/*.html
329 dobin ${TOOLS[@]/#/tools/}
333 multilib_src_install_all() {
334 dodoc Changelog README.md INSTALL
337 multilib_src_test() {
338 local _libs="$(for i in lib*/;do echo -n "${BUILD_DIR}/${i%/}:";done)"
339 einfo "LD_LIBRARY_PATH is set to \"${_libs}\""
340 LD_LIBRARY_PATH="${_libs}" emake -k -j1 fate