avcodec/mjpegdec: Fix undefined shift
[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 Standard options:
65   --help                   print this message
66   --logfile=FILE           log tests and output to FILE [config.log]
67   --disable-logging        do not log configure debug information
68   --prefix=PREFIX          install in PREFIX [$prefix]
69   --bindir=DIR             install binaries in DIR [PREFIX/bin]
70   --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
71   --libdir=DIR             install libs in DIR [PREFIX/lib]
72   --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
73   --incdir=DIR             install includes in DIR [PREFIX/include]
74   --mandir=DIR             install man page in DIR [PREFIX/share/man]
75
76 Configuration options:
77   --disable-static         do not build static libraries [no]
78   --enable-shared          build shared libraries [no]
79   --enable-gpl             allow use of GPL code, the resulting libs
80                            and binaries will be under GPL [no]
81   --enable-version3        upgrade (L)GPL to version 3 [no]
82   --enable-nonfree         allow use of nonfree code, the resulting libs
83                            and binaries will be unredistributable [no]
84   --disable-doc            do not build documentation
85   --disable-ffmpeg         disable ffmpeg build
86   --disable-ffplay         disable ffplay build
87   --disable-ffprobe        disable ffprobe build
88   --disable-ffserver       disable ffserver build
89   --disable-avdevice       disable libavdevice build
90   --disable-avcodec        disable libavcodec build
91   --disable-avformat       disable libavformat build
92   --disable-swresample     disable libswresample build
93   --disable-swscale        disable libswscale build
94   --disable-postproc       disable libpostproc build
95   --disable-avfilter       disable video filter support [no]
96   --disable-pthreads       disable pthreads [auto]
97   --disable-w32threads     disable Win32 threads [auto]
98   --disable-os2threads     disable OS/2 threads [auto]
99   --enable-x11grab         enable X11 grabbing [no]
100   --disable-network        disable network support [no]
101   --enable-gray            enable full grayscale support (slower color)
102   --disable-swscale-alpha  disable alpha channel support in swscale
103   --disable-fastdiv        disable table-based division
104   --enable-small           optimize for size instead of speed
105   --disable-aandct         disable AAN DCT code
106   --disable-dct            disable DCT code
107   --disable-fft            disable FFT code
108   --disable-golomb         disable Golomb code
109   --disable-huffman        disable Huffman code
110   --disable-lpc            disable LPC code
111   --disable-mdct           disable MDCT code
112   --disable-rdft           disable RDFT code
113   --enable-vaapi           enable VAAPI code [autodetect]
114   --enable-vda             enable VDA code [autodetect]
115   --enable-vdpau           enable VDPAU code [autodetect]
116   --disable-dxva2          disable DXVA2 code
117   --disable-vda            disable VDA code
118   --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
119   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
120   --disable-safe-bitstream-reader
121                            disable buffer boundary checking in bitreaders
122                            (faster, but may crash)
123   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
124   --disable-everything     disable all components listed below
125   --disable-encoder=NAME   disable encoder NAME
126   --enable-encoder=NAME    enable encoder NAME
127   --disable-encoders       disable all encoders
128   --disable-decoder=NAME   disable decoder NAME
129   --enable-decoder=NAME    enable decoder NAME
130   --disable-decoders       disable all decoders
131   --disable-hwaccel=NAME   disable hwaccel NAME
132   --enable-hwaccel=NAME    enable hwaccel NAME
133   --disable-hwaccels       disable all hwaccels
134   --disable-muxer=NAME     disable muxer NAME
135   --enable-muxer=NAME      enable muxer NAME
136   --disable-muxers         disable all muxers
137   --disable-demuxer=NAME   disable demuxer NAME
138   --enable-demuxer=NAME    enable demuxer NAME
139   --disable-demuxers       disable all demuxers
140   --enable-parser=NAME     enable parser NAME
141   --disable-parser=NAME    disable parser NAME
142   --disable-parsers        disable all parsers
143   --enable-bsf=NAME        enable bitstream filter NAME
144   --disable-bsf=NAME       disable bitstream filter NAME
145   --disable-bsfs           disable all bitstream filters
146   --enable-protocol=NAME   enable protocol NAME
147   --disable-protocol=NAME  disable protocol NAME
148   --disable-protocols      disable all protocols
149   --disable-indev=NAME     disable input device NAME
150   --disable-outdev=NAME    disable output device NAME
151   --disable-indevs         disable input devices
152   --disable-outdevs        disable output devices
153   --disable-devices        disable all devices
154   --enable-filter=NAME     enable filter NAME
155   --disable-filter=NAME    disable filter NAME
156   --disable-filters        disable all filters
157   --list-decoders          show all available decoders
158   --list-encoders          show all available encoders
159   --list-hwaccels          show all available hardware accelerators
160   --list-muxers            show all available muxers
161   --list-demuxers          show all available demuxers
162   --list-parsers           show all available parsers
163   --list-protocols         show all available protocols
164   --list-bsfs              show all available bitstream filters
165   --list-indevs            show all available input devices
166   --list-outdevs           show all available output devices
167   --list-filters           show all available filters
168
169 External library support:
170   --enable-avisynth        enable reading of AVISynth script files [no]
171   --enable-bzlib           enable bzlib [autodetect]
172   --enable-frei0r          enable frei0r video filtering
173   --enable-gnutls          enable gnutls [no]
174   --enable-libaacplus      enable AAC+ encoding via libaacplus [no]
175   --enable-libass          enable libass subtitles rendering [no]
176   --enable-libcelt         enable CELT decoding via libcelt [no]
177   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
178   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
179   --enable-libopencv       enable video filtering via libopencv [no]
180   --enable-libcdio         enable audio CD grabbing with libcdio
181   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
182                            and libraw1394 [no]
183   --enable-libdirac        enable Dirac support via libdirac [no]
184   --enable-libfaac         enable FAAC support via libfaac [no]
185   --enable-libfreetype     enable libfreetype [no]
186   --enable-libgsm          enable GSM support via libgsm [no]
187   --enable-libmodplug      enable ModPlug via libmodplug [no]
188   --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
189   --enable-libnut          enable NUT (de)muxing via libnut,
190                            native (de)muxer exists [no]
191   --enable-libopenjpeg     enable JPEG 2000 encoding/decoding via OpenJPEG [no]
192   --enable-libpulse        enable Pulseaudio input via libpulse [no]
193   --enable-librtmp         enable RTMP[E] support via librtmp [no]
194   --enable-libschroedinger enable Dirac support via libschroedinger [no]
195   --enable-libspeex        enable Speex support via libspeex [no]
196   --enable-libstagefright-h264  enable H.264 decoding via libstagefright [no]
197   --enable-libtheora       enable Theora encoding via libtheora [no]
198   --enable-libutvideo      enable Ut Video decoding via libutvideo [no]
199   --enable-libv4l2         enable libv4l2/v4l-utils [no]
200   --enable-libvo-aacenc    enable AAC encoding via libvo-aacenc [no]
201   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
202   --enable-libvorbis       enable Vorbis encoding via libvorbis,
203                            native implementation exists [no]
204   --enable-libvpx          enable VP8 support via libvpx [no]
205   --enable-libx264         enable H.264 encoding via x264 [no]
206   --enable-libxavs         enable AVS encoding via xavs [no]
207   --enable-libxvid         enable Xvid encoding via xvidcore,
208                            native MPEG-4/Xvid encoder exists [no]
209   --enable-openal          enable OpenAL 1.1 capture support [no]
210   --enable-mlib            enable Sun medialib [no]
211   --enable-openssl         enable openssl [no]
212   --enable-zlib            enable zlib [autodetect]
213
214 Advanced options (experts only):
215   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
216   --enable-cross-compile   assume a cross-compiler is used
217   --sysroot=PATH           root of cross-build tree
218   --sysinclude=PATH        location of cross-build system headers
219   --target-os=OS           compiler targets OS [$target_os]
220   --target-exec=CMD        command to run executables on target
221   --target-path=DIR        path to view of build directory on target
222   --nm=NM                  use nm tool NM [$nm_default]
223   --ar=AR                  use archive tool AR [$ar_default]
224   --as=AS                  use assembler AS [$as_default]
225   --yasmexe=EXE            use yasm-compatible assembler EXE [$yasmexe_default]
226   --cc=CC                  use C compiler CC [$cc_default]
227   --cxx=CXX                use C compiler CXX [$cxx_default]
228   --ld=LD                  use linker LD [$ld_default]
229   --host-cc=HOSTCC         use host C compiler HOSTCC
230   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
231   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
232   --host-libs=HLIBS        use libs HLIBS when linking for host
233   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
234   --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
235   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
236   --extra-libs=ELIBS       add ELIBS [$ELIBS]
237   --extra-version=STRING   version string suffix []
238   --build-suffix=SUFFIX    library name suffix []
239   --progs-suffix=SUFFIX    program name suffix []
240   --arch=ARCH              select architecture [$arch]
241   --cpu=CPU                select the minimum required CPU (affects
242                            instruction selection, may crash on older CPUs)
243   --disable-asm            disable all assembler optimizations
244   --disable-altivec        disable AltiVec optimizations
245   --disable-amd3dnow       disable 3DNow! optimizations
246   --disable-amd3dnowext    disable 3DNow! extended optimizations
247   --disable-mmx            disable MMX optimizations
248   --disable-mmx2           disable MMX2 optimizations
249   --disable-sse            disable SSE optimizations
250   --disable-ssse3          disable SSSE3 optimizations
251   --disable-avx            disable AVX optimizations
252   --disable-armv5te        disable armv5te optimizations
253   --disable-armv6          disable armv6 optimizations
254   --disable-armv6t2        disable armv6t2 optimizations
255   --disable-armvfp         disable ARM VFP optimizations
256   --disable-iwmmxt         disable iwmmxt optimizations
257   --disable-mmi            disable MMI optimizations
258   --disable-neon           disable NEON optimizations
259   --disable-vis            disable VIS optimizations
260   --disable-yasm           disable use of yasm assembler
261   --enable-pic             build position-independent code
262   --malloc-prefix=PFX      prefix malloc and related names with PFX
263   --enable-sram            allow use of on-chip SRAM
264   --disable-symver         disable symbol versioning
265   --optflags               override optimization-related compiler flags
266   --postproc-version=V     build libpostproc version V.
267                            Where V can be '$ALT_PP_VER_MAJOR.$ALT_PP_VER_MINOR.$ALT_PP_VER_MICRO' or 'current'. [$postproc_version_default]
268
269 Developer options (useful when working on FFmpeg itself):
270   --enable-coverage        build with test coverage instrumentation
271   --disable-debug          disable debugging symbols
272   --enable-debug=LEVEL     set the debug level [$debuglevel]
273   --disable-optimizations  disable compiler optimizations
274   --enable-extra-warnings  enable more compiler warnings
275   --disable-stripping      disable stripping of executables and shared libraries
276   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
277                            leaks and errors, using the specified valgrind binary.
278                            Cannot be combined with --target-exec
279   --samples=PATH           location of test samples for FATE, if not set use
280                            \$FATE_SAMPLES at make invocation time.
281
282 NOTE: Object files are built at the place where configure is launched.
283 EOF
284   exit 0
285 }
286
287 quotes='""'
288
289 log(){
290     echo "$@" >> $logfile
291 }
292
293 log_file(){
294     log BEGIN $1
295     pr -n -t $1 >> $logfile
296     log END $1
297 }
298
299 echolog(){
300     log "$@"
301     echo "$@"
302 }
303
304 warn(){
305     log "WARNING: $*"
306     WARNINGS="${WARNINGS}WARNING: $*\n"
307 }
308
309 die(){
310     echolog "$@"
311     cat <<EOF
312
313 If you think configure made a mistake, make sure you are using the latest
314 version from Git.  If the latest version fails, report the problem to the
315 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
316 EOF
317     if disabled logging; then
318         cat <<EOF
319 Rerun configure with logging enabled (do not use --disable-logging), and
320 include the log this produces with your report.
321 EOF
322     else
323 cat <<EOF
324 Include the log file "$logfile" produced by configure as this will help
325 solving the problem.
326 EOF
327     fi
328     exit 1
329 }
330
331 # Avoid locale weirdness, besides we really just want to translate ASCII.
332 toupper(){
333     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
334 }
335
336 tolower(){
337     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
338 }
339
340 c_escape(){
341     echo "$*" | sed 's/["\\]/\\\0/g'
342 }
343
344 sh_quote(){
345     v=$(echo "$1" | sed "s/'/'\\\\''/g")
346     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
347     echo "$v"
348 }
349
350 cleanws(){
351     echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//'
352 }
353
354 filter(){
355     pat=$1
356     shift
357     for v; do
358         eval "case $v in $pat) echo $v ;; esac"
359     done
360 }
361
362 filter_out(){
363     pat=$1
364     shift
365     for v; do
366         eval "case $v in $pat) ;; *) echo $v ;; esac"
367     done
368 }
369
370 map(){
371     m=$1
372     shift
373     for v; do eval $m; done
374 }
375
376 set_all(){
377     value=$1
378     shift
379     for var in $*; do
380         eval $var=$value
381     done
382 }
383
384 set_weak(){
385     value=$1
386     shift
387     for var; do
388         eval : \${$var:=$value}
389     done
390 }
391
392 set_safe(){
393     var=$1
394     shift
395     eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
396 }
397
398 get_safe(){
399     eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
400 }
401
402 pushvar(){
403     for var in $*; do
404         eval level=\${${var}_level:=0}
405         eval ${var}_${level}="\$$var"
406         eval ${var}_level=$(($level+1))
407     done
408 }
409
410 popvar(){
411     for var in $*; do
412         eval level=\${${var}_level:-0}
413         test $level = 0 && continue
414         eval level=$(($level-1))
415         eval $var="\${${var}_${level}}"
416         eval ${var}_level=$level
417         eval unset ${var}_${level}
418     done
419 }
420
421 enable(){
422     set_all yes $*
423 }
424
425 disable(){
426     set_all no $*
427 }
428
429 enable_weak(){
430     set_weak yes $*
431 }
432
433 disable_weak(){
434     set_weak no $*
435 }
436
437 enable_safe(){
438     for var; do
439         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
440     done
441 }
442
443 disable_safe(){
444     for var; do
445         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
446     done
447 }
448
449 do_enable_deep(){
450     for var; do
451         enabled $var && continue
452         eval sel="\$${var}_select"
453         eval sgs="\$${var}_suggest"
454         pushvar var sgs
455         enable_deep $sel
456         popvar sgs
457         enable_deep_weak $sgs
458         popvar var
459     done
460 }
461
462 enable_deep(){
463     do_enable_deep $*
464     enable $*
465 }
466
467 enable_deep_weak(){
468     do_enable_deep $*
469     enable_weak $*
470 }
471
472 enabled(){
473     test "${1#!}" = "$1" && op== || op=!=
474     eval test "x\$${1#!}" $op "xyes"
475 }
476
477 disabled(){
478     test "${1#!}" = "$1" && op== || op=!=
479     eval test "x\$${1#!}" $op "xno"
480 }
481
482 enabled_all(){
483     for opt; do
484         enabled $opt || return 1
485     done
486 }
487
488 disabled_all(){
489     for opt; do
490         disabled $opt || return 1
491     done
492 }
493
494 enabled_any(){
495     for opt; do
496         enabled $opt && return 0
497     done
498 }
499
500 disabled_any(){
501     for opt; do
502         disabled $opt && return 0
503     done
504     return 1
505 }
506
507 set_default(){
508     for opt; do
509         eval : \${$opt:=\$${opt}_default}
510     done
511 }
512
513 is_in(){
514     value=$1
515     shift
516     for var in $*; do
517         [ $var = $value ] && return 0
518     done
519     return 1
520 }
521
522 check_deps(){
523     for cfg; do
524         cfg="${cfg#!}"
525         enabled ${cfg}_checking && die "Circular dependency for $cfg."
526         disabled ${cfg}_checking && continue
527         enable ${cfg}_checking
528
529         eval dep_all="\$${cfg}_deps"
530         eval dep_any="\$${cfg}_deps_any"
531         eval dep_sel="\$${cfg}_select"
532         eval dep_sgs="\$${cfg}_suggest"
533         eval dep_ifa="\$${cfg}_if"
534         eval dep_ifn="\$${cfg}_if_any"
535
536         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
537         check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
538         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
539
540         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
541         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
542         enabled_all  $dep_all || disable $cfg
543         enabled_any  $dep_any || disable $cfg
544         disabled_any $dep_sel && disable $cfg
545
546         if enabled $cfg; then
547             eval dep_extralibs="\$${cfg}_extralibs"
548             test -n "$dep_extralibs" && add_extralibs $dep_extralibs
549             enable_deep $dep_sel
550             enable_deep_weak $dep_sgs
551         fi
552
553         disable ${cfg}_checking
554     done
555 }
556
557 print_config_h(){
558     enabled $1 && v=1 || v=0
559     echo "#define $2 $v"
560 }
561
562 print_config_mak(){
563     enabled $1 && v= || v=!
564     echo "$v$2=yes"
565 }
566
567 print_config_asm(){
568     enabled $1 && echo "%define $2"
569 }
570
571 print_config(){
572     pfx=$1
573     files=$2
574     shift 2
575     for cfg; do
576         ucname="$(toupper $cfg)"
577         for f in $files; do
578             "print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
579         done
580     done
581 }
582
583 print_enabled(){
584     test "$1" = -n && end=" " && shift || end="\n"
585     suf=$1
586     shift
587     for v; do
588         enabled $v && printf "%s$end" ${v%$suf};
589     done
590 }
591
592 append(){
593     var=$1
594     shift
595     eval "$var=\"\$$var $*\""
596 }
597
598 prepend(){
599     var=$1
600     shift
601     eval "$var=\"$* \$$var\""
602 }
603
604 add_cppflags(){
605     append CPPFLAGS $($filter_cppflags "$@")
606 }
607
608 add_cflags(){
609     append CFLAGS $($filter_cflags "$@")
610 }
611
612 add_cxxflags(){
613     append CXXFLAGS $($filter_cflags "$@")
614 }
615
616 add_asflags(){
617     append ASFLAGS $($filter_asflags "$@")
618 }
619
620 add_ldflags(){
621     append LDFLAGS "$@"
622 }
623
624 add_extralibs(){
625     prepend extralibs "$@"
626 }
627
628 check_cmd(){
629     log "$@"
630     "$@" >> $logfile 2>&1
631 }
632
633 check_cc(){
634     log check_cc "$@"
635     cat > $TMPC
636     log_file $TMPC
637     check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
638 }
639
640 check_cxx(){
641     log check_cxx "$@"
642     cat > $TMPCPP
643     log_file $TMPCPP
644     check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" -c -o $TMPO $TMPCPP
645 }
646
647 check_cpp(){
648     log check_cpp "$@"
649     cat > $TMPC
650     log_file $TMPC
651     check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
652 }
653
654 check_as(){
655     log check_as "$@"
656     cat > $TMPC
657     log_file $TMPC
658     check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
659 }
660
661 check_asm(){
662     log check_asm "$@"
663     name="$1"
664     code="$2"
665     shift 2
666     disable $name
667     check_as "$@" <<EOF && enable $name
668 void foo(void){ __asm__ volatile($code); }
669 EOF
670 }
671
672 check_yasm(){
673     log check_yasm "$@"
674     echo "$1" > $TMPS
675     log_file $TMPS
676     shift 1
677     check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
678 }
679
680 check_ld(){
681     log check_ld "$@"
682     type=$1
683     shift 1
684     flags=''
685     libs=''
686     for f; do
687         test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
688     done
689     check_$type $($filter_cflags $flags) || return
690     check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
691 }
692
693 print_include(){
694     hdr=$1
695     test "${hdr%.h}" = "${hdr}" &&
696         echo "#include $hdr"    ||
697         echo "#include <$hdr>"
698 }
699
700 check_cppflags(){
701     log check_cppflags "$@"
702     set -- $($filter_cppflags "$@")
703     check_cc "$@" <<EOF && append CPPFLAGS "$@"
704 int x;
705 EOF
706 }
707
708 check_cflags(){
709     log check_cflags "$@"
710     set -- $($filter_cflags "$@")
711     check_cc "$@" <<EOF && append CFLAGS "$@"
712 int x;
713 EOF
714 }
715
716 check_cxxflags(){
717     log check_cxxflags "$@"
718     set -- $($filter_cflags "$@")
719     check_cxx "$@" <<EOF && append CXXFLAGS "$@"
720 int x;
721 EOF
722 }
723
724 test_ldflags(){
725     log test_ldflags "$@"
726     check_ld "cc" "$@" <<EOF
727 int main(void){ return 0; }
728 EOF
729 }
730
731 check_ldflags(){
732     log check_ldflags "$@"
733     test_ldflags "$@" && add_ldflags "$@"
734 }
735
736 check_header(){
737     log check_header "$@"
738     header=$1
739     shift
740     disable_safe $header
741     check_cpp "$@" <<EOF && enable_safe $header
742 #include <$header>
743 int x;
744 EOF
745 }
746
747 check_func(){
748     log check_func "$@"
749     func=$1
750     shift
751     disable $func
752     check_ld "cc" "$@" <<EOF && enable $func
753 extern int $func();
754 int main(void){ $func(); }
755 EOF
756 }
757
758 check_mathfunc(){
759     log check_mathfunc "$@"
760     func=$1
761     shift
762     disable $func
763     check_ld "cc" "$@" <<EOF && enable $func
764 #include <math.h>
765 float foo(float f) { return $func(f); }
766 int main(void){ return (int) foo; }
767 EOF
768 }
769
770 check_func_headers(){
771     log check_func_headers "$@"
772     headers=$1
773     funcs=$2
774     shift 2
775     {
776         for hdr in $headers; do
777             print_include $hdr
778         done
779         for func in $funcs; do
780             echo "long check_$func(void) { return (long) $func; }"
781         done
782         echo "int main(void) { return 0; }"
783     } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
784 }
785
786 check_class_headers_cpp(){
787     log check_class_headers_cpp "$@"
788     headers=$1
789     classes=$2
790     shift 2
791     {
792         for hdr in $headers; do
793             echo "#include <$hdr>"
794         done
795         echo "int main(void) { "
796         i=1
797         for class in $classes; do
798             echo "$class obj$i;"
799             i=$(expr $i + 1)
800         done
801         echo "return 0; }"
802     } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
803 }
804
805 check_cpp_condition(){
806     log check_cpp_condition "$@"
807     header=$1
808     condition=$2
809     shift 2
810     check_cpp $($filter_cppflags "$@") <<EOF
811 #include <$header>
812 #if !($condition)
813 #error "unsatisfied condition: $condition"
814 #endif
815 EOF
816 }
817
818 check_lib(){
819     log check_lib "$@"
820     header="$1"
821     func="$2"
822     shift 2
823     check_header $header && check_func $func "$@" && add_extralibs "$@"
824 }
825
826 check_lib2(){
827     log check_lib2 "$@"
828     headers="$1"
829     funcs="$2"
830     shift 2
831     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
832 }
833
834 check_lib_cpp(){
835     log check_lib_cpp "$@"
836     headers="$1"
837     classes="$2"
838     shift 2
839     check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
840 }
841
842 check_pkg_config(){
843     log check_pkg_config "$@"
844     pkg="$1"
845     headers="$2"
846     funcs="$3"
847     shift 3
848     $pkg_config --exists $pkg 2>/dev/null || return
849     pkg_cflags=$($pkg_config --cflags $pkg)
850     pkg_libs=$($pkg_config --libs $pkg)
851     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
852         set_safe ${pkg}_cflags $pkg_cflags   &&
853         set_safe ${pkg}_libs   $pkg_libs
854 }
855
856 check_exec(){
857     check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
858 }
859
860 check_exec_crash(){
861     code=$(cat)
862
863     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
864     # are safe but may not be available everywhere.  Thus we use
865     # raise(SIGTERM) instead.  The check is run in a subshell so we
866     # can redirect the "Terminated" message from the shell.  SIGBUS
867     # is not defined by standard C so it is used conditionally.
868
869     (check_exec "$@") >> $logfile 2>&1 <<EOF
870 #include <signal.h>
871 static void sighandler(int sig){
872     raise(SIGTERM);
873 }
874 int func(void){
875     $code
876 }
877 int main(void){
878     signal(SIGILL, sighandler);
879     signal(SIGFPE, sighandler);
880     signal(SIGSEGV, sighandler);
881 #ifdef SIGBUS
882     signal(SIGBUS, sighandler);
883 #endif
884     return func();
885 }
886 EOF
887 }
888
889 check_type(){
890     log check_type "$@"
891     headers=$1
892     type=$2
893     shift 2
894     disable_safe "$type"
895     incs=""
896     for hdr in $headers; do
897         incs="$incs
898 #include <$hdr>"
899     done
900     check_cc "$@" <<EOF && enable_safe "$type"
901 $incs
902 $type v;
903 EOF
904 }
905
906 check_struct(){
907     log check_type "$@"
908     headers=$1
909     struct=$2
910     member=$3
911     shift 3
912     disable_safe "${struct}_${member}"
913     incs=""
914     for hdr in $headers; do
915         incs="$incs
916 #include <$hdr>"
917     done
918     check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
919 $incs
920 const void *p = &(($struct *)0)->$member;
921 EOF
922 }
923
924 require(){
925     name="$1"
926     header="$2"
927     func="$3"
928     shift 3
929     check_lib $header $func "$@" || die "ERROR: $name not found"
930 }
931
932 require2(){
933     name="$1"
934     headers="$2"
935     func="$3"
936     shift 3
937     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
938 }
939
940 require_cpp(){
941     name="$1"
942     headers="$2"
943     classes="$3"
944     shift 3
945     check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
946 }
947
948 require_pkg_config(){
949     pkg="$1"
950     check_pkg_config "$@" || die "ERROR: $pkg not found"
951     add_cflags    $(get_safe ${pkg}_cflags)
952     add_extralibs $(get_safe ${pkg}_libs)
953 }
954
955 check_host_cc(){
956     log check_host_cc "$@"
957     cat > $TMPC
958     log_file $TMPC
959     check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
960 }
961
962 check_host_cflags(){
963     log check_host_cflags "$@"
964     check_host_cc "$@" <<EOF && append host_cflags "$@"
965 int x;
966 EOF
967 }
968
969 apply(){
970     file=$1
971     shift
972     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
973 }
974
975 cp_if_changed(){
976     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
977     mkdir -p "$(dirname $2)"
978     cp -f "$1" "$2"
979 }
980
981 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
982 # system-dependent things.
983
984 COMPONENT_LIST="
985     bsfs
986     decoders
987     demuxers
988     encoders
989     filters
990     hwaccels
991     indevs
992     muxers
993     outdevs
994     parsers
995     protocols
996 "
997
998 PROGRAM_LIST="
999     ffplay
1000     ffprobe
1001     ffserver
1002     ffmpeg
1003 "
1004
1005 CONFIG_LIST="
1006     $COMPONENT_LIST
1007     $PROGRAM_LIST
1008     avplay
1009     avprobe
1010     avserver
1011     aandct
1012     ac3dsp
1013     avcodec
1014     avdevice
1015     avfilter
1016     avformat
1017     avisynth
1018     bzlib
1019     crystalhd
1020     dct
1021     doc
1022     dwt
1023     dxva2
1024     fastdiv
1025     fft
1026     frei0r
1027     gnutls
1028     golomb
1029     gpl
1030     gray
1031     h264chroma
1032     h264dsp
1033     h264pred
1034     hardcoded_tables
1035     huffman
1036     libaacplus
1037     libass
1038     libcdio
1039     libcelt
1040     libdc1394
1041     libdirac
1042     libfaac
1043     libfreetype
1044     libgsm
1045     libmodplug
1046     libmp3lame
1047     libnut
1048     libopencore_amrnb
1049     libopencore_amrwb
1050     libopencv
1051     libopenjpeg
1052     libpulse
1053     librtmp
1054     libschroedinger
1055     libspeex
1056     libstagefright_h264
1057     libtheora
1058     libutvideo
1059     libv4l2
1060     libvo_aacenc
1061     libvo_amrwbenc
1062     libvorbis
1063     libvpx
1064     libx264
1065     libxavs
1066     libxvid
1067     lpc
1068     lsp
1069     mdct
1070     memalign_hack
1071     mlib
1072     mpegaudiodsp
1073     network
1074     nonfree
1075     openal
1076     openssl
1077     pic
1078     postproc
1079     rdft
1080     rtpdec
1081     runtime_cpudetect
1082     safe_bitstream_reader
1083     shared
1084     sinewin
1085     small
1086     sram
1087     static
1088     swresample
1089     swscale
1090     swscale_alpha
1091     thumb
1092     vaapi
1093     vda
1094     vdpau
1095     version3
1096     x11grab
1097     zlib
1098 "
1099
1100 THREADS_LIST='
1101     pthreads
1102     w32threads
1103     os2threads
1104 '
1105
1106 ARCH_LIST='
1107     alpha
1108     arm
1109     avr32
1110     avr32_ap
1111     avr32_uc
1112     bfin
1113     ia64
1114     m68k
1115     mips
1116     mips64
1117     parisc
1118     ppc
1119     ppc64
1120     s390
1121     sh4
1122     sparc
1123     sparc64
1124     tomi
1125     x86
1126     x86_32
1127     x86_64
1128 '
1129
1130 ARCH_EXT_LIST='
1131     altivec
1132     amd3dnow
1133     amd3dnowext
1134     armv5te
1135     armv6
1136     armv6t2
1137     armvfp
1138     avx
1139     iwmmxt
1140     mmi
1141     mmx
1142     mmx2
1143     neon
1144     ppc4xx
1145     sse
1146     ssse3
1147     vfpv3
1148     vis
1149 '
1150
1151 HAVE_LIST_PUB='
1152     bigendian
1153     fast_unaligned
1154 '
1155
1156 HAVE_LIST="
1157     $ARCH_EXT_LIST
1158     $HAVE_LIST_PUB
1159     $THREADS_LIST
1160     aligned_stack
1161     alsa_asoundlib_h
1162     altivec_h
1163     arpa_inet_h
1164     asm_mod_y
1165     asm_types_h
1166     attribute_may_alias
1167     attribute_packed
1168     cbrtf
1169     closesocket
1170     cmov
1171     dcbzl
1172     dev_bktr_ioctl_bt848_h
1173     dev_bktr_ioctl_meteor_h
1174     dev_ic_bt8xx_h
1175     dev_video_bktr_ioctl_bt848_h
1176     dev_video_meteor_ioctl_meteor_h
1177     dlfcn_h
1178     dlopen
1179     dos_paths
1180     dxva_h
1181     ebp_available
1182     ebx_available
1183     exp2
1184     exp2f
1185     fast_64bit
1186     fast_clz
1187     fast_cmov
1188     fcntl
1189     fork
1190     getaddrinfo
1191     gethrtime
1192     GetProcessAffinityMask
1193     GetProcessMemoryInfo
1194     GetProcessTimes
1195     getrusage
1196     gnu_as
1197     ibm_asm
1198     inet_aton
1199     inline_asm
1200     isatty
1201     kbhit
1202     ldbrx
1203     llrint
1204     llrintf
1205     local_aligned_16
1206     local_aligned_8
1207     localtime_r
1208     log2
1209     log2f
1210     loongson
1211     lrint
1212     lrintf
1213     lzo1x_999_compress
1214     machine_ioctl_bt848_h
1215     machine_ioctl_meteor_h
1216     makeinfo
1217     malloc_h
1218     MapViewOfFile
1219     memalign
1220     mkstemp
1221     mmap
1222     PeekNamedPipe
1223     poll_h
1224     posix_memalign
1225     round
1226     roundf
1227     sched_getaffinity
1228     sdl
1229     sdl_video_size
1230     setmode
1231     setrlimit
1232     sndio_h
1233     socklen_t
1234     soundcard_h
1235     strerror_r
1236     strptime
1237     struct_addrinfo
1238     struct_ipv6_mreq
1239     struct_rusage_ru_maxrss
1240     struct_sockaddr_in6
1241     struct_sockaddr_sa_len
1242     struct_sockaddr_storage
1243     struct_v4l2_frmivalenum_discrete
1244     symver
1245     symver_asm_label
1246     symver_gnu_asm
1247     sysconf
1248     sysctl
1249     sys_mman_h
1250     sys_param_h
1251     sys_resource_h
1252     sys_select_h
1253     sys_soundcard_h
1254     sys_videoio_h
1255     termios_h
1256     threads
1257     trunc
1258     truncf
1259     vfp_args
1260     VirtualAlloc
1261     winsock2_h
1262     xform_asm
1263     xmm_clobbers
1264     yasm
1265 "
1266
1267 # options emitted with CONFIG_ prefix but not available on command line
1268 CONFIG_EXTRA="
1269     avutil
1270     gplv3
1271     lgplv3
1272 "
1273
1274 CMDLINE_SELECT="
1275     $ARCH_EXT_LIST
1276     $CONFIG_LIST
1277     $THREADS_LIST
1278     asm
1279     coverage
1280     cross_compile
1281     debug
1282     extra_warnings
1283     logging
1284     optimizations
1285     stripping
1286     symver
1287     yasm
1288 "
1289
1290 PATHS_LIST='
1291     bindir
1292     datadir
1293     incdir
1294     libdir
1295     mandir
1296     prefix
1297     shlibdir
1298 '
1299
1300 CMDLINE_SET="
1301     $PATHS_LIST
1302     ar
1303     arch
1304     as
1305     build_suffix
1306     progs_suffix
1307     cc
1308     cpu
1309     cross_prefix
1310     cxx
1311     dep_cc
1312     extra_version
1313     host_cc
1314     host_cflags
1315     host_ldflags
1316     host_libs
1317     host_os
1318     install
1319     ld
1320     logfile
1321     malloc_prefix
1322     nm
1323     optflags
1324     pkg_config
1325     samples
1326     strip
1327     sysinclude
1328     sysroot
1329     target_exec
1330     target_os
1331     target_path
1332     postproc_version
1333     valgrind
1334     yasmexe
1335 "
1336
1337 CMDLINE_APPEND="
1338     extra_cflags
1339     extra_cxxflags
1340 "
1341
1342 # code dependency declarations
1343
1344 # architecture extensions
1345
1346 armv5te_deps="arm"
1347 armv6_deps="arm"
1348 armv6t2_deps="arm"
1349 armvfp_deps="arm"
1350 iwmmxt_deps="arm"
1351 neon_deps="arm"
1352 vfpv3_deps="armvfp"
1353
1354 mmi_deps="mips"
1355
1356 altivec_deps="ppc"
1357 ppc4xx_deps="ppc"
1358
1359 vis_deps="sparc"
1360
1361 x86_64_suggest="cmov fast_cmov"
1362 amd3dnow_deps="mmx"
1363 amd3dnowext_deps="amd3dnow"
1364 mmx_deps="x86"
1365 mmx2_deps="mmx"
1366 sse_deps="mmx"
1367 ssse3_deps="sse"
1368 avx_deps="ssse3"
1369
1370 aligned_stack_if_any="ppc x86"
1371 fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1372 fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1373 fast_unaligned_if_any="armv6 ppc x86"
1374
1375 inline_asm_deps="!tms470"
1376 need_memalign="altivec neon sse"
1377
1378 symver_if_any="symver_asm_label symver_gnu_asm"
1379
1380 # subsystems
1381 dct_select="rdft"
1382 mdct_select="fft"
1383 rdft_select="fft"
1384 mpegaudiodsp_select="dct"
1385
1386 # decoders / encoders / hardware accelerators
1387 aac_decoder_select="mdct sinewin"
1388 aac_encoder_select="mdct sinewin"
1389 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1390 ac3_decoder_select="mdct ac3dsp ac3_parser"
1391 ac3_encoder_select="mdct ac3dsp"
1392 ac3_fixed_encoder_select="mdct ac3dsp"
1393 alac_encoder_select="lpc"
1394 amrnb_decoder_select="lsp"
1395 amrwb_decoder_select="lsp"
1396 atrac1_decoder_select="mdct sinewin"
1397 atrac3_decoder_select="mdct"
1398 binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1399 binkaudio_rdft_decoder_select="mdct rdft sinewin"
1400 cavs_decoder_select="golomb"
1401 cook_decoder_select="mdct sinewin"
1402 cscd_decoder_suggest="zlib"
1403 dca_decoder_select="mdct"
1404 dnxhd_encoder_select="aandct"
1405 dxa_decoder_select="zlib"
1406 eac3_decoder_select="ac3_decoder"
1407 eac3_encoder_select="mdct ac3dsp"
1408 eamad_decoder_select="aandct"
1409 eatgq_decoder_select="aandct"
1410 eatqi_decoder_select="aandct"
1411 ffv1_decoder_select="golomb"
1412 flac_decoder_select="golomb"
1413 flac_encoder_select="golomb lpc"
1414 flashsv_decoder_select="zlib"
1415 flashsv_encoder_select="zlib"
1416 flashsv2_encoder_select="zlib"
1417 flashsv2_decoder_select="zlib"
1418 flv_decoder_select="h263_decoder"
1419 flv_encoder_select="h263_encoder"
1420 fraps_decoder_select="huffman"
1421 h261_encoder_select="aandct"
1422 h263_decoder_select="h263_parser"
1423 h263_encoder_select="aandct"
1424 h263_vaapi_hwaccel_select="vaapi h263_decoder"
1425 h263i_decoder_select="h263_decoder"
1426 h263p_encoder_select="h263_encoder"
1427 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
1428 h264_decoder_select="golomb h264chroma h264dsp h264pred"
1429 h264_dxva2_hwaccel_deps="dxva2api_h"
1430 h264_dxva2_hwaccel_select="dxva2 h264_decoder"
1431 h264_vaapi_hwaccel_select="vaapi h264_decoder"
1432 h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
1433 h264_vda_hwaccel_select="vda h264_decoder"
1434 h264_vdpau_decoder_select="vdpau h264_decoder"
1435 imc_decoder_select="fft mdct sinewin"
1436 jpegls_decoder_select="golomb"
1437 jpegls_encoder_select="golomb"
1438 ljpeg_encoder_select="aandct"
1439 loco_decoder_select="golomb"
1440 mjpeg_encoder_select="aandct"
1441 mlp_decoder_select="mlp_parser"
1442 mp1_decoder_select="mpegaudiodsp"
1443 mp1float_decoder_select="mpegaudiodsp"
1444 mp2_decoder_select="mpegaudiodsp"
1445 mp2float_decoder_select="mpegaudiodsp"
1446 mp3_decoder_select="mpegaudiodsp"
1447 mp3adu_decoder_select="mpegaudiodsp"
1448 mp3adufloat_decoder_select="mpegaudiodsp"
1449 mp3float_decoder_select="mpegaudiodsp"
1450 mp3on4_decoder_select="mpegaudiodsp"
1451 mp3on4float_decoder_select="mpegaudiodsp"
1452 mpc7_decoder_select="mpegaudiodsp"
1453 mpc8_decoder_select="mpegaudiodsp"
1454 mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1455 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1456 mpeg_xvmc_decoder_select="mpegvideo_decoder"
1457 mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1458 mpeg1_vdpau_hwaccel_select="vdpau mpeg1video_decoder"
1459 mpeg1video_encoder_select="aandct"
1460 mpeg2_crystalhd_decoder_select="crystalhd"
1461 mpeg2_dxva2_hwaccel_deps="dxva2api_h"
1462 mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
1463 mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder"
1464 mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1465 mpeg2video_encoder_select="aandct"
1466 mpeg4_crystalhd_decoder_select="crystalhd"
1467 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1468 mpeg4_encoder_select="h263_encoder"
1469 mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1470 mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1471 msmpeg4_crystalhd_decoder_select="crystalhd"
1472 msmpeg4v1_decoder_select="h263_decoder"
1473 msmpeg4v1_encoder_select="h263_encoder"
1474 msmpeg4v2_decoder_select="h263_decoder"
1475 msmpeg4v2_encoder_select="h263_encoder"
1476 msmpeg4v3_decoder_select="h263_decoder"
1477 msmpeg4v3_encoder_select="h263_encoder"
1478 nellymoser_decoder_select="mdct sinewin"
1479 nellymoser_encoder_select="mdct sinewin"
1480 png_decoder_select="zlib"
1481 png_encoder_select="zlib"
1482 qcelp_decoder_select="lsp"
1483 qdm2_decoder_select="mdct rdft mpegaudiodsp"
1484 ra_144_encoder_select="lpc"
1485 rv10_decoder_select="h263_decoder"
1486 rv10_encoder_select="h263_encoder"
1487 rv20_decoder_select="h263_decoder"
1488 rv20_encoder_select="h263_encoder"
1489 rv30_decoder_select="golomb h264chroma h264pred"
1490 rv40_decoder_select="golomb h264chroma h264pred"
1491 shorten_decoder_select="golomb"
1492 sipr_decoder_select="lsp"
1493 snow_decoder_select="dwt"
1494 snow_encoder_select="aandct dwt"
1495 sonic_decoder_select="golomb"
1496 sonic_encoder_select="golomb"
1497 sonic_ls_encoder_select="golomb"
1498 svq1_encoder_select="aandct"
1499 svq3_decoder_select="golomb h264chroma h264dsp h264pred"
1500 svq3_decoder_suggest="zlib"
1501 theora_decoder_select="vp3_decoder"
1502 tiff_decoder_suggest="zlib"
1503 tiff_encoder_suggest="zlib"
1504 truehd_decoder_select="mlp_decoder"
1505 tscc_decoder_select="zlib"
1506 twinvq_decoder_select="mdct lsp sinewin"
1507 vc1_crystalhd_decoder_select="crystalhd"
1508 vc1_decoder_select="h263_decoder h264chroma"
1509 vc1_dxva2_hwaccel_deps="dxva2api_h"
1510 vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
1511 vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1512 vc1_vdpau_decoder_select="vdpau vc1_decoder"
1513 vc1image_decoder_select="vc1_decoder"
1514 vorbis_decoder_select="mdct"
1515 vorbis_encoder_select="mdct"
1516 vp6_decoder_select="huffman"
1517 vp6a_decoder_select="vp6_decoder"
1518 vp6f_decoder_select="vp6_decoder"
1519 vp8_decoder_select="h264pred"
1520 wmapro_decoder_select="mdct sinewin"
1521 wmav1_decoder_select="mdct sinewin"
1522 wmav1_encoder_select="mdct sinewin"
1523 wmav2_decoder_select="mdct sinewin"
1524 wmav2_encoder_select="mdct sinewin"
1525 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
1526 wmv1_decoder_select="h263_decoder"
1527 wmv1_encoder_select="h263_encoder"
1528 wmv2_decoder_select="h263_decoder"
1529 wmv2_encoder_select="h263_encoder"
1530 wmv3_decoder_select="vc1_decoder"
1531 wmv3_crystalhd_decoder_select="crystalhd"
1532 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
1533 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1534 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1535 wmv3image_decoder_select="wmv3_decoder"
1536 zlib_decoder_select="zlib"
1537 zlib_encoder_select="zlib"
1538 zmbv_decoder_select="zlib"
1539 zmbv_encoder_select="zlib"
1540
1541 crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
1542 vaapi_deps="va_va_h"
1543 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
1544 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1545
1546 # parsers
1547 h264_parser_select="golomb h264chroma h264dsp h264pred"
1548
1549 # external libraries
1550 libaacplus_encoder_deps="libaacplus"
1551 libcelt_decoder_deps="libcelt"
1552 libdirac_decoder_deps="libdirac !libschroedinger"
1553 libdirac_encoder_deps="libdirac"
1554 libfaac_encoder_deps="libfaac"
1555 libgsm_decoder_deps="libgsm"
1556 libgsm_encoder_deps="libgsm"
1557 libgsm_ms_decoder_deps="libgsm"
1558 libgsm_ms_encoder_deps="libgsm"
1559 libmodplug_demuxer_deps="libmodplug"
1560 libmp3lame_encoder_deps="libmp3lame"
1561 libopencore_amrnb_decoder_deps="libopencore_amrnb"
1562 libopencore_amrnb_encoder_deps="libopencore_amrnb"
1563 libopencore_amrwb_decoder_deps="libopencore_amrwb"
1564 libopenjpeg_decoder_deps="libopenjpeg"
1565 libopenjpeg_encoder_deps="libopenjpeg"
1566 libschroedinger_decoder_deps="libschroedinger"
1567 libschroedinger_encoder_deps="libschroedinger"
1568 libspeex_decoder_deps="libspeex"
1569 libspeex_encoder_deps="libspeex"
1570 libstagefright_h264_decoder_deps="libstagefright_h264"
1571 libtheora_encoder_deps="libtheora"
1572 libvo_aacenc_encoder_deps="libvo_aacenc"
1573 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
1574 libvorbis_encoder_deps="libvorbis"
1575 libvpx_decoder_deps="libvpx"
1576 libvpx_encoder_deps="libvpx"
1577 libx264_encoder_deps="libx264"
1578 libx264rgb_encoder_deps="libx264"
1579 libxavs_encoder_deps="libxavs"
1580 libxvid_encoder_deps="libxvid"
1581 libutvideo_decoder_deps="libutvideo gpl"
1582
1583 # demuxers / muxers
1584 ac3_demuxer_select="ac3_parser"
1585 asf_stream_muxer_select="asf_muxer"
1586 avisynth_demuxer_deps="avisynth"
1587 dirac_demuxer_select="dirac_parser"
1588 eac3_demuxer_select="ac3_parser"
1589 flac_demuxer_select="flac_parser"
1590 ipod_muxer_select="mov_muxer"
1591 libnut_demuxer_deps="libnut"
1592 libnut_muxer_deps="libnut"
1593 matroska_audio_muxer_select="matroska_muxer"
1594 matroska_demuxer_suggest="zlib bzlib"
1595 mov_demuxer_suggest="zlib"
1596 mp3_demuxer_select="mpegaudio_parser"
1597 mp4_muxer_select="mov_muxer"
1598 mpegtsraw_demuxer_select="mpegts_demuxer"
1599 mxf_d10_muxer_select="mxf_muxer"
1600 ogg_demuxer_select="golomb"
1601 psp_muxer_select="mov_muxer"
1602 rtp_demuxer_select="sdp_demuxer"
1603 rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
1604 rtsp_demuxer_select="http_protocol rtpdec"
1605 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
1606 sap_demuxer_select="sdp_demuxer"
1607 sap_muxer_select="rtp_muxer rtp_protocol"
1608 sdp_demuxer_select="rtpdec"
1609 spdif_muxer_select="aac_parser"
1610 tg2_muxer_select="mov_muxer"
1611 tgp_muxer_select="mov_muxer"
1612 w64_demuxer_deps="wav_demuxer"
1613
1614 # indevs / outdevs
1615 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1616 alsa_outdev_deps="alsa_asoundlib_h"
1617 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1618 dshow_indev_deps="IBaseFilter"
1619 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid"
1620 dv1394_indev_deps="dv1394 dv_demuxer"
1621 fbdev_indev_deps="linux_fb_h"
1622 jack_indev_deps="jack_jack_h sem_timedwait"
1623 lavfi_indev_deps="avfilter"
1624 libcdio_indev_deps="libcdio"
1625 libdc1394_indev_deps="libdc1394"
1626 libv4l2_indev_deps="libv4l2"
1627 openal_indev_deps="openal"
1628 oss_indev_deps_any="soundcard_h sys_soundcard_h"
1629 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1630 pulse_indev_deps="libpulse"
1631 sdl_outdev_deps="sdl"
1632 sndio_indev_deps="sndio_h"
1633 sndio_outdev_deps="sndio_h"
1634 v4l_indev_deps="linux_videodev_h"
1635 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1636 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
1637 vfwcap_indev_extralibs="-lavicap32"
1638 x11_grab_device_indev_deps="x11grab XShmCreateImage"
1639 x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1640
1641 # protocols
1642 gopher_protocol_deps="network"
1643 httpproxy_protocol_deps="network"
1644 httpproxy_protocol_select="tcp_protocol"
1645 http_protocol_deps="network"
1646 http_protocol_select="tcp_protocol"
1647 https_protocol_select="tls_protocol"
1648 mmsh_protocol_select="http_protocol"
1649 mmst_protocol_deps="network"
1650 rtmp_protocol_select="tcp_protocol"
1651 rtp_protocol_select="udp_protocol"
1652 tcp_protocol_deps="network"
1653 tls_protocol_deps_any="openssl gnutls"
1654 tls_protocol_select="tcp_protocol"
1655 udp_protocol_deps="network"
1656
1657 # filters
1658 amovie_filter_deps="avcodec avformat"
1659 ass_filter_deps="libass"
1660 blackframe_filter_deps="gpl"
1661 boxblur_filter_deps="gpl"
1662 cropdetect_filter_deps="gpl"
1663 delogo_filter_deps="gpl"
1664 drawtext_filter_deps="libfreetype"
1665 frei0r_filter_deps="frei0r dlopen"
1666 frei0r_src_filter_deps="frei0r dlopen"
1667 hqdn3d_filter_deps="gpl"
1668 movie_filter_deps="avcodec avformat"
1669 mp_filter_deps="gpl avcodec"
1670 mptestsrc_filter_deps="gpl"
1671 negate_filter_deps="lut_filter"
1672 ocv_filter_deps="libopencv"
1673 pan_filter_deps="swresample"
1674 scale_filter_deps="swscale"
1675 tinterlace_filter_deps="gpl"
1676 yadif_filter_deps="gpl"
1677
1678 # libraries
1679 avdevice_deps="avcodec avformat"
1680 avformat_deps="avcodec"
1681 postproc_deps="gpl"
1682
1683 # programs
1684 ffplay_deps="avcodec avformat swscale sdl"
1685 ffplay_select="buffersink_filter rdft"
1686 ffprobe_deps="avcodec avformat"
1687 ffserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer"
1688 ffserver_extralibs='$ldl'
1689 ffmpeg_deps="avcodec avformat swscale swresample"
1690 ffmpeg_select="buffersink_filter"
1691
1692 doc_deps="texi2html"
1693
1694 # tests
1695
1696 test_deps(){
1697     suf1=$1
1698     suf2=$2
1699     shift 2
1700     for v; do
1701         dep=${v%=*}
1702         tests=${v#*=}
1703         for name in ${tests}; do
1704             append ${name}_test_deps ${dep}$suf1 ${dep}$suf2
1705         done
1706     done
1707 }
1708
1709 mxf_d10_test_deps="avfilter"
1710 seek_lavf_mxf_d10_test_deps="mxf_d10_test"
1711
1712 test_deps _encoder _decoder                                             \
1713     adpcm_ima_qt                                                        \
1714     adpcm_ima_wav                                                       \
1715     adpcm_ms                                                            \
1716     adpcm_swf                                                           \
1717     adpcm_yamaha=adpcm_yam                                              \
1718     alac                                                                \
1719     asv1                                                                \
1720     asv2                                                                \
1721     bmp                                                                 \
1722     dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd"                        \
1723     dvvideo="dv dv_411 dv50"                                            \
1724     ffv1                                                                \
1725     flac                                                                \
1726     flashsv                                                             \
1727     flv                                                                 \
1728     adpcm_g726=g726                                                     \
1729     gif                                                                 \
1730     h261                                                                \
1731     h263="h263 h263p"                                                   \
1732     huffyuv                                                             \
1733     jpegls                                                              \
1734     mjpeg="jpg mjpeg ljpeg"                                             \
1735     mp2                                                                 \
1736     mpeg1video="mpeg mpeg1b"                                            \
1737     mpeg2video="mpeg2 mpeg2_422 mpeg2_idct_int mpeg2_ilace mpeg2_ivlc_qprd" \
1738     mpeg2video="mpeg2thread mpeg2thread_ilace"                          \
1739     mpeg4="mpeg4 mpeg4_adap mpeg4_qpel mpeg4_qprd mpeg4adv mpeg4nr"     \
1740     mpeg4="mpeg4thread error rc"                                        \
1741     msmpeg4v3=msmpeg4                                                   \
1742     msmpeg4v2                                                           \
1743     pbm=pbmpipe                                                         \
1744     pcx                                                                 \
1745     pgm="pgm pgmpipe"                                                   \
1746     png                                                                 \
1747     ppm="ppm ppmpipe"                                                   \
1748     rawvideo="rgb yuv"                                                  \
1749     roq                                                                 \
1750     rv10                                                                \
1751     rv20                                                                \
1752     sgi                                                                 \
1753     snow="snow snowll"                                                  \
1754     svq1                                                                \
1755     targa=tga                                                           \
1756     tiff                                                                \
1757     wmav1                                                               \
1758     wmav2                                                               \
1759     wmv1                                                                \
1760     wmv2                                                                \
1761
1762 test_deps _muxer _demuxer                                               \
1763     aiff                                                                \
1764     pcm_alaw=alaw                                                       \
1765     asf                                                                 \
1766     au                                                                  \
1767     avi                                                                 \
1768     dv=dv_fmt                                                           \
1769     ffm                                                                 \
1770     flv=flv_fmt                                                         \
1771     gxf                                                                 \
1772     matroska=mkv                                                        \
1773     mmf                                                                 \
1774     mov                                                                 \
1775     pcm_mulaw=mulaw                                                     \
1776     mxf="mxf mxf_d10"                                                   \
1777     nut                                                                 \
1778     ogg                                                                 \
1779     rawvideo=pixfmt                                                     \
1780     rm                                                                  \
1781     swf                                                                 \
1782     mpegts=ts                                                           \
1783     voc                                                                 \
1784     wav                                                                 \
1785     yuv4mpegpipe=yuv4mpeg                                               \
1786
1787 ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1788 mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1789
1790 # default parameters
1791
1792 logfile="config.log"
1793
1794 # installation paths
1795 prefix_default="/usr/local"
1796 bindir_default='${prefix}/bin'
1797 datadir_default='${prefix}/share/ffmpeg'
1798 incdir_default='${prefix}/include'
1799 libdir_default='${prefix}/lib'
1800 mandir_default='${prefix}/share/man'
1801 shlibdir_default="$libdir_default"
1802 postproc_version_default="current"
1803
1804 # toolchain
1805 ar_default="ar"
1806 cc_default="gcc"
1807 cxx_default="g++"
1808 cc_version=\"unknown\"
1809 host_cc_default="gcc"
1810 install="install"
1811 ln_s="ln -sf"
1812 nm_default="nm"
1813 objformat="elf"
1814 pkg_config_default=pkg-config
1815 ranlib="ranlib"
1816 strip_default="strip"
1817 yasmexe_default="yasm"
1818
1819 nm_opts='-g'
1820 nogas=":"
1821
1822 # machine
1823 arch_default=$(uname -m)
1824 cpu="generic"
1825
1826 # OS
1827 target_os_default=$(tolower $(uname -s))
1828 host_os=$target_os_default
1829
1830 # alternative libpostproc version
1831 ALT_PP_VER_MAJOR=51
1832 ALT_PP_VER_MINOR=2
1833 ALT_PP_VER_MICRO=101
1834 ALT_PP_VER=$ALT_PP_VER_MAJOR.$ALT_PP_VER_MINOR.$ALT_PP_VER_MICRO
1835
1836 # configurable options
1837 enable $PROGRAM_LIST
1838
1839 enable avcodec
1840 enable avdevice
1841 enable avfilter
1842 enable avformat
1843 enable avutil
1844 enable postproc
1845 enable stripping
1846 enable swresample
1847 enable swscale
1848
1849 enable asm
1850 enable debug
1851 enable doc
1852 enable fastdiv
1853 enable network
1854 enable optimizations
1855 enable safe_bitstream_reader
1856 enable static
1857 enable swscale_alpha
1858
1859 # build settings
1860 SHFLAGS='-shared -Wl,-soname,$$(@F)'
1861 FFSERVERLDFLAGS=-Wl,-E
1862 LIBPREF="lib"
1863 LIBSUF=".a"
1864 FULLNAME='$(NAME)$(BUILDSUF)'
1865 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1866 SLIBPREF="lib"
1867 SLIBSUF=".so"
1868 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1869 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1870 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1871 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1872 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
1873 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
1874
1875 AS_O='-o $@'
1876 CC_O='-o $@'
1877 CXX_O='-o $@'
1878
1879 host_cflags='-D_ISOC99_SOURCE -O3 -g'
1880 host_libs='-lm'
1881
1882 target_path='$(CURDIR)'
1883
1884 # since the object filename is not given with the -MM flag, the compiler
1885 # is only able to print the basename, and we must add the path ourselves
1886 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1887 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1888
1889 # find source path
1890 if test -f configure; then
1891     source_path=.
1892 else
1893     source_path=$(cd $(dirname "$0"); pwd)
1894     echo "$source_path" | grep -q '[[:blank:]]' &&
1895         die "Out of tree builds are impossible with whitespace in source path."
1896     test -e "$source_path/config.h" &&
1897         die "Out of tree builds are impossible with config.h in source dir."
1898 fi
1899
1900 for v in "$@"; do
1901     r=${v#*=}
1902     l=${v%"$r"}
1903     r=$(sh_quote "$r")
1904     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1905 done
1906
1907 find_things(){
1908     thing=$1
1909     pattern=$2
1910     file=$source_path/$3
1911     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1912 }
1913
1914 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1915 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1916 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1917 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1918 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1919 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1920 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1921 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1922 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1923 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1924 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1925
1926 ALL_COMPONENTS="
1927     $BSF_LIST
1928     $DECODER_LIST
1929     $DEMUXER_LIST
1930     $ENCODER_LIST
1931     $FILTER_LIST
1932     $HWACCEL_LIST
1933     $INDEV_LIST
1934     $MUXER_LIST
1935     $OUTDEV_LIST
1936     $PARSER_LIST
1937     $PROTOCOL_LIST
1938 "
1939
1940 find_tests(){
1941     map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
1942 }
1943
1944 ACODEC_TESTS=$(find_tests acodec)
1945 VCODEC_TESTS=$(find_tests vsynth1)
1946 LAVF_TESTS=$(find_tests lavf)
1947 LAVFI_TESTS=$(find_tests lavfi)
1948 SEEK_TESTS=$(find_tests seek seek_)
1949
1950 ALL_TESTS="$ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS"
1951
1952 pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
1953
1954 for n in $COMPONENT_LIST; do
1955     v=$(toupper ${n%s})_LIST
1956     eval enable \$$v
1957     eval ${n}_if_any="\$$v"
1958 done
1959
1960 enable $ARCH_EXT_LIST $ALL_TESTS
1961
1962 die_unknown(){
1963     echo "Unknown option \"$1\"."
1964     echo "See $0 --help for available options."
1965     exit 1
1966 }
1967
1968 show_list() {
1969     suffix=_$1
1970     shift
1971     echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1972     exit 0
1973 }
1974
1975 for opt do
1976     optval="${opt#*=}"
1977     case "$opt" in
1978     --extra-ldflags=*) add_ldflags $optval
1979     ;;
1980     --extra-libs=*) add_extralibs $optval
1981     ;;
1982     --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1983     ;;
1984     --enable-debug=*) debuglevel="$optval"
1985     ;;
1986     --disable-everything)
1987     map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1988     ;;
1989     --enable-*=*|--disable-*=*)
1990     eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1991     is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1992     eval list=\$$(toupper $thing)_LIST
1993     name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1994     $action $(filter "$name" $list)
1995     ;;
1996     --enable-?*|--disable-?*)
1997     eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1998     if is_in $option $COMPONENT_LIST; then
1999         test $action = disable && action=unset
2000         eval $action \$$(toupper ${option%s})_LIST
2001     elif is_in $option $CMDLINE_SELECT; then
2002         $action $option
2003     else
2004         die_unknown $opt
2005     fi
2006     ;;
2007     --list-*)
2008         NAME="${opt#--list-}"
2009         is_in $NAME $COMPONENT_LIST || die_unknown $opt
2010         NAME=${NAME%s}
2011         eval show_list $NAME \$$(toupper $NAME)_LIST
2012     ;;
2013     --help|-h) show_help
2014     ;;
2015     *)
2016     optname="${opt%%=*}"
2017     optname="${optname#--}"
2018     optname=$(echo "$optname" | sed 's/-/_/g')
2019     if is_in $optname $CMDLINE_SET; then
2020         eval $optname='$optval'
2021     elif is_in $optname $CMDLINE_APPEND; then
2022         append $optname "$optval"
2023     else
2024          die_unknown $opt
2025     fi
2026     ;;
2027     esac
2028 done
2029
2030 disabled logging && logfile=/dev/null
2031
2032 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
2033 set >> $logfile
2034
2035 test -n "$cross_prefix" && enable cross_compile
2036
2037 if enabled cross_compile; then
2038     test -n "$arch" && test -n "$target_os" ||
2039         die "Must specify target arch and OS when cross-compiling"
2040 fi
2041
2042 set_default arch target_os postproc_version
2043
2044 # Check if we should build alternative libpostproc version instead of current
2045 if   test "$postproc_version" = $ALT_PP_VER; then
2046   LIBPOSTPROC_VERSION=$ALT_PP_VER
2047   LIBPOSTPROC_VERSION_MAJOR=$ALT_PP_VER_MAJOR
2048   LIBPOSTPROC_VERSION_MINOR=$ALT_PP_VER_MINOR
2049   LIBPOSTPROC_VERSION_MICRO=$ALT_PP_VER_MICRO
2050 elif test "$postproc_version" != current; then
2051   die "Invalid argument to --postproc-version. See --help output."
2052 fi
2053
2054 ar_default="${cross_prefix}${ar_default}"
2055 cc_default="${cross_prefix}${cc_default}"
2056 cxx_default="${cross_prefix}${cxx_default}"
2057 nm_default="${cross_prefix}${nm_default}"
2058 pkg_config_default="${cross_prefix}${pkg_config_default}"
2059 ranlib="${cross_prefix}${ranlib}"
2060 strip_default="${cross_prefix}${strip_default}"
2061
2062 sysinclude_default="${sysroot}/usr/include"
2063
2064 set_default cc cxx nm pkg_config strip sysinclude yasmexe
2065 enabled cross_compile || host_cc_default=$cc
2066 set_default host_cc
2067
2068 if ! $pkg_config --version >/dev/null 2>&1; then
2069     warn "$pkg_config not found, library detection may fail."
2070     pkg_config=false
2071 fi
2072
2073 exesuf() {
2074     case $1 in
2075         mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
2076     esac
2077 }
2078
2079 EXESUF=$(exesuf $target_os)
2080 HOSTEXESUF=$(exesuf $host_os)
2081
2082 # set temporary file name
2083 : ${TMPDIR:=$TEMPDIR}
2084 : ${TMPDIR:=$TMP}
2085 : ${TMPDIR:=/tmp}
2086
2087 if ! check_cmd mktemp -u XXXXXX; then
2088     # simple replacement for missing mktemp
2089     # NOT SAFE FOR GENERAL USE
2090     mktemp(){
2091         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2092     }
2093 fi
2094
2095 tmpfile(){
2096     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2097         (set -C; exec > $tmp) 2>/dev/null ||
2098         die "Unable to create temporary file in $TMPDIR."
2099     append TMPFILES $tmp
2100     eval $1=$tmp
2101 }
2102
2103 trap 'rm -f -- $TMPFILES' EXIT
2104
2105 tmpfile TMPASM .asm
2106 tmpfile TMPC   .c
2107 tmpfile TMPCPP .cpp
2108 tmpfile TMPE   $EXESUF
2109 tmpfile TMPH   .h
2110 tmpfile TMPO   .o
2111 tmpfile TMPS   .S
2112 tmpfile TMPSH  .sh
2113 tmpfile TMPV   .ver
2114
2115 unset -f mktemp
2116
2117 chmod +x $TMPE
2118
2119 # make sure we can execute files in $TMPDIR
2120 cat > $TMPSH 2>> $logfile <<EOF
2121 #! /bin/sh
2122 EOF
2123 chmod +x $TMPSH >> $logfile 2>&1
2124 if ! $TMPSH >> $logfile 2>&1; then
2125     cat <<EOF
2126 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
2127 variable to another directory and make sure that it is not mounted noexec.
2128 EOF
2129     die "Sanity test failed."
2130 fi
2131
2132 filter_asflags=echo
2133 filter_cflags=echo
2134 filter_cppflags=echo
2135
2136 if   $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
2137     cc_type=llvm_gcc
2138     cc_version=__VERSION__
2139     gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
2140     cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
2141     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2142     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2143     speed_cflags='-O3'
2144     size_cflags='-Os'
2145 elif $cc -v 2>&1 | grep -qi ^gcc; then
2146     cc_type=gcc
2147     cc_version=__VERSION__
2148     gcc_version=$($cc --version | head -n1)
2149     gcc_basever=$($cc -dumpversion)
2150     gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
2151     gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
2152     cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
2153     if ! $cc -dumpversion | grep -q '^2\.'; then
2154         CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2155         AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2156     fi
2157     speed_cflags='-O3'
2158     size_cflags='-Os'
2159 elif $cc --version 2>/dev/null | grep -q Intel; then
2160     cc_type=icc
2161     cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
2162     cc_ident=$($cc --version | head -n1)
2163     icc_version=$($cc -dumpversion)
2164     CC_DEPFLAGS='-MMD'
2165     AS_DEPFLAGS='-MMD'
2166     speed_cflags='-O3'
2167     size_cflags='-Os'
2168     noopt_cflags='-O1'
2169 elif $cc -v 2>&1 | grep -q xlc; then
2170     cc_type=xlc
2171     cc_version="AV_STRINGIFY(__IBMC__)"
2172     cc_ident=$($cc -qversion 2>/dev/null | head -n1)
2173     speed_cflags='-O5'
2174     size_cflags='-O5 -qcompact'
2175 elif $cc -V 2>/dev/null | grep -q Compaq; then
2176     cc_type=ccc
2177     cc_version="AV_STRINGIFY(__DECC_VER)"
2178     cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
2179     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
2180     debuglevel=3
2181     add_ldflags -Wl,-z,now # calls to libots crash without this
2182     speed_cflags='-fast'
2183     size_cflags='-O1'
2184 elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
2185     test -d "$sysroot" || die "No valid sysroot specified."
2186     cc_type=armcc
2187     cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
2188     cc_ident=$($cc --vsn | head -n1)
2189     armcc_conf="$PWD/armcc.conf"
2190     $cc --arm_linux_configure                 \
2191         --arm_linux_config_file="$armcc_conf" \
2192         --configure_sysroot="$sysroot"        \
2193         --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2194         die "Error creating armcc configuration file."
2195     $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
2196     cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
2197     as_default="${cross_prefix}gcc"
2198     CC_DEPFLAGS='-MMD'
2199     AS_DEPFLAGS='-MMD'
2200     speed_cflags='-O3'
2201     size_cflags='-Os'
2202     filter_asflags="filter_out -W${armcc_opt}*"
2203 elif $cc -version 2>/dev/null | grep -q TMS470; then
2204     cc_type=tms470
2205     cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
2206     cc_ident=$($cc -version | head -n1 | tr -s ' ')
2207     cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
2208     CC_O='-fr=$(@D)'
2209     as_default="${cross_prefix}gcc"
2210     ld_default="${cross_prefix}gcc"
2211     TMPO=$(basename $TMPC .c).o
2212     append TMPFILES $TMPO
2213     add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
2214     CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
2215     AS_DEPFLAGS='-MMD'
2216     speed_cflags='-O3 -mf=5'
2217     size_cflags='-O3 -mf=2'
2218     filter_cflags=tms470_flags
2219     tms470_flags(){
2220         for flag; do
2221             case $flag in
2222                 -march=*|-mcpu=*)
2223                     case "${flag#*=}" in
2224                         armv7-a|cortex-a*)      echo -mv=7a8 ;;
2225                         armv7-r|cortex-r*)      echo -mv=7r4 ;;
2226                         armv7-m|cortex-m*)      echo -mv=7m3 ;;
2227                         armv6*|arm11*)          echo -mv=6   ;;
2228                         armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2229                                                 echo -mv=5e  ;;
2230                         armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
2231                     esac
2232                     ;;
2233                 -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
2234                 -mfpu=vfp)      echo --float_support=vfpv2        ;;
2235                 -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
2236                 -msoft-float)   echo --float_support=vfplib       ;;
2237                 -O[0-3]|-mf=*)  echo $flag                        ;;
2238                 -g)             echo -g -mn                       ;;
2239                 -pds=*)         echo $flag                        ;;
2240             esac
2241         done
2242     }
2243 elif $cc -v 2>&1 | grep -q clang; then
2244     cc_type=clang
2245     $cc -dM -E $TMPC | grep -q __clang_version__ &&
2246         cc_version=__clang_version__ || cc_version=__VERSION__
2247     cc_ident=$($cc --version | head -n1)
2248     CC_DEPFLAGS='-MMD'
2249     AS_DEPFLAGS='-MMD'
2250     speed_cflags='-O3'
2251     size_cflags='-Os'
2252 elif $cc -V 2>&1 | grep -q Sun; then
2253     cc_type=suncc
2254     cc_version="AV_STRINGIFY(__SUNPRO_C)"
2255     cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2256     DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2257     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
2258     add_ldflags -xc99
2259     speed_cflags='-O5'
2260     size_cflags='-O5 -xspace'
2261     filter_cflags=suncc_flags
2262     suncc_flags(){
2263         for flag; do
2264             case $flag in
2265                 -march=*|-mcpu=*)
2266                     case "${flag#*=}" in
2267                         native)                   echo -xtarget=native       ;;
2268                         v9|niagara)               echo -xarch=sparc          ;;
2269                         ultrasparc)               echo -xarch=sparcvis       ;;
2270                         ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
2271                         i586|pentium)             echo -xchip=pentium        ;;
2272                         i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
2273                         pentium3*|c3-2)           echo -xtarget=pentium3     ;;
2274                         pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
2275                         pentium4*)          echo -xtarget=pentium4           ;;
2276                         prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2277                         *-sse3)             echo -xarch=sse3                 ;;
2278                         core2)              echo -xarch=ssse3 -xchip=core2   ;;
2279                         amdfam10|barcelona)       echo -xarch=sse4_1         ;;
2280                         athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
2281                         k8|opteron|athlon64|athlon-fx)
2282                                                   echo -xarch=sse2a          ;;
2283                         athlon*)                  echo -xarch=pentium_proa   ;;
2284                     esac
2285                     ;;
2286                 -std=c99)             echo -xc99              ;;
2287                 -fomit-frame-pointer) echo -xregs=frameptr    ;;
2288                 -fPIC)                echo -KPIC -xcode=pic32 ;;
2289                 -W*,*)                echo $flag              ;;
2290                 -f*-*|-W*)                                    ;;
2291                 *)                    echo $flag              ;;
2292             esac
2293         done
2294     }
2295 elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2296     cc_type=pathscale
2297     cc_version=__PATHSCALE__
2298     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2299     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2300     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2301     speed_cflags='-O2'
2302     size_cflags='-Os'
2303     filter_cflags='filter_out -Wdisabled-optimization'
2304 elif $cc -v 2>&1 | grep -q Open64; then
2305     cc_type=open64
2306     cc_version=__OPEN64__
2307     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2308     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2309     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2310     speed_cflags='-O2'
2311     size_cflags='-Os'
2312     filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
2313 fi
2314
2315 test -n "$cc_type" && enable $cc_type ||
2316     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2317
2318 : ${as_default:=$cc}
2319 : ${dep_cc_default:=$cc}
2320 : ${ld_default:=$cc}
2321 set_default ar as dep_cc ld
2322
2323 test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2324 test -n "$CXX_DEPFLAGS" || CXXDEP=$DEPEND_CMD
2325 test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2326
2327 add_cflags $extra_cflags
2328 add_cxxflags $extra_cxxflags
2329 add_asflags $extra_cflags
2330
2331 if test -n "$sysroot"; then
2332     case "$cc_type" in
2333         gcc|llvm_gcc|clang)
2334             add_cppflags --sysroot="$sysroot"
2335             add_ldflags --sysroot="$sysroot"
2336         ;;
2337         tms470)
2338             add_cppflags -I"$sysinclude"
2339             add_ldflags  --sysroot="$sysroot"
2340         ;;
2341     esac
2342 fi
2343
2344 if test "$cpu" = host; then
2345     enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2346
2347     case "$cc_type" in
2348         gcc|llvm_gcc)
2349             check_native(){
2350                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
2351                 sed -n "/cc1.*$1=/{
2352                             s/.*$1=\\([^ ]*\\).*/\\1/
2353                             p
2354                             q
2355                         }" $TMPE
2356             }
2357             cpu=$(check_native -march || check_native -mcpu)
2358         ;;
2359     esac
2360
2361     test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2362 fi
2363
2364 # Deal with common $arch aliases
2365 case "$arch" in
2366     arm*|iPad*)
2367         arch="arm"
2368     ;;
2369     mips|mipsel|IP*)
2370         arch="mips"
2371     ;;
2372     mips64*)
2373         arch="mips"
2374         subarch="mips64"
2375     ;;
2376     parisc|hppa)
2377         arch="parisc"
2378     ;;
2379     parisc64|hppa64)
2380         arch="parisc"
2381         subarch="parisc64"
2382     ;;
2383     "Power Macintosh"|ppc|powerpc|ppc64|powerpc64)
2384         arch="ppc"
2385     ;;
2386     s390|s390x)
2387         arch="s390"
2388     ;;
2389     sh4|sh)
2390         arch="sh4"
2391     ;;
2392     sun4u|sparc64)
2393         arch="sparc"
2394         subarch="sparc64"
2395     ;;
2396     i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
2397         arch="x86"
2398     ;;
2399 esac
2400
2401 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2402 enable $arch
2403
2404 # Add processor-specific flags
2405 if test "$cpu" = generic; then
2406     : do nothing
2407 elif enabled ppc; then
2408
2409     case $(tolower $cpu) in
2410         601|ppc601|powerpc601)
2411             cpuflags="-mcpu=601"
2412             disable altivec
2413         ;;
2414         603*|ppc603*|powerpc603*)
2415             cpuflags="-mcpu=603"
2416             disable altivec
2417         ;;
2418         604*|ppc604*|powerpc604*)
2419             cpuflags="-mcpu=604"
2420             disable altivec
2421         ;;
2422         g3|75*|ppc75*|powerpc75*)
2423             cpuflags="-mcpu=750 -mpowerpc-gfxopt"
2424             disable altivec
2425         ;;
2426         g4|745*|ppc745*|powerpc745*)
2427             cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
2428         ;;
2429         74*|ppc74*|powerpc74*)
2430             cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
2431         ;;
2432         g5|970|ppc970|powerpc970|power4*)
2433             cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
2434         ;;
2435         cell)
2436             cpuflags="-mcpu=cell"
2437             enable ldbrx
2438         ;;
2439         e500v2)
2440             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
2441             disable altivec
2442         ;;
2443         e500)
2444             cpuflags="-mcpu=8540 -mhard-float"
2445             disable altivec
2446         ;;
2447     esac
2448
2449 elif enabled x86; then
2450
2451     case $cpu in
2452         i[345]86|pentium)
2453             cpuflags="-march=$cpu"
2454             disable mmx
2455         ;;
2456         # targets that do NOT support conditional mov (cmov)
2457         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2458             cpuflags="-march=$cpu"
2459             disable cmov
2460         ;;
2461         # targets that do support conditional mov (cmov)
2462         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
2463             cpuflags="-march=$cpu"
2464             enable cmov
2465             enable fast_cmov
2466         ;;
2467         # targets that do support conditional mov but on which it's slow
2468         pentium4|pentium4m|prescott|nocona)
2469             cpuflags="-march=$cpu"
2470             enable cmov
2471             disable fast_cmov
2472         ;;
2473     esac
2474
2475 elif enabled sparc; then
2476
2477     case $cpu in
2478         niagara)
2479             cpuflags="-mcpu=$cpu"
2480             disable vis
2481         ;;
2482         sparc64)
2483             cpuflags="-mcpu=v9"
2484         ;;
2485     esac
2486
2487 elif enabled arm; then
2488
2489     case $cpu in
2490         armv*)
2491             cpuflags="-march=$cpu"
2492             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
2493         ;;
2494         *)
2495             cpuflags="-mcpu=$cpu"
2496             case $cpu in
2497                 cortex-a*)                               subarch=armv7a  ;;
2498                 cortex-r*)                               subarch=armv7r  ;;
2499                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
2500                 arm11*)                                  subarch=armv6   ;;
2501                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
2502                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
2503             esac
2504         ;;
2505     esac
2506
2507 elif enabled alpha; then
2508
2509     enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2510
2511 elif enabled bfin; then
2512
2513     cpuflags="-mcpu=$cpu"
2514
2515 elif enabled mips; then
2516
2517     cpuflags="-march=$cpu"
2518
2519 elif enabled avr32; then
2520
2521     case $cpu in
2522         ap7[02]0[0-2])
2523             subarch="avr32_ap"
2524             cpuflags="-mpart=$cpu"
2525         ;;
2526         ap)
2527             subarch="avr32_ap"
2528             cpuflags="-march=$cpu"
2529         ;;
2530         uc3[ab]*)
2531             subarch="avr32_uc"
2532             cpuflags="-mcpu=$cpu"
2533         ;;
2534         uc)
2535             subarch="avr32_uc"
2536             cpuflags="-march=$cpu"
2537         ;;
2538     esac
2539
2540 fi
2541
2542 add_cflags $cpuflags
2543 add_asflags $cpuflags
2544
2545 # compiler sanity check
2546 check_exec <<EOF
2547 int main(void){ return 0; }
2548 EOF
2549 if test "$?" != 0; then
2550     echo "$cc is unable to create an executable file."
2551     if test -z "$cross_prefix" && ! enabled cross_compile ; then
2552         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2553         echo "Only do this if you know what cross compiling means."
2554     fi
2555     die "C compiler test failed."
2556 fi
2557
2558 add_cppflags -D_ISOC99_SOURCE
2559 add_cxxflags -D__STDC_CONSTANT_MACROS
2560 check_cflags -std=c99
2561 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2562 #include <stdlib.h>
2563 EOF
2564 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2565 #include <stdlib.h>
2566 EOF
2567
2568 check_host_cflags -std=c99
2569 check_host_cflags -Wall
2570
2571 case "$arch" in
2572     alpha|ia64|mips|parisc|ppc|sparc)
2573         spic=$shared
2574     ;;
2575     x86)
2576         subarch="x86_32"
2577         check_cc <<EOF && subarch="x86_64"
2578         int test[(int)sizeof(char*) - 7];
2579 EOF
2580         if test "$subarch" = "x86_64"; then
2581             spic=$shared
2582         fi
2583     ;;
2584     ppc)
2585         check_cc <<EOF && subarch="ppc64"
2586         int test[(int)sizeof(char*) - 7];
2587 EOF
2588     ;;
2589 esac
2590
2591 enable $subarch
2592 enabled spic && enable pic
2593
2594 # OS specific
2595 case $target_os in
2596     haiku)
2597         prefix_default="/boot/common"
2598         network_extralibs="-lnetwork"
2599         host_libs=
2600         ;;
2601     sunos)
2602         FFSERVERLDFLAGS=""
2603         SHFLAGS='-shared -Wl,-h,$$(@F)'
2604         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2605         network_extralibs="-lsocket -lnsl"
2606         add_cppflags -D__EXTENSIONS__
2607         # When using suncc to build, the Solaris linker will mark
2608         # an executable with each instruction set encountered by
2609         # the Solaris assembler.  As our libraries contain their own
2610         # guards for processor-specific code, instead suppress
2611         # generation of the HWCAPS ELF section on Solaris x86 only.
2612         enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
2613         nm_opts='-P -g'
2614         ;;
2615     netbsd)
2616         disable symver
2617         oss_indev_extralibs="-lossaudio"
2618         oss_outdev_extralibs="-lossaudio"
2619         ;;
2620     openbsd)
2621         enable malloc_aligned
2622         # On OpenBSD 4.5. the compiler does not use PIC unless
2623         # explicitly using -fPIC. FFmpeg builds fine without PIC,
2624         # however the generated executable will not do anything
2625         # (simply quits with exit-code 1, no crash, no output).
2626         # Thus explicitly enable PIC here.
2627         enable pic
2628         disable symver
2629         SHFLAGS='-shared'
2630         oss_indev_extralibs="-lossaudio"
2631         oss_outdev_extralibs="-lossaudio"
2632         ;;
2633     dragonfly)
2634         enable malloc_aligned
2635         disable symver
2636         ;;
2637     freebsd)
2638         enable malloc_aligned
2639         ;;
2640     bsd/os)
2641         add_extralibs -lpoll -lgnugetopt
2642         strip="strip -d"
2643         ;;
2644     darwin)
2645         enable malloc_aligned
2646         gas="gas-preprocessor.pl $cc"
2647         enabled ppc && add_asflags -force_cpusubtype_ALL
2648         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
2649         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
2650         strip="${strip} -x"
2651         add_ldflags -Wl,-dynamic,-search_paths_first
2652         SLIBSUF=".dylib"
2653         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2654         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2655         FFSERVERLDFLAGS=-Wl,-bind_at_load
2656         objformat="macho"
2657         enabled x86_64 && objformat="macho64"
2658         enabled_any pic shared ||
2659             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2660         ;;
2661     mingw32*)
2662         if test $target_os = "mingw32ce"; then
2663             disable network
2664         else
2665             target_os=mingw32
2666         fi
2667         LIBTARGET=i386
2668         if enabled x86_64; then
2669             enable malloc_aligned
2670             LIBTARGET=x64
2671         elif enabled arm; then
2672             LIBTARGET=arm-wince
2673         fi
2674         shlibdir_default="$bindir_default"
2675         SLIBPREF=""
2676         SLIBSUF=".dll"
2677         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2678         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2679         SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
2680         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
2681         SLIB_INSTALL_LINKS=
2682         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
2683         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
2684         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
2685         objformat="win32"
2686         enable dos_paths
2687         check_cflags -fno-common
2688         check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
2689                                       || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2690                 die "ERROR: MinGW runtime version must be >= 3.15."
2691         add_cppflags -U__STRICT_ANSI__
2692         ;;
2693     cygwin*)
2694         target_os=cygwin
2695         shlibdir_default="$bindir_default"
2696         SLIBPREF="cyg"
2697         SLIBSUF=".dll"
2698         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2699         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2700         SHFLAGS='-shared -Wl,--enable-auto-image-base'
2701         objformat="win32"
2702         enable dos_paths
2703         check_cflags -fno-common
2704         add_cppflags -U__STRICT_ANSI__
2705         ;;
2706     *-dos|freedos|opendos)
2707         network_extralibs="-lsocket"
2708         objformat="coff"
2709         enable dos_paths
2710         add_cppflags -U__STRICT_ANSI__
2711         ;;
2712     linux)
2713         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
2714         enable dv1394
2715         ;;
2716     irix*)
2717         target_os=irix
2718         ranlib="echo ignoring ranlib"
2719         ;;
2720     os/2*)
2721         strip="lxlite -CS"
2722         ln_s="cp -f"
2723         objformat="aout"
2724         add_cppflags -D_GNU_SOURCE
2725         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
2726         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2727         FFSERVERLDFLAGS=""
2728         LIBSUF="_s.a"
2729         SLIBPREF=""
2730         SLIBSUF=".dll"
2731         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2732         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2733         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2734           echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2735           echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2736           echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2737           echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2738           emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2739         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2740           emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2741         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
2742         enable dos_paths
2743         enable_weak os2threads
2744         ;;
2745     gnu/kfreebsd)
2746         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
2747         ;;
2748     gnu)
2749         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
2750         ;;
2751     qnx)
2752         add_cppflags -D_QNX_SOURCE
2753         network_extralibs="-lsocket"
2754         ;;
2755     symbian)
2756         SLIBSUF=".dll"
2757         enable dos_paths
2758         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
2759         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
2760         add_ldflags -Wl,--target1-abs,--no-undefined \
2761                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
2762                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
2763         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
2764                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
2765                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
2766         ;;
2767     none)
2768         ;;
2769     *)
2770         die "Unknown OS '$target_os'."
2771         ;;
2772 esac
2773
2774 echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
2775
2776 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2777
2778 set_default $PATHS_LIST
2779
2780 # we need to build at least one lib type
2781 if ! enabled_any static shared; then
2782     cat <<EOF
2783 At least one library type must be built.
2784 Specify --enable-static to build the static libraries or --enable-shared to
2785 build the shared libraries as well. To only build the shared libraries specify
2786 --disable-static in addition to --enable-shared.
2787 EOF
2788     exit 1;
2789 fi
2790
2791 die_license_disabled() {
2792     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2793 }
2794
2795 die_license_disabled gpl libcdio
2796 die_license_disabled gpl libx264
2797 die_license_disabled gpl libxavs
2798 die_license_disabled gpl libxvid
2799 die_license_disabled gpl x11grab
2800
2801 die_license_disabled nonfree libaacplus
2802 die_license_disabled nonfree libfaac
2803 die_license_disabled nonfree openssl
2804
2805 die_license_disabled version3 libopencore_amrnb
2806 die_license_disabled version3 libopencore_amrwb
2807 die_license_disabled version3 libvo_aacenc
2808 die_license_disabled version3 libvo_amrwbenc
2809
2810 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2811
2812 disabled optimizations || check_cflags -fomit-frame-pointer
2813
2814 enable_pic() {
2815     enable pic
2816     add_cppflags -DPIC
2817     add_cflags   -fPIC
2818     add_asflags  -fPIC
2819 }
2820
2821 enabled pic && enable_pic
2822
2823 check_cc <<EOF || die "Symbol mangling check failed."
2824 int ff_extern;
2825 EOF
2826 sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2827 extern_prefix=${sym%%ff_extern*}
2828
2829 check_cc <<EOF && enable inline_asm
2830 void foo(void) { __asm__ volatile ("" ::); }
2831 EOF
2832
2833 _restrict=
2834 for restrict_keyword in restrict __restrict__ __restrict; do
2835     check_cc <<EOF && _restrict=$restrict_keyword && break
2836 void foo(char * $restrict_keyword p);
2837 EOF
2838 done
2839
2840 check_cc <<EOF && enable attribute_packed
2841 struct { int x; } __attribute__((packed)) x;
2842 EOF
2843
2844 check_cc <<EOF && enable attribute_may_alias
2845 union { int x; } __attribute__((may_alias)) x;
2846 EOF
2847
2848 check_cc <<EOF || die "endian test failed"
2849 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2850 EOF
2851 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2852
2853 if enabled alpha; then
2854
2855     check_cflags -mieee
2856
2857 elif enabled arm; then
2858
2859     enabled thumb && check_cflags -mthumb || check_cflags -marm
2860     nogas=die
2861
2862     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
2863         enable vfp_args
2864     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
2865         case "${cross_prefix:-$cc}" in
2866             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
2867             *) check_ld "cc" <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
2868 __asm__ (".eabi_attribute 28, 1");
2869 int main(void) { return 0; }
2870 EOF
2871         esac
2872         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
2873     fi
2874
2875     enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2876     enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2877     enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2878     enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2879     enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2880     enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2881     enabled vfpv3   && check_asm vfpv3   '"vmov.f32 s0, #1.0"'
2882
2883     check_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
2884
2885     enabled_all armv6t2 shared !pic && enable_pic
2886
2887 elif enabled mips; then
2888
2889     check_asm loongson '"dmult.g $1, $2, $3"'
2890     enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2891
2892 elif enabled ppc; then
2893
2894     enable local_aligned_8 local_aligned_16
2895
2896     check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
2897     check_asm ibm_asm   '"add 0, 0, 0"'
2898     check_asm ppc4xx    '"maclhw r10, r11, r12"'
2899     check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2900
2901     # AltiVec flags: The FSF version of GCC differs from the Apple version
2902     if enabled altivec; then
2903         nogas=warn
2904         check_cflags -maltivec -mabi=altivec &&
2905         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2906         check_cflags -faltivec
2907
2908         # check if our compiler supports Motorola AltiVec C API
2909         check_cc <<EOF || disable altivec
2910 $inc_altivec_h
2911 int main(void) {
2912     vector signed int v1 = (vector signed int) { 0 };
2913     vector signed int v2 = (vector signed int) { 1 };
2914     v1 = vec_add(v1, v2);
2915     return 0;
2916 }
2917 EOF
2918
2919         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
2920     fi
2921
2922 elif enabled sparc; then
2923
2924     enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2925         add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2926
2927 elif enabled x86; then
2928
2929     enable local_aligned_8 local_aligned_16
2930
2931     # check whether EBP is available on x86
2932     # As 'i' is stored on the stack, this program will crash
2933     # if the base pointer is used to access it because the
2934     # base pointer is cleared in the inline assembly code.
2935     check_exec_crash <<EOF && enable ebp_available
2936     volatile int i=0;
2937     __asm__ volatile (
2938         "xorl %%ebp, %%ebp"
2939     ::: "%ebp");
2940     return i;
2941 EOF
2942
2943     # check whether EBX is available on x86
2944     check_asm ebx_available '""::"b"(0)' &&
2945         check_asm ebx_available '"":::"%ebx"'
2946
2947     # check whether xmm clobbers are supported
2948     check_asm xmm_clobbers '"":::"%xmm0"'
2949
2950     # check whether binutils is new enough to compile SSSE3/MMX2
2951     enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2952     enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2953
2954     if ! disabled_any asm mmx yasm; then
2955         if check_cmd $yasmexe --version; then
2956             enabled x86_64 && yasm_extra="-m amd64"
2957             yasm_debug="-g dwarf2"
2958         elif check_cmd nasm -v; then
2959             yasmexe=nasm
2960             yasm_debug="-g -F dwarf"
2961             enabled x86_64 && test "$objformat" = elf && objformat=elf64
2962         fi
2963
2964         YASMFLAGS="-f $objformat $yasm_extra"
2965         enabled pic               && append YASMFLAGS "-DPIC"
2966         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2967         case "$objformat" in
2968             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
2969         esac
2970
2971         check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
2972             die "yasm not found, use --disable-yasm for a crippled build"
2973         check_yasm "vextractf128 xmm0, ymm0, 0" || disable avx
2974     fi
2975
2976     case "$cpu" in
2977         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2978             disable fast_clz
2979         ;;
2980     esac
2981
2982 fi
2983
2984 if enabled asm; then
2985     as=${gas:=$as}
2986     check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
2987         $nogas "GNU assembler not found, install gas-preprocessor"
2988 fi
2989
2990 check_ldflags -Wl,--as-needed
2991
2992 if check_func dlopen; then
2993     ldl=
2994 elif check_func dlopen -ldl; then
2995     ldl=-ldl
2996 fi
2997
2998 if enabled network; then
2999     check_type "sys/types.h sys/socket.h" socklen_t
3000     check_type netdb.h "struct addrinfo"
3001     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
3002     check_type netinet/in.h "struct sockaddr_in6"
3003     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
3004     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
3005     # Prefer arpa/inet.h over winsock2
3006     if check_header arpa/inet.h ; then
3007         check_func closesocket
3008     elif check_header winsock2.h ; then
3009         check_func_headers winsock2.h closesocket -lws2 && \
3010             network_extralibs="-lws2" || \
3011         { check_func_headers winsock2.h closesocket -lws2_32 && \
3012             network_extralibs="-lws2_32"; }
3013         check_type ws2tcpip.h socklen_t
3014         check_type ws2tcpip.h "struct addrinfo"
3015         check_type ws2tcpip.h "struct ipv6_mreq"
3016         check_type ws2tcpip.h "struct sockaddr_in6"
3017         check_type ws2tcpip.h "struct sockaddr_storage"
3018         check_struct winsock2.h "struct sockaddr" sa_len
3019     else
3020         disable network
3021     fi
3022 fi
3023
3024 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
3025 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
3026
3027 check_func  fcntl
3028 check_func  fork
3029 check_func  getaddrinfo $network_extralibs
3030 check_func  gethrtime
3031 check_func  getrusage
3032 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
3033 check_func  inet_aton $network_extralibs
3034 check_func  isatty
3035 check_func  localtime_r
3036 check_func  ${malloc_prefix}memalign            && enable memalign
3037 check_func  mkstemp
3038 check_func  mmap
3039 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
3040 check_func  setrlimit
3041 check_func  strerror_r
3042 check_func  strptime
3043 check_func  sched_getaffinity
3044 check_func  sysconf
3045 check_func  sysctl
3046 check_func_headers conio.h kbhit
3047 check_func_headers windows.h PeekNamedPipe
3048 check_func_headers io.h setmode
3049 check_func_headers lzo/lzo1x.h lzo1x_999_compress
3050 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
3051 check_func_headers windows.h GetProcessAffinityMask
3052 check_func_headers windows.h GetProcessTimes
3053 check_func_headers windows.h MapViewOfFile
3054 check_func_headers windows.h VirtualAlloc
3055
3056 check_header dlfcn.h
3057 check_header dxva.h
3058 check_header dxva2api.h -D_WIN32_WINNT=0x0600
3059 check_header libcrystalhd/libcrystalhd_if.h
3060 check_header malloc.h
3061 check_header poll.h
3062 check_header sys/mman.h
3063 check_header sys/param.h
3064 check_header sys/resource.h
3065 check_header sys/select.h
3066 check_header termios.h
3067 check_header vdpau/vdpau.h
3068 check_header vdpau/vdpau_x11.h
3069 check_header X11/extensions/XvMClib.h
3070 check_header asm/types.h
3071
3072 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
3073 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
3074
3075 # check for VDA header
3076 if ! disabled vda; then
3077     if check_header VideoDecodeAcceleration/VDADecoder.h; then
3078         enable vda
3079         add_extralibs -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
3080     fi
3081 fi
3082
3083 if ! disabled w32threads && ! enabled pthreads; then
3084     check_func _beginthreadex && enable w32threads
3085 fi
3086
3087 # check for some common methods of building with pthread support
3088 # do this before the optional library checks as some of them require pthreads
3089 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
3090     enable pthreads
3091     if check_func pthread_create; then
3092         :
3093     elif check_func pthread_create -pthread; then
3094         add_cflags -pthread
3095         add_extralibs -pthread
3096     elif check_func pthread_create -pthreads; then
3097         add_cflags -pthreads
3098         add_extralibs -pthreads
3099     elif check_func pthread_create -lpthreadGC2; then
3100         add_extralibs -lpthreadGC2
3101     elif ! check_lib pthread.h pthread_create -lpthread; then
3102         disable pthreads
3103     fi
3104 fi
3105
3106 for thread in $THREADS_LIST; do
3107     if enabled $thread; then
3108         test -n "$thread_type" &&
3109             die "ERROR: Only one thread type must be selected." ||
3110             thread_type="$thread"
3111     fi
3112 done
3113
3114 check_lib math.h sin -lm && LIBM="-lm"
3115 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
3116 enabled vaapi && require vaapi va/va.h vaInitialize -lva
3117
3118 check_mathfunc cbrtf
3119 check_mathfunc exp2
3120 check_mathfunc exp2f
3121 check_mathfunc llrint
3122 check_mathfunc llrintf
3123 check_mathfunc log2
3124 check_mathfunc log2f
3125 check_mathfunc lrint
3126 check_mathfunc lrintf
3127 check_mathfunc round
3128 check_mathfunc roundf
3129 check_mathfunc trunc
3130 check_mathfunc truncf
3131
3132 # these are off by default, so fail if requested and not available
3133 enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
3134 enabled frei0r     && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
3135 enabled gnutls     && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
3136 enabled libaacplus && require  "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
3137 enabled libass     && require_pkg_config libass ass/ass.h ass_library_init
3138 enabled libcelt    && require libcelt celt/celt.h celt_decode -lcelt0 &&
3139                       { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
3140                         die "ERROR: libcelt version must be >= 0.11.0."; }
3141 enabled libdc1394  && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new
3142 enabled libdirac   && require_pkg_config dirac                          \
3143     "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h"  \
3144     "dirac_decoder_init dirac_encoder_init"
3145 enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
3146 enabled libfreetype && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
3147 enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
3148 enabled libmodplug && require  libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
3149 enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
3150 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
3151 enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
3152 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
3153 enabled libopencv  && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
3154 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
3155 enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
3156 enabled librtmp    && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
3157 enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
3158 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
3159 enabled libstagefright_h264  && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
3160     media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
3161     media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder
3162 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
3163 enabled libutvideo    && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
3164 enabled libv4l2    && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl
3165 enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
3166 enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
3167 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
3168 enabled libvpx     && {
3169     enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
3170                                 die "ERROR: libvpx decoder version must be >=0.9.1"; }
3171     enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
3172                                 die "ERROR: libvpx encoder version must be >=0.9.6"; } }
3173 enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 &&
3174                       { check_cpp_condition x264.h "X264_BUILD >= 118" ||
3175                         die "ERROR: libx264 version must be >= 0.118."; }
3176 enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
3177 enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
3178 enabled openal     && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
3179                         check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
3180                         die "ERROR: openal not found"; } &&
3181                       { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
3182                         die "ERROR: openal version must be 1.1 or compatible"; }
3183 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
3184 enabled openssl    && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
3185                         check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
3186                         check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
3187                         die "ERROR: openssl not found"; }
3188
3189 SDL_CONFIG="${cross_prefix}sdl-config"
3190 if check_pkg_config sdl SDL_version.h SDL_Linked_Version; then
3191     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
3192     enable sdl &&
3193     check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
3194 else
3195   if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
3196     sdl_cflags=$("${SDL_CONFIG}" --cflags)
3197     sdl_libs=$("${SDL_CONFIG}" --libs)
3198     check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
3199     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
3200     enable sdl &&
3201     check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
3202   fi
3203 fi
3204 enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
3205
3206 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
3207 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
3208
3209 check_header linux/fb.h
3210 check_header linux/videodev.h
3211 check_header linux/videodev2.h
3212 check_cc <<EOF && enable_safe struct_v4l2_frmivalenum_discrete
3213 #include <linux/videodev2.h>
3214 int main(void) {
3215 struct v4l2_frmsizeenum vfse;
3216 vfse.discrete.width = 0;
3217 return 0;
3218 }
3219 EOF
3220
3221 check_header sys/videoio.h
3222
3223 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
3224 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
3225 # w32api 3.12 had it defined wrong
3226 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
3227
3228 check_type "dshow.h" IBaseFilter
3229
3230 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
3231 { check_header dev/bktr/ioctl_meteor.h &&
3232   check_header dev/bktr/ioctl_bt848.h; } ||
3233 { check_header machine/ioctl_meteor.h &&
3234   check_header machine/ioctl_bt848.h; } ||
3235 { check_header dev/video/meteor/ioctl_meteor.h &&
3236   check_header dev/video/bktr/ioctl_bt848.h; } ||
3237 check_header dev/ic/bt8xx.h
3238
3239 check_header sndio.h
3240 if check_struct sys/soundcard.h audio_buf_info bytes; then
3241     enable_safe sys/soundcard.h
3242 else
3243     check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h
3244     #include <sys/soundcard.h>
3245     audio_buf_info abc;
3246 EOF
3247 fi
3248 check_header soundcard.h
3249
3250 enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
3251
3252 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func sem_timedwait
3253
3254 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
3255
3256 enabled libcdio &&
3257     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio"
3258
3259 enabled x11grab                         &&
3260 check_header X11/Xlib.h                 &&
3261 check_header X11/extensions/XShm.h      &&
3262 check_header X11/extensions/Xfixes.h    &&
3263 check_func XOpenDisplay -lX11           &&
3264 check_func XShmCreateImage -lX11 -lXext &&
3265 check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
3266
3267 if ! disabled vaapi; then
3268     check_lib va/va.h vaInitialize -lva && {
3269         check_cpp_condition va/va_version.h "VA_CHECK_VERSION(0,32,0)" ||
3270         warn "Please upgrade to VA-API >= 0.32 if you would like full VA-API support.";
3271     } || disable vaapi
3272 fi
3273
3274 if ! disabled vdpau && enabled vdpau_vdpau_h; then
3275 check_cpp_condition \
3276     vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
3277     { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
3278       disable vdpau; }
3279 fi
3280
3281 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
3282 enabled coverage && add_cflags "-fprofile-arcs -ftest-coverage" && add_ldflags "-fprofile-arcs -ftest-coverage"
3283 test -n "$valgrind" && target_exec="$valgrind --error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp"
3284
3285 # add some useful compiler flags if supported
3286 check_cflags -Wdeclaration-after-statement
3287 check_cflags -Wall
3288 check_cflags -Wno-parentheses
3289 check_cflags -Wno-switch
3290 check_cflags -Wno-format-zero-length
3291 check_cflags -Wdisabled-optimization
3292 check_cflags -Wpointer-arith
3293 check_cflags -Wredundant-decls
3294 check_cflags -Wno-pointer-sign
3295 check_cflags -Wcast-qual
3296 check_cflags -Wwrite-strings
3297 check_cflags -Wtype-limits
3298 check_cflags -Wundef
3299 check_cflags -Wmissing-prototypes
3300 check_cflags -Wno-pointer-to-int-cast
3301 check_cflags -Wstrict-prototypes
3302 enabled extra_warnings && check_cflags -Winline
3303
3304 # add some linker flags
3305 check_ldflags -Wl,--warn-common
3306 check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
3307 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
3308
3309 echo "X{};" > $TMPV
3310 if test_ldflags -Wl,--version-script,$TMPV; then
3311     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
3312     check_cc <<EOF && enable symver_asm_label
3313 void ff_foo(void) __asm__ ("av_foo@VERSION");
3314 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
3315 EOF
3316     check_cc <<EOF && enable symver_gnu_asm
3317 __asm__(".symver ff_foo,av_foo@VERSION");
3318 void ff_foo(void) {}
3319 EOF
3320 fi
3321
3322 if [ -n "$optflags" ]; then
3323     add_cflags $optflags
3324 elif enabled small; then
3325     add_cflags $size_cflags
3326 elif enabled optimizations; then
3327     add_cflags $speed_cflags
3328 else
3329     add_cflags $noopt_cflags
3330 fi
3331 check_cflags -fno-math-errno
3332 check_cflags -fno-signed-zeros
3333 check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
3334 int x;
3335 EOF
3336
3337
3338 if enabled icc; then
3339     # Just warnings, no remarks
3340     check_cflags -w1
3341     # -wd: Disable following warnings
3342     # 144, 167, 556: -Wno-pointer-sign
3343     # 1292: attribute "foo" ignored
3344     # 10006: ignoring unknown option -fno-signed-zeros
3345     # 10148: ignoring unknown option -Wno-parentheses
3346     # 10156: ignoring option '-W'; no argument required
3347     check_cflags -wd144,167,556,1292,10006,10148,10156
3348     # 11030: Warning unknown option --as-needed
3349     # 10156: ignoring option '-export'; no argument required
3350     check_ldflags -wd10156,11030
3351     # Allow to compile with optimizations
3352     check_ldflags -march=$cpu
3353     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
3354     enable ebp_available
3355     if enabled x86_32; then
3356         test ${icc_version%%.*} -ge 11 && \
3357             check_cflags -falign-stack=maintain-16-byte || \
3358             disable aligned_stack
3359     fi
3360 elif enabled ccc; then
3361     # disable some annoying warnings
3362     add_cflags -msg_disable cvtu32to64
3363     add_cflags -msg_disable embedcomment
3364     add_cflags -msg_disable needconstext
3365     add_cflags -msg_disable nomainieee
3366     add_cflags -msg_disable ptrmismatch1
3367     add_cflags -msg_disable unreachcode
3368 elif enabled gcc; then
3369     check_cflags -fno-tree-vectorize
3370     check_cflags -Werror=implicit-function-declaration
3371     check_cflags -Werror=missing-prototypes
3372     check_cflags -Werror=return-type
3373 elif enabled llvm_gcc; then
3374     check_cflags -mllvm -stack-alignment=16
3375 elif enabled clang; then
3376     check_cflags -mllvm -stack-alignment=16
3377     check_cflags -Qunused-arguments
3378     check_cflags -Werror=return-type
3379 elif enabled armcc; then
3380     # 2523: use of inline assembler is deprecated
3381     add_cflags -W${armcc_opt},--diag_suppress=2523
3382     add_cflags -W${armcc_opt},--diag_suppress=1207
3383     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
3384     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
3385     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
3386     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
3387 elif enabled tms470; then
3388     add_cflags -pds=824 -pds=837
3389 elif enabled pathscale; then
3390     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
3391 fi
3392
3393 enabled_any $THREADS_LIST      && enable threads
3394
3395 check_deps $CONFIG_LIST       \
3396            $CONFIG_EXTRA      \
3397            $HAVE_LIST         \
3398            $ALL_COMPONENTS    \
3399            $ALL_TESTS         \
3400
3401 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
3402
3403 if test $target_os = "haiku"; then
3404     disable memalign
3405     disable posix_memalign
3406 fi
3407
3408 ! enabled_any memalign posix_memalign malloc_aligned &&
3409     enabled_any $need_memalign && enable memalign_hack
3410
3411 echo "install prefix            $prefix"
3412 echo "source path               $source_path"
3413 echo "C compiler                $cc"
3414 echo "ARCH                      $arch ($cpu)"
3415 if test "$build_suffix" != ""; then
3416     echo "build suffix              $build_suffix"
3417 fi
3418 if test "$progs_suffix" != ""; then
3419     echo "progs suffix              $progs_suffix"
3420 fi
3421 if test "$extra_version" != ""; then
3422     echo "version string suffix     $extra_version"
3423 fi
3424 echo "big-endian                ${bigendian-no}"
3425 echo "runtime cpu detection     ${runtime_cpudetect-no}"
3426 if enabled x86; then
3427     echo "${yasmexe}                      ${yasm-no}"
3428     echo "MMX enabled               ${mmx-no}"
3429     echo "MMX2 enabled              ${mmx2-no}"
3430     echo "3DNow! enabled            ${amd3dnow-no}"
3431     echo "3DNow! extended enabled   ${amd3dnowext-no}"
3432     echo "SSE enabled               ${sse-no}"
3433     echo "SSSE3 enabled             ${ssse3-no}"
3434     echo "AVX enabled               ${avx-no}"
3435     echo "CMOV enabled              ${cmov-no}"
3436     echo "CMOV is fast              ${fast_cmov-no}"
3437     echo "EBX available             ${ebx_available-no}"
3438     echo "EBP available             ${ebp_available-no}"
3439 fi
3440 if enabled arm; then
3441     echo "ARMv5TE enabled           ${armv5te-no}"
3442     echo "ARMv6 enabled             ${armv6-no}"
3443     echo "ARMv6T2 enabled           ${armv6t2-no}"
3444     echo "ARM VFP enabled           ${armvfp-no}"
3445     echo "IWMMXT enabled            ${iwmmxt-no}"
3446     echo "NEON enabled              ${neon-no}"
3447 fi
3448 if enabled mips; then
3449     echo "MMI enabled               ${mmi-no}"
3450 fi
3451 if enabled ppc; then
3452     echo "AltiVec enabled           ${altivec-no}"
3453     echo "PPC 4xx optimizations     ${ppc4xx-no}"
3454     echo "dcbzl available           ${dcbzl-no}"
3455 fi
3456 if enabled sparc; then
3457     echo "VIS enabled               ${vis-no}"
3458 fi
3459 echo "debug symbols             ${debug-no}"
3460 echo "strip symbols             ${stripping-no}"
3461 echo "optimize for size         ${small-no}"
3462 echo "optimizations             ${optimizations-no}"
3463 echo "static                    ${static-no}"
3464 echo "shared                    ${shared-no}"
3465 echo "postprocessing support    ${postproc-no}"
3466 echo "new filter support        ${avfilter-no}"
3467 echo "network support           ${network-no}"
3468 echo "threading support         ${thread_type-no}"
3469 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
3470 echo "SDL support               ${sdl-no}"
3471 echo "Sun medialib support      ${mlib-no}"
3472 echo "libdxva2 enabled          ${dxva2-no}"
3473 echo "libva enabled             ${vaapi-no}"
3474 echo "libvdpau enabled          ${vdpau-no}"
3475 echo "AVISynth enabled          ${avisynth-no}"
3476 echo "frei0r enabled            ${frei0r-no}"
3477 echo "gnutls enabled            ${gnutls-no}"
3478 echo "libaacplus enabled        ${libaacplus-no}"
3479 echo "libass enabled            ${libass-no}"
3480 echo "libcdio support           ${libcdio-no}"
3481 echo "libcelt enabled           ${libcelt-no}"
3482 echo "libdc1394 support         ${libdc1394-no}"
3483 echo "libdirac enabled          ${libdirac-no}"
3484 echo "libfaac enabled           ${libfaac-no}"
3485 echo "libgsm enabled            ${libgsm-no}"
3486 echo "libmodplug enabled        ${libmodplug-no}"
3487 echo "libmp3lame enabled        ${libmp3lame-no}"
3488 echo "libnut enabled            ${libnut-no}"
3489 echo "libopencore-amrnb support ${libopencore_amrnb-no}"
3490 echo "libopencore-amrwb support ${libopencore_amrwb-no}"
3491 echo "libopencv support         ${libopencv-no}"
3492 echo "libopenjpeg enabled       ${libopenjpeg-no}"
3493 echo "libpulse enabled          ${libpulse-no}"
3494 echo "librtmp enabled           ${librtmp-no}"
3495 echo "libschroedinger enabled   ${libschroedinger-no}"
3496 echo "libspeex enabled          ${libspeex-no}"
3497 echo "libstagefright-h264 enabled    ${libstagefright_h264-no}"
3498 echo "libtheora enabled         ${libtheora-no}"
3499 echo "libutvideo enabled        ${libutvideo-no}"
3500 echo "libv4l2 enabled           ${libv4l2-no}"
3501 echo "libvo-aacenc support      ${libvo_aacenc-no}"
3502 echo "libvo-amrwbenc support    ${libvo_amrwbenc-no}"
3503 echo "libvorbis enabled         ${libvorbis-no}"
3504 echo "libvpx enabled            ${libvpx-no}"
3505 echo "libx264 enabled           ${libx264-no}"
3506 echo "libxavs enabled           ${libxavs-no}"
3507 echo "libxvid enabled           ${libxvid-no}"
3508 echo "openal enabled            ${openal-no}"
3509 echo "openssl enabled           ${openssl-no}"
3510 echo "zlib enabled              ${zlib-no}"
3511 echo "bzlib enabled             ${bzlib-no}"
3512 echo
3513
3514 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
3515     echo "Enabled ${type}s:"
3516     eval list=\$$(toupper $type)_LIST
3517     print_enabled '_*' $list | sort | pr -r -3 -t
3518     echo
3519 done
3520
3521 license="LGPL version 2.1 or later"
3522 if enabled nonfree; then
3523     license="nonfree and unredistributable"
3524 elif enabled gplv3; then
3525     license="GPL version 3 or later"
3526 elif enabled lgplv3; then
3527     license="LGPL version 3 or later"
3528 elif enabled gpl; then
3529     license="GPL version 2 or later"
3530 fi
3531
3532 echo "License: $license"
3533
3534 echo "Creating config.mak and config.h..."
3535
3536 test -e Makefile || $ln_s "$source_path/Makefile" .
3537
3538 enabled stripping || strip="echo skipping strip"
3539
3540 config_files="$TMPH config.mak"
3541
3542 cat > config.mak <<EOF
3543 # Automatically generated by configure - do not modify!
3544 ifndef FFMPEG_CONFIG_MAK
3545 FFMPEG_CONFIG_MAK=1
3546 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
3547 prefix=$prefix
3548 LIBDIR=\$(DESTDIR)$libdir
3549 SHLIBDIR=\$(DESTDIR)$shlibdir
3550 INCDIR=\$(DESTDIR)$incdir
3551 BINDIR=\$(DESTDIR)$bindir
3552 DATADIR=\$(DESTDIR)$datadir
3553 MANDIR=\$(DESTDIR)$mandir
3554 SRC_PATH=$source_path
3555 ifndef MAIN_MAKEFILE
3556 SRC_PATH:=\$(SRC_PATH:.%=..%)
3557 endif
3558 CC_IDENT=$cc_ident
3559 ARCH=$arch
3560 CC=$cc
3561 CXX=$cxx
3562 AS=$as
3563 LD=$ld
3564 DEPCC=$dep_cc
3565 YASM=$yasmexe
3566 YASMDEP=$yasmexe
3567 AR=$ar
3568 RANLIB=$ranlib
3569 CP=cp -p
3570 LN_S=$ln_s
3571 STRIP=$strip
3572 CPPFLAGS=$CPPFLAGS
3573 CFLAGS=$CFLAGS
3574 CXXFLAGS=$CXXFLAGS
3575 ASFLAGS=$ASFLAGS
3576 AS_O=$CC_O
3577 CC_O=$CC_O
3578 CXX_O=$CXX_O
3579 LDFLAGS=$LDFLAGS
3580 FFSERVERLDFLAGS=$FFSERVERLDFLAGS
3581 SHFLAGS=$SHFLAGS
3582 YASMFLAGS=$YASMFLAGS
3583 BUILDSUF=$build_suffix
3584 PROGSSUF=$progs_suffix
3585 FULLNAME=$FULLNAME
3586 LIBPREF=$LIBPREF
3587 LIBSUF=$LIBSUF
3588 LIBNAME=$LIBNAME
3589 SLIBPREF=$SLIBPREF
3590 SLIBSUF=$SLIBSUF
3591 EXESUF=$EXESUF
3592 EXTRA_VERSION=$extra_version
3593 DEPFLAGS=$DEPFLAGS
3594 CCDEP=$CCDEP
3595 CXXDEP=$CXXDEP
3596 ASDEP=$ASDEP
3597 CC_DEPFLAGS=$CC_DEPFLAGS
3598 AS_DEPFLAGS=$AS_DEPFLAGS
3599 HOSTCC=$host_cc
3600 HOSTCFLAGS=$host_cflags
3601 HOSTEXESUF=$HOSTEXESUF
3602 HOSTLDFLAGS=$host_ldflags
3603 HOSTLIBS=$host_libs
3604 TARGET_EXEC=$target_exec
3605 TARGET_PATH=$target_path
3606 SDL_LIBS=$sdl_libs
3607 SDL_CFLAGS=$sdl_cflags
3608 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
3609 EXTRALIBS=$extralibs
3610 INSTALL=$install
3611 LIBTARGET=${LIBTARGET}
3612 SLIBNAME=${SLIBNAME}
3613 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
3614 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
3615 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
3616 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
3617 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
3618 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
3619 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
3620 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
3621 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
3622 NOREDZONE_FLAGS=$noredzone_flags
3623 EOF
3624
3625 get_version(){
3626     name=$1
3627     file=$source_path/$2
3628 # This condition will be removed when we stop supporting old libpostproc versions
3629 if ! test "$name" = LIBPOSTPROC || test "$postproc_version" = current; then
3630     eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3631     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3632 fi
3633     lcname=$(tolower $name)
3634     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3635     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3636 }
3637
3638 get_version LIBAVCODEC  libavcodec/version.h
3639 get_version LIBAVDEVICE libavdevice/avdevice.h
3640 get_version LIBAVFILTER libavfilter/version.h
3641 get_version LIBAVFORMAT libavformat/version.h
3642 get_version LIBAVUTIL   libavutil/avutil.h
3643 get_version LIBPOSTPROC libpostproc/postprocess.h
3644 get_version LIBSWRESAMPLE libswresample/swresample.h
3645 get_version LIBSWSCALE  libswscale/swscale.h
3646
3647 cat > $TMPH <<EOF
3648 /* Automatically generated by configure - do not modify! */
3649 #ifndef FFMPEG_CONFIG_H
3650 #define FFMPEG_CONFIG_H
3651 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3652 #define FFMPEG_LICENSE "$(c_escape $license)"
3653 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3654 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
3655 #define CC_TYPE "$cc_type"
3656 #define CC_VERSION $cc_version
3657 #define restrict $_restrict
3658 #define EXTERN_PREFIX "${extern_prefix}"
3659 #define EXTERN_ASM ${extern_prefix}
3660 #define SLIBSUF "$SLIBSUF"
3661 EOF
3662
3663 test -n "$malloc_prefix" &&
3664     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3665
3666 if enabled small || disabled optimizations; then
3667     echo "#undef  av_always_inline"  >> $TMPH
3668     if enabled small; then
3669         echo "#define av_always_inline inline"  >> $TMPH
3670     else
3671         echo "#define av_always_inline av_unused"  >> $TMPH
3672     fi
3673 fi
3674
3675 if enabled yasm; then
3676     append config_files $TMPASM
3677     printf '' >$TMPASM
3678 fi
3679
3680 print_config ARCH_   "$config_files" $ARCH_LIST
3681 print_config HAVE_   "$config_files" $HAVE_LIST
3682 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
3683                                      $CONFIG_EXTRA      \
3684                                      $ALL_COMPONENTS    \
3685
3686 cat >>config.mak <<EOF
3687 ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
3688 VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
3689 LAVF_TESTS=$(print_enabled   -n _test $LAVF_TESTS)
3690 LAVFI_TESTS=$(print_enabled  -n _test $LAVFI_TESTS)
3691 SEEK_TESTS=$(print_enabled   -n _test $SEEK_TESTS)
3692 EOF
3693
3694 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3695 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3696
3697 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3698 cp_if_changed $TMPH config.h
3699 touch .config
3700
3701 enabled yasm && cp_if_changed $TMPASM config.asm
3702
3703 cat > $TMPH <<EOF
3704 /* Generated by ffconf */
3705 #ifndef AVUTIL_AVCONFIG_H
3706 #define AVUTIL_AVCONFIG_H
3707 EOF
3708
3709 test "$postproc_version" != current && cat >> $TMPH <<EOF
3710 #define LIBPOSTPROC_VERSION_MAJOR $LIBPOSTPROC_VERSION_MAJOR
3711 #define LIBPOSTPROC_VERSION_MINOR $LIBPOSTPROC_VERSION_MINOR
3712 #define LIBPOSTPROC_VERSION_MICRO $LIBPOSTPROC_VERSION_MICRO
3713 EOF
3714
3715 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
3716
3717 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3718
3719 cp_if_changed $TMPH libavutil/avconfig.h
3720
3721 test -n "$WARNINGS" && printf "\n$WARNINGS"
3722
3723 # build pkg-config files
3724
3725 pkgconfig_generate(){
3726 name=$1
3727 shortname=${name#lib}${build_suffix}
3728 comment=$2
3729 version=$3
3730 libs=$4
3731 requires=$5
3732 enabled ${name#lib} || return 0
3733 mkdir -p $name
3734 cat <<EOF > $name/$name.pc
3735 prefix=$prefix
3736 exec_prefix=\${prefix}
3737 libdir=$libdir
3738 includedir=$incdir
3739
3740 Name: $name
3741 Description: $comment
3742 Version: $version
3743 Requires: $(enabled shared || echo $requires)
3744 Requires.private: $(enabled shared && echo $requires)
3745 Conflicts:
3746 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3747 Libs.private: $(enabled shared && echo $libs)
3748 Cflags: -I\${includedir}
3749 EOF
3750 cat <<EOF > $name/$name-uninstalled.pc
3751 prefix=
3752 exec_prefix=
3753 libdir=\${pcfiledir}
3754 includedir=${source_path}
3755
3756 Name: $name
3757 Description: $comment
3758 Version: $version
3759 Requires: $requires
3760 Conflicts:
3761 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3762 Cflags: -I\${includedir}
3763 EOF
3764 }
3765
3766 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM"
3767 pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3768 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3769 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3770 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
3771 pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
3772 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
3773 pkgconfig_generate libswresample "FFmpeg audio rescaling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"