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