10l: set genre default immediately before reading genre tag
[libav.git] / configure
CommitLineData
aeb29222 1#!/bin/sh
0f3cb305 2#
f57620d5
MR
3# FFmpeg configure script
4#
949906ea
DB
5# Copyright (c) 2000-2002 Fabrice Bellard
6# Copyright (c) 2005-2008 Diego Biurrun
7# Copyright (c) 2005-2008 Mans Rullgard
0f3cb305 8#
cf9d24ad 9
31e647f8 10# Prevent locale nonsense from breaking basic text processing.
79ab96ba
DB
11LC_ALL=C
12export LC_ALL
31e647f8 13
cde2d79a 14# make sure we are running under a compatible shell
c21d6325
MR
15# try to make this part work with most shells
16
17try_exec(){
0dbe81bb 18 echo "Trying shell $1"
2270b4b2 19 type "$1" > /dev/null 2>&1 && exec "$@"
c21d6325
MR
20}
21
5237ce67 22unset foo
2270b4b2 23(: ${foo%%bar}) 2> /dev/null
0dbe81bb
MR
24E1="$?"
25
2270b4b2 26(: ${foo?}) 2> /dev/null
0dbe81bb
MR
27E2="$?"
28
29if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
31 export FF_CONF_EXEC
32 if test "0$FF_CONF_EXEC" -lt 1; then
33 FF_CONF_EXEC=1
34 try_exec bash "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 2; then
37 FF_CONF_EXEC=2
38 try_exec ksh "$0" "$@"
39 fi
40 if test "0$FF_CONF_EXEC" -lt 3; then
41 FF_CONF_EXEC=3
42 try_exec /usr/xpg4/bin/sh "$0" "$@"
cde2d79a
MR
43 fi
44 echo "No compatible shell script interpreter found."
fc53da20 45 echo "This configure script requires a POSIX-compatible shell"
c21d6325 46 echo "such as bash or ksh."
505dfb09
DB
47 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
48 echo "Instead, install a working POSIX-compatible shell."
49 echo "Disabling this configure test will create a broken FFmpeg."
c21d6325
MR
50 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51 echo "This bash version ($BASH_VERSION) is broken on your platform."
52 echo "Upgrade to a later version if available."
53 fi
cde2d79a
MR
54 exit 1
55fi
56
74c53c2d
MR
57show_help(){
58 echo "Usage: configure [options]"
59 echo "Options: [defaults in brackets after descriptions]"
60 echo
61 echo "Standard options:"
62 echo " --help print this message"
8c6afa4d
DB
63 echo " --logfile=FILE log tests and output to FILE [config.err]"
64 echo " --disable-logging do not log configure debug information"
3e89171a 65 echo " --prefix=PREFIX install in PREFIX [$prefix]"
d156bede 66 echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
14a8acf1 67 echo " --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]"
74c53c2d 68 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 69 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
5341d856 70 echo " --incdir=DIR install includes in DIR [PREFIX/include]"
4ca5ece5 71 echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
62560865
DB
72 echo
73 echo "Configuration options:"
e6b9d588
DB
74 echo " --disable-static do not build static libraries [no]"
75 echo " --enable-shared build shared libraries [no]"
0a23c0bb
DB
76 echo " --enable-gpl allow use of GPL code, the resulting libs"
77 echo " and binaries will be under GPL [no]"
9cad0e4e 78 echo " --enable-version3 upgrade (L)GPL to version 3 [no]"
0a23c0bb
DB
79 echo " --enable-nonfree allow use of nonfree code, the resulting libs"
80 echo " and binaries will be unredistributable [no]"
62560865
DB
81 echo " --disable-ffmpeg disable ffmpeg build"
82 echo " --disable-ffplay disable ffplay build"
83 echo " --disable-ffserver disable ffserver build"
e6b9d588 84 echo " --enable-postproc enable GPLed postprocessing support [no]"
fdf11906 85 echo " --enable-avfilter video filter support [no]"
0a23c0bb 86 echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
e6b9d588
DB
87 echo " --enable-beosthreads use BeOS threads [no]"
88 echo " --enable-os2threads use OS/2 threads [no]"
89 echo " --enable-pthreads use pthreads [no]"
90 echo " --enable-w32threads use Win32 threads [no]"
91 echo " --enable-x11grab enable X11 grabbing [no]"
62560865
DB
92 echo " --disable-network disable network support [no]"
93 echo " --disable-ipv6 disable IPv6 support [no]"
94 echo " --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]"
95 echo " --enable-gray enable full grayscale support (slower color)"
a9ddb5b1 96 echo " --disable-swscale-alpha disable alpha channel support in swscale"
aa033b1e 97 echo " --disable-fastdiv disable table-based division"
62560865
DB
98 echo " --enable-small optimize for size instead of speed"
99 echo " --disable-aandct disable AAN DCT code"
100 echo " --disable-fft disable FFT code"
101 echo " --disable-golomb disable Golomb code"
102 echo " --disable-mdct disable MDCT code"
68602540 103 echo " --disable-rdft disable RDFT code"
17492d5e
DB
104 echo " --disable-vaapi disable VAAPI code"
105 echo " --disable-vdpau disable VDPAU code"
e90f5b5a 106 echo " --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)"
62560865
DB
107 echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
108 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
109 echo " --enable-beos-netserver enable BeOS netserver"
110 echo " --disable-encoder=NAME disable encoder NAME"
111 echo " --enable-encoder=NAME enable encoder NAME"
112 echo " --disable-encoders disable all encoders"
113 echo " --disable-decoder=NAME disable decoder NAME"
114 echo " --enable-decoder=NAME enable decoder NAME"
115 echo " --disable-decoders disable all decoders"
5666fd73
GB
116 echo " --disable-hwaccel=NAME disable hwaccel NAME"
117 echo " --enable-hwaccel=NAME enable hwaccel NAME"
118 echo " --disable-hwaccels disable all hwaccels"
62560865
DB
119 echo " --disable-muxer=NAME disable muxer NAME"
120 echo " --enable-muxer=NAME enable muxer NAME"
121 echo " --disable-muxers disable all muxers"
122 echo " --disable-demuxer=NAME disable demuxer NAME"
123 echo " --enable-demuxer=NAME enable demuxer NAME"
124 echo " --disable-demuxers disable all demuxers"
125 echo " --enable-parser=NAME enable parser NAME"
126 echo " --disable-parser=NAME disable parser NAME"
127 echo " --disable-parsers disable all parsers"
128 echo " --enable-bsf=NAME enable bitstream filter NAME"
129 echo " --disable-bsf=NAME disable bitstream filter NAME"
130 echo " --disable-bsfs disable all bitstream filters"
131 echo " --enable-protocol=NAME enable protocol NAME"
132 echo " --disable-protocol=NAME disable protocol NAME"
133 echo " --disable-protocols disable all protocols"
38e54a75
SS
134 echo " --disable-indev=NAME disable input device NAME"
135 echo " --disable-outdev=NAME disable output device NAME"
62560865
DB
136 echo " --disable-indevs disable input devices"
137 echo " --disable-outdevs disable output devices"
138 echo " --disable-devices disable all devices"
139 echo " --enable-filter=NAME enable filter NAME"
140 echo " --disable-filter=NAME disable filter NAME"
141 echo " --disable-filters disable all filters"
142 echo " --list-decoders show all available decoders"
143 echo " --list-encoders show all available encoders"
5666fd73 144 echo " --list-hwaccels show all available hardware accelerators"
62560865
DB
145 echo " --list-muxers show all available muxers"
146 echo " --list-demuxers show all available demuxers"
147 echo " --list-parsers show all available parsers"
148 echo " --list-protocols show all available protocols"
149 echo " --list-bsfs show all available bitstream filters"
150 echo " --list-indevs show all available input devices"
151 echo " --list-outdevs show all available output devices"
152 echo " --list-filters show all available filters"
0a622b98
MR
153 echo
154 echo "External library support:"
0a23c0bb 155 echo " --enable-avisynth enable reading of AVISynth script files [no]"
27cb5cbc 156 echo " --enable-bzlib enable bzlib [autodetect]"
0b175caa
DB
157 echo " --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]"
158 echo " --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]"
f7b8bffe 159 echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
e6b9d588
DB
160 echo " and libraw1394 [no]"
161 echo " --enable-libdirac enable Dirac support via libdirac [no]"
162 echo " --enable-libfaac enable FAAC support via libfaac [no]"
163 echo " --enable-libfaad enable FAAD support via libfaad [no]"
164 echo " --enable-libfaadbin open libfaad.so.0 at runtime [no]"
165 echo " --enable-libgsm enable GSM support via libgsm [no]"
166 echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [no]"
31235134 167 echo " --enable-libnut enable NUT (de)muxing via libnut,"
0a23c0bb 168 echo " native (de)muxer exists [no]"
9a77d59a 169 echo " --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]"
e6b9d588
DB
170 echo " --enable-libschroedinger enable Dirac support via libschroedinger [no]"
171 echo " --enable-libspeex enable Speex decoding via libspeex [no]"
172 echo " --enable-libtheora enable Theora encoding via libtheora [no]"
f9def9cc 173 echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
e6b9d588
DB
174 echo " native implementation exists [no]"
175 echo " --enable-libx264 enable H.264 encoding via x264 [no]"
1cc60c47 176 echo " --enable-libxvid enable Xvid encoding via xvidcore,"
e6b9d588 177 echo " native MPEG-4/Xvid encoder exists [no]"
732c9a34 178 echo " --enable-mlib enable Sun medialib [no]"
27cb5cbc 179 echo " --enable-zlib enable zlib [autodetect]"
74c53c2d
MR
180 echo ""
181 echo "Advanced options (experts only):"
182 echo " --source-path=PATH path to source code [$source_path]"
183 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
db6107b6 184 echo " --enable-cross-compile assume a cross-compiler is used"
c5200f17
MR
185 echo " --sysroot=PATH root of cross-build tree"
186 echo " --sysinclude=PATH location of cross-build system headers"
4f854758 187 echo " --target-os=OS compiler targets OS [$target_os]"
a7ada2ba
MR
188 echo " --target-exec=CMD command to run executables on target"
189 echo " --target-path=DIR path to view of build directory on target"
89641463 190 echo " --nm=NM use nm tool"
313c46a6 191 echo " --as=AS use assembler AS [$as_default]"
15396d5c 192 echo " --cc=CC use C compiler CC [$cc_default]"
684b28e0 193 echo " --ld=LD use linker LD"
9da6609f
MR
194 echo " --host-cc=HOSTCC use host C compiler HOSTCC"
195 echo " --host-cflags=HCFLAGS use HCFLAGS when compiling for host"
196 echo " --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host"
197 echo " --host-libs=HLIBS use libs HLIBS when linking for host"
74c53c2d
MR
198 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
199 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
200 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
ac63af34 201 echo " --extra-version=STRING version string suffix []"
0a23c0bb
DB
202 echo " --build-suffix=SUFFIX library name suffix []"
203 echo " --arch=ARCH select architecture [$arch]"
204 echo " --cpu=CPU select the minimum required CPU (affects"
7c758d33 205 echo " instruction selection, may crash on older CPUs)"
2b4c3615 206 echo " --enable-powerpc-perf enable performance report on PPC"
74c53c2d 207 echo " (requires enabling PMC)"
4f50c3d5 208 echo " --disable-altivec disable AltiVec optimizations"
3bf96eec 209 echo " --disable-amd3dnow disable 3DNow! optimizations"
a1ef9f08 210 echo " --disable-amd3dnowext disable 3DNow! extended optimizations"
0a23c0bb
DB
211 echo " --disable-mmx disable MMX optimizations"
212 echo " --disable-mmx2 disable MMX2 optimizations"
1bb04d5a 213 echo " --disable-sse disable SSE optimizations"
0a23c0bb
DB
214 echo " --disable-ssse3 disable SSSE3 optimizations"
215 echo " --disable-armv5te disable armv5te optimizations"
216 echo " --disable-armv6 disable armv6 optimizations"
26c7aa17 217 echo " --disable-armv6t2 disable armv6t2 optimizations"
3bbcba32 218 echo " --disable-armvfp disable ARM VFP optimizations"
0a23c0bb 219 echo " --disable-iwmmxt disable iwmmxt optimizations"
49276307
DB
220 echo " --disable-mmi disable MMI optimizations"
221 echo " --disable-neon disable neon optimizations"
222 echo " --disable-vis disable VIS optimizations"
7595a5e4 223 echo " --disable-yasm disable use of yasm assembler"
8a3c8627 224 echo " --enable-pic build position-independent code"
0a622b98
MR
225 echo
226 echo "Developer options (useful when working on FFmpeg itself):"
9c56a1f9 227 echo " --disable-debug disable debugging symbols"
b7d49373 228 echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
0a622b98 229 echo " --enable-gprof enable profiling with gprof [$gprof]"
d2bbb2f7 230 echo " --disable-optimizations disable compiler optimizations"
0a622b98 231 echo " --enable-extra-warnings enable more compiler warnings"
87a0fb62 232 echo " --disable-stripping disable stripping of executables and shared libraries"
74c53c2d
MR
233 echo ""
234 echo "NOTE: Object files are built at the place where configure is launched."
60e8bc13 235 exit 0
74c53c2d 236}
cf9d24ad 237
57bd82d4 238log(){
2270b4b2 239 echo "$@" >> $logfile
57bd82d4
MR
240}
241
720c69da 242log_file(){
c8e9f801 243 log BEGIN $1
2270b4b2 244 pr -n -t $1 >> $logfile
c8e9f801
MR
245 log END $1
246}
247
2ba042a7 248echolog(){
c8e9f801 249 log "$@"
57bd82d4 250 echo "$@"
2ba042a7
MR
251}
252
253die(){
254 echolog "$@"
255 cat <<EOF
d326cf7f 256
2ba042a7
MR
257If you think configure made a mistake, make sure you are using the latest
258version from SVN. If the latest version fails, report the problem to the
e5d8ccd7 259ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
2ba042a7 260EOF
e155a21a 261 if disabled logging; then
2ba042a7 262 cat <<EOF
e155a21a
DB
263Rerun configure with logging enabled (do not use --disable-logging), and
264include the log this produces with your report.
2ba042a7
MR
265EOF
266 else
267cat <<EOF
e155a21a
DB
268Include the log file "$logfile" produced by configure as this will help
269solving the problem.
2ba042a7
MR
270EOF
271 fi
57bd82d4
MR
272 exit 1
273}
274
6c6007d6 275# Avoid locale weirdness, besides we really just want to translate ASCII.
44161118 276toupper(){
6c6007d6 277 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
44161118
MR
278}
279
4a5444db 280tolower(){
6c6007d6 281 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
4a5444db
MR
282}
283
14a8acf1
MR
284c_escape(){
285 echo "$*" | sed 's/["\\]/\\\0/g'
286}
287
b04251c5
MR
288sh_quote(){
289 v=$(echo "$1" | sed "s/'/'\\\\''/g")
290 test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
291 echo "$v"
292}
293
be8f2501
MR
294filter(){
295 pat=$1
296 shift
297 for v; do
98ef6079 298 eval "case $v in $pat) echo $v ;; esac"
be8f2501
MR
299 done
300}
301
a8d04fba
MR
302set_all(){
303 value=$1
304 shift
305 for var in $*; do
306 eval $var=$value
307 done
308}
309
72a43668
MR
310set_weak(){
311 value=$1
312 shift
313 for var; do
314 eval : \${$var:=$value}
315 done
316}
317
799c9e9b
MR
318pushvar(){
319 for var in $*; do
320 eval level=\${${var}_level:=0}
321 eval ${var}_${level}="\$$var"
322 eval ${var}_level=$(($level+1))
323 done
324}
325
326popvar(){
327 for var in $*; do
328 eval level=\${${var}_level:-0}
329 test $level = 0 && continue
330 eval level=$(($level-1))
331 eval $var="\${${var}_${level}}"
332 eval ${var}_level=$level
333 eval unset ${var}_${level}
334 done
335}
336
a8d04fba
MR
337enable(){
338 set_all yes $*
339}
340
341disable(){
342 set_all no $*
343}
344
72a43668
MR
345enable_weak(){
346 set_weak yes $*
347}
348
349disable_weak(){
350 set_weak no $*
351}
352
72702705
MR
353enable_safe(){
354 enable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
355}
356
357disable_safe(){
358 disable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
359}
360
f9d328da
MR
361do_enable_deep(){
362 for var; do
363 enabled $var && continue
364 eval sel="\$${var}_select"
c510c7b5
MR
365 eval sgs="\$${var}_suggest"
366 pushvar var sgs
f9d328da 367 enable_deep $sel
c510c7b5
MR
368 popvar sgs
369 enable_deep_weak $sgs
f9d328da
MR
370 popvar var
371 done
372}
373
374enable_deep(){
375 do_enable_deep $*
376 enable $*
377}
378
72a43668
MR
379enable_deep_weak(){
380 do_enable_deep $*
381 enable_weak $*
382}
383
57bd82d4 384enabled(){
3250003c
MR
385 test "${1#!}" = "$1" && op== || op=!=
386 eval test "x\$${1#!}" $op "xyes"
44161118
MR
387}
388
37970ebf 389disabled(){
3250003c
MR
390 test "${1#!}" = "$1" && op== || op=!=
391 eval test "x\$${1#!}" $op "xno"
37970ebf
RP
392}
393
44161118
MR
394enabled_all(){
395 for opt; do
396 enabled $opt || return 1
397 done
398}
399
85bca2c5
DB
400disabled_all(){
401 for opt; do
402 disabled $opt || return 1
403 done
404}
405
44161118
MR
406enabled_any(){
407 for opt; do
408 enabled $opt && return 0
409 done
410}
411
85bca2c5
DB
412disabled_any(){
413 for opt; do
414 disabled $opt && return 0
415 done
f7b230a7 416 return 1
85bca2c5
DB
417}
418
c9d19248
MR
419set_default(){
420 for opt; do
88268e94 421 eval : \${$opt:=\$${opt}_default}
c9d19248
MR
422 done
423}
424
4a0d6686
AJ
425is_in(){
426 value=$1
427 shift
428 for var in $*; do
429 [ $var = $value ] && return 0
430 done
431 return 1
432}
433
30fd06be
MR
434check_deps(){
435 for cfg; do
3250003c 436 cfg="${cfg#!}"
799c9e9b
MR
437 enabled ${cfg}_checking && die "Circular dependency for $cfg."
438 disabled ${cfg}_checking && continue
439 enable ${cfg}_checking
440
30fd06be
MR
441 eval dep_all="\$${cfg}_deps"
442 eval dep_any="\$${cfg}_deps_any"
7ef3425f 443 eval dep_sel="\$${cfg}_select"
c510c7b5 444 eval dep_sgs="\$${cfg}_suggest"
799c9e9b 445
c510c7b5
MR
446 pushvar cfg dep_all dep_any dep_sel dep_sgs
447 check_deps $dep_all $dep_any $dep_sel $dep_sgs
448 popvar cfg dep_all dep_any dep_sel dep_sgs
799c9e9b 449
6a702d4c
MR
450 enabled_all $dep_all || disable $cfg
451 enabled_any $dep_any || disable $cfg
7ef3425f 452 disabled_any $dep_sel && disable $cfg
799c9e9b 453
4ec45764
RP
454 if enabled $cfg; then
455 eval dep_extralibs="\$${cfg}_extralibs"
456 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
f9d328da 457 enable_deep $dep_sel
c510c7b5 458 enable_deep_weak $dep_sgs
4ec45764
RP
459 fi
460
799c9e9b 461 disable ${cfg}_checking
30fd06be
MR
462 done
463}
464
44161118
MR
465print_config(){
466 pfx=$1
467 header=$2
468 makefile=$3
469 shift 3
470 for cfg; do
5e622c40 471 ucname="$(toupper $cfg)"
44161118 472 if enabled $cfg; then
3d907e22 473 echo "#define ${pfx}${ucname} 1" >> $header
3d907e22
MR
474 echo "${pfx}${ucname}=yes" >> $makefile
475 else
b250f9c6 476 echo "#define ${pfx}${ucname} 0" >> $header
44161118
MR
477 fi
478 done
57bd82d4
MR
479}
480
481flags_saved(){
2270b4b2 482 (: ${SAVE_CFLAGS?}) 2> /dev/null
57bd82d4
MR
483}
484
dcd479c0 485save_flags(){
57bd82d4 486 flags_saved && return
dcd479c0
MR
487 SAVE_CFLAGS="$CFLAGS"
488 SAVE_LDFLAGS="$LDFLAGS"
489 SAVE_extralibs="$extralibs"
490}
491
492restore_flags(){
f5d28d10 493 flags_saved || return
dcd479c0
MR
494 CFLAGS="$SAVE_CFLAGS"
495 LDFLAGS="$SAVE_LDFLAGS"
496 extralibs="$SAVE_extralibs"
497 unset SAVE_CFLAGS
498 unset SAVE_LDFLAGS
499 unset SAVE_extralibs
500}
501
502temp_cflags(){
503 save_flags
504 CFLAGS="$CFLAGS $*"
505}
506
507temp_ldflags(){
508 save_flags
509 LDFLAGS="$LDFLAGS $*"
510}
511
512temp_extralibs(){
513 save_flags
514 extralibs="$extralibs $*"
515}
516
57bd82d4
MR
517append(){
518 var=$1
519 shift
520 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
521 eval "$var=\"\$$var $*\""
522}
523
50a334e4 524add_cppflags(){
caf458dd 525 append CPPFLAGS $($filter_cppflags "$@")
50a334e4
MR
526}
527
57bd82d4 528add_cflags(){
caf458dd 529 append CFLAGS $($filter_cflags "$@")
57bd82d4
MR
530}
531
2f2e6c7c 532add_asflags(){
caf458dd 533 append ASFLAGS $($filter_asflags "$@")
2f2e6c7c
MR
534}
535
57bd82d4
MR
536add_ldflags(){
537 append LDFLAGS "$@"
538}
539
540add_extralibs(){
541 append extralibs "$@"
542}
543
b0cfb663 544check_cmd(){
b3cb5d51 545 log "$@"
2270b4b2 546 "$@" >> $logfile 2>&1
b0cfb663
MR
547}
548
dcd479c0 549check_cc(){
57bd82d4 550 log check_cc "$@"
2270b4b2 551 cat > $TMPC
720c69da 552 log_file $TMPC
50a334e4 553 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
554}
555
556check_cpp(){
557 log check_cpp "$@"
2270b4b2 558 cat > $TMPC
720c69da 559 log_file $TMPC
9e7f3277 560 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
561}
562
f65883c8
MR
563check_as(){
564 log check_as "$@"
565 cat > $TMPC
566 log_file $TMPC
2f2e6c7c 567 check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
f65883c8
MR
568}
569
940f335a
MR
570check_asm(){
571 log check_asm "$@"
572 name="$1"
573 asm="$2"
574 shift 2
f65883c8 575 check_as "$@" <<EOF && enable $name || disable $name
124c21d7 576void foo(void){ __asm__ volatile($asm); }
940f335a
MR
577EOF
578}
579
304d586d
LM
580check_yasm(){
581 log check_yasm "$@"
582 echo "$1" > $TMPS
583 log_file $TMPS
584 shift 1
585 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
586}
587
dcd479c0 588check_ld(){
57bd82d4 589 log check_ld "$@"
0607887f 590 check_cc || return
3155a644
MR
591 flags=''
592 libs=''
593 for f; do
594 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
595 done
684b28e0 596 check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
dcd479c0
MR
597}
598
50a334e4
MR
599check_cppflags(){
600 log check_cppflags "$@"
caf458dd
MR
601 set -- $($filter_cppflags "$@")
602 check_cc "$@" <<EOF && append CPPFLAGS "$@"
50a334e4
MR
603int x;
604EOF
605}
606
dcd479c0 607check_cflags(){
57bd82d4 608 log check_cflags "$@"
caf458dd
MR
609 set -- $($filter_cflags "$@")
610 check_cc "$@" <<EOF && append CFLAGS "$@"
dcd479c0
MR
611int x;
612EOF
613}
614
615check_ldflags(){
57bd82d4
MR
616 log check_ldflags "$@"
617 check_ld "$@" <<EOF && add_ldflags "$@"
c23a0ac8 618int main(void){ return 0; }
dcd479c0
MR
619EOF
620}
621
622check_header(){
57bd82d4 623 log check_header "$@"
dcd479c0
MR
624 header=$1
625 shift
b77df637
MR
626 disable_safe $header
627 check_cpp "$@" <<EOF && enable_safe $header
dcd479c0
MR
628#include <$header>
629int x;
630EOF
631}
632
633check_func(){
57bd82d4 634 log check_func "$@"
dcd479c0
MR
635 func=$1
636 shift
d8bc5f06
MR
637 disable $func
638 check_ld "$@" <<EOF && enable $func
dcd479c0 639extern int $func();
c23a0ac8 640int main(void){ $func(); }
dcd479c0
MR
641EOF
642}
643
2446d3d6
DB
644check_func_headers(){
645 log check_func_headers "$@"
f8d7b072
MR
646 headers=$1
647 func=$2
648 shift 2
649 disable $func
650 incs=""
651 for hdr in $headers; do
652 incs="$incs
653#include <$hdr>"
654 done
cd0d9a9d 655 check_ld "$@" <<EOF && enable $func && enable_safe $headers
f8d7b072 656$incs
d6773f56 657int main(int argc, char **argv){
2b2c2a81 658 return (long) $func;
f8d7b072
MR
659}
660EOF
661}
662
a5344cf7
SS
663check_cpp_condition(){
664 log check_cpp_condition "$@"
665 header=$1
666 condition=$2
667 check_cpp <<EOF
668#include <$header>
669#if !($condition)
670#error "unsatisfied condition: $condition"
671#endif
672EOF
673}
674
57bd82d4
MR
675check_lib(){
676 log check_lib "$@"
677 header="$1"
678 func="$2"
679 shift 2
fcfcde17
MR
680 temp_extralibs "$@"
681 check_header $header && check_func $func && add_extralibs "$@"
682 err=$?
683 restore_flags
684 return $err
57bd82d4
MR
685}
686
f8d7b072
MR
687check_lib2(){
688 log check_lib2 "$@"
689 headers="$1"
690 func="$2"
691 shift 2
692 temp_extralibs "$@"
2446d3d6 693 check_func_headers "$headers" $func && add_extralibs "$@"
f8d7b072
MR
694 err=$?
695 restore_flags
696 return $err
697}
698
dcd479c0 699check_exec(){
2270b4b2 700 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
57bd82d4
MR
701}
702
7dfef245 703check_exec_crash(){
5e622c40 704 code=$(cat)
7dfef245
MR
705
706 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
707 # are safe but may not be available everywhere. Thus we use
708 # raise(SIGTERM) instead. The check is run in a subshell so we
709 # can redirect the "Terminated" message from the shell. SIGBUS
710 # is not defined by standard C so it is used conditionally.
711
2270b4b2 712 (check_exec "$@") >> $logfile 2>&1 <<EOF
7dfef245
MR
713#include <signal.h>
714static void sighandler(int sig){
715 raise(SIGTERM);
716}
e5af4a11 717int main(void){
7dfef245
MR
718 signal(SIGILL, sighandler);
719 signal(SIGFPE, sighandler);
720 signal(SIGSEGV, sighandler);
721#ifdef SIGBUS
722 signal(SIGBUS, sighandler);
723#endif
724 { $code }
725}
726EOF
727}
728
72be9e73
DY
729check_type(){
730 log check_type "$@"
731 headers=$1
732 type=$2
733 shift 2
734 disable $type
735 incs=""
736 for hdr in $headers; do
737 incs="$incs
738#include <$hdr>"
739 done
740 check_cc "$@" <<EOF && enable $type
741$incs
742$type v;
743EOF
744}
745
57bd82d4
MR
746require(){
747 name="$1"
748 header="$2"
749 func="$3"
750 shift 3
751 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
752}
753
f8d7b072
MR
754require2(){
755 name="$1"
756 headers="$2"
757 func="$3"
758 shift 3
759 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
760}
761
eea50282
MR
762check_foo_config(){
763 cfg=$1
764 pkg=$2
765 header=$3
766 func=$4
767 shift 4
768 disable $cfg
769 check_cmd ${pkg}-config --version
770 err=$?
771 if test "$err" = 0; then
5e622c40
DB
772 temp_cflags $(${pkg}-config --cflags)
773 temp_extralibs $(${pkg}-config --libs)
eea50282
MR
774 check_lib "$@" $header $func && enable $cfg
775 fi
776 return $err
777}
778
c505dd31
MR
779apply(){
780 file=$1
781 shift
782 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
783}
784
dcd61286
DB
785# CONFIG_LIST contains configurable options, while HAVE_LIST is for
786# system-dependent things.
787
4a0d6686
AJ
788COMPONENT_LIST="
789 bsfs
790 decoders
791 demuxers
792 encoders
3cde40aa 793 filters
5666fd73 794 hwaccels
c552605c 795 indevs
4a0d6686 796 muxers
c552605c 797 outdevs
4a0d6686
AJ
798 parsers
799 protocols
800"
801
802CONFIG_LIST="
803 $COMPONENT_LIST
e8ed9b7a 804 aandct
f7679c54
VS
805 avfilter
806 avfilter_lavf
c88f5d72
MR
807 avisynth
808 beos_netserver
f402916e 809 bzlib
27a9466b 810 fastdiv
c88f5d72
MR
811 ffmpeg
812 ffplay
813 ffserver
1848f7d9 814 fft
4f034993 815 golomb
c88f5d72 816 gpl
ecfc4f44 817 gprof
d8d0d0b2 818 gray
3abe5fbd 819 hardcoded_tables
c88f5d72 820 ipv6
f7b8bffe 821 libdc1394
690bfceb 822 libdirac
2eed5a46
DB
823 libfaac
824 libfaad
825 libfaadbin
c88f5d72 826 libgsm
6ebe07fb 827 libmp3lame
c88f5d72 828 libnut
0b175caa
DB
829 libopencore_amrnb
830 libopencore_amrwb
9a77d59a 831 libopenjpeg
f7cd9eed 832 libschroedinger
ae14f311 833 libspeex
150d2772 834 libtheora
c88f5d72 835 libvorbis
1cc60c47
DB
836 libx264
837 libxvid
47a158cb 838 mdct
c88f5d72 839 memalign_hack
a8150374 840 mlib
c88f5d72
MR
841 mpegaudio_hp
842 network
3fe142e2 843 nonfree
8a3c8627 844 pic
4a24ab64 845 postproc
2b4c3615 846 powerpc_perf
68602540 847 rdft
e90f5b5a 848 runtime_cpudetect
2e35e684 849 shared
bd2216e4 850 small
2e35e684 851 static
a9ddb5b1 852 swscale_alpha
17492d5e
DB
853 vaapi
854 vdpau
9cad0e4e 855 version3
56a059ac 856 x11grab
c88f5d72 857 zlib
4a0d6686 858"
c88f5d72 859
8eee7025
DB
860THREADS_LIST='
861 beosthreads
d22e8442 862 os2threads
8eee7025
DB
863 pthreads
864 w32threads
865'
866
3f5b56e5
MR
867ARCH_LIST='
868 alpha
a2fc0f6a 869 arm
fdcd782d
MR
870 avr32
871 avr32_ap
872 avr32_uc
3f5b56e5
MR
873 bfin
874 ia64
875 m68k
876 mips
bae3abb0 877 mips64
3f5b56e5 878 parisc
79cb09b2 879 ppc
34d11b87 880 ppc64
3f5b56e5
MR
881 s390
882 sh4
883 sparc
884 sparc64
885 x86
886 x86_32
887 x86_64
888'
889
890ARCH_EXT_LIST='
1ac9331a 891 altivec
3bf96eec 892 amd3dnow
a1ef9f08 893 amd3dnowext
1ac9331a 894 armv5te
edab3048 895 armv6
ab5cb084 896 armv6t2
f55b299a 897 armvfp
3f5b56e5
MR
898 iwmmxt
899 mmi
900 mmx
d7f0920b 901 mmx2
6b18d278 902 neon
799fde37 903 ppc4xx
1bb04d5a 904 sse
9eeed841 905 ssse3
bd9d34a0 906 vis
3f5b56e5
MR
907'
908
909HAVE_LIST="
910 $ARCH_EXT_LIST
911 $THREADS_LIST
35fd8122 912 alsa_asoundlib_h
3f5b56e5 913 altivec_h
c9fdab0d 914 arpa_inet_h
e7ea5e3d 915 attribute_packed
08a85a59 916 bigendian
6bd859d6 917 bswap
ecf97f22 918 closesocket
1ac9331a 919 cmov
e16e49ac 920 conio_h
c88f5d72 921 dcbzl
f8aa696f
DB
922 dev_bktr_ioctl_bt848_h
923 dev_bktr_ioctl_meteor_h
924 dev_ic_bt8xx_h
925 dev_video_meteor_ioctl_meteor_h
926 dev_video_bktr_ioctl_bt848_h
18b67ae5 927 dlfcn_h
c88f5d72 928 dlopen
bc574408 929 dos_paths
245626d0
DB
930 ebp_available
931 ebx_available
c2a29455 932 fast_64bit
7073e9fc 933 fast_cmov
7b829d2a 934 fast_unaligned
9d99cc5a 935 fork
da9e86f8 936 gethrtime
4e68cb8a 937 GetProcessTimes
66be5b45 938 getrusage
2e1913b1 939 inet_aton
61d251db 940 inline_asm
abfc8d05 941 isatty
9f5ff83f 942 ldbrx
0b4a1821
AS
943 libdc1394_1
944 libdc1394_2
a33cab3a 945 llrint
291fd18a 946 log2
85dd97ad 947 loongson
a33cab3a 948 lrint
c88f5d72 949 lrintf
e4673692 950 lzo1x_999_compress
f8aa696f
DB
951 machine_ioctl_bt848_h
952 machine_ioctl_meteor_h
c88f5d72
MR
953 malloc_h
954 memalign
6ffa87d3 955 mkstemp
b4e806b2 956 pld
1f91cdce 957 posix_memalign
a33cab3a
MK
958 round
959 roundf
c88f5d72
MR
960 sdl
961 sdl_video_size
b507ebd1 962 setmode
72be9e73 963 socklen_t
deb29777 964 soundcard_h
f8cda19e 965 poll_h
b58412f1 966 sys_mman_h
b091aa44 967 sys_resource_h
81644c2e 968 sys_select_h
deb29777 969 sys_soundcard_h
1b6e8b73 970 sys_videoio_h
d3a4b4e0 971 ten_operands
e16e49ac 972 termios_h
b265431e 973 threads
7b04b8a0 974 truncf
ce742de2 975 vfp_args
7c5bfe7a 976 VirtualAlloc
6ff3f3e7 977 winsock2_h
cc078b5d 978 xform_asm
304d586d 979 yasm
0cb78cef 980"
44161118 981
b6bb00b0
MR
982# options emitted with CONFIG_ prefix but not available on command line
983CONFIG_EXTRA="
9cad0e4e
DB
984 gplv3
985 lgplv3
b6bb00b0
MR
986"
987
520cc7f1 988CMDLINE_SELECT="
3f5b56e5 989 $ARCH_EXT_LIST
520cc7f1 990 $CONFIG_LIST
8eee7025 991 $THREADS_LIST
db6107b6 992 cross_compile
520cc7f1
MR
993 debug
994 extra_warnings
8c6afa4d 995 logging
d2bbb2f7 996 optimizations
87a0fb62 997 stripping
7595a5e4 998 yasm
520cc7f1 999"
426be5dc
DB
1000
1001PATHS_LIST='
d156bede 1002 bindir
14a8acf1 1003 datadir
26759c44
MR
1004 incdir
1005 libdir
26759c44
MR
1006 mandir
1007 prefix
1008 shlibdir
426be5dc
DB
1009'
1010
1011CMDLINE_SET="
1012 $PATHS_LIST
1013 arch
313c46a6 1014 as
426be5dc
DB
1015 build_suffix
1016 cc
1017 cpu
1018 cross_prefix
50567afa 1019 dep_cc
ac63af34 1020 extra_version
9da6609f
MR
1021 host_cc
1022 host_cflags
1023 host_ldflags
1024 host_libs
82bb3329 1025 host_os
684b28e0 1026 ld
426be5dc 1027 logfile
89641463 1028 nm
26759c44 1029 source_path
c5200f17
MR
1030 sysinclude
1031 sysroot
a7ada2ba 1032 target_exec
26759c44 1033 target_os
a7ada2ba 1034 target_path
426be5dc 1035"
520cc7f1 1036
89f2932b
MR
1037CMDLINE_APPEND="
1038 extra_cflags
1039"
1040
912f3148
DB
1041# code dependency declarations
1042
9eeed841 1043# architecture extensions
79cb09b2 1044altivec_deps="ppc"
3bf96eec 1045amd3dnow_deps="mmx"
a1ef9f08 1046amd3dnowext_deps="amd3dnow"
a2fc0f6a
MR
1047armv5te_deps="arm"
1048armv6_deps="arm"
ab5cb084 1049armv6t2_deps="arm"
a2fc0f6a
MR
1050armvfp_deps="arm"
1051iwmmxt_deps="arm"
e241ba14 1052mmi_deps="mips"
9eeed841 1053mmx_deps="x86"
75aa95a6 1054mmx2_deps="mmx"
a2fc0f6a 1055neon_deps="arm"
799fde37 1056ppc4xx_deps="ppc"
75aa95a6
DB
1057sse_deps="mmx"
1058ssse3_deps="sse"
bd9d34a0 1059vis_deps="sparc"
9eeed841 1060
89e053f8 1061need_memalign="altivec neon sse"
6fec122a 1062inline_asm_deps="!tms470"
89e053f8 1063
5666fd73 1064# decoders / encoders / hardware accelerators
47a158cb 1065aac_decoder_select="fft mdct"
84c04e25 1066aac_encoder_select="fft mdct"
47a158cb
MR
1067ac3_decoder_select="fft mdct"
1068atrac3_decoder_select="fft mdct"
4f034993 1069cavs_decoder_select="golomb"
47a158cb 1070cook_decoder_select="fft mdct"
2eef7c62 1071cscd_decoder_suggest="zlib"
47a158cb 1072dca_decoder_select="fft mdct"
e8ed9b7a 1073dnxhd_encoder_select="aandct"
2eef7c62 1074dxa_decoder_select="zlib"
baf91bb9 1075eac3_decoder_select="ac3_decoder"
84c04e25 1076eamad_decoder_select="aandct"
e8ed9b7a 1077eatgq_decoder_select="aandct"
d52b39c7 1078eatqi_decoder_select="aandct"
4f034993
MR
1079ffv1_decoder_select="golomb"
1080flac_decoder_select="golomb"
1081flac_encoder_select="golomb"
2eef7c62
AJ
1082flashsv_decoder_select="zlib"
1083flashsv_encoder_select="zlib"
4d4b4bd1 1084flv_encoder_select="h263_encoder"
e8ed9b7a
DB
1085h261_encoder_select="aandct"
1086h263_encoder_select="aandct"
ff418735 1087h263_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1088h263_vaapi_hwaccel_select="vaapi h263_decoder"
fe629c2d 1089h263p_encoder_select="h263_encoder"
4f034993 1090h264_decoder_select="golomb"
ff418735 1091h264_vaapi_hwaccel_deps="va_va_h"
17492d5e 1092h264_vaapi_hwaccel_select="vaapi"
711dae77 1093h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1094h264_vdpau_decoder_select="vdpau h264_decoder"
47a158cb 1095imc_decoder_select="fft mdct"
4f034993
MR
1096jpegls_decoder_select="golomb"
1097jpegls_encoder_select="golomb"
e8ed9b7a 1098ljpeg_encoder_select="aandct"
4f034993 1099loco_decoder_select="golomb"
e8ed9b7a
DB
1100mjpeg_encoder_select="aandct"
1101mpeg1video_encoder_select="aandct"
1102mpeg2video_encoder_select="aandct"
c37de5e1 1103mpeg4_encoder_select="h263_encoder"
711dae77 1104mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1105mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
711dae77 1106mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1107mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
ff418735 1108mpeg2_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1109mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
ff418735 1110mpeg4_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1111mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
8f6f050a 1112mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
4d8eecf4 1113mpeg_xvmc_decoder_select="mpegvideo_decoder"
4e169d89
DB
1114msmpeg4v1_encoder_select="h263_encoder"
1115msmpeg4v2_encoder_select="h263_encoder"
1116msmpeg4v3_encoder_select="h263_encoder"
47a158cb
MR
1117nellymoser_decoder_select="fft mdct"
1118nellymoser_encoder_select="fft mdct"
2eef7c62
AJ
1119png_decoder_select="zlib"
1120png_encoder_select="zlib"
63cae55d 1121qdm2_decoder_select="fft mdct rdft"
b2bf38b4
DB
1122rv10_encoder_select="h263_encoder"
1123rv20_encoder_select="h263_encoder"
d52b39c7
AJ
1124rv30_decoder_select="golomb"
1125rv40_decoder_select="golomb"
4f034993
MR
1126shorten_decoder_select="golomb"
1127sonic_decoder_select="golomb"
1128sonic_encoder_select="golomb"
1129sonic_ls_encoder_select="golomb"
1130svq3_decoder_select="golomb"
bee2eac5 1131svq3_decoder_suggest="zlib"
4eef77c1 1132theora_decoder_select="vp3_decoder"
2eef7c62
AJ
1133tiff_decoder_suggest="zlib"
1134tiff_encoder_suggest="zlib"
1135tscc_decoder_select="zlib"
ff418735 1136vc1_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1137vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
711dae77 1138vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1139vc1_vdpau_decoder_select="vdpau vc1_decoder"
47a158cb
MR
1140vorbis_decoder_select="fft mdct"
1141vorbis_encoder_select="fft mdct"
e82dc4c9
DB
1142vp6a_decoder_select="vp6_decoder"
1143vp6f_decoder_select="vp6_decoder"
47a158cb
MR
1144wmav1_decoder_select="fft mdct"
1145wmav1_encoder_select="fft mdct"
1146wmav2_decoder_select="fft mdct"
1147wmav2_encoder_select="fft mdct"
665507aa 1148wmv1_encoder_select="h263_encoder"
1746e2a9 1149wmv2_encoder_select="h263_encoder"
015f8ee0
DB
1150wmv3_decoder_select="vc1_decoder"
1151wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1152wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
2eef7c62
AJ
1153zlib_decoder_select="zlib"
1154zlib_encoder_select="zlib"
1155zmbv_decoder_select="zlib"
1156zmbv_encoder_select="zlib"
30fd06be 1157
28b80940
DB
1158# parsers
1159h264_parser_select="golomb"
1160
912f3148 1161# external libraries
1b71f045 1162libdirac_decoder_deps="libdirac !libschroedinger"
690bfceb 1163libdirac_encoder_deps="libdirac"
c9171a83 1164libfaac_encoder_deps="libfaac"
69ddbd1d 1165libfaad_decoder_deps="libfaad"
4ec45764 1166libfaadbin_decoder_extralibs='$ldl'
299c77d5
MR
1167libgsm_decoder_deps="libgsm"
1168libgsm_encoder_deps="libgsm"
8ffed8d8
MR
1169libgsm_ms_decoder_deps="libgsm"
1170libgsm_ms_encoder_deps="libgsm"
1cc60c47 1171libmp3lame_encoder_deps="libmp3lame"
0b175caa
DB
1172libopencore_amrnb_decoder_deps="libopencore_amrnb"
1173libopencore_amrnb_encoder_deps="libopencore_amrnb"
1174libopencore_amrwb_decoder_deps="libopencore_amrwb"
9a77d59a 1175libopenjpeg_decoder_deps="libopenjpeg"
f7cd9eed
AS
1176libschroedinger_decoder_deps="libschroedinger"
1177libschroedinger_encoder_deps="libschroedinger"
ae14f311 1178libspeex_decoder_deps="libspeex"
150d2772 1179libtheora_encoder_deps="libtheora"
b0caf888 1180libvorbis_encoder_deps="libvorbis"
1cc60c47
DB
1181libx264_encoder_deps="libx264"
1182libxvid_encoder_deps="libxvid"
30fd06be 1183
912f3148 1184# demuxers / muxers
03a76ba9 1185ac3_demuxer_deps="ac3_parser"
647c2356 1186asf_stream_muxer_select="asf_muxer"
4e622dea
SS
1187avisynth_demuxer_deps="avisynth"
1188dirac_demuxer_deps="dirac_parser"
647c2356 1189ipod_muxer_select="mov_muxer"
4e622dea
SS
1190libnut_demuxer_deps="libnut"
1191libnut_muxer_deps="libnut"
647c2356 1192matroska_audio_muxer_select="matroska_muxer"
4e622dea
SS
1193matroska_demuxer_suggest="zlib bzlib"
1194mov_demuxer_suggest="zlib"
1195mp3_demuxer_deps="mpegaudio_parser"
647c2356
DB
1196mp4_muxer_select="mov_muxer"
1197mpegtsraw_demuxer_select="mpegts_demuxer"
1198mxf_d10_muxer_select="mxf_muxer"
1199psp_muxer_select="mov_muxer"
4e622dea
SS
1200redir_demuxer_deps="network"
1201rtp_muxer_deps="network rtp_protocol"
1202rtsp_demuxer_deps="sdp_demuxer"
1203sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
647c2356
DB
1204tg2_muxer_select="mov_muxer"
1205tgp_muxer_select="mov_muxer"
4e622dea
SS
1206
1207# indevs / outdevs
38e54a75
SS
1208alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1209alsa_indev_extralibs="-lasound"
1210alsa_outdev_deps="alsa_asoundlib_h"
1211alsa_outdev_extralibs="-lasound"
1212audio_beos_indev_deps="audio_beos"
1213audio_beos_indev_extralibs="-lmedia -lbe"
1214audio_beos_outdev_deps="audio_beos"
1215audio_beos_outdev_extralibs="-lmedia -lbe"
38e54a75 1216bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
38e54a75
SS
1217dv1394_indev_deps="dv1394 dv_demuxer"
1218jack_indev_deps="jack_jack_h"
1219jack_indev_extralibs="-ljack"
1220libdc1394_indev_deps="libdc1394"
38e54a75
SS
1221oss_indev_deps_any="soundcard_h sys_soundcard_h"
1222oss_outdev_deps_any="soundcard_h sys_soundcard_h"
38e54a75
SS
1223v4l_indev_deps="linux_videodev_h"
1224v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1225vfwcap_indev_deps="capCreateCaptureWindow"
1226vfwcap_indev_extralibs="-lvfw32"
1227x11_grab_device_indev_deps="x11grab XShmCreateImage"
1228x11_grab_device_indev_extralibs="-lX11 -lXext"
30fd06be 1229
912f3148 1230# protocols
3fff6382 1231gopher_protocol_deps="network"
c08fb000 1232http_protocol_deps="network"
cbf29889 1233rtmp_protocol_deps="tcp_protocol"
c08fb000
AB
1234rtp_protocol_deps="udp_protocol"
1235tcp_protocol_deps="network"
1236udp_protocol_deps="network"
1237
f7679c54 1238# filters
81124ba0 1239movie_filter_deps="avfilter_lavf"
f7679c54 1240
912f3148 1241# programs
fa859b4d 1242ffplay_deps="sdl"
6ad42348 1243ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764 1244ffserver_extralibs='$ldl'
a2830dca 1245
912f3148 1246
de6d9b64 1247# default parameters
8a608357 1248
2ba042a7 1249logfile="config.err"
8a608357
MR
1250
1251# installation paths
c9d19248
MR
1252prefix_default="/usr/local"
1253bindir_default='${prefix}/bin'
14a8acf1 1254datadir_default='${prefix}/share/ffmpeg'
c9d19248
MR
1255incdir_default='${prefix}/include'
1256libdir_default='${prefix}/lib'
1257mandir_default='${prefix}/share/man'
1258shlibdir_default="$libdir_default"
8a608357
MR
1259
1260# toolchain
11e6d03a 1261ar="ar"
13c7df3d 1262cc_default="gcc"
9da6609f 1263host_cc_default="gcc"
11e6d03a 1264ln_s="ln -sf"
89641463 1265nm_default="nm"
11e6d03a 1266objformat="elf"
be7109c1 1267ranlib="ranlib"
0f3cb305 1268strip="strip"
11e6d03a 1269yasmexe="yasm"
8a608357
MR
1270
1271# machine
5e622c40 1272arch=$(uname -m)
38d0a8aa 1273cpu="generic"
8a608357 1274
8a608357 1275# OS
4f854758 1276target_os=$(tolower $(uname -s))
82bb3329 1277host_os=$target_os
8a608357 1278
8a608357 1279# configurable options
497237c7 1280enable debug
aa033b1e 1281enable fastdiv
497237c7
RP
1282enable ffmpeg
1283enable ffplay
1284enable ffserver
1285enable ipv6
497237c7
RP
1286enable mpegaudio_hp
1287enable network
8400d6b8 1288enable optimizations
497237c7 1289enable protocols
530dc538 1290enable static
87a0fb62 1291enable stripping
a9ddb5b1 1292enable swscale_alpha
8a608357 1293
8a608357 1294# build settings
9987769a 1295SHFLAGS='-shared -Wl,-soname,$$(@F)'
c536cb09 1296FFSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
1297LIBPREF="lib"
1298LIBSUF=".a"
c5f14466
RP
1299FULLNAME='$(NAME)$(BUILDSUF)'
1300LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
1301SLIBPREF="lib"
1302SLIBSUF=".so"
c5f14466 1303SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
1304SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1305SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 1306LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 1307
7e6c86e6
MR
1308CC_O='-o $@'
1309
9da6609f
MR
1310host_cflags='-O3 -g -Wall'
1311host_libs='-lm'
1312
a7ada2ba
MR
1313target_path='.'
1314
0d7dca36
DB
1315# gcc stupidly only outputs the basename of targets with -MM, but we need the
1316# full relative path for objects in subdirectories for non-recursive Make.
c1c3933a 1317DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
d8059267 1318DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
315c741d 1319
c597172e 1320# find source path
5e622c40 1321source_path="$(dirname "$0")"
497237c7 1322enable source_path_used
24524f36 1323if test -f configure; then
5e622c40 1324 source_path="$(pwd)"
497237c7 1325 disable source_path_used
c597172e 1326else
5e622c40 1327 source_path="$(cd "$source_path"; pwd)"
c597172e 1328 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1329 die "Out of tree builds are impossible with whitespace in source path."
337cee68
MC
1330 test -e "$source_path/config.h" &&
1331 die "Out of tree builds are impossible with config.h in source dir."
c597172e
MR
1332fi
1333
13cbe2c0 1334for v in "$@"; do
b04251c5
MR
1335 r=${v#*=}
1336 l=${v%"$r"}
1337 r=$(sh_quote "$r")
13cbe2c0
MR
1338 FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1339done
c597172e 1340
73ef8980
MR
1341find_things(){
1342 thing=$1
1343 pattern=$2
1344 file=$source_path/$3
932ccf39 1345 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1346}
1347
1348ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1349DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
5666fd73 1350HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
73ef8980
MR
1351PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1352BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1353MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1354DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
38e54a75
SS
1355OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
1356INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
73ef8980 1357PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1358FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1359
7483e694
DB
1360enable $ARCH_EXT_LIST \
1361 $DECODER_LIST \
1362 $ENCODER_LIST \
5666fd73 1363 $HWACCEL_LIST \
7483e694
DB
1364 $PARSER_LIST \
1365 $BSF_LIST \
1366 $DEMUXER_LIST \
1367 $MUXER_LIST \
f7679c54 1368 $FILTER_LIST \
7483e694
DB
1369 $PROTOCOL_LIST \
1370 $INDEV_LIST \
1371 $OUTDEV_LIST \
c597172e
MR
1372
1373die_unknown(){
1374 echo "Unknown option \"$1\"."
1375 echo "See $0 --help for available options."
1376 exit 1
1377}
1378
794f8e97 1379show_list() {
bf0c4afa
RP
1380 suffix=_$1
1381 shift
1382 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
1383 exit 0
1384}
1385
c597172e 1386for opt do
7483e694
DB
1387 optval="${opt#*=}"
1388 case "$opt" in
0f010b2f 1389 --extra-ldflags=*) add_ldflags $optval
7483e694 1390 ;;
0f010b2f 1391 --extra-libs=*) add_extralibs $optval
7483e694 1392 ;;
8fb1cb58 1393 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1394 ;;
40bcf4c7
BL
1395 --enable-debug=*) debuglevel="$optval"
1396 ;;
7483e694 1397 --enable-*=*|--disable-*=*)
8b93ddc3 1398 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
be8f2501
MR
1399 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1400 eval list=\$$(toupper $thing)_LIST
8b93ddc3
MR
1401 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1402 $action $(filter "$name" $list)
7483e694
DB
1403 ;;
1404 --enable-?*|--disable-?*)
5e622c40 1405 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
e3773a55 1406 if is_in $option $COMPONENT_LIST; then
fed5d54b 1407 test $action = disable && action=unset
e3773a55
MR
1408 eval $action \$$(toupper ${option%s})_LIST
1409 elif is_in $option $CMDLINE_SELECT; then
1410 $action $option
1411 else
1412 die_unknown $opt
1413 fi
7483e694
DB
1414 ;;
1415 --list-*)
1416 NAME="${opt#--list-}"
1417 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1418 NAME=${NAME%s}
1419 eval show_list $NAME \$$(toupper $NAME)_LIST
1420 ;;
1421 --help|-h) show_help
1422 ;;
1423 *)
884a36a7 1424 optname="${opt%%=*}"
26759c44
MR
1425 optname="${optname#--}"
1426 optname=$(echo "$optname" | sed 's/-/_/g')
89f2932b
MR
1427 if is_in $optname $CMDLINE_SET; then
1428 eval $optname='$optval'
1429 elif is_in $optname $CMDLINE_APPEND; then
1430 append $optname "$optval"
1431 else
1432 die_unknown $opt
1433 fi
7483e694
DB
1434 ;;
1435 esac
c597172e
MR
1436done
1437
bcea99bb
MR
1438disabled logging && logfile=/dev/null
1439
13cbe2c0 1440echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
bcea99bb
MR
1441set >> $logfile
1442
9da6609f
MR
1443test -n "$cross_prefix" && enable cross_compile
1444
adb2b908 1445ar="${cross_prefix}${ar}"
11e6d03a 1446cc_default="${cross_prefix}${cc_default}"
20e0ed95 1447nm_default="${cross_prefix}${nm_default}"
adb2b908
RP
1448ranlib="${cross_prefix}${ranlib}"
1449strip="${cross_prefix}${strip}"
1450
c5200f17
MR
1451sysinclude_default="${sysroot}/usr/include"
1452
75800dce 1453set_default cc nm sysinclude
9da6609f
MR
1454enabled cross_compile || host_cc_default=$cc
1455set_default host_cc
13c7df3d 1456
82bb3329
MR
1457exesuf() {
1458 case $1 in
1459 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1460 esac
1461}
1462
1463EXESUF=$(exesuf $target_os)
1464HOSTEXESUF=$(exesuf $host_os)
c0f5b7f1 1465
e4e69e0b 1466# set temporary file name
a49d42c2 1467: ${TMPDIR:=$TEMPDIR}
c51fafa1 1468: ${TMPDIR:=$TMP}
a49d42c2 1469: ${TMPDIR:=/tmp}
e4e69e0b 1470
54460a83
MR
1471if ! check_cmd type mktemp; then
1472 # simple replacement for missing mktemp
1473 # NOT SAFE FOR GENERAL USE
1474 mktemp(){
1475 echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1476 }
1477fi
1478
1479tmpfile(){
1480 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1481 (set -C; exec > $tmp) 2>/dev/null ||
f7ba16a7 1482 die "Unable to create temporary file in $TMPDIR."
54460a83
MR
1483 append TMPFILES $tmp
1484 eval $1=$tmp
1485}
1486
1487trap 'rm -f -- $TMPFILES' EXIT
1488trap exit HUP INT TERM
1489
1490tmpfile TMPC .c
1491tmpfile TMPE $EXESUF
1492tmpfile TMPH .h
1493tmpfile TMPO .o
1494tmpfile TMPS .S
1495tmpfile TMPSH .sh
1496
1497unset -f mktemp
e4e69e0b 1498
993f2d0f
MR
1499# make sure we can execute files in $TMPDIR
1500cat > $TMPSH 2>> $logfile <<EOF
1501#! /bin/sh
1502EOF
1503chmod +x $TMPSH >> $logfile 2>&1
1504if ! $TMPSH >> $logfile 2>&1; then
1505 cat <<EOF
1506Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1507variable to another directory and make sure that it is not mounted noexec.
1508EOF
1509 die "Sanity test failed."
1510fi
993f2d0f 1511
19b4c628
MR
1512filter_cflags=echo
1513filter_cppflags=echo
1514filter_asflags=echo
1515
8f0c157a 1516if $cc -v 2>&1 | grep -qi ^gcc; then
629687f6 1517 cc_type=gcc
aef6bd1b
MR
1518 if ! $cc -dumpversion | grep -q '^2\.'; then
1519 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1520 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1521 fi
629687f6
MR
1522elif $cc --version 2>/dev/null | grep -q Intel; then
1523 cc_type=icc
07dec06e
MR
1524 CC_DEPFLAGS='-MMD'
1525 AS_DEPFLAGS='-MMD'
629687f6
MR
1526elif $cc -v 2>&1 | grep -q xlc; then
1527 cc_type=xlc
df442a8d
MR
1528elif $cc -V 2>/dev/null | grep -q Compaq; then
1529 cc_type=ccc
d8059267 1530 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
03754fcd 1531 debuglevel=3
df442a8d 1532 add_ldflags -Wl,-z,now # calls to libots crash without this
03e37762
MR
1533elif $cc --vsn 2>/dev/null | grep -q RVCT; then
1534 test -d "$sysroot" || die "No valid sysroot specified."
1535 cc_type=armcc
1536 armcc_conf="$PWD/armcc.conf"
1537 $cc --arm_linux_configure \
1538 --arm_linux_config_file="$armcc_conf" \
1539 --configure_sysroot="$sysroot" \
1540 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1541 die "Error creating armcc configuration file."
1542 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
75800dce 1543 as_default="${cross_prefix}gcc"
07dec06e
MR
1544 CC_DEPFLAGS='-MMD'
1545 AS_DEPFLAGS='-MMD'
6fec122a
MR
1546elif $cc -version 2>/dev/null | grep -q TMS470; then
1547 cc_type=tms470
1548 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1549 CC_O='-fr=$(@D)'
1550 as_default="${cross_prefix}gcc"
1551 ld_default="${cross_prefix}gcc"
6fec122a
MR
1552 TMPO=$(basename $TMPC .c).o
1553 append TMPFILES $TMPO
1554 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
07dec06e
MR
1555 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1556 AS_DEPFLAGS='-MMD'
6fec122a
MR
1557 filter_cflags=tms470_flags
1558 tms470_flags(){
1559 for flag; do
1560 case $flag in
1561 -march=*|-mcpu=*)
1562 case "${flag#*=}" in
1563 armv7-a|cortex-a*) echo -mv=7a8 ;;
1564 armv7-r|cortex-r*) echo -mv=7r4 ;;
1565 armv7-m|cortex-m*) echo -mv=7m3 ;;
1566 armv6*|arm11*) echo -mv=6 ;;
1567 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1568 echo -mv=5e ;;
1569 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
1570 esac
1571 ;;
1572 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
1573 -mfpu=vfp) echo --float_support=vfpv2 ;;
1574 -mfpu=softvfp) echo --float_support=vfplib ;;
1575 -Os) echo -O3 -mf=2 ;;
1576 -O[0-3]) echo $flag -mf=5 ;;
1577 -g) echo -g -mn ;;
1578 esac
1579 done
1580 }
629687f6
MR
1581fi
1582
1583test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1584
75bafbac 1585: ${as_default:=$cc}
50567afa 1586: ${dep_cc_default:=$cc}
684b28e0 1587: ${ld_default:=$cc}
50567afa 1588set_default as dep_cc ld
75800dce 1589
07dec06e
MR
1590test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1591test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1592
7f32f40c 1593add_cflags $extra_cflags
2f2e6c7c 1594add_asflags $extra_cflags
7f32f40c 1595
154d432c
MR
1596if test -n "$sysroot"; then
1597 case "$cc_type" in
1598 gcc)
467256f2 1599 add_cppflags --sysroot="$sysroot"
154d432c
MR
1600 add_ldflags --sysroot="$sysroot"
1601 ;;
6fec122a
MR
1602 tms470)
1603 add_cppflags -I"$sysinclude"
1604 add_ldflags --sysroot="$sysroot"
1605 ;;
154d432c
MR
1606 esac
1607fi
1608
d22c13a8
MR
1609if test "$cpu" = host; then
1610 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1611
1612 case "$cc_type" in
1613 gcc)
1614 check_native(){
1615 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1616 awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1617 }
1618 cpu=$(check_native -march || check_native -mcpu)
1619 ;;
1620 esac
1621
1622 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1623fi
1624
df5cdc24
MR
1625# Add processor-specific flags
1626case $cpu in
1627 601|ppc601|PowerPC601)
1628 cpuflags="-mcpu=601"
1629 ;;
1630 603*|ppc603*|PowerPC603*)
1631 cpuflags="-mcpu=603"
1632 ;;
1633 604*|ppc604*|PowerPC604*)
1634 cpuflags="-mcpu=604"
1635 ;;
1636 G3|g3|75*|ppc75*|PowerPC75*)
1637 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1638 ;;
1639 G4|g4|745*|ppc745*|PowerPC745*)
1640 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1641 ;;
1642 74*|ppc74*|PowerPC74*)
1643 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1644 ;;
1645 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1646 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1647 ;;
1648 Cell|CELL|cell)
1649 cpuflags="-mcpu=cell"
1650 enable ldbrx
1651 ;;
1652 # targets that do NOT support conditional mov (cmov)
1653 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1654 cpuflags="-march=$cpu"
1655 disable cmov
1656 ;;
1657 # targets that do support conditional mov (cmov)
1658 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1659 cpuflags="-march=$cpu"
1660 enable cmov
1661 enable fast_cmov
1662 ;;
1663 # targets that do support conditional mov but on which it's slow
1664 pentium4|pentium4m|prescott|nocona)
1665 cpuflags="-march=$cpu"
1666 enable cmov
1667 disable fast_cmov
1668 ;;
1669 sparc64)
1670 cpuflags="-mcpu=v9"
1671 ;;
1672 arm11*|cortex*)
1673 cpuflags="-mcpu=$cpu"
1674 enable fast_unaligned
1675 ;;
1676 armv[67]*)
1677 cpuflags="-march=$cpu"
1678 enable fast_unaligned
1679 ;;
1680 armv*)
1681 cpuflags="-march=$cpu"
1682 ;;
1683 arm*)
1684 cpuflags="-mcpu=$cpu"
1685 ;;
1686 ev4|ev45|ev5|ev56|pca56|ev6|ev67)
1687 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1688 ;;
1689 bf*)
1690 cpuflags="-mcpu=$cpu"
1691 ;;
1692 mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
1693 cpuflags="-march=$cpu"
1694 ;;
fdcd782d
MR
1695 ap7[02]0[0-2])
1696 subarch="avr32_ap"
1697 cpuflags="-mpart=$cpu"
1698 ;;
1699 ap)
1700 subarch="avr32_ap"
1701 cpuflags="-march=$cpu"
1702 ;;
1703 uc3[ab]*)
1704 subarch="avr32_uc"
1705 cpuflags="-mcpu=$cpu"
1706 ;;
1707 uc)
1708 subarch="avr32_uc"
1709 cpuflags="-march=$cpu"
1710 ;;
df5cdc24
MR
1711 generic)
1712 ;;
1713 *)
1714 echo "WARNING: Unknown CPU \"$cpu\", ignored."
1715 ;;
1716esac
1717
1718add_cflags $cpuflags
1719add_asflags $cpuflags
1720
993f2d0f
MR
1721# compiler sanity check
1722check_exec <<EOF
1723int main(void){ return 0; }
1724EOF
1725if test "$?" != 0; then
1726 echo "$cc is unable to create an executable file."
1727 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1728 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1729 echo "Only do this if you know what cross compiling means."
1730 fi
1731 die "C compiler test failed."
1732fi
1733
38a9c529 1734add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
e9b9a2f8 1735check_cflags -std=c99
50a334e4 1736check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
9d821fc2
DB
1737#include <stdlib.h>
1738EOF
50a334e4 1739check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
9d821fc2
DB
1740#include <stdlib.h>
1741EOF
e9b9a2f8 1742
b24dbcbd 1743case "$arch" in
b24dbcbd
RP
1744 alpha)
1745 arch="alpha"
1746 enable fast_64bit
c0a02a3e 1747 check_cflags -mieee
8a3c8627 1748 spic=$shared
b24dbcbd 1749 ;;
cfdb6148
MR
1750 arm|armv[4567]*l)
1751 arch="arm"
b24dbcbd 1752 ;;
f4870943
MR
1753 avr32)
1754 ;;
cfdb6148
MR
1755 bfin)
1756 arch="bfin"
1757 ;;
1758 ia64)
1759 arch="ia64"
b24dbcbd 1760 enable fast_64bit
8a3c8627 1761 spic=$shared
cfdb6148
MR
1762 ;;
1763 m68k)
1764 arch="m68k"
b24dbcbd 1765 ;;
de3a1240 1766 mips|mipsel|IP*)
b24dbcbd 1767 arch="mips"
8a3c8627 1768 spic=$shared
b24dbcbd 1769 ;;
de3a1240
DB
1770 mips64)
1771 arch="mips"
bae3abb0 1772 subarch="mips64"
de3a1240 1773 enable fast_64bit
8a3c8627 1774 spic=$shared
de3a1240 1775 ;;
61597a98 1776 parisc|hppa)
b24dbcbd 1777 arch="parisc"
8a3c8627 1778 spic=$shared
b24dbcbd 1779 ;;
61597a98 1780 parisc64|hppa64)
b24dbcbd
RP
1781 arch="parisc"
1782 enable fast_64bit
8a3c8627 1783 spic=$shared
b24dbcbd 1784 ;;
cfdb6148
MR
1785 "Power Macintosh"|ppc|powerpc)
1786 arch="ppc"
1787 enable fast_unaligned
1788 ;;
1789 ppc64)
1790 arch="ppc"
34d11b87 1791 subarch="ppc64"
cfdb6148
MR
1792 enable fast_64bit
1793 enable fast_unaligned
1794 ;;
b24dbcbd
RP
1795 s390|s390x)
1796 arch="s390"
1797 ;;
cfdb6148
MR
1798 sh4|sh)
1799 arch="sh4"
b24dbcbd 1800 ;;
cfdb6148
MR
1801 sparc)
1802 arch="sparc"
8a3c8627 1803 spic=$shared
cfdb6148
MR
1804 ;;
1805 sun4u|sparc64)
1806 arch="sparc"
1807 subarch="sparc64"
b24dbcbd 1808 enable fast_64bit
8a3c8627 1809 spic=$shared
b24dbcbd 1810 ;;
cfdb6148
MR
1811 i386|i486|i586|i686|i86pc|BePC)
1812 arch="x86"
1813 subarch="x86_32"
1814 enable fast_unaligned
1815 ;;
1816 x86_64|amd64)
1817 arch="x86"
1818 subarch="x86_32"
1819 enable cmov
1820 enable fast_cmov
1821 enable fast_unaligned
8a3c8627 1822 check_cc <<EOF && enable fast_64bit && subarch="x86_64" && spic=$shared
cfdb6148
MR
1823 int test[sizeof(char*) - 7];
1824EOF
b24dbcbd
RP
1825 ;;
1826 *)
1827 arch="unknown"
1828 ;;
1829esac
1830
62045d48 1831enable $arch $subarch
8a3c8627 1832enabled spic && enable pic
b24dbcbd 1833
7483e694 1834# OS specific
4f854758 1835case $target_os in
7483e694 1836 beos|haiku|zeta)
c9d19248 1837 prefix_default="$HOME/config"
7483e694 1838 # helps building libavcodec
50a334e4
MR
1839 add_cppflags -DPIC
1840 add_cflags -fomit-frame-pointer
7483e694 1841 # 3 gcc releases known for BeOS, each with ugly bugs
5e622c40 1842 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
7483e694
DB
1843 case "$gcc_version" in
1844 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1845 disable mmx
1846 ;;
1847 *20010315*) echo "BeBits gcc"
0f010b2f 1848 add_cflags -fno-expensive-optimizations
7483e694
DB
1849 ;;
1850 esac
7483e694
DB
1851 SHFLAGS=-nostart
1852 # enable BeOS things
1853 enable audio_beos
1854 # no need for libm, but the inet stuff
1855 # Check for BONE
1856 # XXX: actually should check for NOT net_server
78fe7631 1857 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1858 network_extralibs="-lbind -lsocket"
1859 else
1860 enable beos_netserver
1861 network_extralibs="-lnet"
1862 fi ;;
1863 sunos)
1864 FFSERVERLDFLAGS=""
9987769a 1865 SHFLAGS='-shared -Wl,-h,$$(@F)'
7483e694 1866 network_extralibs="-lsocket -lnsl"
50a334e4 1867 add_cppflags -D__EXTENSIONS__
7483e694
DB
1868 ;;
1869 netbsd)
07a8eef6
MR
1870 oss_indev_extralibs="-lossaudio"
1871 oss_outdev_extralibs="-lossaudio"
7483e694
DB
1872 ;;
1873 openbsd)
89e053f8 1874 enable malloc_aligned
cd78208b 1875 enable pic
7483e694 1876 SHFLAGS='-shared'
07a8eef6
MR
1877 oss_indev_extralibs="-lossaudio"
1878 oss_outdev_extralibs="-lossaudio"
7483e694 1879 ;;
90b4f091 1880 freebsd|dragonfly)
89e053f8 1881 enable malloc_aligned
7483e694
DB
1882 ;;
1883 bsd/os)
1884 osextralibs="-lpoll -lgnugetopt"
1885 strip="strip -d"
1886 ;;
1887 darwin)
89e053f8 1888 enable malloc_aligned
0138c54e 1889 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
7483e694
DB
1890 strip="strip -x"
1891 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1892 SLIBSUF=".dylib"
1893 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1894 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1895 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1896 objformat="macho"
1b0f6fb8 1897 enabled x86_64 && objformat="macho64"
2704bd1a
AS
1898 enabled shared ||
1899 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
7483e694
DB
1900 ;;
1901 mingw32*)
9d3f4f50 1902 if test $target_os = "mingw32ce"; then
1aa71e25
MS
1903 disable network
1904 else
1905 target_os=mingw32
1906 fi
dcc01c06 1907 LIBTARGET=i386
1fc9fb8a 1908 if enabled x86_64; then
89e053f8 1909 enable malloc_aligned
dcc01c06 1910 LIBTARGET=x64
336cc1b0
MS
1911 elif enabled arm; then
1912 LIBTARGET=arm
dcc01c06 1913 fi
fbd971a4 1914 shlibdir_default="$bindir_default"
7483e694
DB
1915 disable ffserver
1916 SLIBPREF=""
1917 SLIBSUF=".dll"
7483e694
DB
1918 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1919 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
06abe7f5 1920 SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159 1921 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
b9349ff4
MS
1922 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
1923 install -d "$(LIBDIR)"; \
1924 install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
7483e694 1925 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
4b51fb1c 1926 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
304d586d 1927 objformat="win32"
bc574408 1928 enable dos_paths
1894e741 1929 check_cflags -fno-common
b1549d61 1930 if ! enabled x86_64; then
f7ad5aa2
RP
1931 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
1932 die "ERROR: MinGW runtime version must be >= 3.15."
8beb4178 1933 enabled_any avisynth vfwcap_indev &&
f7ad5aa2 1934 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
8beb4178 1935 die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
f7ad5aa2 1936 fi
7483e694
DB
1937 ;;
1938 cygwin*)
4f854758 1939 target_os=cygwin
fbd971a4 1940 shlibdir_default="$bindir_default"
7483e694
DB
1941 SLIBPREF="cyg"
1942 SLIBSUF=".dll"
1943 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1944 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1945 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1946 objformat="win32"
bc574408 1947 enable dos_paths
1894e741 1948 check_cflags -fno-common
7483e694 1949 ;;
4f365f37 1950 *-dos|freedos|opendos)
fdf11906 1951 disable ffplay ffserver
4f365f37
MK
1952 disable $INDEV_LIST $OUTDEV_LIST
1953 network_extralibs="-lsocket"
ff1c015d 1954 objformat="coff"
bc574408 1955 enable dos_paths
4f365f37 1956 ;;
7483e694 1957 linux)
7483e694
DB
1958 enable dv1394
1959 ;;
1960 irix*)
4f854758 1961 target_os=irix
7483e694
DB
1962 ranlib="echo ignoring ranlib"
1963 ;;
d22e8442 1964 os/2*)
d22e8442
DY
1965 strip="lxlite"
1966 ln_s="cp -f"
d22e8442 1967 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 1968 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 1969 FFSERVERLDFLAGS=""
287d3b13 1970 LIBSUF="_s.a"
d22e8442
DY
1971 SLIBPREF=""
1972 SLIBSUF=".dll"
1973 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1974 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
1975 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1976 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1977 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1978 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1979 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1980 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1981 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1982 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1983 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 1984 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
bc574408 1985 enable dos_paths
d22e8442 1986 ;;
83993c1c
AM
1987 gnu/kfreebsd)
1988 ;;
34e82167 1989 gnu)
34e82167 1990 ;;
d22e8442 1991
7483e694 1992 *)
4f924f9a 1993 die "Unknown OS '$target_os'."
7483e694
DB
1994 ;;
1995esac
1996
c9d19248
MR
1997set_default $PATHS_LIST
1998
c597172e 1999add_extralibs $osextralibs
de6d9b64 2000
28d8e661
DB
2001# Combine FFLDFLAGS and the LDFLAGS environment variable.
2002LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 2003
320d060a 2004# we need to build at least one lib type
93b3c083 2005if ! enabled_any static shared; then
320d060a
DB
2006 cat <<EOF
2007At least one library type must be built.
2008Specify --enable-static to build the static libraries or --enable-shared to
2009build the shared libraries as well. To only build the shared libraries specify
2010--disable-static in addition to --enable-shared.
2011EOF
2012 exit 1;
2013fi
2014
abc4e572 2015disabled static && LIBNAME=""
2a320695 2016
a2234ceb
RP
2017if enabled_any libfaad libfaadbin ; then
2018 if check_header faad.h; then
295b8c70 2019 check_cc <<EOF
a2234ceb
RP
2020#include <faad.h>
2021#ifndef FAAD2_VERSION
2022ok faad1
2023#endif
db817cf3 2024int main(void) { return 0; }
a2234ceb
RP
2025EOF
2026 test $? = 0 && enable libfaad2
2027 else
ff3dac65 2028 die "FAAD test failed."
a2234ceb
RP
2029 fi
2030fi
2031
2032
2184c6f7 2033die_license_disabled() {
4c27207c 2034 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2184c6f7
DB
2035}
2036
2037die_license_disabled gpl libfaad2
2038die_license_disabled gpl libx264
2039die_license_disabled gpl libxvid
2040die_license_disabled gpl postproc
2041die_license_disabled gpl x11grab
2042
2f7ae63b 2043die_license_disabled nonfree libfaac
b2e3c528 2044
0b175caa
DB
2045die_license_disabled version3 libopencore_amrnb
2046die_license_disabled version3 libopencore_amrwb
2047
9cad0e4e 2048enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3fe142e2 2049
9eeed841 2050check_deps $ARCH_EXT_LIST
0f3cb305 2051
40617a6d 2052disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 2053
bce7b696
MR
2054if enabled pic; then
2055 add_cppflags -DPIC
2056 add_cflags -fPIC
2057 add_asflags -fPIC
2058fi
2059
b4d96ba2
MR
2060check_cc <<EOF || die "Symbol mangling check failed."
2061int ff_extern;
2062EOF
2f05d9c1 2063sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
2064extern_prefix=${sym%%ff_extern*}
2065
f65883c8
MR
2066check_cc <<EOF && enable inline_asm
2067void foo(void) { __asm__ volatile ("" ::); }
2068EOF
61d251db 2069
df5e3978
MR
2070_restrict=
2071for restrict_keyword in restrict __restrict__ __restrict; do
2072 check_cc <<EOF && _restrict=$restrict_keyword && break
2073void foo(char * $restrict_keyword p);
2074EOF
2075done
2076
2077check_cc <<EOF && enable attribute_packed
2078struct { int x; } __attribute__((packed)) x;
2079EOF
2080
2081check_cc <<EOF || die "endian test failed"
2082unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2083EOF
2084od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2085
fa0912fe 2086if enabled arm; then
e45391bb 2087
fa0912fe
MR
2088 check_ld <<EOF && enable vfp_args
2089__asm__ (".eabi_attribute 28, 1");
2090int main(void) { return 0; }
2091EOF
2092
2093 # We have to check if pld is a nop and disable it.
2094 check_asm pld '"pld [r0]"'
2095
2096 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2097 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2098 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2099 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2100 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2101 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
e45391bb 2102
fa0912fe 2103elif enabled mips; then
e45391bb 2104
fa0912fe
MR
2105 check_asm loongson '"dmult.g $1, $2, $3"'
2106 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
e45391bb 2107
fa0912fe 2108elif enabled ppc; then
e45391bb 2109
fa0912fe
MR
2110 check_asm dcbzl '"dcbzl 0, 1"'
2111 check_asm ppc4xx '"maclhw r10, r11, r12"'
2112 check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
2113
2114 # AltiVec flags: The FSF version of GCC differs from the Apple version
2115 if enabled altivec; then
2116 check_cflags -maltivec -mabi=altivec &&
2117 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2118 check_cflags -faltivec
2119
2120 # check if our compiler supports Motorola AltiVec C API
2121 check_cc <<EOF || disable altivec
2122$inc_altivec_h
2123int main(void) {
2124 vector signed int v1, v2, v3;
2125 v1 = vec_add(v2,v3);
2126 return 0;
2127}
2128EOF
2129
2130 # check if our compiler supports braces for vector declarations
2131 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2132$inc_altivec_h
2133int main (void) { (vector int) {1}; return 0; }
2134EOF
2135 fi
e45391bb 2136
fa0912fe 2137elif enabled sparc; then
e45391bb 2138
fa0912fe
MR
2139 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2140 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
e45391bb 2141
fa0912fe 2142elif enabled x86; then
e45391bb 2143
44965991
PI
2144 # check whether EBP is available on x86
2145 # As 'i' is stored on the stack, this program will crash
2146 # if the base pointer is used to access it because the
2147 # base pointer is cleared in the inline assembly code.
7dfef245 2148 check_exec_crash <<EOF && enable ebp_available
44965991 2149 volatile int i=0;
be449fca 2150 __asm__ volatile (
44965991
PI
2151 "xorl %%ebp, %%ebp"
2152 ::: "%ebp");
2153 return i;
44965991
PI
2154EOF
2155
2156 # check wether EBX is available on x86
940f335a 2157 check_asm ebx_available '"":::"%ebx"'
8e380710 2158
d3a4b4e0
DB
2159 # check whether more than 10 operands are supported
2160 check_cc <<EOF && enable ten_operands
2161int main(void) {
2162 int x=0;
2163 __asm__ volatile(
2164 ""
2165 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2166 );
2167 return 0;
2168}
2169EOF
2170
d7f0920b 2171 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 2172 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
5fd89ca0 2173 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
6bd859d6
MR
2174
2175 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d 2176
d52481b9 2177 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
304d586d
LM
2178 enabled x86_64 && append YASMFLAGS "-m amd64"
2179 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
2180 case "$objformat" in
2181 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 2182 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
2183 *) append YASMFLAGS "-DPREFIX" ;;
2184 esac
7595a5e4 2185 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
e45391bb 2186
44965991
PI
2187fi
2188
a98bb16d
RP
2189if check_func dlopen; then
2190 ldl=
2191elif check_func dlopen -ldl; then
2192 ldl=-ldl
8bf5d58f
MN
2193fi
2194
75ecf149
DB
2195# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2196check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2197
7483e694
DB
2198check_func fork
2199check_func gethrtime
2200check_func getrusage
094c09bb 2201check_func inet_aton $network_extralibs
abfc8d05 2202check_func isatty
7483e694
DB
2203check_func memalign
2204check_func mkstemp
1f91cdce 2205check_func posix_memalign
b507ebd1 2206check_func_headers io.h setmode
e4673692 2207check_func_headers lzo/lzo1x.h lzo1x_999_compress
2446d3d6 2208check_func_headers windows.h GetProcessTimes
7c5bfe7a 2209check_func_headers windows.h VirtualAlloc
6ffa87d3 2210
e16e49ac 2211check_header conio.h
a98bb16d
RP
2212check_header dlfcn.h
2213check_header malloc.h
bf6ce82d 2214check_header poll.h
b58412f1 2215check_header sys/mman.h
b091aa44 2216check_header sys/resource.h
bf6ce82d 2217check_header sys/select.h
a98bb16d 2218check_header termios.h
272081b0
CEH
2219check_header vdpau/vdpau.h
2220check_header vdpau/vdpau_x11.h
68178ca9 2221check_header X11/extensions/XvMClib.h
a98bb16d 2222
89e053f8
MR
2223if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2224 enabled_any $need_memalign ; then
1f91cdce 2225 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
a98bb16d 2226fi
e16e49ac 2227
a4fa192c 2228disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 2229disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
2230
2231# check for some common methods of building with pthread support
2232# do this before the optional library checks as some of them require pthreads
2233if enabled pthreads; then
9e7fd101
MR
2234 if check_func pthread_create; then
2235 :
2236 elif check_func pthread_create -pthread; then
2237 add_cflags -pthread
afc9aee2 2238 add_extralibs -pthread
9e7fd101
MR
2239 elif check_func pthread_create -pthreads; then
2240 add_cflags -pthreads
afc9aee2 2241 add_extralibs -pthreads
8d94f606
GT
2242 elif check_func pthread_create -lpthreadGC2; then
2243 add_extralibs -lpthreadGC2
9e7fd101
MR
2244 elif ! check_lib pthread.h pthread_create -lpthread; then
2245 die "ERROR: can't find pthreads library"
2246 fi
57bd82d4
MR
2247fi
2248
8eee7025 2249for thread in $THREADS_LIST; do
e5f94c2b 2250 if enabled $thread; then
3ae3b721
RP
2251 test -n "$thread_type" &&
2252 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 2253 thread_type="$thread"
e5f94c2b
RP
2254 fi
2255done
2256
fdf88598 2257check_lib math.h sin -lm
ff418735 2258check_lib va/va.h vaInitialize -lva
fdf88598 2259
ad420e25
MR
2260check_func llrint
2261check_func log2
2262check_func lrint
2263check_func lrintf
2264check_func round
2265check_func roundf
2266check_func truncf
f32adb22 2267
57bd82d4 2268# these are off by default, so fail if requested and not available
79fda097 2269enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
e3cc7d6f 2270enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
2513b2b4
DB
2271 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2272 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
79fda097
DB
2273enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2274enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694 2275enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2bfecf73 2276enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
7483e694 2277enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
0b175caa
DB
2278enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2279enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
3d6fac8c 2280enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
36718e51
DB
2281enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2282 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
ae14f311 2283enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
7483e694
DB
2284enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
2285enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
e69bb386 2286enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
57f0ec6e
MR
2287 { check_cpp_condition x264.h "X264_BUILD >= 65" ||
2288 die "ERROR: libx264 version must be >= 0.65."; }
2bfecf73 2289enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2290enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 2291
0b4a1821
AS
2292# libdc1394 check
2293if enabled libdc1394; then
2294 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2295 enable libdc1394_2; } ||
2296 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2297 enable libdc1394_1; } ||
2298 die "ERROR: No version of libdc1394 found "
2299fi
2300
497237c7
RP
2301disable sdl_too_old
2302disable sdl
6a1a892f 2303SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 2304if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5e622c40 2305 sdl_cflags=$("${SDL_CONFIG}" --cflags)
225e21ef 2306 temp_cflags $sdl_cflags
5e622c40 2307 temp_extralibs $("${SDL_CONFIG}" --libs)
1ca5d97f 2308 if check_lib2 SDL.h SDL_Init; then
5e622c40 2309 _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
29f3b38a 2310 if test "$_sdlversion" -lt 121 ; then
497237c7 2311 enable sdl_too_old
dcd479c0 2312 else
497237c7 2313 enable sdl
225e21ef 2314 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 2315#include <SDL.h>
d6773f56 2316int main(int argc, char **argv){
29f3b38a
MR
2317 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2318 int w = vi->current_w;
2319 return 0;
2320}
2321EOF
dcd479c0
MR
2322 fi
2323 fi
29f3b38a 2324 restore_flags
c3f6b472 2325fi
57bd82d4 2326
2270b4b2 2327texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2328
73b46a95 2329if enabled network; then
96000432 2330 check_type "sys/types.h sys/socket.h" socklen_t
73b46a95
RP
2331 # Prefer arpa/inet.h over winsock2
2332 if check_header arpa/inet.h ; then
2333 check_func closesocket
2334 elif check_header winsock2.h ; then
f4c13872
MS
2335 check_func_headers winsock2.h closesocket -lws2 && \
2336 network_extralibs="-lws2" || \
2337 { check_func_headers winsock2.h closesocket -lws2_32 && \
2338 network_extralibs="-lws2_32"; }
72be9e73 2339 check_type ws2tcpip.h socklen_t
28c9f069
MK
2340 else
2341 disable network
73b46a95
RP
2342 fi
2343fi
2344
b6f3d925 2345enabled_all network ipv6 && check_ld <<EOF || disable ipv6
7a91333f
HZ
2346#include <sys/types.h>
2347#include <sys/socket.h>
2348#include <netinet/in.h>
2349#include <netdb.h>
db817cf3 2350int main(void) {
7483e694
DB
2351 struct sockaddr_storage saddr;
2352 struct ipv6_mreq mreq6;
2353 getaddrinfo(0,0,0,0);
2354 getnameinfo(0,0,0,0,0,0,0);
2355 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
2356}
2357EOF
2358
06e31011
RP
2359check_header linux/videodev.h
2360check_header linux/videodev2.h
1b6e8b73 2361check_header sys/videoio.h
47f38850 2362
2446d3d6 2363check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 2364
f8aa696f 2365# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
2366{ check_header dev/bktr/ioctl_meteor.h &&
2367 check_header dev/bktr/ioctl_bt848.h; } ||
2368{ check_header machine/ioctl_meteor.h &&
2369 check_header machine/ioctl_bt848.h; } ||
2370{ check_header dev/video/meteor/ioctl_meteor.h &&
2371 check_header dev/video/bktr/ioctl_bt848.h; } ||
2372check_header dev/ic/bt8xx.h
f8aa696f 2373
c7682de0
RP
2374check_header sys/soundcard.h
2375check_header soundcard.h
deb29777 2376
b6f3d925 2377enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
35fd8122 2378
0e57fe17 2379enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
80ff8a16 2380
56a059ac 2381enabled x11grab &&
f58f4ce1
GP
2382check_header X11/Xlib.h &&
2383check_header X11/extensions/XShm.h &&
2384check_func XOpenDisplay -lX11 &&
06eab4ba 2385check_func XShmCreateImage -lX11 -lXext
f58f4ce1 2386
95e561ec 2387enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
57bd82d4
MR
2388
2389# add some useful compiler flags if supported
2390check_cflags -Wdeclaration-after-statement
dcd479c0
MR
2391check_cflags -Wall
2392check_cflags -Wno-switch
c07bd6a9
MN
2393check_cflags -Wdisabled-optimization
2394check_cflags -Wpointer-arith
2395check_cflags -Wredundant-decls
cc1fb623 2396check_cflags -Wno-pointer-sign
f4929996 2397check_cflags -Wcast-qual
9aceb3cf 2398check_cflags -Wwrite-strings
652a5bf6 2399check_cflags -Wtype-limits
764551c6 2400check_cflags -Wundef
5af4e0cc 2401enabled extra_warnings && check_cflags -Winline
cf9d24ad 2402
57bd82d4 2403# add some linker flags
5c0e9479 2404check_ldflags -Wl,--warn-common
8351d2ba
DB
2405check_ldflags -Wl,--as-needed
2406check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c2fd6530 2407check_ldflags -Wl,-Bsymbolic
94a3401e 2408
bd2216e4
MR
2409if enabled small; then
2410 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
2411 optimizations="small"
2412elif enabled optimizations; then
629687f6 2413 if enabled xlc; then
0f010b2f
DB
2414 add_cflags -O5
2415 add_ldflags -O5
df442a8d
MR
2416 elif enabled ccc; then
2417 add_cflags -fast
cf9d24ad 2418 else
0f010b2f 2419 add_cflags -O3
cf9d24ad 2420 fi
cddf3f45 2421fi
11fdbc44 2422check_cflags -fno-math-errno
b2eb2ff0 2423check_cflags -fno-signed-zeros
cddf3f45 2424
629687f6 2425if enabled icc; then
b1598b58
MR
2426 # Just warnings, no remarks
2427 check_cflags -w1
2428 # -wd: Disable following warnings
2429 # 144, 167, 556: -Wno-pointer-sign
2430 # 10006: ignoring unknown option -fno-signed-zeros
2431 # 10156: ignoring option '-W'; no argument required
2432 check_cflags -wd144,167,556,10006,10156
2433 # 11030: Warning unknown option --as-needed
2434 # 10156: ignoring option '-export'; no argument required
2435 check_ldflags -wd10156,11030
2436 # Allow to compile with optimizations
2437 check_ldflags -march=$cpu
be2cf98a
CEH
2438 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2439 enable ebp_available
df442a8d
MR
2440elif enabled ccc; then
2441 # disable some annoying warnings
2442 add_cflags -msg_disable cvtu32to64
2443 add_cflags -msg_disable embedcomment
2444 add_cflags -msg_disable needconstext
2445 add_cflags -msg_disable nomainieee
2446 add_cflags -msg_disable ptrmismatch1
2447 add_cflags -msg_disable unreachcode
973859f5
MR
2448elif enabled gcc; then
2449 check_cflags -fno-tree-vectorize
504a64b9
CEH
2450fi
2451
90be59ef 2452if enabled gprof; then
0f010b2f
DB
2453 add_cflags -p
2454 add_ldflags -p
1db54e20
DB
2455fi
2456
7f3c02fc 2457# Find out if the .align argument is a power of two or not.
9377b6ce 2458check_asm asmalign_pot '".align 3"'
4454dc1b 2459
7483e694
DB
2460enabled_any $DECODER_LIST && enable decoders
2461enabled_any $ENCODER_LIST && enable encoders
5666fd73 2462enabled_any $HWACCEL_LIST && enable hwaccels
7483e694
DB
2463enabled_any $BSF_LIST && enable bsfs
2464enabled_any $DEMUXER_LIST && enable demuxers
2465enabled_any $MUXER_LIST && enable muxers
f7679c54 2466enabled_any $FILTER_LIST && enable filters
63d72fda
DB
2467enabled_any $INDEV_LIST && enable indevs
2468enabled_any $OUTDEV_LIST && enable outdevs
7483e694
DB
2469enabled_any $PROTOCOL_LIST && enable protocols
2470
2471enabled_any $THREADS_LIST && enable threads
2472
2473check_deps $CONFIG_LIST \
b6bb00b0 2474 $CONFIG_EXTRA \
7483e694
DB
2475 $HAVE_LIST \
2476 $DECODER_LIST \
2477 $ENCODER_LIST \
5666fd73 2478 $HWACCEL_LIST \
7483e694
DB
2479 $PARSER_LIST \
2480 $BSF_LIST \
2481 $DEMUXER_LIST \
2482 $MUXER_LIST \
f7679c54 2483 $FILTER_LIST \
7483e694
DB
2484 $INDEV_LIST \
2485 $OUTDEV_LIST \
2486 $PROTOCOL_LIST \
f70f03f6 2487
3e89171a 2488echo "install prefix $prefix"
f36958f8
DB
2489echo "source path $source_path"
2490echo "C compiler $cc"
bfd5afd8 2491echo ".align is power-of-two $asmalign_pot"
f36958f8 2492echo "ARCH $arch ($cpu)"
ce8871c2
MR
2493if test "$build_suffix" != ""; then
2494 echo "build suffix $build_suffix"
eb94aca9 2495fi
ac63af34
DB
2496if test "$extra_version" != ""; then
2497 echo "version string suffix $extra_version"
2498fi
0db2ce77 2499echo "big-endian ${bigendian-no}"
e90f5b5a 2500echo "runtime cpu detection ${runtime_cpudetect-no}"
5b6c2cbd 2501if enabled x86; then
af44e8e4 2502 echo "yasm ${yasm-no}"
0db2ce77 2503 echo "MMX enabled ${mmx-no}"
30e98e62 2504 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 2505 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 2506 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 2507 echo "SSE enabled ${sse-no}"
30e98e62 2508 echo "SSSE3 enabled ${ssse3-no}"
0db2ce77
MR
2509 echo "CMOV enabled ${cmov-no}"
2510 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
2511 echo "EBX available ${ebx_available-no}"
2512 echo "EBP available ${ebp_available-no}"
d3a4b4e0 2513 echo "10 operands supported ${ten_operands-no}"
e41e8342 2514fi
5b6c2cbd 2515if enabled arm; then
0db2ce77
MR
2516 echo "ARMv5TE enabled ${armv5te-no}"
2517 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 2518 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 2519 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 2520 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 2521 echo "NEON enabled ${neon-no}"
eba9ae3c 2522fi
5b6c2cbd 2523if enabled mips; then
0db2ce77 2524 echo "MMI enabled ${mmi-no}"
e41e8342 2525fi
5b6c2cbd 2526if enabled ppc; then
0db2ce77 2527 echo "AltiVec enabled ${altivec-no}"
30e98e62 2528 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 2529 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
2530 echo "performance report ${powerpc_perf-no}"
2531fi
2532if enabled sparc; then
2533 echo "VIS enabled ${vis-no}"
e41e8342 2534fi
0db2ce77
MR
2535echo "gprof enabled ${gprof-no}"
2536echo "debug symbols ${debug-no}"
87a0fb62 2537echo "strip symbols ${stripping-no}"
8400d6b8 2538echo "optimizations ${optimizations-no}"
0db2ce77
MR
2539echo "static ${static-no}"
2540echo "shared ${shared-no}"
4a24ab64 2541echo "postprocessing support ${postproc-no}"
f7679c54 2542echo "new filter support ${avfilter-no}"
81124ba0 2543echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 2544echo "network support ${network-no}"
90be59ef 2545if enabled network; then
0db2ce77 2546 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2547fi
0db2ce77
MR
2548echo "threading support ${thread_type-no}"
2549echo "SDL support ${sdl-no}"
90be59ef 2550if enabled sdl_too_old; then
bfd5afd8
DB
2551 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2552fi
0db2ce77
MR
2553echo "Sun medialib support ${mlib-no}"
2554echo "AVISynth enabled ${avisynth-no}"
f7b8bffe 2555echo "libdc1394 support ${libdc1394-no}"
690bfceb 2556echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2557echo "libfaac enabled ${libfaac-no}"
2558echo "libfaad enabled ${libfaad-no}"
7e0871a7 2559echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2560echo "libgsm enabled ${libgsm-no}"
2561echo "libmp3lame enabled ${libmp3lame-no}"
2562echo "libnut enabled ${libnut-no}"
0b175caa
DB
2563echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2564echo "libopencore-amrwb support ${libopencore_amrwb-no}"
9a77d59a 2565echo "libopenjpeg enabled ${libopenjpeg-no}"
f7cd9eed 2566echo "libschroedinger enabled ${libschroedinger-no}"
ae14f311 2567echo "libspeex enabled ${libspeex-no}"
0db2ce77
MR
2568echo "libtheora enabled ${libtheora-no}"
2569echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2570echo "libx264 enabled ${libx264-no}"
2571echo "libxvid enabled ${libxvid-no}"
0db2ce77 2572echo "zlib enabled ${zlib-no}"
f402916e 2573echo "bzlib enabled ${bzlib-no}"
2c62e737 2574echo
de6d9b64 2575
5666fd73 2576for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2577 echo "Enabled ${type}s:"
f65c9da1 2578 eval list=\$$(toupper $type)_LIST
8138b9db 2579 for part in $list; do
f65c9da1
MR
2580 enabled $part && echo ${part%_*}
2581 done | sort | pr -3 -t
2582 echo
8138b9db
RP
2583done
2584
ba7a7039 2585license="LGPL version 2.1 or later"
ba321adb 2586if enabled nonfree; then
ba7a7039 2587 license="nonfree and unredistributable"
9cad0e4e
DB
2588elif enabled gplv3; then
2589 license="GPL version 3 or later"
2590elif enabled lgplv3; then
2591 license="LGPL version 3 or later"
ba321adb 2592elif enabled gpl; then
ba7a7039 2593 license="GPL version 2 or later"
ba321adb
JK
2594fi
2595
2596echo "License: $license"
ca5323af 2597
cf1392e9
DB
2598echo "Creating config.mak and config.h..."
2599
29799f8b
DB
2600echo "# Automatically generated by configure - do not modify!" > config.mak
2601echo "/* Automatically generated by configure - do not modify! */" > $TMPH
9c05103f
DB
2602echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2603echo "#define FFMPEG_CONFIG_H" >> $TMPH
b04251c5 2604echo "#define FFMPEG_CONFIGURATION \"$(c_escape $FFMPEG_CONFIGURATION)\"" >> $TMPH
14a8acf1 2605echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
de6d9b64 2606
8c6d2da5
MR
2607echo "ifndef FFMPEG_CONFIG_MAK" >> config.mak
2608echo "FFMPEG_CONFIG_MAK=1" >> config.mak
2609
d921f03f 2610echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
c9d19248 2611echo "prefix=$prefix" >> config.mak
22a324da
DB
2612echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2613echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2614echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2615echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
14a8acf1 2616echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
22a324da 2617echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
0a7ee3ef
DB
2618echo "SRC_PATH=\"$source_path\"" >> config.mak
2619echo "SRC_PATH_BARE=$source_path" >> config.mak
2620echo "BUILD_ROOT=\"$PWD\"" >> config.mak
980fc7b8 2621echo "CC=$cc" >> config.mak
313c46a6 2622echo "AS=$as" >> config.mak
684b28e0 2623echo "LD=$ld" >> config.mak
50567afa 2624echo "DEPCC=$dep_cc" >> config.mak
304d586d 2625echo "YASM=$yasmexe" >> config.mak
980fc7b8 2626echo "AR=$ar" >> config.mak
be7109c1 2627echo "RANLIB=$ranlib" >> config.mak
20369773 2628echo "LN_S=$ln_s" >> config.mak
87a0fb62 2629enabled stripping &&
3ae3b721 2630 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 2631 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 2632
ce40e347 2633echo "CPPFLAGS=$CPPFLAGS" >> config.mak
3198f618 2634echo "CFLAGS=$CFLAGS" >> config.mak
2f2e6c7c 2635echo "ASFLAGS=$ASFLAGS" >> config.mak
7e6c86e6 2636echo "CC_O=$CC_O" >> config.mak
0f3cb305 2637echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 2638echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 2639echo "SHFLAGS=$SHFLAGS" >> config.mak
304d586d 2640echo "YASMFLAGS=$YASMFLAGS" >> config.mak
ce8871c2 2641echo "BUILDSUF=$build_suffix" >> config.mak
c5f14466 2642echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 2643echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 2644echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 2645echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 2646echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
2647echo "SLIBSUF=$SLIBSUF" >> config.mak
2648echo "EXESUF=$EXESUF" >> config.mak
ac63af34 2649echo "EXTRA_VERSION=$extra_version" >> config.mak
d8059267 2650echo "DEPFLAGS=$DEPFLAGS" >> config.mak
07dec06e
MR
2651echo "CCDEP=$CCDEP" >> config.mak
2652echo "ASDEP=$ASDEP" >> config.mak
2653echo "CC_DEPFLAGS=$CC_DEPFLAGS" >> config.mak
2654echo "AS_DEPFLAGS=$AS_DEPFLAGS" >> config.mak
9da6609f
MR
2655echo "HOSTCC=$host_cc" >> config.mak
2656echo "HOSTCFLAGS=$host_cflags" >> config.mak
82bb3329 2657echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
9da6609f
MR
2658echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
2659echo "HOSTLIBS=$host_libs" >> config.mak
a7ada2ba
MR
2660echo "TARGET_EXEC=$target_exec" >> config.mak
2661echo "TARGET_PATH=$target_path" >> config.mak
4dc62701 2662
90be59ef 2663if enabled sdl; then
5e622c40
DB
2664 echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
2665 echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
a86b921c 2666fi
90be59ef 2667if enabled texi2html; then
7483e694 2668 echo "BUILD_DOC=yes" >> config.mak
146ea952 2669fi
5a872801 2670
719c8e00
MR
2671get_version(){
2672 name=$1
2673 file=$source_path/$2
147e7692
MR
2674 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2675 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2676 lcname=$(tolower $name)
2677 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2678 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2679}
2680
147e7692
MR
2681get_version LIBSWSCALE libswscale/swscale.h
2682get_version LIBPOSTPROC libpostproc/postprocess.h
2683get_version LIBAVCODEC libavcodec/avcodec.h
2684get_version LIBAVDEVICE libavdevice/avdevice.h
2685get_version LIBAVFORMAT libavformat/avformat.h
2686get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2687get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2688
5af4e0cc 2689if enabled shared; then
dcc01c06 2690 echo "LIBTARGET=${LIBTARGET}" >> config.mak
7483e694
DB
2691 echo "SLIBNAME=${SLIBNAME}" >> config.mak
2692 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2693 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
d22e8442 2694 echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
7483e694
DB
2695 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2696 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2697 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 2698fi
d7e27559 2699echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 2700echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 2701
7b5e8a27
DB
2702echo "ARCH=$arch" >> config.mak
2703
3d907e22
MR
2704print_config ARCH_ $TMPH config.mak $ARCH_LIST
2705print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694 2706print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
b6bb00b0 2707 $CONFIG_EXTRA \
7483e694
DB
2708 $DECODER_LIST \
2709 $ENCODER_LIST \
5666fd73 2710 $HWACCEL_LIST \
7483e694
DB
2711 $PARSER_LIST \
2712 $BSF_LIST \
2713 $DEMUXER_LIST \
2714 $MUXER_LIST \
f7679c54 2715 $FILTER_LIST \
7483e694
DB
2716 $PROTOCOL_LIST \
2717 $INDEV_LIST \
2718 $OUTDEV_LIST \
8ac17293 2719
c13e1abd
FH
2720echo "#define restrict $_restrict" >> $TMPH
2721
abbe30ad 2722if enabled small || disabled optimizations; then
7483e694 2723 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
2724fi
2725
0f3cb305 2726
8156056e 2727# Apparently it's not possible to portably echo a backslash.
3ae3b721 2728enabled asmalign_pot &&
7483e694 2729 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
295b8c70 2730 printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 2731
b4d96ba2 2732echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
bc634f6f 2733
9c05103f 2734echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
8c6d2da5 2735echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
9c05103f 2736
b7860763 2737# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2738cmp -s $TMPH config.h &&
2739 echo "config.h is unchanged" ||
2740 mv -f $TMPH config.h
3d204385 2741
165af439 2742# build tree in object directory if source path is different from current one
90be59ef 2743if enabled source_path_used; then
165af439 2744 DIRS="\
7483e694
DB
2745 doc \
2746 libavcodec \
566ae9fb 2747 libavcodec/$arch \
52a9cf34 2748 libavdevice \
f7679c54 2749 libavfilter \
7483e694
DB
2750 libavformat \
2751 libavutil \
566ae9fb 2752 libavutil/$arch \
7483e694
DB
2753 libpostproc \
2754 libswscale \
566ae9fb 2755 libswscale/$arch \
7483e694
DB
2756 tests \
2757 tools \
7483e694 2758 "
165af439 2759 FILES="\
7483e694
DB
2760 Makefile \
2761 common.mak \
71c61f62 2762 subdir.mak \
7483e694
DB
2763 doc/texi2pod.pl \
2764 libavcodec/Makefile \
52a9cf34 2765 libavdevice/Makefile \
f7679c54 2766 libavfilter/Makefile \
7483e694
DB
2767 libavformat/Makefile \
2768 libavutil/Makefile \
2769 libpostproc/Makefile \
2770 libswscale/Makefile \
2771 "
165af439 2772 for dir in $DIRS ; do
7483e694 2773 mkdir -p $dir
165af439
MR
2774 done
2775 for f in $FILES ; do
20369773 2776 $ln_s "$source_path/$f" $f
165af439
MR
2777 done
2778fi
def4272a 2779
def4272a 2780
d0674868 2781# build pkg-config files
def4272a 2782
d0674868
DB
2783pkgconfig_generate(){
2784name=$1
b0dfd108 2785shortname=${name#lib}${build_suffix}
d0674868
DB
2786comment=$2
2787version=$3
2788libs=$4
2789requires=$5
25cd5cb3 2790cat <<EOF > $name/$name.pc
3e89171a 2791prefix=$prefix
a94e666c 2792exec_prefix=\${prefix}
f2b7382c 2793libdir=$libdir
7622778e 2794includedir=$incdir
def4272a 2795
d0674868
DB
2796Name: $name
2797Description: $comment
2798Version: $version
5dcfe9f8
AH
2799Requires: $(disabled shared && echo $requires)
2800Requires.private: $(enabled shared && echo $requires)
def4272a 2801Conflicts:
12701f6e
AH
2802Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
2803Libs.private: $(enabled shared && echo $libs)
76a448ed 2804Cflags: -I\${includedir}
def4272a 2805EOF
25cd5cb3 2806cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2807prefix=
2808exec_prefix=
46d1ff83 2809libdir=\${pcfiledir}
1d44d365 2810includedir=${source_path}
def4272a 2811
d0674868
DB
2812Name: $name
2813Description: $comment
2814Version: $version
2815Requires: $requires
def4272a 2816Conflicts:
12701f6e 2817Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2818Cflags: -I\${includedir}
2819EOF
d0674868 2820}
def4272a 2821
e426941d 2822pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
46983309
RT
2823pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2824pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2825pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2826enabled avfilter &&
46983309 2827 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2828enabled postproc &&
e426941d 2829 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
5add54b4 2830pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"