Use https by default
[gentoo.git] / media-video / libav / libav-9999.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 inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
8
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}"}
13         fi
14         inherit git-r3
15 fi
16
17 DESCRIPTION="Complete solution to record, convert and stream audio and video"
18 HOMEPAGE="https://libav.org/"
19 if [[ ${PV} == *9999 ]] ; then
20         SRC_URI=""
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"
25 fi
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 )"
28
29 LICENSE="LGPL-2.1  gpl? ( GPL-3 )"
30 SLOT="0/12"
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"
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="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#*:}"
46 done
47 for i in ${CPU_FEATURES} ; do
48         IUSE+=" ${i%:*}"
49 done
50
51 RDEPEND="
52         !media-video/ffmpeg:0
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}] )
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                 mp3? ( >=media-sound/lame-3.99.5-r1[${MULTILIB_USEDEP}] )
63                 theora? (
64                         >=media-libs/libtheora-1.1.1[encode,${MULTILIB_USEDEP}]
65                         >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
66                 )
67                 twolame? ( >=media-sound/twolame-0.3.13-r1[${MULTILIB_USEDEP}] )
68                 vorbis? (
69                         >=media-libs/libvorbis-1.3.3-r1[${MULTILIB_USEDEP}]
70                         >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
71                 )
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}] )
77         )
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}] )
81         ieee1394? (
82                 >=media-libs/libdc1394-2.2.1[${MULTILIB_USEDEP}]
83                 >=sys-libs/libraw1394-2.1.0-r1[${MULTILIB_USEDEP}]
84         )
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}] )
90         ssl? (
91                 openssl? ( >=dev-libs/openssl-1.0.1h-r2[${MULTILIB_USEDEP}] )
92                 !openssl? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}] )
93         )
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}] )
102         X? (
103                 >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
104                 >=x11-libs/libxcb-1.9.1[${MULTILIB_USEDEP}]
105         )
106         zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )
107 "
108
109 DEPEND="${RDEPEND}
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 )
121 "
122
123 RDEPEND="${RDEPEND}
124         abi_x86_32? ( !<=app-emulation/emul-linux-x86-medialibs-20140508-r3
125                 !app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)] )"
126
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
131 # x264 requires gpl2
132 REQUIRED_USE="
133         rtmp? ( network )
134         amr? ( gpl ) aac? ( gpl ) x264? ( gpl ) X? ( gpl ) cdio? ( gpl ) x265? ( gpl )
135         test? ( encode zlib )
136         fontconfig? ( truetype )
137 "
138 RESTRICT="faac? ( bindist ) fdk? ( bindist ) openssl? ( bindist )"
139
140 MULTILIB_WRAPPED_HEADERS=(
141         /usr/include/libavutil/avconfig.h
142 )
143
144 src_unpack() {
145         [[ ${PV} == *9999 ]] && git-r3_src_unpack
146         # 9999 does not have fate-*.tar.xz
147         [[ ${PV%9999} != "" ]] && default_src_unpack
148 }
149
150 src_prepare() {
151         epatch_user
152
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
156         fi
157
158         TOOLS=( aviocat graph2dot ismindex pktdumper qt-faststart trasher )
159         use zlib && TOOLS+=( cws2fws )
160
161         MAKEOPTS+=" V=1"
162 }
163
164 multilib_src_configure() {
165         local myconf=( ${EXTRA_LIBAV_CONF} )
166         local uses i
167
168         # 9999 does not have fate-*.tar.xz
169         [[ ${PV%9999} != "" ]] && use test && myconf+=( --samples="${WORKDIR}/fate" )
170
171         myconf+=(
172                 $(use_enable gpl)
173                 $(use_enable gpl version3)
174                 --enable-avfilter
175         )
176
177         # enabled by default
178         uses="debug doc network zlib"
179         for i in ${uses}; do
180                 use ${i} || myconf+=( --disable-${i} )
181         done
182         use bzip2 || myconf+=( --disable-bzlib )
183         use sdl || myconf+=( --disable-avplay )
184
185         if use ssl; then
186                 use openssl && myconf+=( --enable-openssl --enable-nonfree ) \
187                         || myconf+=( --enable-gnutls )
188         fi
189
190         use custom-cflags && myconf+=( --disable-optimizations )
191         use cpudetection && myconf+=( --enable-runtime-cpudetect )
192
193         use vdpau || myconf+=( --disable-vdpau )
194
195         use vaapi && myconf+=( --enable-vaapi )
196
197         # Encoders
198         if use encode; then
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"
204                 for i in ${uses}; do
205                         use ${i} && myconf+=( --enable-lib${i} )
206                 done
207         else
208                 myconf+=( --disable-encoders )
209         fi
210
211         # libavdevice options
212         use cdio && myconf+=( --enable-libcdio )
213         use ieee1394 && myconf+=( --enable-libdc1394 )
214         use pulseaudio && myconf+=( --enable-libpulse )
215
216         # Indevs
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} )
222         done
223         use X && myconf+=( --enable-libxcb )
224         # Outdevs
225         for i in alsa oss ; do
226                 use ${i} || myconf+=( --disable-outdev=${i} )
227         done
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 )
233
234         # Threads; we only support pthread for now
235         use threads && myconf+=( --enable-pthreads )
236
237         # Decoders
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"
241         for i in ${uses}; do
242                 use ${i} && myconf+=( --enable-lib${i} )
243         done
244         use jpeg2k && myconf+=( --enable-libopenjpeg )
245
246         # CPU features
247         for i in ${CPU_FEATURES}; do
248                 use ${i%:*} || myconf+=( --disable-${i#*:} )
249         done
250
251         # pass the right -mfpu as extra
252         use neon && append-cflags -mfpu=neon
253
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 )
258         fi
259
260         # Option to force building pic
261         use pic && myconf+=( --enable-pic )
262
263         # cross compile support
264         if tc-is-cross-compiler ; then
265                 myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- )
266                 case ${CHOST} in
267                         *freebsd*)
268                                 myconf+=( --target-os=freebsd )
269                                 ;;
270                         mingw32*)
271                                 myconf+=( --target-os=mingw32 )
272                                 ;;
273                         *linux*)
274                                 myconf+=( --target-os=linux )
275                                 ;;
276                 esac
277         fi
278
279         # Misc stuff
280         use hardcoded-tables && myconf+=( --enable-hardcoded-tables )
281
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
288                 if use debug; then
289                         # no need to warn about debug if not using debug flag
290                         ewarn ""
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."
294                         ewarn ""
295                 fi
296         fi
297
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 \
303                 --enable-shared \
304                 --cc="$(tc-getCC)" \
305                 --ar="$(tc-getAR)" \
306                 --optflags="${CFLAGS}" \
307                 --extra-cflags="${CFLAGS}" \
308                 $(use_enable static-libs static) \
309                 "${myconf[@]}"
310         echo "${@}"
311         "${@}" || die
312 }
313
314 multilib_src_compile() {
315         emake
316
317         if use tools; then
318                 tc-export CC
319
320                 emake ${TOOLS[@]/#/tools/}
321         fi
322 }
323
324 multilib_src_install() {
325         emake DESTDIR="${D}" install install-man
326         use doc && dodoc doc/*.html
327
328         if use tools; then
329                 dobin ${TOOLS[@]/#/tools/}
330         fi
331 }
332
333 multilib_src_install_all() {
334         dodoc Changelog README.md INSTALL
335 }
336
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
341 }