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