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