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