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