avutil/log: skip IO calls on empty strings
[ffmpeg.git] / configure
1 #!/bin/sh
2 #
3 # FFmpeg configure script
4 #
5 # Copyright (c) 2000-2002 Fabrice Bellard
6 # Copyright (c) 2005-2008 Diego Biurrun
7 # Copyright (c) 2005-2008 Mans Rullgard
8 #
9
10 # Prevent locale nonsense from breaking basic text processing.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 try_exec(){
18     echo "Trying shell $1"
19     type "$1" > /dev/null 2>&1 && exec "$@"
20 }
21
22 unset foo
23 (: ${foo%%bar}) 2> /dev/null
24 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30     echo "Broken shell detected.  Trying alternatives."
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" "$@"
43     fi
44     echo "No compatible shell script interpreter found."
45     echo "This configure script requires a POSIX-compatible shell"
46     echo "such as bash or ksh."
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."
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
54     exit 1
55 fi
56
57 test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59 show_help(){
60     cat <<EOF
61 Usage: configure [options]
62 Options: [defaults in brackets after descriptions]
63
64 Help options:
65   --help                   print this message
66   --list-decoders          show all available decoders
67   --list-encoders          show all available encoders
68   --list-hwaccels          show all available hardware accelerators
69   --list-demuxers          show all available demuxers
70   --list-muxers            show all available muxers
71   --list-parsers           show all available parsers
72   --list-protocols         show all available protocols
73   --list-bsfs              show all available bitstream filters
74   --list-indevs            show all available input devices
75   --list-outdevs           show all available output devices
76   --list-filters           show all available filters
77
78 Standard options:
79   --logfile=FILE           log tests and output to FILE [config.log]
80   --disable-logging        do not log configure debug information
81   --fatal-warnings         fail if any configure warning is generated
82   --prefix=PREFIX          install in PREFIX [$prefix]
83   --bindir=DIR             install binaries in DIR [PREFIX/bin]
84   --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
85   --docdir=DIR             install documentation in DIR [PREFIX/share/doc/ffmpeg]
86   --libdir=DIR             install libs in DIR [PREFIX/lib]
87   --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
88   --incdir=DIR             install includes in DIR [PREFIX/include]
89   --mandir=DIR             install man page in DIR [PREFIX/share/man]
90
91 Licensing options:
92   --enable-gpl             allow use of GPL code, the resulting libs
93                            and binaries will be under GPL [no]
94   --enable-version3        upgrade (L)GPL to version 3 [no]
95   --enable-nonfree         allow use of nonfree code, the resulting libs
96                            and binaries will be unredistributable [no]
97
98 Configuration options:
99   --disable-static         do not build static libraries [no]
100   --enable-shared          build shared libraries [no]
101   --enable-small           optimize for size instead of speed
102   --disable-runtime-cpudetect disable detecting cpu capabilities at runtime (smaller binary)
103   --enable-gray            enable full grayscale support (slower color)
104   --disable-swscale-alpha  disable alpha channel support in swscale
105   --disable-all            disable building components, libraries and programs
106   --enable-incompatible-libav-abi enable incompatible Libav fork ABI [no]
107   --enable-incompatible-fork-abi  enable incompatible Libav fork ABI (deprecated) [no]
108
109 Program options:
110   --disable-programs       do not build command line programs
111   --disable-ffmpeg         disable ffmpeg build
112   --disable-ffplay         disable ffplay build
113   --disable-ffprobe        disable ffprobe build
114   --disable-ffserver       disable ffserver build
115
116 Documentation options:
117   --disable-doc            do not build documentation
118   --disable-htmlpages      do not build HTML documentation pages
119   --disable-manpages       do not build man documentation pages
120   --disable-podpages       do not build POD documentation pages
121   --disable-txtpages       do not build text documentation pages
122
123 Component options:
124   --disable-avdevice       disable libavdevice build
125   --disable-avcodec        disable libavcodec build
126   --disable-avformat       disable libavformat build
127   --disable-avutil         disable libavutil build
128   --disable-swresample     disable libswresample build
129   --disable-swscale        disable libswscale build
130   --disable-postproc       disable libpostproc build
131   --disable-avfilter       disable libavfilter build
132   --enable-avresample      enable libavresample build [no]
133   --disable-pthreads       disable pthreads [auto]
134   --disable-w32threads     disable Win32 threads [auto]
135   --disable-os2threads     disable OS/2 threads [auto]
136   --disable-network        disable network support [no]
137   --disable-dct            disable DCT code
138   --disable-dwt            disable DWT code
139   --disable-error-resilience disable error resilience code
140   --disable-lsp            disable LSP code
141   --disable-lzo            disable LZO decoder code
142   --disable-mdct           disable MDCT code
143   --disable-rdft           disable RDFT code
144   --disable-fft            disable FFT code
145
146 Hardware accelerators:
147   --disable-dxva2          disable DXVA2 code [autodetect]
148   --disable-vaapi          disable VAAPI code [autodetect]
149   --enable-vda             enable VDA code
150   --disable-vdpau          disable VDPAU code [autodetect]
151
152 Individual component options:
153   --disable-everything     disable all components listed below
154   --disable-encoder=NAME   disable encoder NAME
155   --enable-encoder=NAME    enable encoder NAME
156   --disable-encoders       disable all encoders
157   --disable-decoder=NAME   disable decoder NAME
158   --enable-decoder=NAME    enable decoder NAME
159   --disable-decoders       disable all decoders
160   --disable-hwaccel=NAME   disable hwaccel NAME
161   --enable-hwaccel=NAME    enable hwaccel NAME
162   --disable-hwaccels       disable all hwaccels
163   --disable-muxer=NAME     disable muxer NAME
164   --enable-muxer=NAME      enable muxer NAME
165   --disable-muxers         disable all muxers
166   --disable-demuxer=NAME   disable demuxer NAME
167   --enable-demuxer=NAME    enable demuxer NAME
168   --disable-demuxers       disable all demuxers
169   --enable-parser=NAME     enable parser NAME
170   --disable-parser=NAME    disable parser NAME
171   --disable-parsers        disable all parsers
172   --enable-bsf=NAME        enable bitstream filter NAME
173   --disable-bsf=NAME       disable bitstream filter NAME
174   --disable-bsfs           disable all bitstream filters
175   --enable-protocol=NAME   enable protocol NAME
176   --disable-protocol=NAME  disable protocol NAME
177   --disable-protocols      disable all protocols
178   --enable-indev=NAME      enable input device NAME
179   --disable-indev=NAME     disable input device NAME
180   --disable-indevs         disable input devices
181   --enable-outdev=NAME     enable output device NAME
182   --disable-outdev=NAME    disable output device NAME
183   --disable-outdevs        disable output devices
184   --disable-devices        disable all devices
185   --enable-filter=NAME     enable filter NAME
186   --disable-filter=NAME    disable filter NAME
187   --disable-filters        disable all filters
188
189 External library support:
190   --enable-avisynth        enable reading of AviSynth script files [no]
191   --disable-bzlib          disable bzlib [autodetect]
192   --enable-fontconfig      enable fontconfig
193   --enable-frei0r          enable frei0r video filtering
194   --enable-gnutls          enable gnutls [no]
195   --disable-iconv          disable iconv [autodetect]
196   --enable-ladspa          enable LADSPA audio filtering
197   --enable-libaacplus      enable AAC+ encoding via libaacplus [no]
198   --enable-libass          enable libass subtitles rendering [no]
199   --enable-libbluray       enable BluRay reading using libbluray [no]
200   --enable-libcaca         enable textual display using libcaca
201   --enable-libcelt         enable CELT decoding via libcelt [no]
202   --enable-libcdio         enable audio CD grabbing with libcdio
203   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
204                            and libraw1394 [no]
205   --enable-libfaac         enable AAC encoding via libfaac [no]
206   --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
207   --enable-libflite        enable flite (voice synthesis) support via libflite [no]
208   --enable-libfreetype     enable libfreetype [no]
209   --enable-libgme          enable Game Music Emu via libgme [no]
210   --enable-libgsm          enable GSM de/encoding via libgsm [no]
211   --enable-libiec61883     enable iec61883 via libiec61883 [no]
212   --enable-libilbc         enable iLBC de/encoding via libilbc [no]
213   --enable-libmodplug      enable ModPlug via libmodplug [no]
214   --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
215   --enable-libnut          enable NUT (de)muxing via libnut,
216                            native (de)muxer exists [no]
217   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
218   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
219   --enable-libopencv       enable video filtering via libopencv [no]
220   --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
221   --enable-libopus         enable Opus decoding via libopus [no]
222   --enable-libpulse        enable Pulseaudio input via libpulse [no]
223   --enable-libquvi         enable quvi input via libquvi [no]
224   --enable-librtmp         enable RTMP[E] support via librtmp [no]
225   --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
226   --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
227   --enable-libsoxr         enable Include libsoxr resampling [no]
228   --enable-libspeex        enable Speex de/encoding via libspeex [no]
229   --enable-libssh          enable SFTP protocol via libssh [no]
230   --enable-libstagefright-h264  enable H.264 decoding via libstagefright [no]
231   --enable-libtheora       enable Theora encoding via libtheora [no]
232   --enable-libtwolame      enable MP2 encoding via libtwolame [no]
233   --enable-libutvideo      enable Ut Video encoding and decoding via libutvideo [no]
234   --enable-libv4l2         enable libv4l2/v4l-utils [no]
235   --enable-libvidstab      enable video stabilization using vid.stab [no]
236   --enable-libvo-aacenc    enable AAC encoding via libvo-aacenc [no]
237   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
238   --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
239                            native implementation exists [no]
240   --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
241   --enable-libwavpack      enable wavpack encoding via libwavpack [no]
242   --enable-libx264         enable H.264 encoding via x264 [no]
243   --enable-libxavs         enable AVS encoding via xavs [no]
244   --enable-libxvid         enable Xvid encoding via xvidcore,
245                            native MPEG-4/Xvid encoder exists [no]
246   --enable-libzmq          enable message passing via libzmq [no]
247   --enable-libzvbi         enable teletext support via libzvbi [no]
248   --enable-openal          enable OpenAL 1.1 capture support [no]
249   --enable-opencl          enable OpenCL code
250   --enable-openssl         enable openssl [no]
251   --enable-x11grab         enable X11 grabbing [no]
252   --disable-zlib           disable zlib [autodetect]
253
254 Advanced options (experts only):
255   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
256   --enable-cross-compile   assume a cross-compiler is used
257   --sysroot=PATH           root of cross-build tree
258   --sysinclude=PATH        location of cross-build system headers
259   --target-os=OS           compiler targets OS [$target_os]
260   --target-exec=CMD        command to run executables on target
261   --target-path=DIR        path to view of build directory on target
262   --target-samples=DIR     path to samples directory on target
263   --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
264   --toolchain=NAME         set tool defaults according to NAME
265   --nm=NM                  use nm tool NM [$nm_default]
266   --ar=AR                  use archive tool AR [$ar_default]
267   --as=AS                  use assembler AS [$as_default]
268   --yasmexe=EXE            use yasm-compatible assembler EXE [$yasmexe_default]
269   --cc=CC                  use C compiler CC [$cc_default]
270   --cxx=CXX                use C compiler CXX [$cxx_default]
271   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
272   --ld=LD                  use linker LD [$ld_default]
273   --host-cc=HOSTCC         use host C compiler HOSTCC
274   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
275   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
276   --host-ld=HOSTLD         use host linker HOSTLD
277   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
278   --host-libs=HLIBS        use libs HLIBS when linking for host
279   --host-os=OS             compiler host OS [$target_os]
280   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
281   --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
282   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
283   --extra-libs=ELIBS       add ELIBS [$ELIBS]
284   --extra-version=STRING   version string suffix []
285   --optflags=OPTFLAGS      override optimization-related compiler flags
286   --build-suffix=SUFFIX    library name suffix []
287   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
288   --progs-suffix=SUFFIX    program name suffix []
289   --arch=ARCH              select architecture [$arch]
290   --cpu=CPU                select the minimum required CPU (affects
291                            instruction selection, may crash on older CPUs)
292   --enable-pic             build position-independent code
293   --enable-sram            allow use of on-chip SRAM
294   --enable-thumb           compile for Thumb instruction set
295   --disable-symver         disable symbol versioning
296   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
297   --disable-safe-bitstream-reader
298                            disable buffer boundary checking in bitreaders
299                            (faster, but may crash)
300   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
301   --enable-lto             use link-time optimization
302
303 Optimization options (experts only):
304   --disable-asm            disable all assembler optimizations
305   --disable-altivec        disable AltiVec optimizations
306   --disable-amd3dnow       disable 3DNow! optimizations
307   --disable-amd3dnowext    disable 3DNow! extended optimizations
308   --disable-mmx            disable MMX optimizations
309   --disable-mmxext         disable MMXEXT optimizations
310   --disable-sse            disable SSE optimizations
311   --disable-sse2           disable SSE2 optimizations
312   --disable-sse3           disable SSE3 optimizations
313   --disable-ssse3          disable SSSE3 optimizations
314   --disable-sse4           disable SSE4 optimizations
315   --disable-sse42          disable SSE4.2 optimizations
316   --disable-avx            disable AVX optimizations
317   --disable-fma4           disable FMA4 optimizations
318   --disable-avx2           disable AVX2 optimizations
319   --disable-armv5te        disable armv5te optimizations
320   --disable-armv6          disable armv6 optimizations
321   --disable-armv6t2        disable armv6t2 optimizations
322   --disable-vfp            disable VFP optimizations
323   --disable-neon           disable NEON optimizations
324   --disable-vis            disable VIS optimizations
325   --disable-inline-asm     disable use of inline assembler
326   --disable-yasm           disable use of yasm assembler
327   --disable-mips32r2       disable MIPS32R2 optimizations
328   --disable-mipsdspr1      disable MIPS DSP ASE R1 optimizations
329   --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
330   --disable-mipsfpu        disable floating point MIPS optimizations
331   --disable-fast-unaligned consider unaligned accesses slow
332
333 Developer options (useful when working on FFmpeg itself):
334   --disable-debug          disable debugging symbols
335   --enable-debug=LEVEL     set the debug level [$debuglevel]
336   --disable-optimizations  disable compiler optimizations
337   --enable-extra-warnings  enable more compiler warnings
338   --disable-stripping      disable stripping of executables and shared libraries
339   --assert-level=level     0(default), 1 or 2, amount of assertion testing,
340                            2 causes a slowdown at runtime.
341   --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
342   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
343                            leaks and errors, using the specified valgrind binary.
344                            Cannot be combined with --target-exec
345   --enable-ftrapv          Trap arithmetic overflows
346   --samples=PATH           location of test samples for FATE, if not set use
347                            \$FATE_SAMPLES at make invocation time.
348   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
349                            should be used only for debugging purposes)
350   --enable-random          randomly enable/disable components
351   --disable-random
352   --enable-random=LIST     randomly enable/disable specific components or
353   --disable-random=LIST    component groups. LIST is a comma-separated list
354                            of NAME[:PROB] entries where NAME is a component
355                            (group) and PROB the probability associated with
356                            NAME (default 0.5).
357   --random-seed=VALUE      seed value for --enable/disable-random
358
359 NOTE: Object files are built at the place where configure is launched.
360 EOF
361   exit 0
362 }
363
364 quotes='""'
365
366 log(){
367     echo "$@" >> $logfile
368 }
369
370 log_file(){
371     log BEGIN $1
372     pr -n -t $1 >> $logfile
373     log END $1
374 }
375
376 echolog(){
377     log "$@"
378     echo "$@"
379 }
380
381 warn(){
382     log "WARNING: $*"
383     WARNINGS="${WARNINGS}WARNING: $*\n"
384 }
385
386 die(){
387     echolog "$@"
388     cat <<EOF
389
390 If you think configure made a mistake, make sure you are using the latest
391 version from Git.  If the latest version fails, report the problem to the
392 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
393 EOF
394     if disabled logging; then
395         cat <<EOF
396 Rerun configure with logging enabled (do not use --disable-logging), and
397 include the log this produces with your report.
398 EOF
399     else
400         cat <<EOF
401 Include the log file "$logfile" produced by configure as this will help
402 solving the problem.
403 EOF
404     fi
405     exit 1
406 }
407
408 # Avoid locale weirdness, besides we really just want to translate ASCII.
409 toupper(){
410     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
411 }
412
413 tolower(){
414     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
415 }
416
417 c_escape(){
418     echo "$*" | sed 's/["\\]/\\\0/g'
419 }
420
421 sh_quote(){
422     v=$(echo "$1" | sed "s/'/'\\\\''/g")
423     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
424     echo "$v"
425 }
426
427 cleanws(){
428     echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//;s/\r//g'
429 }
430
431 filter(){
432     pat=$1
433     shift
434     for v; do
435         eval "case $v in $pat) echo $v ;; esac"
436     done
437 }
438
439 filter_out(){
440     pat=$1
441     shift
442     for v; do
443         eval "case $v in $pat) ;; *) echo $v ;; esac"
444     done
445 }
446
447 map(){
448     m=$1
449     shift
450     for v; do eval $m; done
451 }
452
453 add_suffix(){
454     suffix=$1
455     shift
456     for v; do echo ${v}${suffix}; done
457 }
458
459 set_all(){
460     value=$1
461     shift
462     for var in $*; do
463         eval $var=$value
464     done
465 }
466
467 set_weak(){
468     value=$1
469     shift
470     for var; do
471         eval : \${$var:=$value}
472     done
473 }
474
475 sanitize_var_name(){
476     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
477 }
478
479 set_safe(){
480     var=$1
481     shift
482     eval $(sanitize_var_name "$var")='$*'
483 }
484
485 get_safe(){
486     eval echo \$$(sanitize_var_name "$1")
487 }
488
489 pushvar(){
490     for pvar in $*; do
491         eval level=\${${pvar}_level:=0}
492         eval ${pvar}_${level}="\$$pvar"
493         eval ${pvar}_level=$(($level+1))
494     done
495 }
496
497 popvar(){
498     for pvar in $*; do
499         eval level=\${${pvar}_level:-0}
500         test $level = 0 && continue
501         eval level=$(($level-1))
502         eval $pvar="\${${pvar}_${level}}"
503         eval ${pvar}_level=$level
504         eval unset ${pvar}_${level}
505     done
506 }
507
508 enable(){
509     set_all yes $*
510 }
511
512 disable(){
513     set_all no $*
514 }
515
516 enable_weak(){
517     set_weak yes $*
518 }
519
520 disable_weak(){
521     set_weak no $*
522 }
523
524 enable_safe(){
525     for var; do
526         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
527     done
528 }
529
530 disable_safe(){
531     for var; do
532         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
533     done
534 }
535
536 do_enable_deep(){
537     for var; do
538         enabled $var && continue
539         eval sel="\$${var}_select"
540         eval sgs="\$${var}_suggest"
541         pushvar var sgs
542         enable_deep $sel
543         popvar sgs
544         enable_deep_weak $sgs
545         popvar var
546     done
547 }
548
549 enable_deep(){
550     do_enable_deep $*
551     enable $*
552 }
553
554 enable_deep_weak(){
555     for var; do
556         disabled $var && continue
557         pushvar var
558         do_enable_deep $var
559         popvar var
560         enable_weak $var
561     done
562 }
563
564 enabled(){
565     test "${1#!}" = "$1" && op== || op=!=
566     eval test "x\$${1#!}" $op "xyes"
567 }
568
569 disabled(){
570     test "${1#!}" = "$1" && op== || op=!=
571     eval test "x\$${1#!}" $op "xno"
572 }
573
574 enabled_all(){
575     for opt; do
576         enabled $opt || return 1
577     done
578 }
579
580 disabled_all(){
581     for opt; do
582         disabled $opt || return 1
583     done
584 }
585
586 enabled_any(){
587     for opt; do
588         enabled $opt && return 0
589     done
590 }
591
592 disabled_any(){
593     for opt; do
594         disabled $opt && return 0
595     done
596     return 1
597 }
598
599 set_default(){
600     for opt; do
601         eval : \${$opt:=\$${opt}_default}
602     done
603 }
604
605 is_in(){
606     value=$1
607     shift
608     for var in $*; do
609         [ $var = $value ] && return 0
610     done
611     return 1
612 }
613
614 do_check_deps(){
615     for cfg; do
616         cfg="${cfg#!}"
617         enabled ${cfg}_checking && die "Circular dependency for $cfg."
618         disabled ${cfg}_checking && continue
619         enable ${cfg}_checking
620         append allopts $cfg
621
622         eval dep_all="\$${cfg}_deps"
623         eval dep_any="\$${cfg}_deps_any"
624         eval dep_sel="\$${cfg}_select"
625         eval dep_sgs="\$${cfg}_suggest"
626         eval dep_ifa="\$${cfg}_if"
627         eval dep_ifn="\$${cfg}_if_any"
628
629         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
630         do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
631         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
632
633         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
634         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
635         enabled_all  $dep_all || disable $cfg
636         enabled_any  $dep_any || disable $cfg
637         disabled_any $dep_sel && disable $cfg
638
639         if enabled $cfg; then
640             enable_deep $dep_sel
641             enable_deep_weak $dep_sgs
642         fi
643
644         disable ${cfg}_checking
645     done
646 }
647
648 check_deps(){
649     unset allopts
650
651     do_check_deps "$@"
652
653     for cfg in $allopts; do
654         enabled $cfg || continue
655         eval dep_extralibs="\$${cfg}_extralibs"
656         test -n "$dep_extralibs" && add_extralibs $dep_extralibs
657     done
658 }
659
660 print_config(){
661     pfx=$1
662     files=$2
663     shift 2
664     map 'eval echo "$v \${$v:-no}"' "$@" |
665     awk "BEGIN { split(\"$files\", files) }
666         {
667             c = \"$pfx\" toupper(\$1);
668             v = \$2;
669             sub(/yes/, 1, v);
670             sub(/no/,  0, v);
671             for (f in files) {
672                 file = files[f];
673                 if (file ~ /\\.h\$/) {
674                     printf(\"#define %s %d\\n\", c, v) >>file;
675                 } else if (file ~ /\\.asm\$/) {
676                     printf(\"%%define %s %d\\n\", c, v) >>file;
677                 } else if (file ~ /\\.mak\$/) {
678                     n = -v ? \"\" : \"!\";
679                     printf(\"%s%s=yes\\n\", n, c) >>file;
680                 } else if (file ~ /\\.texi\$/) {
681                     pre = -v ? \"\" : \"@c \";
682                     yesno = \$2;
683                     c2 = tolower(c);
684                     gsub(/_/, \"-\", c2);
685                     printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file;
686                 }
687             }
688         }"
689 }
690
691 print_enabled(){
692     suf=$1
693     shift
694     for v; do
695         enabled $v && printf "%s\n" ${v%$suf};
696     done
697 }
698
699 append(){
700     var=$1
701     shift
702     eval "$var=\"\$$var $*\""
703 }
704
705 prepend(){
706     var=$1
707     shift
708     eval "$var=\"$* \$$var\""
709 }
710
711 add_cppflags(){
712     append CPPFLAGS "$@"
713 }
714
715 add_cflags(){
716     append CFLAGS $($cflags_filter "$@")
717 }
718
719 add_cxxflags(){
720     append CXXFLAGS $($cflags_filter "$@")
721 }
722
723 add_asflags(){
724     append ASFLAGS $($asflags_filter "$@")
725 }
726
727 add_ldflags(){
728     append LDFLAGS $($ldflags_filter "$@")
729 }
730
731 add_extralibs(){
732     prepend extralibs $($ldflags_filter "$@")
733 }
734
735 add_host_cppflags(){
736     append host_cppflags "$@"
737 }
738
739 add_host_cflags(){
740     append host_cflags $($host_cflags_filter "$@")
741 }
742
743 add_host_ldflags(){
744     append host_ldflags $($host_ldflags_filter "$@")
745 }
746
747 add_compat(){
748     append compat_objs $1
749     shift
750     map 'add_cppflags -D$v' "$@"
751 }
752
753 check_cmd(){
754     log "$@"
755     "$@" >> $logfile 2>&1
756 }
757
758 cc_o(){
759     eval printf '%s\\n' $CC_O
760 }
761
762 cc_e(){
763     eval printf '%s\\n' $CC_E
764 }
765
766 check_cc(){
767     log check_cc "$@"
768     cat > $TMPC
769     log_file $TMPC
770     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
771 }
772
773 check_cxx(){
774     log check_cxx "$@"
775     cat > $TMPCPP
776     log_file $TMPCPP
777     check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP
778 }
779
780 check_cpp(){
781     log check_cpp "$@"
782     cat > $TMPC
783     log_file $TMPC
784     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
785 }
786
787 as_o(){
788     eval printf '%s\\n' $AS_O
789 }
790
791 check_as(){
792     log check_as "$@"
793     cat > $TMPS
794     log_file $TMPS
795     check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
796 }
797
798 check_inline_asm(){
799     log check_inline_asm "$@"
800     name="$1"
801     code="$2"
802     shift 2
803     disable $name
804     check_cc "$@" <<EOF && enable $name
805 void foo(void){ __asm__ volatile($code); }
806 EOF
807 }
808
809 check_insn(){
810     log check_insn "$@"
811     check_inline_asm ${1}_inline "\"$2\""
812     echo "$2" | check_as && enable ${1}_external || disable ${1}_external
813 }
814
815 check_yasm(){
816     log check_yasm "$@"
817     echo "$1" > $TMPS
818     log_file $TMPS
819     shift 1
820     check_cmd $yasmexe $YASMFLAGS -Werror "$@" -o $TMPO $TMPS
821 }
822
823 ld_o(){
824     eval printf '%s\\n' $LD_O
825 }
826
827 check_ld(){
828     log check_ld "$@"
829     type=$1
830     shift 1
831     flags=$(filter_out '-l*|*.so' $@)
832     libs=$(filter '-l*|*.so' $@)
833     check_$type $($cflags_filter $flags) || return
834     flags=$($ldflags_filter $flags)
835     libs=$($ldflags_filter $libs)
836     check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
837 }
838
839 check_code(){
840     log check_code "$@"
841     check=$1
842     headers=$2
843     code=$3
844     shift 3
845     {
846         for hdr in $headers; do
847             echo "#include <$hdr>"
848         done
849         echo "int main(void) { $code; return 0; }"
850     } | check_$check "$@"
851 }
852
853 check_cppflags(){
854     log check_cppflags "$@"
855     check_cc "$@" <<EOF && append CPPFLAGS "$@"
856 int x;
857 EOF
858 }
859
860 check_cflags(){
861     log check_cflags "$@"
862     set -- $($cflags_filter "$@")
863     check_cc "$@" <<EOF && append CFLAGS "$@"
864 int x;
865 EOF
866 }
867
868 check_cxxflags(){
869     log check_cxxflags "$@"
870     set -- $($cflags_filter "$@")
871     check_cxx "$@" <<EOF && append CXXFLAGS "$@"
872 int x;
873 EOF
874 }
875
876 test_ldflags(){
877     log test_ldflags "$@"
878     check_ld "cc" "$@" <<EOF
879 int main(void){ return 0; }
880 EOF
881 }
882
883 check_ldflags(){
884     log check_ldflags "$@"
885     test_ldflags "$@" && add_ldflags "$@"
886 }
887
888 check_header(){
889     log check_header "$@"
890     header=$1
891     shift
892     disable_safe $header
893     check_cpp "$@" <<EOF && enable_safe $header
894 #include <$header>
895 int x;
896 EOF
897 }
898
899 check_func(){
900     log check_func "$@"
901     func=$1
902     shift
903     disable $func
904     check_ld "cc" "$@" <<EOF && enable $func
905 extern int $func();
906 int main(void){ $func(); }
907 EOF
908 }
909
910 check_mathfunc(){
911     log check_mathfunc "$@"
912     func=$1
913     narg=$2
914     shift 2
915     test $narg = 2 && args="f, g" || args="f"
916     disable $func
917     check_ld "cc" "$@" <<EOF && enable $func
918 #include <math.h>
919 float foo(float f, float g) { return $func($args); }
920 int main(void){ return (int) foo; }
921 EOF
922 }
923
924 check_func_headers(){
925     log check_func_headers "$@"
926     headers=$1
927     funcs=$2
928     shift 2
929     {
930         for hdr in $headers; do
931             echo "#include <$hdr>"
932         done
933         for func in $funcs; do
934             echo "long check_$func(void) { return (long) $func; }"
935         done
936         echo "int main(void) { return 0; }"
937     } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
938 }
939
940 check_class_headers_cpp(){
941     log check_class_headers_cpp "$@"
942     headers=$1
943     classes=$2
944     shift 2
945     {
946         for hdr in $headers; do
947             echo "#include <$hdr>"
948         done
949         echo "int main(void) { "
950         i=1
951         for class in $classes; do
952             echo "$class obj$i;"
953             i=$(expr $i + 1)
954         done
955         echo "return 0; }"
956     } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
957 }
958
959 check_cpp_condition(){
960     log check_cpp_condition "$@"
961     header=$1
962     condition=$2
963     shift 2
964     check_cpp "$@" <<EOF
965 #include <$header>
966 #if !($condition)
967 #error "unsatisfied condition: $condition"
968 #endif
969 EOF
970 }
971
972 check_lib(){
973     log check_lib "$@"
974     header="$1"
975     func="$2"
976     shift 2
977     check_header $header && check_func $func "$@" && add_extralibs "$@"
978 }
979
980 check_lib2(){
981     log check_lib2 "$@"
982     headers="$1"
983     funcs="$2"
984     shift 2
985     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
986 }
987
988 check_lib_cpp(){
989     log check_lib_cpp "$@"
990     headers="$1"
991     classes="$2"
992     shift 2
993     check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
994 }
995
996 check_pkg_config(){
997     log check_pkg_config "$@"
998     pkg="$1"
999     headers="$2"
1000     funcs="$3"
1001     shift 3
1002     check_cmd $pkg_config --exists --print-errors $pkg || return
1003     pkg_cflags=$($pkg_config --cflags $pkg)
1004     pkg_libs=$($pkg_config --libs $pkg)
1005     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1006         set_safe ${pkg}_cflags $pkg_cflags   &&
1007         set_safe ${pkg}_libs   $pkg_libs
1008 }
1009
1010 check_exec(){
1011     check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1012 }
1013
1014 check_exec_crash(){
1015     code=$(cat)
1016
1017     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1018     # are safe but may not be available everywhere.  Thus we use
1019     # raise(SIGTERM) instead.  The check is run in a subshell so we
1020     # can redirect the "Terminated" message from the shell.  SIGBUS
1021     # is not defined by standard C so it is used conditionally.
1022
1023     (check_exec "$@") >> $logfile 2>&1 <<EOF
1024 #include <signal.h>
1025 static void sighandler(int sig){
1026     raise(SIGTERM);
1027 }
1028 int foo(void){
1029     $code
1030 }
1031 int (*func_ptr)(void) = foo;
1032 int main(void){
1033     signal(SIGILL, sighandler);
1034     signal(SIGFPE, sighandler);
1035     signal(SIGSEGV, sighandler);
1036 #ifdef SIGBUS
1037     signal(SIGBUS, sighandler);
1038 #endif
1039     return func_ptr();
1040 }
1041 EOF
1042 }
1043
1044 check_type(){
1045     log check_type "$@"
1046     headers=$1
1047     type=$2
1048     shift 2
1049     disable_safe "$type"
1050     check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
1051 }
1052
1053 check_struct(){
1054     log check_struct "$@"
1055     headers=$1
1056     struct=$2
1057     member=$3
1058     shift 3
1059     disable_safe "${struct}_${member}"
1060     check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1061         enable_safe "${struct}_${member}"
1062 }
1063
1064 check_builtin(){
1065     log check_builtin "$@"
1066     name=$1
1067     headers=$2
1068     builtin=$3
1069     shift 3
1070     disable "$name"
1071     check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
1072 }
1073
1074 require(){
1075     name="$1"
1076     header="$2"
1077     func="$3"
1078     shift 3
1079     check_lib $header $func "$@" || die "ERROR: $name not found"
1080 }
1081
1082 require2(){
1083     name="$1"
1084     headers="$2"
1085     func="$3"
1086     shift 3
1087     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1088 }
1089
1090 require_cpp(){
1091     name="$1"
1092     headers="$2"
1093     classes="$3"
1094     shift 3
1095     check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
1096 }
1097
1098 require_pkg_config(){
1099     pkg="$1"
1100     check_pkg_config "$@" || die "ERROR: $pkg not found"
1101     add_cflags    $(get_safe ${pkg}_cflags)
1102     add_extralibs $(get_safe ${pkg}_libs)
1103 }
1104
1105 require_libfreetype(){
1106     log require_libfreetype "$@"
1107     pkg="freetype2"
1108     check_cmd $pkg_config --exists --print-errors $pkg \
1109       || die "ERROR: $pkg not found"
1110     pkg_cflags=$($pkg_config --cflags $pkg)
1111     pkg_libs=$($pkg_config --libs $pkg)
1112     {
1113         echo "#include <ft2build.h>"
1114         echo "#include FT_FREETYPE_H"
1115         echo "long check_func(void) { return (long) FT_Init_FreeType; }"
1116         echo "int main(void) { return 0; }"
1117     } | check_ld "cc" $pkg_cflags $pkg_libs \
1118       && set_safe ${pkg}_cflags $pkg_cflags \
1119       && set_safe ${pkg}_libs   $pkg_libs \
1120       || die "ERROR: $pkg not found"
1121     add_cflags    $(get_safe ${pkg}_cflags)
1122     add_extralibs $(get_safe ${pkg}_libs)
1123 }
1124
1125 hostcc_o(){
1126     eval printf '%s\\n' $HOSTCC_O
1127 }
1128
1129 check_host_cc(){
1130     log check_host_cc "$@"
1131     cat > $TMPC
1132     log_file $TMPC
1133     check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1134 }
1135
1136 check_host_cppflags(){
1137     log check_host_cppflags "$@"
1138     check_host_cc "$@" <<EOF && append host_cppflags "$@"
1139 int x;
1140 EOF
1141 }
1142
1143 check_host_cflags(){
1144     log check_host_cflags "$@"
1145     set -- $($host_cflags_filter "$@")
1146     check_host_cc "$@" <<EOF && append host_cflags "$@"
1147 int x;
1148 EOF
1149 }
1150
1151 apply(){
1152     file=$1
1153     shift
1154     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
1155 }
1156
1157 cp_if_changed(){
1158     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1159     mkdir -p "$(dirname $2)"
1160     $cp_f "$1" "$2"
1161 }
1162
1163 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1164 # system-dependent things.
1165
1166 COMPONENT_LIST="
1167     bsfs
1168     decoders
1169     demuxers
1170     encoders
1171     filters
1172     hwaccels
1173     indevs
1174     muxers
1175     outdevs
1176     parsers
1177     protocols
1178 "
1179
1180 EXTERNAL_LIBRARY_LIST="
1181     avisynth
1182     bzlib
1183     crystalhd
1184     fontconfig
1185     frei0r
1186     gnutls
1187     iconv
1188     ladspa
1189     libaacplus
1190     libass
1191     libbluray
1192     libcaca
1193     libcdio
1194     libcelt
1195     libdc1394
1196     libfaac
1197     libfdk_aac
1198     libflite
1199     libfreetype
1200     libgme
1201     libgsm
1202     libiec61883
1203     libilbc
1204     libmodplug
1205     libmp3lame
1206     libnut
1207     libopencore_amrnb
1208     libopencore_amrwb
1209     libopencv
1210     libopenjpeg
1211     libopus
1212     libpulse
1213     libquvi
1214     librtmp
1215     libschroedinger
1216     libshine
1217     libsoxr
1218     libspeex
1219     libssh
1220     libstagefright_h264
1221     libtheora
1222     libtwolame
1223     libutvideo
1224     libv4l2
1225     libvidstab
1226     libvo_aacenc
1227     libvo_amrwbenc
1228     libvorbis
1229     libvpx
1230     libwavpack
1231     libx264
1232     libxavs
1233     libxvid
1234     libzmq
1235     libzvbi
1236     openal
1237     opencl
1238     openssl
1239     x11grab
1240     zlib
1241 "
1242
1243 DOCUMENT_LIST="
1244     doc
1245     htmlpages
1246     manpages
1247     podpages
1248     txtpages
1249 "
1250
1251 HWACCEL_LIST="
1252     dxva2
1253     vaapi
1254     vda
1255     vdpau
1256 "
1257
1258 LIBRARY_LIST="
1259     avcodec
1260     avdevice
1261     avfilter
1262     avformat
1263     avresample
1264     avutil
1265     postproc
1266     swresample
1267     swscale
1268 "
1269
1270 PROGRAM_LIST="
1271     ffplay
1272     ffprobe
1273     ffserver
1274     ffmpeg
1275 "
1276
1277 CONFIG_LIST="
1278     $COMPONENT_LIST
1279     $DOCUMENT_LIST
1280     $EXTERNAL_LIBRARY_LIST
1281     $HWACCEL_LIST
1282     $LIBRARY_LIST
1283     $PROGRAM_LIST
1284     dct
1285     dwt
1286     error_resilience
1287     fast_unaligned
1288     fft
1289     ftrapv
1290     gpl
1291     gray
1292     hardcoded_tables
1293     incompatible_libav_abi
1294     incompatible_fork_abi
1295     lsp
1296     lzo
1297     mdct
1298     memalign_hack
1299     memory_poisoning
1300     network
1301     nonfree
1302     pic
1303     rdft
1304     runtime_cpudetect
1305     safe_bitstream_reader
1306     shared
1307     small
1308     sram
1309     static
1310     swscale_alpha
1311     thumb
1312     version3
1313     xmm_clobber_test
1314 "
1315
1316 THREADS_LIST='
1317     pthreads
1318     w32threads
1319     os2threads
1320 '
1321
1322 ATOMICS_LIST='
1323     atomics_gcc
1324     atomics_suncc
1325     atomics_win32
1326 '
1327
1328 ARCH_LIST='
1329     aarch64
1330     alpha
1331     arm
1332     avr32
1333     avr32_ap
1334     avr32_uc
1335     bfin
1336     ia64
1337     m68k
1338     mips
1339     mips64
1340     parisc
1341     ppc
1342     ppc64
1343     s390
1344     sh4
1345     sparc
1346     sparc64
1347     tilegx
1348     tilepro
1349     tomi
1350     x86
1351     x86_32
1352     x86_64
1353 '
1354
1355 ARCH_EXT_LIST_ARM='
1356     armv5te
1357     armv6
1358     armv6t2
1359     neon
1360     vfp
1361     vfpv3
1362 '
1363
1364 ARCH_EXT_LIST_X86='
1365     amd3dnow
1366     amd3dnowext
1367     avx
1368     avx2
1369     fma4
1370     i686
1371     mmx
1372     mmxext
1373     sse
1374     sse2
1375     sse3
1376     sse4
1377     sse42
1378     ssse3
1379 '
1380
1381 ARCH_EXT_LIST="
1382     $ARCH_EXT_LIST_ARM
1383     $ARCH_EXT_LIST_X86
1384     altivec
1385     ppc4xx
1386     vis
1387     mipsfpu
1388     mips32r2
1389     mipsdspr1
1390     mipsdspr2
1391 "
1392
1393 HAVE_LIST_CMDLINE='
1394     inline_asm
1395     symver
1396     yasm
1397 '
1398
1399 HAVE_LIST_PUB='
1400     bigendian
1401     fast_unaligned
1402     incompatible_libav_abi
1403     incompatible_fork_abi
1404 '
1405
1406 MATH_FUNCS="
1407     atanf
1408     atan2f
1409     cbrt
1410     cbrtf
1411     cosf
1412     exp2
1413     exp2f
1414     expf
1415     isinf
1416     isnan
1417     ldexpf
1418     llrint
1419     llrintf
1420     log2
1421     log2f
1422     log10f
1423     lrint
1424     lrintf
1425     powf
1426     rint
1427     round
1428     roundf
1429     sinf
1430     trunc
1431     truncf
1432 "
1433
1434 HAVE_LIST="
1435     $ARCH_EXT_LIST
1436     $(add_suffix _external $ARCH_EXT_LIST)
1437     $(add_suffix _inline   $ARCH_EXT_LIST)
1438     $HAVE_LIST_CMDLINE
1439     $HAVE_LIST_PUB
1440     $THREADS_LIST
1441     $ATOMICS_LIST
1442     $MATH_FUNCS
1443     access
1444     aligned_malloc
1445     aligned_stack
1446     alsa_asoundlib_h
1447     altivec_h
1448     arpa_inet_h
1449     asm_mod_q
1450     asm_mod_y
1451     asm_types_h
1452     atomic_cas_ptr
1453     atomics_native
1454     attribute_may_alias
1455     attribute_packed
1456     cdio_paranoia_h
1457     cdio_paranoia_paranoia_h
1458     CL_cl_h
1459     clock_gettime
1460     closesocket
1461     CommandLineToArgvW
1462     cpunop
1463     CryptGenRandom
1464     dcbzl
1465     dev_bktr_ioctl_bt848_h
1466     dev_bktr_ioctl_meteor_h
1467     dev_ic_bt8xx_h
1468     dev_video_bktr_ioctl_bt848_h
1469     dev_video_meteor_ioctl_meteor_h
1470     direct_h
1471     dlfcn_h
1472     dlopen
1473     dos_paths
1474     dxva_h
1475     ebp_available
1476     ebx_available
1477     fast_64bit
1478     fast_clz
1479     fast_cmov
1480     fcntl
1481     fork
1482     getaddrinfo
1483     gethrtime
1484     getopt
1485     GetProcessAffinityMask
1486     GetProcessMemoryInfo
1487     GetProcessTimes
1488     GetSystemTimeAsFileTime
1489     getrusage
1490     getservbyport
1491     gettimeofday
1492     glob
1493     gnu_as
1494     gsm_h
1495     ibm_asm
1496     inet_aton
1497     io_h
1498     inline_asm_labels
1499     isatty
1500     jack_port_get_latency_range
1501     kbhit
1502     ldbrx
1503     libdc1394_1
1504     libdc1394_2
1505     local_aligned_16
1506     local_aligned_8
1507     localtime_r
1508     loongson
1509     lzo1x_999_compress
1510     machine_ioctl_bt848_h
1511     machine_ioctl_meteor_h
1512     machine_rw_barrier
1513     makeinfo
1514     malloc_h
1515     MapViewOfFile
1516     memalign
1517     MemoryBarrier
1518     mkstemp
1519     mm_empty
1520     mmap
1521     mprotect
1522     msvcrt
1523     nanosleep
1524     openjpeg_1_5_openjpeg_h
1525     PeekNamedPipe
1526     perl
1527     pod2man
1528     poll_h
1529     posix_memalign
1530     pragma_deprecated
1531     pthread_cancel
1532     rdtsc
1533     rsync_contimeout
1534     sarestart
1535     sched_getaffinity
1536     sdl
1537     SetConsoleTextAttribute
1538     setmode
1539     setrlimit
1540     Sleep
1541     sndio_h
1542     socklen_t
1543     soundcard_h
1544     strerror_r
1545     struct_addrinfo
1546     struct_group_source_req
1547     struct_ip_mreq_source
1548     struct_ipv6_mreq
1549     struct_pollfd
1550     struct_rusage_ru_maxrss
1551     struct_sctp_event_subscribe
1552     struct_sockaddr_in6
1553     struct_sockaddr_sa_len
1554     struct_sockaddr_storage
1555     struct_stat_st_mtim_tv_nsec
1556     struct_v4l2_frmivalenum_discrete
1557     symver_asm_label
1558     symver_gnu_asm
1559     sync_val_compare_and_swap
1560     sysconf
1561     sysctl
1562     sys_mman_h
1563     sys_param_h
1564     sys_resource_h
1565     sys_select_h
1566     sys_soundcard_h
1567     sys_time_h
1568     sys_un_h
1569     sys_videoio_h
1570     termios_h
1571     texi2html
1572     threads
1573     unistd_h
1574     usleep
1575     vfp_args
1576     VirtualAlloc
1577     windows_h
1578     winsock2_h
1579     xform_asm
1580     xmm_clobbers
1581 "
1582
1583 # options emitted with CONFIG_ prefix but not available on the command line
1584 CONFIG_EXTRA="
1585     aandcttables
1586     ac3dsp
1587     audio_frame_queue
1588     dsputil
1589     exif
1590     frame_thread_encoder
1591     gcrypt
1592     golomb
1593     gplv3
1594     h264chroma
1595     h264dsp
1596     h264pred
1597     h264qpel
1598     hpeldsp
1599     huffman
1600     lgplv3
1601     lpc
1602     mpegaudio
1603     mpegaudiodsp
1604     mpegvideo
1605     mpegvideoenc
1606     nettle
1607     rangecoder
1608     riffdec
1609     riffenc
1610     rtpdec
1611     rtpenc_chain
1612     sinewin
1613     videodsp
1614     vp3dsp
1615 "
1616
1617 CMDLINE_SELECT="
1618     $ARCH_EXT_LIST
1619     $CONFIG_LIST
1620     $HAVE_LIST_CMDLINE
1621     $THREADS_LIST
1622     asm
1623     cross_compile
1624     debug
1625     extra_warnings
1626     logging
1627     lto
1628     optimizations
1629     stripping
1630 "
1631
1632 PATHS_LIST='
1633     bindir
1634     datadir
1635     docdir
1636     incdir
1637     libdir
1638     mandir
1639     prefix
1640     shlibdir
1641 '
1642
1643 CMDLINE_SET="
1644     $PATHS_LIST
1645     ar
1646     arch
1647     as
1648     assert_level
1649     build_suffix
1650     cc
1651     cpu
1652     cross_prefix
1653     cxx
1654     dep_cc
1655     extra_version
1656     host_cc
1657     host_cflags
1658     host_ld
1659     host_ldflags
1660     host_libs
1661     host_os
1662     install
1663     ld
1664     logfile
1665     malloc_prefix
1666     nm
1667     optflags
1668     pkg_config
1669     progs_suffix
1670     random_seed
1671     samples
1672     strip
1673     sysinclude
1674     sysroot
1675     target_exec
1676     target_os
1677     target_path
1678     target_samples
1679     tempprefix
1680     toolchain
1681     valgrind
1682     yasmexe
1683 "
1684
1685 CMDLINE_APPEND="
1686     extra_cflags
1687     extra_cxxflags
1688     host_cppflags
1689 "
1690
1691 # code dependency declarations
1692
1693 # architecture extensions
1694
1695 armv5te_deps="arm"
1696 armv6_deps="arm"
1697 armv6t2_deps="arm"
1698 neon_deps="arm"
1699 vfp_deps="arm"
1700 vfpv3_deps="vfp"
1701
1702 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1703
1704 mipsfpu_deps="mips"
1705 mips32r2_deps="mips"
1706 mipsdspr1_deps="mips"
1707 mipsdspr2_deps="mips"
1708
1709 altivec_deps="ppc"
1710 ppc4xx_deps="ppc"
1711
1712 vis_deps="sparc"
1713
1714 cpunop_deps="i686"
1715 x86_64_select="i686"
1716 x86_64_suggest="fast_cmov"
1717
1718 amd3dnow_deps="mmx"
1719 amd3dnowext_deps="amd3dnow"
1720 mmx_deps="x86"
1721 mmxext_deps="mmx"
1722 sse_deps="mmxext"
1723 sse2_deps="sse"
1724 sse3_deps="sse2"
1725 ssse3_deps="sse3"
1726 sse4_deps="ssse3"
1727 sse42_deps="sse4"
1728 avx_deps="sse42"
1729 fma4_deps="avx"
1730 avx2_deps="avx"
1731
1732 mmx_external_deps="yasm"
1733 mmx_inline_deps="inline_asm"
1734 mmx_suggest="mmx_external mmx_inline"
1735
1736 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
1737     eval dep=\$${ext}_deps
1738     eval ${ext}_external_deps='"${dep}_external"'
1739     eval ${ext}_inline_deps='"${dep}_inline"'
1740     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1741 done
1742
1743 aligned_stack_if_any="ppc x86"
1744 fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1745 fast_clz_if_any="alpha avr32 mips ppc x86"
1746 fast_unaligned_if_any="ppc x86"
1747
1748 inline_asm_deps="!tms470"
1749 need_memalign="altivec neon sse"
1750
1751 symver_if_any="symver_asm_label symver_gnu_asm"
1752
1753 log2_deps="!msvcrt"
1754
1755 # subsystems
1756 dct_select="rdft"
1757 error_resilience_select="dsputil"
1758 frame_thread_encoder_deps="encoders threads"
1759 lpc_select="dsputil"
1760 mdct_select="fft"
1761 rdft_select="fft"
1762 mpegaudio_select="mpegaudiodsp"
1763 mpegaudiodsp_select="dct"
1764 mpegvideo_select="dsputil h264chroma hpeldsp videodsp"
1765 mpegvideoenc_select="mpegvideo"
1766
1767 # decoders / encoders
1768 aac_decoder_select="mdct sinewin"
1769 aac_encoder_select="audio_frame_queue mdct sinewin"
1770 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1771 ac3_decoder_select="mdct ac3dsp ac3_parser dsputil"
1772 ac3_encoder_select="mdct ac3dsp dsputil"
1773 ac3_fixed_encoder_select="mdct ac3dsp dsputil"
1774 aic_decoder_select="dsputil golomb"
1775 alac_encoder_select="lpc"
1776 als_decoder_select="dsputil"
1777 amrnb_decoder_select="lsp"
1778 amrwb_decoder_select="lsp"
1779 amv_decoder_select="dsputil hpeldsp exif"
1780 amv_encoder_select="aandcttables"
1781 ape_decoder_select="dsputil"
1782 asv1_decoder_select="dsputil"
1783 asv1_encoder_select="dsputil"
1784 asv2_decoder_select="dsputil"
1785 asv2_encoder_select="dsputil"
1786 atrac1_decoder_select="mdct sinewin"
1787 atrac3_decoder_select="mdct"
1788 avrn_decoder_select="exif"
1789 bink_decoder_select="dsputil hpeldsp"
1790 binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1791 binkaudio_rdft_decoder_select="mdct rdft sinewin"
1792 cavs_decoder_select="dsputil golomb h264chroma videodsp"
1793 cllc_decoder_select="dsputil"
1794 comfortnoise_encoder_select="lpc"
1795 cook_decoder_select="dsputil mdct sinewin"
1796 cscd_decoder_select="lzo"
1797 cscd_decoder_suggest="zlib"
1798 dca_decoder_select="mdct"
1799 dirac_decoder_select="dsputil dwt golomb videodsp"
1800 dnxhd_decoder_select="dsputil"
1801 dnxhd_encoder_select="aandcttables dsputil mpegvideoenc"
1802 dvvideo_decoder_select="dsputil"
1803 dvvideo_encoder_select="dsputil"
1804 dxa_decoder_select="zlib"
1805 eac3_decoder_select="ac3_decoder"
1806 eac3_encoder_select="ac3_encoder"
1807 eamad_decoder_select="aandcttables dsputil mpegvideo"
1808 eatgq_decoder_select="aandcttables"
1809 eatqi_decoder_select="aandcttables error_resilience mpegvideo"
1810 exr_decoder_select="zlib"
1811 ffv1_decoder_select="dsputil golomb rangecoder"
1812 ffv1_encoder_select="dsputil rangecoder"
1813 ffvhuff_decoder_select="dsputil"
1814 ffvhuff_encoder_select="dsputil huffman"
1815 flac_decoder_select="golomb"
1816 flac_encoder_select="dsputil golomb lpc"
1817 flashsv_decoder_select="zlib"
1818 flashsv_encoder_select="zlib"
1819 flashsv2_encoder_select="zlib"
1820 flashsv2_decoder_select="zlib"
1821 flv_decoder_select="h263_decoder"
1822 flv_encoder_select="h263_encoder"
1823 fourxm_decoder_select="dsputil"
1824 fraps_decoder_select="dsputil huffman"
1825 g2m_decoder_select="dsputil zlib"
1826 g729_decoder_select="dsputil"
1827 h261_decoder_select="error_resilience mpegvideo"
1828 h261_encoder_select="aandcttables mpegvideoenc"
1829 h263_decoder_select="error_resilience h263_parser mpegvideo"
1830 h263_encoder_select="aandcttables mpegvideoenc"
1831 h263i_decoder_select="h263_decoder"
1832 h263p_encoder_select="h263_encoder"
1833 h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
1834 h264_decoder_suggest="error_resilience"
1835 hevc_decoder_select="dsputil golomb videodsp"
1836 huffyuv_decoder_select="dsputil"
1837 huffyuv_encoder_select="dsputil huffman"
1838 iac_decoder_select="dsputil fft mdct sinewin"
1839 imc_decoder_select="dsputil fft mdct sinewin"
1840 indeo3_decoder_select="hpeldsp"
1841 interplay_video_decoder_select="hpeldsp"
1842 jpegls_decoder_select="dsputil golomb hpeldsp exif"
1843 jpegls_encoder_select="golomb"
1844 jv_decoder_select="dsputil"
1845 lagarith_decoder_select="dsputil"
1846 ljpeg_encoder_select="aandcttables mpegvideoenc"
1847 loco_decoder_select="golomb"
1848 mdec_decoder_select="dsputil error_resilience mpegvideo"
1849 metasound_decoder_select="lsp mdct sinewin"
1850 mimic_decoder_select="dsputil hpeldsp"
1851 mjpeg_decoder_select="dsputil hpeldsp exif"
1852 mjpegb_decoder_select="dsputil hpeldsp exif"
1853 mjpeg_encoder_select="aandcttables dsputil mpegvideoenc"
1854 mlp_decoder_select="dsputil mlp_parser"
1855 motionpixels_decoder_select="dsputil"
1856 mp1_decoder_select="mpegaudio"
1857 mp1float_decoder_select="mpegaudio"
1858 mp2_decoder_select="mpegaudio"
1859 mp2float_decoder_select="mpegaudio"
1860 mp3_decoder_select="mpegaudio"
1861 mp3adu_decoder_select="mpegaudio"
1862 mp3adufloat_decoder_select="mpegaudio"
1863 mp3float_decoder_select="mpegaudio"
1864 mp3on4_decoder_select="mpegaudio"
1865 mp3on4float_decoder_select="mpegaudio"
1866 mpc7_decoder_select="dsputil mpegaudiodsp"
1867 mpc8_decoder_select="dsputil mpegaudiodsp"
1868 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1869 mpeg_xvmc_decoder_select="mpeg2video_decoder"
1870 mpeg1video_decoder_select="error_resilience mpegvideo"
1871 mpeg1video_encoder_select="aandcttables mpegvideoenc"
1872 mpeg2video_decoder_select="error_resilience mpegvideo"
1873 mpeg2video_encoder_select="aandcttables mpegvideoenc"
1874 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1875 mpeg4_encoder_select="h263_encoder"
1876 msmpeg4v1_decoder_select="h263_decoder"
1877 msmpeg4v2_decoder_select="h263_decoder"
1878 msmpeg4v2_encoder_select="h263_encoder"
1879 msmpeg4v3_decoder_select="h263_decoder"
1880 msmpeg4v3_encoder_select="h263_encoder"
1881 mss2_decoder_select="error_resilience vc1_decoder"
1882 mxpeg_decoder_select="dsputil hpeldsp exif"
1883 nellymoser_decoder_select="mdct sinewin"
1884 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
1885 nuv_decoder_select="dsputil lzo"
1886 png_decoder_select="zlib"
1887 png_encoder_select="dsputil zlib"
1888 prores_decoder_select="dsputil"
1889 prores_encoder_select="dsputil"
1890 qcelp_decoder_select="lsp"
1891 qdm2_decoder_select="mdct rdft mpegaudiodsp"
1892 ra_144_encoder_select="audio_frame_queue lpc"
1893 ralf_decoder_select="golomb"
1894 rtjpeg_decoder_select="dsputil"
1895 rv10_decoder_select="error_resilience h263_decoder"
1896 rv10_encoder_select="h263_encoder"
1897 rv20_decoder_select="error_resilience h263_decoder"
1898 rv20_encoder_select="h263_encoder"
1899 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo videodsp"
1900 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo videodsp"
1901 shorten_decoder_select="golomb"
1902 sipr_decoder_select="lsp"
1903 snow_decoder_select="dsputil dwt h264qpel hpeldsp rangecoder"
1904 snow_encoder_select="aandcttables dsputil dwt h264qpel hpeldsp mpegvideoenc rangecoder"
1905 sonic_decoder_select="golomb"
1906 sonic_encoder_select="golomb"
1907 sonic_ls_encoder_select="golomb"
1908 sp5x_decoder_select="dsputil hpeldsp exif"
1909 svq1_decoder_select="hpeldsp"
1910 svq1_encoder_select="aandcttables dsputil hpeldsp mpegvideoenc"
1911 svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel hpeldsp mpegvideo videodsp"
1912 svq3_decoder_suggest="error_resilience zlib"
1913 tak_decoder_select="dsputil"
1914 theora_decoder_select="vp3_decoder"
1915 tiff_decoder_suggest="zlib"
1916 tiff_encoder_suggest="zlib"
1917 thp_decoder_select="dsputil hpeldsp exif"
1918 truehd_decoder_select="mlp_parser"
1919 truemotion2_decoder_select="dsputil"
1920 truespeech_decoder_select="dsputil"
1921 tscc_decoder_select="zlib"
1922 twinvq_decoder_select="mdct lsp sinewin"
1923 utvideo_decoder_select="dsputil"
1924 utvideo_encoder_select="dsputil huffman"
1925 vble_decoder_select="dsputil"
1926 vc1_decoder_select="error_resilience h263_decoder h264chroma h264qpel"
1927 vc1image_decoder_select="vc1_decoder"
1928 vorbis_decoder_select="mdct"
1929 vorbis_encoder_select="mdct"
1930 vp3_decoder_select="hpeldsp vp3dsp videodsp"
1931 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp"
1932 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp"
1933 vp6a_decoder_select="vp6_decoder"
1934 vp6f_decoder_select="vp6_decoder"
1935 vp8_decoder_select="h264pred videodsp"
1936 vp9_decoder_select="videodsp"
1937 webp_decoder_select="vp8_decoder"
1938 wmapro_decoder_select="mdct sinewin"
1939 wmav1_decoder_select="mdct sinewin"
1940 wmav1_encoder_select="mdct sinewin"
1941 wmav2_decoder_select="mdct sinewin"
1942 wmav2_encoder_select="mdct sinewin"
1943 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
1944 wmv1_decoder_select="h263_decoder"
1945 wmv1_encoder_select="h263_encoder"
1946 wmv2_decoder_select="h263_decoder videodsp"
1947 wmv2_encoder_select="h263_encoder"
1948 wmv3_decoder_select="vc1_decoder"
1949 wmv3image_decoder_select="wmv3_decoder"
1950 zerocodec_decoder_select="zlib"
1951 zlib_decoder_select="zlib"
1952 zlib_encoder_select="zlib"
1953 zmbv_decoder_select="zlib"
1954 zmbv_encoder_select="zlib"
1955
1956 # hardware accelerators
1957 crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
1958 dxva2_deps="dxva2api_h"
1959 vaapi_deps="va_va_h"
1960 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
1961 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
1962 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1963
1964 h263_vaapi_hwaccel_deps="vaapi"
1965 h263_vaapi_hwaccel_select="h263_decoder"
1966 h263_vdpau_hwaccel_deps="vdpau"
1967 h263_vdpau_hwaccel_select="h263_decoder"
1968 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
1969 h264_dxva2_hwaccel_deps="dxva2"
1970 h264_dxva2_hwaccel_select="h264_decoder"
1971 h264_vaapi_hwaccel_deps="vaapi"
1972 h264_vaapi_hwaccel_select="h264_decoder"
1973 h264_vda_decoder_deps="vda"
1974 h264_vda_decoder_select="h264_decoder"
1975 h264_vda_hwaccel_deps="vda"
1976 h264_vda_hwaccel_select="h264_decoder"
1977 h264_vdpau_decoder_deps="vdpau"
1978 h264_vdpau_decoder_select="h264_decoder"
1979 h264_vdpau_hwaccel_deps="vdpau"
1980 h264_vdpau_hwaccel_select="h264_decoder"
1981 mpeg_vdpau_decoder_deps="vdpau"
1982 mpeg_vdpau_decoder_select="mpeg2video_decoder"
1983 mpeg1_vdpau_decoder_deps="vdpau"
1984 mpeg1_vdpau_decoder_select="mpeg1video_decoder"
1985 mpeg1_vdpau_hwaccel_deps="vdpau"
1986 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
1987 mpeg2_crystalhd_decoder_select="crystalhd"
1988 mpeg2_dxva2_hwaccel_deps="dxva2"
1989 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
1990 mpeg2_vaapi_hwaccel_deps="vaapi"
1991 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
1992 mpeg2_vdpau_hwaccel_deps="vdpau"
1993 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
1994 mpeg4_crystalhd_decoder_select="crystalhd"
1995 mpeg4_vaapi_hwaccel_deps="vaapi"
1996 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
1997 mpeg4_vdpau_decoder_deps="vdpau"
1998 mpeg4_vdpau_decoder_select="mpeg4_decoder"
1999 mpeg4_vdpau_hwaccel_deps="vdpau"
2000 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2001 msmpeg4_crystalhd_decoder_select="crystalhd"
2002 vc1_crystalhd_decoder_select="crystalhd"
2003 vc1_dxva2_hwaccel_deps="dxva2"
2004 vc1_dxva2_hwaccel_select="vc1_decoder"
2005 vc1_vaapi_hwaccel_deps="vaapi"
2006 vc1_vaapi_hwaccel_select="vc1_decoder"
2007 vc1_vdpau_decoder_deps="vdpau"
2008 vc1_vdpau_decoder_select="vc1_decoder"
2009 vc1_vdpau_hwaccel_deps="vdpau"
2010 vc1_vdpau_hwaccel_select="vc1_decoder"
2011 wmv3_crystalhd_decoder_select="crystalhd"
2012 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2013 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2014 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
2015 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2016
2017 # parsers
2018 h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
2019 mpeg4video_parser_select="error_resilience mpegvideo"
2020 mpegvideo_parser_select="error_resilience mpegvideo"
2021 vc1_parser_select="mpegvideo"
2022
2023 # external libraries
2024 libaacplus_encoder_deps="libaacplus"
2025 libcelt_decoder_deps="libcelt"
2026 libfaac_encoder_deps="libfaac"
2027 libfaac_encoder_select="audio_frame_queue"
2028 libfdk_aac_decoder_deps="libfdk_aac"
2029 libfdk_aac_encoder_deps="libfdk_aac"
2030 libfdk_aac_encoder_select="audio_frame_queue"
2031 libgme_demuxer_deps="libgme"
2032 libgsm_decoder_deps="libgsm"
2033 libgsm_encoder_deps="libgsm"
2034 libgsm_ms_decoder_deps="libgsm"
2035 libgsm_ms_encoder_deps="libgsm"
2036 libilbc_decoder_deps="libilbc"
2037 libilbc_encoder_deps="libilbc"
2038 libmodplug_demuxer_deps="libmodplug"
2039 libmp3lame_encoder_deps="libmp3lame"
2040 libmp3lame_encoder_select="audio_frame_queue"
2041 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2042 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2043 libopencore_amrnb_encoder_select="audio_frame_queue"
2044 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2045 libopenjpeg_decoder_deps="libopenjpeg"
2046 libopenjpeg_encoder_deps="libopenjpeg"
2047 libopus_decoder_deps="libopus"
2048 libopus_encoder_deps="libopus"
2049 libopus_encoder_select="audio_frame_queue"
2050 libquvi_demuxer_deps="libquvi"
2051 libschroedinger_decoder_deps="libschroedinger"
2052 libschroedinger_encoder_deps="libschroedinger"
2053 libshine_encoder_deps="libshine"
2054 libshine_encoder_select="audio_frame_queue"
2055 libspeex_decoder_deps="libspeex"
2056 libspeex_encoder_deps="libspeex"
2057 libspeex_encoder_select="audio_frame_queue"
2058 libstagefright_h264_decoder_deps="libstagefright_h264"
2059 libtheora_encoder_deps="libtheora"
2060 libtwolame_encoder_deps="libtwolame"
2061 libvo_aacenc_encoder_deps="libvo_aacenc"
2062 libvo_aacenc_encoder_select="audio_frame_queue"
2063 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2064 libvorbis_decoder_deps="libvorbis"
2065 libvorbis_encoder_deps="libvorbis"
2066 libvorbis_encoder_select="audio_frame_queue"
2067 libvpx_vp8_decoder_deps="libvpx"
2068 libvpx_vp8_encoder_deps="libvpx"
2069 libvpx_vp9_decoder_deps="libvpx"
2070 libvpx_vp9_encoder_deps="libvpx"
2071 libwavpack_encoder_deps="libwavpack"
2072 libx264_encoder_deps="libx264"
2073 libx264rgb_encoder_deps="libx264"
2074 libxavs_encoder_deps="libxavs"
2075 libxvid_encoder_deps="libxvid"
2076 libutvideo_decoder_deps="libutvideo"
2077 libutvideo_encoder_deps="libutvideo"
2078 libzvbi_teletext_decoder_deps="libzvbi"
2079
2080 # demuxers / muxers
2081 ac3_demuxer_select="ac3_parser"
2082 asf_demuxer_select="riffdec"
2083 asf_muxer_select="riffenc"
2084 asf_stream_muxer_select="asf_muxer"
2085 avi_demuxer_select="riffdec"
2086 avi_muxer_select="riffenc"
2087 avisynth_demuxer_deps="avisynth"
2088 avisynth_demuxer_select="riffdec"
2089 caf_demuxer_select="riffdec"
2090 dirac_demuxer_select="dirac_parser"
2091 dts_demuxer_select="dca_parser"
2092 dtshd_demuxer_select="dca_parser"
2093 dxa_demuxer_select="riffdec"
2094 eac3_demuxer_select="ac3_parser"
2095 f4v_muxer_select="mov_muxer"
2096 flac_demuxer_select="flac_parser"
2097 hls_muxer_select="mpegts_muxer"
2098 ipod_muxer_select="mov_muxer"
2099 ismv_muxer_select="mov_muxer"
2100 libnut_demuxer_deps="libnut"
2101 libnut_muxer_deps="libnut"
2102 matroska_audio_muxer_select="matroska_muxer"
2103 matroska_demuxer_select="riffdec"
2104 matroska_demuxer_suggest="bzlib lzo zlib"
2105 matroska_muxer_select="riffenc"
2106 mmf_muxer_select="riffenc"
2107 mov_demuxer_select="riffdec"
2108 mov_demuxer_suggest="zlib"
2109 mov_muxer_select="riffenc rtpenc_chain"
2110 mp3_demuxer_select="mpegaudio_parser"
2111 mp4_muxer_select="mov_muxer"
2112 mpegts_muxer_select="adts_muxer latm_muxer"
2113 mpegtsraw_demuxer_select="mpegts_demuxer"
2114 mxf_d10_muxer_select="mxf_muxer"
2115 nut_muxer_select="riffenc"
2116 nuv_demuxer_select="riffdec"
2117 ogg_demuxer_select="golomb"
2118 psp_muxer_select="mov_muxer"
2119 rtp_demuxer_select="sdp_demuxer"
2120 rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
2121 rtsp_demuxer_select="http_protocol rtpdec"
2122 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2123 sap_demuxer_select="sdp_demuxer"
2124 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2125 sdp_demuxer_select="rtpdec"
2126 smoothstreaming_muxer_select="ismv_muxer"
2127 spdif_muxer_select="aac_parser"
2128 tak_demuxer_select="tak_parser"
2129 tg2_muxer_select="mov_muxer"
2130 tgp_muxer_select="mov_muxer"
2131 vobsub_demuxer_select="mpegps_demuxer"
2132 w64_demuxer_select="wav_demuxer"
2133 w64_muxer_select="wav_muxer"
2134 wav_demuxer_select="riffdec"
2135 wav_muxer_select="riffenc"
2136 webm_muxer_select="riffenc"
2137 wtv_demuxer_select="riffdec"
2138 xmv_demuxer_select="riffdec"
2139 xwma_demuxer_select="riffdec"
2140
2141 # indevs / outdevs
2142 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
2143 alsa_outdev_deps="alsa_asoundlib_h"
2144 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2145 caca_outdev_deps="libcaca"
2146 dshow_indev_deps="IBaseFilter"
2147 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid"
2148 dv1394_indev_deps="dv1394"
2149 dv1394_indev_select="dv_demuxer"
2150 fbdev_indev_deps="linux_fb_h"
2151 fbdev_outdev_deps="linux_fb_h"
2152 iec61883_indev_deps="libiec61883"
2153 jack_indev_deps="jack_jack_h sem_timedwait"
2154 lavfi_indev_deps="avfilter"
2155 libcdio_indev_deps="libcdio"
2156 libdc1394_indev_deps="libdc1394"
2157 libv4l2_indev_deps="libv4l2"
2158 openal_indev_deps="openal"
2159 oss_indev_deps_any="soundcard_h sys_soundcard_h"
2160 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
2161 pulse_indev_deps="libpulse"
2162 pulse_outdev_deps="libpulse"
2163 sdl_outdev_deps="sdl"
2164 sndio_indev_deps="sndio_h"
2165 sndio_outdev_deps="sndio_h"
2166 v4l_indev_deps="linux_videodev_h"
2167 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2168 v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
2169 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
2170 vfwcap_indev_extralibs="-lavicap32"
2171 xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
2172 xv_outdev_extralibs="-lXv -lX11 -lXext"
2173 x11grab_indev_deps="x11grab"
2174
2175 # protocols
2176 bluray_protocol_deps="libbluray"
2177 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
2178 ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
2179 ffrtmpcrypt_protocol_select="tcp_protocol"
2180 ffrtmphttp_protocol_deps="!librtmp_protocol"
2181 ffrtmphttp_protocol_select="http_protocol"
2182 ftp_protocol_select="tcp_protocol"
2183 gopher_protocol_select="network"
2184 httpproxy_protocol_select="tcp_protocol"
2185 http_protocol_select="tcp_protocol"
2186 https_protocol_select="tls_protocol"
2187 librtmp_protocol_deps="librtmp"
2188 librtmpe_protocol_deps="librtmp"
2189 librtmps_protocol_deps="librtmp"
2190 librtmpt_protocol_deps="librtmp"
2191 librtmpte_protocol_deps="librtmp"
2192 libssh_protocol_deps="libssh"
2193 mmsh_protocol_select="http_protocol"
2194 mmst_protocol_select="network"
2195 rtmp_protocol_deps="!librtmp_protocol"
2196 rtmp_protocol_select="tcp_protocol"
2197 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2198 rtmps_protocol_deps="!librtmp_protocol"
2199 rtmps_protocol_select="tls_protocol"
2200 rtmpt_protocol_select="ffrtmphttp_protocol"
2201 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2202 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2203 rtp_protocol_select="udp_protocol"
2204 sctp_protocol_deps="struct_sctp_event_subscribe"
2205 sctp_protocol_select="network"
2206 srtp_protocol_select="rtp_protocol"
2207 tcp_protocol_select="network"
2208 tls_protocol_deps_any="openssl gnutls"
2209 tls_protocol_select="tcp_protocol"
2210 udp_protocol_select="network"
2211 unix_protocol_deps="sys_un_h"
2212 unix_protocol_select="network"
2213
2214 # filters
2215 aconvert_filter_deps="swresample"
2216 amovie_filter_deps="avcodec avformat"
2217 aresample_filter_deps="swresample"
2218 ass_filter_deps="libass"
2219 asyncts_filter_deps="avresample"
2220 atempo_filter_deps="avcodec"
2221 atempo_filter_select="rdft"
2222 azmq_filter_deps="libzmq"
2223 blackframe_filter_deps="gpl"
2224 boxblur_filter_deps="gpl"
2225 colormatrix_filter_deps="gpl"
2226 cropdetect_filter_deps="gpl"
2227 dctdnoiz_filter_deps="avcodec"
2228 dctdnoiz_filter_select="fft"
2229 delogo_filter_deps="gpl"
2230 deshake_filter_deps="avcodec"
2231 deshake_filter_select="dsputil"
2232 drawtext_filter_deps="libfreetype"
2233 ebur128_filter_deps="gpl"
2234 flite_filter_deps="libflite"
2235 frei0r_filter_deps="frei0r dlopen"
2236 frei0r_filter_extralibs='$ldl'
2237 frei0r_src_filter_deps="frei0r dlopen"
2238 frei0r_src_filter_extralibs='$ldl'
2239 geq_filter_deps="gpl"
2240 histeq_filter_deps="gpl"
2241 hqdn3d_filter_deps="gpl"
2242 interlace_filter_deps="gpl"
2243 kerndeint_filter_deps="gpl"
2244 ladspa_filter_deps="ladspa dlopen"
2245 mcdeint_filter_deps="avcodec gpl"
2246 movie_filter_deps="avcodec avformat"
2247 mp_filter_deps="gpl avcodec swscale inline_asm"
2248 mpdecimate_filter_deps="gpl avcodec"
2249 mptestsrc_filter_deps="gpl"
2250 negate_filter_deps="lut_filter"
2251 perspective_filter_deps="gpl"
2252 resample_filter_deps="avresample"
2253 ocv_filter_deps="libopencv"
2254 owdenoise_filter_deps="gpl"
2255 pan_filter_deps="swresample"
2256 phase_filter_deps="gpl"
2257 pp_filter_deps="gpl postproc"
2258 pullup_filter_deps="gpl"
2259 removelogo_filter_deps="avcodec avformat swscale"
2260 sab_filter_deps="gpl swscale"
2261 scale_filter_deps="swscale"
2262 smartblur_filter_deps="gpl swscale"
2263 showspectrum_filter_deps="avcodec"
2264 showspectrum_filter_select="rdft"
2265 spp_filter_deps="gpl avcodec"
2266 spp_filter_select="fft"
2267 stereo3d_filter_deps="gpl"
2268 subtitles_filter_deps="avformat avcodec libass"
2269 super2xsai_filter_deps="gpl"
2270 tinterlace_filter_deps="gpl"
2271 vidstabdetect_filter_deps="libvidstab"
2272 vidstabtransform_filter_deps="libvidstab"
2273 yadif_filter_deps="gpl"
2274 pixfmts_super2xsai_test_deps="super2xsai_filter"
2275 tinterlace_merge_test_deps="tinterlace_filter"
2276 tinterlace_pad_test_deps="tinterlace_filter"
2277 zmq_filter_deps="libzmq"
2278
2279 # libraries
2280 avcodec_deps="avutil"
2281 avdevice_deps="avutil avcodec avformat"
2282 avfilter_deps="avutil"
2283 avformat_deps="avutil avcodec"
2284 avresample_deps="avutil"
2285 postproc_deps="avutil gpl"
2286 swscale_deps="avutil"
2287
2288 # programs
2289 ffmpeg_deps="avcodec avfilter avformat swresample"
2290 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
2291                null_filter
2292                setpts_filter trim_filter"
2293 ffplay_deps="avcodec avformat swscale swresample sdl"
2294 ffplay_select="rdft crop_filter"
2295 ffprobe_deps="avcodec avformat"
2296 ffserver_deps="avformat fork sarestart"
2297 ffserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
2298 ffserver_extralibs='$ldl'
2299
2300 # documentation
2301 podpages_deps="perl"
2302 manpages_deps="perl pod2man"
2303 htmlpages_deps="texi2html"
2304 txtpages_deps="makeinfo"
2305 doc_deps_any="manpages htmlpages podpages txtpages"
2306
2307 # default parameters
2308
2309 logfile="config.log"
2310
2311 # installation paths
2312 prefix_default="/usr/local"
2313 bindir_default='${prefix}/bin'
2314 datadir_default='${prefix}/share/ffmpeg'
2315 docdir_default='${prefix}/share/doc/ffmpeg'
2316 incdir_default='${prefix}/include'
2317 libdir_default='${prefix}/lib'
2318 mandir_default='${prefix}/share/man'
2319 shlibdir_default="$libdir_default"
2320
2321 # toolchain
2322 ar_default="ar"
2323 cc_default="gcc"
2324 cxx_default="g++"
2325 host_cc_default="gcc"
2326 cp_f="cp -f"
2327 install="install"
2328 ln_s="ln -s -f"
2329 nm_default="nm -g"
2330 objformat="elf"
2331 pkg_config_default=pkg-config
2332 ranlib="ranlib"
2333 strip_default="strip"
2334 yasmexe_default="yasm"
2335
2336 nogas=":"
2337
2338 # machine
2339 arch_default=$(uname -m)
2340 cpu="generic"
2341
2342 # OS
2343 target_os_default=$(tolower $(uname -s))
2344 host_os=$target_os_default
2345
2346 # configurable options
2347 enable $PROGRAM_LIST
2348 enable $DOCUMENT_LIST
2349 enable $(filter_out avresample $LIBRARY_LIST)
2350 enable stripping
2351
2352 enable asm
2353 enable debug
2354 enable doc
2355 enable optimizations
2356 enable runtime_cpudetect
2357 enable safe_bitstream_reader
2358 enable static
2359 enable swscale_alpha
2360
2361 # Enable hwaccels by default.
2362 enable dxva2 vaapi vdpau
2363
2364 # build settings
2365 SHFLAGS='-shared -Wl,-soname,$$(@F)'
2366 LIBPREF="lib"
2367 LIBSUF=".a"
2368 FULLNAME='$(NAME)$(BUILDSUF)'
2369 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
2370 SLIBPREF="lib"
2371 SLIBSUF=".so"
2372 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
2373 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2374 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2375 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2376 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2377 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2378
2379 asflags_filter=echo
2380 cflags_filter=echo
2381 ldflags_filter=echo
2382
2383 AS_C='-c'
2384 AS_O='-o $@'
2385 CC_C='-c'
2386 CC_E='-E -o $@'
2387 CC_O='-o $@'
2388 CXX_C='-c'
2389 CXX_O='-o $@'
2390 LD_O='-o $@'
2391 LD_LIB='-l%'
2392 LD_PATH='-L'
2393 HOSTCC_C='-c'
2394 HOSTCC_O='-o $@'
2395 HOSTLD_O='-o $@'
2396
2397 host_cflags='-O3 -g'
2398 host_cppflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600'
2399 host_libs='-lm'
2400 host_cflags_filter=echo
2401 host_ldflags_filter=echo
2402
2403 target_path='$(CURDIR)'
2404
2405 # since the object filename is not given with the -MM flag, the compiler
2406 # is only able to print the basename, and we must add the path ourselves
2407 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2408 DEPFLAGS='-MM'
2409
2410 # find source path
2411 if test -f configure; then
2412     source_path=.
2413 else
2414     source_path=$(cd $(dirname "$0"); pwd)
2415     echo "$source_path" | grep -q '[[:blank:]]' &&
2416         die "Out of tree builds are impossible with whitespace in source path."
2417     test -e "$source_path/config.h" &&
2418         die "Out of tree builds are impossible with config.h in source dir."
2419 fi
2420
2421 for v in "$@"; do
2422     r=${v#*=}
2423     l=${v%"$r"}
2424     r=$(sh_quote "$r")
2425     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
2426 done
2427
2428 find_things(){
2429     thing=$1
2430     pattern=$2
2431     file=$source_path/$3
2432     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2433 }
2434
2435 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
2436 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
2437 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
2438 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
2439 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
2440 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
2441 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
2442 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
2443 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
2444 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
2445 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
2446
2447 ALL_COMPONENTS="
2448     $BSF_LIST
2449     $DECODER_LIST
2450     $DEMUXER_LIST
2451     $ENCODER_LIST
2452     $FILTER_LIST
2453     $HWACCEL_LIST
2454     $INDEV_LIST
2455     $MUXER_LIST
2456     $OUTDEV_LIST
2457     $PARSER_LIST
2458     $PROTOCOL_LIST
2459 "
2460
2461 for n in $COMPONENT_LIST; do
2462     v=$(toupper ${n%s})_LIST
2463     eval enable \$$v
2464     eval ${n}_if_any="\$$v"
2465 done
2466
2467 enable $ARCH_EXT_LIST
2468
2469 die_unknown(){
2470     echo "Unknown option \"$1\"."
2471     echo "See $0 --help for available options."
2472     exit 1
2473 }
2474
2475 print_3_columns() {
2476     cat | tr ' ' '\n' | sort | pr -r -3 -t
2477 }
2478
2479 show_list() {
2480     suffix=_$1
2481     shift
2482     echo $* | sed s/$suffix//g | print_3_columns
2483     exit 0
2484 }
2485
2486 rand_list(){
2487     IFS=', '
2488     set -- $*
2489     unset IFS
2490     for thing; do
2491         comp=${thing%:*}
2492         prob=${thing#$comp}
2493         prob=${prob#:}
2494         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
2495         echo "prob ${prob:-0.5}"
2496         printf '%s\n' $comp
2497     done
2498 }
2499
2500 do_random(){
2501     action=$1
2502     shift
2503     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
2504     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
2505 }
2506
2507 for opt do
2508     optval="${opt#*=}"
2509     case "$opt" in
2510         --extra-ldflags=*)
2511             add_ldflags $optval
2512         ;;
2513         --extra-libs=*)
2514             add_extralibs $optval
2515         ;;
2516         --disable-devices)
2517             disable $INDEV_LIST $OUTDEV_LIST
2518         ;;
2519         --enable-debug=*)
2520             debuglevel="$optval"
2521         ;;
2522         --disable-programs)
2523             disable $PROGRAM_LIST
2524         ;;
2525         --disable-everything)
2526             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2527         ;;
2528         --disable-all)
2529             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2530             disable $LIBRARY_LIST $PROGRAM_LIST doc
2531         ;;
2532         --enable-random|--disable-random)
2533             action=${opt%%-random}
2534             do_random ${action#--} $COMPONENT_LIST
2535         ;;
2536         --enable-random=*|--disable-random=*)
2537             action=${opt%%-random=*}
2538             do_random ${action#--} $optval
2539         ;;
2540         --enable-*=*|--disable-*=*)
2541             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2542             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2543             eval list=\$$(toupper $thing)_LIST
2544             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2545             list=$(filter "$name" $list)
2546             [ "$list" = "" ] && warn "Option $opt did not match anything"
2547             $action $list
2548         ;;
2549         --enable-?*|--disable-?*)
2550             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2551             if is_in $option $COMPONENT_LIST; then
2552                 test $action = disable && action=unset
2553                 eval $action \$$(toupper ${option%s})_LIST
2554             elif is_in $option $CMDLINE_SELECT; then
2555                 $action $option
2556             else
2557                 die_unknown $opt
2558             fi
2559         ;;
2560         --list-*)
2561             NAME="${opt#--list-}"
2562             is_in $NAME $COMPONENT_LIST || die_unknown $opt
2563             NAME=${NAME%s}
2564             eval show_list $NAME \$$(toupper $NAME)_LIST
2565         ;;
2566         --help|-h) show_help
2567         ;;
2568         --fatal-warnings) enable fatal_warnings
2569         ;;
2570         *)
2571             optname="${opt%%=*}"
2572             optname="${optname#--}"
2573             optname=$(echo "$optname" | sed 's/-/_/g')
2574             if is_in $optname $CMDLINE_SET; then
2575                 eval $optname='$optval'
2576             elif is_in $optname $CMDLINE_APPEND; then
2577                 append $optname "$optval"
2578             else
2579                 die_unknown $opt
2580             fi
2581         ;;
2582     esac
2583 done
2584
2585 disabled logging && logfile=/dev/null
2586
2587 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
2588 set >> $logfile
2589
2590 test -n "$cross_prefix" && enable cross_compile
2591
2592 if enabled cross_compile; then
2593     test -n "$arch" && test -n "$target_os" ||
2594         die "Must specify target arch and OS when cross-compiling"
2595 fi
2596
2597 ar_default="${cross_prefix}${ar_default}"
2598 cc_default="${cross_prefix}${cc_default}"
2599 cxx_default="${cross_prefix}${cxx_default}"
2600 nm_default="${cross_prefix}${nm_default}"
2601 pkg_config_default="${cross_prefix}${pkg_config_default}"
2602 ranlib="${cross_prefix}${ranlib}"
2603 strip_default="${cross_prefix}${strip_default}"
2604
2605 sysinclude_default="${sysroot}/usr/include"
2606
2607 test -n "$valgrind" && toolchain="valgrind-memcheck"
2608
2609 case "$toolchain" in
2610     clang-asan)
2611         cc_default="clang"
2612         add_cflags  -fsanitize=address
2613         add_ldflags -fsanitize=address
2614     ;;
2615     clang-tsan)
2616         cc_default="clang"
2617         add_cflags  -fsanitize=thread -pie
2618         add_ldflags -fsanitize=thread -pie
2619     ;;
2620     gcc-asan)
2621         cc_default="gcc"
2622         add_cflags  -fsanitize=address
2623         add_ldflags -fsanitize=address
2624     ;;
2625     gcc-tsan)
2626         cc_default="gcc"
2627         add_cflags  -fsanitize=thread -pie -fPIC
2628         add_ldflags -fsanitize=thread -pie -fPIC
2629     ;;
2630     valgrind-massif)
2631         target_exec_default=${valgrind:-"valgrind"}
2632         target_exec_args="--tool=massif --alloc-fn=av_malloc --alloc-fn=av_mallocz --alloc-fn=av_calloc --alloc-fn=av_fast_padded_malloc --alloc-fn=av_fast_malloc --alloc-fn=av_realloc_f --alloc-fn=av_fast_realloc --alloc-fn=av_realloc"
2633     ;;
2634     valgrind-memcheck)
2635         target_exec_default=${valgrind:-"valgrind"}
2636         target_exec_args="--error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp"
2637     ;;
2638     msvc)
2639         cc_default="c99wrap cl"
2640         ld_default="c99wrap link"
2641         nm_default="dumpbin -symbols"
2642         ar_default="lib"
2643         target_os_default="win32"
2644     ;;
2645     icl)
2646         cc_default="c99wrap -noconv icl"
2647         ld_default="c99wrap xilink"
2648         nm_default="dumpbin -symbols"
2649         ar_default="xilib"
2650         target_os_default="win32"
2651     ;;
2652     gcov)
2653         add_cflags  -fprofile-arcs -ftest-coverage
2654         add_ldflags -fprofile-arcs -ftest-coverage
2655     ;;
2656     ?*)
2657         die "Unknown toolchain $toolchain"
2658     ;;
2659 esac
2660
2661 set_default arch cc cxx pkg_config strip sysinclude target_exec target_os yasmexe
2662 enabled cross_compile || host_cc_default=$cc
2663 set_default host_cc
2664
2665 if ! $pkg_config --version >/dev/null 2>&1; then
2666     warn "$pkg_config not found, library detection may fail."
2667     pkg_config=false
2668 fi
2669
2670 exesuf() {
2671     case $1 in
2672         mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
2673     esac
2674 }
2675
2676 EXESUF=$(exesuf $target_os)
2677 HOSTEXESUF=$(exesuf $host_os)
2678
2679 # set temporary file name
2680 : ${TMPDIR:=$TEMPDIR}
2681 : ${TMPDIR:=$TMP}
2682 : ${TMPDIR:=/tmp}
2683
2684 if [ -n "$tempprefix" ] ; then
2685     mktemp(){
2686         echo $tempprefix.${HOSTNAME}.${UID}
2687     }
2688 elif ! check_cmd mktemp -u XXXXXX; then
2689     # simple replacement for missing mktemp
2690     # NOT SAFE FOR GENERAL USE
2691     mktemp(){
2692         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2693     }
2694 fi
2695
2696 tmpfile(){
2697     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2698         (set -C; exec > $tmp) 2>/dev/null ||
2699         die "Unable to create temporary file in $TMPDIR."
2700     append TMPFILES $tmp
2701     eval $1=$tmp
2702 }
2703
2704 trap 'rm -f -- $TMPFILES' EXIT
2705
2706 tmpfile TMPASM .asm
2707 tmpfile TMPC   .c
2708 tmpfile TMPCPP .cpp
2709 tmpfile TMPE   $EXESUF
2710 tmpfile TMPH   .h
2711 tmpfile TMPO   .o
2712 tmpfile TMPS   .S
2713 tmpfile TMPSH  .sh
2714 tmpfile TMPV   .ver
2715
2716 unset -f mktemp
2717
2718 chmod +x $TMPE
2719
2720 # make sure we can execute files in $TMPDIR
2721 cat > $TMPSH 2>> $logfile <<EOF
2722 #! /bin/sh
2723 EOF
2724 chmod +x $TMPSH >> $logfile 2>&1
2725 if ! $TMPSH >> $logfile 2>&1; then
2726     cat <<EOF
2727 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
2728 variable to another directory and make sure that it is not mounted noexec.
2729 EOF
2730     die "Sanity test failed."
2731 fi
2732
2733 ccc_flags(){
2734     for flag; do
2735         case $flag in
2736             -std=c99)           echo -c99                       ;;
2737             -mcpu=*)            echo -arch ${flag#*=}           ;;
2738             -mieee)             echo -ieee                      ;;
2739             -O*|-fast)          echo $flag                      ;;
2740             -fno-math-errno)    echo -assume nomath_errno       ;;
2741             -g)                 echo -g3                        ;;
2742             -Wall)              echo -msg_enable level2         ;;
2743             -Wno-pointer-sign)  echo -msg_disable ptrmismatch1  ;;
2744             -Wl,*)              echo $flag                      ;;
2745             -f*|-W*)                                            ;;
2746             *)                  echo $flag                      ;;
2747         esac
2748    done
2749 }
2750
2751 cparser_flags(){
2752     for flag; do
2753         case $flag in
2754             -Wno-switch)             echo -Wno-switch-enum ;;
2755             -Wno-format-zero-length) ;;
2756             -Wdisabled-optimization) ;;
2757             -Wno-pointer-sign)       echo -Wno-other ;;
2758             *)                       echo $flag ;;
2759         esac
2760     done
2761 }
2762
2763 msvc_common_flags(){
2764     for flag; do
2765         case $flag in
2766             # In addition to specifying certain flags under the compiler
2767             # specific filters, they must be specified here as well or else the
2768             # generic catch all at the bottom will print the original flag.
2769             -Wall)                ;;
2770             -std=c99)             ;;
2771             # Common flags
2772             -fomit-frame-pointer) ;;
2773             -g)                   echo -Z7 ;;
2774             -fno-math-errno)      ;;
2775             -fno-common)          ;;
2776             -fno-signed-zeros)    ;;
2777             -fPIC)                ;;
2778             -mthumb)              ;;
2779             -march=*)             ;;
2780             -lz)                  echo zlib.lib ;;
2781             -lavifil32)           echo vfw32.lib ;;
2782             -lavicap32)           echo vfw32.lib user32.lib ;;
2783             -l*)                  echo ${flag#-l}.lib ;;
2784             *)                    echo $flag ;;
2785         esac
2786     done
2787 }
2788
2789 msvc_flags(){
2790     msvc_common_flags "$@"
2791     for flag; do
2792         case $flag in
2793             -Wall)                echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
2794                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
2795                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
2796                                        -wd4554 \
2797                                        -wd4273 ;;
2798         esac
2799     done
2800 }
2801
2802 icl_flags(){
2803     msvc_common_flags "$@"
2804     for flag; do
2805         case $flag in
2806             # Despite what Intel's documentation says -Wall, which is supported
2807             # on Windows, does enable remarks so disable them here.
2808             -Wall)                echo $flag -Qdiag-disable:remark ;;
2809             -std=c99)             echo -Qstd=c99 ;;
2810         esac
2811     done
2812 }
2813
2814 pgi_flags(){
2815     for flag; do
2816         case $flag in
2817             -flto)                echo -Mipa=fast,libopt,libinline,vestigial ;;
2818             -fomit-frame-pointer) echo -Mnoframe ;;
2819             -g)                   echo -gopt ;;
2820             *)                    echo $flag ;;
2821         esac
2822     done
2823 }
2824
2825 suncc_flags(){
2826     for flag; do
2827         case $flag in
2828             -march=*|-mcpu=*)
2829                 case "${flag#*=}" in
2830                     native)                   echo -xtarget=native       ;;
2831                     v9|niagara)               echo -xarch=sparc          ;;
2832                     ultrasparc)               echo -xarch=sparcvis       ;;
2833                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
2834                     i586|pentium)             echo -xchip=pentium        ;;
2835                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
2836                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
2837                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
2838                     pentium4*)          echo -xtarget=pentium4           ;;
2839                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2840                     *-sse3)             echo -xarch=sse3                 ;;
2841                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
2842                     corei7)           echo -xarch=sse4_2 -xchip=nehalem  ;;
2843                     corei7-avx)       echo -xarch=avx -xchip=sandybridge ;;
2844                     amdfam10|barcelona)        echo -xtarget=barcelona   ;;
2845                     bdver*)                    echo -xarch=avx           ;;
2846                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
2847                     k8|opteron|athlon64|athlon-fx)
2848                                                echo -xarch=sse2a         ;;
2849                     athlon*)                   echo -xarch=pentium_proa  ;;
2850                 esac
2851                 ;;
2852             -std=c99)             echo -xc99              ;;
2853             -fomit-frame-pointer) echo -xregs=frameptr    ;;
2854             -fPIC)                echo -KPIC -xcode=pic32 ;;
2855             -W*,*)                echo $flag              ;;
2856             -f*-*|-W*|-mimpure-text)                      ;;
2857             -shared)              echo -G                 ;;
2858             *)                    echo $flag              ;;
2859         esac
2860     done
2861 }
2862
2863 tms470_flags(){
2864     for flag; do
2865         case $flag in
2866             -march=*|-mcpu=*)
2867                 case "${flag#*=}" in
2868                     armv7-a|cortex-a*)      echo -mv=7a8 ;;
2869                     armv7-r|cortex-r*)      echo -mv=7r4 ;;
2870                     armv7-m|cortex-m*)      echo -mv=7m3 ;;
2871                     armv6*|arm11*)          echo -mv=6   ;;
2872                     armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2873                                             echo -mv=5e  ;;
2874                     armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
2875                 esac
2876                 ;;
2877             -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
2878             -mfpu=vfp)      echo --float_support=vfpv2        ;;
2879             -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
2880             -mfpu=vfpv3-d16) echo --float_support=vfpv3d16    ;;
2881             -msoft-float)   echo --float_support=vfplib       ;;
2882             -O[0-3]|-mf=*)  echo $flag                        ;;
2883             -g)             echo -g -mn                       ;;
2884             -pds=*)         echo $flag                        ;;
2885             -D*|-I*)        echo $flag                        ;;
2886             --gcc|--abi=*)  echo $flag                        ;;
2887             -me)            echo $flag                        ;;
2888         esac
2889     done
2890 }
2891
2892 probe_cc(){
2893     pfx=$1
2894     _cc=$2
2895
2896     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
2897     unset _ld_o _ldflags _ld_lib _ld_path
2898     unset _depflags _DEPCMD _DEPFLAGS
2899     _flags_filter=echo
2900
2901     if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
2902         true # no-op to avoid reading stdin in following checks
2903     elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
2904         _type=llvm_gcc
2905         gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
2906         _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
2907         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2908         _cflags_speed='-O3'
2909         _cflags_size='-Os'
2910     elif $_cc -v 2>&1 | grep -qi ^gcc; then
2911         _type=gcc
2912         gcc_version=$($_cc --version | head -n1)
2913         gcc_basever=$($_cc -dumpversion)
2914         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
2915         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
2916         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
2917         if ! $_cc -dumpversion | grep -q '^2\.'; then
2918             _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2919         fi
2920         _cflags_speed='-O3'
2921         _cflags_size='-Os'
2922     elif $_cc --version 2>/dev/null | grep -q ^icc; then
2923         _type=icc
2924         _ident=$($_cc --version | head -n1)
2925         _depflags='-MMD'
2926         _cflags_speed='-O3'
2927         _cflags_size='-Os'
2928         _cflags_noopt='-O1'
2929     elif $_cc -v 2>&1 | grep -q xlc; then
2930         _type=xlc
2931         _ident=$($_cc -qversion 2>/dev/null | head -n1)
2932         _cflags_speed='-O5'
2933         _cflags_size='-O5 -qcompact'
2934     elif $_cc -V 2>/dev/null | grep -q Compaq; then
2935         _type=ccc
2936         _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
2937         _DEPFLAGS='-M'
2938         _cflags_speed='-fast'
2939         _cflags_size='-O1'
2940         _flags_filter=ccc_flags
2941     elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
2942         test -d "$sysroot" || die "No valid sysroot specified."
2943         _type=armcc
2944         _ident=$($_cc --vsn | head -n1)
2945         armcc_conf="$PWD/armcc.conf"
2946         $_cc --arm_linux_configure                 \
2947              --arm_linux_config_file="$armcc_conf" \
2948              --configure_sysroot="$sysroot"        \
2949              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2950              die "Error creating armcc configuration file."
2951         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
2952         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
2953         as_default="${cross_prefix}gcc"
2954         _depflags='-MMD'
2955         _cflags_speed='-O3'
2956         _cflags_size='-Os'
2957     elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
2958         _type=tms470
2959         _ident=$($_cc -version | head -n1 | tr -s ' ')
2960         _flags='--gcc --abi=eabi -me'
2961         _cc_e='-ppl -fe=$@'
2962         _cc_o='-fe=$@'
2963         _depflags='-ppa -ppd=$(@:.o=.d)'
2964         _cflags_speed='-O3 -mf=5'
2965         _cflags_size='-O3 -mf=2'
2966         _flags_filter=tms470_flags
2967     elif $_cc -v 2>&1 | grep -q clang; then
2968         _type=clang
2969         _ident=$($_cc --version | head -n1)
2970         _depflags='-MMD'
2971         _cflags_speed='-O3'
2972         _cflags_size='-Os'
2973     elif $_cc -V 2>&1 | grep -q Sun; then
2974         _type=suncc
2975         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2976         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2977         _DEPFLAGS='-xM1 -xc99'
2978         _ldflags='-std=c99'
2979         _cflags_speed='-O5'
2980         _cflags_size='-O5 -xspace'
2981         _flags_filter=suncc_flags
2982     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2983         _type=pathscale
2984         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2985         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2986         _cflags_speed='-O2'
2987         _cflags_size='-Os'
2988         _flags_filter='filter_out -Wdisabled-optimization'
2989     elif $_cc -v 2>&1 | grep -q Open64; then
2990         _type=open64
2991         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2992         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2993         _cflags_speed='-O2'
2994         _cflags_size='-Os'
2995         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
2996     elif $_cc -V 2>&1 | grep -q Portland; then
2997         _type=pgi
2998         _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
2999         opt_common='-alias=ansi -Mdse -Mlre -Mpre'
3000         _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
3001         _cflags_size="-O2 -Munroll=c:1 $opt_common"
3002         _cflags_noopt="-O"
3003         _flags_filter=pgi_flags
3004     elif $_cc 2>&1 | grep -q Microsoft; then
3005         _type=msvc
3006         _ident=$($cc 2>&1 | head -n1)
3007         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
3008         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
3009         _cflags_speed="-O2"
3010         _cflags_size="-O1"
3011         # Nonstandard output options, to avoid msys path conversion issues.
3012         # Relies on wrapper to remap it.
3013         if $_cc 2>&1 | grep -q Linker; then
3014             _ld_o='-out $@'
3015         else
3016             _ld_o='-Fe$@'
3017         fi
3018         _cc_o='-Fo $@'
3019         _cc_e='-P -Fi $@'
3020         _flags_filter=msvc_flags
3021         _ld_lib='lib%.a'
3022         _ld_path='-libpath:'
3023         _flags='-nologo'
3024         _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
3025         if [ $pfx = hostcc ]; then
3026             append _cflags -Dsnprintf=_snprintf
3027         fi
3028         disable stripping
3029     elif $_cc 2>&1 | grep -q Intel; then
3030         _type=icl
3031         _ident=$($cc 2>&1 | head -n1)
3032         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
3033         # Not only is O3 broken on 13.x+ but it is slower on all previous
3034         # versions (tested) as well.
3035         _cflags_speed="-O2"
3036         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
3037         # Nonstandard output options, to avoid msys path conversion issues.
3038         # Relies on wrapper to remap it.
3039         if $_cc 2>&1 | grep -q Linker; then
3040             _ld_o='-out $@'
3041         else
3042             _ld_o='-Fe$@'
3043         fi
3044         _cc_o='-Fo $@'
3045         _cc_e='-P'
3046         _flags_filter=icl_flags
3047         _ld_lib='lib%.a'
3048         _ld_path='-libpath:'
3049         # -Qdiag-error to make icl error when seeing certain unknown arguments
3050         _flags='-nologo -Qdiag-error:4044,10157'
3051         # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
3052         # with MSVC which enables it by default.
3053         _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS'
3054         if [ $pfx = hostcc ]; then
3055             append _cflags -Dsnprintf=_snprintf
3056         fi
3057     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3058         _type=cparser
3059         _ident=$($_cc --version | head -n1)
3060         _depflags='-MMD'
3061         _cflags_speed='-O4'
3062         _cflags_size='-O2'
3063         _flags_filter=cparser_flags
3064     fi
3065
3066     eval ${pfx}_type=\$_type
3067     eval ${pfx}_ident=\$_ident
3068 }
3069
3070 set_ccvars(){
3071     eval ${1}_C=\${_cc_c-\${${1}_C}}
3072     eval ${1}_E=\${_cc_e-\${${1}_E}}
3073     eval ${1}_O=\${_cc_o-\${${1}_O}}
3074
3075     if [ -n "$_depflags" ]; then
3076         eval ${1}_DEPFLAGS=\$_depflags
3077     else
3078         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3079         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3080         eval DEP${1}FLAGS=\$_flags
3081     fi
3082 }
3083
3084 probe_cc cc "$cc"
3085 cflags_filter=$_flags_filter
3086 cflags_speed=$_cflags_speed
3087 cflags_size=$_cflags_size
3088 cflags_noopt=$_cflags_noopt
3089 add_cflags $_flags $_cflags
3090 cc_ldflags=$_ldflags
3091 set_ccvars CC
3092
3093 probe_cc hostcc "$host_cc"
3094 host_cflags_filter=$_flags_filter
3095 add_host_cflags  $_flags $_cflags
3096 set_ccvars HOSTCC
3097
3098 test -n "$cc_type" && enable $cc_type ||
3099     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3100
3101 : ${as_default:=$cc}
3102 : ${dep_cc_default:=$cc}
3103 : ${ld_default:=$cc}
3104 : ${host_ld_default:=$host_cc}
3105 set_default ar as dep_cc ld host_ld
3106
3107 probe_cc as "$as"
3108 asflags_filter=$_flags_filter
3109 add_asflags $_flags $_cflags
3110 set_ccvars AS
3111
3112 probe_cc ld "$ld"
3113 ldflags_filter=$_flags_filter
3114 add_ldflags $_flags $_ldflags
3115 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3116 LD_O=${_ld_o-$LD_O}
3117 LD_LIB=${_ld_lib-$LD_LIB}
3118 LD_PATH=${_ld_path-$LD_PATH}
3119
3120 probe_cc hostld "$host_ld"
3121 host_ldflags_filter=$_flags_filter
3122 add_host_ldflags $_flags $_ldflags
3123 HOSTLD_O=${_ld_o-$HOSTLD_O}
3124
3125 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3126     probe_cc depcc "$dep_cc"
3127     CCDEP=${_DEPCMD:-$DEPCMD}
3128     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3129     DEPCCFLAGS=$_flags
3130 fi
3131
3132 if $ar 2>&1 | grep -q Microsoft; then
3133     arflags="-nologo"
3134     ar_o='-out:$@'
3135 elif $ar 2>&1 | grep -q 'Texas Instruments'; then
3136     arflags="rq"
3137     ar_o='$@'
3138 elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then
3139     arflags='-Xany -r -c'
3140     ar_o='$@'
3141 else
3142     arflags="rc"
3143     ar_o='$@'
3144 fi
3145
3146 add_cflags $extra_cflags
3147 add_cxxflags $extra_cxxflags
3148 add_asflags $extra_cflags
3149
3150 if test -n "$sysroot"; then
3151     case "$cc_type" in
3152         gcc|llvm_gcc|clang)
3153             add_cppflags --sysroot="$sysroot"
3154             add_ldflags --sysroot="$sysroot"
3155         ;;
3156         tms470)
3157             add_cppflags -I"$sysinclude"
3158             add_ldflags  --sysroot="$sysroot"
3159         ;;
3160     esac
3161 fi
3162
3163 if test "$cpu" = host; then
3164     enabled cross_compile &&
3165         die "--cpu=host makes no sense when cross-compiling."
3166
3167     case "$cc_type" in
3168         gcc|llvm_gcc)
3169             check_native(){
3170                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3171                 sed -n "/cc1.*$1=/{
3172                             s/.*$1=\\([^ ]*\\).*/\\1/
3173                             p
3174                             q
3175                         }" $TMPE
3176             }
3177             cpu=$(check_native -march || check_native -mcpu)
3178         ;;
3179     esac
3180
3181     test "${cpu:-host}" = host &&
3182         die "--cpu=host not supported with compiler $cc"
3183 fi
3184
3185 # Deal with common $arch aliases
3186 case "$arch" in
3187     aarch64|arm64)
3188         arch="aarch64"
3189     ;;
3190     arm*|iPad*|iPhone*)
3191         arch="arm"
3192     ;;
3193     mips*|IP*)
3194         arch="mips"
3195     ;;
3196     parisc*|hppa*)
3197         arch="parisc"
3198     ;;
3199     "Power Macintosh"|ppc*|powerpc*)
3200         arch="ppc"
3201     ;;
3202     s390|s390x)
3203         arch="s390"
3204     ;;
3205     sh4|sh)
3206         arch="sh4"
3207     ;;
3208     sun4u|sparc*)
3209         arch="sparc"
3210     ;;
3211     tilegx|tile-gx)
3212         arch="tilegx"
3213     ;;
3214     i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
3215         arch="x86"
3216     ;;
3217 esac
3218
3219 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3220 enable $arch
3221
3222 # Add processor-specific flags
3223 if enabled aarch64; then
3224
3225     case $cpu in
3226         armv*)
3227             cpuflags="-march=$cpu"
3228         ;;
3229         *)
3230             cpuflags="-mcpu=$cpu"
3231         ;;
3232     esac
3233
3234 elif enabled alpha; then
3235
3236     cpuflags="-mcpu=$cpu"
3237
3238 elif enabled arm; then
3239
3240     check_arm_arch() {
3241         check_cpp_condition stddef.h \
3242             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
3243             $cpuflags
3244     }
3245
3246     probe_arm_arch() {
3247         if   check_arm_arch 4;        then echo armv4;
3248         elif check_arm_arch 4T;       then echo armv4t;
3249         elif check_arm_arch 5;        then echo armv5;
3250         elif check_arm_arch 5E;       then echo armv5e;
3251         elif check_arm_arch 5T;       then echo armv5t;
3252         elif check_arm_arch 5TE;      then echo armv5te;
3253         elif check_arm_arch 5TEJ;     then echo armv5te;
3254         elif check_arm_arch 6;        then echo armv6;
3255         elif check_arm_arch 6J;       then echo armv6j;
3256         elif check_arm_arch 6K;       then echo armv6k;
3257         elif check_arm_arch 6Z;       then echo armv6z;
3258         elif check_arm_arch 6ZK;      then echo armv6zk;
3259         elif check_arm_arch 6T2;      then echo armv6t2;
3260         elif check_arm_arch 7;        then echo armv7;
3261         elif check_arm_arch 7A  7_A;  then echo armv7-a;
3262         elif check_arm_arch 7R  7_R;  then echo armv7-r;
3263         elif check_arm_arch 7M  7_M;  then echo armv7-m;
3264         elif check_arm_arch 7EM 7E_M; then echo armv7-m;
3265         elif check_arm_arch 8A  8_A;  then echo armv8-a;
3266         fi
3267     }
3268
3269     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3270
3271     case $cpu in
3272         armv*)
3273             cpuflags="-march=$cpu"
3274             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3275         ;;
3276         *)
3277             cpuflags="-mcpu=$cpu"
3278             case $cpu in
3279                 cortex-a*)                               subarch=armv7a  ;;
3280                 cortex-r*)                               subarch=armv7r  ;;
3281                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
3282                 arm11*)                                  subarch=armv6   ;;
3283                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3284                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
3285                 *)                             subarch=$(probe_arm_arch) ;;
3286             esac
3287         ;;
3288     esac
3289
3290     case "$subarch" in
3291         armv5t*)    enable fast_clz                ;;
3292         armv[6-8]*) enable fast_clz fast_unaligned ;;
3293     esac
3294
3295 elif enabled avr32; then
3296
3297     case $cpu in
3298         ap7[02]0[0-2])
3299             subarch="avr32_ap"
3300             cpuflags="-mpart=$cpu"
3301         ;;
3302         ap)
3303             subarch="avr32_ap"
3304             cpuflags="-march=$cpu"
3305         ;;
3306         uc3[ab]*)
3307             subarch="avr32_uc"
3308             cpuflags="-mcpu=$cpu"
3309         ;;
3310         uc)
3311             subarch="avr32_uc"
3312             cpuflags="-march=$cpu"
3313         ;;
3314     esac
3315
3316 elif enabled bfin; then
3317
3318     cpuflags="-mcpu=$cpu"
3319
3320 elif enabled mips; then
3321
3322     cpuflags="-march=$cpu"
3323
3324     case $cpu in
3325         24kc)
3326             disable mipsfpu
3327             disable mipsdspr1
3328             disable mipsdspr2
3329         ;;
3330         24kf*)
3331             disable mipsdspr1
3332             disable mipsdspr2
3333         ;;
3334         24kec|34kc|1004kc)
3335             disable mipsfpu
3336             disable mipsdspr2
3337         ;;
3338         24kef*|34kf*|1004kf*)
3339             disable mipsdspr2
3340         ;;
3341         74kc)
3342             disable mipsfpu
3343         ;;
3344     esac
3345
3346 elif enabled ppc; then
3347
3348     case $(tolower $cpu) in
3349         601|ppc601|powerpc601)
3350             cpuflags="-mcpu=601"
3351             disable altivec
3352         ;;
3353         603*|ppc603*|powerpc603*)
3354             cpuflags="-mcpu=603"
3355             disable altivec
3356         ;;
3357         604*|ppc604*|powerpc604*)
3358             cpuflags="-mcpu=604"
3359             disable altivec
3360         ;;
3361         g3|75*|ppc75*|powerpc75*)
3362             cpuflags="-mcpu=750"
3363             disable altivec
3364         ;;
3365         g4|745*|ppc745*|powerpc745*)
3366             cpuflags="-mcpu=7450"
3367         ;;
3368         74*|ppc74*|powerpc74*)
3369             cpuflags="-mcpu=7400"
3370         ;;
3371         g5|970|ppc970|powerpc970)
3372             cpuflags="-mcpu=970"
3373         ;;
3374         power[3-7]*)
3375             cpuflags="-mcpu=$cpu"
3376         ;;
3377         cell)
3378             cpuflags="-mcpu=cell"
3379             enable ldbrx
3380         ;;
3381         e500mc)
3382             cpuflags="-mcpu=e500mc"
3383             disable altivec
3384         ;;
3385         e500v2)
3386             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3387             disable altivec
3388         ;;
3389         e500)
3390             cpuflags="-mcpu=8540 -mhard-float"
3391             disable altivec
3392         ;;
3393     esac
3394
3395 elif enabled sparc; then
3396
3397     case $cpu in
3398         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3399             cpuflags="-mcpu=$cpu"
3400             disable vis
3401         ;;
3402         ultrasparc*|niagara[234])
3403             cpuflags="-mcpu=$cpu"
3404         ;;
3405     esac
3406
3407 elif enabled x86; then
3408
3409     case $cpu in
3410         i[345]86|pentium)
3411             cpuflags="-march=$cpu"
3412             disable mmx
3413         ;;
3414         # targets that do NOT support nopl and conditional mov (cmov)
3415         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3416             cpuflags="-march=$cpu"
3417             disable i686
3418         ;;
3419         # targets that do support nopl and conditional mov (cmov)
3420         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
3421             cpuflags="-march=$cpu"
3422             enable i686
3423             enable fast_cmov
3424         ;;
3425         # targets that do support conditional mov but on which it's slow
3426         pentium4|pentium4m|prescott|nocona)
3427             cpuflags="-march=$cpu"
3428             enable i686
3429             disable fast_cmov
3430         ;;
3431     esac
3432
3433 fi
3434
3435 if [ "$cpu" != generic ]; then
3436     add_cflags  $cpuflags
3437     add_asflags $cpuflags
3438 fi
3439
3440 # compiler sanity check
3441 check_exec <<EOF
3442 int main(void){ return 0; }
3443 EOF
3444 if test "$?" != 0; then
3445     echo "$cc is unable to create an executable file."
3446     if test -z "$cross_prefix" && ! enabled cross_compile ; then
3447         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3448         echo "Only do this if you know what cross compiling means."
3449     fi
3450     die "C compiler test failed."
3451 fi
3452
3453 add_cppflags -D_ISOC99_SOURCE
3454 add_cxxflags -D__STDC_CONSTANT_MACROS
3455 check_cflags -std=c99
3456 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
3457 #include <stdlib.h>
3458 EOF
3459 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
3460 #include <stdlib.h>
3461 EOF
3462
3463 check_host_cflags -std=c99
3464 check_host_cflags -Wall
3465
3466 check_64bit(){
3467     arch32=$1
3468     arch64=$2
3469     expr=$3
3470     check_code cc "" "int test[2*($expr) - 1]" &&
3471         subarch=$arch64 || subarch=$arch32
3472 }
3473
3474 case "$arch" in
3475     aarch64|alpha|ia64)
3476         spic=$shared
3477     ;;
3478     mips)
3479         check_64bit mips mips64 '_MIPS_SIM > 1'
3480         spic=$shared
3481     ;;
3482     parisc)
3483         check_64bit parisc parisc64 'sizeof(void *) > 4'
3484         spic=$shared
3485     ;;
3486     ppc)
3487         check_64bit ppc ppc64 'sizeof(void *) > 4'
3488         spic=$shared
3489     ;;
3490     sparc)
3491         check_64bit sparc sparc64 'sizeof(void *) > 4'
3492         spic=$shared
3493     ;;
3494     x86)
3495         check_64bit x86_32 x86_64 'sizeof(void *) > 4'
3496         if test "$subarch" = "x86_64"; then
3497             spic=$shared
3498         fi
3499     ;;
3500     ppc)
3501         check_cc <<EOF && subarch="ppc64"
3502         int test[(int)sizeof(char*) - 7];
3503 EOF
3504     ;;
3505 esac
3506
3507 enable $subarch
3508 enabled spic && enable_weak pic
3509
3510 # OS specific
3511 case $target_os in
3512     aix)
3513         SHFLAGS=-shared
3514         add_cppflags '-I\$(SRC_PATH)/compat/aix'
3515         enabled shared && add_ldflags -Wl,-brtl
3516         ;;
3517     haiku)
3518         prefix_default="/boot/common"
3519         network_extralibs="-lnetwork"
3520         host_libs=
3521         ;;
3522     sunos)
3523         SHFLAGS='-shared -Wl,-h,$$(@F)'
3524         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
3525         network_extralibs="-lsocket -lnsl"
3526         add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
3527         # When using suncc to build, the Solaris linker will mark
3528         # an executable with each instruction set encountered by
3529         # the Solaris assembler.  As our libraries contain their own
3530         # guards for processor-specific code, instead suppress
3531         # generation of the HWCAPS ELF section on Solaris x86 only.
3532         enabled_all suncc x86 &&
3533             echo "hwcap_1 = OVERRIDE;" > mapfile &&
3534             add_ldflags -Wl,-M,mapfile
3535         nm_default='nm -P -g'
3536         ;;
3537     netbsd)
3538         disable symver
3539         oss_indev_extralibs="-lossaudio"
3540         oss_outdev_extralibs="-lossaudio"
3541         enabled gcc || check_ldflags -Wl,-zmuldefs
3542         ;;
3543     openbsd|bitrig)
3544         disable symver
3545         SHFLAGS='-shared'
3546         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3547         SLIB_INSTALL_LINKS=
3548         oss_indev_extralibs="-lossaudio"
3549         oss_outdev_extralibs="-lossaudio"
3550         ;;
3551     dragonfly)
3552         disable symver
3553         ;;
3554     freebsd)
3555         ;;
3556     bsd/os)
3557         add_extralibs -lpoll -lgnugetopt
3558         strip="strip -d"
3559         ;;
3560     darwin)
3561         gas="gas-preprocessor.pl $cc"
3562         enabled ppc && add_asflags -force_cpusubtype_ALL
3563         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3564         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3565         strip="${strip} -x"
3566         add_ldflags -Wl,-dynamic,-search_paths_first
3567         SLIBSUF=".dylib"
3568         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
3569         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
3570         objformat="macho"
3571         enabled x86_64 && objformat="macho64"
3572         enabled_any pic shared ||
3573             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3574         ;;
3575     mingw32*)
3576         if test $target_os = "mingw32ce"; then
3577             disable network
3578         else
3579             target_os=mingw32
3580         fi
3581         LIBTARGET=i386
3582         if enabled x86_64; then
3583             LIBTARGET="i386:x86-64"
3584         elif enabled arm; then
3585             LIBTARGET=arm-wince
3586         fi
3587         check_ldflags -Wl,--nxcompat
3588         check_ldflags -Wl,--dynamicbase
3589         shlibdir_default="$bindir_default"
3590         SLIBPREF=""
3591         SLIBSUF=".dll"
3592         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3593         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3594         dlltool="${cross_prefix}dlltool"
3595         if check_cmd lib.exe -list; then
3596             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3597             if enabled x86_64; then
3598                 LIBTARGET=x64
3599             fi
3600         elif check_cmd $dlltool --version; then
3601             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3602         fi
3603         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3604         SLIB_INSTALL_LINKS=
3605         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3606         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3607         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
3608         objformat="win32"
3609         ranlib=:
3610         enable dos_paths
3611         ;;
3612     win32|win64)
3613         if enabled shared; then
3614             # Link to the import library instead of the normal static library
3615             # for shared libs.
3616             LD_LIB='%.lib'
3617             # Cannot build both shared and static libs with MSVC or icl.
3618             disable static
3619         fi
3620         shlibdir_default="$bindir_default"
3621         SLIBPREF=""
3622         SLIBSUF=".dll"
3623         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3624         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3625         SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3626         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3627         SLIB_INSTALL_LINKS=
3628         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3629         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3630         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3631         objformat="win32"
3632         ranlib=:
3633         enable dos_paths
3634         ;;
3635     cygwin*)
3636         target_os=cygwin
3637         shlibdir_default="$bindir_default"
3638         SLIBPREF="cyg"
3639         SLIBSUF=".dll"
3640         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3641         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3642         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3643         SLIB_INSTALL_LINKS=
3644         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
3645         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
3646         objformat="win32"
3647         enable dos_paths
3648         ;;
3649     *-dos|freedos|opendos)
3650         network_extralibs="-lsocket"
3651         objformat="coff"
3652         enable dos_paths
3653         add_cppflags -U__STRICT_ANSI__
3654         ;;
3655     linux)
3656         enable dv1394
3657         ;;
3658     irix*)
3659         target_os=irix
3660         ranlib="echo ignoring ranlib"
3661         ;;
3662     os/2*)
3663         strip="lxlite -CS"
3664         ln_s="cp -f"
3665         objformat="aout"
3666         add_cppflags -D_GNU_SOURCE
3667         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
3668         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
3669         LIBSUF="_s.a"
3670         SLIBPREF=""
3671         SLIBSUF=".dll"
3672         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3673         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
3674         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
3675             echo PROTMODE >> $(SUBDIR)$(NAME).def; \
3676             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
3677             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
3678             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
3679             emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
3680         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
3681             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
3682         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
3683         enable dos_paths
3684         enable_weak os2threads
3685         ;;
3686     gnu/kfreebsd)
3687         add_cppflags -D_BSD_SOURCE
3688         ;;
3689     gnu)
3690         ;;
3691     qnx)
3692         add_cppflags -D_QNX_SOURCE
3693         network_extralibs="-lsocket"
3694         ;;
3695     symbian)
3696         SLIBSUF=".dll"
3697         enable dos_paths
3698         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
3699         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
3700         add_ldflags -Wl,--target1-abs,--no-undefined \
3701                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
3702                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
3703         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
3704                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
3705                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
3706         ;;
3707     osf1)
3708         add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
3709         ;;
3710     minix)
3711         ;;
3712     plan9)
3713         add_cppflags -D_C99_SNPRINTF_EXTENSION  \
3714                      -D_REENTRANT_SOURCE        \
3715                      -D_RESEARCH_SOURCE         \
3716                      -DFD_SETSIZE=96            \
3717                      -DHAVE_SOCK_OPTS
3718         add_compat strtod.o strtod=avpriv_strtod
3719         network_extralibs='-lbsd'
3720         exeobjs=compat/plan9/main.o
3721         disable ffserver
3722         cp_f='cp'
3723         ;;
3724     none)
3725         ;;
3726     *)
3727         die "Unknown OS '$target_os'."
3728         ;;
3729 esac
3730
3731 # determine libc flavour
3732
3733 # uclibc defines __GLIBC__, so it needs to be checked before glibc.
3734 if check_cpp_condition features.h "defined __UCLIBC__"; then
3735     libc_type=uclibc
3736     add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3737 elif check_cpp_condition features.h "defined __GLIBC__"; then
3738     libc_type=glibc
3739     add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3740 # MinGW headers can be installed on Cygwin, so check for newlib first.
3741 elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
3742     libc_type=newlib
3743     add_cppflags -U__STRICT_ANSI__
3744 elif check_header _mingw.h; then
3745     libc_type=mingw
3746     check_cpp_condition _mingw.h \
3747         "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \
3748             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
3749         die "ERROR: MinGW runtime version must be >= 3.15."
3750     add_cppflags -U__STRICT_ANSI__
3751     if check_cpp_condition _mingw.h "defined(__MINGW64_VERSION_MAJOR) && \
3752             __MINGW64_VERSION_MAJOR < 3"; then
3753         add_compat msvcrt/snprintf.o
3754         add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
3755     else
3756         add_cppflags -D__USE_MINGW_ANSI_STDIO=1
3757     fi
3758 elif check_func_headers stdlib.h _get_doserrno; then
3759     libc_type=msvcrt
3760     add_compat strtod.o strtod=avpriv_strtod
3761     add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
3762                                  _snprintf=avpriv_snprintf  \
3763                                  vsnprintf=avpriv_vsnprintf
3764     # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
3765     # 0x601 by default unless something else is set by the user.
3766     # This can easily lead to us detecting functions only present
3767     # in such new versions and producing binaries requiring windows 7.0.
3768     # Therefore explicitly set the default to XP unless the user has
3769     # set something else on the command line.
3770     check_cpp_condition stdlib.h "defined(_WIN32_WINNT)" || add_cppflags -D_WIN32_WINNT=0x0502
3771 elif check_cpp_condition stddef.h "defined __KLIBC__"; then
3772     libc_type=klibc
3773 elif check_cpp_condition sys/cdefs.h "defined __BIONIC__"; then
3774     libc_type=bionic
3775     add_compat strtod.o strtod=avpriv_strtod
3776 fi
3777
3778 test -n "$libc_type" && enable $libc_type
3779
3780 # hacks for compiler/libc/os combinations
3781
3782 if enabled_all tms470 glibc; then
3783     CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
3784     add_cppflags -D__USER_LABEL_PREFIX__=
3785     add_cppflags -D__builtin_memset=memset
3786     add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
3787     add_cflags   -pds=48    # incompatible redefinition of macro
3788 fi
3789
3790 if enabled_all ccc glibc; then
3791     add_ldflags -Wl,-z,now  # calls to libots crash without this
3792 fi
3793
3794 esc(){
3795     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
3796 }
3797
3798 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" >config.fate
3799
3800 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
3801
3802 set_default $PATHS_LIST
3803 set_default nm
3804
3805 # we need to build at least one lib type
3806 if ! enabled_any static shared; then
3807     cat <<EOF
3808 At least one library type must be built.
3809 Specify --enable-static to build the static libraries or --enable-shared to
3810 build the shared libraries as well. To only build the shared libraries specify
3811 --disable-static in addition to --enable-shared.
3812 EOF
3813     exit 1;
3814 fi
3815
3816 # backward compatibility layer for incompatible_libav/fork_abi
3817 enabled incompatible_fork_abi  && enable incompatible_libav_abi
3818 enabled incompatible_libav_abi && enable incompatible_fork_abi
3819
3820 die_license_disabled() {
3821     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
3822 }
3823
3824 die_license_disabled_gpl() {
3825     enabled $1 || { enabled $2 && die "$2 is incompatible with the gpl and --enable-$1 is not specified."; }
3826 }
3827
3828 die_license_disabled gpl frei0r
3829 die_license_disabled gpl libcdio
3830 die_license_disabled gpl libutvideo
3831 die_license_disabled gpl libvidstab
3832 die_license_disabled gpl libx264
3833 die_license_disabled gpl libxavs
3834 die_license_disabled gpl libxvid
3835 die_license_disabled gpl libzvbi
3836 die_license_disabled gpl x11grab
3837
3838 die_license_disabled nonfree libaacplus
3839 die_license_disabled nonfree libfaac
3840 enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
3841 enabled gpl && die_license_disabled_gpl nonfree openssl
3842
3843 die_license_disabled version3 libopencore_amrnb
3844 die_license_disabled version3 libopencore_amrwb
3845 die_license_disabled version3 libvo_aacenc
3846 die_license_disabled version3 libvo_amrwbenc
3847
3848 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3849
3850 disabled optimizations || check_cflags -fomit-frame-pointer
3851
3852 enable_weak_pic() {
3853     disabled pic && return
3854     enable pic
3855     add_cppflags -DPIC
3856     case "$target_os" in
3857     mingw*|cygwin*)
3858         ;;
3859     *)
3860         add_cflags -fPIC
3861         ;;
3862     esac
3863     add_asflags  -fPIC
3864 }
3865
3866 enabled pic && enable_weak_pic
3867
3868 check_cc <<EOF || die "Symbol mangling check failed."
3869 int ff_extern;
3870 EOF
3871 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
3872 extern_prefix=${sym%%ff_extern*}
3873
3874 check_cc <<EOF && enable_weak inline_asm
3875 void foo(void) { __asm__ volatile ("" ::); }
3876 EOF
3877
3878 _restrict=
3879 for restrict_keyword in restrict __restrict__ __restrict; do
3880     check_cc <<EOF && _restrict=$restrict_keyword && break
3881 void foo(char * $restrict_keyword p);
3882 EOF
3883 done
3884
3885 check_cc <<EOF && enable pragma_deprecated
3886 void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
3887 EOF
3888
3889 check_cc <<EOF && enable attribute_packed
3890 struct { int x; } __attribute__((packed)) x;
3891 EOF
3892
3893 check_cc <<EOF && enable attribute_may_alias
3894 union { int x; } __attribute__((may_alias)) x;
3895 EOF
3896
3897 check_cc <<EOF || die "endian test failed"
3898 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
3899 EOF
3900 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
3901
3902 check_inline_asm inline_asm_labels '"1:\n"'
3903
3904 if enabled alpha; then
3905
3906     check_cflags -mieee
3907
3908 elif enabled arm; then
3909
3910     check_cpp_condition stddef.h "defined __thumb__" && check_cc <<EOF && enable_weak thumb
3911 float func(float a, float b){ return a+b; }
3912 EOF
3913
3914     enabled thumb && check_cflags -mthumb || check_cflags -marm
3915     nogas=die
3916
3917     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
3918         enable vfp_args
3919     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
3920         case "${cross_prefix:-$cc}" in
3921             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
3922             *) check_ld "cc" <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
3923 __asm__ (".eabi_attribute 28, 1");
3924 int main(void) { return 0; }
3925 EOF
3926         esac
3927         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
3928     fi
3929
3930     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
3931     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
3932     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
3933     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
3934     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
3935     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
3936
3937     [ $target_os = linux ] ||
3938         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
3939             $ARCH_EXT_LIST_ARM
3940
3941     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
3942     check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
3943
3944     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
3945
3946 elif enabled mips; then
3947
3948     check_inline_asm loongson '"dmult.g $1, $2, $3"'
3949     enabled mips32r2  && add_cflags "-mips32r2" && add_asflags "-mips32r2" &&
3950      check_inline_asm mips32r2  '"rotr $t0, $t1, 1"'
3951     enabled mipsdspr1 && add_cflags "-mdsp" && add_asflags "-mdsp" &&
3952      check_inline_asm mipsdspr1 '"addu.qb $t0, $t1, $t2"'
3953     enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" &&
3954      check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"'
3955     enabled mipsfpu   && add_cflags "-mhard-float" && add_asflags "-mhard-float" &&
3956      check_inline_asm mipsfpu   '"madd.d $f0, $f2, $f4, $f6"'
3957
3958 elif enabled parisc; then
3959
3960     if enabled gcc; then
3961         case $($cc -dumpversion) in
3962             4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
3963         esac
3964     fi
3965
3966 elif enabled ppc; then
3967
3968     enable local_aligned_8 local_aligned_16
3969
3970     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
3971     check_inline_asm ibm_asm   '"add 0, 0, 0"'
3972     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
3973     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
3974
3975     # AltiVec flags: The FSF version of GCC differs from the Apple version
3976     if enabled altivec; then
3977         if ! enabled_any pic ppc64; then
3978             nogas=warn
3979         fi
3980         check_cflags -maltivec -mabi=altivec &&
3981         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
3982         check_cflags -faltivec
3983
3984         # check if our compiler supports Motorola AltiVec C API
3985         check_cc <<EOF || disable altivec
3986 $inc_altivec_h
3987 int main(void) {
3988     vector signed int v1 = (vector signed int) { 0 };
3989     vector signed int v2 = (vector signed int) { 1 };
3990     v1 = vec_add(v1, v2);
3991     return 0;
3992 }
3993 EOF
3994
3995         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
3996     fi
3997
3998 elif enabled sparc; then
3999
4000     enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
4001
4002 elif enabled x86; then
4003
4004     check_builtin rdtsc    intrin.h   "__rdtsc()"
4005     check_builtin mm_empty mmintrin.h "_mm_empty()"
4006
4007     enable local_aligned_8 local_aligned_16
4008
4009     # check whether EBP is available on x86
4010     # As 'i' is stored on the stack, this program will crash
4011     # if the base pointer is used to access it because the
4012     # base pointer is cleared in the inline assembly code.
4013     check_exec_crash <<EOF && enable ebp_available
4014 volatile int i=0;
4015 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
4016 return i;
4017 EOF
4018
4019     # check whether EBX is available on x86
4020     check_inline_asm ebx_available '""::"b"(0)' &&
4021         check_inline_asm ebx_available '"":::"%ebx"'
4022
4023     # check whether xmm clobbers are supported
4024     check_inline_asm xmm_clobbers '"":::"%xmm0"'
4025
4026     # check whether binutils is new enough to compile SSSE3/MMXEXT
4027     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
4028     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
4029
4030     if ! disabled_any asm mmx yasm; then
4031         if check_cmd $yasmexe --version; then
4032             enabled x86_64 && yasm_extra="-m amd64"
4033             yasm_debug="-g dwarf2"
4034         elif check_cmd nasm -v; then
4035             yasmexe=nasm
4036             yasm_debug="-g -F dwarf"
4037             enabled x86_64 && test "$objformat" = elf && objformat=elf64
4038         fi
4039
4040         YASMFLAGS="-f $objformat $yasm_extra"
4041         enabled pic               && append YASMFLAGS "-DPIC"
4042         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
4043         case "$objformat" in
4044             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
4045         esac
4046
4047         check_yasm "movbe ecx, [5]" && enable yasm ||
4048             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
4049         check_yasm "vextractf128 xmm0, ymm0, 0"      || disable avx_external avresample
4050         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
4051         check_yasm "CPU amdnop" && enable cpunop
4052     fi
4053
4054     case "$cpu" in
4055         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
4056             disable fast_clz
4057         ;;
4058     esac
4059
4060 fi
4061
4062 if enabled asm; then
4063     as=${gas:=$as}
4064     check_as <<EOF && enable gnu_as || \
4065         $nogas "GNU assembler not found, install gas-preprocessor"
4066 .macro m n
4067 \n: .int 0
4068 .endm
4069 m x
4070 EOF
4071 fi
4072
4073 check_ldflags -Wl,--as-needed
4074
4075 if check_func dlopen; then
4076     ldl=
4077 elif check_func dlopen -ldl; then
4078     ldl=-ldl
4079 fi
4080
4081 if ! disabled network; then
4082     check_type "sys/types.h sys/socket.h" socklen_t
4083     check_type netdb.h "struct addrinfo"
4084     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
4085     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
4086     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
4087     check_type netinet/in.h "struct sockaddr_in6"
4088     check_type poll.h "struct pollfd"
4089     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
4090     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
4091     check_type netinet/sctp.h "struct sctp_event_subscribe"
4092     check_func getaddrinfo $network_extralibs
4093     check_func getservbyport $network_extralibs
4094     # Prefer arpa/inet.h over winsock2
4095     if check_header arpa/inet.h ; then
4096         check_func closesocket
4097     elif check_header winsock2.h ; then
4098         check_func_headers winsock2.h closesocket -lws2 &&
4099             network_extralibs="-lws2" ||
4100         { check_func_headers winsock2.h closesocket -lws2_32 &&
4101             network_extralibs="-lws2_32"; }
4102         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
4103         check_type ws2tcpip.h socklen_t
4104         check_type ws2tcpip.h "struct addrinfo"
4105         check_type ws2tcpip.h "struct group_source_req"
4106         check_type ws2tcpip.h "struct ip_mreq_source"
4107         check_type ws2tcpip.h "struct ipv6_mreq"
4108         check_type winsock2.h "struct pollfd"
4109         check_type ws2tcpip.h "struct sockaddr_in6"
4110         check_type ws2tcpip.h "struct sockaddr_storage"
4111         check_struct winsock2.h "struct sockaddr" sa_len
4112     else
4113         disable network
4114     fi
4115 fi
4116
4117 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
4118 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
4119
4120 check_func  access
4121 check_func  clock_gettime || { check_func clock_gettime -lrt && add_extralibs -lrt; }
4122 check_func  fcntl
4123 check_func  fork
4124 check_func_headers stdlib.h getenv
4125 check_func  gethrtime
4126 check_func  getopt
4127 check_func  getrusage
4128 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
4129 check_func  gettimeofday
4130 check_func  inet_aton $network_extralibs
4131 check_func  isatty
4132 check_func  localtime_r
4133 check_func  ${malloc_prefix}memalign            && enable memalign
4134 check_func  mkstemp
4135 check_func  mmap
4136 check_func  mprotect
4137 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
4138 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
4139 check_func  setrlimit
4140 check_struct "sys/stat.h" "struct stat" st_mtim.tv_nsec -D_BSD_SOURCE
4141 check_func  strerror_r
4142 check_func  sched_getaffinity
4143 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
4144 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
4145 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
4146 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
4147 check_builtin sarestart signal.h "SA_RESTART"
4148 check_func  sysconf
4149 check_func  sysctl
4150 check_func  usleep
4151 check_func_headers conio.h kbhit
4152 check_func_headers windows.h PeekNamedPipe
4153 check_func_headers io.h setmode
4154 check_func_headers lzo/lzo1x.h lzo1x_999_compress
4155 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
4156 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
4157 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
4158 check_func_headers windows.h GetProcessAffinityMask
4159 check_func_headers windows.h GetProcessTimes
4160 check_func_headers windows.h GetSystemTimeAsFileTime
4161 check_func_headers windows.h MapViewOfFile
4162 check_func_headers windows.h SetConsoleTextAttribute
4163 check_func_headers windows.h Sleep
4164 check_func_headers windows.h VirtualAlloc
4165 check_func_headers glob.h glob
4166 check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
4167
4168 check_header cl/cl.h
4169 check_header direct.h
4170 check_header dlfcn.h
4171 check_header dxva.h
4172 check_header dxva2api.h -D_WIN32_WINNT=0x0600
4173 check_header io.h
4174 check_header libcrystalhd/libcrystalhd_if.h
4175 check_header malloc.h
4176 check_header poll.h
4177 check_header sys/mman.h
4178 check_header sys/param.h
4179 check_header sys/resource.h
4180 check_header sys/select.h
4181 check_header sys/time.h
4182 check_header sys/un.h
4183 check_header termios.h
4184 check_header unistd.h
4185 check_header vdpau/vdpau.h
4186 check_header vdpau/vdpau_x11.h
4187 check_header VideoDecodeAcceleration/VDADecoder.h
4188 check_header windows.h
4189 check_header X11/extensions/XvMClib.h
4190 check_header asm/types.h
4191
4192 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
4193 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
4194
4195 if ! disabled w32threads && ! enabled pthreads; then
4196     check_func_headers "windows.h process.h" _beginthreadex && enable w32threads
4197 fi
4198
4199 # check for some common methods of building with pthread support
4200 # do this before the optional library checks as some of them require pthreads
4201 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
4202     enable pthreads
4203     if check_func pthread_create; then
4204         :
4205     elif check_func pthread_create -pthread; then
4206         add_cflags -pthread
4207         add_extralibs -pthread
4208     elif check_func pthread_create -pthreads; then
4209         add_cflags -pthreads
4210         add_extralibs -pthreads
4211     elif check_func pthread_create -lpthreadGC2; then
4212         add_extralibs -lpthreadGC2
4213     elif ! check_lib pthread.h pthread_create -lpthread; then
4214         disable pthreads
4215     fi
4216 fi
4217
4218 for thread in $THREADS_LIST; do
4219     if enabled $thread; then
4220         test -n "$thread_type" &&
4221             die "ERROR: Only one thread type must be selected." ||
4222             thread_type="$thread"
4223     fi
4224 done
4225
4226 if enabled pthreads; then
4227   check_func pthread_cancel
4228 fi
4229
4230 enabled sync_val_compare_and_swap && enable atomics_gcc
4231 enabled_all atomic_cas_ptr machine_rw_barrier && enable atomics_suncc
4232 enabled MemoryBarrier && enable atomics_win32
4233
4234 check_lib math.h sin -lm && LIBM="-lm"
4235 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
4236
4237 atan2f_args=2
4238 ldexpf_args=2
4239 powf_args=2
4240
4241 for func in $MATH_FUNCS; do
4242     eval check_mathfunc $func \${${func}_args:-1}
4243 done
4244
4245 # these are off by default, so fail if requested and not available
4246 enabled avisynth          && { { check_lib2 "windows.h" LoadLibrary; } ||
4247                                { check_lib2 "dlfcn.h" dlopen -ldl; } ||
4248                                die "ERROR: LoadLibrary/dlopen not found for avisynth"; }
4249 enabled fontconfig        && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit
4250 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
4251 enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
4252 enabled ladspa            && { check_header ladspa.h || die "ERROR: ladspa.h header not found"; }
4253 enabled libiec61883       && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
4254 enabled libaacplus        && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
4255 enabled libass            && require_pkg_config libass ass/ass.h ass_library_init
4256 enabled libbluray         && require libbluray libbluray/bluray.h bd_open -lbluray
4257 enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
4258                              { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
4259                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
4260 enabled libcaca           && require_pkg_config caca caca.h caca_create_canvas
4261 enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
4262 enabled libfdk_aac        && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
4263 flite_libs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
4264 enabled libflite          && require2 libflite "flite/flite.h" flite_init $flite_libs
4265 enabled libfreetype       && require_libfreetype
4266 enabled libgme            && require  libgme gme/gme.h gme_new_emu -lgme -lstdc++
4267 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
4268                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
4269                                done || die "ERROR: libgsm not found"; }
4270 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
4271 enabled libmodplug        && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
4272 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
4273 enabled libnut            && require libnut libnut.h nut_demuxer_init -lnut
4274 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
4275 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
4276 enabled libopencv         && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
4277 enabled libopenjpeg       && { check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg ||
4278                                check_lib openjpeg.h opj_version -lopenjpeg ||
4279                                die "ERROR: libopenjpeg not found"; }
4280 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
4281 enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
4282 enabled libquvi           && require_pkg_config libquvi quvi/quvi.h quvi_init
4283 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
4284 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
4285 enabled libshine          && require_pkg_config shine shine/layer3.h shine_encode_buffer
4286 enabled libsoxr           && require libsoxr soxr.h soxr_create -lsoxr
4287 enabled libssh            && require_pkg_config libssh libssh/sftp.h sftp_init
4288 enabled libspeex          && require libspeex speex/speex.h speex_decoder_init -lspeex
4289 enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
4290     media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
4291     media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static
4292 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
4293 enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
4294                              { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
4295                                die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
4296 enabled libutvideo        && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
4297 enabled libv4l2           && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl
4298 enabled libvidstab        && require_pkg_config vidstab vid.stab/libvidstab.h vsMotionDetectInit
4299 enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
4300 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
4301 enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
4302 enabled libvpx            && {
4303     enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
4304                                     die "ERROR: libvpx decoder version must be >=0.9.1"; }
4305     enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx ||
4306                                     die "ERROR: libvpx encoder version must be >=0.9.7"; }
4307     enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
4308     enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
4309 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
4310 enabled libx264           && require libx264 x264.h x264_encoder_encode -lx264 &&
4311                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
4312                                die "ERROR: libx264 must be installed and version must be >= 0.118."; }
4313 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
4314 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
4315 enabled libzmq            && require_pkg_config libzmq zmq.h zmq_ctx_new
4316 enabled libzvbi           && require libzvbi libzvbi.h vbi_decoder_new -lzvbi
4317 enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
4318                                check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
4319                                die "ERROR: openal not found"; } &&
4320                              { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
4321                                die "ERROR: openal must be installed and version must be 1.1 or compatible"; }
4322 enabled opencl            && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
4323                                check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
4324                                die "ERROR: opencl not found"; } &&
4325                              { ! enabled_any w32threads os2threads ||
4326                                die "opencl currently needs --enable-pthreads or --disable-w32threads"; } &&
4327                              { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
4328                                check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
4329                                die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
4330 enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
4331                                check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
4332                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
4333                                die "ERROR: openssl not found"; }
4334
4335 if enabled gnutls; then
4336     { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
4337     { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
4338 fi
4339
4340 # libdc1394 check
4341 if enabled libdc1394; then
4342     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
4343         enable libdc1394_2; } ||
4344     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
4345         enable libdc1394_1; } ||
4346     die "ERROR: No version of libdc1394 found "
4347 fi
4348
4349 SDL_CONFIG="${cross_prefix}sdl-config"
4350 if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
4351     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
4352     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
4353     enable sdl
4354 else
4355   if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
4356     sdl_cflags=$("${SDL_CONFIG}" --cflags)
4357     sdl_libs=$("${SDL_CONFIG}" --libs)
4358     check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
4359     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
4360     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
4361     enable sdl
4362   fi
4363 fi
4364 enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
4365
4366 texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
4367 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
4368 perl --version > /dev/null 2>&1 && enable perl || disable perl
4369 pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
4370 rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
4371
4372 check_header linux/fb.h
4373 check_header linux/videodev.h
4374 check_header linux/videodev2.h
4375 check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
4376
4377 check_header sys/videoio.h
4378
4379 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
4380 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
4381 # w32api 3.12 had it defined wrong
4382 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
4383
4384 check_type "dshow.h" IBaseFilter
4385
4386 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
4387 { check_header dev/bktr/ioctl_meteor.h &&
4388   check_header dev/bktr/ioctl_bt848.h; } ||
4389 { check_header machine/ioctl_meteor.h &&
4390   check_header machine/ioctl_bt848.h; } ||
4391 { check_header dev/video/meteor/ioctl_meteor.h &&
4392   check_header dev/video/bktr/ioctl_bt848.h; } ||
4393 check_header dev/ic/bt8xx.h
4394
4395 check_header sndio.h
4396 if check_struct sys/soundcard.h audio_buf_info bytes; then
4397     enable_safe sys/soundcard.h
4398 else
4399     check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h
4400     #include <sys/soundcard.h>
4401     audio_buf_info abc;
4402 EOF
4403 fi
4404 check_header soundcard.h
4405
4406 enabled_any alsa_indev alsa_outdev &&
4407     check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
4408
4409 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func sem_timedwait &&
4410     check_func jack_port_get_latency_range -ljack
4411
4412 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
4413
4414 if enabled libcdio; then
4415     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4416     check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4417     die "ERROR: libcdio-paranoia not found"
4418 fi
4419
4420 enabled x11grab                                           &&
4421 require X11 X11/Xlib.h XOpenDisplay -lX11                 &&
4422 require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
4423 require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
4424
4425 enabled vaapi &&
4426     check_lib va/va.h vaInitialize -lva ||
4427     disable vaapi
4428
4429 enabled vdpau &&
4430     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
4431     disable vdpau
4432
4433 # Funny iconv installations are not unusual, so check it after all flags have been set
4434 disabled iconv || check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || disable iconv
4435
4436 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
4437
4438 # add some useful compiler flags if supported
4439 check_cflags -Wdeclaration-after-statement
4440 check_cflags -Wall
4441 check_cflags -Wno-parentheses
4442 check_cflags -Wno-switch
4443 check_cflags -Wno-format-zero-length
4444 check_cflags -Wdisabled-optimization
4445 check_cflags -Wpointer-arith
4446 check_cflags -Wredundant-decls
4447 check_cflags -Wno-pointer-sign
4448 check_cflags -Wwrite-strings
4449 check_cflags -Wtype-limits
4450 check_cflags -Wundef
4451 check_cflags -Wmissing-prototypes
4452 check_cflags -Wno-pointer-to-int-cast
4453 check_cflags -Wstrict-prototypes
4454 enabled extra_warnings && check_cflags -Winline
4455
4456 # add some linker flags
4457 check_ldflags -Wl,--warn-common
4458 check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
4459 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
4460
4461 enabled xmm_clobber_test &&
4462     check_ldflags -Wl,--wrap,avcodec_open2              \
4463                   -Wl,--wrap,avcodec_decode_audio4      \
4464                   -Wl,--wrap,avcodec_decode_video2      \
4465                   -Wl,--wrap,avcodec_decode_subtitle2   \
4466                   -Wl,--wrap,avcodec_encode_audio2      \
4467                   -Wl,--wrap,avcodec_encode_video       \
4468                   -Wl,--wrap,avcodec_encode_video2      \
4469                   -Wl,--wrap,avcodec_encode_subtitle    \
4470                   -Wl,--wrap,sws_scale ||
4471     disable xmm_clobber_test
4472
4473 echo "X{};" > $TMPV
4474 if test_ldflags -Wl,--version-script,$TMPV; then
4475     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
4476     check_cc <<EOF && enable symver_asm_label
4477 void ff_foo(void) __asm__ ("av_foo@VERSION");
4478 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
4479 EOF
4480     check_cc <<EOF && enable symver_gnu_asm
4481 __asm__(".symver ff_foo,av_foo@VERSION");
4482 void ff_foo(void) {}
4483 EOF
4484 fi
4485
4486 if [ -z "$optflags" ]; then
4487     if enabled small; then
4488         optflags=$cflags_size
4489     elif enabled optimizations; then
4490         optflags=$cflags_speed
4491     else
4492         optflags=$cflags_noopt
4493     fi
4494 fi
4495
4496 check_optflags(){
4497     check_cflags "$@"
4498     enabled lto && check_ldflags "$@"
4499 }
4500
4501
4502 if enabled lto; then
4503     test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
4504     check_cflags  -flto
4505     check_ldflags -flto $cpuflags
4506 fi
4507
4508 check_optflags $optflags
4509 check_optflags -fno-math-errno
4510 check_optflags -fno-signed-zeros
4511
4512 enabled ftrapv && check_cflags -ftrapv
4513
4514 check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
4515 int x;
4516 EOF
4517
4518
4519 if enabled icc; then
4520     # Just warnings, no remarks
4521     check_cflags -w1
4522     # -wd: Disable following warnings
4523     # 144, 167, 556: -Wno-pointer-sign
4524     # 188: enumerated type mixed with another type
4525     # 1292: attribute "foo" ignored
4526     # 1419: external declaration in primary source file
4527     # 10006: ignoring unknown option -fno-signed-zeros
4528     # 10148: ignoring unknown option -Wno-parentheses
4529     # 10156: ignoring option '-W'; no argument required
4530     check_cflags -wd144,167,188,556,1292,1419,10006,10148,10156
4531     # 11030: Warning unknown option --as-needed
4532     # 10156: ignoring option '-export'; no argument required
4533     check_ldflags -wd10156,11030
4534     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
4535     enable ebp_available
4536     if enabled x86_32; then
4537         icc_version=$($cc -dumpversion)
4538         test ${icc_version%%.*} -ge 11 &&
4539             check_cflags -falign-stack=maintain-16-byte ||
4540             disable aligned_stack
4541     fi
4542 elif enabled ccc; then
4543     # disable some annoying warnings
4544     add_cflags -msg_disable bitnotint
4545     add_cflags -msg_disable mixfuncvoid
4546     add_cflags -msg_disable nonstandcast
4547     add_cflags -msg_disable unsupieee
4548 elif enabled gcc; then
4549     check_optflags -fno-tree-vectorize
4550     check_cflags -Werror=implicit-function-declaration
4551     check_cflags -Werror=missing-prototypes
4552     check_cflags -Werror=return-type
4553     check_cflags -Werror=vla
4554 elif enabled llvm_gcc; then
4555     check_cflags -mllvm -stack-alignment=16
4556 elif enabled clang; then
4557     check_cflags -mllvm -stack-alignment=16
4558     check_cflags -Qunused-arguments
4559     check_cflags -Werror=implicit-function-declaration
4560     check_cflags -Werror=missing-prototypes
4561     check_cflags -Werror=return-type
4562 elif enabled cparser; then
4563     add_cflags -Wno-missing-variable-declarations
4564     add_cflags -Wno-empty-statement
4565 elif enabled armcc; then
4566     # 2523: use of inline assembler is deprecated
4567     add_cflags -W${armcc_opt},--diag_suppress=2523
4568     add_cflags -W${armcc_opt},--diag_suppress=1207
4569     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
4570     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
4571     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
4572     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
4573 elif enabled tms470; then
4574     add_cflags -pds=824 -pds=837
4575 elif enabled pathscale; then
4576     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
4577 elif enabled_any msvc icl; then
4578     enabled x86_32 && disable aligned_stack
4579     enabled_all x86_32 debug && add_cflags -Oy-
4580     enabled debug && add_ldflags -debug
4581     enable pragma_deprecated
4582     if enabled icl; then
4583         # -Qansi-alias is basically -fstrict-aliasing, but does not work
4584         # (correctly) on icl 13.x.
4585         check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
4586             add_cflags -Qansi-alias
4587         # icl will pass the inline asm tests but inline asm is currently
4588         # not supported (build will fail)
4589         disabled inline_asm || warn "inline asm disabled due to issues with it in ICL"
4590         disable inline_asm
4591     fi
4592 fi
4593
4594 case $target_os in
4595     osf1)
4596         enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
4597     ;;
4598     plan9)
4599         add_cppflags -Dmain=plan9_main
4600     ;;
4601 esac
4602
4603 enable frame_thread_encoder
4604 enabled_any $THREADS_LIST      && enable threads
4605 enabled_any $ATOMICS_LIST      && enable atomics_native
4606
4607 enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86"
4608
4609 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
4610
4611 check_deps $CONFIG_LIST       \
4612            $CONFIG_EXTRA      \
4613            $HAVE_LIST         \
4614            $ALL_COMPONENTS    \
4615
4616
4617 if test $target_os = "haiku"; then
4618     disable memalign
4619     disable posix_memalign
4620 fi
4621
4622 ! enabled_any memalign posix_memalign aligned_malloc &&
4623     enabled_any $need_memalign && enable memalign_hack
4624
4625 # add_dep lib dep
4626 # -> enable ${lib}_deps_${dep}
4627 # -> add $dep to ${lib}_deps only once
4628 add_dep() {
4629     lib=$1
4630     dep=$2
4631     enabled "${lib}_deps_${dep}" && return 0
4632     enable  "${lib}_deps_${dep}"
4633     prepend "${lib}_deps" $dep
4634 }
4635
4636 # merge deps lib components
4637 # merge all ${component}_deps into ${lib}_deps and ${lib}_deps_*
4638 merge_deps() {
4639     lib=$1
4640     shift
4641     for comp in $*; do
4642         enabled $comp || continue
4643         eval "dep=\"\$${comp}_deps\""
4644         for d in $dep; do
4645             add_dep $lib $d
4646         done
4647     done
4648 }
4649
4650 merge_deps libavfilter $FILTER_LIST
4651
4652 echo "install prefix            $prefix"
4653 echo "source path               $source_path"
4654 echo "C compiler                $cc"
4655 echo "ARCH                      $arch ($cpu)"
4656 if test "$build_suffix" != ""; then
4657     echo "build suffix              $build_suffix"
4658 fi
4659 if test "$progs_suffix" != ""; then
4660     echo "progs suffix              $progs_suffix"
4661 fi
4662 if test "$extra_version" != ""; then
4663     echo "version string suffix     $extra_version"
4664 fi
4665 echo "big-endian                ${bigendian-no}"
4666 echo "runtime cpu detection     ${runtime_cpudetect-no}"
4667 if enabled x86; then
4668     echo "${yasmexe}                      ${yasm-no}"
4669     echo "MMX enabled               ${mmx-no}"
4670     echo "MMXEXT enabled            ${mmxext-no}"
4671     echo "3DNow! enabled            ${amd3dnow-no}"
4672     echo "3DNow! extended enabled   ${amd3dnowext-no}"
4673     echo "SSE enabled               ${sse-no}"
4674     echo "SSSE3 enabled             ${ssse3-no}"
4675     echo "AVX enabled               ${avx-no}"
4676     echo "FMA4 enabled              ${fma4-no}"
4677     echo "i686 features enabled     ${i686-no}"
4678     echo "CMOV is fast              ${fast_cmov-no}"
4679     echo "EBX available             ${ebx_available-no}"
4680     echo "EBP available             ${ebp_available-no}"
4681 fi
4682 if enabled arm; then
4683     echo "ARMv5TE enabled           ${armv5te-no}"
4684     echo "ARMv6 enabled             ${armv6-no}"
4685     echo "ARMv6T2 enabled           ${armv6t2-no}"
4686     echo "VFP enabled               ${vfp-no}"
4687     echo "NEON enabled              ${neon-no}"
4688     echo "THUMB enabled             ${thumb-no}"
4689 fi
4690 if enabled mips; then
4691     echo "MIPS FPU enabled          ${mipsfpu-no}"
4692     echo "MIPS32R2 enabled          ${mips32r2-no}"
4693     echo "MIPS DSP R1 enabled       ${mipsdspr1-no}"
4694     echo "MIPS DSP R2 enabled       ${mipsdspr2-no}"
4695 fi
4696 if enabled ppc; then
4697     echo "AltiVec enabled           ${altivec-no}"
4698     echo "PPC 4xx optimizations     ${ppc4xx-no}"
4699     echo "dcbzl available           ${dcbzl-no}"
4700 fi
4701 if enabled sparc; then
4702     echo "VIS enabled               ${vis-no}"
4703 fi
4704 echo "debug symbols             ${debug-no}"
4705 echo "strip symbols             ${stripping-no}"
4706 echo "optimize for size         ${small-no}"
4707 echo "optimizations             ${optimizations-no}"
4708 echo "static                    ${static-no}"
4709 echo "shared                    ${shared-no}"
4710 echo "postprocessing support    ${postproc-no}"
4711 echo "new filter support        ${avfilter-no}"
4712 echo "network support           ${network-no}"
4713 echo "threading support         ${thread_type-no}"
4714 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
4715 echo "SDL support               ${sdl-no}"
4716 echo "opencl enabled            ${opencl-no}"
4717 echo "libzvbi enabled           ${libzvbi-no}"
4718 echo "texi2html enabled         ${texi2html-no}"
4719 echo "perl enabled              ${perl-no}"
4720 echo "pod2man enabled           ${pod2man-no}"
4721 echo "makeinfo enabled          ${makeinfo-no}"
4722 test -n "$random_seed" &&
4723     echo "random seed               ${random_seed}"
4724 echo
4725
4726 echo "External libraries:"
4727 print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
4728 echo
4729
4730 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
4731     echo "Enabled ${type}s:"
4732     eval list=\$$(toupper $type)_LIST
4733     print_enabled '_*' $list | print_3_columns
4734     echo
4735 done
4736
4737 license="LGPL version 2.1 or later"
4738 if enabled nonfree; then
4739     license="nonfree and unredistributable"
4740 elif enabled gplv3; then
4741     license="GPL version 3 or later"
4742 elif enabled lgplv3; then
4743     license="LGPL version 3 or later"
4744 elif enabled gpl; then
4745     license="GPL version 2 or later"
4746 fi
4747
4748 echo "License: $license"
4749
4750 echo "Creating config.mak, config.h, and doc/config.texi..."
4751
4752 test -e Makefile || $ln_s "$source_path/Makefile" .
4753
4754 enabled stripping || strip="echo skipping strip"
4755
4756 config_files="$TMPH config.mak doc/config.texi"
4757
4758 cat > config.mak <<EOF
4759 # Automatically generated by configure - do not modify!
4760 ifndef FFMPEG_CONFIG_MAK
4761 FFMPEG_CONFIG_MAK=1
4762 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
4763 prefix=$prefix
4764 LIBDIR=\$(DESTDIR)$libdir
4765 SHLIBDIR=\$(DESTDIR)$shlibdir
4766 INCDIR=\$(DESTDIR)$incdir
4767 BINDIR=\$(DESTDIR)$bindir
4768 DATADIR=\$(DESTDIR)$datadir
4769 DOCDIR=\$(DESTDIR)$docdir
4770 MANDIR=\$(DESTDIR)$mandir
4771 SRC_PATH=$source_path
4772 ifndef MAIN_MAKEFILE
4773 SRC_PATH:=\$(SRC_PATH:.%=..%)
4774 endif
4775 CC_IDENT=$cc_ident
4776 ARCH=$arch
4777 CC=$cc
4778 CXX=$cxx
4779 AS=$as
4780 LD=$ld
4781 DEPCC=$dep_cc
4782 DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
4783 DEPAS=$as
4784 DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
4785 YASM=$yasmexe
4786 DEPYASM=$yasmexe
4787 AR=$ar
4788 ARFLAGS=$arflags
4789 AR_O=$ar_o
4790 RANLIB=$ranlib
4791 STRIP=$strip
4792 CP=cp -p
4793 LN_S=$ln_s
4794 CPPFLAGS=$CPPFLAGS
4795 CFLAGS=$CFLAGS
4796 CXXFLAGS=$CXXFLAGS
4797 ASFLAGS=$ASFLAGS
4798 AS_C=$AS_C
4799 AS_O=$AS_O
4800 CC_C=$CC_C
4801 CC_E=$CC_E
4802 CC_O=$CC_O
4803 CXX_C=$CXX_C
4804 CXX_O=$CXX_O
4805 LD_O=$LD_O
4806 LD_LIB=$LD_LIB
4807 LD_PATH=$LD_PATH
4808 DLLTOOL=$dlltool
4809 LDFLAGS=$LDFLAGS
4810 SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
4811 YASMFLAGS=$YASMFLAGS
4812 BUILDSUF=$build_suffix
4813 PROGSSUF=$progs_suffix
4814 FULLNAME=$FULLNAME
4815 LIBPREF=$LIBPREF
4816 LIBSUF=$LIBSUF
4817 LIBNAME=$LIBN