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