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