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