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