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