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