Use skip_put_bytes in MJPEG encoder instead of filling all bytes with 0
[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"
6bdaa5f4 1206w64_demuxer_deps="wav_demuxer"
4e622dea
SS
1207
1208# indevs / outdevs
38e54a75
SS
1209alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1210alsa_indev_extralibs="-lasound"
1211alsa_outdev_deps="alsa_asoundlib_h"
1212alsa_outdev_extralibs="-lasound"
1213audio_beos_indev_deps="audio_beos"
1214audio_beos_indev_extralibs="-lmedia -lbe"
1215audio_beos_outdev_deps="audio_beos"
1216audio_beos_outdev_extralibs="-lmedia -lbe"
38e54a75 1217bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
38e54a75
SS
1218dv1394_indev_deps="dv1394 dv_demuxer"
1219jack_indev_deps="jack_jack_h"
1220jack_indev_extralibs="-ljack"
1221libdc1394_indev_deps="libdc1394"
38e54a75
SS
1222oss_indev_deps_any="soundcard_h sys_soundcard_h"
1223oss_outdev_deps_any="soundcard_h sys_soundcard_h"
38e54a75
SS
1224v4l_indev_deps="linux_videodev_h"
1225v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1226vfwcap_indev_deps="capCreateCaptureWindow"
1227vfwcap_indev_extralibs="-lvfw32"
1228x11_grab_device_indev_deps="x11grab XShmCreateImage"
1229x11_grab_device_indev_extralibs="-lX11 -lXext"
30fd06be 1230
912f3148 1231# protocols
3fff6382 1232gopher_protocol_deps="network"
c08fb000 1233http_protocol_deps="network"
cbf29889 1234rtmp_protocol_deps="tcp_protocol"
c08fb000
AB
1235rtp_protocol_deps="udp_protocol"
1236tcp_protocol_deps="network"
1237udp_protocol_deps="network"
1238
f7679c54 1239# filters
81124ba0 1240movie_filter_deps="avfilter_lavf"
f7679c54 1241
912f3148 1242# programs
fa859b4d 1243ffplay_deps="sdl"
6ad42348 1244ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764 1245ffserver_extralibs='$ldl'
a2830dca 1246
912f3148 1247
de6d9b64 1248# default parameters
8a608357 1249
2ba042a7 1250logfile="config.err"
8a608357
MR
1251
1252# installation paths
c9d19248
MR
1253prefix_default="/usr/local"
1254bindir_default='${prefix}/bin'
14a8acf1 1255datadir_default='${prefix}/share/ffmpeg'
c9d19248
MR
1256incdir_default='${prefix}/include'
1257libdir_default='${prefix}/lib'
1258mandir_default='${prefix}/share/man'
1259shlibdir_default="$libdir_default"
8a608357
MR
1260
1261# toolchain
11e6d03a 1262ar="ar"
13c7df3d 1263cc_default="gcc"
a3d7c197 1264cc_version=\"unknown\"
9da6609f 1265host_cc_default="gcc"
11e6d03a 1266ln_s="ln -sf"
89641463 1267nm_default="nm"
11e6d03a 1268objformat="elf"
be7109c1 1269ranlib="ranlib"
0f3cb305 1270strip="strip"
11e6d03a 1271yasmexe="yasm"
8a608357
MR
1272
1273# machine
5e622c40 1274arch=$(uname -m)
38d0a8aa 1275cpu="generic"
8a608357 1276
8a608357 1277# OS
4f854758 1278target_os=$(tolower $(uname -s))
82bb3329 1279host_os=$target_os
8a608357 1280
8a608357 1281# configurable options
497237c7 1282enable debug
aa033b1e 1283enable fastdiv
497237c7
RP
1284enable ffmpeg
1285enable ffplay
1286enable ffserver
1287enable ipv6
497237c7
RP
1288enable mpegaudio_hp
1289enable network
8400d6b8 1290enable optimizations
497237c7 1291enable protocols
530dc538 1292enable static
87a0fb62 1293enable stripping
a9ddb5b1 1294enable swscale_alpha
8a608357 1295
8a608357 1296# build settings
9987769a 1297SHFLAGS='-shared -Wl,-soname,$$(@F)'
c536cb09 1298FFSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
1299LIBPREF="lib"
1300LIBSUF=".a"
c5f14466
RP
1301FULLNAME='$(NAME)$(BUILDSUF)'
1302LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
1303SLIBPREF="lib"
1304SLIBSUF=".so"
c5f14466 1305SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
1306SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1307SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 1308LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 1309
7e6c86e6
MR
1310CC_O='-o $@'
1311
9da6609f
MR
1312host_cflags='-O3 -g -Wall'
1313host_libs='-lm'
1314
a7ada2ba
MR
1315target_path='.'
1316
0d7dca36
DB
1317# gcc stupidly only outputs the basename of targets with -MM, but we need the
1318# full relative path for objects in subdirectories for non-recursive Make.
c1c3933a 1319DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
d8059267 1320DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
315c741d 1321
c597172e 1322# find source path
5e622c40 1323source_path="$(dirname "$0")"
497237c7 1324enable source_path_used
24524f36 1325if test -f configure; then
5e622c40 1326 source_path="$(pwd)"
497237c7 1327 disable source_path_used
c597172e 1328else
5e622c40 1329 source_path="$(cd "$source_path"; pwd)"
c597172e 1330 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1331 die "Out of tree builds are impossible with whitespace in source path."
337cee68
MC
1332 test -e "$source_path/config.h" &&
1333 die "Out of tree builds are impossible with config.h in source dir."
c597172e
MR
1334fi
1335
13cbe2c0 1336for v in "$@"; do
b04251c5
MR
1337 r=${v#*=}
1338 l=${v%"$r"}
1339 r=$(sh_quote "$r")
13cbe2c0
MR
1340 FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1341done
c597172e 1342
73ef8980
MR
1343find_things(){
1344 thing=$1
1345 pattern=$2
1346 file=$source_path/$3
932ccf39 1347 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1348}
1349
1350ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1351DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
5666fd73 1352HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
73ef8980
MR
1353PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1354BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1355MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1356DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
38e54a75
SS
1357OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
1358INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
73ef8980 1359PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1360FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1361
7483e694
DB
1362enable $ARCH_EXT_LIST \
1363 $DECODER_LIST \
1364 $ENCODER_LIST \
5666fd73 1365 $HWACCEL_LIST \
7483e694
DB
1366 $PARSER_LIST \
1367 $BSF_LIST \
1368 $DEMUXER_LIST \
1369 $MUXER_LIST \
f7679c54 1370 $FILTER_LIST \
7483e694
DB
1371 $PROTOCOL_LIST \
1372 $INDEV_LIST \
1373 $OUTDEV_LIST \
c597172e
MR
1374
1375die_unknown(){
1376 echo "Unknown option \"$1\"."
1377 echo "See $0 --help for available options."
1378 exit 1
1379}
1380
794f8e97 1381show_list() {
bf0c4afa
RP
1382 suffix=_$1
1383 shift
1384 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
1385 exit 0
1386}
1387
c597172e 1388for opt do
7483e694
DB
1389 optval="${opt#*=}"
1390 case "$opt" in
0f010b2f 1391 --extra-ldflags=*) add_ldflags $optval
7483e694 1392 ;;
0f010b2f 1393 --extra-libs=*) add_extralibs $optval
7483e694 1394 ;;
8fb1cb58 1395 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1396 ;;
40bcf4c7
BL
1397 --enable-debug=*) debuglevel="$optval"
1398 ;;
7483e694 1399 --enable-*=*|--disable-*=*)
8b93ddc3 1400 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
be8f2501
MR
1401 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1402 eval list=\$$(toupper $thing)_LIST
8b93ddc3
MR
1403 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1404 $action $(filter "$name" $list)
7483e694
DB
1405 ;;
1406 --enable-?*|--disable-?*)
5e622c40 1407 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
e3773a55 1408 if is_in $option $COMPONENT_LIST; then
fed5d54b 1409 test $action = disable && action=unset
e3773a55
MR
1410 eval $action \$$(toupper ${option%s})_LIST
1411 elif is_in $option $CMDLINE_SELECT; then
1412 $action $option
1413 else
1414 die_unknown $opt
1415 fi
7483e694
DB
1416 ;;
1417 --list-*)
1418 NAME="${opt#--list-}"
1419 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1420 NAME=${NAME%s}
1421 eval show_list $NAME \$$(toupper $NAME)_LIST
1422 ;;
1423 --help|-h) show_help
1424 ;;
1425 *)
884a36a7 1426 optname="${opt%%=*}"
26759c44
MR
1427 optname="${optname#--}"
1428 optname=$(echo "$optname" | sed 's/-/_/g')
89f2932b
MR
1429 if is_in $optname $CMDLINE_SET; then
1430 eval $optname='$optval'
1431 elif is_in $optname $CMDLINE_APPEND; then
1432 append $optname "$optval"
1433 else
1434 die_unknown $opt
1435 fi
7483e694
DB
1436 ;;
1437 esac
c597172e
MR
1438done
1439
bcea99bb
MR
1440disabled logging && logfile=/dev/null
1441
13cbe2c0 1442echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
bcea99bb
MR
1443set >> $logfile
1444
9da6609f
MR
1445test -n "$cross_prefix" && enable cross_compile
1446
adb2b908 1447ar="${cross_prefix}${ar}"
11e6d03a 1448cc_default="${cross_prefix}${cc_default}"
20e0ed95 1449nm_default="${cross_prefix}${nm_default}"
adb2b908
RP
1450ranlib="${cross_prefix}${ranlib}"
1451strip="${cross_prefix}${strip}"
1452
c5200f17
MR
1453sysinclude_default="${sysroot}/usr/include"
1454
75800dce 1455set_default cc nm sysinclude
9da6609f
MR
1456enabled cross_compile || host_cc_default=$cc
1457set_default host_cc
13c7df3d 1458
82bb3329
MR
1459exesuf() {
1460 case $1 in
1461 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1462 esac
1463}
1464
1465EXESUF=$(exesuf $target_os)
1466HOSTEXESUF=$(exesuf $host_os)
c0f5b7f1 1467
e4e69e0b 1468# set temporary file name
a49d42c2 1469: ${TMPDIR:=$TEMPDIR}
c51fafa1 1470: ${TMPDIR:=$TMP}
a49d42c2 1471: ${TMPDIR:=/tmp}
e4e69e0b 1472
54460a83
MR
1473if ! check_cmd type mktemp; then
1474 # simple replacement for missing mktemp
1475 # NOT SAFE FOR GENERAL USE
1476 mktemp(){
1477 echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1478 }
1479fi
1480
1481tmpfile(){
1482 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1483 (set -C; exec > $tmp) 2>/dev/null ||
f7ba16a7 1484 die "Unable to create temporary file in $TMPDIR."
54460a83
MR
1485 append TMPFILES $tmp
1486 eval $1=$tmp
1487}
1488
1489trap 'rm -f -- $TMPFILES' EXIT
1490trap exit HUP INT TERM
1491
1492tmpfile TMPC .c
1493tmpfile TMPE $EXESUF
1494tmpfile TMPH .h
1495tmpfile TMPO .o
1496tmpfile TMPS .S
1497tmpfile TMPSH .sh
1498
1499unset -f mktemp
e4e69e0b 1500
993f2d0f
MR
1501# make sure we can execute files in $TMPDIR
1502cat > $TMPSH 2>> $logfile <<EOF
1503#! /bin/sh
1504EOF
1505chmod +x $TMPSH >> $logfile 2>&1
1506if ! $TMPSH >> $logfile 2>&1; then
1507 cat <<EOF
1508Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1509variable to another directory and make sure that it is not mounted noexec.
1510EOF
1511 die "Sanity test failed."
1512fi
993f2d0f 1513
19b4c628
MR
1514filter_cflags=echo
1515filter_cppflags=echo
1516filter_asflags=echo
1517
8f0c157a 1518if $cc -v 2>&1 | grep -qi ^gcc; then
629687f6 1519 cc_type=gcc
a3d7c197 1520 cc_version=__VERSION__
aef6bd1b
MR
1521 if ! $cc -dumpversion | grep -q '^2\.'; then
1522 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1523 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1524 fi
629687f6
MR
1525elif $cc --version 2>/dev/null | grep -q Intel; then
1526 cc_type=icc
6e3fa35d 1527 cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
07dec06e
MR
1528 CC_DEPFLAGS='-MMD'
1529 AS_DEPFLAGS='-MMD'
629687f6
MR
1530elif $cc -v 2>&1 | grep -q xlc; then
1531 cc_type=xlc
6e3fa35d 1532 cc_version="AV_STRINGIFY(__IBMC__)"
df442a8d
MR
1533elif $cc -V 2>/dev/null | grep -q Compaq; then
1534 cc_type=ccc
6e3fa35d 1535 cc_version="AV_STRINGIFY(__DECC_VER)"
d8059267 1536 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
03754fcd 1537 debuglevel=3
df442a8d 1538 add_ldflags -Wl,-z,now # calls to libots crash without this
6a0d5493 1539elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
03e37762
MR
1540 test -d "$sysroot" || die "No valid sysroot specified."
1541 cc_type=armcc
6e3fa35d 1542 cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
03e37762
MR
1543 armcc_conf="$PWD/armcc.conf"
1544 $cc --arm_linux_configure \
1545 --arm_linux_config_file="$armcc_conf" \
1546 --configure_sysroot="$sysroot" \
1547 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1548 die "Error creating armcc configuration file."
1549 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
75800dce 1550 as_default="${cross_prefix}gcc"
07dec06e
MR
1551 CC_DEPFLAGS='-MMD'
1552 AS_DEPFLAGS='-MMD'
6fec122a
MR
1553elif $cc -version 2>/dev/null | grep -q TMS470; then
1554 cc_type=tms470
6e3fa35d 1555 cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
6fec122a
MR
1556 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1557 CC_O='-fr=$(@D)'
1558 as_default="${cross_prefix}gcc"
1559 ld_default="${cross_prefix}gcc"
6fec122a
MR
1560 TMPO=$(basename $TMPC .c).o
1561 append TMPFILES $TMPO
1562 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
07dec06e
MR
1563 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1564 AS_DEPFLAGS='-MMD'
6fec122a
MR
1565 filter_cflags=tms470_flags
1566 tms470_flags(){
1567 for flag; do
1568 case $flag in
1569 -march=*|-mcpu=*)
1570 case "${flag#*=}" in
1571 armv7-a|cortex-a*) echo -mv=7a8 ;;
1572 armv7-r|cortex-r*) echo -mv=7r4 ;;
1573 armv7-m|cortex-m*) echo -mv=7m3 ;;
1574 armv6*|arm11*) echo -mv=6 ;;
1575 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1576 echo -mv=5e ;;
1577 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
1578 esac
1579 ;;
1580 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
1581 -mfpu=vfp) echo --float_support=vfpv2 ;;
a2709020 1582 -msoft-float) echo --float_support=vfplib ;;
6fec122a
MR
1583 -Os) echo -O3 -mf=2 ;;
1584 -O[0-3]) echo $flag -mf=5 ;;
1585 -g) echo -g -mn ;;
1586 esac
1587 done
1588 }
629687f6
MR
1589fi
1590
1591test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1592
75bafbac 1593: ${as_default:=$cc}
50567afa 1594: ${dep_cc_default:=$cc}
684b28e0 1595: ${ld_default:=$cc}
50567afa 1596set_default as dep_cc ld
75800dce 1597
07dec06e
MR
1598test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1599test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1600
7f32f40c 1601add_cflags $extra_cflags
2f2e6c7c 1602add_asflags $extra_cflags
7f32f40c 1603
154d432c
MR
1604if test -n "$sysroot"; then
1605 case "$cc_type" in
1606 gcc)
467256f2 1607 add_cppflags --sysroot="$sysroot"
154d432c
MR
1608 add_ldflags --sysroot="$sysroot"
1609 ;;
6fec122a
MR
1610 tms470)
1611 add_cppflags -I"$sysinclude"
1612 add_ldflags --sysroot="$sysroot"
1613 ;;
154d432c
MR
1614 esac
1615fi
1616
d22c13a8
MR
1617if test "$cpu" = host; then
1618 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1619
1620 case "$cc_type" in
1621 gcc)
1622 check_native(){
1623 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1624 awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1625 }
1626 cpu=$(check_native -march || check_native -mcpu)
1627 ;;
1628 esac
1629
1630 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1631fi
1632
df5cdc24
MR
1633# Add processor-specific flags
1634case $cpu in
1635 601|ppc601|PowerPC601)
1636 cpuflags="-mcpu=601"
1637 ;;
1638 603*|ppc603*|PowerPC603*)
1639 cpuflags="-mcpu=603"
1640 ;;
1641 604*|ppc604*|PowerPC604*)
1642 cpuflags="-mcpu=604"
1643 ;;
1644 G3|g3|75*|ppc75*|PowerPC75*)
1645 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1646 ;;
1647 G4|g4|745*|ppc745*|PowerPC745*)
1648 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1649 ;;
1650 74*|ppc74*|PowerPC74*)
1651 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1652 ;;
1653 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1654 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1655 ;;
1656 Cell|CELL|cell)
1657 cpuflags="-mcpu=cell"
1658 enable ldbrx
1659 ;;
1660 # targets that do NOT support conditional mov (cmov)
1661 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1662 cpuflags="-march=$cpu"
1663 disable cmov
1664 ;;
1665 # targets that do support conditional mov (cmov)
1666 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1667 cpuflags="-march=$cpu"
1668 enable cmov
1669 enable fast_cmov
1670 ;;
1671 # targets that do support conditional mov but on which it's slow
1672 pentium4|pentium4m|prescott|nocona)
1673 cpuflags="-march=$cpu"
1674 enable cmov
1675 disable fast_cmov
1676 ;;
1677 sparc64)
1678 cpuflags="-mcpu=v9"
1679 ;;
1680 arm11*|cortex*)
1681 cpuflags="-mcpu=$cpu"
1682 enable fast_unaligned
1683 ;;
1684 armv[67]*)
1685 cpuflags="-march=$cpu"
1686 enable fast_unaligned
1687 ;;
1688 armv*)
1689 cpuflags="-march=$cpu"
1690 ;;
1691 arm*)
1692 cpuflags="-mcpu=$cpu"
1693 ;;
1694 ev4|ev45|ev5|ev56|pca56|ev6|ev67)
1695 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1696 ;;
1697 bf*)
1698 cpuflags="-mcpu=$cpu"
1699 ;;
1700 mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
1701 cpuflags="-march=$cpu"
1702 ;;
fdcd782d
MR
1703 ap7[02]0[0-2])
1704 subarch="avr32_ap"
1705 cpuflags="-mpart=$cpu"
1706 ;;
1707 ap)
1708 subarch="avr32_ap"
1709 cpuflags="-march=$cpu"
1710 ;;
1711 uc3[ab]*)
1712 subarch="avr32_uc"
1713 cpuflags="-mcpu=$cpu"
1714 ;;
1715 uc)
1716 subarch="avr32_uc"
1717 cpuflags="-march=$cpu"
1718 ;;
df5cdc24
MR
1719 generic)
1720 ;;
1721 *)
1722 echo "WARNING: Unknown CPU \"$cpu\", ignored."
1723 ;;
1724esac
1725
1726add_cflags $cpuflags
1727add_asflags $cpuflags
1728
993f2d0f
MR
1729# compiler sanity check
1730check_exec <<EOF
1731int main(void){ return 0; }
1732EOF
1733if test "$?" != 0; then
1734 echo "$cc is unable to create an executable file."
1735 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1736 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1737 echo "Only do this if you know what cross compiling means."
1738 fi
1739 die "C compiler test failed."
1740fi
1741
38a9c529 1742add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
e9b9a2f8 1743check_cflags -std=c99
50a334e4 1744check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
9d821fc2
DB
1745#include <stdlib.h>
1746EOF
50a334e4 1747check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
9d821fc2
DB
1748#include <stdlib.h>
1749EOF
e9b9a2f8 1750
b24dbcbd 1751case "$arch" in
b24dbcbd
RP
1752 alpha)
1753 arch="alpha"
1754 enable fast_64bit
c0a02a3e 1755 check_cflags -mieee
8a3c8627 1756 spic=$shared
b24dbcbd 1757 ;;
cfdb6148
MR
1758 arm|armv[4567]*l)
1759 arch="arm"
b24dbcbd 1760 ;;
f4870943
MR
1761 avr32)
1762 ;;
cfdb6148
MR
1763 bfin)
1764 arch="bfin"
1765 ;;
1766 ia64)
1767 arch="ia64"
b24dbcbd 1768 enable fast_64bit
8a3c8627 1769 spic=$shared
cfdb6148
MR
1770 ;;
1771 m68k)
1772 arch="m68k"
b24dbcbd 1773 ;;
de3a1240 1774 mips|mipsel|IP*)
b24dbcbd 1775 arch="mips"
8a3c8627 1776 spic=$shared
b24dbcbd 1777 ;;
de3a1240
DB
1778 mips64)
1779 arch="mips"
bae3abb0 1780 subarch="mips64"
de3a1240 1781 enable fast_64bit
8a3c8627 1782 spic=$shared
de3a1240 1783 ;;
61597a98 1784 parisc|hppa)
b24dbcbd 1785 arch="parisc"
8a3c8627 1786 spic=$shared
b24dbcbd 1787 ;;
61597a98 1788 parisc64|hppa64)
b24dbcbd
RP
1789 arch="parisc"
1790 enable fast_64bit
8a3c8627 1791 spic=$shared
b24dbcbd 1792 ;;
cfdb6148
MR
1793 "Power Macintosh"|ppc|powerpc)
1794 arch="ppc"
1795 enable fast_unaligned
1796 ;;
1797 ppc64)
1798 arch="ppc"
34d11b87 1799 subarch="ppc64"
cfdb6148
MR
1800 enable fast_64bit
1801 enable fast_unaligned
1802 ;;
b24dbcbd
RP
1803 s390|s390x)
1804 arch="s390"
1805 ;;
cfdb6148
MR
1806 sh4|sh)
1807 arch="sh4"
b24dbcbd 1808 ;;
cfdb6148
MR
1809 sparc)
1810 arch="sparc"
8a3c8627 1811 spic=$shared
cfdb6148
MR
1812 ;;
1813 sun4u|sparc64)
1814 arch="sparc"
1815 subarch="sparc64"
b24dbcbd 1816 enable fast_64bit
8a3c8627 1817 spic=$shared
b24dbcbd 1818 ;;
cfdb6148
MR
1819 i386|i486|i586|i686|i86pc|BePC)
1820 arch="x86"
1821 subarch="x86_32"
1822 enable fast_unaligned
1823 ;;
1824 x86_64|amd64)
1825 arch="x86"
1826 subarch="x86_32"
1827 enable cmov
1828 enable fast_cmov
1829 enable fast_unaligned
8a3c8627 1830 check_cc <<EOF && enable fast_64bit && subarch="x86_64" && spic=$shared
cfdb6148
MR
1831 int test[sizeof(char*) - 7];
1832EOF
b24dbcbd
RP
1833 ;;
1834 *)
1835 arch="unknown"
1836 ;;
1837esac
1838
62045d48 1839enable $arch $subarch
8a3c8627 1840enabled spic && enable pic
b24dbcbd 1841
7483e694 1842# OS specific
4f854758 1843case $target_os in
7483e694 1844 beos|haiku|zeta)
c9d19248 1845 prefix_default="$HOME/config"
7483e694 1846 # helps building libavcodec
50a334e4
MR
1847 add_cppflags -DPIC
1848 add_cflags -fomit-frame-pointer
7483e694 1849 # 3 gcc releases known for BeOS, each with ugly bugs
5e622c40 1850 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
7483e694
DB
1851 case "$gcc_version" in
1852 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1853 disable mmx
1854 ;;
1855 *20010315*) echo "BeBits gcc"
0f010b2f 1856 add_cflags -fno-expensive-optimizations
7483e694
DB
1857 ;;
1858 esac
7483e694
DB
1859 SHFLAGS=-nostart
1860 # enable BeOS things
1861 enable audio_beos
1862 # no need for libm, but the inet stuff
1863 # Check for BONE
1864 # XXX: actually should check for NOT net_server
78fe7631 1865 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1866 network_extralibs="-lbind -lsocket"
1867 else
1868 enable beos_netserver
1869 network_extralibs="-lnet"
1870 fi ;;
1871 sunos)
1872 FFSERVERLDFLAGS=""
9987769a 1873 SHFLAGS='-shared -Wl,-h,$$(@F)'
7483e694 1874 network_extralibs="-lsocket -lnsl"
50a334e4 1875 add_cppflags -D__EXTENSIONS__
7483e694
DB
1876 ;;
1877 netbsd)
07a8eef6
MR
1878 oss_indev_extralibs="-lossaudio"
1879 oss_outdev_extralibs="-lossaudio"
7483e694
DB
1880 ;;
1881 openbsd)
89e053f8 1882 enable malloc_aligned
cd78208b 1883 enable pic
7483e694 1884 SHFLAGS='-shared'
07a8eef6
MR
1885 oss_indev_extralibs="-lossaudio"
1886 oss_outdev_extralibs="-lossaudio"
7483e694 1887 ;;
90b4f091 1888 freebsd|dragonfly)
89e053f8 1889 enable malloc_aligned
7483e694
DB
1890 ;;
1891 bsd/os)
1892 osextralibs="-lpoll -lgnugetopt"
1893 strip="strip -d"
1894 ;;
1895 darwin)
89e053f8 1896 enable malloc_aligned
0138c54e 1897 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
7483e694
DB
1898 strip="strip -x"
1899 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1900 SLIBSUF=".dylib"
1901 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1902 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1903 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1904 objformat="macho"
1b0f6fb8 1905 enabled x86_64 && objformat="macho64"
2704bd1a
AS
1906 enabled shared ||
1907 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
7483e694
DB
1908 ;;
1909 mingw32*)
9d3f4f50 1910 if test $target_os = "mingw32ce"; then
1aa71e25
MS
1911 disable network
1912 else
1913 target_os=mingw32
1914 fi
dcc01c06 1915 LIBTARGET=i386
1fc9fb8a 1916 if enabled x86_64; then
89e053f8 1917 enable malloc_aligned
dcc01c06 1918 LIBTARGET=x64
336cc1b0
MS
1919 elif enabled arm; then
1920 LIBTARGET=arm
dcc01c06 1921 fi
fbd971a4 1922 shlibdir_default="$bindir_default"
7483e694
DB
1923 disable ffserver
1924 SLIBPREF=""
1925 SLIBSUF=".dll"
7483e694
DB
1926 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1927 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
06abe7f5 1928 SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159 1929 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
b9349ff4
MS
1930 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
1931 install -d "$(LIBDIR)"; \
1932 install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
7483e694 1933 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
4b51fb1c 1934 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 1935 objformat="win32"
bc574408 1936 enable dos_paths
1894e741 1937 check_cflags -fno-common
b1549d61 1938 if ! enabled x86_64; then
f7ad5aa2
RP
1939 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
1940 die "ERROR: MinGW runtime version must be >= 3.15."
8beb4178 1941 enabled_any avisynth vfwcap_indev &&
f7ad5aa2 1942 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
8beb4178 1943 die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
f7ad5aa2 1944 fi
7483e694
DB
1945 ;;
1946 cygwin*)
4f854758 1947 target_os=cygwin
fbd971a4 1948 shlibdir_default="$bindir_default"
7483e694
DB
1949 SLIBPREF="cyg"
1950 SLIBSUF=".dll"
1951 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1952 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1953 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1954 objformat="win32"
bc574408 1955 enable dos_paths
1894e741 1956 check_cflags -fno-common
7483e694 1957 ;;
4f365f37 1958 *-dos|freedos|opendos)
fdf11906 1959 disable ffplay ffserver
4f365f37
MK
1960 disable $INDEV_LIST $OUTDEV_LIST
1961 network_extralibs="-lsocket"
ff1c015d 1962 objformat="coff"
bc574408 1963 enable dos_paths
4f365f37 1964 ;;
7483e694 1965 linux)
7483e694
DB
1966 enable dv1394
1967 ;;
1968 irix*)
4f854758 1969 target_os=irix
7483e694
DB
1970 ranlib="echo ignoring ranlib"
1971 ;;
d22e8442 1972 os/2*)
d22e8442
DY
1973 strip="lxlite"
1974 ln_s="cp -f"
d22e8442 1975 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 1976 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 1977 FFSERVERLDFLAGS=""
287d3b13 1978 LIBSUF="_s.a"
d22e8442
DY
1979 SLIBPREF=""
1980 SLIBSUF=".dll"
1981 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1982 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
1983 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1984 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1985 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1986 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1987 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1988 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1989 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1990 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1991 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 1992 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
bc574408 1993 enable dos_paths
d22e8442 1994 ;;
83993c1c
AM
1995 gnu/kfreebsd)
1996 ;;
34e82167 1997 gnu)
34e82167 1998 ;;
d22e8442 1999
7483e694 2000 *)
4f924f9a 2001 die "Unknown OS '$target_os'."
7483e694
DB
2002 ;;
2003esac
2004
c9d19248
MR
2005set_default $PATHS_LIST
2006
c597172e 2007add_extralibs $osextralibs
de6d9b64 2008
28d8e661
DB
2009# Combine FFLDFLAGS and the LDFLAGS environment variable.
2010LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 2011
320d060a 2012# we need to build at least one lib type
93b3c083 2013if ! enabled_any static shared; then
320d060a
DB
2014 cat <<EOF
2015At least one library type must be built.
2016Specify --enable-static to build the static libraries or --enable-shared to
2017build the shared libraries as well. To only build the shared libraries specify
2018--disable-static in addition to --enable-shared.
2019EOF
2020 exit 1;
2021fi
2022
abc4e572 2023disabled static && LIBNAME=""
2a320695 2024
a2234ceb
RP
2025if enabled_any libfaad libfaadbin ; then
2026 if check_header faad.h; then
295b8c70 2027 check_cc <<EOF
a2234ceb
RP
2028#include <faad.h>
2029#ifndef FAAD2_VERSION
2030ok faad1
2031#endif
db817cf3 2032int main(void) { return 0; }
a2234ceb
RP
2033EOF
2034 test $? = 0 && enable libfaad2
2035 else
ff3dac65 2036 die "FAAD test failed."
a2234ceb
RP
2037 fi
2038fi
2039
2040
2184c6f7 2041die_license_disabled() {
4c27207c 2042 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2184c6f7
DB
2043}
2044
2045die_license_disabled gpl libfaad2
2046die_license_disabled gpl libx264
2047die_license_disabled gpl libxvid
2048die_license_disabled gpl postproc
2049die_license_disabled gpl x11grab
2050
2f7ae63b 2051die_license_disabled nonfree libfaac
b2e3c528 2052
0b175caa
DB
2053die_license_disabled version3 libopencore_amrnb
2054die_license_disabled version3 libopencore_amrwb
2055
9cad0e4e 2056enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3fe142e2 2057
9eeed841 2058check_deps $ARCH_EXT_LIST
0f3cb305 2059
40617a6d 2060disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 2061
bce7b696
MR
2062if enabled pic; then
2063 add_cppflags -DPIC
2064 add_cflags -fPIC
2065 add_asflags -fPIC
2066fi
2067
b4d96ba2
MR
2068check_cc <<EOF || die "Symbol mangling check failed."
2069int ff_extern;
2070EOF
2f05d9c1 2071sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
2072extern_prefix=${sym%%ff_extern*}
2073
f65883c8
MR
2074check_cc <<EOF && enable inline_asm
2075void foo(void) { __asm__ volatile ("" ::); }
2076EOF
61d251db 2077
df5e3978
MR
2078_restrict=
2079for restrict_keyword in restrict __restrict__ __restrict; do
2080 check_cc <<EOF && _restrict=$restrict_keyword && break
2081void foo(char * $restrict_keyword p);
2082EOF
2083done
2084
2085check_cc <<EOF && enable attribute_packed
2086struct { int x; } __attribute__((packed)) x;
2087EOF
2088
2089check_cc <<EOF || die "endian test failed"
2090unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2091EOF
2092od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2093
fa0912fe 2094if enabled arm; then
e45391bb 2095
fa0912fe
MR
2096 check_ld <<EOF && enable vfp_args
2097__asm__ (".eabi_attribute 28, 1");
2098int main(void) { return 0; }
2099EOF
2100
2101 # We have to check if pld is a nop and disable it.
2102 check_asm pld '"pld [r0]"'
2103
2104 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2105 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2106 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2107 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2108 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2109 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
e45391bb 2110
fa0912fe 2111elif enabled mips; then
e45391bb 2112
fa0912fe
MR
2113 check_asm loongson '"dmult.g $1, $2, $3"'
2114 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
e45391bb 2115
fa0912fe 2116elif enabled ppc; then
e45391bb 2117
fa0912fe
MR
2118 check_asm dcbzl '"dcbzl 0, 1"'
2119 check_asm ppc4xx '"maclhw r10, r11, r12"'
2120 check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
2121
2122 # AltiVec flags: The FSF version of GCC differs from the Apple version
2123 if enabled altivec; then
2124 check_cflags -maltivec -mabi=altivec &&
2125 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2126 check_cflags -faltivec
2127
2128 # check if our compiler supports Motorola AltiVec C API
2129 check_cc <<EOF || disable altivec
2130$inc_altivec_h
2131int main(void) {
2132 vector signed int v1, v2, v3;
2133 v1 = vec_add(v2,v3);
2134 return 0;
2135}
2136EOF
2137
2138 # check if our compiler supports braces for vector declarations
2139 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2140$inc_altivec_h
2141int main (void) { (vector int) {1}; return 0; }
2142EOF
2143 fi
e45391bb 2144
fa0912fe 2145elif enabled sparc; then
e45391bb 2146
fa0912fe
MR
2147 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2148 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
e45391bb 2149
fa0912fe 2150elif enabled x86; then
e45391bb 2151
44965991
PI
2152 # check whether EBP is available on x86
2153 # As 'i' is stored on the stack, this program will crash
2154 # if the base pointer is used to access it because the
2155 # base pointer is cleared in the inline assembly code.
7dfef245 2156 check_exec_crash <<EOF && enable ebp_available
44965991 2157 volatile int i=0;
be449fca 2158 __asm__ volatile (
44965991
PI
2159 "xorl %%ebp, %%ebp"
2160 ::: "%ebp");
2161 return i;
44965991
PI
2162EOF
2163
2164 # check wether EBX is available on x86
940f335a 2165 check_asm ebx_available '"":::"%ebx"'
8e380710 2166
d3a4b4e0
DB
2167 # check whether more than 10 operands are supported
2168 check_cc <<EOF && enable ten_operands
2169int main(void) {
2170 int x=0;
2171 __asm__ volatile(
2172 ""
2173 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2174 );
2175 return 0;
2176}
2177EOF
2178
d7f0920b 2179 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 2180 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
5fd89ca0 2181 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
6bd859d6
MR
2182
2183 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d 2184
d52481b9 2185 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
304d586d
LM
2186 enabled x86_64 && append YASMFLAGS "-m amd64"
2187 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
2188 case "$objformat" in
2189 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 2190 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
2191 *) append YASMFLAGS "-DPREFIX" ;;
2192 esac
7595a5e4 2193 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
e45391bb 2194
44965991
PI
2195fi
2196
a98bb16d
RP
2197if check_func dlopen; then
2198 ldl=
2199elif check_func dlopen -ldl; then
2200 ldl=-ldl
8bf5d58f
MN
2201fi
2202
75ecf149
DB
2203# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2204check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2205
7483e694
DB
2206check_func fork
2207check_func gethrtime
2208check_func getrusage
094c09bb 2209check_func inet_aton $network_extralibs
abfc8d05 2210check_func isatty
7483e694
DB
2211check_func memalign
2212check_func mkstemp
1f91cdce 2213check_func posix_memalign
b507ebd1 2214check_func_headers io.h setmode
e4673692 2215check_func_headers lzo/lzo1x.h lzo1x_999_compress
2446d3d6 2216check_func_headers windows.h GetProcessTimes
7c5bfe7a 2217check_func_headers windows.h VirtualAlloc
6ffa87d3 2218
e16e49ac 2219check_header conio.h
a98bb16d
RP
2220check_header dlfcn.h
2221check_header malloc.h
bf6ce82d 2222check_header poll.h
b58412f1 2223check_header sys/mman.h
b091aa44 2224check_header sys/resource.h
bf6ce82d 2225check_header sys/select.h
a98bb16d 2226check_header termios.h
272081b0
CEH
2227check_header vdpau/vdpau.h
2228check_header vdpau/vdpau_x11.h
68178ca9 2229check_header X11/extensions/XvMClib.h
a98bb16d 2230
89e053f8
MR
2231if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2232 enabled_any $need_memalign ; then
1f91cdce 2233 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
a98bb16d 2234fi
e16e49ac 2235
a4fa192c 2236disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 2237disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
2238
2239# check for some common methods of building with pthread support
2240# do this before the optional library checks as some of them require pthreads
2241if enabled pthreads; then
9e7fd101
MR
2242 if check_func pthread_create; then
2243 :
2244 elif check_func pthread_create -pthread; then
2245 add_cflags -pthread
afc9aee2 2246 add_extralibs -pthread
9e7fd101
MR
2247 elif check_func pthread_create -pthreads; then
2248 add_cflags -pthreads
afc9aee2 2249 add_extralibs -pthreads
8d94f606
GT
2250 elif check_func pthread_create -lpthreadGC2; then
2251 add_extralibs -lpthreadGC2
9e7fd101
MR
2252 elif ! check_lib pthread.h pthread_create -lpthread; then
2253 die "ERROR: can't find pthreads library"
2254 fi
57bd82d4
MR
2255fi
2256
8eee7025 2257for thread in $THREADS_LIST; do
e5f94c2b 2258 if enabled $thread; then
3ae3b721
RP
2259 test -n "$thread_type" &&
2260 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 2261 thread_type="$thread"
e5f94c2b
RP
2262 fi
2263done
2264
fdf88598 2265check_lib math.h sin -lm
ff418735 2266check_lib va/va.h vaInitialize -lva
fdf88598 2267
ad420e25
MR
2268check_func llrint
2269check_func log2
2270check_func lrint
2271check_func lrintf
2272check_func round
2273check_func roundf
2274check_func truncf
f32adb22 2275
57bd82d4 2276# these are off by default, so fail if requested and not available
79fda097 2277enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
e3cc7d6f 2278enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
2513b2b4
DB
2279 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2280 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
79fda097
DB
2281enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2282enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694 2283enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2bfecf73 2284enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
7483e694 2285enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
0b175caa
DB
2286enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2287enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
3d6fac8c 2288enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
36718e51
DB
2289enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2290 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
ae14f311 2291enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
7483e694
DB
2292enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
2293enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
e69bb386 2294enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
2d3beede
JGG
2295 { check_cpp_condition x264.h "X264_BUILD >= 76" ||
2296 die "ERROR: libx264 version must be >= 0.76."; }
2bfecf73 2297enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2298enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 2299
0b4a1821
AS
2300# libdc1394 check
2301if enabled libdc1394; then
2302 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2303 enable libdc1394_2; } ||
2304 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2305 enable libdc1394_1; } ||
2306 die "ERROR: No version of libdc1394 found "
2307fi
2308
497237c7
RP
2309disable sdl_too_old
2310disable sdl
6a1a892f 2311SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 2312if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5e622c40 2313 sdl_cflags=$("${SDL_CONFIG}" --cflags)
225e21ef 2314 temp_cflags $sdl_cflags
5e622c40 2315 temp_extralibs $("${SDL_CONFIG}" --libs)
1ca5d97f 2316 if check_lib2 SDL.h SDL_Init; then
5e622c40 2317 _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
29f3b38a 2318 if test "$_sdlversion" -lt 121 ; then
497237c7 2319 enable sdl_too_old
dcd479c0 2320 else
497237c7 2321 enable sdl
225e21ef 2322 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 2323#include <SDL.h>
d6773f56 2324int main(int argc, char **argv){
29f3b38a
MR
2325 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2326 int w = vi->current_w;
2327 return 0;
2328}
2329EOF
dcd479c0
MR
2330 fi
2331 fi
29f3b38a 2332 restore_flags
c3f6b472 2333fi
57bd82d4 2334
2270b4b2 2335texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2336
73b46a95 2337if enabled network; then
96000432 2338 check_type "sys/types.h sys/socket.h" socklen_t
73b46a95
RP
2339 # Prefer arpa/inet.h over winsock2
2340 if check_header arpa/inet.h ; then
2341 check_func closesocket
2342 elif check_header winsock2.h ; then
f4c13872
MS
2343 check_func_headers winsock2.h closesocket -lws2 && \
2344 network_extralibs="-lws2" || \
2345 { check_func_headers winsock2.h closesocket -lws2_32 && \
2346 network_extralibs="-lws2_32"; }
72be9e73 2347 check_type ws2tcpip.h socklen_t
28c9f069
MK
2348 else
2349 disable network
73b46a95
RP
2350 fi
2351fi
2352
b6f3d925 2353enabled_all network ipv6 && check_ld <<EOF || disable ipv6
7a91333f
HZ
2354#include <sys/types.h>
2355#include <sys/socket.h>
2356#include <netinet/in.h>
2357#include <netdb.h>
db817cf3 2358int main(void) {
7483e694
DB
2359 struct sockaddr_storage saddr;
2360 struct ipv6_mreq mreq6;
2361 getaddrinfo(0,0,0,0);
2362 getnameinfo(0,0,0,0,0,0,0);
2363 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
2364}
2365EOF
2366
06e31011
RP
2367check_header linux/videodev.h
2368check_header linux/videodev2.h
1b6e8b73 2369check_header sys/videoio.h
47f38850 2370
2446d3d6 2371check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 2372
f8aa696f 2373# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
2374{ check_header dev/bktr/ioctl_meteor.h &&
2375 check_header dev/bktr/ioctl_bt848.h; } ||
2376{ check_header machine/ioctl_meteor.h &&
2377 check_header machine/ioctl_bt848.h; } ||
2378{ check_header dev/video/meteor/ioctl_meteor.h &&
2379 check_header dev/video/bktr/ioctl_bt848.h; } ||
2380check_header dev/ic/bt8xx.h
f8aa696f 2381
c7682de0
RP
2382check_header sys/soundcard.h
2383check_header soundcard.h
deb29777 2384
b6f3d925 2385enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
35fd8122 2386
0e57fe17 2387enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
80ff8a16 2388
56a059ac 2389enabled x11grab &&
f58f4ce1
GP
2390check_header X11/Xlib.h &&
2391check_header X11/extensions/XShm.h &&
2392check_func XOpenDisplay -lX11 &&
06eab4ba 2393check_func XShmCreateImage -lX11 -lXext
f58f4ce1 2394
95e561ec 2395enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
57bd82d4
MR
2396
2397# add some useful compiler flags if supported
2398check_cflags -Wdeclaration-after-statement
dcd479c0
MR
2399check_cflags -Wall
2400check_cflags -Wno-switch
c07bd6a9
MN
2401check_cflags -Wdisabled-optimization
2402check_cflags -Wpointer-arith
2403check_cflags -Wredundant-decls
cc1fb623 2404check_cflags -Wno-pointer-sign
f4929996 2405check_cflags -Wcast-qual
9aceb3cf 2406check_cflags -Wwrite-strings
652a5bf6 2407check_cflags -Wtype-limits
764551c6 2408check_cflags -Wundef
5af4e0cc 2409enabled extra_warnings && check_cflags -Winline
cf9d24ad 2410
57bd82d4 2411# add some linker flags
5c0e9479 2412check_ldflags -Wl,--warn-common
8351d2ba
DB
2413check_ldflags -Wl,--as-needed
2414check_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 2415check_ldflags -Wl,-Bsymbolic
94a3401e 2416
bd2216e4
MR
2417if enabled small; then
2418 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
2419 optimizations="small"
2420elif enabled optimizations; then
629687f6 2421 if enabled xlc; then
0f010b2f
DB
2422 add_cflags -O5
2423 add_ldflags -O5
df442a8d
MR
2424 elif enabled ccc; then
2425 add_cflags -fast
cf9d24ad 2426 else
0f010b2f 2427 add_cflags -O3
cf9d24ad 2428 fi
cddf3f45 2429fi
11fdbc44 2430check_cflags -fno-math-errno
b2eb2ff0 2431check_cflags -fno-signed-zeros
cddf3f45 2432
629687f6 2433if enabled icc; then
b1598b58
MR
2434 # Just warnings, no remarks
2435 check_cflags -w1
2436 # -wd: Disable following warnings
2437 # 144, 167, 556: -Wno-pointer-sign
2438 # 10006: ignoring unknown option -fno-signed-zeros
2439 # 10156: ignoring option '-W'; no argument required
2440 check_cflags -wd144,167,556,10006,10156
2441 # 11030: Warning unknown option --as-needed
2442 # 10156: ignoring option '-export'; no argument required
2443 check_ldflags -wd10156,11030
2444 # Allow to compile with optimizations
2445 check_ldflags -march=$cpu
be2cf98a
CEH
2446 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2447 enable ebp_available
df442a8d
MR
2448elif enabled ccc; then
2449 # disable some annoying warnings
2450 add_cflags -msg_disable cvtu32to64
2451 add_cflags -msg_disable embedcomment
2452 add_cflags -msg_disable needconstext
2453 add_cflags -msg_disable nomainieee
2454 add_cflags -msg_disable ptrmismatch1
2455 add_cflags -msg_disable unreachcode
973859f5
MR
2456elif enabled gcc; then
2457 check_cflags -fno-tree-vectorize
504a64b9
CEH
2458fi
2459
90be59ef 2460if enabled gprof; then
0f010b2f
DB
2461 add_cflags -p
2462 add_ldflags -p
1db54e20
DB
2463fi
2464
7f3c02fc 2465# Find out if the .align argument is a power of two or not.
9377b6ce 2466check_asm asmalign_pot '".align 3"'
4454dc1b 2467
7483e694
DB
2468enabled_any $DECODER_LIST && enable decoders
2469enabled_any $ENCODER_LIST && enable encoders
5666fd73 2470enabled_any $HWACCEL_LIST && enable hwaccels
7483e694
DB
2471enabled_any $BSF_LIST && enable bsfs
2472enabled_any $DEMUXER_LIST && enable demuxers
2473enabled_any $MUXER_LIST && enable muxers
f7679c54 2474enabled_any $FILTER_LIST && enable filters
63d72fda
DB
2475enabled_any $INDEV_LIST && enable indevs
2476enabled_any $OUTDEV_LIST && enable outdevs
7483e694
DB
2477enabled_any $PROTOCOL_LIST && enable protocols
2478
2479enabled_any $THREADS_LIST && enable threads
2480
2481check_deps $CONFIG_LIST \
b6bb00b0 2482 $CONFIG_EXTRA \
7483e694
DB
2483 $HAVE_LIST \
2484 $DECODER_LIST \
2485 $ENCODER_LIST \
5666fd73 2486 $HWACCEL_LIST \
7483e694
DB
2487 $PARSER_LIST \
2488 $BSF_LIST \
2489 $DEMUXER_LIST \
2490 $MUXER_LIST \
f7679c54 2491 $FILTER_LIST \
7483e694
DB
2492 $INDEV_LIST \
2493 $OUTDEV_LIST \
2494 $PROTOCOL_LIST \
f70f03f6 2495
3e89171a 2496echo "install prefix $prefix"
f36958f8
DB
2497echo "source path $source_path"
2498echo "C compiler $cc"
bfd5afd8 2499echo ".align is power-of-two $asmalign_pot"
f36958f8 2500echo "ARCH $arch ($cpu)"
ce8871c2
MR
2501if test "$build_suffix" != ""; then
2502 echo "build suffix $build_suffix"
eb94aca9 2503fi
ac63af34
DB
2504if test "$extra_version" != ""; then
2505 echo "version string suffix $extra_version"
2506fi
0db2ce77 2507echo "big-endian ${bigendian-no}"
e90f5b5a 2508echo "runtime cpu detection ${runtime_cpudetect-no}"
5b6c2cbd 2509if enabled x86; then
af44e8e4 2510 echo "yasm ${yasm-no}"
0db2ce77 2511 echo "MMX enabled ${mmx-no}"
30e98e62 2512 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 2513 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 2514 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 2515 echo "SSE enabled ${sse-no}"
30e98e62 2516 echo "SSSE3 enabled ${ssse3-no}"
0db2ce77
MR
2517 echo "CMOV enabled ${cmov-no}"
2518 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
2519 echo "EBX available ${ebx_available-no}"
2520 echo "EBP available ${ebp_available-no}"
d3a4b4e0 2521 echo "10 operands supported ${ten_operands-no}"
e41e8342 2522fi
5b6c2cbd 2523if enabled arm; then
0db2ce77
MR
2524 echo "ARMv5TE enabled ${armv5te-no}"
2525 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 2526 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 2527 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 2528 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 2529 echo "NEON enabled ${neon-no}"
eba9ae3c 2530fi
5b6c2cbd 2531if enabled mips; then
0db2ce77 2532 echo "MMI enabled ${mmi-no}"
e41e8342 2533fi
5b6c2cbd 2534if enabled ppc; then
0db2ce77 2535 echo "AltiVec enabled ${altivec-no}"
30e98e62 2536 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 2537 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
2538 echo "performance report ${powerpc_perf-no}"
2539fi
2540if enabled sparc; then
2541 echo "VIS enabled ${vis-no}"
e41e8342 2542fi
0db2ce77
MR
2543echo "gprof enabled ${gprof-no}"
2544echo "debug symbols ${debug-no}"
87a0fb62 2545echo "strip symbols ${stripping-no}"
8400d6b8 2546echo "optimizations ${optimizations-no}"
0db2ce77
MR
2547echo "static ${static-no}"
2548echo "shared ${shared-no}"
4a24ab64 2549echo "postprocessing support ${postproc-no}"
f7679c54 2550echo "new filter support ${avfilter-no}"
81124ba0 2551echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 2552echo "network support ${network-no}"
90be59ef 2553if enabled network; then
0db2ce77 2554 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2555fi
0db2ce77
MR
2556echo "threading support ${thread_type-no}"
2557echo "SDL support ${sdl-no}"
90be59ef 2558if enabled sdl_too_old; then
bfd5afd8
DB
2559 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2560fi
0db2ce77
MR
2561echo "Sun medialib support ${mlib-no}"
2562echo "AVISynth enabled ${avisynth-no}"
f7b8bffe 2563echo "libdc1394 support ${libdc1394-no}"
690bfceb 2564echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2565echo "libfaac enabled ${libfaac-no}"
2566echo "libfaad enabled ${libfaad-no}"
7e0871a7 2567echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2568echo "libgsm enabled ${libgsm-no}"
2569echo "libmp3lame enabled ${libmp3lame-no}"
2570echo "libnut enabled ${libnut-no}"
0b175caa
DB
2571echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2572echo "libopencore-amrwb support ${libopencore_amrwb-no}"
9a77d59a 2573echo "libopenjpeg enabled ${libopenjpeg-no}"
f7cd9eed 2574echo "libschroedinger enabled ${libschroedinger-no}"
ae14f311 2575echo "libspeex enabled ${libspeex-no}"
0db2ce77
MR
2576echo "libtheora enabled ${libtheora-no}"
2577echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2578echo "libx264 enabled ${libx264-no}"
2579echo "libxvid enabled ${libxvid-no}"
0db2ce77 2580echo "zlib enabled ${zlib-no}"
f402916e 2581echo "bzlib enabled ${bzlib-no}"
2c62e737 2582echo
de6d9b64 2583
5666fd73 2584for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2585 echo "Enabled ${type}s:"
f65c9da1 2586 eval list=\$$(toupper $type)_LIST
8138b9db 2587 for part in $list; do
f65c9da1
MR
2588 enabled $part && echo ${part%_*}
2589 done | sort | pr -3 -t
2590 echo
8138b9db
RP
2591done
2592
ba7a7039 2593license="LGPL version 2.1 or later"
ba321adb 2594if enabled nonfree; then
ba7a7039 2595 license="nonfree and unredistributable"
9cad0e4e
DB
2596elif enabled gplv3; then
2597 license="GPL version 3 or later"
2598elif enabled lgplv3; then
2599 license="LGPL version 3 or later"
ba321adb 2600elif enabled gpl; then
ba7a7039 2601 license="GPL version 2 or later"
ba321adb
JK
2602fi
2603
2604echo "License: $license"
ca5323af 2605
cf1392e9
DB
2606echo "Creating config.mak and config.h..."
2607
29799f8b 2608echo "# Automatically generated by configure - do not modify!" > config.mak
8c6d2da5
MR
2609echo "ifndef FFMPEG_CONFIG_MAK" >> config.mak
2610echo "FFMPEG_CONFIG_MAK=1" >> config.mak
2611
d921f03f 2612echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
c9d19248 2613echo "prefix=$prefix" >> config.mak
22a324da
DB
2614echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2615echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2616echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2617echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
14a8acf1 2618echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
22a324da 2619echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
0a7ee3ef
DB
2620echo "SRC_PATH=\"$source_path\"" >> config.mak
2621echo "SRC_PATH_BARE=$source_path" >> config.mak
2622echo "BUILD_ROOT=\"$PWD\"" >> config.mak
980fc7b8 2623echo "CC=$cc" >> config.mak
313c46a6 2624echo "AS=$as" >> config.mak
684b28e0 2625echo "LD=$ld" >> config.mak
50567afa 2626echo "DEPCC=$dep_cc" >> config.mak
304d586d 2627echo "YASM=$yasmexe" >> config.mak
980fc7b8 2628echo "AR=$ar" >> config.mak
be7109c1 2629echo "RANLIB=$ranlib" >> config.mak
20369773 2630echo "LN_S=$ln_s" >> config.mak
87a0fb62 2631enabled stripping &&
3ae3b721 2632 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 2633 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 2634
ce40e347 2635echo "CPPFLAGS=$CPPFLAGS" >> config.mak
3198f618 2636echo "CFLAGS=$CFLAGS" >> config.mak
2f2e6c7c 2637echo "ASFLAGS=$ASFLAGS" >> config.mak
7e6c86e6 2638echo "CC_O=$CC_O" >> config.mak
0f3cb305 2639echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 2640echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 2641echo "SHFLAGS=$SHFLAGS" >> config.mak
304d586d 2642echo "YASMFLAGS=$YASMFLAGS" >> config.mak
ce8871c2 2643echo "BUILDSUF=$build_suffix" >> config.mak
c5f14466 2644echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 2645echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 2646echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 2647echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 2648echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
2649echo "SLIBSUF=$SLIBSUF" >> config.mak
2650echo "EXESUF=$EXESUF" >> config.mak
ac63af34 2651echo "EXTRA_VERSION=$extra_version" >> config.mak
d8059267 2652echo "DEPFLAGS=$DEPFLAGS" >> config.mak
07dec06e
MR
2653echo "CCDEP=$CCDEP" >> config.mak
2654echo "ASDEP=$ASDEP" >> config.mak
2655echo "CC_DEPFLAGS=$CC_DEPFLAGS" >> config.mak
2656echo "AS_DEPFLAGS=$AS_DEPFLAGS" >> config.mak
9da6609f
MR
2657echo "HOSTCC=$host_cc" >> config.mak
2658echo "HOSTCFLAGS=$host_cflags" >> config.mak
82bb3329 2659echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
9da6609f
MR
2660echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
2661echo "HOSTLIBS=$host_libs" >> config.mak
a7ada2ba
MR
2662echo "TARGET_EXEC=$target_exec" >> config.mak
2663echo "TARGET_PATH=$target_path" >> config.mak
4dc62701 2664
90be59ef 2665if enabled sdl; then
5e622c40
DB
2666 echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
2667 echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
a86b921c 2668fi
90be59ef 2669if enabled texi2html; then
7483e694 2670 echo "BUILD_DOC=yes" >> config.mak
146ea952 2671fi
5a872801 2672
719c8e00
MR
2673get_version(){
2674 name=$1
2675 file=$source_path/$2
147e7692
MR
2676 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2677 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2678 lcname=$(tolower $name)
2679 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2680 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2681}
2682
147e7692
MR
2683get_version LIBSWSCALE libswscale/swscale.h
2684get_version LIBPOSTPROC libpostproc/postprocess.h
2685get_version LIBAVCODEC libavcodec/avcodec.h
2686get_version LIBAVDEVICE libavdevice/avdevice.h
2687get_version LIBAVFORMAT libavformat/avformat.h
2688get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2689get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2690
5af4e0cc 2691if enabled shared; then
dcc01c06 2692 echo "LIBTARGET=${LIBTARGET}" >> config.mak
7483e694
DB
2693 echo "SLIBNAME=${SLIBNAME}" >> config.mak
2694 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2695 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
d22e8442 2696 echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
7483e694
DB
2697 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2698 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2699 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 2700fi
d7e27559 2701echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 2702echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 2703
7b5e8a27
DB
2704echo "ARCH=$arch" >> config.mak
2705
523ef551
DB
2706
2707echo "/* Automatically generated by configure - do not modify! */" > $TMPH
2708echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2709echo "#define FFMPEG_CONFIG_H" >> $TMPH
2710echo "#define FFMPEG_CONFIGURATION \"$(c_escape $FFMPEG_CONFIGURATION)\"" >> $TMPH
2711echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
2712
a3d7c197
DB
2713echo "#define CC_TYPE \"$cc_type\"" >> $TMPH
2714echo "#define CC_VERSION $cc_version" >> $TMPH
523ef551
DB
2715echo "#define restrict $_restrict" >> $TMPH
2716
2717if enabled small || disabled optimizations; then
2718 echo "#define av_always_inline" >> $TMPH
2719fi
2720
2721
2722# Apparently it's not possible to portably echo a backslash.
2723enabled asmalign_pot &&
2724 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
2725 printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
2726
2727echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
2728
3d907e22
MR
2729print_config ARCH_ $TMPH config.mak $ARCH_LIST
2730print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694 2731print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
b6bb00b0 2732 $CONFIG_EXTRA \
7483e694
DB
2733 $DECODER_LIST \
2734 $ENCODER_LIST \
5666fd73 2735 $HWACCEL_LIST \
7483e694
DB
2736 $PARSER_LIST \
2737 $BSF_LIST \
2738 $DEMUXER_LIST \
2739 $MUXER_LIST \
f7679c54 2740 $FILTER_LIST \
7483e694
DB
2741 $PROTOCOL_LIST \
2742 $INDEV_LIST \
2743 $OUTDEV_LIST \
8ac17293 2744
9c05103f 2745echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
8c6d2da5 2746echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
9c05103f 2747
b7860763 2748# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2749cmp -s $TMPH config.h &&
2750 echo "config.h is unchanged" ||
2751 mv -f $TMPH config.h
3d204385 2752
165af439 2753# build tree in object directory if source path is different from current one
90be59ef 2754if enabled source_path_used; then
b767b9cd
MR
2755 DIRS="
2756 doc
2757 libavcodec
2758 libavcodec/$arch
2759 libavdevice
2760 libavfilter
2761 libavformat
2762 libavutil
2763 libavutil/$arch
2764 libpostproc
2765 libswscale
2766 libswscale/$arch
2767 tests
2768 tools
2769 "
2770 FILES="
2771 Makefile
2772 common.mak
2773 subdir.mak
2774 doc/texi2pod.pl
2775 libavcodec/Makefile
2776 libavdevice/Makefile
2777 libavfilter/Makefile
2778 libavformat/Makefile
2779 libavutil/Makefile
2780 libpostproc/Makefile
2781 libswscale/Makefile
2782 "
165af439 2783 for dir in $DIRS ; do
7483e694 2784 mkdir -p $dir
165af439
MR
2785 done
2786 for f in $FILES ; do
20369773 2787 $ln_s "$source_path/$f" $f
165af439
MR
2788 done
2789fi
def4272a 2790
def4272a 2791
d0674868 2792# build pkg-config files
def4272a 2793
d0674868
DB
2794pkgconfig_generate(){
2795name=$1
b0dfd108 2796shortname=${name#lib}${build_suffix}
d0674868
DB
2797comment=$2
2798version=$3
2799libs=$4
2800requires=$5
25cd5cb3 2801cat <<EOF > $name/$name.pc
3e89171a 2802prefix=$prefix
a94e666c 2803exec_prefix=\${prefix}
f2b7382c 2804libdir=$libdir
7622778e 2805includedir=$incdir
def4272a 2806
d0674868
DB
2807Name: $name
2808Description: $comment
2809Version: $version
8cd6b388 2810Requires: $(enabled shared || echo $requires)
5dcfe9f8 2811Requires.private: $(enabled shared && echo $requires)
def4272a 2812Conflicts:
8cd6b388 2813Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
12701f6e 2814Libs.private: $(enabled shared && echo $libs)
76a448ed 2815Cflags: -I\${includedir}
def4272a 2816EOF
25cd5cb3 2817cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2818prefix=
2819exec_prefix=
46d1ff83 2820libdir=\${pcfiledir}
1d44d365 2821includedir=${source_path}
def4272a 2822
d0674868
DB
2823Name: $name
2824Description: $comment
2825Version: $version
2826Requires: $requires
def4272a 2827Conflicts:
12701f6e 2828Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2829Cflags: -I\${includedir}
2830EOF
d0674868 2831}
def4272a 2832
e426941d 2833pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
46983309
RT
2834pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2835pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2836pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2837enabled avfilter &&
46983309 2838 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2839enabled postproc &&
e426941d 2840 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
5add54b4 2841pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"