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