Line 0
Link Here
|
|
|
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 |
SRC_URI+=" https://dev.gentoo.org/~lu_zero/libav/patches/0001-x86-Put-COPY3_IF_LT-under-HAVE_6REGS.patch.gz" |
26 |
fi |
27 |
# 9999 does not have fate-*.tar.xz |
28 |
[[ ${PV%9999} != "" ]] && SRC_URI+=" test? ( https://dev.gentoo.org/~lu_zero/libav/fate-${PV%%.*}.tar.xz )" |
29 |
|
30 |
LICENSE="LGPL-2.1 gpl? ( GPL-3 )" |
31 |
SLOT="0/11" |
32 |
[[ ${PV} == *9999 ]] || \ |
33 |
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" |
34 |
IUSE="aac alsa amr bs2b +bzip2 cdio cpudetection custom-cflags debug doc +encode faac fdk |
35 |
frei0r fontconfig gnutls +gpl gsm +hardcoded-tables ieee1394 jack jpeg2k libressl mp3 |
36 |
+network 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 |
!gnutls? ( !libressl? ( >=dev-libs/openssl-1.0.1h-r2:0[${MULTILIB_USEDEP}] ) ) |
92 |
gnutls? ( >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}] ) |
93 |
libressl? ( dev-libs/libressl[${MULTILIB_USEDEP}] ) |
94 |
) |
95 |
sdl? ( >=media-libs/libsdl-1.2.15-r4[sound,video,${MULTILIB_USEDEP}] ) |
96 |
schroedinger? ( >=media-libs/schroedinger-1.0.11-r1[${MULTILIB_USEDEP}] ) |
97 |
speex? ( >=media-libs/speex-1.2_rc1-r1[${MULTILIB_USEDEP}] ) |
98 |
truetype? ( >=media-libs/freetype-2.5.0.1:2[${MULTILIB_USEDEP}] ) |
99 |
fontconfig? ( >=media-libs/fontconfig-2.10[${MULTILIB_USEDEP}] ) |
100 |
vaapi? ( >=x11-libs/libva-1.2.1-r1[${MULTILIB_USEDEP}] ) |
101 |
vdpau? ( >=x11-libs/libvdpau-0.7[${MULTILIB_USEDEP}] ) |
102 |
vpx? ( >=media-libs/libvpx-1.2.0_pre20130625[${MULTILIB_USEDEP}] ) |
103 |
X? ( |
104 |
>=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}] |
105 |
>=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}] |
106 |
>=x11-libs/libXfixes-5.0.1[${MULTILIB_USEDEP}] |
107 |
) |
108 |
zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] ) |
109 |
" |
110 |
|
111 |
DEPEND="${RDEPEND} |
112 |
>=sys-devel/make-3.81 |
113 |
doc? ( app-text/texi2html ) |
114 |
ieee1394? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
115 |
cpu_flags_x86_mmx? ( dev-lang/yasm ) |
116 |
rtmp? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
117 |
schroedinger? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
118 |
ssl? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
119 |
test? ( sys-devel/bc ) |
120 |
truetype? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
121 |
fontconfig? ( >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] ) |
122 |
v4l? ( sys-kernel/linux-headers ) |
123 |
" |
124 |
|
125 |
RDEPEND="${RDEPEND} |
126 |
abi_x86_32? ( !<=app-emulation/emul-linux-x86-medialibs-20140508-r3 |
127 |
!app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)] )" |
128 |
|
129 |
# faac can't be binary distributed |
130 |
# openssl support marked as nonfree |
131 |
# faac and aac are concurent implementations |
132 |
# amr and aac require at least lgpl3 |
133 |
# x264 requires gpl2 |
134 |
REQUIRED_USE=" |
135 |
rtmp? ( network ) |
136 |
amr? ( gpl ) aac? ( gpl ) x264? ( gpl ) X? ( gpl ) cdio? ( gpl ) x265? ( gpl ) |
137 |
test? ( encode zlib ) |
138 |
fontconfig? ( truetype ) |
139 |
?? ( gnutls libressl ) |
140 |
" |
141 |
RESTRICT="faac? ( bindist ) fdk? ( bindist ) !gnutls? ( !libressl? ( bindist ) )" |
142 |
|
143 |
MULTILIB_WRAPPED_HEADERS=( |
144 |
/usr/include/libavutil/avconfig.h |
145 |
) |
146 |
|
147 |
src_unpack() { |
148 |
[[ ${PV} == *9999 ]] && git-r3_src_unpack |
149 |
# 9999 does not have fate-*.tar.xz |
150 |
[[ ${PV%9999} != "" ]] && default_src_unpack |
151 |
} |
152 |
|
153 |
src_prepare() { |
154 |
epatch_user |
155 |
|
156 |
epatch "${WORKDIR}/0001-x86-Put-COPY3_IF_LT-under-HAVE_6REGS.patch" |
157 |
|
158 |
# if we have snapshot then we need to hardcode the version |
159 |
if [[ ${PV%_p*} != ${PV} ]]; then |
160 |
sed -i -e "s/UNKNOWN/DATE-${PV#*_pre}/" "${S}/version.sh" || die |
161 |
fi |
162 |
|
163 |
TOOLS=( aviocat graph2dot ismindex pktdumper qt-faststart trasher ) |
164 |
use zlib && TOOLS+=( cws2fws ) |
165 |
|
166 |
MAKEOPTS+=" V=1" |
167 |
} |
168 |
|
169 |
multilib_src_configure() { |
170 |
local myconf=( ${EXTRA_LIBAV_CONF} ) |
171 |
local uses i |
172 |
|
173 |
# 9999 does not have fate-*.tar.xz |
174 |
[[ ${PV%9999} != "" ]] && use test && myconf+=( --samples="${WORKDIR}/fate" ) |
175 |
|
176 |
myconf+=( |
177 |
$(use_enable gpl) |
178 |
$(use_enable gpl version3) |
179 |
--enable-avfilter |
180 |
) |
181 |
|
182 |
# enabled by default |
183 |
uses="debug doc network zlib" |
184 |
for i in ${uses}; do |
185 |
use ${i} || myconf+=( --disable-${i} ) |
186 |
done |
187 |
use bzip2 || myconf+=( --disable-bzlib ) |
188 |
use sdl || myconf+=( --disable-avplay ) |
189 |
|
190 |
if use ssl; then |
191 |
use !gnutls && myconf+=( --enable-openssl --enable-nonfree ) \ |
192 |
|| myconf+=( --enable-gnutls ) |
193 |
fi |
194 |
|
195 |
use custom-cflags && myconf+=( --disable-optimizations ) |
196 |
use cpudetection && myconf+=( --enable-runtime-cpudetect ) |
197 |
|
198 |
use vdpau || myconf+=( --disable-vdpau ) |
199 |
|
200 |
use vaapi && myconf+=( --enable-vaapi ) |
201 |
|
202 |
# Encoders |
203 |
if use encode; then |
204 |
use faac && myconf+=( --enable-nonfree ) |
205 |
use mp3 && myconf+=( --enable-libmp3lame ) |
206 |
use amr && myconf+=( --enable-libvo-amrwbenc ) |
207 |
use aac && myconf+=( --enable-libvo-aacenc ) |
208 |
uses="faac theora twolame vorbis wavpack webp x264 x265 xvid" |
209 |
for i in ${uses}; do |
210 |
use ${i} && myconf+=( --enable-lib${i} ) |
211 |
done |
212 |
else |
213 |
myconf+=( --disable-encoders ) |
214 |
fi |
215 |
|
216 |
# libavdevice options |
217 |
use cdio && myconf+=( --enable-libcdio ) |
218 |
use ieee1394 && myconf+=( --enable-libdc1394 ) |
219 |
use pulseaudio && myconf+=( --enable-libpulse ) |
220 |
|
221 |
# Indevs |
222 |
# v4l1 is gone since linux-headers-2.6.38 |
223 |
myconf+=( --disable-indev=v4l ) |
224 |
use v4l || myconf+=( --disable-indev=v4l2 ) |
225 |
for i in alsa oss jack; do |
226 |
use ${i} || myconf+=( --disable-indev=${i} ) |
227 |
done |
228 |
use X && myconf+=( --enable-x11grab ) |
229 |
# Outdevs |
230 |
for i in alsa oss ; do |
231 |
use ${i} || myconf+=( --disable-outdev=${i} ) |
232 |
done |
233 |
# libavfilter options |
234 |
use bs2b && myconf+=( --enable-libbs2b ) |
235 |
multilib_is_native_abi && use frei0r && myconf+=( --enable-frei0r ) |
236 |
use truetype && myconf+=( --enable-libfreetype ) |
237 |
use fontconfig && myconf+=( --enable-libfontconfig ) |
238 |
|
239 |
# Threads; we only support pthread for now |
240 |
use threads && myconf+=( --enable-pthreads ) |
241 |
|
242 |
# Decoders |
243 |
use amr && myconf+=( --enable-libopencore-amrwb --enable-libopencore-amrnb ) |
244 |
use fdk && myconf+=( --enable-nonfree --enable-libfdk-aac ) |
245 |
uses="gsm opus rtmp schroedinger speex vpx" |
246 |
for i in ${uses}; do |
247 |
use ${i} && myconf+=( --enable-lib${i} ) |
248 |
done |
249 |
use jpeg2k && myconf+=( --enable-libopenjpeg ) |
250 |
|
251 |
# CPU features |
252 |
for i in ${CPU_FEATURES}; do |
253 |
use ${i%:*} || myconf+=( --disable-${i#*:} ) |
254 |
done |
255 |
|
256 |
# pass the right -mfpu as extra |
257 |
use neon && append-cflags -mfpu=neon |
258 |
|
259 |
# disable mmx accelerated code if PIC is required |
260 |
# as the provided asm decidedly is not PIC for x86. |
261 |
if use pic && [[ ${ABI} == x86 ]]; then |
262 |
myconf+=( --disable-mmx --disable-mmxext ) |
263 |
fi |
264 |
|
265 |
# Option to force building pic |
266 |
use pic && myconf+=( --enable-pic ) |
267 |
|
268 |
# cross compile support |
269 |
if tc-is-cross-compiler ; then |
270 |
myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- ) |
271 |
case ${CHOST} in |
272 |
*freebsd*) |
273 |
myconf+=( --target-os=freebsd ) |
274 |
;; |
275 |
mingw32*) |
276 |
myconf+=( --target-os=mingw32 ) |
277 |
;; |
278 |
*linux*) |
279 |
myconf+=( --target-os=linux ) |
280 |
;; |
281 |
esac |
282 |
fi |
283 |
|
284 |
# Misc stuff |
285 |
use hardcoded-tables && myconf+=( --enable-hardcoded-tables ) |
286 |
|
287 |
# Specific workarounds for too-few-registers arch... |
288 |
if [[ ${ABI} == x86 ]]; then |
289 |
local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS} |
290 |
filter-flags -fforce-addr -momit-leaf-frame-pointer |
291 |
append-flags -fomit-frame-pointer |
292 |
is-flag -O? || append-flags -O2 |
293 |
if use debug; then |
294 |
# no need to warn about debug if not using debug flag |
295 |
ewarn "" |
296 |
ewarn "Debug information will be almost useless as the frame pointer is omitted." |
297 |
ewarn "This makes debugging harder, so crashes that has no fixed behavior are" |
298 |
ewarn "difficult to fix. Please have that in mind." |
299 |
ewarn "" |
300 |
fi |
301 |
fi |
302 |
|
303 |
set -- "${S}"/configure \ |
304 |
--prefix="${EPREFIX}"/usr \ |
305 |
--libdir="${EPREFIX}"/usr/$(get_libdir) \ |
306 |
--shlibdir="${EPREFIX}"/usr/$(get_libdir) \ |
307 |
--mandir="${EPREFIX}"/usr/share/man \ |
308 |
--enable-shared \ |
309 |
--cc="$(tc-getCC)" \ |
310 |
--ar="$(tc-getAR)" \ |
311 |
--optflags="${CFLAGS}" \ |
312 |
--extra-cflags="${CFLAGS}" \ |
313 |
$(use_enable static-libs static) \ |
314 |
"${myconf[@]}" |
315 |
echo "${@}" |
316 |
"${@}" || die |
317 |
} |
318 |
|
319 |
multilib_src_compile() { |
320 |
emake |
321 |
|
322 |
if use tools; then |
323 |
tc-export CC |
324 |
|
325 |
emake ${TOOLS[@]/#/tools/} |
326 |
fi |
327 |
} |
328 |
|
329 |
multilib_src_install() { |
330 |
emake DESTDIR="${D}" install install-man |
331 |
use doc && dodoc doc/*.html |
332 |
|
333 |
if use tools; then |
334 |
dobin ${TOOLS[@]/#/tools/} |
335 |
fi |
336 |
} |
337 |
|
338 |
multilib_src_install_all() { |
339 |
dodoc Changelog README.md INSTALL |
340 |
} |
341 |
|
342 |
multilib_src_test() { |
343 |
local _libs="$(for i in lib*/;do echo -n "${BUILD_DIR}/${i%/}:";done)" |
344 |
einfo "LD_LIBRARY_PATH is set to \"${_libs}\"" |
345 |
LD_LIBRARY_PATH="${_libs}" emake -k -j1 fate |
346 |
} |