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