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