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