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