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