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