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