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