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