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