lavc: Add filter_units bitstream filter
[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_select="cbs_h264"
2924 h264_redundant_pps_bsf_select="cbs_h264"
2925 hevc_metadata_bsf_select="cbs_h265"
2926 mjpeg2jpeg_bsf_select="jpegtables"
2927 mpeg2_metadata_bsf_select="cbs_mpeg2"
2928 trace_headers_bsf_select="cbs"
2929
2930 # external libraries
2931 aac_at_decoder_deps="audiotoolbox"
2932 aac_at_decoder_select="aac_adtstoasc_bsf"
2933 ac3_at_decoder_deps="audiotoolbox"
2934 ac3_at_decoder_select="ac3_parser"
2935 adpcm_ima_qt_at_decoder_deps="audiotoolbox"
2936 alac_at_decoder_deps="audiotoolbox"
2937 amr_nb_at_decoder_deps="audiotoolbox"
2938 avisynth_deps_any="libdl LoadLibrary"
2939 avisynth_demuxer_deps="avisynth"
2940 avisynth_demuxer_select="riffdec"
2941 eac3_at_decoder_deps="audiotoolbox"
2942 eac3_at_decoder_select="ac3_parser"
2943 gsm_ms_at_decoder_deps="audiotoolbox"
2944 ilbc_at_decoder_deps="audiotoolbox"
2945 mp1_at_decoder_deps="audiotoolbox"
2946 mp2_at_decoder_deps="audiotoolbox"
2947 mp3_at_decoder_deps="audiotoolbox"
2948 mp1_at_decoder_select="mpegaudioheader"
2949 mp2_at_decoder_select="mpegaudioheader"
2950 mp3_at_decoder_select="mpegaudioheader"
2951 pcm_alaw_at_decoder_deps="audiotoolbox"
2952 pcm_mulaw_at_decoder_deps="audiotoolbox"
2953 qdmc_at_decoder_deps="audiotoolbox"
2954 qdm2_at_decoder_deps="audiotoolbox"
2955 aac_at_encoder_deps="audiotoolbox"
2956 aac_at_encoder_select="audio_frame_queue"
2957 alac_at_encoder_deps="audiotoolbox"
2958 alac_at_encoder_select="audio_frame_queue"
2959 ilbc_at_encoder_deps="audiotoolbox"
2960 ilbc_at_encoder_select="audio_frame_queue"
2961 pcm_alaw_at_encoder_deps="audiotoolbox"
2962 pcm_alaw_at_encoder_select="audio_frame_queue"
2963 pcm_mulaw_at_encoder_deps="audiotoolbox"
2964 pcm_mulaw_at_encoder_select="audio_frame_queue"
2965 chromaprint_muxer_deps="chromaprint"
2966 h264_videotoolbox_encoder_deps="pthreads"
2967 h264_videotoolbox_encoder_select="videotoolbox_encoder"
2968 hevc_videotoolbox_encoder_deps="pthreads"
2969 hevc_videotoolbox_encoder_select="videotoolbox_encoder"
2970 libcelt_decoder_deps="libcelt"
2971 libcodec2_decoder_deps="libcodec2"
2972 libcodec2_encoder_deps="libcodec2"
2973 libfdk_aac_decoder_deps="libfdk_aac"
2974 libfdk_aac_encoder_deps="libfdk_aac"
2975 libfdk_aac_encoder_select="audio_frame_queue"
2976 libgme_demuxer_deps="libgme"
2977 libgsm_decoder_deps="libgsm"
2978 libgsm_encoder_deps="libgsm"
2979 libgsm_ms_decoder_deps="libgsm"
2980 libgsm_ms_encoder_deps="libgsm"
2981 libilbc_decoder_deps="libilbc"
2982 libilbc_encoder_deps="libilbc"
2983 libkvazaar_encoder_deps="libkvazaar"
2984 libmodplug_demuxer_deps="libmodplug"
2985 libmp3lame_encoder_deps="libmp3lame"
2986 libmp3lame_encoder_select="audio_frame_queue mpegaudioheader"
2987 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2988 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2989 libopencore_amrnb_encoder_select="audio_frame_queue"
2990 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2991 libopenh264_decoder_deps="libopenh264"
2992 libopenh264_decoder_select="h264_mp4toannexb_bsf"
2993 libopenh264_encoder_deps="libopenh264"
2994 libopenjpeg_decoder_deps="libopenjpeg"
2995 libopenjpeg_encoder_deps="libopenjpeg"
2996 libopenmpt_demuxer_deps="libopenmpt"
2997 libopus_decoder_deps="libopus"
2998 libopus_encoder_deps="libopus"
2999 libopus_encoder_select="audio_frame_queue"
3000 librsvg_decoder_deps="librsvg"
3001 libshine_encoder_deps="libshine"
3002 libshine_encoder_select="audio_frame_queue"
3003 libspeex_decoder_deps="libspeex"
3004 libspeex_encoder_deps="libspeex"
3005 libspeex_encoder_select="audio_frame_queue"
3006 libtheora_encoder_deps="libtheora"
3007 libtwolame_encoder_deps="libtwolame"
3008 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
3009 libvorbis_decoder_deps="libvorbis"
3010 libvorbis_encoder_deps="libvorbis libvorbisenc"
3011 libvorbis_encoder_select="audio_frame_queue"
3012 libvpx_vp8_decoder_deps="libvpx"
3013 libvpx_vp8_encoder_deps="libvpx"
3014 libvpx_vp9_decoder_deps="libvpx"
3015 libvpx_vp9_encoder_deps="libvpx"
3016 libwavpack_encoder_deps="libwavpack"
3017 libwavpack_encoder_select="audio_frame_queue"
3018 libwebp_encoder_deps="libwebp"
3019 libwebp_anim_encoder_deps="libwebp"
3020 libx262_encoder_deps="libx262"
3021 libx264_encoder_deps="libx264"
3022 libx264rgb_encoder_deps="libx264 x264_csp_bgr"
3023 libx264rgb_encoder_select="libx264_encoder"
3024 libx265_encoder_deps="libx265"
3025 libxavs_encoder_deps="libxavs"
3026 libxvid_encoder_deps="libxvid"
3027 libzvbi_teletext_decoder_deps="libzvbi"
3028 videotoolbox_suggest="coreservices"
3029 videotoolbox_deps="corefoundation coremedia corevideo"
3030 videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames"
3031
3032 # demuxers / muxers
3033 ac3_demuxer_select="ac3_parser"
3034 aiff_muxer_select="iso_media"
3035 asf_demuxer_select="riffdec"
3036 asf_o_demuxer_select="riffdec"
3037 asf_muxer_select="riffenc"
3038 asf_stream_muxer_select="asf_muxer"
3039 avi_demuxer_select="iso_media riffdec exif"
3040 avi_muxer_select="riffenc"
3041 caf_demuxer_select="iso_media riffdec"
3042 caf_muxer_select="iso_media"
3043 dash_muxer_select="mp4_muxer"
3044 dash_demuxer_deps="libxml2"
3045 dirac_demuxer_select="dirac_parser"
3046 dts_demuxer_select="dca_parser"
3047 dtshd_demuxer_select="dca_parser"
3048 dv_demuxer_select="dvprofile"
3049 dv_muxer_select="dvprofile"
3050 dxa_demuxer_select="riffdec"
3051 eac3_demuxer_select="ac3_parser"
3052 f4v_muxer_select="mov_muxer"
3053 fifo_muxer_deps="threads"
3054 flac_demuxer_select="flac_parser"
3055 hds_muxer_select="flv_muxer"
3056 hls_muxer_select="mpegts_muxer"
3057 hls_muxer_suggest="gcrypt openssl"
3058 image2_alias_pix_demuxer_select="image2_demuxer"
3059 image2_brender_pix_demuxer_select="image2_demuxer"
3060 ipod_muxer_select="mov_muxer"
3061 ismv_muxer_select="mov_muxer"
3062 matroska_audio_muxer_select="matroska_muxer"
3063 matroska_demuxer_select="iso_media riffdec"
3064 matroska_demuxer_suggest="bzlib lzo zlib"
3065 matroska_muxer_select="iso_media riffenc"
3066 mmf_muxer_select="riffenc"
3067 mov_demuxer_select="iso_media riffdec"
3068 mov_demuxer_suggest="zlib"
3069 mov_muxer_select="iso_media riffenc rtpenc_chain"
3070 mp3_demuxer_select="mpegaudio_parser"
3071 mp3_muxer_select="mpegaudioheader"
3072 mp4_muxer_select="mov_muxer"
3073 mpegts_demuxer_select="iso_media"
3074 mpegts_muxer_select="adts_muxer latm_muxer"
3075 mpegtsraw_demuxer_select="mpegts_demuxer"
3076 mxf_d10_muxer_select="mxf_muxer"
3077 mxf_opatom_muxer_select="mxf_muxer"
3078 nut_muxer_select="riffenc"
3079 nuv_demuxer_select="riffdec"
3080 oga_muxer_select="ogg_muxer"
3081 ogg_demuxer_select="dirac_parse"
3082 ogv_muxer_select="ogg_muxer"
3083 opus_muxer_select="ogg_muxer"
3084 psp_muxer_select="mov_muxer"
3085 rtp_demuxer_select="sdp_demuxer"
3086 rtp_muxer_select="golomb"
3087 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
3088 rtsp_demuxer_select="http_protocol rtpdec"
3089 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
3090 sap_demuxer_select="sdp_demuxer"
3091 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
3092 sdp_demuxer_select="rtpdec"
3093 smoothstreaming_muxer_select="ismv_muxer"
3094 spdif_demuxer_select="adts_header"
3095 spdif_muxer_select="adts_header"
3096 spx_muxer_select="ogg_muxer"
3097 swf_demuxer_suggest="zlib"
3098 tak_demuxer_select="tak_parser"
3099 tg2_muxer_select="mov_muxer"
3100 tgp_muxer_select="mov_muxer"
3101 vobsub_demuxer_select="mpegps_demuxer"
3102 w64_demuxer_select="wav_demuxer"
3103 w64_muxer_select="wav_muxer"
3104 wav_demuxer_select="riffdec"
3105 wav_muxer_select="riffenc"
3106 webm_muxer_select="iso_media riffenc"
3107 webm_dash_manifest_demuxer_select="matroska_demuxer"
3108 wtv_demuxer_select="mpegts_demuxer riffdec"
3109 wtv_muxer_select="mpegts_muxer riffenc"
3110 xmv_demuxer_select="riffdec"
3111 xwma_demuxer_select="riffdec"
3112
3113 # indevs / outdevs
3114 android_camera_indev_deps="android camera2ndk mediandk pthreads"
3115 android_camera_indev_extralibs="-landroid -lcamera2ndk -lmediandk"
3116 alsa_indev_deps="alsa"
3117 alsa_outdev_deps="alsa"
3118 avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
3119 avfoundation_indev_suggest="coregraphics applicationservices"
3120 avfoundation_indev_extralibs="-framework Foundation"
3121 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
3122 caca_outdev_deps="libcaca"
3123 decklink_deps_any="libdl LoadLibrary"
3124 decklink_indev_deps="decklink threads"
3125 decklink_indev_extralibs="-lstdc++"
3126 decklink_outdev_deps="decklink threads"
3127 decklink_outdev_extralibs="-lstdc++"
3128 libndi_newtek_indev_deps="libndi_newtek"
3129 libndi_newtek_indev_extralibs="-lndi"
3130 libndi_newtek_outdev_deps="libndi_newtek"
3131 libndi_newtek_outdev_extralibs="-lndi"
3132 dshow_indev_deps="IBaseFilter"
3133 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
3134 fbdev_indev_deps="linux_fb_h"
3135 fbdev_outdev_deps="linux_fb_h"
3136 gdigrab_indev_deps="CreateDIBSection"
3137 gdigrab_indev_extralibs="-lgdi32"
3138 gdigrab_indev_select="bmp_decoder"
3139 iec61883_indev_deps="libiec61883"
3140 jack_indev_deps="libjack"
3141 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
3142 kmsgrab_indev_deps="libdrm"
3143 lavfi_indev_deps="avfilter"
3144 libcdio_indev_deps="libcdio"
3145 libdc1394_indev_deps="libdc1394"
3146 openal_indev_deps="openal"
3147 opengl_outdev_deps="opengl"
3148 oss_indev_deps_any="sys_soundcard_h"
3149 oss_outdev_deps_any="sys_soundcard_h"
3150 pulse_indev_deps="libpulse"
3151 pulse_outdev_deps="libpulse"
3152 sdl2_outdev_deps="sdl2"
3153 sndio_indev_deps="sndio"
3154 sndio_outdev_deps="sndio"
3155 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
3156 v4l2_indev_suggest="libv4l2"
3157 v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
3158 v4l2_outdev_suggest="libv4l2"
3159 vfwcap_indev_deps="vfw32 vfwcap_defines"
3160 xcbgrab_indev_deps="libxcb"
3161 xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes"
3162 xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
3163 xv_outdev_extralibs="-lXv -lX11 -lXext"
3164
3165 # protocols
3166 async_protocol_deps="threads"
3167 bluray_protocol_deps="libbluray"
3168 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
3169 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
3170 ffrtmpcrypt_protocol_select="tcp_protocol"
3171 ffrtmphttp_protocol_conflict="librtmp_protocol"
3172 ffrtmphttp_protocol_select="http_protocol"
3173 ftp_protocol_select="tcp_protocol"
3174 gopher_protocol_select="network"
3175 http_protocol_select="tcp_protocol"
3176 http_protocol_suggest="zlib"
3177 httpproxy_protocol_select="tcp_protocol"
3178 httpproxy_protocol_suggest="zlib"
3179 https_protocol_select="tls_protocol"
3180 https_protocol_suggest="zlib"
3181 icecast_protocol_select="http_protocol"
3182 librtmp_protocol_deps="librtmp"
3183 librtmpe_protocol_deps="librtmp"
3184 librtmps_protocol_deps="librtmp"
3185 librtmpt_protocol_deps="librtmp"
3186 librtmpte_protocol_deps="librtmp"
3187 libsmbclient_protocol_deps="libsmbclient gplv3"
3188 libssh_protocol_deps="libssh"
3189 libtls_conflict="openssl gnutls"
3190 mmsh_protocol_select="http_protocol"
3191 mmst_protocol_select="network"
3192 rtmp_protocol_conflict="librtmp_protocol"
3193 rtmp_protocol_select="tcp_protocol"
3194 rtmp_protocol_suggest="zlib"
3195 rtmpe_protocol_select="ffrtmpcrypt_protocol"
3196 rtmpe_protocol_suggest="zlib"
3197 rtmps_protocol_conflict="librtmp_protocol"
3198 rtmps_protocol_select="tls_protocol"
3199 rtmps_protocol_suggest="zlib"
3200 rtmpt_protocol_select="ffrtmphttp_protocol"
3201 rtmpt_protocol_suggest="zlib"
3202 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
3203 rtmpte_protocol_suggest="zlib"
3204 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
3205 rtmpts_protocol_suggest="zlib"
3206 rtp_protocol_select="udp_protocol"
3207 schannel_conflict="openssl gnutls libtls"
3208 sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
3209 sctp_protocol_select="network"
3210 securetransport_conflict="openssl gnutls libtls"
3211 srtp_protocol_select="rtp_protocol srtp"
3212 tcp_protocol_select="network"
3213 tls_protocol_deps_any="gnutls openssl schannel securetransport libtls"
3214 tls_protocol_select="tcp_protocol"
3215 udp_protocol_select="network"
3216 udplite_protocol_select="network"
3217 unix_protocol_deps="sys_un_h"
3218 unix_protocol_select="network"
3219
3220 # filters
3221 afftfilt_filter_deps="avcodec"
3222 afftfilt_filter_select="fft"
3223 afir_filter_deps="avcodec"
3224 afir_filter_select="fft"
3225 amovie_filter_deps="avcodec avformat"
3226 aresample_filter_deps="swresample"
3227 ass_filter_deps="libass"
3228 atempo_filter_deps="avcodec"
3229 atempo_filter_select="rdft"
3230 azmq_filter_deps="libzmq"
3231 blackframe_filter_deps="gpl"
3232 boxblur_filter_deps="gpl"
3233 bs2b_filter_deps="libbs2b"
3234 colormatrix_filter_deps="gpl"
3235 convolve_filter_deps="avcodec"
3236 convolve_filter_select="fft"
3237 coreimage_filter_deps="coreimage appkit"
3238 coreimage_filter_extralibs="-framework OpenGL"
3239 coreimagesrc_filter_deps="coreimage appkit"
3240 coreimagesrc_filter_extralibs="-framework OpenGL"
3241 cover_rect_filter_deps="avcodec avformat gpl"
3242 cropdetect_filter_deps="gpl"
3243 deconvolve_filter_deps="avcodec"
3244 deconvolve_filter_select="fft"
3245 deinterlace_qsv_filter_deps="libmfx"
3246 deinterlace_vaapi_filter_deps="vaapi"
3247 delogo_filter_deps="gpl"
3248 denoise_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
3249 deshake_filter_select="pixelutils"
3250 drawtext_filter_deps="libfreetype"
3251 drawtext_filter_suggest="libfontconfig libfribidi"
3252 elbg_filter_deps="avcodec"
3253 eq_filter_deps="gpl"
3254 fftfilt_filter_deps="avcodec"
3255 fftfilt_filter_select="rdft"
3256 find_rect_filter_deps="avcodec avformat gpl"
3257 firequalizer_filter_deps="avcodec"
3258 firequalizer_filter_select="rdft"
3259 flite_filter_deps="libflite"
3260 framerate_filter_select="pixelutils"
3261 frei0r_filter_deps="frei0r libdl"
3262 frei0r_src_filter_deps="frei0r libdl"
3263 fspp_filter_deps="gpl"
3264 geq_filter_deps="gpl"
3265 histeq_filter_deps="gpl"
3266 hqdn3d_filter_deps="gpl"
3267 interlace_filter_deps="gpl"
3268 kerndeint_filter_deps="gpl"
3269 ladspa_filter_deps="ladspa libdl"
3270 lv2_filter_deps="lv2"
3271 mcdeint_filter_deps="avcodec gpl"
3272 movie_filter_deps="avcodec avformat"
3273 mpdecimate_filter_deps="gpl"
3274 mpdecimate_filter_select="pixelutils"
3275 mptestsrc_filter_deps="gpl"
3276 negate_filter_deps="lut_filter"
3277 nnedi_filter_deps="gpl"
3278 ocr_filter_deps="libtesseract"
3279 ocv_filter_deps="libopencv"
3280 openclsrc_filter_deps="opencl"
3281 overlay_opencl_filter_deps="opencl"
3282 overlay_qsv_filter_deps="libmfx"
3283 overlay_qsv_filter_select="qsvvpp"
3284 owdenoise_filter_deps="gpl"
3285 pan_filter_deps="swresample"
3286 perspective_filter_deps="gpl"
3287 phase_filter_deps="gpl"
3288 pp7_filter_deps="gpl"
3289 pp_filter_deps="gpl postproc"
3290 procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
3291 program_opencl_filter_deps="opencl"
3292 pullup_filter_deps="gpl"
3293 removelogo_filter_deps="avcodec avformat swscale"
3294 repeatfields_filter_deps="gpl"
3295 resample_filter_deps="avresample"
3296 rubberband_filter_deps="librubberband"
3297 sab_filter_deps="gpl swscale"
3298 scale2ref_filter_deps="swscale"
3299 scale_filter_deps="swscale"
3300 scale_qsv_filter_deps="libmfx"
3301 select_filter_select="pixelutils"
3302 sharpness_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
3303 showcqt_filter_deps="avcodec avformat swscale"
3304 showcqt_filter_suggest="libfontconfig libfreetype"
3305 showcqt_filter_select="fft"
3306 showfreqs_filter_deps="avcodec"
3307 showfreqs_filter_select="fft"
3308 showspectrum_filter_deps="avcodec"
3309 showspectrum_filter_select="fft"
3310 showspectrumpic_filter_deps="avcodec"
3311 showspectrumpic_filter_select="fft"
3312 signature_filter_deps="gpl avcodec avformat"
3313 smartblur_filter_deps="gpl swscale"
3314 sofalizer_filter_deps="libmysofa avcodec"
3315 sofalizer_filter_select="fft"
3316 spectrumsynth_filter_deps="avcodec"
3317 spectrumsynth_filter_select="fft"
3318 spp_filter_deps="gpl avcodec"
3319 spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp"
3320 stereo3d_filter_deps="gpl"
3321 subtitles_filter_deps="avformat avcodec libass"
3322 super2xsai_filter_deps="gpl"
3323 pixfmts_super2xsai_test_deps="super2xsai_filter"
3324 tinterlace_filter_deps="gpl"
3325 tinterlace_merge_test_deps="tinterlace_filter"
3326 tinterlace_pad_test_deps="tinterlace_filter"
3327 tonemap_filter_deps="const_nan"
3328 unsharp_opencl_filter_deps="opencl"
3329 uspp_filter_deps="gpl avcodec"
3330 vaguedenoiser_filter_deps="gpl"
3331 vidstabdetect_filter_deps="libvidstab"
3332 vidstabtransform_filter_deps="libvidstab"
3333 libvmaf_filter_deps="libvmaf pthreads"
3334 zmq_filter_deps="libzmq"
3335 zoompan_filter_deps="swscale"
3336 zscale_filter_deps="libzimg const_nan"
3337 scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
3338 vpp_qsv_filter_deps="libmfx"
3339 vpp_qsv_filter_select="qsvvpp"
3340
3341 # examples
3342 avio_dir_cmd_deps="avformat avutil"
3343 avio_reading_deps="avformat avcodec avutil"
3344 decode_audio_example_deps="avcodec avutil"
3345 decode_video_example_deps="avcodec avutil"
3346 demuxing_decoding_example_deps="avcodec avformat avutil"
3347 encode_audio_example_deps="avcodec avutil"
3348 encode_video_example_deps="avcodec avutil"
3349 extract_mvs_example_deps="avcodec avformat avutil"
3350 filter_audio_example_deps="avfilter avutil"
3351 filtering_audio_example_deps="avfilter avcodec avformat avutil"
3352 filtering_video_example_deps="avfilter avcodec avformat avutil"
3353 http_multiclient_example_deps="avformat avutil fork"
3354 hw_decode_example_deps="avcodec avformat avutil"
3355 metadata_example_deps="avformat avutil"
3356 muxing_example_deps="avcodec avformat avutil swscale"
3357 qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder"
3358 remuxing_example_deps="avcodec avformat avutil"
3359 resampling_audio_example_deps="avutil swresample"
3360 scaling_video_example_deps="avutil swscale"
3361 transcode_aac_example_deps="avcodec avformat swresample"
3362 transcoding_example_deps="avfilter avcodec avformat avutil"
3363 vaapi_encode_example_deps="avcodec avutil h264_vaapi_encoder"
3364 vaapi_transcode_example_deps="avcodec avformat avutil h264_vaapi_encoder"
3365
3366 # EXTRALIBS_LIST
3367 cpu_init_extralibs="pthreads_extralibs"
3368 cws2fws_extralibs="zlib_extralibs"
3369
3370 # libraries, in linking order
3371 avcodec_deps="avutil"
3372 avcodec_suggest="libm"
3373 avcodec_select="null_bsf"
3374 avdevice_deps="avformat avcodec avutil"
3375 avdevice_suggest="libm"
3376 avfilter_deps="avutil"
3377 avfilter_suggest="libm"
3378 avformat_deps="avcodec avutil"
3379 avformat_suggest="libm network zlib"
3380 avresample_deps="avutil"
3381 avresample_suggest="libm"
3382 avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi videotoolbox corefoundation corevideo coremedia wincrypt"
3383 postproc_deps="avutil gpl"
3384 postproc_suggest="libm"
3385 swresample_deps="avutil"
3386 swresample_suggest="libm libsoxr"
3387 swscale_deps="avutil"
3388 swscale_suggest="libm"
3389
3390 avcodec_extralibs="pthreads_extralibs iconv_extralibs"
3391 avfilter_extralibs="pthreads_extralibs"
3392 avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
3393
3394 # programs
3395 ffmpeg_deps="avcodec avfilter avformat swresample"
3396 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
3397                null_filter
3398                trim_filter"
3399 ffmpeg_suggest="ole32 psapi shell32"
3400 ffplay_deps="avcodec avformat swscale swresample sdl2"
3401 ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter rotate_filter"
3402 ffplay_suggest="shell32"
3403 ffprobe_deps="avcodec avformat"
3404 ffprobe_suggest="shell32"
3405
3406 # documentation
3407 podpages_deps="perl"
3408 manpages_deps="perl pod2man"
3409 htmlpages_deps="perl"
3410 htmlpages_deps_any="makeinfo_html texi2html"
3411 txtpages_deps="perl makeinfo"
3412 doc_deps_any="manpages htmlpages podpages txtpages"
3413
3414 # default parameters
3415
3416 logfile="ffbuild/config.log"
3417
3418 # installation paths
3419 prefix_default="/usr/local"
3420 bindir_default='${prefix}/bin'
3421 datadir_default='${prefix}/share/ffmpeg'
3422 docdir_default='${prefix}/share/doc/ffmpeg'
3423 incdir_default='${prefix}/include'
3424 libdir_default='${prefix}/lib'
3425 mandir_default='${prefix}/share/man'
3426
3427 # toolchain
3428 ar_default="ar"
3429 cc_default="gcc"
3430 cxx_default="g++"
3431 host_cc_default="gcc"
3432 doxygen_default="doxygen"
3433 install="install"
3434 ln_s_default="ln -s -f"
3435 nm_default="nm -g"
3436 pkg_config_default=pkg-config
3437 ranlib_default="ranlib"
3438 strip_default="strip"
3439 version_script='--version-script'
3440 objformat="elf32"
3441 x86asmexe_default="nasm"
3442 windres_default="windres"
3443 nvcc_default="nvcc"
3444 nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2"
3445 striptype="direct"
3446
3447 # OS
3448 target_os_default=$(tolower $(uname -s))
3449 host_os=$target_os_default
3450
3451 # machine
3452 if test "$target_os_default" = aix; then
3453     arch_default=$(uname -p)
3454     strip_default="strip -X32_64"
3455 else
3456     arch_default=$(uname -m)
3457 fi
3458 cpu="generic"
3459 intrinsics="none"
3460
3461 # configurable options
3462 enable $PROGRAM_LIST
3463 enable $DOCUMENT_LIST
3464 enable $EXAMPLE_LIST
3465 enable $(filter_out avresample $LIBRARY_LIST)
3466 enable stripping
3467
3468 enable asm
3469 enable debug
3470 enable doc
3471 enable faan faandct faanidct
3472 enable optimizations
3473 enable runtime_cpudetect
3474 enable safe_bitstream_reader
3475 enable static
3476 enable swscale_alpha
3477 enable valgrind_backtrace
3478
3479 sws_max_filter_size_default=256
3480 set_default sws_max_filter_size
3481
3482 # internal components are enabled by default
3483 enable $EXTRALIBS_LIST
3484
3485 # Avoid external, non-system, libraries getting enabled by dependency resolution
3486 disable $EXTERNAL_LIBRARY_LIST $HWACCEL_LIBRARY_LIST
3487
3488 # build settings
3489 SHFLAGS='-shared -Wl,-soname,$$(@F)'
3490 LIBPREF="lib"
3491 LIBSUF=".a"
3492 FULLNAME='$(NAME)$(BUILDSUF)'
3493 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
3494 SLIBPREF="lib"
3495 SLIBSUF=".so"
3496 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
3497 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
3498 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
3499 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
3500 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
3501 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
3502 VERSION_SCRIPT_POSTPROCESS_CMD="cat"
3503
3504 asflags_filter=echo
3505 cflags_filter=echo
3506 ldflags_filter=echo
3507
3508 AS_C='-c'
3509 AS_O='-o $@'
3510 CC_C='-c'
3511 CC_E='-E -o $@'
3512 CC_O='-o $@'
3513 CXX_C='-c'
3514 CXX_O='-o $@'
3515 OBJCC_C='-c'
3516 OBJCC_E='-E -o $@'
3517 OBJCC_O='-o $@'
3518 X86ASM_O='-o $@'
3519 LD_O='-o $@'
3520 LD_LIB='-l%'
3521 LD_PATH='-L'
3522 HOSTCC_C='-c'
3523 HOSTCC_E='-E -o $@'
3524 HOSTCC_O='-o $@'
3525 HOSTLD_O='-o $@'
3526 NVCC_C='-c'
3527 NVCC_O='-o $@'
3528
3529 host_extralibs='-lm'
3530 host_cflags_filter=echo
3531 host_ldflags_filter=echo
3532
3533 target_path='$(CURDIR)'
3534
3535 # since the object filename is not given with the -MM flag, the compiler
3536 # is only able to print the basename, and we must add the path ourselves
3537 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)'
3538 DEPFLAGS='-MM'
3539
3540 mkdir -p ffbuild
3541
3542 # find source path
3543 if test -f configure; then
3544     source_path=.
3545 else
3546     source_path=$(cd $(dirname "$0"); pwd)
3547     case "$source_path" in
3548         *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;;
3549     esac
3550     test -e "$source_path/config.h" &&
3551         die "Out of tree builds are impossible with config.h in source dir."
3552 fi
3553
3554 for v in "$@"; do
3555     r=${v#*=}
3556     l=${v%"$r"}
3557     r=$(sh_quote "$r")
3558     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
3559 done
3560
3561 find_things(){
3562     thing=$1
3563     pattern=$2
3564     file=$source_path/$3
3565     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
3566 }
3567
3568 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
3569
3570 find_things_extern(){
3571     thing=$1
3572     pattern=$2
3573     file=$source_path/$3
3574     out=${4:-$thing}
3575     sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
3576 }
3577
3578 OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c outdev)
3579 INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c indev)
3580 MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
3581 DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat libavformat/allformats.c)
3582 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
3583 DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
3584 CODEC_LIST="
3585     $ENCODER_LIST
3586     $DECODER_LIST
3587 "
3588 PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c)
3589 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
3590 HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
3591 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
3592
3593 AVCODEC_COMPONENTS_LIST="
3594     $BSF_LIST
3595     $DECODER_LIST
3596     $ENCODER_LIST
3597     $HWACCEL_LIST
3598     $PARSER_LIST
3599 "
3600
3601 AVDEVICE_COMPONENTS_LIST="
3602     $INDEV_LIST
3603     $OUTDEV_LIST
3604 "
3605
3606 AVFILTER_COMPONENTS_LIST="
3607     $FILTER_LIST
3608 "
3609
3610 AVFORMAT_COMPONENTS_LIST="
3611     $DEMUXER_LIST
3612     $MUXER_LIST
3613     $PROTOCOL_LIST
3614 "
3615
3616 ALL_COMPONENTS="
3617     $AVCODEC_COMPONENTS_LIST
3618     $AVDEVICE_COMPONENTS_LIST
3619     $AVFILTER_COMPONENTS_LIST
3620     $AVFORMAT_COMPONENTS_LIST
3621 "
3622
3623 for n in $COMPONENT_LIST; do
3624     v=$(toupper ${n%s})_LIST
3625     eval enable \$$v
3626     eval ${n}_if_any="\$$v"
3627 done
3628
3629 enable $ARCH_EXT_LIST
3630
3631 die_unknown(){
3632     echo "Unknown option \"$1\"."
3633     echo "See $0 --help for available options."
3634     exit 1
3635 }
3636
3637 print_in_columns() {
3638     cols=$(expr $ncols / 24)
3639     cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
3640 }
3641
3642 show_list() {
3643     suffix=_$1
3644     shift
3645     echo $* | sed s/$suffix//g | print_in_columns
3646     exit 0
3647 }
3648
3649 rand_list(){
3650     IFS=', '
3651     set -- $*
3652     unset IFS
3653     for thing; do
3654         comp=${thing%:*}
3655         prob=${thing#$comp}
3656         prob=${prob#:}
3657         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
3658         echo "prob ${prob:-0.5}"
3659         printf '%s\n' $comp
3660     done
3661 }
3662
3663 do_random(){
3664     action=$1
3665     shift
3666     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
3667     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
3668 }
3669
3670 for opt do
3671     optval="${opt#*=}"
3672     case "$opt" in
3673         --extra-ldflags=*)
3674             add_ldflags $optval
3675         ;;
3676         --extra-ldexeflags=*)
3677             add_ldexeflags $optval
3678         ;;
3679         --extra-ldsoflags=*)
3680             add_ldsoflags $optval
3681         ;;
3682         --extra-ldlibflags=*)
3683             warn "The --extra-ldlibflags option is only provided for compatibility and will be\n"\
3684                  "removed in the future. Use --extra-ldsoflags instead."
3685             add_ldsoflags $optval
3686         ;;
3687         --extra-libs=*)
3688             add_extralibs $optval
3689         ;;
3690         --disable-devices)
3691             disable $INDEV_LIST $OUTDEV_LIST
3692         ;;
3693         --enable-debug=*)
3694             debuglevel="$optval"
3695         ;;
3696         --disable-programs)
3697             disable $PROGRAM_LIST
3698         ;;
3699         --disable-everything)
3700             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
3701         ;;
3702         --disable-all)
3703             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
3704             disable $LIBRARY_LIST $PROGRAM_LIST doc
3705             enable avutil
3706         ;;
3707         --enable-random|--disable-random)
3708             action=${opt%%-random}
3709             do_random ${action#--} $COMPONENT_LIST
3710         ;;
3711         --enable-random=*|--disable-random=*)
3712             action=${opt%%-random=*}
3713             do_random ${action#--} $optval
3714         ;;
3715         --enable-sdl)
3716             enable sdl2
3717         ;;
3718         --enable-*=*|--disable-*=*)
3719             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
3720             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
3721             eval list=\$$(toupper $thing)_LIST
3722             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
3723             list=$(filter "$name" $list)
3724             [ "$list" = "" ] && warn "Option $opt did not match anything"
3725             $action $list
3726         ;;
3727         --enable-yasm|--disable-yasm)
3728             warn "The ${opt} option is only provided for compatibility and will be\n"\
3729                  "removed in the future. Use --enable-x86asm / --disable-x86asm instead."
3730             test $opt = --enable-yasm && x86asm=yes || x86asm=no
3731         ;;
3732         --yasmexe=*)
3733             warn "The --yasmexe option is only provided for compatibility and will be\n"\
3734                  "removed in the future. Use --x86asmexe instead."
3735             x86asmexe="$optval"
3736         ;;
3737         --enable-?*|--disable-?*)
3738             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
3739             if is_in $option $COMPONENT_LIST; then
3740                 test $action = disable && action=unset
3741                 eval $action \$$(toupper ${option%s})_LIST
3742             elif is_in $option $CMDLINE_SELECT; then
3743                 $action $option
3744             else
3745                 die_unknown $opt
3746             fi
3747         ;;
3748         --list-*)
3749             NAME="${opt#--list-}"
3750             is_in $NAME $COMPONENT_LIST || die_unknown $opt
3751             NAME=${NAME%s}
3752             eval show_list $NAME \$$(toupper $NAME)_LIST
3753         ;;
3754         --help|-h) show_help
3755         ;;
3756         --quiet|-q) quiet=yes
3757         ;;
3758         --fatal-warnings) enable fatal_warnings
3759         ;;
3760         --libfuzzer=*)
3761             libfuzzer_path="$optval"
3762         ;;
3763         *)
3764             optname="${opt%%=*}"
3765             optname="${optname#--}"
3766             optname=$(echo "$optname" | sed 's/-/_/g')
3767             if is_in $optname $CMDLINE_SET; then
3768                 eval $optname='$optval'
3769             elif is_in $optname $CMDLINE_APPEND; then
3770                 append $optname "$optval"
3771             else
3772                 die_unknown $opt
3773             fi
3774         ;;
3775     esac
3776 done
3777
3778 for e in $env; do
3779     eval "export $e"
3780 done
3781
3782 if disabled autodetect; then
3783
3784     # Unless iconv is explicitely disabled by the user, we still want to probe
3785     # for the iconv from the libc.
3786     disabled iconv || enable libc_iconv
3787
3788     disable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
3789     disable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
3790 fi
3791 # Mark specifically enabled, but normally autodetected libraries as requested.
3792 for lib in $AUTODETECT_LIBS; do
3793     enabled $lib && request $lib
3794 done
3795 #TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way
3796 enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
3797 enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
3798
3799 disabled logging && logfile=/dev/null
3800
3801 # command line configuration sanity checks
3802
3803 # we need to build at least one lib type
3804 if ! enabled_any static shared; then
3805     cat <<EOF
3806 At least one library type must be built.
3807 Specify --enable-static to build the static libraries or --enable-shared to
3808 build the shared libraries as well. To only build the shared libraries specify
3809 --disable-static in addition to --enable-shared.
3810 EOF
3811     exit 1
3812 fi
3813
3814 die_license_disabled() {
3815     enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; }
3816 }
3817
3818 die_license_disabled_gpl() {
3819     enabled $1 || { enabled $v && die "$v is incompatible with the gpl and --enable-$1 is not specified."; }
3820 }
3821
3822 map "die_license_disabled gpl"      $EXTERNAL_LIBRARY_GPL_LIST $EXTERNAL_LIBRARY_GPLV3_LIST
3823 map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST $EXTERNAL_LIBRARY_GPLV3_LIST
3824
3825 enabled gpl && map "die_license_disabled_gpl nonfree" $EXTERNAL_LIBRARY_NONFREE_LIST
3826 map "die_license_disabled nonfree" $HWACCEL_LIBRARY_NONFREE_LIST
3827
3828 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3829
3830 if enabled nonfree; then
3831     license="nonfree and unredistributable"
3832 elif enabled gplv3; then
3833     license="GPL version 3 or later"
3834 elif enabled lgplv3; then
3835     license="LGPL version 3 or later"
3836 elif enabled gpl; then
3837     license="GPL version 2 or later"
3838 else
3839     license="LGPL version 2.1 or later"
3840 fi
3841
3842 enabled_all gnutls openssl &&
3843     die "GnuTLS and OpenSSL must not be enabled at the same time."
3844
3845 # Disable all the library-specific components if the library itself
3846 # is disabled, see AVCODEC_LIST and following _LIST variables.
3847
3848 disable_components(){
3849     disabled ${1} && disable $(
3850         eval components="\$$(toupper ${1})_COMPONENTS"
3851         map 'eval echo \${$(toupper ${v%s})_LIST}' $components
3852     )
3853 }
3854
3855 map 'disable_components $v' $LIBRARY_LIST
3856
3857 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
3858 set >> $logfile
3859
3860 test -n "$valgrind" && toolchain="valgrind-memcheck"
3861
3862 enabled ossfuzz && {
3863     add_cflags  -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp -fno-omit-frame-pointer
3864     add_ldflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp
3865 }
3866
3867 case "$toolchain" in
3868     *-asan)
3869         cc_default="${toolchain%-asan}"
3870         add_cflags  -fsanitize=address
3871         add_ldflags -fsanitize=address
3872     ;;
3873     *-msan)
3874         cc_default="${toolchain%-msan}"
3875         add_cflags  -fsanitize=memory -fsanitize-memory-track-origins
3876         add_ldflags -fsanitize=memory
3877     ;;
3878     *-tsan)
3879         cc_default="${toolchain%-tsan}"
3880         add_cflags  -fsanitize=thread -fPIE
3881         add_ldflags -fsanitize=thread -pie
3882         case "$toolchain" in
3883             gcc-tsan)
3884                 add_cflags  -fPIC
3885                 add_ldflags -fPIC
3886                 ;;
3887         esac
3888     ;;
3889     *-usan)
3890         cc_default="${toolchain%-usan}"
3891         add_cflags  -fsanitize=undefined
3892         add_ldflags -fsanitize=undefined
3893     ;;
3894     valgrind-*)
3895         target_exec_default="valgrind"
3896         case "$toolchain" in
3897             valgrind-massif)
3898                 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"
3899                 ;;
3900             valgrind-memcheck)
3901                 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"
3902                 ;;
3903         esac
3904     ;;
3905     msvc)
3906         # Check whether the current MSVC version needs the C99 converter.
3907         # From MSVC 2013 (compiler major version 18) onwards, it does actually
3908         # support enough of C99 to build ffmpeg. Default to the new
3909         # behaviour if the regexp was unable to match anything, since this
3910         # successfully parses the version number of existing supported
3911         # versions that require the converter (MSVC 2010 and 2012).
3912         cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
3913         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
3914             cc_default="cl"
3915             cxx_default="cl"
3916         else
3917             cc_default="c99wrap cl"
3918             cxx_default="c99wrap cl"
3919         fi
3920         ld_default="$source_path/compat/windows/mslink"
3921         nm_default="dumpbin -symbols"
3922         ar_default="lib"
3923         case "$arch" in
3924         aarch64|arm64)
3925             as_default="armasm64"
3926             ;;
3927         arm*)
3928             as_default="armasm"
3929             ;;
3930         esac
3931         target_os_default="win32"
3932         # Use a relative path for TMPDIR. This makes sure all the
3933         # ffconf temp files are written with a relative path, avoiding
3934         # issues with msys/win32 path conversion for MSVC parameters
3935         # such as -Fo<file> or -out:<file>.
3936         TMPDIR=.
3937     ;;
3938     icl)
3939         cc_default="icl"
3940         ld_default="xilink"
3941         nm_default="dumpbin -symbols"
3942         ar_default="xilib"
3943         target_os_default="win32"
3944         TMPDIR=.
3945     ;;
3946     gcov)
3947         add_cflags  -fprofile-arcs -ftest-coverage
3948         add_ldflags -fprofile-arcs -ftest-coverage
3949     ;;
3950     llvm-cov)
3951         add_cflags -fprofile-arcs -ftest-coverage
3952         add_ldflags --coverage
3953     ;;
3954     hardened)
3955         add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
3956         add_cflags   -fno-strict-overflow -fstack-protector-all
3957         add_ldflags  -Wl,-z,relro -Wl,-z,now
3958         add_cflags   -fPIE
3959         add_ldexeflags -fPIE -pie
3960     ;;
3961     ?*)
3962         die "Unknown toolchain $toolchain"
3963     ;;
3964 esac
3965
3966 if test -n "$cross_prefix"; then
3967     test -n "$arch" && test -n "$target_os" ||
3968         die "Must specify target arch (--arch) and OS (--target-os) when cross-compiling"
3969     enable cross_compile
3970 fi
3971
3972 ar_default="${cross_prefix}${ar_default}"
3973 cc_default="${cross_prefix}${cc_default}"
3974 cxx_default="${cross_prefix}${cxx_default}"
3975 nm_default="${cross_prefix}${nm_default}"
3976 pkg_config_default="${cross_prefix}${pkg_config_default}"
3977 if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then
3978     ranlib_default="${cross_prefix}${ranlib_default} -D"
3979 else
3980     ranlib_default="${cross_prefix}${ranlib_default}"
3981 fi
3982 strip_default="${cross_prefix}${strip_default}"
3983 windres_default="${cross_prefix}${windres_default}"
3984
3985 sysinclude_default="${sysroot}/usr/include"
3986
3987 set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
3988     target_exec target_os x86asmexe nvcc
3989 enabled cross_compile || host_cc_default=$cc
3990 set_default host_cc
3991
3992 pkg_config_fail_message=""
3993 if ! $pkg_config --version >/dev/null 2>&1; then
3994     warn "$pkg_config not found, library detection may fail."
3995     pkg_config=false
3996 elif is_in -static $cc $LDFLAGS && ! is_in --static $pkg_config $pkg_config_flags; then
3997     pkg_config_fail_message="
3998 Note: When building a static binary, add --pkg-config-flags=\"--static\"."
3999 fi
4000
4001 if test $doxygen != $doxygen_default && \
4002   ! $doxygen --version >/dev/null 2>&1; then
4003     warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build."
4004 fi
4005
4006 exesuf() {
4007     case $1 in
4008         mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
4009     esac
4010 }
4011
4012 EXESUF=$(exesuf $target_os)
4013 HOSTEXESUF=$(exesuf $host_os)
4014
4015 # set temporary file name
4016 : ${TMPDIR:=$TEMPDIR}
4017 : ${TMPDIR:=$TMP}
4018 : ${TMPDIR:=/tmp}
4019
4020 if [ -n "$tempprefix" ] ; then
4021     mktemp(){
4022         tmpname="$tempprefix.${HOSTNAME}.${UID}"
4023         echo "$tmpname"
4024         mkdir "$tmpname"
4025     }
4026 elif ! test_cmd mktemp -u XXXXXX; then
4027     # simple replacement for missing mktemp
4028     # NOT SAFE FOR GENERAL USE
4029     mktemp(){
4030         tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
4031         echo "$tmpname"
4032         mkdir "$tmpname"
4033     }
4034 fi
4035
4036 FFTMPDIR=$(mktemp -d "${TMPDIR}/ffconf.XXXXXXXX" 2> /dev/null) ||
4037     die "Unable to create temporary directory in $TMPDIR."
4038
4039 tmpfile(){
4040     tmp="${FFTMPDIR}/test"$2
4041     (set -C; exec > $tmp) 2> /dev/null ||
4042         die "Unable to create temporary file in $FFTMPDIR."
4043     eval $1=$tmp
4044 }
4045
4046 trap 'rm -rf -- "$FFTMPDIR"' EXIT
4047 trap 'exit 2' INT
4048
4049 tmpfile TMPASM .asm
4050 tmpfile TMPC   .c
4051 tmpfile TMPCPP .cpp
4052 tmpfile TMPE   $EXESUF
4053 tmpfile TMPH   .h
4054 tmpfile TMPM   .m
4055 tmpfile TMPO   .o
4056 tmpfile TMPS   .S
4057 tmpfile TMPSH  .sh
4058 tmpfile TMPV   .ver
4059
4060 unset -f mktemp
4061
4062 chmod +x $TMPE
4063
4064 # make sure we can execute files in $TMPDIR
4065 cat > $TMPSH 2>> $logfile <<EOF
4066 #! /bin/sh
4067 EOF
4068 chmod +x $TMPSH >> $logfile 2>&1
4069 if ! $TMPSH >> $logfile 2>&1; then
4070     cat <<EOF
4071 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
4072 variable to another directory and make sure that it is not mounted noexec.
4073 EOF
4074     die "Sanity test failed."
4075 fi
4076
4077 armasm_flags(){
4078     for flag; do
4079         case $flag in
4080             # Filter out MSVC cl.exe options from cflags that shouldn't
4081             # be passed to gas-preprocessor
4082             -M[TD]*)                                            ;;
4083             *)                  echo $flag                      ;;
4084         esac
4085    done
4086 }
4087
4088 cparser_flags(){
4089     for flag; do
4090         case $flag in
4091             -Wno-switch)             echo -Wno-switch-enum ;;
4092             -Wno-format-zero-length) ;;
4093             -Wdisabled-optimization) ;;
4094             -Wno-pointer-sign)       echo -Wno-other ;;
4095             *)                       echo $flag ;;
4096         esac
4097     done
4098 }
4099
4100 msvc_common_flags(){
4101     for flag; do
4102         case $flag in
4103             # In addition to specifying certain flags under the compiler
4104             # specific filters, they must be specified here as well or else the
4105             # generic catch all at the bottom will print the original flag.
4106             -Wall)                ;;
4107             -Wextra)              ;;
4108             -std=c99)             ;;
4109             # Common flags
4110             -fomit-frame-pointer) ;;
4111             -g)                   echo -Z7 ;;
4112             -fno-math-errno)      ;;
4113             -fno-common)          ;;
4114             -fno-signed-zeros)    ;;
4115             -fPIC)                ;;
4116             -mthumb)              ;;
4117             -march=*)             ;;
4118             -lz)                  echo zlib.lib ;;
4119             -lx264)               echo libx264.lib ;;
4120             -lstdc++)             ;;
4121             -l*)                  echo ${flag#-l}.lib ;;
4122             -LARGEADDRESSAWARE)   echo $flag ;;
4123             -L*)                  echo -libpath:${flag#-L} ;;
4124             *)                    echo $flag ;;
4125         esac
4126     done
4127 }
4128
4129 msvc_flags(){
4130     msvc_common_flags "$@"
4131     for flag; do
4132         case $flag in
4133             -Wall)                echo -W3 -wd4018 -wd4146 -wd4244 -wd4305     \
4134                                        -wd4554 ;;
4135             -Wextra)              echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
4136                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
4137                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
4138                                        -wd4307 \
4139                                        -wd4273 -wd4554 -wd4701 -wd4703 ;;
4140         esac
4141     done
4142 }
4143
4144 icl_flags(){
4145     msvc_common_flags "$@"
4146     for flag; do
4147         case $flag in
4148             # Despite what Intel's documentation says -Wall, which is supported
4149             # on Windows, does enable remarks so disable them here.
4150             -Wall)                echo $flag -Qdiag-disable:remark ;;
4151             -std=c99)             echo -Qstd=c99 ;;
4152             -flto)                echo -ipo ;;
4153         esac
4154     done
4155 }
4156
4157 icc_flags(){
4158     for flag; do
4159         case $flag in
4160             -flto)                echo -ipo ;;
4161             *)                    echo $flag ;;
4162         esac
4163     done
4164 }
4165
4166 suncc_flags(){
4167     for flag; do
4168         case $flag in
4169             -march=*|-mcpu=*)
4170                 case "${flag#*=}" in
4171                     native)                   echo -xtarget=native       ;;
4172                     v9|niagara)               echo -xarch=sparc          ;;
4173                     ultrasparc)               echo -xarch=sparcvis       ;;
4174                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
4175                     i586|pentium)             echo -xchip=pentium        ;;
4176                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
4177                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
4178                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
4179                     pentium4*)          echo -xtarget=pentium4           ;;
4180                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
4181                     *-sse3)             echo -xarch=sse3                 ;;
4182                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
4183                     bonnell)                   echo -xarch=ssse3         ;;
4184                     corei7|nehalem)            echo -xtarget=nehalem     ;;
4185                     westmere)                  echo -xtarget=westmere    ;;
4186                     silvermont)                echo -xarch=sse4_2        ;;
4187                     corei7-avx|sandybridge)    echo -xtarget=sandybridge ;;
4188                     core-avx*|ivybridge|haswell|broadwell|skylake*|knl)
4189                                                echo -xarch=avx           ;;
4190                     amdfam10|barcelona)        echo -xtarget=barcelona   ;;
4191                     btver1)                    echo -xarch=amdsse4a      ;;
4192                     btver2|bdver*|znver*)      echo -xarch=avx           ;;
4193                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
4194                     k8|opteron|athlon64|athlon-fx)
4195                                                echo -xarch=sse2a         ;;
4196                     athlon*)                   echo -xarch=pentium_proa  ;;
4197                 esac
4198                 ;;
4199             -std=c99)             echo -xc99              ;;
4200             -fomit-frame-pointer) echo -xregs=frameptr    ;;
4201             -fPIC)                echo -KPIC -xcode=pic32 ;;
4202             -W*,*)                echo $flag              ;;
4203             -f*-*|-W*|-mimpure-text)                      ;;
4204             -shared)              echo -G                 ;;
4205             *)                    echo $flag              ;;
4206         esac
4207     done
4208 }
4209
4210 probe_cc(){
4211     pfx=$1
4212     _cc=$2
4213     first=$3
4214
4215     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
4216     unset _ld_o _ldflags _ld_lib _ld_path
4217     unset _depflags _DEPCMD _DEPFLAGS
4218     _flags_filter=echo
4219
4220     if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
4221         true # no-op to avoid reading stdin in following checks
4222     elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
4223         _type=llvm_gcc
4224         gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
4225         _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
4226         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4227         _cflags_speed='-O3'
4228         _cflags_size='-Os'
4229     elif $_cc -v 2>&1 | grep -qi ^gcc; then
4230         _type=gcc
4231         gcc_version=$($_cc --version | head -n1)
4232         gcc_basever=$($_cc -dumpversion)
4233         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
4234         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
4235         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
4236         case $gcc_basever in
4237             2) ;;
4238             2.*) ;;
4239             *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;;
4240         esac
4241         if [ "$first" = true ]; then
4242             case $gcc_basever in
4243                 4.2*)
4244                 warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;;
4245             esac
4246         fi
4247         _cflags_speed='-O3'
4248         _cflags_size='-Os'
4249     elif $_cc --version 2>/dev/null | grep -q ^icc; then
4250         _type=icc
4251         _ident=$($_cc --version | head -n1)
4252         _depflags='-MMD'
4253         _cflags_speed='-O3'
4254         _cflags_size='-Os'
4255         _cflags_noopt='-O1'
4256         _flags_filter=icc_flags
4257     elif $_cc -v 2>&1 | grep -q xlc; then
4258         _type=xlc
4259         _ident=$($_cc -qversion 2>/dev/null | head -n1)
4260         _cflags_speed='-O5'
4261         _cflags_size='-O5 -qcompact'
4262     elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
4263         test -d "$sysroot" || die "No valid sysroot specified."
4264         _type=armcc
4265         _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
4266         armcc_conf="$PWD/armcc.conf"
4267         $_cc --arm_linux_configure                 \
4268              --arm_linux_config_file="$armcc_conf" \
4269              --configure_sysroot="$sysroot"        \
4270              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
4271              die "Error creating armcc configuration file."
4272         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
4273         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
4274         as_default="${cross_prefix}gcc"
4275         _depflags='-MMD'
4276         _cflags_speed='-O3'
4277         _cflags_size='-Os'
4278     elif $_cc -v 2>&1 | grep -q clang; then
4279         _type=clang
4280         _ident=$($_cc --version 2>/dev/null | head -n1)
4281         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4282         _cflags_speed='-O3'
4283         _cflags_size='-Oz'
4284     elif $_cc -V 2>&1 | grep -q Sun; then
4285         _type=suncc
4286         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
4287         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
4288         _DEPFLAGS='-xM1 -xc99'
4289         _ldflags='-std=c99'
4290         _cflags_speed='-O5'
4291         _cflags_size='-O5 -xspace'
4292         _flags_filter=suncc_flags
4293     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
4294         _type=pathscale
4295         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
4296         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4297         _cflags_speed='-O2'
4298         _cflags_size='-Os'
4299         _flags_filter='filter_out -Wdisabled-optimization'
4300     elif $_cc -v 2>&1 | grep -q Open64; then
4301         _type=open64
4302         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
4303         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4304         _cflags_speed='-O2'
4305         _cflags_size='-Os'
4306         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
4307     elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
4308         _type=armasm
4309         _ident=$($_cc | head -n1)
4310         # 4509: "This form of conditional instruction is deprecated"
4311         _flags="-nologo -ignore 4509"
4312         _flags_filter=armasm_flags
4313     elif $_cc 2>&1 | grep -q Intel; then
4314         _type=icl
4315         _ident=$($_cc 2>&1 | head -n1)
4316         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
4317         # Not only is O3 broken on 13.x+ but it is slower on all previous
4318         # versions (tested) as well.
4319         _cflags_speed="-O2"
4320         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
4321         if $_cc 2>&1 | grep -q Linker; then
4322             _ld_o='-out:$@'
4323         else
4324             _ld_o='-Fe$@'
4325         fi
4326         _cc_o='-Fo$@'
4327         _cc_e='-P'
4328         _flags_filter=icl_flags
4329         _ld_lib='lib%.a'
4330         _ld_path='-libpath:'
4331         # -Qdiag-error to make icl error when seeing certain unknown arguments
4332         _flags='-nologo -Qdiag-error:4044,10157'
4333         # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency
4334         # with MSVC which enables it by default.
4335         _cflags='-Qms0 -Qvec- -Qsimd- -GS -fp:precise'
4336         disable stripping
4337     elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then
4338         # lld can emulate multiple different linkers; in ms link.exe mode,
4339         # the -? parameter gives the help output which contains an identifyable
4340         # string, while it gives an error in other modes.
4341         _type=lld-link
4342         # The link.exe mode doesn't have a switch for getting the version,
4343         # but we can force it back to gnu mode and get the version from there.
4344         _ident=$($_cc -flavor gnu --version 2>/dev/null)
4345         _ld_o='-out:$@'
4346         _flags_filter=msvc_flags
4347         _ld_lib='lib%.a'
4348         _ld_path='-libpath:'
4349     elif $_cc -nologo- 2>&1 | grep -q Microsoft; then
4350         _type=msvc
4351         _ident=$($_cc 2>&1 | head -n1 | tr -d '\r')
4352         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
4353         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
4354         _cflags_speed="-O2"
4355         _cflags_size="-O1"
4356         _cflags_noopt="-O1"
4357         if $_cc -nologo- 2>&1 | grep -q Linker; then
4358             _ld_o='-out:$@'
4359         else
4360             _ld_o='-Fe$@'
4361         fi
4362         _cc_o='-Fo$@'
4363         _cc_e='-P -Fi$@'
4364         _flags_filter=msvc_flags
4365         _ld_lib='lib%.a'
4366         _ld_path='-libpath:'
4367         _flags='-nologo'
4368         disable stripping
4369     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
4370         _type=cparser
4371         _ident=$($_cc --version | head -n1)
4372         _depflags='-MMD'
4373         _cflags_speed='-O4'
4374         _cflags_size='-O2'
4375         _flags_filter=cparser_flags
4376     fi
4377
4378     eval ${pfx}_type=\$_type
4379     eval ${pfx}_ident=\$_ident
4380 }
4381
4382 set_ccvars(){
4383     eval ${1}_C=\${_cc_c-\${${1}_C}}
4384     eval ${1}_E=\${_cc_e-\${${1}_E}}
4385     eval ${1}_O=\${_cc_o-\${${1}_O}}
4386
4387     if [ -n "$_depflags" ]; then
4388         eval ${1}_DEPFLAGS=\$_depflags
4389     else
4390         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
4391         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
4392         eval DEP${1}FLAGS=\$_flags
4393     fi
4394 }
4395
4396 probe_cc cc "$cc" "true"
4397 cflags_filter=$_flags_filter
4398 cflags_speed=$_cflags_speed
4399 cflags_size=$_cflags_size
4400 cflags_noopt=$_cflags_noopt
4401 add_cflags $_flags $_cflags
4402 cc_ldflags=$_ldflags
4403 set_ccvars CC
4404 set_ccvars CXX
4405
4406 probe_cc hostcc "$host_cc"
4407 host_cflags_filter=$_flags_filter
4408 host_cflags_speed=$_cflags_speed
4409 add_host_cflags  $_flags $_cflags
4410 set_ccvars HOSTCC
4411
4412 test -n "$cc_type" && enable $cc_type ||
4413     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
4414
4415 : ${as_default:=$cc}
4416 : ${objcc_default:=$cc}
4417 : ${dep_cc_default:=$cc}
4418 : ${ld_default:=$cc}
4419 : ${host_ld_default:=$host_cc}
4420 set_default ar as objcc dep_cc ld ln_s host_ld windres
4421
4422 probe_cc as "$as"
4423 asflags_filter=$_flags_filter
4424 add_asflags $_flags $_cflags
4425 set_ccvars AS
4426
4427 probe_cc objcc "$objcc"
4428 objcflags_filter=$_flags_filter
4429 add_objcflags $_flags $_cflags
4430 set_ccvars OBJC
4431
4432 probe_cc ld "$ld"
4433 ldflags_filter=$_flags_filter
4434 add_ldflags $_flags $_ldflags
4435 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
4436 LD_O=${_ld_o-$LD_O}
4437 LD_LIB=${_ld_lib-$LD_LIB}
4438 LD_PATH=${_ld_path-$LD_PATH}
4439
4440 probe_cc hostld "$host_ld"
4441 host_ldflags_filter=$_flags_filter
4442 add_host_ldflags $_flags $_ldflags
4443 HOSTLD_O=${_ld_o-$HOSTLD_O}
4444
4445 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
4446     probe_cc depcc "$dep_cc"
4447     CCDEP=${_DEPCMD:-$DEPCMD}
4448     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
4449     DEPCCFLAGS=$_flags
4450 fi
4451
4452 if $ar 2>&1 | grep -q Microsoft; then
4453     arflags="-nologo"
4454     ar_o='-out:$@'
4455 elif $ar 2>&1 | grep -q "\[D\] "; then
4456     arflags="rcD"
4457     ar_o='$@'
4458 else
4459     arflags="rc"
4460     ar_o='$@'
4461 fi
4462
4463 add_cflags $extra_cflags
4464 add_cxxflags $extra_cxxflags
4465 add_objcflags $extra_objcflags
4466 add_asflags $extra_cflags
4467
4468 if test -n "$sysroot"; then
4469     case "$cc_type" in
4470         gcc|llvm_gcc|clang)
4471             add_cppflags --sysroot="$sysroot"
4472             add_ldflags --sysroot="$sysroot"
4473         ;;
4474     esac
4475 fi
4476
4477 if test "$cpu" = host; then
4478     enabled cross_compile &&
4479         die "--cpu=host makes no sense when cross-compiling."
4480
4481     case "$cc_type" in
4482         gcc|llvm_gcc)
4483             check_native(){
4484                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
4485                 sed -n "/cc1.*$1=/{
4486                             s/.*$1=\\([^ ]*\\).*/\\1/
4487                             p
4488                             q
4489                         }" $TMPE
4490             }
4491             cpu=$(check_native -march || check_native -mcpu)
4492         ;;
4493         clang)
4494             check_native(){
4495                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
4496                 sed -n "/cc1.*-target-cpu /{
4497                             s/.*-target-cpu \\([^ ]*\\).*/\\1/
4498                             p
4499                             q
4500                         }" $TMPE
4501             }
4502             cpu=$(check_native -march)
4503         ;;
4504     esac
4505
4506     test "${cpu:-host}" = host &&
4507         die "--cpu=host not supported with compiler $cc"
4508 fi
4509
4510 # Deal with common $arch aliases
4511 case "$arch" in
4512     aarch64|arm64)
4513         arch="aarch64"
4514     ;;
4515     arm*|iPad*|iPhone*)
4516         arch="arm"
4517     ;;
4518     mips*|IP*)
4519         case "$arch" in
4520         *el)
4521             add_cppflags -EL
4522             add_ldflags -EL
4523         ;;
4524         *eb)
4525             add_cppflags -EB
4526             add_ldflags -EB
4527         ;;
4528         esac
4529         arch="mips"
4530     ;;
4531     parisc*|hppa*)
4532         arch="parisc"
4533     ;;
4534     "Power Macintosh"|ppc*|powerpc*)
4535         arch="ppc"
4536     ;;
4537     s390|s390x)
4538         arch="s390"
4539     ;;
4540     sh4|sh)
4541         arch="sh4"
4542     ;;
4543     sun4*|sparc*)
4544         arch="sparc"
4545     ;;
4546     tilegx|tile-gx)
4547         arch="tilegx"
4548     ;;
4549     i[3-6]86*|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
4550         arch="x86"
4551     ;;
4552 esac
4553
4554 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
4555 enable $arch
4556
4557 # Add processor-specific flags
4558 if enabled aarch64; then
4559
4560     case $cpu in
4561         armv*)
4562             cpuflags="-march=$cpu"
4563         ;;
4564         *)
4565             cpuflags="-mcpu=$cpu"
4566         ;;
4567     esac
4568
4569 elif enabled alpha; then
4570
4571     cpuflags="-mcpu=$cpu"
4572
4573 elif enabled arm; then
4574
4575     check_arm_arch() {
4576         test_cpp_condition stddef.h \
4577             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
4578             $cpuflags
4579     }
4580
4581     probe_arm_arch() {
4582         if   check_arm_arch 4;        then echo armv4
4583         elif check_arm_arch 4T;       then echo armv4t
4584         elif check_arm_arch 5;        then echo armv5
4585         elif check_arm_arch 5E;       then echo armv5e
4586         elif check_arm_arch 5T;       then echo armv5t
4587         elif check_arm_arch 5TE;      then echo armv5te
4588         elif check_arm_arch 5TEJ;     then echo armv5te
4589         elif check_arm_arch 6;        then echo armv6
4590         elif check_arm_arch 6J;       then echo armv6j
4591         elif check_arm_arch 6K;       then echo armv6k
4592         elif check_arm_arch 6Z;       then echo armv6z
4593         elif check_arm_arch 6KZ;      then echo armv6zk
4594         elif check_arm_arch 6ZK;      then echo armv6zk
4595         elif check_arm_arch 6T2;      then echo armv6t2
4596         elif check_arm_arch 7;        then echo armv7
4597         elif check_arm_arch 7A  7_A;  then echo armv7-a
4598         elif check_arm_arch 7S;       then echo armv7-a
4599         elif check_arm_arch 7R  7_R;  then echo armv7-r
4600         elif check_arm_arch 7M  7_M;  then echo armv7-m
4601         elif check_arm_arch 7EM 7E_M; then echo armv7-m
4602         elif check_arm_arch 8A  8_A;  then echo armv8-a
4603         fi
4604     }
4605
4606     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
4607
4608     case $cpu in
4609         armv*)
4610             cpuflags="-march=$cpu"
4611             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
4612         ;;
4613         *)
4614             cpuflags="-mcpu=$cpu"
4615             case $cpu in
4616                 cortex-a*)                               subarch=armv7a  ;;
4617                 cortex-r*)                               subarch=armv7r  ;;
4618                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
4619                 arm11*)                                  subarch=armv6   ;;
4620                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
4621                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
4622                 *)                             subarch=$(probe_arm_arch) ;;
4623             esac
4624         ;;
4625     esac
4626
4627     case "$subarch" in
4628         armv5t*)    enable fast_clz                ;;
4629         armv[6-8]*)
4630             enable fast_clz
4631             disabled fast_unaligned || enable fast_unaligned
4632             ;;
4633     esac
4634
4635 elif enabled avr32; then
4636
4637     case $cpu in
4638         ap7[02]0[0-2])
4639             subarch="avr32_ap"
4640             cpuflags="-mpart=$cpu"
4641         ;;
4642         ap)
4643             subarch="avr32_ap"
4644             cpuflags="-march=$cpu"
4645         ;;
4646         uc3[ab]*)
4647             subarch="avr32_uc"
4648             cpuflags="-mcpu=$cpu"
4649         ;;
4650         uc)
4651             subarch="avr32_uc"
4652             cpuflags="-march=$cpu"
4653         ;;
4654     esac
4655
4656 elif enabled bfin; then
4657
4658     cpuflags="-mcpu=$cpu"
4659
4660 elif enabled mips; then
4661
4662     cpuflags="-march=$cpu"
4663
4664     if [ "$cpu" != "generic" ]; then
4665         disable mips32r2
4666         disable mips32r5
4667         disable mips64r2
4668         disable mips32r6
4669         disable mips64r6
4670         disable loongson2
4671         disable loongson3
4672
4673         case $cpu in
4674             24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf)
4675                 enable mips32r2
4676                 disable msa
4677             ;;
4678             p5600|i6400|p6600)
4679                 disable mipsdsp
4680                 disable mipsdspr2
4681             ;;
4682             loongson*)
4683                 enable loongson2
4684                 enable loongson3
4685                 enable local_aligned
4686                 enable simd_align_16
4687                 enable fast_64bit
4688                 enable fast_clz
4689                 enable fast_cmov
4690                 enable fast_unaligned
4691                 disable aligned_stack
4692                 disable mipsfpu
4693                 disable mipsdsp
4694                 disable mipsdspr2
4695                 case $cpu in
4696                     loongson3*)
4697                         cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations"
4698                     ;;
4699                     loongson2e)
4700                         cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations"
4701                     ;;
4702                     loongson2f)
4703                         cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations"
4704                     ;;
4705                 esac
4706             ;;
4707             *)
4708                 # Unknown CPU. Disable everything.
4709                 warn "unknown CPU. Disabling all MIPS optimizations."
4710                 disable mipsfpu
4711                 disable mipsdsp
4712                 disable mipsdspr2
4713                 disable msa
4714                 disable mmi
4715             ;;
4716         esac
4717
4718         case $cpu in
4719             24kc)
4720                 disable mipsfpu
4721                 disable mipsdsp
4722                 disable mipsdspr2
4723             ;;
4724             24kf*)
4725                 disable mipsdsp
4726                 disable mipsdspr2
4727             ;;
4728             24kec|34kc|1004kc)
4729                 disable mipsfpu
4730                 disable mipsdspr2
4731             ;;
4732             24kef*|34kf*|1004kf*)
4733                 disable mipsdspr2
4734             ;;
4735             74kc)
4736                 disable mipsfpu
4737             ;;
4738             p5600)
4739                 enable mips32r5
4740                 check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops"
4741             ;;
4742             i6400)
4743                 enable mips64r6
4744                 check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
4745             ;;
4746             p6600)
4747                 enable mips64r6
4748                 check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
4749             ;;
4750         esac
4751     else
4752         # We do not disable anything. Is up to the user to disable the unwanted features.
4753         warn 'generic cpu selected'
4754     fi
4755
4756 elif enabled ppc; then
4757
4758     disable ldbrx
4759
4760     case $(tolower $cpu) in
4761         601|ppc601|powerpc601)
4762             cpuflags="-mcpu=601"
4763             disable altivec
4764         ;;
4765         603*|ppc603*|powerpc603*)
4766             cpuflags="-mcpu=603"
4767             disable altivec
4768         ;;
4769         604*|ppc604*|powerpc604*)
4770             cpuflags="-mcpu=604"
4771             disable altivec
4772         ;;
4773         g3|75*|ppc75*|powerpc75*)
4774             cpuflags="-mcpu=750"
4775             disable altivec
4776         ;;
4777         g4|745*|ppc745*|powerpc745*)
4778             cpuflags="-mcpu=7450"
4779             disable vsx
4780         ;;
4781         74*|ppc74*|powerpc74*)
4782             cpuflags="-mcpu=7400"
4783             disable vsx
4784         ;;
4785         g5|970|ppc970|powerpc970)
4786             cpuflags="-mcpu=970"
4787             disable vsx
4788         ;;
4789         power[3-6]*)
4790             cpuflags="-mcpu=$cpu"
4791             disable vsx
4792         ;;
4793         power[7-8]*)
4794             cpuflags="-mcpu=$cpu"
4795         ;;
4796         cell)
4797             cpuflags="-mcpu=cell"
4798             enable ldbrx
4799             disable vsx
4800         ;;
4801         e500mc)
4802             cpuflags="-mcpu=e500mc"
4803             disable altivec
4804         ;;
4805         e500v2)
4806             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
4807             disable altivec
4808             disable dcbzl
4809         ;;
4810         e500)
4811             cpuflags="-mcpu=8540 -mhard-float"
4812             disable altivec
4813             disable dcbzl
4814         ;;
4815     esac
4816
4817 elif enabled sparc; then
4818
4819     case $cpu in
4820         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
4821             cpuflags="-mcpu=$cpu"
4822         ;;
4823         ultrasparc*|niagara[234])
4824             cpuflags="-mcpu=$cpu"
4825         ;;
4826     esac
4827
4828 elif enabled x86; then
4829
4830     case $cpu in
4831         i[345]86|pentium)
4832             cpuflags="-march=$cpu"
4833             disable i686
4834             disable mmx
4835         ;;
4836         # targets that do NOT support nopl and conditional mov (cmov)
4837         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
4838             cpuflags="-march=$cpu"
4839             disable i686
4840         ;;
4841         # targets that do support nopl and conditional mov (cmov)
4842         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\
4843         |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|skylake*|knl\
4844         |amdfam10|barcelona|b[dt]ver*|znver*)
4845             cpuflags="-march=$cpu"
4846             enable i686
4847             enable fast_cmov
4848         ;;
4849         # targets that do support conditional mov but on which it's slow
4850         pentium4|pentium4m|prescott|nocona)
4851             cpuflags="-march=$cpu"
4852             enable i686
4853             disable fast_cmov
4854         ;;
4855     esac
4856
4857 fi
4858
4859 if [ "$cpu" != generic ]; then
4860     add_cflags  $cpuflags
4861     add_asflags $cpuflags
4862     test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
4863 fi
4864
4865 # compiler sanity check
4866 test_exec <<EOF
4867 int main(void){ return 0; }
4868 EOF
4869 if test "$?" != 0; then
4870     echo "$cc is unable to create an executable file."
4871     if test -z "$cross_prefix" && ! enabled cross_compile ; then
4872         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
4873         echo "Only do this if you know what cross compiling means."
4874     fi
4875     die "C compiler test failed."
4876 fi
4877
4878 add_cppflags -D_ISOC99_SOURCE
4879 add_cxxflags -D__STDC_CONSTANT_MACROS
4880 check_cxxflags -std=c++11 || check_cxxflags -std=c++0x
4881
4882 # some compilers silently accept -std=c11, so we also need to check that the
4883 # version macro is defined properly
4884 test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" &&
4885     add_cflags -std=c11 ||
4886     check_cflags -std=c99
4887
4888 check_cppflags -D_FILE_OFFSET_BITS=64
4889 check_cppflags -D_LARGEFILE_SOURCE
4890
4891 add_host_cppflags -D_ISOC99_SOURCE
4892 check_host_cflags -std=c99
4893 check_host_cflags -Wall
4894 check_host_cflags $host_cflags_speed
4895
4896 check_64bit(){
4897     arch32=$1
4898     arch64=$2
4899     expr=${3:-'sizeof(void *) > 4'}
4900     test_code cc "" "int test[2*($expr) - 1]" &&
4901         subarch=$arch64 || subarch=$arch32
4902     enable $subarch
4903 }
4904
4905 case "$arch" in
4906     aarch64|alpha|ia64)
4907         enabled shared && enable_weak pic
4908     ;;
4909     mips)
4910         check_64bit mips mip