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