]> git.sesse.net Git - ffmpeg/blob - configure
mips: add p5600 core optimizations
[ffmpeg] / 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-libaacplus      enable AAC+ encoding via libaacplus [no]
211   --enable-libass          enable libass subtitles rendering,
212                            needed for subtitles and ass filter [no]
213   --enable-libbluray       enable BluRay reading using libbluray [no]
214   --enable-libbs2b         enable bs2b DSP library [no]
215   --enable-libcaca         enable textual display using libcaca [no]
216   --enable-libcelt         enable CELT decoding via libcelt [no]
217   --enable-libcdio         enable audio CD grabbing with libcdio [no]
218   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
219                            and libraw1394 [no]
220   --enable-libdcadec       enable DCA decoding via libdcadec [no]
221   --enable-libfaac         enable AAC encoding via libfaac [no]
222   --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
223   --enable-libflite        enable flite (voice synthesis) support via libflite [no]
224   --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
225   --enable-libfribidi      enable libfribidi, improves drawtext filter [no]
226   --enable-libgme          enable Game Music Emu via libgme [no]
227   --enable-libgsm          enable GSM de/encoding via libgsm [no]
228   --enable-libiec61883     enable iec61883 via libiec61883 [no]
229   --enable-libilbc         enable iLBC de/encoding via libilbc [no]
230   --enable-libkvazaar      enable HEVC encoding via libkvazaar [no]
231   --enable-libmfx          enable HW acceleration through libmfx
232   --enable-libmodplug      enable ModPlug via libmodplug [no]
233   --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
234   --enable-libnut          enable NUT (de)muxing via libnut,
235                            native (de)muxer exists [no]
236   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
237   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
238   --enable-libopencv       enable video filtering via libopencv [no]
239   --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
240   --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
241   --enable-libopus         enable Opus de/encoding via libopus [no]
242   --enable-libpulse        enable Pulseaudio input via libpulse [no]
243   --enable-librubberband   enable rubberband needed for rubberband filter [no]
244   --enable-libquvi         enable quvi input via libquvi [no]
245   --enable-librtmp         enable RTMP[E] support via librtmp [no]
246   --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
247   --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
248   --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
249   --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
250   --enable-libsoxr         enable Include libsoxr resampling [no]
251   --enable-libspeex        enable Speex de/encoding via libspeex [no]
252   --enable-libssh          enable SFTP protocol via libssh [no]
253   --enable-libstagefright-h264  enable H.264 decoding via libstagefright [no]
254   --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
255   --enable-libtheora       enable Theora encoding via libtheora [no]
256   --enable-libtwolame      enable MP2 encoding via libtwolame [no]
257   --enable-libutvideo      enable Ut Video encoding and decoding via libutvideo [no]
258   --enable-libv4l2         enable libv4l2/v4l-utils [no]
259   --enable-libvidstab      enable video stabilization using vid.stab [no]
260   --enable-libvo-aacenc    enable AAC encoding via libvo-aacenc [no]
261   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
262   --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
263                            native implementation exists [no]
264   --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
265   --enable-libwavpack      enable wavpack encoding via libwavpack [no]
266   --enable-libwebp         enable WebP encoding via libwebp [no]
267   --enable-libx264         enable H.264 encoding via x264 [no]
268   --enable-libx265         enable HEVC encoding via x265 [no]
269   --enable-libxavs         enable AVS encoding via xavs [no]
270   --enable-libxcb          enable X11 grabbing using XCB [autodetect]
271   --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
272   --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
273   --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
274   --enable-libxvid         enable Xvid encoding via xvidcore,
275                            native MPEG-4/Xvid encoder exists [no]
276   --enable-libzimg         enable z.lib, needed for zscale filter [no]
277   --enable-libzmq          enable message passing via libzmq [no]
278   --enable-libzvbi         enable teletext support via libzvbi [no]
279   --disable-lzma           disable lzma [autodetect]
280   --enable-decklink        enable Blackmagic DeckLink I/O support [no]
281   --enable-mmal            enable decoding via MMAL [no]
282   --enable-nvenc           enable NVIDIA NVENC support [no]
283   --enable-openal          enable OpenAL 1.1 capture support [no]
284   --enable-opencl          enable OpenCL code
285   --enable-opengl          enable OpenGL rendering [no]
286   --enable-openssl         enable openssl, needed for https support
287                            if gnutls is not used [no]
288   --disable-schannel       disable SChannel SSP, needed for TLS support on
289                            Windows if openssl and gnutls are not used [autodetect]
290   --disable-sdl            disable sdl [autodetect]
291   --disable-securetransport disable Secure Transport, needed for TLS support
292                            on OSX if openssl and gnutls are not used [autodetect]
293   --enable-x11grab         enable X11 grabbing (legacy) [no]
294   --disable-xlib           disable xlib [autodetect]
295   --disable-zlib           disable zlib [autodetect]
296
297 Toolchain options:
298   --arch=ARCH              select architecture [$arch]
299   --cpu=CPU                select the minimum required CPU (affects
300                            instruction selection, may crash on older CPUs)
301   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
302   --progs-suffix=SUFFIX    program name suffix []
303   --enable-cross-compile   assume a cross-compiler is used
304   --sysroot=PATH           root of cross-build tree
305   --sysinclude=PATH        location of cross-build system headers
306   --target-os=OS           compiler targets OS [$target_os]
307   --target-exec=CMD        command to run executables on target
308   --target-path=DIR        path to view of build directory on target
309   --target-samples=DIR     path to samples directory on target
310   --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
311   --toolchain=NAME         set tool defaults according to NAME
312   --nm=NM                  use nm tool NM [$nm_default]
313   --ar=AR                  use archive tool AR [$ar_default]
314   --as=AS                  use assembler AS [$as_default]
315   --windres=WINDRES        use windows resource compiler WINDRES [$windres_default]
316   --yasmexe=EXE            use yasm-compatible assembler EXE [$yasmexe_default]
317   --cc=CC                  use C compiler CC [$cc_default]
318   --cxx=CXX                use C compiler CXX [$cxx_default]
319   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
320   --ld=LD                  use linker LD [$ld_default]
321   --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
322   --pkg-config-flags=FLAGS pass additional flags to pkgconf []
323   --ranlib=RANLIB          use ranlib RANLIB [$ranlib_default]
324   --doxygen=DOXYGEN        use DOXYGEN to generate API doc [$doxygen_default]
325   --host-cc=HOSTCC         use host C compiler HOSTCC
326   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
327   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
328   --host-ld=HOSTLD         use host linker HOSTLD
329   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
330   --host-libs=HLIBS        use libs HLIBS when linking for host
331   --host-os=OS             compiler host OS [$target_os]
332   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
333   --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
334   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
335   --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
336   --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS]
337   --extra-libs=ELIBS       add ELIBS [$ELIBS]
338   --extra-version=STRING   version string suffix []
339   --optflags=OPTFLAGS      override optimization-related compiler flags
340   --build-suffix=SUFFIX    library name suffix []
341   --enable-pic             build position-independent code
342   --enable-thumb           compile for Thumb instruction set
343   --enable-lto             use link-time optimization
344   --env="ENV=override"     override the environment variables
345
346 Advanced options (experts only):
347   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
348   --custom-allocator=NAME  use a supported custom allocator
349   --disable-symver         disable symbol versioning
350   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
351   --disable-safe-bitstream-reader
352                            disable buffer boundary checking in bitreaders
353                            (faster, but may crash)
354   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
355   --sws-max-filter-size=N  the max filter size swscale uses [$sws_max_filter_size_default]
356
357 Optimization options (experts only):
358   --disable-asm            disable all assembly optimizations
359   --disable-altivec        disable AltiVec optimizations
360   --disable-vsx            disable VSX optimizations
361   --disable-power8         disable POWER8 optimizations
362   --disable-amd3dnow       disable 3DNow! optimizations
363   --disable-amd3dnowext    disable 3DNow! extended optimizations
364   --disable-mmx            disable MMX optimizations
365   --disable-mmxext         disable MMXEXT optimizations
366   --disable-sse            disable SSE optimizations
367   --disable-sse2           disable SSE2 optimizations
368   --disable-sse3           disable SSE3 optimizations
369   --disable-ssse3          disable SSSE3 optimizations
370   --disable-sse4           disable SSE4 optimizations
371   --disable-sse42          disable SSE4.2 optimizations
372   --disable-avx            disable AVX optimizations
373   --disable-xop            disable XOP optimizations
374   --disable-fma3           disable FMA3 optimizations
375   --disable-fma4           disable FMA4 optimizations
376   --disable-avx2           disable AVX2 optimizations
377   --disable-aesni          disable AESNI optimizations
378   --disable-armv5te        disable armv5te optimizations
379   --disable-armv6          disable armv6 optimizations
380   --disable-armv6t2        disable armv6t2 optimizations
381   --disable-vfp            disable VFP optimizations
382   --disable-neon           disable NEON optimizations
383   --disable-inline-asm     disable use of inline assembly
384   --disable-yasm           disable use of nasm/yasm assembly
385   --disable-mips64r6       disable MIPS64R6 optimizations
386   --disable-mipsdsp        disable MIPS DSP ASE R1 optimizations
387   --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
388   --disable-msa            disable MSA optimizations
389   --disable-mipsfpu        disable floating point MIPS optimizations
390   --disable-mmi            disable Loongson SIMD optimizations
391   --disable-fast-unaligned consider unaligned accesses slow
392
393 Developer options (useful when working on FFmpeg itself):
394   --disable-debug          disable debugging symbols
395   --enable-debug=LEVEL     set the debug level [$debuglevel]
396   --disable-optimizations  disable compiler optimizations
397   --enable-extra-warnings  enable more compiler warnings
398   --disable-stripping      disable stripping of executables and shared libraries
399   --assert-level=level     0(default), 1 or 2, amount of assertion testing,
400                            2 causes a slowdown at runtime.
401   --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
402   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
403                            leaks and errors, using the specified valgrind binary.
404                            Cannot be combined with --target-exec
405   --enable-ftrapv          Trap arithmetic overflows
406   --samples=PATH           location of test samples for FATE, if not set use
407                            \$FATE_SAMPLES at make invocation time.
408   --enable-neon-clobber-test check NEON registers for clobbering (should be
409                            used only for debugging purposes)
410   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
411                            should be used only for debugging purposes)
412   --enable-random          randomly enable/disable components
413   --disable-random
414   --enable-random=LIST     randomly enable/disable specific components or
415   --disable-random=LIST    component groups. LIST is a comma-separated list
416                            of NAME[:PROB] entries where NAME is a component
417                            (group) and PROB the probability associated with
418                            NAME (default 0.5).
419   --random-seed=VALUE      seed value for --enable/disable-random
420   --disable-valgrind-backtrace do not print a backtrace under Valgrind
421                            (only applies to --disable-optimizations builds)
422
423 NOTE: Object files are built at the place where configure is launched.
424 EOF
425   exit 0
426 }
427
428 quotes='""'
429 if test -t 1 && which tput >/dev/null 2>&1; then
430     ncolors=$(tput colors)
431     if test -n "$ncolors" && test $ncolors -ge 8; then
432         bold_color=$(tput bold)
433         warn_color=$(tput setaf 3)
434         error_color=$(tput setaf 1)
435         reset_color=$(tput sgr0)
436     fi
437     # 72 used instead of 80 since that's the default of pr
438     ncols=$(tput cols)
439 fi
440 : ${ncols:=72}
441
442 log(){
443     echo "$@" >> $logfile
444 }
445
446 log_file(){
447     log BEGIN $1
448     pr -n -t $1 >> $logfile
449     log END $1
450 }
451
452 warn(){
453     log "WARNING: $*"
454     WARNINGS="${WARNINGS}WARNING: $*\n"
455 }
456
457 die(){
458     log "$@"
459     echo "$error_color$bold_color$@$reset_color"
460     cat <<EOF
461
462 If you think configure made a mistake, make sure you are using the latest
463 version from Git.  If the latest version fails, report the problem to the
464 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
465 EOF
466     if disabled logging; then
467         cat <<EOF
468 Rerun configure with logging enabled (do not use --disable-logging), and
469 include the log this produces with your report.
470 EOF
471     else
472         cat <<EOF
473 Include the log file "$logfile" produced by configure as this will help
474 solve the problem.
475 EOF
476     fi
477     exit 1
478 }
479
480 # Avoid locale weirdness, besides we really just want to translate ASCII.
481 toupper(){
482     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
483 }
484
485 tolower(){
486     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
487 }
488
489 c_escape(){
490     echo "$*" | sed 's/["\\]/\\\0/g'
491 }
492
493 sh_quote(){
494     v=$(echo "$1" | sed "s/'/'\\\\''/g")
495     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
496     echo "$v"
497 }
498
499 cleanws(){
500     echo "$@" | sed 's/^ *//;s/[[:space:]][[:space:]]*/ /g;s/ *$//'
501 }
502
503 filter(){
504     pat=$1
505     shift
506     for v; do
507         eval "case $v in $pat) echo $v ;; esac"
508     done
509 }
510
511 filter_out(){
512     pat=$1
513     shift
514     for v; do
515         eval "case $v in $pat) ;; *) echo $v ;; esac"
516     done
517 }
518
519 map(){
520     m=$1
521     shift
522     for v; do eval $m; done
523 }
524
525 add_suffix(){
526     suffix=$1
527     shift
528     for v; do echo ${v}${suffix}; done
529 }
530
531 set_all(){
532     value=$1
533     shift
534     for var in $*; do
535         eval $var=$value
536     done
537 }
538
539 set_weak(){
540     value=$1
541     shift
542     for var; do
543         eval : \${$var:=$value}
544     done
545 }
546
547 sanitize_var_name(){
548     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
549 }
550
551 set_safe(){
552     var=$1
553     shift
554     eval $(sanitize_var_name "$var")='$*'
555 }
556
557 get_safe(){
558     eval echo \$$(sanitize_var_name "$1")
559 }
560
561 pushvar(){
562     for pvar in $*; do
563         eval level=\${${pvar}_level:=0}
564         eval ${pvar}_${level}="\$$pvar"
565         eval ${pvar}_level=$(($level+1))
566     done
567 }
568
569 popvar(){
570     for pvar in $*; do
571         eval level=\${${pvar}_level:-0}
572         test $level = 0 && continue
573         eval level=$(($level-1))
574         eval $pvar="\${${pvar}_${level}}"
575         eval ${pvar}_level=$level
576         eval unset ${pvar}_${level}
577     done
578 }
579
580 enable(){
581     set_all yes $*
582 }
583
584 disable(){
585     set_all no $*
586 }
587
588 enable_weak(){
589     set_weak yes $*
590 }
591
592 disable_weak(){
593     set_weak no $*
594 }
595
596 enable_safe(){
597     for var; do
598         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
599     done
600 }
601
602 disable_safe(){
603     for var; do
604         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
605     done
606 }
607
608 do_enable_deep(){
609     for var; do
610         enabled $var && continue
611         eval sel="\$${var}_select"
612         eval sgs="\$${var}_suggest"
613         pushvar var sgs
614         enable_deep $sel
615         popvar sgs
616         enable_deep_weak $sgs
617         popvar var
618     done
619 }
620
621 enable_deep(){
622     do_enable_deep $*
623     enable $*
624 }
625
626 enable_deep_weak(){
627     for var; do
628         disabled $var && continue
629         pushvar var
630         do_enable_deep $var
631         popvar var
632         enable_weak $var
633     done
634 }
635
636 enabled(){
637     test "${1#!}" = "$1" && op='=' || op=!=
638     eval test "x\$${1#!}" $op "xyes"
639 }
640
641 disabled(){
642     test "${1#!}" = "$1" && op='=' || op=!=
643     eval test "x\$${1#!}" $op "xno"
644 }
645
646 enabled_all(){
647     for opt; do
648         enabled $opt || return 1
649     done
650 }
651
652 disabled_all(){
653     for opt; do
654         disabled $opt || return 1
655     done
656 }
657
658 enabled_any(){
659     for opt; do
660         enabled $opt && return 0
661     done
662 }
663
664 disabled_any(){
665     for opt; do
666         disabled $opt && return 0
667     done
668     return 1
669 }
670
671 set_default(){
672     for opt; do
673         eval : \${$opt:=\$${opt}_default}
674     done
675 }
676
677 is_in(){
678     value=$1
679     shift
680     for var in $*; do
681         [ $var = $value ] && return 0
682     done
683     return 1
684 }
685
686 do_check_deps(){
687     for cfg; do
688         cfg="${cfg#!}"
689         enabled ${cfg}_checking && die "Circular dependency for $cfg."
690         disabled ${cfg}_checking && continue
691         enable ${cfg}_checking
692         append allopts $cfg
693
694         eval dep_all="\$${cfg}_deps"
695         eval dep_any="\$${cfg}_deps_any"
696         eval dep_sel="\$${cfg}_select"
697         eval dep_sgs="\$${cfg}_suggest"
698         eval dep_ifa="\$${cfg}_if"
699         eval dep_ifn="\$${cfg}_if_any"
700
701         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
702         do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
703         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
704
705         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
706         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
707         enabled_all  $dep_all || disable $cfg
708         enabled_any  $dep_any || disable $cfg
709         disabled_any $dep_sel && disable $cfg
710
711         if enabled $cfg; then
712             enable_deep $dep_sel
713             enable_deep_weak $dep_sgs
714         fi
715
716         disable ${cfg}_checking
717     done
718 }
719
720 check_deps(){
721     unset allopts
722
723     do_check_deps "$@"
724
725     for cfg in $allopts; do
726         enabled $cfg || continue
727         eval dep_extralibs="\$${cfg}_extralibs"
728         test -n "$dep_extralibs" && add_extralibs $dep_extralibs
729     done
730 }
731
732 print_config(){
733     pfx=$1
734     files=$2
735     shift 2
736     map 'eval echo "$v \${$v:-no}"' "$@" |
737     awk "BEGIN { split(\"$files\", files) }
738         {
739             c = \"$pfx\" toupper(\$1);
740             v = \$2;
741             sub(/yes/, 1, v);
742             sub(/no/,  0, v);
743             for (f in files) {
744                 file = files[f];
745                 if (file ~ /\\.h\$/) {
746                     printf(\"#define %s %d\\n\", c, v) >>file;
747                 } else if (file ~ /\\.asm\$/) {
748                     printf(\"%%define %s %d\\n\", c, v) >>file;
749                 } else if (file ~ /\\.mak\$/) {
750                     n = -v ? \"\" : \"!\";
751                     printf(\"%s%s=yes\\n\", n, c) >>file;
752                 } else if (file ~ /\\.texi\$/) {
753                     pre = -v ? \"\" : \"@c \";
754                     yesno = \$2;
755                     c2 = tolower(c);
756                     gsub(/_/, \"-\", c2);
757                     printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file;
758                 }
759             }
760         }"
761 }
762
763 print_enabled(){
764     suf=$1
765     shift
766     for v; do
767         enabled $v && printf "%s\n" ${v%$suf};
768     done
769 }
770
771 append(){
772     var=$1
773     shift
774     eval "$var=\"\$$var $*\""
775 }
776
777 prepend(){
778     var=$1
779     shift
780     eval "$var=\"$* \$$var\""
781 }
782
783 unique(){
784     var=$1
785     uniq_list=""
786     for tok in $(eval echo \$$var); do
787         uniq_list="$(filter_out $tok $uniq_list) $tok"
788     done
789     eval "$var=\"${uniq_list}\""
790 }
791
792 add_cppflags(){
793     append CPPFLAGS "$@"
794 }
795
796 add_cflags(){
797     append CFLAGS $($cflags_filter "$@")
798 }
799
800 add_cxxflags(){
801     append CXXFLAGS $($cflags_filter "$@")
802 }
803
804 add_asflags(){
805     append ASFLAGS $($asflags_filter "$@")
806 }
807
808 add_ldflags(){
809     append LDFLAGS $($ldflags_filter "$@")
810 }
811
812 add_ldexeflags(){
813     append LDEXEFLAGS $($ldflags_filter "$@")
814 }
815
816 add_ldlibflags(){
817     append LDLIBFLAGS $($ldflags_filter "$@")
818 }
819
820 add_stripflags(){
821     append ASMSTRIPFLAGS "$@"
822 }
823
824 add_extralibs(){
825     prepend extralibs $($ldflags_filter "$@")
826 }
827
828 add_host_cppflags(){
829     append host_cppflags "$@"
830 }
831
832 add_host_cflags(){
833     append host_cflags $($host_cflags_filter "$@")
834 }
835
836 add_host_ldflags(){
837     append host_ldflags $($host_ldflags_filter "$@")
838 }
839
840 add_compat(){
841     append compat_objs $1
842     shift
843     map 'add_cppflags -D$v' "$@"
844 }
845
846 check_cmd(){
847     log "$@"
848     "$@" >> $logfile 2>&1
849 }
850
851 check_stat(){
852     log check_stat "$@"
853     stat "$1" >> $logfile 2>&1
854 }
855
856 cc_o(){
857     eval printf '%s\\n' $CC_O
858 }
859
860 cc_e(){
861     eval printf '%s\\n' $CC_E
862 }
863
864 check_cc(){
865     log check_cc "$@"
866     cat > $TMPC
867     log_file $TMPC
868     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
869 }
870
871 check_cxx(){
872     log check_cxx "$@"
873     cat > $TMPCPP
874     log_file $TMPCPP
875     check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP
876 }
877
878 check_oc(){
879     log check_oc "$@"
880     cat > $TMPM
881     log_file $TMPM
882     check_cmd $cc -Werror=missing-prototypes $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPM
883 }
884
885 check_cpp(){
886     log check_cpp "$@"
887     cat > $TMPC
888     log_file $TMPC
889     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
890 }
891
892 as_o(){
893     eval printf '%s\\n' $AS_O
894 }
895
896 check_as(){
897     log check_as "$@"
898     cat > $TMPS
899     log_file $TMPS
900     check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
901 }
902
903 check_inline_asm(){
904     log check_inline_asm "$@"
905     name="$1"
906     code="$2"
907     shift 2
908     disable $name
909     check_cc "$@" <<EOF && enable $name
910 void foo(void){ __asm__ volatile($code); }
911 EOF
912 }
913
914 check_insn(){
915     log check_insn "$@"
916     check_inline_asm ${1}_inline "\"$2\""
917     echo "$2" | check_as && enable ${1}_external || disable ${1}_external
918 }
919
920 check_yasm(){
921     log check_yasm "$@"
922     echo "$1" > $TMPS
923     log_file $TMPS
924     shift 1
925     check_cmd $yasmexe $YASMFLAGS -Werror "$@" -o $TMPO $TMPS
926 }
927
928 ld_o(){
929     eval printf '%s\\n' $LD_O
930 }
931
932 check_ld(){
933     log check_ld "$@"
934     type=$1
935     shift 1
936     flags=$(filter_out '-l*|*.so' $@)
937     libs=$(filter '-l*|*.so' $@)
938     check_$type $($cflags_filter $flags) || return
939     flags=$($ldflags_filter $flags)
940     libs=$($ldflags_filter $libs)
941     check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
942 }
943
944 print_include(){
945     hdr=$1
946     test "${hdr%.h}" = "${hdr}" &&
947         echo "#include $hdr"    ||
948         echo "#include <$hdr>"
949 }
950
951 check_code(){
952     log check_code "$@"
953     check=$1
954     headers=$2
955     code=$3
956     shift 3
957     {
958         for hdr in $headers; do
959             print_include $hdr
960         done
961         echo "int main(void) { $code; return 0; }"
962     } | check_$check "$@"
963 }
964
965 check_cppflags(){
966     log check_cppflags "$@"
967     check_cc "$@" <<EOF && append CPPFLAGS "$@"
968 int x;
969 EOF
970 }
971
972 test_cflags(){
973     log test_cflags "$@"
974     set -- $($cflags_filter "$@")
975     check_cc "$@" <<EOF
976 int x;
977 EOF
978 }
979
980 check_cflags(){
981     log check_cflags "$@"
982     test_cflags "$@" && add_cflags "$@"
983 }
984
985 check_cxxflags(){
986     log check_cxxflags "$@"
987     set -- $($cflags_filter "$@")
988     check_cxx "$@" <<EOF && append CXXFLAGS "$@"
989 int x;
990 EOF
991 }
992
993 test_ldflags(){
994     log test_ldflags "$@"
995     check_ld "cc" "$@" <<EOF
996 int main(void){ return 0; }
997 EOF
998 }
999
1000 check_ldflags(){
1001     log check_ldflags "$@"
1002     test_ldflags "$@" && add_ldflags "$@"
1003 }
1004
1005 test_stripflags(){
1006     log test_stripflags "$@"
1007     # call check_cc to get a fresh TMPO
1008     check_cc <<EOF
1009 int main(void) { return 0; }
1010 EOF
1011     check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
1012 }
1013
1014 check_stripflags(){
1015     log check_stripflags "$@"
1016     test_stripflags "$@" && add_stripflags "$@"
1017 }
1018
1019 check_header(){
1020     log check_header "$@"
1021     header=$1
1022     shift
1023     disable_safe $header
1024     check_cpp "$@" <<EOF && enable_safe $header
1025 #include <$header>
1026 int x;
1027 EOF
1028 }
1029
1030 check_header_oc(){
1031     log check_header_oc "$@"
1032     rm -f -- "$TMPO"
1033     header=$1
1034     shift
1035     disable_safe $header
1036     {
1037        echo "#include <$header>"
1038        echo "int main(void) { return 0; }"
1039     } | check_oc && check_stat "$TMPO" && enable_safe $headers
1040 }
1041
1042 check_func(){
1043     log check_func "$@"
1044     func=$1
1045     shift
1046     disable $func
1047     check_ld "cc" "$@" <<EOF && enable $func
1048 extern int $func();
1049 int main(void){ $func(); }
1050 EOF
1051 }
1052
1053 check_complexfunc(){
1054     log check_complexfunc "$@"
1055     func=$1
1056     narg=$2
1057     shift 2
1058     test $narg = 2 && args="f, g" || args="f * I"
1059     disable $func
1060     check_ld "cc" "$@" <<EOF && enable $func
1061 #include <complex.h>
1062 #include <math.h>
1063 float foo(complex float f, complex float g) { return $func($args); }
1064 int main(void){ return (int) foo; }
1065 EOF
1066 }
1067
1068 check_mathfunc(){
1069     log check_mathfunc "$@"
1070     func=$1
1071     narg=$2
1072     shift 2
1073     test $narg = 2 && args="f, g" || args="f"
1074     disable $func
1075     check_ld "cc" "$@" <<EOF && enable $func
1076 #include <math.h>
1077 float foo(float f, float g) { return $func($args); }
1078 int main(void){ return (int) foo; }
1079 EOF
1080 }
1081
1082 check_func_headers(){
1083     log check_func_headers "$@"
1084     headers=$1
1085     funcs=$2
1086     shift 2
1087     {
1088         for hdr in $headers; do
1089             print_include $hdr
1090         done
1091         for func in $funcs; do
1092             echo "long check_$func(void) { return (long) $func; }"
1093         done
1094         echo "int main(void) { return 0; }"
1095     } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
1096 }
1097
1098 check_class_headers_cpp(){
1099     log check_class_headers_cpp "$@"
1100     headers=$1
1101     classes=$2
1102     shift 2
1103     {
1104         for hdr in $headers; do
1105             echo "#include <$hdr>"
1106         done
1107         echo "int main(void) { "
1108         i=1
1109         for class in $classes; do
1110             echo "$class obj$i;"
1111             i=$(expr $i + 1)
1112         done
1113         echo "return 0; }"
1114     } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
1115 }
1116
1117 check_cpp_condition(){
1118     log check_cpp_condition "$@"
1119     header=$1
1120     condition=$2
1121     shift 2
1122     check_cpp "$@" <<EOF
1123 #include <$header>
1124 #if !($condition)
1125 #error "unsatisfied condition: $condition"
1126 #endif
1127 EOF
1128 }
1129
1130 check_lib(){
1131     log check_lib "$@"
1132     header="$1"
1133     func="$2"
1134     shift 2
1135     check_header $header && check_func $func "$@" && add_extralibs "$@"
1136 }
1137
1138 check_lib2(){
1139     log check_lib2 "$@"
1140     headers="$1"
1141     funcs="$2"
1142     shift 2
1143     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
1144 }
1145
1146 check_lib_cpp(){
1147     log check_lib_cpp "$@"
1148     headers="$1"
1149     classes="$2"
1150     shift 2
1151     check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
1152 }
1153
1154 check_pkg_config(){
1155     log check_pkg_config "$@"
1156     pkgandversion="$1"
1157     pkg="${1%% *}"
1158     headers="$2"
1159     funcs="$3"
1160     shift 3
1161     check_cmd $pkg_config --exists --print-errors $pkgandversion || return
1162     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1163     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1164     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1165         set_safe "${pkg}_cflags" $pkg_cflags   &&
1166         set_safe "${pkg}_libs"   $pkg_libs
1167 }
1168
1169 check_exec(){
1170     check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1171 }
1172
1173 check_exec_crash(){
1174     code=$(cat)
1175
1176     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1177     # are safe but may not be available everywhere.  Thus we use
1178     # raise(SIGTERM) instead.  The check is run in a subshell so we
1179     # can redirect the "Terminated" message from the shell.  SIGBUS
1180     # is not defined by standard C so it is used conditionally.
1181
1182     (check_exec "$@") >> $logfile 2>&1 <<EOF
1183 #include <signal.h>
1184 static void sighandler(int sig){
1185     raise(SIGTERM);
1186 }
1187 int foo(void){
1188     $code
1189 }
1190 int (*func_ptr)(void) = foo;
1191 int main(void){
1192     signal(SIGILL, sighandler);
1193     signal(SIGFPE, sighandler);
1194     signal(SIGSEGV, sighandler);
1195 #ifdef SIGBUS
1196     signal(SIGBUS, sighandler);
1197 #endif
1198     return func_ptr();
1199 }
1200 EOF
1201 }
1202
1203 check_type(){
1204     log check_type "$@"
1205     headers=$1
1206     type=$2
1207     shift 2
1208     disable_safe "$type"
1209     check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
1210 }
1211
1212 check_struct(){
1213     log check_struct "$@"
1214     headers=$1
1215     struct=$2
1216     member=$3
1217     shift 3
1218     disable_safe "${struct}_${member}"
1219     check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1220         enable_safe "${struct}_${member}"
1221 }
1222
1223 check_builtin(){
1224     log check_builtin "$@"
1225     name=$1
1226     headers=$2
1227     builtin=$3
1228     shift 3
1229     disable "$name"
1230     check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
1231 }
1232
1233 check_compile_assert(){
1234     log check_compile_assert "$@"
1235     name=$1
1236     headers=$2
1237     condition=$3
1238     shift 3
1239     disable "$name"
1240     check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1241 }
1242
1243 require(){
1244     name="$1"
1245     header="$2"
1246     func="$3"
1247     shift 3
1248     check_lib $header $func "$@" || die "ERROR: $name not found"
1249 }
1250
1251 require2(){
1252     name="$1"
1253     headers="$2"
1254     func="$3"
1255     shift 3
1256     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1257 }
1258
1259 require_cpp(){
1260     name="$1"
1261     headers="$2"
1262     classes="$3"
1263     shift 3
1264     check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
1265 }
1266
1267 use_pkg_config(){
1268     pkg="$1"
1269     check_pkg_config "$@" || return 1
1270     add_cflags    $(get_safe "${pkg}_cflags")
1271     add_extralibs $(get_safe "${pkg}_libs")
1272 }
1273
1274 require_pkg_config(){
1275     use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message"
1276 }
1277
1278 require_libfreetype(){
1279     log require_libfreetype "$@"
1280     pkg="freetype2"
1281     check_cmd $pkg_config --exists --print-errors $pkg \
1282       || die "ERROR: $pkg not found"
1283     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1284     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1285     {
1286         echo "#include <ft2build.h>"
1287         echo "#include FT_FREETYPE_H"
1288         echo "long check_func(void) { return (long) FT_Init_FreeType; }"
1289         echo "int main(void) { return 0; }"
1290     } | check_ld "cc" $pkg_cflags $pkg_libs \
1291       && set_safe "${pkg}_cflags" $pkg_cflags \
1292       && set_safe "${pkg}_libs"   $pkg_libs \
1293       || die "ERROR: $pkg not found"
1294     add_cflags    $(get_safe "${pkg}_cflags")
1295     add_extralibs $(get_safe "${pkg}_libs")
1296 }
1297
1298 hostcc_e(){
1299     eval printf '%s\\n' $HOSTCC_E
1300 }
1301
1302 hostcc_o(){
1303     eval printf '%s\\n' $HOSTCC_O
1304 }
1305
1306 check_host_cc(){
1307     log check_host_cc "$@"
1308     cat > $TMPC
1309     log_file $TMPC
1310     check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1311 }
1312
1313 check_host_cpp(){
1314     log check_host_cpp "$@"
1315     cat > $TMPC
1316     log_file $TMPC
1317     check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1318 }
1319
1320 check_host_cppflags(){
1321     log check_host_cppflags "$@"
1322     check_host_cc "$@" <<EOF && append host_cppflags "$@"
1323 int x;
1324 EOF
1325 }
1326
1327 check_host_cflags(){
1328     log check_host_cflags "$@"
1329     set -- $($host_cflags_filter "$@")
1330     check_host_cc "$@" <<EOF && append host_cflags "$@"
1331 int x;
1332 EOF
1333 }
1334
1335 check_host_cpp_condition(){
1336     log check_host_cpp_condition "$@"
1337     header=$1
1338     condition=$2
1339     shift 2
1340     check_host_cpp "$@" <<EOF
1341 #include <$header>
1342 #if !($condition)
1343 #error "unsatisfied condition: $condition"
1344 #endif
1345 EOF
1346 }
1347
1348 cp_if_changed(){
1349     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1350     mkdir -p "$(dirname $2)"
1351     $cp_f "$1" "$2"
1352 }
1353
1354 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1355 # system-dependent things.
1356
1357 AVCODEC_COMPONENTS="
1358     bsfs
1359     decoders
1360     encoders
1361     hwaccels
1362     parsers
1363 "
1364
1365 AVDEVICE_COMPONENTS="
1366     indevs
1367     outdevs
1368 "
1369 AVFILTER_COMPONENTS="
1370     filters
1371 "
1372 AVFORMAT_COMPONENTS="
1373     demuxers
1374     muxers
1375     protocols
1376 "
1377
1378 AVRESAMPLE_COMPONENTS=""
1379 AVUTIL_COMPONENTS=""
1380
1381 COMPONENT_LIST="
1382     $AVCODEC_COMPONENTS
1383     $AVDEVICE_COMPONENTS
1384     $AVFILTER_COMPONENTS
1385     $AVFORMAT_COMPONENTS
1386     $AVRESAMPLE_COMPONENTS
1387     $AVUTIL_COMPONENTS
1388 "
1389
1390 EXAMPLE_LIST="
1391     avio_reading_example
1392     avio_dir_cmd_example
1393     decoding_encoding_example
1394     demuxing_decoding_example
1395     extract_mvs_example
1396     filter_audio_example
1397     filtering_audio_example
1398     filtering_video_example
1399     metadata_example
1400     muxing_example
1401     qsvdec_example
1402     remuxing_example
1403     resampling_audio_example
1404     scaling_video_example
1405     transcode_aac_example
1406     transcoding_example
1407 "
1408
1409 EXTERNAL_LIBRARY_LIST="
1410     avisynth
1411     bzlib
1412     chromaprint
1413     crystalhd
1414     decklink
1415     frei0r
1416     gcrypt
1417     gmp
1418     gnutls
1419     iconv
1420     ladspa
1421     libaacplus
1422     libass
1423     libbluray
1424     libbs2b
1425     libcaca
1426     libcdio
1427     libcelt
1428     libdc1394
1429     libdcadec
1430     libfaac
1431     libfdk_aac
1432     libflite
1433     libfontconfig
1434     libfreetype
1435     libfribidi
1436     libgme
1437     libgsm
1438     libiec61883
1439     libilbc
1440     libkvazaar
1441     libmfx
1442     libmodplug
1443     libmp3lame
1444     libnut
1445     libopencore_amrnb
1446     libopencore_amrwb
1447     libopencv
1448     libopenh264
1449     libopenjpeg
1450     libopus
1451     libpulse
1452     libquvi
1453     librtmp
1454     librubberband
1455     libschroedinger
1456     libshine
1457     libsmbclient
1458     libsnappy
1459     libsoxr
1460     libspeex
1461     libssh
1462     libstagefright_h264
1463     libtesseract
1464     libtheora
1465     libtwolame
1466     libutvideo
1467     libv4l2
1468     libvidstab
1469     libvo_aacenc
1470     libvo_amrwbenc
1471     libvorbis
1472     libvpx
1473     libwavpack
1474     libwebp
1475     libx264
1476     libx265
1477     libxavs
1478     libxcb
1479     libxcb_shm
1480     libxcb_shape
1481     libxcb_xfixes
1482     libxvid
1483     libzimg
1484     libzmq
1485     libzvbi
1486     lzma
1487     mmal
1488     nvenc
1489     openal
1490     opencl
1491     opengl
1492     openssl
1493     schannel
1494     sdl
1495     securetransport
1496     x11grab
1497     xlib
1498     zlib
1499 "
1500
1501 DOCUMENT_LIST="
1502     doc
1503     htmlpages
1504     manpages
1505     podpages
1506     txtpages
1507 "
1508
1509 FEATURE_LIST="
1510     ftrapv
1511     gray
1512     hardcoded_tables
1513     runtime_cpudetect
1514     safe_bitstream_reader
1515     shared
1516     small
1517     static
1518     swscale_alpha
1519 "
1520
1521 HWACCEL_LIST="
1522     d3d11va
1523     dxva2
1524     vaapi
1525     vda
1526     vdpau
1527     videotoolbox
1528     xvmc
1529 "
1530
1531 LIBRARY_LIST="
1532     avcodec
1533     avdevice
1534     avfilter
1535     avformat
1536     avresample
1537     avutil
1538     postproc
1539     swresample
1540     swscale
1541 "
1542
1543 LICENSE_LIST="
1544     gpl
1545     nonfree
1546     version3
1547 "
1548
1549 PROGRAM_LIST="
1550     ffplay
1551     ffprobe
1552     ffserver
1553     ffmpeg
1554 "
1555
1556 SUBSYSTEM_LIST="
1557     dct
1558     dwt
1559     error_resilience
1560     faan
1561     fast_unaligned
1562     fft
1563     lsp
1564     lzo
1565     mdct
1566     pixelutils
1567     network
1568     rdft
1569 "
1570
1571 CONFIG_LIST="
1572     $COMPONENT_LIST
1573     $DOCUMENT_LIST
1574     $EXAMPLE_LIST
1575     $EXTERNAL_LIBRARY_LIST
1576     $FEATURE_LIST
1577     $HWACCEL_LIST
1578     $LICENSE_LIST
1579     $LIBRARY_LIST
1580     $PROGRAM_LIST
1581     $SUBSYSTEM_LIST
1582     fontconfig
1583     incompatible_libav_abi
1584     memalign_hack
1585     memory_poisoning
1586     neon_clobber_test
1587     pic
1588     pod2man
1589     raise_major
1590     thumb
1591     valgrind_backtrace
1592     xmm_clobber_test
1593 "
1594
1595 THREADS_LIST="
1596     pthreads
1597     os2threads
1598     w32threads
1599 "
1600
1601 ATOMICS_LIST="
1602     atomics_gcc
1603     atomics_suncc
1604     atomics_win32
1605 "
1606
1607 ARCH_LIST="
1608     aarch64
1609     alpha
1610     arm
1611     avr32
1612     avr32_ap
1613     avr32_uc
1614     bfin
1615     ia64
1616     m68k
1617     mips
1618     mips64
1619     parisc
1620     ppc
1621     ppc64
1622     s390
1623     sh4
1624     sparc
1625     sparc64
1626     tilegx
1627     tilepro
1628     tomi
1629     x86
1630     x86_32
1631     x86_64
1632 "
1633
1634 ARCH_EXT_LIST_ARM="
1635     armv5te
1636     armv6
1637     armv6t2
1638     armv8
1639     neon
1640     vfp
1641     vfpv3
1642     setend
1643 "
1644
1645 ARCH_EXT_LIST_MIPS="
1646     mipsfpu
1647     mips32r2
1648     mips64r6
1649     mipsdsp
1650     mipsdspr2
1651     msa
1652 "
1653
1654 ARCH_EXT_LIST_LOONGSON="
1655     loongson2
1656     loongson3
1657     mmi
1658 "
1659
1660 ARCH_EXT_LIST_X86_SIMD="
1661     aesni
1662     amd3dnow
1663     amd3dnowext
1664     avx
1665     avx2
1666     fma3
1667     fma4
1668     mmx
1669     mmxext
1670     sse
1671     sse2
1672     sse3
1673     sse4
1674     sse42
1675     ssse3
1676     xop
1677 "
1678
1679 ARCH_EXT_LIST_PPC="
1680     altivec
1681     dcbzl
1682     ldbrx
1683     power8
1684     ppc4xx
1685     vsx
1686 "
1687
1688 ARCH_EXT_LIST_X86="
1689     $ARCH_EXT_LIST_X86_SIMD
1690     cpunop
1691     i686
1692 "
1693
1694 ARCH_EXT_LIST="
1695     $ARCH_EXT_LIST_ARM
1696     $ARCH_EXT_LIST_PPC
1697     $ARCH_EXT_LIST_X86
1698     $ARCH_EXT_LIST_MIPS
1699     $ARCH_EXT_LIST_LOONGSON
1700 "
1701
1702 ARCH_FEATURES="
1703     aligned_stack
1704     fast_64bit
1705     fast_clz
1706     fast_cmov
1707     local_aligned_8
1708     local_aligned_16
1709     local_aligned_32
1710     simd_align_16
1711 "
1712
1713 BUILTIN_LIST="
1714     atomic_cas_ptr
1715     atomic_compare_exchange
1716     machine_rw_barrier
1717     MemoryBarrier
1718     mm_empty
1719     rdtsc
1720     sarestart
1721     sync_val_compare_and_swap
1722 "
1723 HAVE_LIST_CMDLINE="
1724     inline_asm
1725     symver
1726     yasm
1727 "
1728
1729 HAVE_LIST_PUB="
1730     bigendian
1731     fast_unaligned
1732     incompatible_libav_abi
1733 "
1734
1735 HEADERS_LIST="
1736     alsa_asoundlib_h
1737     altivec_h
1738     arpa_inet_h
1739     asm_types_h
1740     cdio_paranoia_h
1741     cdio_paranoia_paranoia_h
1742     dev_bktr_ioctl_bt848_h
1743     dev_bktr_ioctl_meteor_h
1744     dev_ic_bt8xx_h
1745     dev_video_bktr_ioctl_bt848_h
1746     dev_video_meteor_ioctl_meteor_h
1747     direct_h
1748     dirent_h
1749     dlfcn_h
1750     d3d11_h
1751     dxva_h
1752     ES2_gl_h
1753     gsm_h
1754     io_h
1755     mach_mach_time_h
1756     machine_ioctl_bt848_h
1757     machine_ioctl_meteor_h
1758     malloc_h
1759     openjpeg_1_5_openjpeg_h
1760     OpenGL_gl3_h
1761     poll_h
1762     sndio_h
1763     soundcard_h
1764     sys_mman_h
1765     sys_param_h
1766     sys_resource_h
1767     sys_select_h
1768     sys_soundcard_h
1769     sys_time_h
1770     sys_un_h
1771     sys_videoio_h
1772     termios_h
1773     udplite_h
1774     unistd_h
1775     valgrind_valgrind_h
1776     windows_h
1777     winsock2_h
1778 "
1779
1780 INTRINSICS_LIST="
1781     intrinsics_neon
1782 "
1783
1784 COMPLEX_FUNCS="
1785     cabs
1786     cexp
1787 "
1788
1789 MATH_FUNCS="
1790     atanf
1791     atan2f
1792     cbrt
1793     cbrtf
1794     copysign
1795     cosf
1796     erf
1797     exp2
1798     exp2f
1799     expf
1800     hypot
1801     isinf
1802     isnan
1803     ldexpf
1804     llrint
1805     llrintf
1806     log2
1807     log2f
1808     log10f
1809     lrint
1810     lrintf
1811     powf
1812     rint
1813     round
1814     roundf
1815     sinf
1816     trunc
1817     truncf
1818 "
1819
1820 SYSTEM_FUNCS="
1821     access
1822     aligned_malloc
1823     clock_gettime
1824     closesocket
1825     CommandLineToArgvW
1826     CoTaskMemFree
1827     CryptGenRandom
1828     dlopen
1829     fcntl
1830     flt_lim
1831     fork
1832     getaddrinfo
1833     gethrtime
1834     getopt
1835     GetProcessAffinityMask
1836     GetProcessMemoryInfo
1837     GetProcessTimes
1838     getrusage
1839     GetSystemTimeAsFileTime
1840     gettimeofday
1841     glob
1842     glXGetProcAddress
1843     gmtime_r
1844     inet_aton
1845     isatty
1846     jack_port_get_latency_range
1847     kbhit
1848     localtime_r
1849     lstat
1850     lzo1x_999_compress
1851     mach_absolute_time
1852     MapViewOfFile
1853     memalign
1854     mkstemp
1855     mmap
1856     mprotect
1857     nanosleep
1858     PeekNamedPipe
1859     posix_memalign
1860     pthread_cancel
1861     sched_getaffinity
1862     SetConsoleTextAttribute
1863     SetConsoleCtrlHandler
1864     setmode
1865     setrlimit
1866     Sleep
1867     strerror_r
1868     sysconf
1869     sysctl
1870     usleep
1871     UTGetOSTypeFromString
1872     VirtualAlloc
1873     wglGetProcAddress
1874 "
1875
1876 TOOLCHAIN_FEATURES="
1877     as_dn_directive
1878     as_func
1879     as_object_arch
1880     asm_mod_q
1881     attribute_may_alias
1882     attribute_packed
1883     ebp_available
1884     ebx_available
1885     gnu_as
1886     gnu_windres
1887     ibm_asm
1888     inline_asm_labels
1889     inline_asm_nonlocal_labels
1890     inline_asm_direct_symbol_refs
1891     pragma_deprecated
1892     rsync_contimeout
1893     symver_asm_label
1894     symver_gnu_asm
1895     vfp_args
1896     xform_asm
1897     xmm_clobbers
1898 "
1899
1900 TYPES_LIST="
1901     CONDITION_VARIABLE_Ptr
1902     socklen_t
1903     struct_addrinfo
1904     struct_group_source_req
1905     struct_ip_mreq_source
1906     struct_ipv6_mreq
1907     struct_pollfd
1908     struct_rusage_ru_maxrss
1909     struct_sctp_event_subscribe
1910     struct_sockaddr_in6
1911     struct_sockaddr_sa_len
1912     struct_sockaddr_storage
1913     struct_stat_st_mtim_tv_nsec
1914     struct_v4l2_frmivalenum_discrete
1915 "
1916
1917 HAVE_LIST="
1918     $ARCH_EXT_LIST
1919     $(add_suffix _external $ARCH_EXT_LIST)
1920     $(add_suffix _inline   $ARCH_EXT_LIST)
1921     $ARCH_FEATURES
1922     $ATOMICS_LIST
1923     $BUILTIN_LIST
1924     $COMPLEX_FUNCS
1925     $HAVE_LIST_CMDLINE
1926     $HAVE_LIST_PUB
1927     $HEADERS_LIST
1928     $INTRINSICS_LIST
1929     $MATH_FUNCS
1930     $SYSTEM_FUNCS
1931     $THREADS_LIST
1932     $TOOLCHAIN_FEATURES
1933     $TYPES_LIST
1934     atomics_native
1935     dos_paths
1936     dxva2api_cobj
1937     dxva2_lib
1938     winrt
1939     libc_msvcrt
1940     libdc1394_1
1941     libdc1394_2
1942     makeinfo
1943     makeinfo_html
1944     perl
1945     pod2man
1946     sdl
1947     section_data_rel_ro
1948     texi2html
1949     threads
1950     vaapi_x11
1951     vdpau_x11
1952     xlib
1953 "
1954
1955 # options emitted with CONFIG_ prefix but not available on the command line
1956 CONFIG_EXTRA="
1957     aandcttables
1958     ac3dsp
1959     audio_frame_queue
1960     audiodsp
1961     blockdsp
1962     bswapdsp
1963     cabac
1964     dvprofile
1965     exif
1966     faandct
1967     faanidct
1968     fdctdsp
1969     flacdsp
1970     fmtconvert
1971     frame_thread_encoder
1972     g722dsp
1973     golomb
1974     gplv3
1975     h263dsp
1976     h264chroma
1977     h264dsp
1978     h264pred
1979     h264qpel
1980     hpeldsp
1981     huffman
1982     huffyuvdsp
1983     huffyuvencdsp
1984     idctdsp
1985     iirfilter
1986     imdct15
1987     intrax8
1988     ividsp
1989     jpegtables
1990     libx262
1991     lgplv3
1992     llauddsp
1993     llviddsp
1994     lpc
1995     lzf
1996     me_cmp
1997     mpeg_er
1998     mpegaudio
1999     mpegaudiodsp
2000     mpegvideo
2001     mpegvideoenc
2002     mss34dsp
2003     pixblockdsp
2004     qpeldsp
2005     qsv
2006     qsvdec
2007     qsvenc
2008     rangecoder
2009     riffdec
2010     riffenc
2011     rtpdec
2012     rtpenc_chain
2013     rv34dsp
2014     sinewin
2015     snappy
2016     startcode
2017     texturedsp
2018     texturedspenc
2019     tpeldsp
2020     videodsp
2021     vp3dsp
2022     vp56dsp
2023     vp8dsp
2024     wma_freqs
2025     wmv2dsp
2026 "
2027
2028 CMDLINE_SELECT="
2029     $ARCH_EXT_LIST
2030     $CONFIG_LIST
2031     $HAVE_LIST_CMDLINE
2032     $THREADS_LIST
2033     asm
2034     cross_compile
2035     debug
2036     extra_warnings
2037     logging
2038     lto
2039     optimizations
2040     rpath
2041     stripping
2042 "
2043
2044 PATHS_LIST="
2045     bindir
2046     datadir
2047     docdir
2048     incdir
2049     libdir
2050     mandir
2051     pkgconfigdir
2052     prefix
2053     shlibdir
2054 "
2055
2056 CMDLINE_SET="
2057     $PATHS_LIST
2058     ar
2059     arch
2060     as
2061     assert_level
2062     build_suffix
2063     cc
2064     cpu
2065     cross_prefix
2066     custom_allocator
2067     cxx
2068     dep_cc
2069     doxygen
2070     env
2071     extra_version
2072     gas
2073     host_cc
2074     host_cflags
2075     host_ld
2076     host_ldflags
2077     host_libs
2078     host_os
2079     install
2080     ld
2081     logfile
2082     malloc_prefix
2083     nm
2084     optflags
2085     pkg_config
2086     pkg_config_flags
2087     progs_suffix
2088     random_seed
2089     ranlib
2090     samples
2091     strip
2092     sws_max_filter_size
2093     sysinclude
2094     sysroot
2095     target_exec
2096     target_os
2097     target_path
2098     target_samples
2099     tempprefix
2100     toolchain
2101     valgrind
2102     yasmexe
2103 "
2104
2105 CMDLINE_APPEND="
2106     extra_cflags
2107     extra_cxxflags
2108     host_cppflags
2109 "
2110
2111 # code dependency declarations
2112
2113 # architecture extensions
2114
2115 armv5te_deps="arm"
2116 armv6_deps="arm"
2117 armv6t2_deps="arm"
2118 armv8_deps="aarch64"
2119 neon_deps_any="aarch64 arm"
2120 intrinsics_neon_deps="neon"
2121 vfp_deps_any="aarch64 arm"
2122 vfpv3_deps="vfp"
2123 setend_deps="arm"
2124
2125 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
2126
2127 mipsfpu_deps="mips"
2128 mipsdsp_deps="mips"
2129 mipsdspr2_deps="mips"
2130 mips32r2_deps="mips"
2131 mips64r6_deps="mips"
2132 msa_deps="mips"
2133 mmi_deps="mips"
2134
2135 altivec_deps="ppc"
2136 dcbzl_deps="ppc"
2137 ldbrx_deps="ppc"
2138 ppc4xx_deps="ppc"
2139 vsx_deps="altivec"
2140 power8_deps="vsx"
2141
2142 cpunop_deps="i686"
2143 x86_64_select="i686"
2144 x86_64_suggest="fast_cmov"
2145
2146 amd3dnow_deps="mmx"
2147 amd3dnowext_deps="amd3dnow"
2148 i686_deps="x86"
2149 mmx_deps="x86"
2150 mmxext_deps="mmx"
2151 sse_deps="mmxext"
2152 sse2_deps="sse"
2153 sse3_deps="sse2"
2154 ssse3_deps="sse3"
2155 sse4_deps="ssse3"
2156 sse42_deps="sse4"
2157 aesni_deps="sse42"
2158 avx_deps="sse42"
2159 xop_deps="avx"
2160 fma3_deps="avx"
2161 fma4_deps="avx"
2162 avx2_deps="avx"
2163
2164 mmx_external_deps="yasm"
2165 mmx_inline_deps="inline_asm"
2166 mmx_suggest="mmx_external mmx_inline"
2167
2168 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
2169     eval dep=\$${ext}_deps
2170     eval ${ext}_external_deps='"${dep}_external"'
2171     eval ${ext}_inline_deps='"${dep}_inline"'
2172     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
2173 done
2174
2175 aligned_stack_if_any="aarch64 ppc x86"
2176 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
2177 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
2178 fast_unaligned_if_any="aarch64 ppc x86"
2179 simd_align_16_if_any="altivec neon sse"
2180
2181 # system capabilities
2182 symver_if_any="symver_asm_label symver_gnu_asm"
2183 valgrind_backtrace_deps="!optimizations valgrind_valgrind_h"
2184
2185 # threading support
2186 atomics_gcc_if_any="sync_val_compare_and_swap atomic_compare_exchange"
2187 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
2188 atomics_win32_if="MemoryBarrier"
2189 atomics_native_if_any="$ATOMICS_LIST"
2190 w32threads_deps="atomics_native"
2191 threads_if_any="$THREADS_LIST"
2192
2193 # subsystems
2194 dct_select="rdft"
2195 error_resilience_select="me_cmp"
2196 faandct_deps="faan fdctdsp"
2197 faanidct_deps="faan idctdsp"
2198 frame_thread_encoder_deps="encoders threads"
2199 intrax8_select="error_resilience"
2200 mdct_select="fft"
2201 rdft_select="fft"
2202 me_cmp_select="fdctdsp idctdsp pixblockdsp"
2203 mpeg_er_select="error_resilience"
2204 mpegaudio_select="mpegaudiodsp"
2205 mpegaudiodsp_select="dct"
2206 mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp mpeg_er videodsp"
2207 mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
2208 qsvdec_select="qsv"
2209 qsvenc_select="qsv"
2210
2211 # decoders / encoders
2212 aac_decoder_select="imdct15 mdct sinewin"
2213 aac_fixed_decoder_select="mdct sinewin"
2214 aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin"
2215 aac_latm_decoder_select="aac_decoder aac_latm_parser"
2216 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
2217 ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
2218 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
2219 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
2220 adpcm_g722_decoder_select="g722dsp"
2221 adpcm_g722_encoder_select="g722dsp"
2222 aic_decoder_select="golomb idctdsp"
2223 alac_encoder_select="lpc"
2224 als_decoder_select="bswapdsp"
2225 amrnb_decoder_select="lsp"
2226 amrwb_decoder_select="lsp"
2227 amv_decoder_select="sp5x_decoder exif"
2228 amv_encoder_select="aandcttables jpegtables mpegvideoenc"
2229 ape_decoder_select="bswapdsp llauddsp"
2230 apng_decoder_select="zlib"
2231 apng_encoder_select="huffyuvencdsp zlib"
2232 asv1_decoder_select="blockdsp bswapdsp idctdsp"
2233 asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
2234 asv2_decoder_select="blockdsp bswapdsp idctdsp"
2235 asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
2236 atrac1_decoder_select="mdct sinewin"
2237 atrac3_decoder_select="mdct"
2238 atrac3p_decoder_select="mdct sinewin"
2239 avrn_decoder_select="exif jpegtables"
2240 bink_decoder_select="blockdsp hpeldsp"
2241 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
2242 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
2243 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
2244 cllc_decoder_select="bswapdsp"
2245 comfortnoise_encoder_select="lpc"
2246 cook_decoder_select="audiodsp mdct sinewin"
2247 cscd_decoder_select="lzo"
2248 cscd_decoder_suggest="zlib"
2249 dca_decoder_select="fmtconvert mdct"
2250 dds_decoder_select="texturedsp"
2251 dirac_decoder_select="dwt golomb videodsp mpegvideoenc"
2252 dnxhd_decoder_select="blockdsp idctdsp"
2253 dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
2254 dvvideo_decoder_select="dvprofile idctdsp"
2255 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
2256 dxa_decoder_select="zlib"
2257 dxv_decoder_select="lzf texturedsp"
2258 eac3_decoder_select="ac3_decoder"
2259 eac3_encoder_select="ac3_encoder"
2260 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
2261 eatgq_decoder_select="aandcttables"
2262 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpeg1video_decoder"
2263 exr_decoder_select="zlib"
2264 ffv1_decoder_select="golomb rangecoder"
2265 ffv1_encoder_select="rangecoder"
2266 ffvhuff_decoder_select="huffyuv_decoder"
2267 ffvhuff_encoder_select="huffyuv_encoder"
2268 fic_decoder_select="golomb"
2269 flac_decoder_select="flacdsp golomb"
2270 flac_encoder_select="bswapdsp flacdsp golomb lpc"
2271 flashsv_decoder_select="zlib"
2272 flashsv_encoder_select="zlib"
2273 flashsv2_encoder_select="zlib"
2274 flashsv2_decoder_select="zlib"
2275 flv_decoder_select="h263_decoder"
2276 flv_encoder_select="h263_encoder"
2277 fourxm_decoder_select="blockdsp bswapdsp"
2278 fraps_decoder_select="bswapdsp huffman"
2279 g2m_decoder_select="blockdsp idctdsp jpegtables zlib"
2280 g729_decoder_select="audiodsp"
2281 h261_decoder_select="mpegvideo"
2282 h261_encoder_select="aandcttables mpegvideoenc"
2283 h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp"
2284 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
2285 h263i_decoder_select="h263_decoder"
2286 h263p_decoder_select="h263_decoder"
2287 h263p_encoder_select="h263_encoder"
2288 h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode videodsp"
2289 h264_decoder_suggest="error_resilience"
2290 h264_qsv_decoder_deps="libmfx"
2291 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
2292 h264_qsv_encoder_deps="libmfx"
2293 h264_qsv_encoder_select="qsvenc"
2294 hap_decoder_select="snappy texturedsp"
2295 hap_encoder_deps="libsnappy"
2296 hap_encoder_select="texturedspenc"
2297 hevc_decoder_select="bswapdsp cabac golomb videodsp"
2298 hevc_qsv_encoder_deps="libmfx"
2299 hevc_qsv_decoder_deps="libmfx"
2300 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec hevc_qsv_hwaccel"
2301 hevc_qsv_encoder_select="qsvenc"
2302 huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
2303 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp"
2304 iac_decoder_select="imc_decoder"
2305 imc_decoder_select="bswapdsp fft mdct sinewin"
2306 indeo3_decoder_select="hpeldsp"
2307 indeo4_decoder_select="ividsp"
2308 indeo5_decoder_select="ividsp"
2309 interplay_video_decoder_select="hpeldsp"
2310 jpegls_decoder_select="golomb mjpeg_decoder"
2311 jpegls_encoder_select="golomb"
2312 jv_decoder_select="blockdsp"
2313 lagarith_decoder_select="huffyuvdsp"
2314 ljpeg_encoder_select="aandcttables idctdsp jpegtables"
2315 loco_decoder_select="golomb"
2316 mdec_decoder_select="blockdsp idctdsp mpegvideo"
2317 metasound_decoder_select="lsp mdct sinewin"
2318 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2319 mjpeg_decoder_select="blockdsp hpeldsp exif idctdsp jpegtables"
2320 mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc"
2321 mjpegb_decoder_select="mjpeg_decoder"
2322 mlp_decoder_select="mlp_parser"
2323 motionpixels_decoder_select="bswapdsp"
2324 mp1_decoder_select="mpegaudio"
2325 mp1float_decoder_select="mpegaudio"
2326 mp2_decoder_select="mpegaudio"
2327 mp2float_decoder_select="mpegaudio"
2328 mp3_decoder_select="mpegaudio"
2329 mp3adu_decoder_select="mpegaudio"
2330 mp3adufloat_decoder_select="mpegaudio"
2331 mp3float_decoder_select="mpegaudio"
2332 mp3on4_decoder_select="mpegaudio"
2333 mp3on4float_decoder_select="mpegaudio"
2334 mpc7_decoder_select="bswapdsp mpegaudiodsp"
2335 mpc8_decoder_select="mpegaudiodsp"
2336 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
2337 mpeg_xvmc_decoder_select="mpeg2video_decoder"
2338 mpegvideo_decoder_select="mpegvideo"
2339 mpeg1video_decoder_select="mpegvideo"
2340 mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp"
2341 mpeg2video_decoder_select="mpegvideo"
2342 mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp"
2343 mpeg2_qsv_decoder_deps="libmfx"
2344 mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
2345 mpeg2_qsv_encoder_deps="libmfx"
2346 mpeg2_qsv_encoder_select="qsvenc"
2347 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2348 mpeg4_encoder_select="h263_encoder"
2349 msa1_decoder_select="mss34dsp"
2350 msmpeg4v1_decoder_select="h263_decoder"
2351 msmpeg4v2_decoder_select="h263_decoder"
2352 msmpeg4v2_encoder_select="h263_encoder"
2353 msmpeg4v3_decoder_select="h263_decoder"
2354 msmpeg4v3_encoder_select="h263_encoder"
2355 mss2_decoder_select="vc1_decoder"
2356 mts2_decoder_select="mss34dsp"
2357 mxpeg_decoder_select="mjpeg_decoder"
2358 nellymoser_decoder_select="mdct sinewin"
2359 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
2360 nuv_decoder_select="idctdsp lzo"
2361 on2avc_decoder_select="mdct"
2362 opus_decoder_deps="swresample"
2363 opus_decoder_select="imdct15"
2364 png_decoder_select="zlib"
2365 png_encoder_select="huffyuvencdsp zlib"
2366 prores_decoder_select="blockdsp idctdsp"
2367 prores_encoder_select="fdctdsp"
2368 qcelp_decoder_select="lsp"
2369 qdm2_decoder_select="mdct rdft mpegaudiodsp"
2370 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
2371 ra_144_decoder_select="audiodsp"
2372 ralf_decoder_select="golomb"
2373 rawvideo_decoder_select="bswapdsp"
2374 rscc_decoder_select="zlib"
2375 rtjpeg_decoder_select="me_cmp"
2376 rv10_decoder_select="h263_decoder"
2377 rv10_encoder_select="h263_encoder"
2378 rv20_decoder_select="h263_decoder"
2379 rv20_encoder_select="h263_encoder"
2380 rv30_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
2381 rv40_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
2382 screenpresso_decoder_select="zlib"
2383 shorten_decoder_select="golomb"
2384 sipr_decoder_select="lsp"
2385 snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp"
2386 snow_encoder_select="aandcttables dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder"
2387 sonic_decoder_select="golomb rangecoder"
2388 sonic_encoder_select="golomb rangecoder"
2389 sonic_ls_encoder_select="golomb rangecoder"
2390 sp5x_decoder_select="mjpeg_decoder"
2391 svq1_decoder_select="hpeldsp"
2392 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
2393 svq3_decoder_select="h264_decoder hpeldsp tpeldsp"
2394 svq3_decoder_suggest="zlib"
2395 tak_decoder_select="audiodsp"
2396 tdsc_decoder_select="zlib mjpeg_decoder"
2397 theora_decoder_select="vp3_decoder"
2398 thp_decoder_select="mjpeg_decoder"
2399 tiff_decoder_suggest="zlib lzma"
2400 tiff_encoder_suggest="zlib"
2401 truehd_decoder_select="mlp_parser"
2402 truemotion2_decoder_select="bswapdsp"
2403 truespeech_decoder_select="bswapdsp"
2404 tscc_decoder_select="zlib"
2405 twinvq_decoder_select="mdct lsp sinewin"
2406 txd_decoder_select="texturedsp"
2407 utvideo_decoder_select="bswapdsp"
2408 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
2409 vble_decoder_select="huffyuvdsp"
2410 vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 qpeldsp startcode"
2411 vc1image_decoder_select="vc1_decoder"
2412 vc1_qsv_decoder_deps="libmfx"
2413 vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel"
2414 vorbis_decoder_select="mdct"
2415 vorbis_encoder_select="mdct"
2416 vp3_decoder_select="hpeldsp vp3dsp videodsp"
2417 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
2418 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
2419 vp6a_decoder_select="vp6_decoder"
2420 vp6f_decoder_select="vp6_decoder"
2421 vp7_decoder_select="h264pred videodsp vp8dsp"
2422 vp8_decoder_select="h264pred videodsp vp8dsp"
2423 vp9_decoder_select="videodsp vp9_parser"
2424 webp_decoder_select="vp8_decoder"
2425 wmalossless_decoder_select="llauddsp"
2426 wmapro_decoder_select="mdct sinewin wma_freqs"
2427 wmav1_decoder_select="mdct sinewin wma_freqs"
2428 wmav1_encoder_select="mdct sinewin wma_freqs"
2429 wmav2_decoder_select="mdct sinewin wma_freqs"
2430 wmav2_encoder_select="mdct sinewin wma_freqs"
2431 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
2432 wmv1_decoder_select="h263_decoder"
2433 wmv1_encoder_select="h263_encoder"
2434 wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp wmv2dsp"
2435 wmv2_encoder_select="h263_encoder wmv2dsp"
2436 wmv3_decoder_select="vc1_decoder"
2437 wmv3image_decoder_select="wmv3_decoder"
2438 zerocodec_decoder_select="zlib"
2439 zlib_decoder_select="zlib"
2440 zlib_encoder_select="zlib"
2441 zmbv_decoder_select="zlib"
2442 zmbv_encoder_select="zlib"
2443
2444 # hardware accelerators
2445 crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
2446 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext"
2447 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
2448 vaapi_deps="va_va_h"
2449 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
2450 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
2451 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
2452 videotoolbox_deps="VideoToolbox_VideoToolbox_h pthreads"
2453 videotoolbox_extralibs="-framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreVideo"
2454 xvmc_deps="X11_extensions_XvMClib_h"
2455
2456 h263_vaapi_hwaccel_deps="vaapi"
2457 h263_vaapi_hwaccel_select="h263_decoder"
2458 h263_videotoolbox_hwaccel_deps="videotoolbox"
2459 h263_videotoolbox_hwaccel_select="h263_decoder"
2460 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
2461 h264_d3d11va_hwaccel_deps="d3d11va"
2462 h264_d3d11va_hwaccel_select="h264_decoder"
2463 h264_dxva2_hwaccel_deps="dxva2"
2464 h264_dxva2_hwaccel_select="h264_decoder"
2465 h264_mmal_decoder_deps="mmal"
2466 h264_mmal_hwaccel_deps="mmal"
2467 h264_mmal_decoder_select="h264_decoder"
2468 h264_mmal_encoder_deps="mmal"
2469 h264_qsv_hwaccel_deps="libmfx"
2470 h264_vaapi_hwaccel_deps="vaapi"
2471 h264_vaapi_hwaccel_select="h264_decoder"
2472 h264_vda_decoder_deps="vda"
2473 h264_vda_decoder_select="h264_decoder"
2474 h264_vda_hwaccel_deps="vda"
2475 h264_vda_hwaccel_select="h264_decoder"
2476 h264_vda_old_hwaccel_deps="vda"
2477 h264_vda_old_hwaccel_select="h264_decoder"
2478 h264_vdpau_decoder_deps="vdpau"
2479 h264_vdpau_decoder_select="h264_decoder"
2480 h264_vdpau_hwaccel_deps="vdpau"
2481 h264_vdpau_hwaccel_select="h264_decoder"
2482 h264_videotoolbox_hwaccel_deps="videotoolbox"
2483 h264_videotoolbox_hwaccel_select="h264_decoder"
2484 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2485 hevc_d3d11va_hwaccel_select="hevc_decoder"
2486 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
2487 hevc_dxva2_hwaccel_select="hevc_decoder"
2488 hevc_qsv_hwaccel_deps="libmfx"
2489 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
2490 hevc_vaapi_hwaccel_select="hevc_decoder"
2491 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
2492 hevc_vdpau_hwaccel_select="hevc_decoder"
2493 mpeg_vdpau_decoder_deps="vdpau"
2494 mpeg_vdpau_decoder_select="mpeg2video_decoder"
2495 mpeg_xvmc_hwaccel_deps="xvmc"
2496 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
2497 mpeg1_vdpau_decoder_deps="vdpau"
2498 mpeg1_vdpau_decoder_select="mpeg1video_decoder"
2499 mpeg1_vdpau_hwaccel_deps="vdpau"
2500 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2501 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
2502 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
2503 mpeg1_xvmc_hwaccel_deps="xvmc"
2504 mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
2505 mpeg2_crystalhd_decoder_select="crystalhd"
2506 mpeg2_d3d11va_hwaccel_deps="d3d11va"
2507 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
2508 mpeg2_dxva2_hwaccel_deps="dxva2"
2509 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
2510 mpeg2_mmal_decoder_deps="mmal"
2511 mpeg2_mmal_hwaccel_deps="mmal"
2512 mpeg2_mmal_decoder_select="mpeg2video_decoder"
2513 mpeg2_qsv_hwaccel_deps="libmfx"
2514 mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
2515 mpeg2_vaapi_hwaccel_deps="vaapi"
2516 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
2517 mpeg2_vdpau_hwaccel_deps="vdpau"
2518 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2519 mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
2520 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
2521 mpeg2_xvmc_hwaccel_deps="xvmc"
2522 mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
2523 mpeg4_crystalhd_decoder_select="crystalhd"
2524 mpeg4_vaapi_hwaccel_deps="vaapi"
2525 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2526 mpeg4_vdpau_decoder_deps="vdpau"
2527 mpeg4_vdpau_decoder_select="mpeg4_decoder"
2528 mpeg4_vdpau_hwaccel_deps="vdpau"
2529 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2530 mpeg4_videotoolbox_hwaccel_deps="videotoolbox"
2531 mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder"
2532 msmpeg4_crystalhd_decoder_select="crystalhd"
2533 vc1_crystalhd_decoder_select="crystalhd"
2534 vc1_d3d11va_hwaccel_deps="d3d11va"
2535 vc1_d3d11va_hwaccel_select="vc1_decoder"
2536 vc1_dxva2_hwaccel_deps="dxva2"
2537 vc1_dxva2_hwaccel_select="vc1_decoder"
2538 vc1_vaapi_hwaccel_deps="vaapi"
2539 vc1_vaapi_hwaccel_select="vc1_decoder"
2540 vc1_vdpau_decoder_deps="vdpau"
2541 vc1_vdpau_decoder_select="vc1_decoder"
2542 vc1_vdpau_hwaccel_deps="vdpau"
2543 vc1_vdpau_hwaccel_select="vc1_decoder"
2544 vc1_mmal_decoder_deps="mmal"
2545 vc1_mmal_hwaccel_deps="mmal"
2546 vc1_mmal_decoder_select="vc1_decoder"
2547 vc1_qsv_hwaccel_deps="libmfx"
2548 vc1_qsv_hwaccel_select="qsvdec_vc1"
2549 wmv3_crystalhd_decoder_select="crystalhd"
2550 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
2551 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2552 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2553 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
2554 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2555
2556 # parsers
2557 h264_parser_select="h264_decoder"
2558 hevc_parser_select="golomb"
2559 mpegvideo_parser_select="mpegvideo"
2560 mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
2561 vc1_parser_select="mpegvideo startcode vc1_decoder"
2562
2563 # bitstream_filters
2564 mjpeg2jpeg_bsf_select="jpegtables"
2565
2566 # external libraries
2567 chromaprint_muxer_deps="chromaprint"
2568 libaacplus_encoder_deps="libaacplus"
2569 libcelt_decoder_deps="libcelt"
2570 libdcadec_decoder_deps="libdcadec"
2571 libfaac_encoder_deps="libfaac"
2572 libfaac_encoder_select="audio_frame_queue"
2573 libfdk_aac_decoder_deps="libfdk_aac"
2574 libfdk_aac_encoder_deps="libfdk_aac"
2575 libfdk_aac_encoder_select="audio_frame_queue"
2576 libgme_demuxer_deps="libgme"
2577 libgsm_decoder_deps="libgsm"
2578 libgsm_encoder_deps="libgsm"
2579 libgsm_ms_decoder_deps="libgsm"
2580 libgsm_ms_encoder_deps="libgsm"
2581 libilbc_decoder_deps="libilbc"
2582 libilbc_encoder_deps="libilbc"
2583 libkvazaar_encoder_deps="libkvazaar"
2584 libmodplug_demuxer_deps="libmodplug"
2585 libmp3lame_encoder_deps="libmp3lame"
2586 libmp3lame_encoder_select="audio_frame_queue"
2587 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2588 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2589 libopencore_amrnb_encoder_select="audio_frame_queue"
2590 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2591 libopenh264_encoder_deps="libopenh264"
2592 libopenjpeg_decoder_deps="libopenjpeg"
2593 libopenjpeg_encoder_deps="libopenjpeg"
2594 libopus_decoder_deps="libopus"
2595 libopus_encoder_deps="libopus"
2596 libopus_encoder_select="audio_frame_queue"
2597 libquvi_demuxer_deps="libquvi"
2598 libschroedinger_decoder_deps="libschroedinger"
2599 libschroedinger_encoder_deps="libschroedinger"
2600 libshine_encoder_deps="libshine"
2601 libshine_encoder_select="audio_frame_queue"
2602 libspeex_decoder_deps="libspeex"
2603 libspeex_encoder_deps="libspeex"
2604 libspeex_encoder_select="audio_frame_queue"
2605 libstagefright_h264_decoder_deps="libstagefright_h264"
2606 libtheora_encoder_deps="libtheora"
2607 libtwolame_encoder_deps="libtwolame"
2608 libvo_aacenc_encoder_deps="libvo_aacenc"
2609 libvo_aacenc_encoder_select="audio_frame_queue"
2610 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2611 libvorbis_decoder_deps="libvorbis"
2612 libvorbis_encoder_deps="libvorbis"
2613 libvorbis_encoder_select="audio_frame_queue"
2614 libvpx_vp8_decoder_deps="libvpx"
2615 libvpx_vp8_encoder_deps="libvpx"
2616 libvpx_vp9_decoder_deps="libvpx"
2617 libvpx_vp9_encoder_deps="libvpx"
2618 libwavpack_encoder_deps="libwavpack"
2619 libwebp_encoder_deps="libwebp"
2620 libwebp_anim_encoder_deps="libwebp"
2621 libx262_encoder_deps="libx262"
2622 libx264_encoder_deps="libx264"
2623 libx264rgb_encoder_deps="libx264"
2624 libx264rgb_encoder_select="libx264_encoder"
2625 libx265_encoder_deps="libx265"
2626 libxavs_encoder_deps="libxavs"
2627 libxvid_encoder_deps="libxvid"
2628 libutvideo_decoder_deps="libutvideo"
2629 libutvideo_encoder_deps="libutvideo"
2630 libzvbi_teletext_decoder_deps="libzvbi"
2631 nvenc_encoder_deps="nvenc"
2632 nvenc_h264_encoder_deps="nvenc"
2633 nvenc_hevc_encoder_deps="nvenc"
2634
2635 # demuxers / muxers
2636 ac3_demuxer_select="ac3_parser"
2637 asf_demuxer_select="riffdec"
2638 asf_o_demuxer_select="riffdec"
2639 asf_muxer_select="riffenc"
2640 asf_stream_muxer_select="asf_muxer"
2641 avi_demuxer_select="riffdec exif"
2642 avi_muxer_select="riffenc"
2643 avisynth_demuxer_deps="avisynth"
2644 avisynth_demuxer_select="riffdec"
2645 caf_demuxer_select="riffdec"
2646 dash_muxer_select="mp4_muxer"
2647 dirac_demuxer_select="dirac_parser"
2648 dts_demuxer_select="dca_parser"
2649 dtshd_demuxer_select="dca_parser"
2650 dv_demuxer_select="dvprofile"
2651 dv_muxer_select="dvprofile"
2652 dxa_demuxer_select="riffdec"
2653 eac3_demuxer_select="ac3_parser"
2654 f4v_muxer_select="mov_muxer"
2655 flac_demuxer_select="flac_parser"
2656 hds_muxer_select="flv_muxer"
2657 hls_muxer_select="mpegts_muxer"
2658 image2_alias_pix_demuxer_select="image2_demuxer"
2659 image2_brender_pix_demuxer_select="image2_demuxer"
2660 ipod_muxer_select="mov_muxer"
2661 ismv_muxer_select="mov_muxer"
2662 libnut_demuxer_deps="libnut"
2663 libnut_muxer_deps="libnut"
2664 matroska_audio_muxer_select="matroska_muxer"
2665 matroska_demuxer_select="riffdec"
2666 matroska_demuxer_suggest="bzlib lzo zlib"
2667 matroska_muxer_select="riffenc"
2668 mmf_muxer_select="riffenc"
2669 mov_demuxer_select="riffdec"
2670 mov_demuxer_suggest="zlib"
2671 mov_muxer_select="riffenc rtpenc_chain"
2672 mp3_demuxer_select="mpegaudio_parser"
2673 mp4_muxer_select="mov_muxer"
2674 mpegts_muxer_select="adts_muxer latm_muxer"
2675 mpegtsraw_demuxer_select="mpegts_demuxer"
2676 mxf_d10_muxer_select="mxf_muxer"
2677 mxf_opatom_muxer_select="mxf_muxer"
2678 nut_muxer_select="riffenc"
2679 nuv_demuxer_select="riffdec"
2680 oga_muxer_select="ogg_muxer"
2681 ogg_demuxer_select="golomb"
2682 opus_muxer_select="ogg_muxer"
2683 psp_muxer_select="mov_muxer"
2684 rtp_demuxer_select="sdp_demuxer"
2685 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol"
2686 rtsp_demuxer_select="http_protocol rtpdec"
2687 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2688 sap_demuxer_select="sdp_demuxer"
2689 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2690 sdp_demuxer_select="rtpdec"
2691 smoothstreaming_muxer_select="ismv_muxer"
2692 spdif_muxer_select="aac_parser"
2693 spx_muxer_select="ogg_muxer"
2694 tak_demuxer_select="tak_parser"
2695 tg2_muxer_select="mov_muxer"
2696 tgp_muxer_select="mov_muxer"
2697 vobsub_demuxer_select="mpegps_demuxer"
2698 w64_demuxer_select="wav_demuxer"
2699 w64_muxer_select="wav_muxer"
2700 wav_demuxer_select="riffdec"
2701 wav_muxer_select="riffenc"
2702 webm_muxer_select="riffenc"
2703 wtv_demuxer_select="riffdec"
2704 wtv_muxer_select="riffenc"
2705 xmv_demuxer_select="riffdec"
2706 xwma_demuxer_select="riffdec"
2707
2708 # indevs / outdevs
2709 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
2710 alsa_outdev_deps="alsa_asoundlib_h"
2711 avfoundation_indev_extralibs="-framework CoreVideo -framework Foundation -framework AVFoundation -framework CoreMedia"
2712 avfoundation_indev_select="avfoundation"
2713 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2714 caca_outdev_deps="libcaca"
2715 decklink_outdev_deps="decklink pthreads"
2716 decklink_outdev_extralibs="-lstdc++"
2717 decklink_indev_deps="decklink pthreads"
2718 decklink_indev_extralibs="-lstdc++"
2719 dshow_indev_deps="IBaseFilter"
2720 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
2721 dv1394_indev_deps="dv1394"
2722 dv1394_indev_select="dv_demuxer"
2723 fbdev_indev_deps="linux_fb_h"
2724 fbdev_outdev_deps="linux_fb_h"
2725 gdigrab_indev_deps="CreateDIBSection"
2726 gdigrab_indev_extralibs="-lgdi32"
2727 gdigrab_indev_select="bmp_decoder"
2728 iec61883_indev_deps="libiec61883"
2729 jack_indev_deps="jack_jack_h sem_timedwait"
2730 lavfi_indev_deps="avfilter"
2731 libcdio_indev_deps="libcdio"
2732 libdc1394_indev_deps="libdc1394"
2733 libv4l2_indev_deps="libv4l2"
2734 openal_indev_deps="openal"
2735 opengl_outdev_deps="opengl"
2736 oss_indev_deps_any="soundcard_h sys_soundcard_h"
2737 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
2738 pulse_indev_deps="libpulse"
2739 pulse_outdev_deps="libpulse"
2740 qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework QuartzCore"
2741 qtkit_indev_select="qtkit"
2742 sdl_outdev_deps="sdl"
2743 sndio_indev_deps="sndio_h"
2744 sndio_outdev_deps="sndio_h"
2745 v4l_indev_deps="linux_videodev_h"
2746 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2747 v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
2748 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
2749 vfwcap_indev_extralibs="-lavicap32"
2750 xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
2751 xv_outdev_extralibs="-lXv -lX11 -lXext"
2752 x11grab_indev_deps="x11grab"
2753 x11grab_xcb_indev_deps="libxcb"
2754
2755 # protocols
2756 async_protocol_deps="threads"
2757 bluray_protocol_deps="libbluray"
2758 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
2759 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
2760 ffrtmpcrypt_protocol_select="tcp_protocol"
2761 ffrtmphttp_protocol_deps="!librtmp_protocol"
2762 ffrtmphttp_protocol_select="http_protocol"
2763 ftp_protocol_select="tcp_protocol"
2764 gopher_protocol_select="network"
2765 http_protocol_select="tcp_protocol"
2766 httpproxy_protocol_select="tcp_protocol"
2767 https_protocol_select="tls_protocol"
2768 icecast_protocol_select="http_protocol"
2769 librtmp_protocol_deps="librtmp"
2770 librtmpe_protocol_deps="librtmp"
2771 librtmps_protocol_deps="librtmp"
2772 librtmpt_protocol_deps="librtmp"
2773 librtmpte_protocol_deps="librtmp"
2774 libsmbclient_protocol_deps="libsmbclient gplv3"
2775 libssh_protocol_deps="libssh"
2776 mmsh_protocol_select="http_protocol"
2777 mmst_protocol_select="network"
2778 rtmp_protocol_deps="!librtmp_protocol"
2779 rtmp_protocol_select="tcp_protocol"
2780 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2781 rtmps_protocol_deps="!librtmp_protocol"
2782 rtmps_protocol_select="tls_protocol"
2783 rtmpt_protocol_select="ffrtmphttp_protocol"
2784 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2785 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2786 rtp_protocol_select="udp_protocol"
2787 sctp_protocol_deps="struct_sctp_event_subscribe"
2788 sctp_protocol_select="network"
2789 srtp_protocol_select="rtp_protocol"
2790 tcp_protocol_select="network"
2791 tls_gnutls_protocol_deps="gnutls !tls_schannel_protocol !tls_securetransport_protocol"
2792 tls_gnutls_protocol_select="tcp_protocol"
2793 tls_openssl_protocol_deps="openssl !tls_schannel_protocol !tls_securetransport_protocol !tls_gnutls_protocol"
2794 tls_openssl_protocol_select="tcp_protocol"
2795 tls_schannel_protocol_deps="schannel"
2796 tls_schannel_protocol_select="tcp_protocol"
2797 tls_securetransport_protocol_deps="securetransport"
2798 tls_securetransport_protocol_select="tcp_protocol"
2799 tls_protocol_deps_any="tls_schannel_protocol tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol"
2800 udp_protocol_select="network"
2801 udplite_protocol_select="network"
2802 unix_protocol_deps="sys_un_h"
2803 unix_protocol_select="network"
2804
2805 # filters
2806 aemphasis_filter_deps="cabs cexp"
2807 amovie_filter_deps="avcodec avformat"
2808 aresample_filter_deps="swresample"
2809 ass_filter_deps="libass"
2810 asyncts_filter_deps="avresample"
2811 atempo_filter_deps="avcodec"
2812 atempo_filter_select="rdft"
2813 azmq_filter_deps="libzmq"
2814 blackframe_filter_deps="gpl"
2815 boxblur_filter_deps="gpl"
2816 bs2b_filter_deps="libbs2b"
2817 colormatrix_filter_deps="gpl"
2818 cover_rect_filter_deps="avcodec avformat gpl"
2819 cropdetect_filter_deps="gpl"
2820 delogo_filter_deps="gpl"
2821 deshake_filter_select="pixelutils"
2822 drawtext_filter_deps="libfreetype"
2823 dynaudnorm_filter_deps="copysign erf"
2824 ebur128_filter_deps="gpl"
2825 eq_filter_deps="gpl"
2826 fftfilt_filter_deps="avcodec"
2827 fftfilt_filter_select="rdft"
2828 flite_filter_deps="libflite"
2829 find_rect_filter_deps="avcodec avformat gpl"
2830 frei0r_filter_deps="frei0r dlopen"
2831 frei0r_src_filter_deps="frei0r dlopen"
2832 fspp_filter_deps="gpl"
2833 geq_filter_deps="gpl"
2834 histeq_filter_deps="gpl"
2835 hqdn3d_filter_deps="gpl"
2836 interlace_filter_deps="gpl"
2837 kerndeint_filter_deps="gpl"
2838 ladspa_filter_deps="ladspa dlopen"
2839 mcdeint_filter_deps="avcodec gpl"
2840 movie_filter_deps="avcodec avformat"
2841 mpdecimate_filter_deps="gpl"
2842 mpdecimate_filter_select="pixelutils"
2843 mptestsrc_filter_deps="gpl"
2844 negate_filter_deps="lut_filter"
2845 perspective_filter_deps="gpl"
2846 pp7_filter_deps="gpl"
2847 ocr_filter_deps="libtesseract"
2848 ocv_filter_deps="libopencv"
2849 owdenoise_filter_deps="gpl"
2850 pan_filter_deps="swresample"
2851 phase_filter_deps="gpl"
2852 pp_filter_deps="gpl postproc"
2853 pullup_filter_deps="gpl"
2854 removelogo_filter_deps="avcodec avformat swscale"
2855 repeatfields_filter_deps="gpl"
2856 resample_filter_deps="avresample"
2857 rubberband_filter_deps="librubberband"
2858 sab_filter_deps="gpl swscale"
2859 scale_filter_deps="swscale"
2860 scale2ref_filter_deps="swscale"
2861 select_filter_select="pixelutils"
2862 smartblur_filter_deps="gpl swscale"
2863 showcqt_filter_deps="avcodec avformat swscale"
2864 showcqt_filter_select="fft"
2865 showfreqs_filter_deps="avcodec"
2866 showfreqs_filter_select="fft"
2867 showspectrum_filter_deps="avcodec"
2868 showspectrum_filter_select="rdft"
2869 spp_filter_deps="gpl avcodec"
2870 spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp"
2871 stereo3d_filter_deps="gpl"
2872 subtitles_filter_deps="avformat avcodec libass"
2873 super2xsai_filter_deps="gpl"
2874 tinterlace_filter_deps="gpl"
2875 vidstabdetect_filter_deps="libvidstab"
2876 vidstabtransform_filter_deps="libvidstab"
2877 pixfmts_super2xsai_test_deps="super2xsai_filter"
2878 tinterlace_merge_test_deps="tinterlace_filter"
2879 tinterlace_pad_test_deps="tinterlace_filter"
2880 uspp_filter_deps="gpl avcodec"
2881 zmq_filter_deps="libzmq"
2882 zoompan_filter_deps="swscale"
2883 zscale_filter_deps="libzimg"
2884
2885 # examples
2886 avio_reading="avformat avcodec avutil"
2887 avio_dir_cmd="avformat avutil"
2888 avcodec_example_deps="avcodec avutil"
2889 decoding_encoding_example_deps="avcodec avformat avutil"
2890 demuxing_decoding_example_deps="avcodec avformat avutil"
2891 extract_mvs_example_deps="avcodec avformat avutil"
2892 filter_audio_example_deps="avfilter avutil"
2893 filtering_audio_example_deps="avfilter avcodec avformat avutil"
2894 filtering_video_example_deps="avfilter avcodec avformat avutil"
2895 metadata_example_deps="avformat avutil"
2896 muxing_example_deps="avcodec avformat avutil swscale"
2897 qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder vaapi_x11"
2898 remuxing_example_deps="avcodec avformat avutil"
2899 resampling_audio_example_deps="avutil swresample"
2900 scaling_video_example_deps="avutil swscale"
2901 transcode_aac_example_deps="avcodec avformat swresample"
2902 transcoding_example_deps="avfilter avcodec avformat avutil"
2903
2904 # libraries, in linking order
2905 avcodec_deps="avutil"
2906 avdevice_deps="avformat avcodec avutil"
2907 avfilter_deps="avutil"
2908 avformat_deps="avcodec avutil"
2909 avresample_deps="avutil"
2910 postproc_deps="avutil gpl"
2911 swresample_deps="avutil"
2912 swscale_deps="avutil"
2913
2914 # programs
2915 ffmpeg_deps="avcodec avfilter avformat swresample"
2916 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
2917                null_filter
2918                setpts_filter trim_filter"
2919 ffplay_deps="avcodec avformat swscale swresample sdl"
2920 ffplay_libs='$sdl_libs'
2921 ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter rotate_filter"
2922 ffprobe_deps="avcodec avformat"
2923 ffserver_deps="avformat fork sarestart"
2924 ffserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
2925
2926 # documentation
2927 podpages_deps="perl"
2928 manpages_deps="perl pod2man"
2929 htmlpages_deps="perl"
2930 htmlpages_deps_any="makeinfo_html texi2html"
2931 txtpages_deps="perl makeinfo"
2932 doc_deps_any="manpages htmlpages podpages txtpages"
2933
2934 # default parameters
2935
2936 logfile="config.log"
2937
2938 # installation paths
2939 prefix_default="/usr/local"
2940 bindir_default='${prefix}/bin'
2941 datadir_default='${prefix}/share/ffmpeg'
2942 docdir_default='${prefix}/share/doc/ffmpeg'
2943 incdir_default='${prefix}/include'
2944 libdir_default='${prefix}/lib'
2945 mandir_default='${prefix}/share/man'
2946
2947 # toolchain
2948 ar_default="ar"
2949 cc_default="gcc"
2950 cxx_default="g++"
2951 host_cc_default="gcc"
2952 cp_f="cp -f"
2953 doxygen_default="doxygen"
2954 install="install"
2955 ln_s="ln -s -f"
2956 nm_default="nm -g"
2957 objformat="elf"
2958 pkg_config_default=pkg-config
2959 ranlib_default="ranlib"
2960 strip_default="strip"
2961 yasmexe_default="yasm"
2962 windres_default="windres"
2963
2964 # OS
2965 target_os_default=$(tolower $(uname -s))
2966 host_os=$target_os_default
2967
2968 # machine
2969 if test "$target_os_default" = aix; then
2970     arch_default=$(uname -p)
2971     strip_default="strip -X32_64"
2972 else
2973     arch_default=$(uname -m)
2974 fi
2975 cpu="generic"
2976 intrinsics="none"
2977
2978 # configurable options
2979 enable $PROGRAM_LIST
2980 enable $DOCUMENT_LIST
2981 enable $EXAMPLE_LIST
2982 enable $(filter_out avresample $LIBRARY_LIST)
2983 enable stripping
2984
2985 enable asm
2986 enable debug
2987 enable doc
2988 enable faan faandct faanidct
2989 enable optimizations
2990 enable runtime_cpudetect
2991 enable safe_bitstream_reader
2992 enable static
2993 enable swscale_alpha
2994 enable valgrind_backtrace
2995
2996 sws_max_filter_size_default=256
2997 set_default sws_max_filter_size
2998
2999 # Enable hwaccels by default.
3000 enable d3d11va dxva2 vaapi vda vdpau videotoolbox xvmc
3001 enable xlib
3002
3003 # build settings
3004 SHFLAGS='-shared -Wl,-soname,$$(@F)'
3005 LIBPREF="lib"
3006 LIBSUF=".a"
3007 FULLNAME='$(NAME)$(BUILDSUF)'
3008 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
3009 SLIBPREF="lib"
3010 SLIBSUF=".so"
3011 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
3012 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
3013 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
3014 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
3015 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
3016 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
3017
3018 asflags_filter=echo
3019 cflags_filter=echo
3020 ldflags_filter=echo
3021
3022 AS_C='-c'
3023 AS_O='-o $@'
3024 CC_C='-c'
3025 CC_E='-E -o $@'
3026 CC_O='-o $@'
3027 CXX_C='-c'
3028 CXX_O='-o $@'
3029 LD_O='-o $@'
3030 LD_LIB='-l%'
3031 LD_PATH='-L'
3032 HOSTCC_C='-c'
3033 HOSTCC_E='-E -o $@'
3034 HOSTCC_O='-o $@'
3035 HOSTLD_O='-o $@'
3036
3037 host_libs='-lm'
3038 host_cflags_filter=echo
3039 host_ldflags_filter=echo
3040
3041 target_path='$(CURDIR)'
3042
3043 # since the object filename is not given with the -MM flag, the compiler
3044 # is only able to print the basename, and we must add the path ourselves
3045 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)'
3046 DEPFLAGS='-MM'
3047
3048 # find source path
3049 if test -f configure; then
3050     source_path=.
3051 else
3052     source_path=$(cd $(dirname "$0"); pwd)
3053     case "$source_path" in
3054         *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;;
3055     esac
3056     test -e "$source_path/config.h" &&
3057         die "Out of tree builds are impossible with config.h in source dir."
3058 fi
3059
3060 for v in "$@"; do
3061     r=${v#*=}
3062     l=${v%"$r"}
3063     r=$(sh_quote "$r")
3064     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
3065 done
3066
3067 find_things(){
3068     thing=$1
3069     pattern=$2
3070     file=$source_path/$3
3071     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
3072 }
3073
3074 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
3075 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
3076 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
3077 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
3078 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
3079 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
3080 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
3081 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
3082 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
3083 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
3084 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
3085
3086 ALL_COMPONENTS="
3087     $BSF_LIST
3088     $DECODER_LIST
3089     $DEMUXER_LIST
3090     $ENCODER_LIST
3091     $FILTER_LIST
3092     $HWACCEL_LIST
3093     $INDEV_LIST
3094     $MUXER_LIST
3095     $OUTDEV_LIST
3096     $PARSER_LIST
3097     $PROTOCOL_LIST
3098 "
3099
3100 for n in $COMPONENT_LIST; do
3101     v=$(toupper ${n%s})_LIST
3102     eval enable \$$v
3103     eval ${n}_if_any="\$$v"
3104 done
3105
3106 enable $ARCH_EXT_LIST
3107
3108 die_unknown(){
3109     echo "Unknown option \"$1\"."
3110     echo "See $0 --help for available options."
3111     exit 1
3112 }
3113
3114 print_in_columns() {
3115     cols=$(expr $ncols / 24)
3116     cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
3117 }
3118
3119 show_list() {
3120     suffix=_$1
3121     shift
3122     echo $* | sed s/$suffix//g | print_in_columns
3123     exit 0
3124 }
3125
3126 rand_list(){
3127     IFS=', '
3128     set -- $*
3129     unset IFS
3130     for thing; do
3131         comp=${thing%:*}
3132         prob=${thing#$comp}
3133         prob=${prob#:}
3134         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
3135         echo "prob ${prob:-0.5}"
3136         printf '%s\n' $comp
3137     done
3138 }
3139
3140 do_random(){
3141     action=$1
3142     shift
3143     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
3144     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
3145 }
3146
3147 for opt do
3148     optval="${opt#*=}"
3149     case "$opt" in
3150         --extra-ldflags=*)
3151             add_ldflags $optval
3152         ;;
3153         --extra-ldexeflags=*)
3154             add_ldexeflags $optval
3155         ;;
3156         --extra-ldlibflags=*)
3157             add_ldlibflags $optval
3158         ;;
3159         --extra-libs=*)
3160             add_extralibs $optval
3161         ;;
3162         --disable-devices)
3163             disable $INDEV_LIST $OUTDEV_LIST
3164         ;;
3165         --enable-debug=*)
3166             debuglevel="$optval"
3167         ;;
3168         --disable-programs)
3169             disable $PROGRAM_LIST
3170         ;;
3171         --disable-everything)
3172             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
3173         ;;
3174         --disable-all)
3175             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
3176             disable $LIBRARY_LIST $PROGRAM_LIST doc
3177             enable avutil
3178         ;;
3179         --enable-random|--disable-random)
3180             action=${opt%%-random}
3181             do_random ${action#--} $COMPONENT_LIST
3182         ;;
3183         --enable-random=*|--disable-random=*)
3184             action=${opt%%-random=*}
3185             do_random ${action#--} $optval
3186         ;;
3187         --enable-*=*|--disable-*=*)
3188             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
3189             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
3190             eval list=\$$(toupper $thing)_LIST
3191             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
3192             list=$(filter "$name" $list)
3193             [ "$list" = "" ] && warn "Option $opt did not match anything"
3194             $action $list
3195         ;;
3196         --enable-?*|--disable-?*)
3197             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
3198             if is_in $option $COMPONENT_LIST; then
3199                 test $action = disable && action=unset
3200                 eval $action \$$(toupper ${option%s})_LIST
3201             elif is_in $option $CMDLINE_SELECT; then
3202                 $action $option
3203             else
3204                 die_unknown $opt
3205             fi
3206         ;;
3207         --list-*)
3208             NAME="${opt#--list-}"
3209             is_in $NAME $COMPONENT_LIST || die_unknown $opt
3210             NAME=${NAME%s}
3211             eval show_list $NAME \$$(toupper $NAME)_LIST
3212         ;;
3213         --help|-h) show_help
3214         ;;
3215         --fatal-warnings) enable fatal_warnings
3216         ;;
3217         *)
3218             optname="${opt%%=*}"
3219             optname="${optname#--}"
3220             optname=$(echo "$optname" | sed 's/-/_/g')
3221             if is_in $optname $CMDLINE_SET; then
3222                 eval $optname='$optval'
3223             elif is_in $optname $CMDLINE_APPEND; then
3224                 append $optname "$optval"
3225             else
3226                 die_unknown $opt
3227             fi
3228         ;;
3229     esac
3230 done
3231
3232 for e in $env; do
3233     eval "export $e"
3234 done
3235
3236 disabled logging && logfile=/dev/null
3237
3238 # Disable all the library-specific components if the library itself
3239 # is disabled, see AVCODEC_LIST and following _LIST variables.
3240
3241 disable_components(){
3242     disabled ${1} && disable $(
3243         eval components="\$$(toupper ${1})_COMPONENTS"
3244         map 'eval echo \${$(toupper ${v%s})_LIST}' $components
3245     )
3246 }
3247
3248 map 'disable_components $v' $LIBRARY_LIST
3249
3250 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
3251 set >> $logfile
3252
3253 test -n "$valgrind" && toolchain="valgrind-memcheck"
3254
3255 case "$toolchain" in
3256     clang-asan)
3257         cc_default="clang"
3258         add_cflags  -fsanitize=address
3259         add_ldflags -fsanitize=address
3260     ;;
3261     clang-tsan)
3262         cc_default="clang"
3263         add_cflags  -fsanitize=thread -pie
3264         add_ldflags -fsanitize=thread -pie
3265     ;;
3266     clang-usan)
3267         cc_default="clang"
3268         add_cflags  -fsanitize=undefined
3269         add_ldflags -fsanitize=undefined
3270     ;;
3271     gcc-asan)
3272         cc_default="gcc"
3273         add_cflags  -fsanitize=address
3274         add_ldflags -fsanitize=address
3275     ;;
3276     gcc-tsan)
3277         cc_default="gcc"
3278         add_cflags  -fsanitize=thread -pie -fPIC
3279         add_ldflags -fsanitize=thread -pie -fPIC
3280     ;;
3281     gcc-usan)
3282         cc_default="gcc"
3283         add_cflags  -fsanitize=undefined
3284         add_ldflags -fsanitize=undefined
3285     ;;
3286     valgrind-massif)
3287         target_exec_default=${valgrind:-"valgrind"}
3288         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"
3289     ;;
3290     valgrind-memcheck)
3291         target_exec_default=${valgrind:-"valgrind"}
3292         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"
3293     ;;
3294     msvc)
3295         # Check whether the current MSVC version needs the C99 converter.
3296         # From MSVC 2013 (compiler major version 18) onwards, it does actually
3297         # support enough of C99 to build ffmpeg. Default to the new
3298         # behaviour if the regexp was unable to match anything, since this
3299         # successfully parses the version number of existing supported
3300         # versions that require the converter (MSVC 2010 and 2012).
3301         cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
3302         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
3303             cc_default="cl"
3304         else
3305             cc_default="c99wrap cl"
3306         fi
3307         ld_default="$source_path/compat/windows/mslink"
3308         nm_default="dumpbin -symbols"
3309         ar_default="lib"
3310         case "$arch" in
3311         arm*)
3312             as_default="armasm"
3313             ;;
3314         esac
3315         target_os_default="win32"
3316         # Use a relative path for TMPDIR. This makes sure all the
3317         # ffconf temp files are written with a relative path, avoiding
3318         # issues with msys/win32 path conversion for MSVC parameters
3319         # such as -Fo<file> or -out:<file>.
3320         TMPDIR=.
3321     ;;
3322     icl)
3323         cc_default="icl"
3324         ld_default="xilink"
3325         nm_default="dumpbin -symbols"
3326         ar_default="xilib"
3327         target_os_default="win32"
3328         TMPDIR=.
3329     ;;
3330     gcov)
3331         add_cflags  -fprofile-arcs -ftest-coverage
3332         add_ldflags -fprofile-arcs -ftest-coverage
3333     ;;
3334     hardened)
3335         add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
3336         add_cflags   -fno-strict-overflow -fstack-protector-all
3337         add_ldflags  -Wl,-z,relro -Wl,-z,now
3338     ;;
3339     ?*)
3340         die "Unknown toolchain $toolchain"
3341     ;;
3342 esac
3343
3344 test -n "$cross_prefix" && enable cross_compile
3345
3346 if enabled cross_compile; then
3347     test -n "$arch" && test -n "$target_os" ||
3348         die "Must specify target arch and OS when cross-compiling"
3349 fi
3350
3351 ar_default="${cross_prefix}${ar_default}"
3352 cc_default="${cross_prefix}${cc_default}"
3353 cxx_default="${cross_prefix}${cxx_default}"
3354 nm_default="${cross_prefix}${nm_default}"
3355 pkg_config_default="${cross_prefix}${pkg_config_default}"
3356 if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then
3357     ranlib_default="${cross_prefix}${ranlib_default} -D"
3358 else
3359     ranlib_default="${cross_prefix}${ranlib_default}"
3360 fi
3361 strip_default="${cross_prefix}${strip_default}"
3362 windres_default="${cross_prefix}${windres_default}"
3363
3364 sysinclude_default="${sysroot}/usr/include"
3365
3366 set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
3367     target_exec target_os yasmexe
3368 enabled cross_compile || host_cc_default=$cc
3369 set_default host_cc
3370
3371 pkg_config_fail_message=""
3372 if ! $pkg_config --version >/dev/null 2>&1; then
3373     warn "$pkg_config not found, library detection may fail."
3374     pkg_config=false
3375 elif is_in -static $cc $LDFLAGS && ! is_in --static $pkg_config $pkg_config_flags; then
3376     pkg_config_fail_message="
3377 Note: When building a static binary, add --pkg-config-flags=\"--static\"."
3378 fi
3379
3380 if test $doxygen != $doxygen_default && \
3381   ! $doxygen --version >/dev/null 2>&1; then
3382     warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build."
3383 fi
3384
3385 exesuf() {
3386     case $1 in
3387         mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
3388     esac
3389 }
3390
3391 EXESUF=$(exesuf $target_os)
3392 HOSTEXESUF=$(exesuf $host_os)
3393
3394 # set temporary file name
3395 : ${TMPDIR:=$TEMPDIR}
3396 : ${TMPDIR:=$TMP}
3397 : ${TMPDIR:=/tmp}
3398
3399 if [ -n "$tempprefix" ] ; then
3400     mktemp(){
3401         echo $tempprefix.${HOSTNAME}.${UID}
3402     }
3403 elif ! check_cmd mktemp -u XXXXXX; then
3404     # simple replacement for missing mktemp
3405     # NOT SAFE FOR GENERAL USE
3406     mktemp(){
3407         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
3408     }
3409 fi
3410
3411 tmpfile(){
3412     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
3413         (set -C; exec > $tmp) 2>/dev/null ||
3414         die "Unable to create temporary file in $TMPDIR."
3415     append TMPFILES $tmp
3416     eval $1=$tmp
3417 }
3418
3419 trap 'rm -f -- $TMPFILES' EXIT
3420
3421 tmpfile TMPASM .asm
3422 tmpfile TMPC   .c
3423 tmpfile TMPCPP .cpp
3424 tmpfile TMPE   $EXESUF
3425 tmpfile TMPH   .h
3426 tmpfile TMPM   .m
3427 tmpfile TMPO   .o
3428 tmpfile TMPS   .S
3429 tmpfile TMPSH  .sh
3430 tmpfile TMPV   .ver
3431
3432 unset -f mktemp
3433
3434 chmod +x $TMPE
3435
3436 # make sure we can execute files in $TMPDIR
3437 cat > $TMPSH 2>> $logfile <<EOF
3438 #! /bin/sh
3439 EOF
3440 chmod +x $TMPSH >> $logfile 2>&1
3441 if ! $TMPSH >> $logfile 2>&1; then
3442     cat <<EOF
3443 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
3444 variable to another directory and make sure that it is not mounted noexec.
3445 EOF
3446     die "Sanity test failed."
3447 fi
3448
3449 armasm_flags(){
3450     for flag; do
3451         case $flag in
3452             # Filter out MSVC cl.exe options from cflags that shouldn't
3453             # be passed to gas-preprocessor
3454             -M[TD]*)                                            ;;
3455             *)                  echo $flag                      ;;
3456         esac
3457    done
3458 }
3459
3460 ccc_flags(){
3461     for flag; do
3462         case $flag in
3463             -std=c99)           echo -c99                       ;;
3464             -mcpu=*)            echo -arch ${flag#*=}           ;;
3465             -mieee)             echo -ieee                      ;;
3466             -O*|-fast)          echo $flag                      ;;
3467             -fno-math-errno)    echo -assume nomath_errno       ;;
3468             -g)                 echo -g3                        ;;
3469             -Wall)              echo -msg_enable level2         ;;
3470             -Wno-pointer-sign)  echo -msg_disable ptrmismatch1  ;;
3471             -Wl,*)              echo $flag                      ;;
3472             -f*|-W*)                                            ;;
3473             *)                  echo $flag                      ;;
3474         esac
3475    done
3476 }
3477
3478 cparser_flags(){
3479     for flag; do
3480         case $flag in
3481             -Wno-switch)             echo -Wno-switch-enum ;;
3482             -Wno-format-zero-length) ;;
3483             -Wdisabled-optimization) ;;
3484             -Wno-pointer-sign)       echo -Wno-other ;;
3485             *)                       echo $flag ;;
3486         esac
3487     done
3488 }
3489
3490 msvc_common_flags(){
3491     for flag; do
3492         case $flag in
3493             # In addition to specifying certain flags under the compiler
3494             # specific filters, they must be specified here as well or else the
3495             # generic catch all at the bottom will print the original flag.
3496             -Wall)                ;;
3497             -std=c99)             ;;
3498             # Common flags
3499             -fomit-frame-pointer) ;;
3500             -g)                   echo -Z7 ;;
3501             -fno-math-errno)      ;;
3502             -fno-common)          ;;
3503             -fno-signed-zeros)    ;;
3504             -fPIC)                ;;
3505             -mthumb)              ;;
3506             -march=*)             ;;
3507             -lz)                  echo zlib.lib ;;
3508             -lavifil32)           echo vfw32.lib ;;
3509             -lavicap32)           echo vfw32.lib user32.lib ;;
3510             -l*)                  echo ${flag#-l}.lib ;;
3511             -LARGEADDRESSAWARE)   echo $flag ;;
3512             -L*)                  echo -libpath:${flag#-L} ;;
3513             *)                    echo $flag ;;
3514         esac
3515     done
3516 }
3517
3518 msvc_flags(){
3519     msvc_common_flags "$@"
3520     for flag; do
3521         case $flag in
3522             -Wall)                echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
3523                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
3524                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
3525                                        -wd4307 \
3526                                        -wd4273 -wd4554 -wd4701 ;;
3527         esac
3528     done
3529 }
3530
3531 icl_flags(){
3532     msvc_common_flags "$@"
3533     for flag; do
3534         case $flag in
3535             # Despite what Intel's documentation says -Wall, which is supported
3536             # on Windows, does enable remarks so disable them here.
3537             -Wall)                echo $flag -Qdiag-disable:remark ;;
3538             -std=c99)             echo -Qstd=c99 ;;
3539             -flto)                echo -ipo ;;
3540         esac
3541     done
3542 }
3543
3544 icc_flags(){
3545     for flag; do
3546         case $flag in
3547             -flto)                echo -ipo ;;
3548             *)                    echo $flag ;;
3549         esac
3550     done
3551 }
3552
3553 pgi_flags(){
3554     for flag; do
3555         case $flag in
3556             -flto)                echo -Mipa=fast,libopt,libinline,vestigial ;;
3557             -fomit-frame-pointer) echo -Mnoframe ;;
3558             -g)                   echo -gopt ;;
3559             *)                    echo $flag ;;
3560         esac
3561     done
3562 }
3563
3564 suncc_flags(){
3565     for flag; do
3566         case $flag in
3567             -march=*|-mcpu=*)
3568                 case "${flag#*=}" in
3569                     native)                   echo -xtarget=native       ;;
3570                     v9|niagara)               echo -xarch=sparc          ;;
3571                     ultrasparc)               echo -xarch=sparcvis       ;;
3572                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
3573                     i586|pentium)             echo -xchip=pentium        ;;
3574                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
3575                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
3576                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
3577                     pentium4*)          echo -xtarget=pentium4           ;;
3578                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
3579                     *-sse3)             echo -xarch=sse3                 ;;
3580                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
3581                     bonnell)                   echo -xarch=ssse3         ;;
3582                     corei7|nehalem)            echo -xtarget=nehalem     ;;
3583                     westmere)                  echo -xtarget=westmere    ;;
3584                     silvermont)                echo -xarch=sse4_2        ;;
3585                     corei7-avx|sandybridge)    echo -xtarget=sandybridge ;;
3586                     core-avx*|ivybridge|haswell|broadwell)
3587                                                echo -xarch=avx           ;;
3588                     amdfam10|barcelona)        echo -xtarget=barcelona   ;;
3589                     btver1)                    echo -xarch=amdsse4a      ;;
3590                     btver2|bdver*)             echo -xarch=avx           ;;
3591                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
3592                     k8|opteron|athlon64|athlon-fx)
3593                                                echo -xarch=sse2a         ;;
3594                     athlon*)                   echo -xarch=pentium_proa  ;;
3595                 esac
3596                 ;;
3597             -std=c99)             echo -xc99              ;;
3598             -fomit-frame-pointer) echo -xregs=frameptr    ;;
3599             -fPIC)                echo -KPIC -xcode=pic32 ;;
3600             -W*,*)                echo $flag              ;;
3601             -f*-*|-W*|-mimpure-text)                      ;;
3602             -shared)              echo -G                 ;;
3603             *)                    echo $flag              ;;
3604         esac
3605     done
3606 }
3607
3608 tms470_flags(){
3609     for flag; do
3610         case $flag in
3611             -march=*|-mcpu=*)
3612                 case "${flag#*=}" in
3613                     armv7-a|cortex-a*)      echo -mv=7a8 ;;
3614                     armv7-r|cortex-r*)      echo -mv=7r4 ;;
3615                     armv7-m|cortex-m*)      echo -mv=7m3 ;;
3616                     armv6*|arm11*)          echo -mv=6   ;;
3617                     armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
3618                                             echo -mv=5e  ;;
3619                     armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
3620                 esac
3621                 ;;
3622             -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
3623             -mfpu=vfp)      echo --float_support=vfpv2        ;;
3624             -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
3625             -mfpu=vfpv3-d16) echo --float_support=vfpv3d16    ;;
3626             -msoft-float)   echo --float_support=vfplib       ;;
3627             -O[0-3]|-mf=*)  echo $flag                        ;;
3628             -g)             echo -g -mn                       ;;
3629             -pds=*)         echo $flag                        ;;
3630             -D*|-I*)        echo $flag                        ;;
3631             --gcc|--abi=*)  echo $flag                        ;;
3632             -me)            echo $flag                        ;;
3633         esac
3634     done
3635 }
3636
3637 probe_cc(){
3638     pfx=$1
3639     _cc=$2
3640     first=$3
3641
3642     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
3643     unset _ld_o _ldflags _ld_lib _ld_path
3644     unset _depflags _DEPCMD _DEPFLAGS
3645     _flags_filter=echo
3646
3647     if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
3648         true # no-op to avoid reading stdin in following checks
3649     elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
3650         _type=llvm_gcc
3651         gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
3652         _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
3653         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3654         _cflags_speed='-O3'
3655         _cflags_size='-Os'
3656     elif $_cc -v 2>&1 | grep -qi ^gcc; then
3657         _type=gcc
3658         gcc_version=$($_cc --version | head -n1)
3659         gcc_basever=$($_cc -dumpversion)
3660         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
3661         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
3662         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
3663         case $gcc_basever in
3664             2*) ;;
3665             *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;;
3666         esac
3667         if [ "$first" = true ]; then
3668             case $gcc_basever in
3669                 4.2*)
3670                 warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;;
3671             esac
3672         fi
3673         _cflags_speed='-O3'
3674         _cflags_size='-Os'
3675     elif $_cc --version 2>/dev/null | grep -q ^icc; then
3676         _type=icc
3677         _ident=$($_cc --version | head -n1)
3678         _depflags='-MMD'
3679         _cflags_speed='-O3'
3680         _cflags_size='-Os'
3681         _cflags_noopt='-O1'
3682         _flags_filter=icc_flags
3683     elif $_cc -v 2>&1 | grep -q xlc; then
3684         _type=xlc
3685         _ident=$($_cc -qversion 2>/dev/null | head -n1)
3686         _cflags_speed='-O5'
3687         _cflags_size='-O5 -qcompact'
3688     elif $_cc -V 2>/dev/null | grep -q Compaq; then
3689         _type=ccc
3690         _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
3691         _DEPFLAGS='-M'
3692         _cflags_speed='-fast'
3693         _cflags_size='-O1'
3694         _flags_filter=ccc_flags
3695     elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
3696         test -d "$sysroot" || die "No valid sysroot specified."
3697         _type=armcc
3698         _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
3699         armcc_conf="$PWD/armcc.conf"
3700         $_cc --arm_linux_configure                 \
3701              --arm_linux_config_file="$armcc_conf" \
3702              --configure_sysroot="$sysroot"        \
3703              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
3704              die "Error creating armcc configuration file."
3705         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
3706         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
3707         as_default="${cross_prefix}gcc"
3708         _depflags='-MMD'
3709         _cflags_speed='-O3'
3710         _cflags_size='-Os'
3711     elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
3712         _type=tms470
3713         _ident=$($_cc -version | head -n1 | tr -s ' ')
3714         _flags='--gcc --abi=eabi -me'
3715         _cc_e='-ppl -fe=$@'
3716         _cc_o='-fe=$@'
3717         _depflags='-ppa -ppd=$(@:.o=.d)'
3718         _cflags_speed='-O3 -mf=5'
3719         _cflags_size='-O3 -mf=2'
3720         _flags_filter=tms470_flags
3721     elif $_cc -v 2>&1 | grep -q clang; then
3722         _type=clang
3723         _ident=$($_cc --version 2>/dev/null | head -n1)
3724         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3725         _cflags_speed='-O3'
3726         _cflags_size='-Os'
3727     elif $_cc -V 2>&1 | grep -q Sun; then
3728         _type=suncc
3729         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
3730         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
3731         _DEPFLAGS='-xM1 -xc99'
3732         _ldflags='-std=c99'
3733         _cflags_speed='-O5'
3734         _cflags_size='-O5 -xspace'
3735         _flags_filter=suncc_flags
3736     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
3737         _type=pathscale
3738         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3739         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3740         _cflags_speed='-O2'
3741         _cflags_size='-Os'
3742         _flags_filter='filter_out -Wdisabled-optimization'
3743     elif $_cc -v 2>&1 | grep -q Open64; then
3744         _type=open64
3745         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3746         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3747         _cflags_speed='-O2'
3748         _cflags_size='-Os'
3749         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
3750     elif $_cc -V 2>&1 | grep -q Portland; then
3751         _type=pgi
3752         _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
3753         opt_common='-alias=ansi -Mdse -Mlre -Mpre'
3754         _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
3755         _cflags_size="-O2 -Munroll=c:1 $opt_common"
3756         _cflags_noopt="-O"
3757         _flags_filter=pgi_flags
3758     elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
3759         _type=armasm
3760         _ident=$($_cc | head -n1)
3761         # 4509: "This form of conditional instruction is deprecated"
3762         _flags="-nologo -ignore 4509"
3763         _flags_filter=armasm_flags
3764     elif $_cc 2>&1 | grep -q Intel; then
3765         _type=icl
3766         _ident=$($_cc 2>&1 | head -n1)
3767         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
3768         # Not only is O3 broken on 13.x+ but it is slower on all previous
3769         # versions (tested) as well.
3770         _cflags_speed="-O2"
3771         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
3772         if $_cc 2>&1 | grep -q Linker; then
3773             _ld_o='-out:$@'
3774         else
3775             _ld_o='-Fe$@'
3776         fi
3777         _cc_o='-Fo$@'
3778         _cc_e='-P'
3779         _flags_filter=icl_flags
3780         _ld_lib='lib%.a'
3781         _ld_path='-libpath:'
3782         # -Qdiag-error to make icl error when seeing certain unknown arguments
3783         _flags='-nologo -Qdiag-error:4044,10157'
3784         # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency
3785         # with MSVC which enables it by default.
3786         _cflags='-D_USE_MATH_DEFINES -Qms0 -Qvec- -Qsimd- -GS -fp:precise'
3787         disable stripping
3788     elif $_cc -nologo- 2>&1 | grep -q Microsoft; then
3789         _type=msvc
3790         _ident=$($_cc 2>&1 | head -n1)
3791         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
3792         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
3793         _cflags_speed="-O2"
3794         _cflags_size="-O1"
3795         if $_cc -nologo- 2>&1 | grep -q Linker; then
3796             _ld_o='-out:$@'
3797         else
3798             _ld_o='-Fe$@'
3799         fi
3800         _cc_o='-Fo$@'
3801         _cc_e='-P -Fi$@'
3802         _flags_filter=msvc_flags
3803         _ld_lib='lib%.a'
3804         _ld_path='-libpath:'
3805         _flags='-nologo'
3806         _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS'
3807         disable stripping
3808     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3809         _type=cparser
3810         _ident=$($_cc --version | head -n1)
3811         _depflags='-MMD'
3812         _cflags_speed='-O4'
3813         _cflags_size='-O2'
3814         _flags_filter=cparser_flags
3815     fi
3816
3817     eval ${pfx}_type=\$_type
3818     eval ${pfx}_ident=\$_ident
3819 }
3820
3821 set_ccvars(){
3822     eval ${1}_C=\${_cc_c-\${${1}_C}}
3823     eval ${1}_E=\${_cc_e-\${${1}_E}}
3824     eval ${1}_O=\${_cc_o-\${${1}_O}}
3825
3826     if [ -n "$_depflags" ]; then
3827         eval ${1}_DEPFLAGS=\$_depflags
3828     else
3829         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3830         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3831         eval DEP${1}FLAGS=\$_flags
3832     fi
3833 }
3834
3835 probe_cc cc "$cc" "true"
3836 cflags_filter=$_flags_filter
3837 cflags_speed=$_cflags_speed
3838 cflags_size=$_cflags_size
3839 cflags_noopt=$_cflags_noopt
3840 add_cflags $_flags $_cflags
3841 cc_ldflags=$_ldflags
3842 set_ccvars CC
3843
3844 probe_cc hostcc "$host_cc"
3845 host_cflags_filter=$_flags_filter
3846 add_host_cflags  $_flags $_cflags
3847 set_ccvars HOSTCC
3848
3849 test -n "$cc_type" && enable $cc_type ||
3850     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3851
3852 : ${as_default:=$cc}
3853 : ${dep_cc_default:=$cc}
3854 : ${ld_default:=$cc}
3855 : ${host_ld_default:=$host_cc}
3856 set_default ar as dep_cc ld host_ld windres
3857
3858 probe_cc as "$as"
3859 asflags_filter=$_flags_filter
3860 add_asflags $_flags $_cflags
3861 set_ccvars AS
3862
3863 probe_cc ld "$ld"
3864 ldflags_filter=$_flags_filter
3865 add_ldflags $_flags $_ldflags
3866 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3867 LD_O=${_ld_o-$LD_O}
3868 LD_LIB=${_ld_lib-$LD_LIB}
3869 LD_PATH=${_ld_path-$LD_PATH}
3870
3871 probe_cc hostld "$host_ld"
3872 host_ldflags_filter=$_flags_filter
3873 add_host_ldflags $_flags $_ldflags
3874 HOSTLD_O=${_ld_o-$HOSTLD_O}
3875
3876 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3877     probe_cc depcc "$dep_cc"
3878     CCDEP=${_DEPCMD:-$DEPCMD}
3879     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3880     DEPCCFLAGS=$_flags
3881 fi
3882
3883 if $ar 2>&1 | grep -q Microsoft; then
3884     arflags="-nologo"
3885     ar_o='-out:$@'
3886 elif $ar 2>&1 | grep -q 'Texas Instruments'; then
3887     arflags="rq"
3888     ar_o='$@'
3889 elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then
3890     arflags='-Xany -r -c'
3891     ar_o='$@'
3892 elif $ar 2>&1 | grep -q "\[D\] "; then
3893     arflags="rcD"
3894     ar_o='$@'
3895 else
3896     arflags="rc"
3897     ar_o='$@'
3898 fi
3899
3900 add_cflags $extra_cflags
3901 add_cxxflags $extra_cxxflags
3902 add_asflags $extra_cflags
3903
3904 if test -n "$sysroot"; then
3905     case "$cc_type" in
3906         gcc|llvm_gcc|clang)
3907             add_cppflags --sysroot="$sysroot"
3908             add_ldflags --sysroot="$sysroot"
3909 # On Darwin --sysroot may be ignored, -isysroot always affects headers and linking
3910             add_cppflags -isysroot "$sysroot"
3911             add_ldflags -isysroot "$sysroot"
3912         ;;
3913         tms470)
3914             add_cppflags -I"$sysinclude"
3915             add_ldflags  --sysroot="$sysroot"
3916         ;;
3917     esac
3918 fi
3919
3920 if test "$cpu" = host; then
3921     enabled cross_compile &&
3922         die "--cpu=host makes no sense when cross-compiling."
3923
3924     case "$cc_type" in
3925         gcc|llvm_gcc)
3926             check_native(){
3927                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3928                 sed -n "/cc1.*$1=/{
3929                             s/.*$1=\\([^ ]*\\).*/\\1/
3930                             p
3931                             q
3932                         }" $TMPE
3933             }
3934             cpu=$(check_native -march || check_native -mcpu)
3935         ;;
3936     esac
3937
3938     test "${cpu:-host}" = host &&
3939         die "--cpu=host not supported with compiler $cc"
3940 fi
3941
3942 # Deal with common $arch aliases
3943 case "$arch" in
3944     aarch64|arm64)
3945         arch="aarch64"
3946     ;;
3947     arm*|iPad*|iPhone*)
3948         arch="arm"
3949     ;;
3950     mips*|IP*)
3951         arch="mips"
3952     ;;
3953     parisc*|hppa*)
3954         arch="parisc"
3955     ;;
3956     "Power Macintosh"|ppc*|powerpc*)
3957         arch="ppc"
3958     ;;
3959     s390|s390x)
3960         arch="s390"
3961     ;;
3962     sh4|sh)
3963         arch="sh4"
3964     ;;
3965     sun4u|sparc*)
3966         arch="sparc"
3967     ;;
3968     tilegx|tile-gx)
3969         arch="tilegx"
3970     ;;
3971     i[3-6]86*|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
3972         arch="x86"
3973     ;;
3974 esac
3975
3976 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3977 enable $arch
3978
3979 # Add processor-specific flags
3980 if enabled aarch64; then
3981
3982     case $cpu in
3983         armv*)
3984             cpuflags="-march=$cpu"
3985         ;;
3986         *)
3987             cpuflags="-mcpu=$cpu"
3988         ;;
3989     esac
3990
3991 elif enabled alpha; then
3992
3993     cpuflags="-mcpu=$cpu"
3994
3995 elif enabled arm; then
3996
3997     check_arm_arch() {
3998         check_cpp_condition stddef.h \
3999             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
4000             $cpuflags
4001     }
4002
4003     probe_arm_arch() {
4004         if   check_arm_arch 4;        then echo armv4;
4005         elif check_arm_arch 4T;       then echo armv4t;
4006         elif check_arm_arch 5;        then echo armv5;
4007         elif check_arm_arch 5E;       then echo armv5e;
4008         elif check_arm_arch 5T;       then echo armv5t;
4009         elif check_arm_arch 5TE;      then echo armv5te;
4010         elif check_arm_arch 5TEJ;     then echo armv5te;
4011         elif check_arm_arch 6;        then echo armv6;
4012         elif check_arm_arch 6J;       then echo armv6j;
4013         elif check_arm_arch 6K;       then echo armv6k;
4014         elif check_arm_arch 6Z;       then echo armv6z;
4015         elif check_arm_arch 6ZK;      then echo armv6zk;
4016         elif check_arm_arch 6T2;      then echo armv6t2;
4017         elif check_arm_arch 7;        then echo armv7;
4018         elif check_arm_arch 7A  7_A;  then echo armv7-a;
4019         elif check_arm_arch 7S;       then echo armv7-a;
4020         elif check_arm_arch 7R  7_R;  then echo armv7-r;
4021         elif check_arm_arch 7M  7_M;  then echo armv7-m;
4022         elif check_arm_arch 7EM 7E_M; then echo armv7-m;
4023         elif check_arm_arch 8A  8_A;  then echo armv8-a;
4024         fi
4025     }
4026
4027     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
4028
4029     case $cpu in
4030         armv*)
4031             cpuflags="-march=$cpu"
4032             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
4033         ;;
4034         *)
4035             cpuflags="-mcpu=$cpu"
4036             case $cpu in
4037                 cortex-a*)                               subarch=armv7a  ;;
4038                 cortex-r*)                               subarch=armv7r  ;;
4039                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
4040                 arm11*)                                  subarch=armv6   ;;
4041                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
4042                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
4043                 *)                             subarch=$(probe_arm_arch) ;;
4044             esac
4045         ;;
4046     esac
4047
4048     case "$subarch" in
4049         armv5t*)    enable fast_clz                ;;
4050         armv[6-8]*)
4051             enable fast_clz
4052             disabled fast_unaligned || enable fast_unaligned
4053             ;;
4054     esac
4055
4056 elif enabled avr32; then
4057
4058     case $cpu in
4059         ap7[02]0[0-2])
4060             subarch="avr32_ap"
4061             cpuflags="-mpart=$cpu"
4062         ;;
4063         ap)
4064             subarch="avr32_ap"
4065             cpuflags="-march=$cpu"
4066         ;;
4067         uc3[ab]*)
4068             subarch="avr32_uc"
4069             cpuflags="-mcpu=$cpu"
4070         ;;
4071         uc)
4072             subarch="avr32_uc"
4073             cpuflags="-march=$cpu"
4074         ;;
4075     esac
4076
4077 elif enabled bfin; then
4078
4079     cpuflags="-mcpu=$cpu"
4080
4081 elif enabled mips; then
4082
4083     cpuflags="-march=$cpu"
4084
4085     case $cpu in
4086         24kc)
4087             disable mips64r6
4088             disable mipsfpu
4089             disable mipsdsp
4090             disable mipsdspr2
4091             disable msa
4092         ;;
4093         24kf*)
4094             disable mips64r6
4095             disable mipsdsp
4096             disable mipsdspr2
4097             disable msa
4098         ;;
4099         24kec|34kc|1004kc)
4100             disable mips64r6
4101             disable mipsfpu
4102             disable mipsdspr2
4103             disable msa
4104         ;;
4105         24kef*|34kf*|1004kf*)
4106             disable mips64r6
4107             disable mipsdspr2
4108             disable msa
4109         ;;
4110         74kc)
4111             disable mips64r6
4112             disable mipsfpu
4113             disable msa
4114         ;;
4115         74kf)
4116             disable mips64r6
4117             disable msa
4118         ;;
4119         p5600)
4120             disable mips64r6
4121             disable mipsdsp
4122             disable mipsdspr2
4123             check_cflags "-mtune=p5600" &&
4124             check_cflags "-mfp64 -msched-weight -mload-store-pairs -funroll-loops" &&
4125             add_asflags "-mfp64"
4126         ;;
4127         i6400)
4128             disable mipsdsp
4129             disable mipsdspr2
4130             disable mipsfpu
4131
4132             check_cflags "-mtune=i6400 -mabi=64"
4133             check_ldflags "-mabi=64"
4134         ;;
4135         loongson*)
4136             disable mipsfpu
4137             disable mips32r2
4138             disable mips64r6
4139             disable mipsdsp
4140             disable mipsdspr2
4141             disable msa
4142             enable local_aligned_8 local_aligned_16 local_aligned_32
4143             enable simd_align_16
4144             enable fast_64bit
4145             enable fast_clz
4146             enable fast_cmov
4147             enable fast_unaligned
4148             disable aligned_stack
4149             case $cpu in
4150                 loongson3*)
4151                     cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations"
4152                 ;;
4153                 loongson2e)
4154                     cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations"
4155                 ;;
4156                 loongson2f)
4157                     cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations"
4158                 ;;
4159             esac
4160         ;;
4161         generic)
4162             disable mips64r6
4163             disable msa
4164         ;;
4165         *)
4166             disable mipsfpu
4167             disable mips32r2
4168             disable mips64r6
4169             disable mipsdsp
4170             disable mipsdspr2
4171             disable msa
4172         ;;
4173     esac
4174
4175 elif enabled ppc; then
4176
4177     disable ldbrx
4178
4179     case $(tolower $cpu) in
4180         601|ppc601|powerpc601)
4181             cpuflags="-mcpu=601"
4182             disable altivec
4183         ;;
4184         603*|ppc603*|powerpc603*)
4185             cpuflags="-mcpu=603"
4186             disable altivec
4187         ;;
4188         604*|ppc604*|powerpc604*)
4189             cpuflags="-mcpu=604"
4190             disable altivec
4191         ;;
4192         g3|75*|ppc75*|powerpc75*)
4193             cpuflags="-mcpu=750"
4194             disable altivec
4195         ;;
4196         g4|745*|ppc745*|powerpc745*)
4197             cpuflags="-mcpu=7450"
4198             disable vsx
4199         ;;
4200         74*|ppc74*|powerpc74*)
4201             cpuflags="-mcpu=7400"
4202             disable vsx
4203         ;;
4204         g5|970|ppc970|powerpc970)
4205             cpuflags="-mcpu=970"
4206             disable vsx
4207         ;;
4208         power[3-6]*)
4209             cpuflags="-mcpu=$cpu"
4210             disable vsx
4211         ;;
4212         power[7-8]*)
4213             cpuflags="-mcpu=$cpu"
4214         ;;
4215         cell)
4216             cpuflags="-mcpu=cell"
4217             enable ldbrx
4218             disable vsx
4219         ;;
4220         e500mc)
4221             cpuflags="-mcpu=e500mc"
4222             disable altivec
4223         ;;
4224         e500v2)
4225             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
4226             disable altivec
4227             disable dcbzl
4228         ;;
4229         e500)
4230             cpuflags="-mcpu=8540 -mhard-float"
4231             disable altivec
4232             disable dcbzl
4233         ;;
4234     esac
4235
4236 elif enabled sparc; then
4237
4238     case $cpu in
4239         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
4240             cpuflags="-mcpu=$cpu"
4241         ;;
4242         ultrasparc*|niagara[234])
4243             cpuflags="-mcpu=$cpu"
4244         ;;
4245     esac
4246
4247 elif enabled x86; then
4248
4249     case $cpu in
4250         i[345]86|pentium)
4251             cpuflags="-march=$cpu"
4252             disable i686
4253             disable mmx
4254         ;;
4255         # targets that do NOT support nopl and conditional mov (cmov)
4256         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
4257             cpuflags="-march=$cpu"
4258             disable i686
4259         ;;
4260         # targets that do support nopl and conditional mov (cmov)
4261         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\
4262         |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*)
4263             cpuflags="-march=$cpu"
4264             enable i686
4265             enable fast_cmov
4266         ;;
4267         # targets that do support conditional mov but on which it's slow
4268         pentium4|pentium4m|prescott|nocona)
4269             cpuflags="-march=$cpu"
4270             enable i686
4271             disable fast_cmov
4272         ;;
4273     esac
4274
4275 fi
4276
4277 if [ "$cpu" != generic ]; then
4278     add_cflags  $cpuflags
4279     add_asflags $cpuflags
4280     test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
4281 fi
4282
4283 # compiler sanity check
4284 check_exec <<EOF
4285 int main(void){ return 0; }
4286 EOF
4287 if test "$?" != 0; then
4288     echo "$cc is unable to create an executable file."
4289     if test -z "$cross_prefix" && ! enabled cross_compile ; then
4290         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
4291         echo "Only do this if you know what cross compiling means."
4292     fi
4293     die "C compiler test failed."
4294 fi
4295
4296 add_cppflags -D_ISOC99_SOURCE
4297 add_cxxflags -D__STDC_CONSTANT_MACROS
4298 check_cflags -std=c99
4299 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
4300 #include <stdlib.h>
4301 EOF
4302 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
4303 #include <stdlib.h>
4304 EOF
4305
4306 add_host_cppflags -D_ISOC99_SOURCE
4307 check_host_cflags -std=c99
4308 check_host_cflags -Wall
4309 check_host_cflags -O3
4310
4311 check_64bit(){
4312     arch32=$1
4313     arch64=$2
4314     expr=$3
4315     check_code cc "" "int test[2*($expr) - 1]" &&
4316         subarch=$arch64 || subarch=$arch32
4317 }
4318
4319 case "$arch" in
4320     aarch64|alpha|ia64)
4321         spic=$shared
4322     ;;
4323     mips)
4324         check_64bit mips mips64 '_MIPS_SIM > 1'
4325         spic=$shared
4326     ;;
4327     parisc)
4328         check_64bit parisc parisc64 'sizeof(void *) > 4'
4329         spic=$shared
4330     ;;
4331     ppc)
4332         check_64bit ppc ppc64 'sizeof(void *) > 4'
4333         spic=$shared
4334     ;;
4335     s390)
4336         check_64bit s390 s390x 'sizeof(void *) > 4'
4337         spic=$shared
4338     ;;
4339     sparc)
4340         check_64bit sparc sparc64 'sizeof(void *) > 4'
4341         spic=$shared
4342     ;;
4343     x86)
4344         check_64bit x86_32 x86_64 'sizeof(void *) > 4'
4345         # Treat x32 as x64 for now. Note it also needs spic=$shared
4346         test "$subarch" = "x86_32" && check_cpp_condition stddef.h 'defined(__x86_64__)' &&
4347             subarch=x86_64
4348         if test "$subarch" = "x86_64"; then
4349             spic=$shared
4350         fi
4351     ;;
4352     ppc)
4353         check_cc <<EOF && subarch="ppc64"
4354         int test[(int)sizeof(char*) - 7];
4355 EOF
4356     ;;
4357 esac
4358
4359 enable $subarch
4360 enabled spic && enable_weak pic
4361
4362 # OS specific
4363 case $target_os in
4364     aix)
4365         SHFLAGS=-shared
4366         add_cppflags '-I\$(SRC_PATH)/compat/aix'
4367         enabled shared && add_ldflags -Wl,-brtl
4368         ;;
4369     android)
4370         disable symver
4371         enable section_data_rel_ro
4372         SLIB_INSTALL_NAME='$(SLIBNAME)'
4373         SLIB_INSTALL_LINKS=
4374         SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
4375         ;;
4376     haiku)
4377         prefix_default="/boot/common"
4378         network_extralibs="-lnetwork"
4379         host_libs=
4380         ;;
4381     sunos)
4382         SHFLAGS='-shared -Wl,-h,$$(@F)'
4383         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
4384         network_extralibs="-lsocket -lnsl"
4385         add_cppflags -D__EXTENSIONS__
4386         # When using suncc to build, the Solaris linker will mark
4387         # an executable with each instruction set encountered by
4388         # the Solaris assembler.  As our libraries contain their own
4389         # guards for processor-specific code, instead suppress
4390         # generation of the HWCAPS ELF section on Solaris x86 only.
4391         enabled_all suncc x86 &&
4392             echo "hwcap_1 = OVERRIDE;" > mapfile &&
4393             add_ldflags -Wl,-M,mapfile
4394         nm_default='nm -P -g'
4395         SLIB_CREATE_DEF_CMD='$(Q)perl $(SRC_PATH)/compat/solaris/make_sunver.pl $$(filter %.ver,$$^) $(OBJS) | grep -v @ > $(SUBDIR)lib$(NAME).ver-sol2'
4396         ;;
4397     netbsd)
4398         disable symver
4399         oss_indev_extralibs="-lossaudio"
4400         oss_outdev_extralibs="-lossaudio"
4401         enabled gcc || check_ldflags -Wl,-zmuldefs
4402         ;;
4403     openbsd|bitrig)
4404         disable symver
4405         SHFLAGS='-shared'
4406         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
4407         SLIB_INSTALL_LINKS=
4408         oss_indev_extralibs="-lossaudio"
4409         oss_outdev_extralibs="-lossaudio"
4410         ;;
4411     dragonfly)
4412         disable symver
4413         ;;
4414     freebsd)
4415         ;;
4416     bsd/os)
4417         add_extralibs -lpoll -lgnugetopt
4418         strip="strip -d"
4419         ;;
4420     darwin)
4421         enabled ppc && add_asflags -force_cpusubtype_ALL
4422         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
4423         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
4424         strip="${strip} -x"
4425         add_ldflags -Wl,-dynamic,-search_paths_first
4426         SLIBSUF=".dylib"
4427         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
4428         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
4429         objformat="macho"
4430         enabled x86_64 && objformat="macho64"
4431         enabled_any pic shared x86_64 ||
4432             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
4433         ;;
4434     msys*)
4435         die "Native MSYS builds are discouraged, please use the MINGW environment.";
4436         ;;
4437     mingw32*|mingw64*)
4438         if test $target_os = "mingw32ce"; then
4439             disable network
4440         else
4441             target_os=mingw32
4442         fi
4443         decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
4444         decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
4445         LIBTARGET=i386
4446         if enabled x86_64; then
4447             LIBTARGET="i386:x86-64"
4448         elif enabled arm; then
4449             LIBTARGET=arm-wince
4450         fi
4451         enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
4452         enabled x86_32 && check_ldflags -Wl,--large-address-aware
4453         shlibdir_default="$bindir_default"
4454         SLIBPREF=""
4455         SLIBSUF=".dll"
4456         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4457         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4458         dlltool="${cross_prefix}dlltool"
4459         if check_cmd lib.exe -list; then
4460             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
4461             if enabled x86_64; then
4462                 LIBTARGET=x64
4463             fi
4464         elif check_cmd $dlltool --version; then
4465             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)'
4466         fi
4467         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4468         SLIB_INSTALL_LINKS=
4469         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
4470         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4471         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'
4472         objformat="win32"
4473         ranlib=:
4474         enable dos_paths
4475         check_ldflags -Wl,--nxcompat,--dynamicbase
4476         # Lets work around some stupidity in binutils.
4477         # ld will strip relocations from executables even though we need them
4478         # for dynamicbase (ASLR).  Using -pie does retain the reloc section
4479         # however ld then forgets what the entry point should be (oops) so we
4480         # have to manually (re)set it.
4481         if enabled x86_32; then
4482             add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup
4483         elif enabled x86_64; then
4484             add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup
4485             check_ldflags -Wl,--high-entropy-va # binutils 2.25
4486             # Set image base >4GB for extra entropy with HEASLR
4487             add_ldexeflags -Wl,--image-base,0x140000000
4488             append SHFLAGS -Wl,--image-base,0x180000000
4489         fi
4490         ;;
4491     win32|win64)
4492         disable symver
4493         if enabled shared; then
4494             # Link to the import library instead of the normal static library
4495             # for shared libs.
4496             LD_LIB='%.lib'
4497             # Cannot build both shared and static libs with MSVC or icl.
4498             disable static
4499         fi
4500         enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
4501         shlibdir_default="$bindir_default"
4502         SLIBPREF=""
4503         SLIBSUF=".dll"
4504         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4505         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4506         SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
4507         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4508         SLIB_INSTALL_LINKS=
4509         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
4510         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4511         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
4512         objformat="win32"
4513         ranlib=:
4514         enable dos_paths
4515         ;;
4516     cygwin*)
4517         target_os=cygwin
4518         shlibdir_default="$bindir_default"
4519         SLIBPREF="cyg"
4520         SLIBSUF=".dll"
4521         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4522         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4523         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4524         SLIB_INSTALL_LINKS=
4525         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
4526         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
4527         objformat="win32"
4528         enable dos_paths
4529         enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
4530         ;;
4531     *-dos|freedos|opendos)
4532         network_extralibs="-lsocket"
4533         objformat="coff"
4534         enable dos_paths
4535         add_cppflags -U__STRICT_ANSI__
4536         ;;
4537     linux)
4538         enable dv1394
4539         enable section_data_rel_ro
4540         ;;
4541     irix*)
4542         target_os=irix
4543         ranlib="echo ignoring ranlib"
4544         ;;
4545     os/2*)
4546         strip="lxlite -CS"
4547         ln_s="cp -f"
4548         objformat="aout"
4549         add_cppflags -D_GNU_SOURCE
4550         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
4551         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
4552         LIBSUF="_s.a"
4553         SLIBPREF=""
4554         SLIBSUF=".dll"
4555         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
4556         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
4557         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
4558             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
4559             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
4560             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
4561             emxexp $(OBJS) >> $(SUBDIR)$(NAME).def'
4562         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
4563             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
4564         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
4565         enable dos_paths
4566         enable_weak os2threads
4567         ;;
4568     gnu/kfreebsd)
4569         add_cppflags -D_BSD_SOURCE
4570         ;;
4571     gnu)
4572         ;;
4573     qnx)
4574         add_cppflags -D_QNX_SOURCE
4575         network_extralibs="-lsocket"
4576         ;;
4577     symbian)
4578         SLIBSUF=".dll"
4579         enable dos_paths
4580         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
4581         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
4582         add_ldflags -Wl,--target1-abs,--no-undefined \
4583                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
4584                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
4585         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
4586                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
4587                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
4588         ;;
4589     osf1)
4590         add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
4591         ;;
4592     minix)
4593         ;;
4594     plan9)
4595         add_cppflags -D_C99_SNPRINTF_EXTENSION  \
4596                      -D_REENTRANT_SOURCE        \
4597                      -D_RESEARCH_SOURCE         \
4598                      -DFD_SETSIZE=96            \
4599                      -DHAVE_SOCK_OPTS
4600         add_compat strtod.o strtod=avpriv_strtod
4601         network_extralibs='-lbsd'
4602         exeobjs=compat/plan9/main.o
4603         disable ffserver
4604         cp_f='cp'
4605         ;;
4606     none)
4607         ;;
4608     *)
4609         die "Unknown OS '$target_os'."
4610         ;;
4611 esac
4612
4613 # determine libc flavour
4614
4615 probe_libc(){
4616     pfx=$1
4617     pfx_no_=${pfx%_}
4618     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
4619     if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
4620         eval ${pfx}libc_type=uclibc
4621         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4622     elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
4623         eval ${pfx}libc_type=glibc
4624         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4625     # MinGW headers can be installed on Cygwin, so check for newlib first.
4626     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
4627         eval ${pfx}libc_type=newlib
4628         add_${pfx}cppflags -U__STRICT_ANSI__
4629     # MinGW64 is backwards compatible with MinGW32, so check for it first.
4630     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
4631         eval ${pfx}libc_type=mingw64
4632         if check_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
4633             add_compat msvcrt/snprintf.o
4634             add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
4635         fi
4636         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4637         eval test \$${pfx_no_}cc_type = "gcc" &&
4638             add_${pfx}cppflags -D__printf__=__gnu_printf__
4639     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
4640          check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
4641         eval ${pfx}libc_type=mingw32
4642         check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
4643             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
4644             die "ERROR: MinGW32 runtime version must be >= 3.15."
4645         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4646         eval test \$${pfx_no_}cc_type = "gcc" &&
4647             add_${pfx}cppflags -D__printf__=__gnu_printf__
4648     elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
4649         eval ${pfx}libc_type=msvcrt
4650         if check_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
4651             if [ "$pfx" = host_ ]; then
4652                 add_host_cppflags -Dsnprintf=_snprintf
4653             else
4654                 add_compat strtod.o strtod=avpriv_strtod
4655                 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
4656                                              _snprintf=avpriv_snprintf  \
4657                                              vsnprintf=avpriv_vsnprintf
4658             fi
4659         fi
4660         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
4661         # 0x601 by default unless something else is set by the user.
4662         # This can easily lead to us detecting functions only present
4663         # in such new versions and producing binaries requiring windows 7.0.
4664         # Therefore explicitly set the default to XP unless the user has
4665         # set something else on the command line.
4666         # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
4667         # family. For these cases, configure is free to use any functions
4668         # found in the SDK headers by default. (Alternatively, we could force
4669         # _WIN32_WINNT to 0x0602 in that case.)
4670         check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
4671             { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
4672 #ifdef WINAPI_FAMILY
4673 #include <winapifamily.h>
4674 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4675 #error not desktop
4676 #endif
4677 #endif
4678 EOF
4679     elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
4680         eval ${pfx}libc_type=klibc
4681     elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
4682         eval ${pfx}libc_type=bionic
4683     elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
4684         eval ${pfx}libc_type=solaris
4685         add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
4686     fi
4687     check_${pfx}cc <<EOF
4688 #include <time.h>
4689 void *v = localtime_r;
4690 EOF
4691 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
4692 #include <time.h>
4693 void *v = localtime_r;
4694 EOF
4695
4696 }
4697
4698 probe_libc
4699 test -n "$libc_type" && enable libc_$libc_type
4700 probe_libc host_
4701 test -n "$host_libc_type" && enable host_libc_$host_libc_type
4702
4703 case $libc_type in
4704     bionic)
4705         add_compat strtod.o strtod=avpriv_strtod
4706         ;;
4707 esac
4708
4709 # hacks for compiler/libc/os combinations
4710
4711 if enabled_all tms470 libc_glibc; then
4712     CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
4713     add_cppflags -D__USER_LABEL_PREFIX__=
4714     add_cppflags -D__builtin_memset=memset
4715     add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
4716     add_cflags   -pds=48    # incompatible redefinition of macro
4717 fi
4718
4719 if enabled_all ccc libc_glibc; then
4720     add_ldflags -Wl,-z,now  # calls to libots crash without this
4721 fi
4722
4723 check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
4724     add_cppflags '-I\$(SRC_PATH)/compat/float'
4725
4726 esc(){
4727     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
4728 }
4729
4730 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" >config.fate
4731
4732 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
4733
4734 set_default libdir
4735 : ${shlibdir_default:="$libdir"}
4736 : ${pkgconfigdir_default:="$libdir/pkgconfig"}
4737
4738 set_default $PATHS_LIST
4739 set_default nm
4740
4741 # we need to build at least one lib type
4742 if ! enabled_any static shared; then
4743     cat <<EOF
4744 At least one library type must be built.
4745 Specify --enable-static to build the static libraries or --enable-shared to
4746 build the shared libraries as well. To only build the shared libraries specify
4747 --disable-static in addition to --enable-shared.
4748 EOF
4749     exit 1;
4750 fi
4751
4752 die_license_disabled() {
4753     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
4754 }
4755
4756 die_license_disabled_gpl() {
4757     enabled $1 || { enabled $2 && die "$2 is incompatible with the gpl and --enable-$1 is not specified."; }
4758 }
4759
4760 die_license_disabled gpl frei0r
4761 die_license_disabled gpl libcdio
4762 die_license_disabled gpl librubberband
4763 die_license_disabled gpl libsmbclient
4764 die_license_disabled gpl libutvideo
4765 die_license_disabled gpl libvidstab
4766 die_license_disabled gpl libx264
4767 die_license_disabled gpl libx265
4768 die_license_disabled gpl libxavs
4769 die_license_disabled gpl libxvid
4770 die_license_disabled gpl libzvbi
4771 die_license_disabled gpl x11grab
4772
4773 die_license_disabled nonfree libaacplus
4774 die_license_disabled nonfree libfaac
4775 die_license_disabled nonfree nvenc
4776 enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
4777 enabled gpl && die_license_disabled_gpl nonfree openssl
4778
4779 die_license_disabled version3 gmp
4780 die_license_disabled version3 libopencore_amrnb
4781 die_license_disabled version3 libopencore_amrwb
4782 die_license_disabled version3 libsmbclient
4783 die_license_disabled version3 libvo_aacenc
4784 die_license_disabled version3 libvo_amrwbenc
4785
4786 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
4787
4788 disabled optimizations || check_cflags -fomit-frame-pointer
4789
4790 enable_weak_pic() {
4791     disabled pic && return
4792     enable pic
4793     add_cppflags -DPIC
4794     case "$target_os" in
4795     mingw*|cygwin*)
4796         ;;
4797     *)
4798         add_cflags -fPIC
4799         ;;
4800     esac
4801     add_asflags  -fPIC
4802 }
4803
4804 enabled pic && enable_weak_pic
4805
4806 check_cc <<EOF || die "Symbol mangling check failed."
4807 int ff_extern;
4808 EOF
4809 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
4810 extern_prefix=${sym%%ff_extern*}
4811
4812 check_cc <<EOF && enable_weak inline_asm
4813 void foo(void) { __asm__ volatile ("" ::); }
4814 EOF
4815
4816 _restrict=
4817 for restrict_keyword in restrict __restrict__ __restrict; do
4818     check_cc <<EOF && _restrict=$restrict_keyword && break
4819 void foo(char * $restrict_keyword p);
4820 EOF
4821 done
4822
4823 check_cc <<EOF && enable pragma_deprecated
4824 void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
4825 EOF
4826
4827 check_cc <<EOF && enable attribute_packed
4828 struct { int x; } __attribute__((packed)) x;
4829 EOF
4830
4831 check_cc <<EOF && enable attribute_may_alias
4832 union { int x; } __attribute__((may_alias)) x;
4833 EOF
4834
4835 check_cc <<EOF || die "endian test failed"
4836 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
4837 EOF
4838 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
4839
4840 if ! enabled ppc64 || enabled bigendian; then
4841     disable vsx
4842 fi
4843
4844 check_gas() {
4845     log "check_gas using '$as' as AS"
4846     # :vararg is used on aarch64, arm and ppc altivec
4847     check_as <<EOF || return 1
4848 .macro m n, y:vararg=0
4849 \n: .int \y
4850 .endm
4851 m x
4852 EOF
4853     # .altmacro is only used in arm asm
4854     ! enabled arm || check_as <<EOF || return 1
4855 .altmacro
4856 EOF
4857     enable gnu_as
4858     return 0
4859 }
4860
4861 if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
4862     nogas=:
4863     enabled_any arm aarch64 && nogas=die
4864     enabled_all ppc altivec && [ $target_os_default != aix ] && nogas=warn
4865     as_noop=-v
4866
4867     case $as_type in
4868         arm*) gaspp_as_type=armasm; as_noop=-h ;;
4869         gcc)  gaspp_as_type=gas ;;
4870         *)    gaspp_as_type=$as_type ;;
4871     esac
4872
4873     [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
4874
4875     test "${as#*gas-preprocessor.pl}" != "$as" ||
4876     check_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- ${as:=$cc} $as_noop &&
4877         gas="${gas:=gas-preprocessor.pl} -arch $arch -as-type $gaspp_as_type -- ${as:=$cc}"
4878
4879     if ! check_gas ; then
4880         as=${gas:=$as}
4881         check_gas || \
4882             $nogas "GNU assembler not found, install/update gas-preprocessor"
4883     fi
4884
4885     check_as <<EOF && enable as_func
4886 .func test
4887 .endfunc
4888 EOF
4889 fi
4890
4891 check_inline_asm inline_asm_labels '"1:\n"'
4892
4893 check_inline_asm inline_asm_nonlocal_labels '"Label:\n"'
4894
4895 if enabled aarch64; then
4896     enabled armv8 && check_insn armv8 'prfm   pldl1strm, [x0]'
4897     # internal assembler in clang 3.3 does not support this instruction
4898     enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
4899     enabled vfp  && check_insn vfp  'fmadd d0,    d0,    d1,    d2'
4900
4901     map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
4902
4903 elif enabled alpha; then
4904
4905     check_cflags -mieee
4906
4907 elif enabled arm; then
4908
4909     enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb
4910
4911     check_cpp_condition stddef.h "defined __thumb__" && check_cc <<EOF && enable_weak thumb
4912 float func(float a, float b){ return a+b; }
4913 EOF
4914
4915     enabled thumb && check_cflags -mthumb || check_cflags -marm
4916
4917     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
4918         enable vfp_args
4919     elif check_cpp_condition stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
4920         enable vfp_args
4921     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then
4922         case "${cross_prefix:-$cc}" in
4923             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
4924             *) check_ld "cc" <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
4925 __asm__ (".eabi_attribute 28, 1");
4926 int main(void) { return 0; }
4927 EOF
4928         esac
4929         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
4930     fi
4931
4932     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
4933     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
4934     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
4935     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
4936     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
4937     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
4938     enabled setend  && check_insn setend  'setend be'
4939
4940     [ $target_os = linux ] || [ $target_os = android ] ||
4941         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
4942             $ARCH_EXT_LIST_ARM
4943
4944     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
4945
4946     check_as <<EOF && enable as_dn_directive
4947 ra .dn d0.i16
4948 .unreq ra
4949 EOF
4950
4951     # llvm's integrated assembler supports .object_arch from llvm 3.5
4952     [ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
4953 .object_arch armv4
4954 EOF
4955
4956     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
4957
4958 elif enabled mips; then
4959
4960     enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"'
4961     enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"'
4962     enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"'
4963
4964     # Enable minimum ISA based on selected options
4965     if enabled mips64 && (enabled mipsdsp || enabled mipsdspr2); then
4966         add_cflags "-mips64r2"
4967         add_asflags "-mips64r2"
4968     elif enabled mips64 && enabled mipsfpu && disabled loongson2 && disabled loongson3; then
4969         add_cflags "-mips64"
4970         add_asflags "-mips64"
4971     elif enabled mipsdsp || enabled mipsdspr2; then
4972         add_cflags "-mips32r2 -mfp32"
4973         add_asflags "-mips32r2 -mfp32"
4974     elif enabled mips64r6; then
4975         check_cflags "-mfp64"
4976         check_ldflags "-mfp64"
4977     fi
4978
4979     enabled mips64r6  && check_cflags "-mips64r6 -msched-weight -mload-store-pairs -funroll-loops" &&
4980      check_ldflags "-mips64r6" &&
4981      check_inline_asm mips64r6  '"aui $t0, $t1, 1"'
4982     enabled mipsdsp && add_cflags "-mdsp" && add_asflags "-mdsp" &&
4983      check_inline_asm mipsdsp '"addu.qb $t0, $t1, $t2"'
4984     enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" &&
4985      check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"'
4986     enabled mipsfpu   && add_cflags "-mhard-float" && add_asflags "-mhard-float" &&
4987      check_inline_asm mipsfpu   '"madd.d $f0, $f2, $f4, $f6"'
4988     enabled msa       && check_cflags "-mmsa" && check_ldflags "-mmsa" &&
4989      check_inline_asm msa       '"addvi.b $w0, $w1, 1"'
4990
4991     enabled mips64r6 && add_asflags "-mips64r6 -mfp64"
4992     enabled msa && add_asflags "-mmsa"
4993
4994 elif enabled parisc; then
4995
4996     if enabled gcc; then
4997         case $($cc -dumpversion) in
4998             4.[3-9].*) check_cflags -fno-optimize-sibling-calls ;;
4999         esac
5000     fi
5001
5002 elif enabled ppc; then
5003
5004     enable local_aligned_8 local_aligned_16 local_aligned_32
5005
5006     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
5007     check_inline_asm ibm_asm   '"add 0, 0, 0"'
5008     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
5009     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
5010
5011     # AltiVec flags: The FSF version of GCC differs from the Apple version
5012     if enabled altivec; then
5013         check_cflags -maltivec -mabi=altivec &&
5014         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
5015         check_cflags -faltivec
5016
5017         # check if our compiler supports Motorola AltiVec C API
5018         check_cc <<EOF || disable altivec
5019 $inc_altivec_h
5020 int main(void) {
5021     vector signed int v1 = (vector signed int) { 0 };
5022     vector signed int v2 = (vector signed int) { 1 };
5023     v1 = vec_add(v1, v2);
5024     return 0;
5025 }
5026 EOF
5027
5028         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
5029     fi
5030
5031     if enabled vsx; then
5032         check_cflags -mvsx &&
5033         check_builtin vec_vsx_ld "altivec.h" "__builtin_vec_vsx_ld" || disable vsx
5034     fi
5035
5036     if enabled power8; then
5037         check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
5038     fi
5039
5040 elif enabled x86; then
5041
5042     check_builtin rdtsc    intrin.h   "__rdtsc()"
5043     check_builtin mm_empty mmintrin.h "_mm_empty()"
5044
5045     enable local_aligned_8 local_aligned_16 local_aligned_32
5046
5047     # check whether EBP is available on x86
5048     # As 'i' is stored on the stack, this program will crash
5049     # if the base pointer is used to access it because the
5050     # base pointer is cleared in the inline assembly code.
5051     check_exec_crash <<EOF && enable ebp_available
5052 volatile int i=0;
5053 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
5054 return i;
5055 EOF
5056
5057     # check whether EBX is available on x86
5058     check_inline_asm ebx_available '""::"b"(0)' &&
5059         check_inline_asm ebx_available '"":::"%ebx"'
5060
5061     # check whether xmm clobbers are supported
5062     check_inline_asm xmm_clobbers '"":::"%xmm0"'
5063
5064     check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test, %eax"' ||
5065         check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test(%rip), %eax"'
5066
5067     # check whether binutils is new enough to compile SSSE3/MMXEXT
5068     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
5069     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
5070
5071     if ! disabled_any asm mmx yasm; then
5072         if check_cmd $yasmexe --version; then
5073             enabled x86_64 && yasm_extra="-m amd64"
5074             yasm_debug="-g dwarf2"
5075         elif check_cmd nasm -v; then
5076             yasmexe=nasm
5077             yasm_debug="-g -F dwarf"
5078             if enabled x86_64; then
5079                 case "$objformat" in
5080                     elf)   objformat=elf64 ;;
5081                     win32) objformat=win64 ;;
5082                 esac
5083             fi
5084         fi
5085
5086         YASMFLAGS="-f $objformat $yasm_extra"
5087         enabled pic               && append YASMFLAGS "-DPIC"
5088         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
5089         case "$objformat" in
5090             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
5091         esac
5092
5093         check_yasm "movbe ecx, [5]" && enable yasm ||
5094             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
5095         check_yasm "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
5096         check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
5097         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
5098         check_yasm "CPU amdnop" || disable cpunop
5099     fi
5100
5101     case "$cpu" in
5102         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
5103             disable fast_clz
5104         ;;
5105     esac
5106
5107 fi
5108
5109 check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
5110
5111 check_ldflags -Wl,--as-needed
5112 check_ldflags -Wl,-z,noexecstack
5113
5114 if check_func dlopen; then
5115     ldl=
5116 elif check_func dlopen -ldl; then
5117     ldl=-ldl
5118 fi
5119
5120 frei0r_filter_extralibs='$ldl'
5121 frei0r_src_filter_extralibs='$ldl'
5122 ladspa_filter_extralibs='$ldl'
5123 nvenc_encoder_extralibs='$ldl'
5124
5125 if ! disabled network; then
5126     check_func getaddrinfo $network_extralibs
5127     check_func inet_aton $network_extralibs
5128
5129     check_type netdb.h "struct addrinfo"
5130     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
5131     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
5132     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
5133     check_type poll.h "struct pollfd"
5134     check_type netinet/sctp.h "struct sctp_event_subscribe"
5135     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
5136     check_type netinet/in.h "struct sockaddr_in6"
5137     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
5138     check_type "sys/types.h sys/socket.h" socklen_t
5139
5140     # Prefer arpa/inet.h over winsock2
5141     if check_header arpa/inet.h ; then
5142         check_func closesocket
5143     elif check_header winsock2.h ; then
5144         check_func_headers winsock2.h closesocket -lws2 &&
5145             network_extralibs="-lws2" ||
5146         { check_func_headers winsock2.h closesocket -lws2_32 &&
5147             network_extralibs="-lws2_32"; } || disable winsock2_h network
5148         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
5149
5150         check_type ws2tcpip.h socklen_t
5151         check_type ws2tcpip.h "struct addrinfo"
5152         check_type ws2tcpip.h "struct group_source_req"
5153         check_type ws2tcpip.h "struct ip_mreq_source"
5154         check_type ws2tcpip.h "struct ipv6_mreq"
5155         check_type winsock2.h "struct pollfd"
5156         check_struct winsock2.h "struct sockaddr" sa_len
5157         check_type ws2tcpip.h "struct sockaddr_in6"
5158         check_type ws2tcpip.h "struct sockaddr_storage"
5159     else
5160         disable network
5161     fi
5162 fi
5163
5164 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
5165 check_builtin atomic_compare_exchange "" "int *ptr, *oldval; int newval; __atomic_compare_exchange_n(ptr, oldval, newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)"
5166 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
5167 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
5168 check_builtin sarestart signal.h "SA_RESTART"
5169 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
5170 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
5171 check_builtin localtime_r time.h "time_t *time; struct tm *tm; localtime_r(time, tm)"
5172
5173 case "$custom_allocator" in
5174     jemalloc)
5175         # jemalloc by default does not use a prefix
5176         require libjemalloc jemalloc/jemalloc.h malloc -ljemalloc
5177     ;;
5178     tcmalloc)
5179         require_pkg_config libtcmalloc gperftools/tcmalloc.h tc_malloc
5180         malloc_prefix=tc_
5181     ;;
5182 esac
5183
5184 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
5185 check_func  ${malloc_prefix}memalign            && enable memalign
5186 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
5187
5188 check_func  access
5189 check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
5190 check_func  fcntl
5191 check_func  fork
5192 check_func  gethrtime
5193 check_func  getopt
5194 check_func  getrusage
5195 check_func  gettimeofday
5196 check_func  isatty
5197 check_func  mach_absolute_time
5198 check_func  mkstemp
5199 check_func  mmap
5200 check_func  mprotect
5201 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
5202 check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
5203 check_func  sched_getaffinity
5204 check_func  setrlimit
5205 check_struct "sys/stat.h" "struct stat" st_mtim.tv_nsec -D_BSD_SOURCE
5206 check_func  strerror_r
5207 check_func  sysconf
5208 check_func  sysctl
5209 check_func  usleep
5210
5211 check_func_headers conio.h kbhit
5212 check_func_headers io.h setmode
5213 check_func_headers lzo/lzo1x.h lzo1x_999_compress
5214 check_func_headers stdlib.h getenv
5215 check_func_headers sys/stat.h lstat
5216
5217 check_func_headers windows.h CoTaskMemFree -lole32
5218 check_func_headers windows.h GetProcessAffinityMask
5219 check_func_headers windows.h GetProcessTimes
5220 check_func_headers windows.h GetSystemTimeAsFileTime
5221 check_func_headers windows.h MapViewOfFile
5222 check_func_headers windows.h PeekNamedPipe
5223 check_func_headers windows.h SetConsoleTextAttribute
5224 check_func_headers windows.h SetConsoleCtrlHandler
5225 check_func_headers windows.h Sleep
5226 check_func_headers windows.h VirtualAlloc
5227 check_struct windows.h "CONDITION_VARIABLE" Ptr
5228 check_func_headers glob.h glob
5229 enabled xlib &&
5230     check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
5231
5232 check_header direct.h
5233 check_header dirent.h
5234 check_header dlfcn.h
5235 check_header d3d11.h
5236 check_header dxva.h
5237 check_header dxva2api.h -D_WIN32_WINNT=0x0600
5238 check_header io.h
5239 check_header libcrystalhd/libcrystalhd_if.h
5240 check_header mach/mach_time.h
5241 check_header malloc.h
5242 check_header net/udplite.h
5243 check_header poll.h
5244 check_header sys/mman.h
5245 check_header sys/param.h
5246 check_header sys/resource.h
5247 check_header sys/select.h
5248 check_header sys/time.h
5249 check_header sys/un.h
5250 check_header termios.h
5251 check_header unistd.h
5252 check_header valgrind/valgrind.h
5253 check_header vdpau/vdpau.h
5254 check_header vdpau/vdpau_x11.h
5255 check_header VideoDecodeAcceleration/VDADecoder.h
5256 check_header VideoToolbox/VideoToolbox.h
5257 check_header windows.h
5258 check_header X11/extensions/XvMClib.h
5259 check_header asm/types.h
5260
5261 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
5262 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
5263 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
5264 check_lib "CoreServices/CoreServices.h" UTGetOSTypeFromString "-framework CoreServices"
5265
5266 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
5267
5268 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
5269 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
5270 check_type "windows.h d3d11.h" "ID3D11VideoContext"
5271 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
5272
5273 check_type "va/va.h" "VAPictureParameterBufferHEVC"
5274
5275 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
5276
5277 check_cpp_condition windows.h "!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)" && enable winrt || disable winrt
5278
5279 if ! disabled w32threads && ! enabled pthreads; then
5280     check_func_headers "windows.h process.h" _beginthreadex &&
5281         enable w32threads || disable w32threads
5282     if ! enabled w32threads && enabled winrt; then
5283         check_func_headers "windows.h" CreateThread &&
5284             enable w32threads || disable w32threads
5285     fi
5286 fi
5287
5288 # check for some common methods of building with pthread support
5289 # do this before the optional library checks as some of them require pthreads
5290 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
5291     enable pthreads
5292     if check_func pthread_join -pthread && check_func pthread_create -pthread; then
5293         add_cflags -pthread
5294         add_extralibs -pthread
5295     elif check_func pthread_join -pthreads && check_func pthread_create -pthreads; then
5296         add_cflags -pthreads
5297         add_extralibs -pthreads
5298     elif check_func pthread_join -ldl -pthread && check_func pthread_create -ldl -pthread; then
5299         add_cflags -ldl -pthread
5300         add_extralibs -ldl -pthread
5301     elif check_func pthread_join -lpthreadGC2 && check_func pthread_create -lpthreadGC2; then
5302         add_extralibs -lpthreadGC2
5303     elif check_lib pthread.h pthread_join -lpthread && check_lib pthread.h pthread_create -lpthread; then
5304         :
5305     elif ! check_func pthread_join && ! check_func pthread_create; then
5306         disable pthreads
5307     fi
5308     check_code cc "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER" || disable pthreads
5309 fi
5310
5311
5312 if enabled pthreads; then
5313   check_func pthread_cancel
5314 fi
5315
5316 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
5317 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
5318 disabled  lzma || check_lib2  lzma.h lzma_version_number -llzma || disable lzma
5319
5320 check_lib math.h sin -lm && LIBM="-lm"
5321 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
5322
5323 atan2f_args=2
5324 copysign_args=2
5325 hypot_args=2
5326 ldexpf_args=2
5327 powf_args=2
5328
5329 for func in $MATH_FUNCS; do
5330     eval check_mathfunc $func \${${func}_args:-1}
5331 done
5332
5333 for func in $COMPLEX_FUNCS; do
5334     eval check_complexfunc $func \${${func}_args:-1}
5335 done
5336
5337 # these are off by default, so fail if requested and not available
5338 enabled avfoundation_indev && { check_header_oc AVFoundation/AVFoundation.h || disable avfoundation_indev; }
5339 enabled avfoundation_indev && { check_lib2 CoreGraphics/CoreGraphics.h CGGetActiveDisplayList -framework CoreGraphics ||
5340                                 check_lib2 ApplicationServices/ApplicationServices.h CGGetActiveDisplayList -framework ApplicationServices; }
5341 enabled avisynth          && { { check_lib2 "windows.h" LoadLibrary; } ||
5342                                { check_lib2 "dlfcn.h" dlopen -ldl; } ||
5343                                die "ERROR: LoadLibrary/dlopen not found for avisynth"; }
5344 enabled chromaprint       && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
5345 enabled decklink          && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; }
5346 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
5347 enabled gcrypt            && require2 gcrypt gcrypt.h gcry_mpi_new -lgcrypt
5348 enabled gmp               && require2 gmp gmp.h mpz_export -lgmp
5349 enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
5350 enabled ladspa            && { check_header ladspa.h || die "ERROR: ladspa.h header not found"; }
5351 enabled libiec61883       && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
5352 enabled libaacplus        && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
5353 enabled libass            && require_pkg_config libass ass/ass.h ass_library_init
5354 enabled libbluray         && require_pkg_config libbluray libbluray/bluray.h bd_open
5355 enabled libbs2b           && require_pkg_config libbs2b bs2b.h bs2b_open
5356 enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
5357                              { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
5358                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
5359 enabled libcaca           && require_pkg_config caca caca.h caca_create_canvas
5360 enabled libdcadec         && require_pkg_config "dcadec >= 0.1.0" libdcadec/dca_context.h dcadec_context_create
5361 enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
5362 enabled libfdk_aac        && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
5363                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
5364                                  warn "using libfdk without pkg-config"; } }
5365 flite_libs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
5366 enabled libflite          && require2 libflite "flite/flite.h" flite_init $flite_libs
5367 enabled fontconfig        && enable libfontconfig
5368 enabled libfontconfig     && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit
5369 enabled libfreetype       && require_libfreetype
5370 enabled libfribidi        && require_pkg_config fribidi fribidi.h fribidi_version_info
5371 enabled libgme            && require  libgme gme/gme.h gme_new_emu -lgme -lstdc++
5372 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
5373                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
5374                                done || die "ERROR: libgsm not found"; }
5375 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
5376 enabled libkvazaar        && require_pkg_config "kvazaar >= 0.7.1" kvazaar.h kvz_api_get
5377 enabled libmfx            && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
5378 enabled libmodplug        && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load
5379 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
5380 enabled libnut            && require libnut libnut.h nut_demuxer_init -lnut
5381 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
5382 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
5383 enabled libopencv         && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
5384 enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
5385 enabled libopenjpeg       && { check_lib openjpeg.h opj_version -lopenmj2 -DOPJ_STATIC ||
5386                                check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
5387                                check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
5388                                die "ERROR: libopenjpeg not found"; }
5389 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
5390 enabled libpulse          && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
5391 enabled libquvi           && require_pkg_config libquvi quvi/quvi.h quvi_init
5392 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
5393 enabled librubberband     && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new
5394 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
5395 enabled libshine          && require_pkg_config shine shine/layer3.h shine_encode_buffer
5396 enabled libsmbclient      && { use_pkg_config smbclient libsmbclient.h smbc_init ||
5397                                require smbclient libsmbclient.h smbc_init -lsmbclient; }
5398 enabled libsnappy         && require snappy snappy-c.h snappy_compress -lsnappy
5399 enabled libsoxr           && require libsoxr soxr.h soxr_create -lsoxr && LIBSOXR="-lsoxr"
5400 enabled libssh            && require_pkg_config libssh libssh/sftp.h sftp_init
5401 enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
5402 enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
5403     media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
5404     media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static
5405 enabled libtesseract      && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate
5406 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
5407 enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
5408                              { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
5409                                die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
5410 enabled libutvideo        && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
5411 enabled libv4l2           && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl
5412 enabled libvidstab        && require_pkg_config "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit
5413 enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
5414 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
5415 enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
5416
5417 enabled libvpx            && {
5418     enabled libvpx_vp8_decoder && {
5419         use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
5420             check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
5421                 die "ERROR: libvpx decoder version must be >=0.9.1";
5422     }
5423     enabled libvpx_vp8_encoder && {
5424         use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
5425             check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx ||
5426                 die "ERROR: libvpx encoder version must be >=0.9.7";
5427     }
5428     enabled libvpx_vp9_decoder && {
5429         use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
5430             check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx ||
5431                 disable libvpx_vp9_decoder;
5432     }
5433     enabled libvpx_vp9_encoder && {
5434         use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
5435             check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx ||
5436                 disable libvpx_vp9_encoder;
5437     }
5438     if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
5439         die "libvpx enabled but no supported decoders found"
5440     fi
5441 }
5442
5443 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
5444 enabled libwebp           && {
5445     enabled libwebp_encoder      && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
5446     enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } }
5447 enabled libx264           && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
5448                                { require libx264 x264.h x264_encoder_encode -lx264 &&
5449                                  warn "using libx264 without pkg-config"; } } &&
5450                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
5451                                die "ERROR: libx264 must be installed and version must be >= 0.118."; } &&
5452                              { check_cpp_condition x264.h "X264_MPEG2" &&
5453                                enable libx262; }
5454 enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
5455                              { check_cpp_condition x265.h "X265_BUILD >= 57" ||
5456                                die "ERROR: libx265 version must be >= 57."; }
5457 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
5458 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
5459 enabled libzimg           && require_pkg_config zimg zimg.h zimg_get_api_version
5460 enabled libzmq            && require_pkg_config libzmq zmq.h zmq_ctx_new
5461 enabled libzvbi           && require libzvbi libzvbi.h vbi_decoder_new -lzvbi
5462 enabled mmal              && { check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
5463                                 { ! enabled cross_compile && {
5464                                     add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline ;
5465                                     add_extralibs -L/opt/vc/lib/ -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ;
5466                                     check_lib interface/mmal/mmal.h mmal_port_connect ; }
5467                                 check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
5468                                die "ERROR: mmal not found"; }
5469 enabled nvenc             && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } &&
5470                              { check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
5471                                die "ERROR: NVENC API version 4 or older is not supported"; } &&
5472                              { [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; }
5473 enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
5474                                check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
5475                                die "ERROR: openal not found"; } &&
5476                              { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
5477                                die "ERROR: openal must be installed and version must be 1.1 or compatible"; }
5478 enabled opencl            && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
5479                                check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
5480                                die "ERROR: opencl not found"; } &&
5481                              { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
5482                                check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
5483                                die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
5484 enabled opengl            && { check_lib GL/glx.h glXGetProcAddress "-lGL" ||
5485                                check_lib2 windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
5486                                check_lib2 OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" ||
5487                                check_lib2 ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
5488                                die "ERROR: opengl not found."
5489                              }
5490 enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
5491                                check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
5492                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
5493                                die "ERROR: openssl not found"; }
5494 enabled qtkit_indev      && { check_header_oc QTKit/QTKit.h || disable qtkit_indev; }
5495
5496 # libdc1394 check
5497 if enabled libdc1394; then
5498     { require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new &&
5499         enable libdc1394_2; } ||
5500     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
5501         enable libdc1394_1; } ||
5502     die "ERROR: No version of libdc1394 found "
5503 fi
5504 if ! disabled sdl; then
5505     SDL_CONFIG="${cross_prefix}sdl-config"
5506     if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
5507         check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5508         check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5509         enable sdl
5510     else
5511         if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5512             sdl_cflags=$("${SDL_CONFIG}" --cflags)
5513             sdl_libs=$("${SDL_CONFIG}" --libs)
5514             check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
5515             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5516             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5517             enable sdl
5518         elif enabled sdl ; then
5519             die "ERROR: SDL not found"
5520         else
5521             disable sdl
5522         fi
5523     fi
5524     if test $target_os = "mingw32"; then
5525         sdl_libs="$sdl_libs -mconsole"
5526     fi
5527 fi
5528 enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
5529
5530 disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5531     check_lib2 "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5532     enable securetransport; }
5533
5534 disabled schannel || { check_func_headers "windows.h Security.h" InitializeSecurityContext -DSECURITY_WIN32 -lSecur32 &&
5535                        enable schannel && add_extralibs -lSecur32; }
5536
5537 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
5538 enabled makeinfo \
5539     && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \
5540     && enable makeinfo_html || disable makeinfo_html
5541 disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
5542 perl -v            > /dev/null 2>&1 && enable perl      || disable perl
5543 pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
5544 rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
5545
5546 check_header linux/fb.h
5547 check_header linux/videodev.h
5548 check_header linux/videodev2.h
5549 check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
5550
5551 check_header sys/videoio.h
5552 check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
5553
5554 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
5555 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
5556 # w32api 3.12 had it defined wrong
5557 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
5558
5559 check_type "dshow.h" IBaseFilter
5560
5561 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
5562 { check_header dev/bktr/ioctl_meteor.h &&
5563   check_header dev/bktr/ioctl_bt848.h; } ||
5564 { check_header machine/ioctl_meteor.h &&
5565   check_header machine/ioctl_bt848.h; } ||
5566 { check_header dev/video/meteor/ioctl_meteor.h &&
5567   check_header dev/video/bktr/ioctl_bt848.h; } ||
5568 check_header dev/ic/bt8xx.h
5569
5570 check_header sndio.h
5571 if check_struct sys/soundcard.h audio_buf_info bytes; then
5572     enable_safe sys/soundcard.h
5573 else
5574     check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h
5575     #include <sys/soundcard.h>
5576     audio_buf_info abc;
5577 EOF
5578 fi
5579 check_header soundcard.h
5580
5581 enabled_any alsa_indev alsa_outdev &&
5582     check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
5583
5584 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func sem_timedwait &&
5585     check_func jack_port_get_latency_range -ljack
5586
5587 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
5588
5589 if enabled libcdio; then
5590     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
5591     check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
5592     die "ERROR: No usable libcdio/cdparanoia found"
5593 fi
5594
5595 enabled xlib &&
5596     check_lib X11/Xlib.h XOpenDisplay -lX11 || disable xlib
5597
5598 if ! disabled libxcb; then
5599     check_pkg_config "xcb >= 1.4" xcb/xcb.h xcb_connect || {
5600         enabled libxcb && die "ERROR: libxcb >= 1.4 not found";
5601     } && disable x11grab && enable libxcb
5602
5603 if enabled libxcb; then
5604     disabled libxcb_shm || {
5605         check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
5606             enabled libxcb_shm && die "ERROR: libxcb_shm not found";
5607         } && check_header sys/shm.h && enable libxcb_shm; }
5608
5609     disabled libxcb_xfixes || {
5610         check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image || {
5611             enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
5612         } && enable libxcb_xfixes; }
5613
5614     disabled libxcb_shape || {
5615         check_pkg_config xcb-shape xcb/shape.h xcb_shape_get_rectangles || {
5616             enabled libxcb_shape && die "ERROR: libxcb_shape not found";
5617         } && enable libxcb_shape; }
5618
5619     add_cflags $xcb_cflags $xcb_shm_cflags $xcb_xfixes_cflags $xcb_shape_cflags
5620     add_extralibs $xcb_libs $xcb_shm_libs $xcb_xfixes_libs $xcb_shape_libs
5621 fi
5622 fi
5623
5624 if enabled x11grab; then
5625     enabled xlib || die "ERROR: Xlib not found"
5626     require Xext X11/extensions/XShm.h XShmCreateImage -lXext
5627     require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
5628 fi
5629
5630 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
5631
5632 enabled dxva2api_h &&
5633     check_cc <<EOF && enable dxva2api_cobj
5634 #define _WIN32_WINNT 0x0600
5635 #define COBJMACROS
5636 #include <windows.h>
5637 #include <d3d9.h>
5638 #include <dxva2api.h>
5639 int main(void) { IDirectXVideoDecoder *o = NULL; IDirectXVideoDecoder_Release(o); return 0; }
5640 EOF
5641
5642 enabled vaapi &&
5643     check_lib va/va.h vaInitialize -lva ||
5644     disable vaapi
5645
5646 enabled vaapi && enabled xlib &&
5647     check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
5648     enable vaapi_x11
5649
5650 enabled vdpau &&
5651     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
5652     disable vdpau
5653
5654 enabled vdpau && enabled xlib &&
5655     check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
5656     prepend ffmpeg_libs $($ldflags_filter "-lvdpau") &&
5657     enable vdpau_x11
5658
5659 # Funny iconv installations are not unusual, so check it after all flags have been set
5660 disabled iconv || check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || disable iconv
5661
5662 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
5663
5664 # add some useful compiler flags if supported
5665 check_cflags -Wdeclaration-after-statement
5666 check_cflags -Wall
5667 check_cflags -Wdisabled-optimization
5668 check_cflags -Wpointer-arith
5669 check_cflags -Wredundant-decls
5670 check_cflags -Wwrite-strings
5671 check_cflags -Wtype-limits
5672 check_cflags -Wundef
5673 check_cflags -Wmissing-prototypes
5674 check_cflags -Wno-pointer-to-int-cast
5675 check_cflags -Wstrict-prototypes
5676 check_cflags -Wempty-body
5677 enabled extra_warnings && check_cflags -Winline
5678
5679 check_disable_warning(){
5680     warning_flag=-W${1#-Wno-}
5681     test_cflags $warning_flag && add_cflags $1
5682 }
5683
5684 check_disable_warning -Wno-parentheses
5685 check_disable_warning -Wno-switch
5686 check_disable_warning -Wno-format-zero-length
5687 check_disable_warning -Wno-pointer-sign
5688
5689 # add some linker flags
5690 check_ldflags -Wl,--warn-common
5691 check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
5692 enabled rpath && add_ldexeflags -Wl,-rpath,$libdir
5693 enabled rpath && add_ldlibflags -Wl,-rpath,$libdir
5694 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
5695
5696 # add some strip flags
5697 # -wN '..@*' is more selective than -x, but not available everywhere.
5698 check_stripflags -wN \'..@*\' || check_stripflags -x
5699
5700 enabled neon_clobber_test &&
5701     check_ldflags -Wl,--wrap,avcodec_open2              \
5702                   -Wl,--wrap,avcodec_decode_audio4      \
5703                   -Wl,--wrap,avcodec_decode_video2      \
5704                   -Wl,--wrap,avcodec_decode_subtitle2   \
5705                   -Wl,--wrap,avcodec_encode_audio2      \
5706                   -Wl,--wrap,avcodec_encode_video2      \
5707                   -Wl,--wrap,avcodec_encode_subtitle    \
5708                   -Wl,--wrap,swr_convert                \
5709                   -Wl,--wrap,avresample_convert ||
5710     disable neon_clobber_test
5711
5712 enabled xmm_clobber_test &&
5713     check_ldflags -Wl,--wrap,avcodec_open2              \
5714                   -Wl,--wrap,avcodec_decode_audio4      \
5715                   -Wl,--wrap,avcodec_decode_video2      \
5716                   -Wl,--wrap,avcodec_decode_subtitle2   \
5717                   -Wl,--wrap,avcodec_encode_audio2      \
5718                   -Wl,--wrap,avcodec_encode_video2      \
5719                   -Wl,--wrap,avcodec_encode_subtitle    \
5720                   -Wl,--wrap,swr_convert                \
5721                   -Wl,--wrap,avresample_convert         \
5722                   -Wl,--wrap,sws_scale ||
5723     disable xmm_clobber_test
5724
5725 echo "X { local: *; };" > $TMPV
5726 if test_ldflags -Wl,--version-script,$TMPV; then
5727     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
5728 elif test_ldflags -Wl,-M,$TMPV; then
5729     append SHFLAGS '-Wl,-M,\$(SUBDIR)lib\$(NAME).ver-sol2'
5730 fi
5731
5732 check_cc <<EOF && enable symver_asm_label
5733 void ff_foo(void) __asm__ ("av_foo@VERSION");
5734 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
5735 EOF
5736     check_cc <<EOF && enable symver_gnu_asm
5737 __asm__(".symver ff_foo,av_foo@VERSION");
5738 void ff_foo(void) {}
5739 EOF
5740
5741 if [ -z "$optflags" ]; then
5742     if enabled small; then
5743         optflags=$cflags_size
5744     elif enabled optimizations; then
5745         optflags=$cflags_speed
5746     else
5747         optflags=$cflags_noopt
5748     fi
5749 fi
5750
5751 check_optflags(){
5752     check_cflags "$@"
5753     enabled lto && check_ldflags "$@"
5754 }
5755
5756
5757 if enabled lto; then
5758     test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
5759     check_cflags  -flto
5760     check_ldflags -flto $cpuflags
5761     disable inline_asm_direct_symbol_refs
5762 fi
5763
5764 check_optflags $optflags
5765 check_optflags -fno-math-errno
5766 check_optflags -fno-signed-zeros
5767
5768 enabled ftrapv && check_cflags -ftrapv
5769
5770 check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
5771 int x;
5772 EOF
5773
5774
5775 if enabled icc; then
5776     # Just warnings, no remarks
5777     check_cflags -w1
5778     # -wd: Disable following warnings
5779     # 144, 167, 556: -Wno-pointer-sign
5780     # 188: enumerated type mixed with another type
5781     # 1292: attribute "foo" ignored
5782     # 1419: external declaration in primary source file
5783     # 10006: ignoring unknown option -fno-signed-zeros
5784     # 10148: ignoring unknown option -Wno-parentheses
5785     # 10156: ignoring option '-W'; no argument required
5786     # 13200: No EMMS instruction before call to function
5787     # 13203: No EMMS instruction before return from function
5788     check_cflags -wd144,167,188,556,1292,1419,10006,10148,10156,13200,13203
5789     # 11030: Warning unknown option --as-needed
5790     # 10156: ignoring option '-export'; no argument required
5791     check_ldflags -wd10156,11030
5792     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
5793     enable ebp_available
5794     # The test above does not test linking
5795     enabled lto && disable symver_asm_label
5796     if enabled x86_32; then
5797         icc_version=$($cc -dumpversion)
5798         test ${icc_version%%.*} -ge 11 &&
5799             check_cflags -falign-stack=maintain-16-byte ||
5800             disable aligned_stack
5801     fi
5802 elif enabled ccc; then
5803     # disable some annoying warnings
5804     add_cflags -msg_disable bitnotint
5805     add_cflags -msg_disable mixfuncvoid
5806     add_cflags -msg_disable nonstandcast
5807     add_cflags -msg_disable unsupieee
5808 elif enabled gcc; then
5809     check_optflags -fno-tree-vectorize
5810     check_cflags -Werror=format-security
5811     check_cflags -Werror=implicit-function-declaration
5812     check_cflags -Werror=missing-prototypes
5813     check_cflags -Werror=return-type
5814     check_cflags -Werror=vla
5815     check_cflags -Wformat
5816     check_cflags -fdiagnostics-color=auto
5817     enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
5818 elif enabled llvm_gcc; then
5819     check_cflags -mllvm -stack-alignment=16
5820 elif enabled clang; then
5821     check_cflags -mllvm -stack-alignment=16
5822     check_cflags -Qunused-arguments
5823     check_cflags -Werror=implicit-function-declaration
5824     check_cflags -Werror=missing-prototypes
5825     check_cflags -Werror=return-type
5826 elif enabled cparser; then
5827     add_cflags -Wno-missing-variable-declarations
5828     add_cflags -Wno-empty-statement
5829 elif enabled armcc; then
5830     add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
5831     add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
5832     # 2523: use of inline assembly is deprecated
5833     add_cflags -W${armcc_opt},--diag_suppress=2523
5834     add_cflags -W${armcc_opt},--diag_suppress=1207
5835     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
5836     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
5837     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
5838     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
5839 elif enabled tms470; then
5840     add_cflags -pds=824 -pds=837
5841     disable inline_asm
5842 elif enabled pathscale; then
5843     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
5844 elif enabled_any msvc icl; then
5845     enabled x86_32 && disable aligned_stack
5846     enabled_all x86_32 debug && add_cflags -Oy-
5847     enabled debug && add_ldflags -debug
5848     enable pragma_deprecated
5849     if enabled icl; then
5850         # -Qansi-alias is basically -fstrict-aliasing, but does not work
5851         # (correctly) on icl 13.x.
5852         check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
5853             add_cflags -Qansi-alias
5854         # Some inline asm is not compilable in debug
5855         if enabled debug; then
5856             disable ebp_available
5857             disable ebx_available
5858         fi
5859     fi
5860     # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2.
5861     check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2
5862     # The CRT headers contain __declspec(restrict) in a few places, but if redefining
5863     # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict)
5864     # (as it ends up if the restrict redefine is done before including stdlib.h), while
5865     # MSVC 2013 and newer can handle it fine.
5866     # If this declspec fails, force including stdlib.h before the restrict redefinition
5867     # happens in config.h.
5868     if [ $_restrict != restrict ]; then
5869         check_cc <<EOF || add_cflags -FIstdlib.h
5870 __declspec($_restrict) void* foo(int);
5871 EOF
5872     fi
5873     check_func strtoll || add_cflags -Dstrtoll=_strtoi64
5874 fi
5875
5876 for pfx in "" host_; do
5877     varname=${pfx%_}cc_type
5878     eval "type=\$$varname"
5879     if [ $type = "msvc" ]; then
5880         check_${pfx}cc <<EOF || add_${pfx}cflags -Dinline=__inline
5881 static inline int foo(int a) { return a; }
5882 EOF
5883     fi
5884 done
5885
5886 case $as_type in
5887     clang)
5888         add_asflags -Qunused-arguments
5889     ;;
5890 esac
5891
5892 case $ld_type in
5893     clang)
5894         check_ldflags -Qunused-arguments
5895     ;;
5896 esac
5897
5898 case $target_os in
5899     osf1)
5900         enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
5901     ;;
5902     plan9)
5903         add_cppflags -Dmain=plan9_main
5904     ;;
5905 esac
5906
5907 enable frame_thread_encoder
5908
5909 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
5910
5911 check_deps $CONFIG_LIST       \
5912            $CONFIG_EXTRA      \
5913            $HAVE_LIST         \
5914            $ALL_COMPONENTS    \
5915
5916 enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86"
5917
5918
5919 if test $target_os = "haiku"; then
5920     disable memalign
5921     disable posix_memalign
5922 fi
5923
5924 enabled_all dxva2 dxva2api_cobj CoTaskMemFree &&
5925     prepend ffmpeg_libs $($ldflags_filter "-lole32" "-luser32") &&
5926     enable dxva2_lib
5927
5928 ! enabled_any memalign posix_memalign aligned_malloc &&
5929     enabled simd_align_16 && enable memalign_hack
5930
5931 # add_dep lib dep
5932 # -> enable ${lib}_deps_${dep}
5933 # -> add $dep to ${lib}_deps only once
5934 add_dep() {
5935     lib=$1
5936     dep=$2
5937     enabled "${lib}_deps_${dep}" && return 0
5938     enable  "${lib}_deps_${dep}"
5939     prepend "${lib}_deps" $dep
5940 }
5941
5942 # merge deps lib components
5943 # merge all ${component}_deps into ${lib}_deps and ${lib}_deps_*
5944 merge_deps() {
5945     lib=$1
5946     shift
5947     for comp in $*; do
5948         enabled $comp || continue
5949         eval "dep=\"\$${comp}_deps\""
5950         for d in $dep; do
5951             add_dep $lib $d
5952         done
5953     done
5954 }
5955
5956 merge_deps libavfilter $FILTER_LIST
5957
5958 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
5959
5960 for thread in $THREADS_LIST; do
5961     if enabled $thread; then
5962         test -n "$thread_type" &&
5963             die "ERROR: Only one thread type must be selected." ||
5964             thread_type="$thread"
5965     fi
5966 done
5967
5968 enabled zlib && add_cppflags -DZLIB_CONST
5969
5970 # conditional library dependencies, in linking order
5971 enabled amovie_filter       && prepend avfilter_deps "avformat avcodec"
5972 enabled aresample_filter    && prepend avfilter_deps "swresample"
5973 enabled asyncts_filter      && prepend avfilter_deps "avresample"
5974 enabled atempo_filter       && prepend avfilter_deps "avcodec"
5975 enabled cover_rect_filter   && prepend avfilter_deps "avformat avcodec"
5976 enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample"
5977 enabled elbg_filter         && prepend avfilter_deps "avcodec"
5978 enabled fftfilt_filter      && prepend avfilter_deps "avcodec"
5979 enabled find_rect_filter    && prepend avfilter_deps "avformat avcodec"
5980 enabled mcdeint_filter      && prepend avfilter_deps "avcodec"
5981 enabled movie_filter    && prepend avfilter_deps "avformat avcodec"
5982 enabled pan_filter          && prepend avfilter_deps "swresample"
5983 enabled pp_filter           && prepend avfilter_deps "postproc"
5984 enabled removelogo_filter   && prepend avfilter_deps "avformat avcodec swscale"
5985 enabled resample_filter && prepend avfilter_deps "avresample"
5986 enabled sab_filter          && prepend avfilter_deps "swscale"
5987 enabled scale_filter    && prepend avfilter_deps "swscale"
5988 enabled scale2ref_filter    && prepend avfilter_deps "swscale"
5989 enabled showspectrum_filter && prepend avfilter_deps "avcodec"
5990 enabled smartblur_filter    && prepend avfilter_deps "swscale"
5991 enabled subtitles_filter    && prepend avfilter_deps "avformat avcodec"
5992 enabled uspp_filter         && prepend avfilter_deps "avcodec"
5993
5994 enabled lavfi_indev         && prepend avdevice_deps "avfilter"
5995
5996 enabled opus_decoder    && prepend avcodec_deps "swresample"
5997
5998 expand_deps(){
5999     lib_deps=${1}_deps
6000     eval "deps=\$$lib_deps"
6001     append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
6002     unique $lib_deps
6003 }
6004
6005 #we have to remove gpl from the deps here as some code assumes all lib deps are libs
6006 postproc_deps="$(filter_out 'gpl' $postproc_deps)"
6007
6008 map 'expand_deps $v' $LIBRARY_LIST
6009
6010 echo "install prefix            $prefix"
6011 echo "source path               $source_path"
6012 echo "C compiler                $cc"
6013 echo "C library                 $libc_type"
6014 if test "$host_cc" != "$cc"; then
6015     echo "host C compiler           $host_cc"
6016     echo "host C library            $host_libc_type"
6017 fi
6018 echo "ARCH                      $arch ($cpu)"
6019 if test "$build_suffix" != ""; then
6020     echo "build suffix              $build_suffix"
6021 fi
6022 if test "$progs_suffix" != ""; then
6023     echo "progs suffix              $progs_suffix"
6024 fi
6025 if test "$extra_version" != ""; then
6026     echo "version string suffix     $extra_version"
6027 fi
6028 echo "big-endian                ${bigendian-no}"
6029 echo "runtime cpu detection     ${runtime_cpudetect-no}"
6030 if enabled x86; then
6031     echo "${yasmexe}                      ${yasm-no}"
6032     echo "MMX enabled               ${mmx-no}"
6033     echo "MMXEXT enabled            ${mmxext-no}"
6034     echo "3DNow! enabled            ${amd3dnow-no}"
6035     echo "3DNow! extended enabled   ${amd3dnowext-no}"
6036     echo "SSE enabled               ${sse-no}"
6037     echo "SSSE3 enabled             ${ssse3-no}"
6038     echo "AESNI enabled             ${aesni-no}"
6039     echo "AVX enabled               ${avx-no}"
6040     echo "XOP enabled               ${xop-no}"
6041     echo "FMA3 enabled              ${fma3-no}"
6042     echo "FMA4 enabled              ${fma4-no}"
6043     echo "i686 features enabled     ${i686-no}"
6044     echo "CMOV is fast              ${fast_cmov-no}"
6045     echo "EBX available             ${ebx_available-no}"
6046     echo "EBP available             ${ebp_available-no}"
6047 fi
6048 if enabled aarch64; then
6049     echo "NEON enabled              ${neon-no}"
6050     echo "VFP enabled               ${vfp-no}"
6051 fi
6052 if enabled arm; then
6053     echo "ARMv5TE enabled           ${armv5te-no}"
6054     echo "ARMv6 enabled             ${armv6-no}"
6055     echo "ARMv6T2 enabled           ${armv6t2-no}"
6056     echo "VFP enabled               ${vfp-no}"
6057     echo "NEON enabled              ${neon-no}"
6058     echo "THUMB enabled             ${thumb-no}"
6059 fi
6060 if enabled mips; then
6061     echo "MIPS FPU enabled          ${mipsfpu-no}"
6062     echo "MIPS64R6 enabled          ${mips64r6-no}"
6063     echo "MIPS DSP R1 enabled       ${mipsdsp-no}"
6064     echo "MIPS DSP R2 enabled       ${mipsdspr2-no}"
6065     echo "MIPS MSA enabled          ${msa-no}"
6066     echo "LOONGSON MMI enabled      ${mmi-no}"
6067 fi
6068 if enabled ppc; then
6069     echo "AltiVec enabled           ${altivec-no}"
6070     echo "VSX enabled               ${vsx-no}"
6071     echo "POWER8 enabled            ${power8-no}"
6072     echo "PPC 4xx optimizations     ${ppc4xx-no}"
6073     echo "dcbzl available           ${dcbzl-no}"
6074 fi
6075 echo "debug symbols             ${debug-no}"
6076 echo "strip symbols             ${stripping-no}"
6077 echo "optimize for size         ${small-no}"
6078 echo "optimizations             ${optimizations-no}"
6079 echo "static                    ${static-no}"
6080 echo "shared                    ${shared-no}"
6081 echo "postprocessing support    ${postproc-no}"
6082 echo "new filter support        ${avfilter-no}"
6083 echo "network support           ${network-no}"
6084 echo "threading support         ${thread_type-no}"
6085 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
6086 echo "SDL support               ${sdl-no}"
6087 echo "opencl enabled            ${opencl-no}"
6088 echo "texi2html enabled         ${texi2html-no}"
6089 echo "perl enabled              ${perl-no}"
6090 echo "pod2man enabled           ${pod2man-no}"
6091 echo "makeinfo enabled          ${makeinfo-no}"
6092 echo "makeinfo supports HTML    ${makeinfo_html-no}"
6093 test -n "$random_seed" &&
6094     echo "random seed               ${random_seed}"
6095 echo
6096
6097 echo "Enabled programs:"
6098 print_enabled '' $PROGRAM_LIST | print_in_columns
6099 echo
6100
6101 echo "External libraries:"
6102 print_enabled '' $EXTERNAL_LIBRARY_LIST | print_in_columns
6103 echo
6104
6105 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
6106     echo "Enabled ${type}s:"
6107     eval list=\$$(toupper $type)_LIST
6108     print_enabled '_*' $list | print_in_columns
6109     echo
6110 done
6111
6112 license="LGPL version 2.1 or later"
6113 if enabled nonfree; then
6114     license="nonfree and unredistributable"
6115 elif enabled gplv3; then
6116     license="GPL version 3 or later"
6117 elif enabled lgplv3; then
6118     license="LGPL version 3 or later"
6119 elif enabled gpl; then
6120     license="GPL version 2 or later"
6121 fi
6122
6123 echo "License: $license"
6124
6125 echo "Creating config.mak, config.h, and doc/config.texi..."
6126
6127 test -e Makefile || echo "include $source_path/Makefile" > Makefile
6128
6129 enabled stripping || strip="echo skipping strip"
6130
6131 config_files="$TMPH config.mak doc/config.texi"
6132
6133 cat > config.mak <<EOF
6134 # Automatically generated by configure - do not modify!
6135 ifndef FFMPEG_CONFIG_MAK
6136 FFMPEG_CONFIG_MAK=1
6137 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
6138 prefix=$prefix
6139 LIBDIR=\$(DESTDIR)$libdir
6140 SHLIBDIR=\$(DESTDIR)$shlibdir
6141 INCDIR=\$(DESTDIR)$incdir
6142 BINDIR=\$(DESTDIR)$bindir
6143 DATADIR=\$(DESTDIR)$datadir
6144 DOCDIR=\$(DESTDIR)$docdir
6145 MANDIR=\$(DESTDIR)$mandir
6146 PKGCONFIGDIR=\$(DESTDIR)$pkgconfigdir
6147 SRC_PATH=$source_path
6148 ifndef MAIN_MAKEFILE
6149 SRC_PATH:=\$(SRC_PATH:.%=..%)
6150 endif
6151 CC_IDENT=$cc_ident
6152 ARCH=$arch
6153 INTRINSICS=$intrinsics
6154 CC=$cc
6155 CXX=$cxx
6156 AS=$as
6157 LD=$ld
6158 DEPCC=$dep_cc
6159 DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
6160 DEPAS=$as
6161 DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
6162 YASM=$yasmexe
6163 DEPYASM=$yasmexe
6164 AR=$ar
6165 ARFLAGS=$arflags
6166 AR_O=$ar_o
6167 RANLIB=$ranlib
6168 STRIP=$strip
6169 CP=cp -p
6170 LN_S=$ln_s
6171 CPPFLAGS=$CPPFLAGS
6172 CFLAGS=$CFLAGS
6173 CXXFLAGS=$CXXFLAGS
6174 ASFLAGS=$ASFLAGS
6175 AS_C=$AS_C
6176 AS_O=$AS_O
6177 CC_C=$CC_C
6178 CC_E=$CC_E
6179 CC_O=$CC_O
6180 CXX_C=$CXX_C
6181 CXX_O=$CXX_O
6182 LD_O=$LD_O
6183 LD_LIB=$LD_LIB
6184 LD_PATH=$LD_PATH
6185 DLLTOOL=$dlltool
6186 WINDRES=$windres
6187 DEPWINDRES=$dep_cc
6188 DOXYGEN=$doxygen
6189 LDFLAGS=$LDFLAGS
6190 LDEXEFLAGS=$LDEXEFLAGS
6191 LDLIBFLAGS=$LDLIBFLAGS
6192 SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
6193 ASMSTRIPFLAGS=$ASMSTRIPFLAGS
6194 YASMFLAGS=$YASMFLAGS
6195 BUILDSUF=$build_suffix
6196 PROGSSUF=$progs_suffix
6197 FULLNAME=$FULLNAME
6198 LIBPREF=$LIBPREF
6199 LIBSUF=$LIBSUF
6200 LIBNAME=$LIBNAME
6201 SLIBPREF=$SLIBPREF
6202 SLIBSUF=$SLIBSUF
6203 EXESUF=$EXESUF
6204 EXTRA_VERSION=$extra_version
6205 CCDEP=$CCDEP
6206 CXXDEP=$CXXDEP
6207 CCDEP_FLAGS=$CCDEP_FLAGS
6208 ASDEP=$ASDEP
6209 ASDEP_FLAGS=$ASDEP_FLAGS
6210 CC_DEPFLAGS=$CC_DEPFLAGS
6211 AS_DEPFLAGS=$AS_DEPFLAGS
6212 HOSTCC=$host_cc
6213 HOSTLD=$host_ld
6214 HOSTCFLAGS=$host_cflags
6215 HOSTCPPFLAGS=$host_cppflags
6216 HOSTEXESUF=$HOSTEXESUF
6217 HOSTLDFLAGS=$host_ldflags
6218 HOSTLIBS=$host_libs
6219 DEPHOSTCC=$host_cc
6220 DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
6221 HOSTCCDEP=$HOSTCCDEP
6222 HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
6223 HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
6224 HOSTCC_C=$HOSTCC_C
6225 HOSTCC_O=$HOSTCC_O
6226 HOSTLD_O=$HOSTLD_O
6227 TARGET_EXEC=$target_exec $target_exec_args
6228 TARGET_PATH=$target_path
6229 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
6230 CFLAGS-ffplay=$sdl_cflags
6231 ZLIB=$($ldflags_filter -lz)
6232 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
6233 EXTRALIBS=$extralibs
6234 COMPAT_OBJS=$compat_objs
6235 EXEOBJS=$exeobjs
6236 INSTALL=$install
6237 LIBTARGET=${LIBTARGET}
6238 SLIBNAME=${SLIBNAME}
6239 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
6240 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
6241 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
6242 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
6243 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
6244 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
6245 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
6246 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
6247 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
6248 NOREDZONE_FLAGS=$noredzone_flags
6249 EOF
6250
6251 get_version(){
6252     lcname=lib${1}
6253     name=$(toupper $lcname)
6254     file=$source_path/$lcname/version.h
6255     eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
6256     enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100))
6257     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
6258     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
6259     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
6260     eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> config.mak
6261 }
6262
6263 map 'get_version $v' $LIBRARY_LIST
6264
6265 map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> config.mak' $LIBRARY_LIST
6266
6267 print_program_libs(){
6268     eval "program_libs=\$${1}_libs"
6269     eval echo "LIBS-${1}=${program_libs}" >> config.mak
6270 }
6271
6272 map 'print_program_libs $v' $PROGRAM_LIST
6273
6274 cat > $TMPH <<EOF
6275 /* Automatically generated by configure - do not modify! */
6276 #ifndef FFMPEG_CONFIG_H
6277 #define FFMPEG_CONFIG_H
6278 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
6279 #define FFMPEG_LICENSE "$(c_escape $license)"
6280 #define CONFIG_THIS_YEAR 2015
6281 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
6282 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
6283 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
6284 #define av_restrict $_restrict
6285 #define EXTERN_PREFIX "${extern_prefix}"
6286 #define EXTERN_ASM ${extern_prefix}
6287 #define BUILDSUF "$build_suffix"
6288 #define SLIBSUF "$SLIBSUF"
6289 #define HAVE_MMX2 HAVE_MMXEXT
6290 #define SWS_MAX_FILTER_SIZE $sws_max_filter_size
6291 EOF
6292
6293 test -n "$assert_level" &&
6294     echo "#define ASSERT_LEVEL $assert_level" >>$TMPH
6295
6296 test -n "$malloc_prefix" &&
6297     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
6298
6299 if enabled yasm; then
6300     append config_files $TMPASM
6301     printf '' >$TMPASM
6302 fi
6303
6304 enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
6305
6306
6307 mkdir -p doc
6308 mkdir -p tests
6309 mkdir -p tests/api
6310 echo "@c auto-generated by configure - do not modify! " > doc/config.texi
6311
6312 print_config ARCH_   "$config_files" $ARCH_LIST
6313 print_config HAVE_   "$config_files" $HAVE_LIST
6314 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
6315                                      $CONFIG_EXTRA      \
6316                                      $ALL_COMPONENTS    \
6317
6318 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
6319 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
6320
6321 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
6322 cp_if_changed $TMPH config.h
6323 touch .config
6324
6325 enabled yasm && cp_if_changed $TMPASM config.asm
6326
6327 cat > $TMPH <<EOF
6328 /* Generated by ffconf */
6329 #ifndef AVUTIL_AVCONFIG_H
6330 #define AVUTIL_AVCONFIG_H
6331 EOF
6332
6333 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
6334
6335 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
6336
6337 cp_if_changed $TMPH libavutil/avconfig.h
6338
6339 if test -n "$WARNINGS"; then
6340     printf "\n%s%s$WARNINGS%s" "$warn_color" "$bold_color" "$reset_color"
6341     enabled fatal_warnings && exit 1
6342 fi
6343
6344 # build pkg-config files
6345
6346 lib_version(){
6347     eval printf "\"lib${1}${build_suffix} >= \$LIB$(toupper ${1})_VERSION, \""
6348 }
6349
6350 pkgconfig_generate(){
6351     name=$1
6352     shortname=${name#lib}${build_suffix}
6353     comment=$2
6354     version=$3
6355     libs=$4
6356     requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps))
6357     requires=${requires%, }
6358     enabled ${name#lib} || return 0
6359     mkdir -p $name
6360     cat <<EOF > $name/$name${build_suffix}.pc
6361 prefix=$prefix
6362 exec_prefix=\${prefix}
6363 libdir=$libdir
6364 includedir=$incdir
6365
6366 Name: $name
6367 Description: $comment
6368 Version: $version
6369 Requires: $(enabled shared || echo $requires)
6370 Requires.private: $(enabled shared && echo $requires)
6371 Conflicts:
6372 Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
6373 Libs.private: $(enabled shared && echo $libs)
6374 Cflags: -I\${includedir}
6375 EOF
6376
6377 mkdir -p doc/examples/pc-uninstalled
6378 includedir=${source_path}
6379 [ "$includedir" = . ] && includedir="\${pcfiledir}/../../.."
6380     cat <<EOF > doc/examples/pc-uninstalled/$name.pc
6381 prefix=
6382 exec_prefix=
6383 libdir=\${pcfiledir}/../../../$name
6384 includedir=${includedir}
6385
6386 Name: $name
6387 Description: $comment
6388 Version: $version
6389 Requires: $requires
6390 Conflicts:
6391 Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${shortname} $(enabled shared || echo $libs)
6392 Cflags: -I\${includedir}
6393 EOF
6394 }
6395
6396 pkgconfig_generate libavutil     "FFmpeg utility library"               "$LIBAVUTIL_VERSION"     "$LIBRT $LIBM"
6397 pkgconfig_generate libavcodec    "FFmpeg codec library"                 "$LIBAVCODEC_VERSION"    "$extralibs"
6398 pkgconfig_generate libavformat   "FFmpeg container format library"      "$LIBAVFORMAT_VERSION"   "$extralibs"
6399 pkgconfig_generate libavdevice   "FFmpeg device handling library"       "$LIBAVDEVICE_VERSION"   "$extralibs"
6400 pkgconfig_generate libavfilter   "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION"   "$extralibs"
6401 pkgconfig_generate libpostproc   "FFmpeg postprocessing library"        "$LIBPOSTPROC_VERSION"   ""
6402 pkgconfig_generate libavresample "Libav audio resampling library"       "$LIBAVRESAMPLE_VERSION" "$LIBM"
6403 pkgconfig_generate libswscale    "FFmpeg image rescaling library"       "$LIBSWSCALE_VERSION"    "$LIBM"
6404 pkgconfig_generate libswresample "FFmpeg audio resampling library"      "$LIBSWRESAMPLE_VERSION" "$LIBM $LIBSOXR"