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