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