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