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