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