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