Move MinGW LDFLAGS setting to configure.
[ffmpeg.git] / configure
1 #!/bin/sh
2 #
3 # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4 #
5
6 # make sure we are running under a compatible shell
7 (: ${foo%%bar}) 2>/dev/null
8 if test "$?" != 0; then
9     if test "x$FFMPEG_CONFIGURE_EXEC" = x; then
10         FFMPEG_CONFIGURE_EXEC=1
11         export FFMPEG_CONFIGURE_EXEC
12         exec bash "$0" "$@"
13         exec ksh "$0" "$@"
14         exec /usr/xpg4/bin/sh "$0" "$@"
15     fi
16     echo "No compatible shell script interpreter found."
17     exit 1
18 fi
19
20 show_help(){
21   echo "Usage: configure [options]"
22   echo "Options: [defaults in brackets after descriptions]"
23   echo
24   echo "Standard options:"
25   echo "  --help                   print this message"
26   echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
27   echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
28   echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
29   echo "  --incdir=DIR             install includes in DIR [PREFIX/include/ffmpeg]"
30   echo "  --mandir=DIR             install man page in DIR [PREFIX/man]"
31   echo "  --enable-mp3lame         enable MP3 encoding via libmp3lame [default=no]"
32   echo "  --enable-libogg          enable Ogg support via libogg [default=no]"
33   echo "  --enable-vorbis          enable Vorbis support via libvorbis [default=no]"
34   echo "  --enable-theora          enable Theora support via libtheora [default=no]"
35   echo "  --enable-faad            enable FAAD support via libfaad [default=no]"
36   echo "  --enable-faadbin         build FAAD support with runtime linking [default=no]"
37   echo "  --enable-faac            enable FAAC support via libfaac [default=no]"
38   echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
39   echo "  --enable-xvid            enable XviD support via xvidcore [default=no]"
40   echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
41   echo "  --enable-mingw32         enable MinGW native/cross Windows compile"
42   echo "  --enable-mingwce         enable MinGW native/cross WinCE compile"
43   echo "  --enable-a52             enable GPLed A52 support [default=no]"
44   echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
45   echo "  --enable-dts             enable GPLed DTS support [default=no]"
46   echo "  --enable-pp              enable GPLed postprocessing support [default=no]"
47   echo "  --enable-static          build static libraries [default=yes]"
48   echo "  --disable-static         do not build static libraries [default=no]"
49   echo "  --enable-shared          build shared libraries [default=no]"
50   echo "  --disable-shared         do not build shared libraries [default=yes]"
51   echo "  --enable-amr_nb          enable amr_nb float audio codec"
52   echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
53   echo "  --enable-amr_wb          enable amr_wb float audio codec"
54   echo "  --enable-amr_if2         enable amr_wb IF2 audio codec"
55   echo "  --enable-sunmlib         use Sun medialib [default=no]"
56   echo "  --enable-pthreads        use pthreads [default=no]"
57   echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394"
58   echo "                           and libraw1394 [default=no]"
59   echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
60   echo "                           and ffmpeg will be under GPL [default=no]"
61   echo ""
62   echo "Advanced options (experts only):"
63   echo "  --source-path=PATH       path to source code [$source_path]"
64   echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
65   echo "  --cross-compile          assume a cross-compiler is used"
66   echo "  --cc=CC                  use C compiler CC [$cc]"
67   echo "  --make=MAKE              use specified make [$make]"
68   echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
69   echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
70   echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
71   echo "  --build-suffix=SUFFIX    suffix for application specific build []"
72   echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
73   echo "  --tune=CPU               tune code for a particular CPU"
74   echo "                           (may fail or perform badly on other CPUs)"
75   echo "  --powerpc-perf-enable    enable performance report on PPC"
76   echo "                           (requires enabling PMC)"
77   echo "  --disable-mmx            disable MMX usage"
78   echo "  --disable-iwmmxt         disable iwmmxt usage"
79   echo "  --disable-altivec        disable AltiVec usage"
80   echo "  --disable-audio-oss      disable OSS audio support [default=no]"
81   echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
82   echo "  --disable-v4l            disable video4linux grabbing [default=no]"
83   echo "  --disable-v4l2           disable video4linux2 grabbing [default=no]"
84   echo "  --disable-bktr           disable bktr video grabbing [default=no]"
85   echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
86   echo "  --disable-network        disable network support [default=no]"
87   echo "  --disable-zlib           disable zlib [default=no]"
88   echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
89   echo "  --disable-vhook          disable video hooking support"
90   echo "  --enable-gprof           enable profiling with gprof [$gprof]"
91   echo "  --disable-debug          disable debugging symbols"
92   echo "  --disable-opts           disable compiler optimizations"
93   echo "  --disable-mpegaudio-hp   faster (but less accurate)"
94   echo "                           MPEG audio decoding [default=no]"
95   echo "  --disable-protocols      disable I/O protocols support [default=no]"
96   echo "  --disable-ffserver       disable ffserver build"
97   echo "  --disable-ffplay         disable ffplay build"
98   echo "  --enable-small           optimize for size instead of speed"
99   echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
100   echo "  --disable-strip          disable stripping of executables and shared libraries"
101   echo "  --disable-encoder=NAME   disables encoder NAME"
102   echo "  --enable-encoder=NAME    enables encoder NAME"
103   echo "  --disable-decoder=NAME   disables decoder NAME"
104   echo "  --enable-decoder=NAME    enables decoder NAME"
105   echo "  --disable-encoders       disables all encoders"
106   echo "  --disable-decoders       disables all decoders"
107   echo "  --disable-muxers         disables all muxers"
108   echo "  --disable-demuxers       disables all demuxers"
109   echo "  --enable-parser=NAME     enables parser NAME"
110   echo "  --disable-parser=NAME    disables parser NAME"
111   echo "  --disable-parsers        disables all parsers"
112   echo ""
113   echo "NOTE: Object files are built at the place where configure is launched."
114   exit 1
115 }
116
117 log(){
118     echo "$@" >>$logfile
119 }
120
121 log_file(){
122     log BEGIN $1
123     cat -n $1 >>$logfile
124     log END $1
125 }
126
127 echolog(){
128     log "$@"
129     echo "$@"
130 }
131
132 die(){
133     echolog "$@"
134     cat <<EOF
135 If you think configure made a mistake, make sure you are using the latest
136 version from SVN.  If the latest version fails, report the problem to the
137 ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
138 EOF
139     if enabled logging; then
140         cat <<EOF
141 Include the log file "$logfile" produced by configure as this will help
142 solving the problem.
143 EOF
144     else
145 cat <<EOF
146 Rerun configure with logging enabled (do not use --log=no), and include the
147 log this produces with your report.
148 EOF
149     fi
150     rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
151     exit 1
152 }
153
154 enabled(){
155     eval test "\$$1" = "yes"
156 }
157
158 flags_saved(){
159     (: ${SAVE_CFLAGS?}) 2>/dev/null
160 }
161
162 save_flags(){
163     flags_saved && return
164     SAVE_CFLAGS="$CFLAGS"
165     SAVE_LDFLAGS="$LDFLAGS"
166     SAVE_extralibs="$extralibs"
167 }
168
169 restore_flags(){
170     CFLAGS="$SAVE_CFLAGS"
171     LDFLAGS="$SAVE_LDFLAGS"
172     extralibs="$SAVE_extralibs"
173     unset SAVE_CFLAGS
174     unset SAVE_LDFLAGS
175     unset SAVE_extralibs
176 }
177
178 temp_cflags(){
179     save_flags
180     CFLAGS="$CFLAGS $*"
181 }
182
183 temp_ldflags(){
184     save_flags
185     LDFLAGS="$LDFLAGS $*"
186 }
187
188 temp_extralibs(){
189     save_flags
190     extralibs="$extralibs $*"
191 }
192
193 append(){
194     var=$1
195     shift
196     flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
197     eval "$var=\"\$$var $*\""
198 }
199
200 add_cflags(){
201     append CFLAGS "$@"
202 }
203
204 add_ldflags(){
205     append LDFLAGS "$@"
206 }
207
208 add_extralibs(){
209     append extralibs "$@"
210 }
211
212 check_cc(){
213     log check_cc "$@"
214     cat >$TMPC
215     log_file $TMPC
216     log $cc $CFLAGS "$@" -c -o $TMPO $TMPC
217     $cc $CFLAGS "$@" -c -o $TMPO $TMPC >>$logfile 2>&1
218 }
219
220 check_cpp(){
221     log check_cpp "$@"
222     cat >$TMPC
223     log_file $TMPC
224     log $cc $CFLAGS "$@" -E -o $TMPO $TMPC
225     $cc $CFLAGS "$@" -E -o $TMPO $TMPC >>$logfile 2>&1
226 }
227
228 check_ld(){
229     log check_ld "$@"
230     cat >$TMPC
231     log_file $TMPC
232     log $cc $CFLAGS $LDFLAGS "$@" -o $TMPE $TMPC $extralibs
233     $cc $CFLAGS $LDFLAGS "$@" -o $TMPE $TMPC $extralibs >>$logfile 2>&1
234 }
235
236 check_cflags(){
237     log check_cflags "$@"
238     check_cc "$@" <<EOF && add_cflags "$@"
239 int x;
240 EOF
241 }
242
243 check_ldflags(){
244     log check_ldflags "$@"
245     check_ld "$@" <<EOF && add_ldflags "$@"
246 int main(){
247     return 0;
248 }
249 EOF
250 }
251
252 check_header(){
253     log check_header "$@"
254     header=$1
255     shift
256     check_cpp "$@" <<EOF
257 #include <$header>
258 int x;
259 EOF
260 }
261
262 check_func(){
263     log check_func "$@"
264     func=$1
265     shift
266     check_ld "$@" <<EOF
267 extern int $func();
268 int main(){
269     $func();
270 }
271 EOF
272 }
273
274 check_lib(){
275     log check_lib "$@"
276     header="$1"
277     func="$2"
278     shift 2
279     temp_extralibs "$@"
280     check_header $header && check_func $func && add_extralibs "$@"
281     err=$?
282     restore_flags
283     return $err
284 }
285
286 check_exec(){
287     check_ld "$@" && { test "$cross_compile" = yes || $TMPE 2>&1 >>$logfile; }
288 }
289
290 require(){
291     name="$1"
292     header="$2"
293     func="$3"
294     shift 3
295     check_lib $header $func "$@" || die "ERROR: $name not found"
296 }
297
298 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
299     show_help
300 fi
301
302 # set temporary file name
303 if test ! -z "$TMPDIR" ; then
304     TMPDIR1="${TMPDIR}"
305 elif test ! -z "$TEMPDIR" ; then
306     TMPDIR1="${TEMPDIR}"
307 else
308     TMPDIR1="/tmp"
309 fi
310
311 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
312 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
313 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
314 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
315 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
316
317 # default parameters
318 logging="yes"
319 logfile="config.err"
320 prefix="/usr/local"
321 libdir=""
322 incdir=""
323 mandir=""
324 bindir=""
325 cross_prefix=""
326 cross_compile="no"
327 cc="gcc"
328 ar="ar"
329 ranlib="ranlib"
330 make="make"
331 strip="strip"
332 cpu=`uname -m`
333 tune="generic"
334 powerpc_perf="no"
335 mmx="default"
336 iwmmxt="default"
337 altivec="default"
338 mmi="default"
339 case "$cpu" in
340   i386|i486|i586|i686|i86pc|BePC)
341     cpu="x86"
342   ;;
343   x86_64|amd64)
344     cpu="x86"
345     canon_arch="`cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
346     if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
347       if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
348         cpu="x86_64"
349       fi
350     fi
351   ;;
352   # armv4l is a subset of armv5tel
353   armv4l|armv5tel)
354     cpu="armv4l"
355   ;;
356   alpha)
357     cpu="alpha"
358   ;;
359   "Power Macintosh"|ppc|powerpc)
360     cpu="powerpc"
361   ;;
362   mips|mipsel|IP*)
363     cpu="mips"
364   ;;
365   sun4u|sparc64)
366     cpu="sparc64"
367   ;;
368   sparc)
369     cpu="sparc"
370   ;;
371   sh4)
372     cpu="sh4"
373   ;;
374   parisc|parisc64)
375     cpu="parisc"
376   ;;
377   s390|s390x)
378     cpu="s390"
379   ;;
380   m68k)
381     cpu="m68k"
382   ;;
383   ia64)
384     cpu="ia64"
385   ;;
386   *)
387     cpu="unknown"
388   ;;
389 esac
390 gprof="no"
391 v4l="yes"
392 v4l2="yes"
393 bktr="no"
394 audio_oss="yes"
395 audio_beos="no"
396 dv1394="yes"
397 dc1394="no"
398 network="yes"
399 zlib="yes"
400 libgsm="no"
401 mp3lame="no"
402 libogg="no"
403 vorbis="no"
404 theora="no"
405 faad="no"
406 faadbin="no"
407 faac="no"
408 xvid="no"
409 x264="no"
410 a52="no"
411 a52bin="no"
412 dts="no"
413 pp="no"
414 mingw32="no"
415 mingwce="no"
416 cygwin="no"
417 os2="no"
418 lstatic="yes"
419 lshared="no"
420 optimize="yes"
421 debug="yes"
422 dostrip="yes"
423 installstrip="-s"
424 extralibs="-lm"
425 simpleidct="yes"
426 bigendian="no"
427 inttypes="yes"
428 emu_fast_int="no"
429 vhook="default"
430 dlfcn="no"
431 dlopen="no"
432 mpegaudio_hp="yes"
433 SHFLAGS='-shared -Wl,-soname,$@'
434 netserver="no"
435 need_inet_aton="no"
436 protocols="yes"
437 ffserver="yes"
438 ffplay="yes"
439 LIBOBJFLAGS=""
440 FFLDFLAGS=-Wl,--warn-common
441 FFSLDFLAGS=-Wl,-E
442 LDCONFIG="ldconfig"
443 LIBPREF="lib"
444 LIBSUF=".a"
445 LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
446 SLIBPREF="lib"
447 SLIBSUF=".so"
448 SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
449 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
450 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
451 EXESUF=""
452 BUILDSUF=""
453 amr_nb="no"
454 amr_wb="no"
455 amr_nb_fixed="no"
456 amr_if2="no"
457 sunmlib="no"
458 pthreads="no"
459 gpl="no"
460 memalignhack="no"
461 muxers="yes"
462 demuxers="yes"
463
464 # OS specific
465 targetos=`uname -s`
466 case $targetos in
467 BeOS)
468 prefix="/boot/home/config"
469 # helps building libavcodec
470 CFLAGS="$CFLAGS -DPIC -fomit-frame-pointer"
471 # 3 gcc releases known for BeOS, each with ugly bugs
472 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
473 case "$gcc_version" in
474 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
475 mmx="no"
476 ;;
477 *20010315*) echo "BeBits gcc"
478 CFLAGS="$CFLAGS -fno-expensive-optimizations"
479 ;;
480 esac
481 SHFLAGS=-nostart
482 # disable Linux things
483 audio_oss="no"
484 v4l="no"
485 v4l2="no"
486 dv1394="no"
487 # enable BeOS things
488 audio_beos="yes"
489 # no need for libm, but the inet stuff
490 # Check for BONE
491 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
492 extralibs="-lbind -lsocket"
493 else
494 netserver="yes"
495 need_inet_aton="yes"
496 extralibs="-lnet"
497 fi ;;
498 SunOS)
499 v4l="no"
500 v4l2="no"
501 audio_oss="no"
502 dv1394="no"
503 make="gmake"
504 FFLDFLAGS=""
505 FFSLDFLAGS=""
506 SHFLAGS="-shared -Wl,-h,\$@"
507 need_inet_aton="yes"
508 extralibs="$extralibs -lsocket -lnsl"
509 ;;
510 NetBSD)
511 v4l="no"
512 v4l2="no"
513 bktr="yes"
514 audio_oss="yes"
515 dv1394="no"
516 make="gmake"
517 extralibs="$extralibs -lossaudio"
518 ;;
519 OpenBSD)
520 v4l="no"
521 v4l2="no"
522 bktr="yes"
523 audio_oss="yes"
524 dv1394="no"
525 make="gmake"
526 LIBOBJFLAGS="\$(PIC)"
527 LDCONFIG="ldconfig -m \$(libdir)"
528 extralibs="$extralibs -lossaudio"
529 ;;
530 FreeBSD)
531 v4l="no"
532 v4l2="no"
533 bktr="yes"
534 audio_oss="yes"
535 dv1394="no"
536 make="gmake"
537 CFLAGS="$CFLAGS -pthread"
538 ;;
539 GNU/kFreeBSD)
540 v4l="no"
541 v4l2="no"
542 bktr="yes"
543 audio_oss="yes"
544 dv1394="no"
545 CFLAGS="$CFLAGS -pthread"
546 ;;
547 BSD/OS)
548 v4l="no"
549 v4l2="no"
550 bktr="yes"
551 audio_oss="yes"
552 dv1394="no"
553 extralibs="-lpoll -lgnugetopt -lm"
554 make="gmake"
555 strip="strip -d"
556 installstrip=""
557 ;;
558 Darwin)
559 cc="cc"
560 v4l="no"
561 v4l2="no"
562 audio_oss="no"
563 dv1394="no"
564 SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(libdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION)"
565 extralibs=""
566 darwin="yes"
567 strip="strip -x"
568 installstrip=""
569 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
570 SLIBSUF=".dylib"
571 SLIBNAME_WITH_FULLVERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
572 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
573 FFSLDFLAGS=-Wl,-bind_at_load
574 ;;
575 MINGW32*)
576 # Note: the rest of the mingw32 config is done afterwards as mingw32
577 # can be forced on the command line for Linux cross compilation.
578 mingw32="yes"
579 ;;
580 CYGWIN*)
581 v4l="no"
582 v4l2="no"
583 audio_oss="yes"
584 dv1394="no"
585 vhook="no"
586 extralibs=""
587 cygwin="yes"
588 EXESUF=".exe"
589 ;;
590 Linux)
591 ;;
592 IRIX*)
593 ranlib="echo ignoring ranlib"
594 v4l="no"
595 v4l2="no"
596 audio_oss="no"
597 make="gmake"
598 ;;
599 OS/2)
600 TMPE=$TMPE".exe"
601 ar="emxomfar -p128"
602 ranlib="echo ignoring ranlib"
603 strip="echo ignoring strip"
604 CFLAGS="$CFLAGS -Zomf"
605 FFLDFLAGS="-Zomf -Zstack 16384 -s"
606 SHFLAGS="-Zdll -Zomf"
607 FFSLDFLAGS=""
608 LIBPREF=""
609 LIBSUF=".lib"
610 SLIBPREF=""
611 SLIBSUF=".dll"
612 EXESUF=".exe"
613 extralibs=""
614 pkg_requires=""
615 v4l="no"
616 v4l2="no"
617 audio_oss="no"
618 dv1394="no"
619 ffserver="no"
620 vhook="no"
621 os2="yes"
622
623 ;;
624 *) ;;
625 esac
626
627 # From MPlayer configure. We need TARGET_OS available
628 # to the Makefile, so it can distinguish between flavors
629 # of AltiVec on PowerPC.
630 TARGET_OS=`( uname -s ) 2>&1`
631   case "$TARGET_OS" in
632   Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS|MorphOS)
633     ;;
634   IRIX*)
635     TARGET_OS=IRIX
636     ;;
637   HP-UX*)
638     TARGET_OS=HP-UX
639     ;;
640   [cC][yY][gG][wW][iI][nN]*)
641     TARGET_OS=CYGWIN
642     ;;
643   *)
644     TARGET_OS="$TARGET_OS-UNKNOWN"
645     ;;
646   esac
647
648 # find source path
649 source_path="`dirname $0`"
650 source_path_used="yes"
651 if test -z "$source_path" -o "$source_path" = "." ; then
652     source_path=`pwd`
653     source_path_used="no"
654 else
655     source_path="`cd \"$source_path\"; pwd`"
656 fi
657
658 FFMPEG_CONFIGURATION=" "
659 for opt do
660   FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
661 done
662
663 CODEC_LIST=`grep 'register_avcodec(&[a-z]' $source_path/libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
664 PARSER_LIST=`grep 'av_register_codec_parser(&[a-z]' $source_path/libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
665
666 for opt do
667   case "$opt" in
668   --log)
669   ;;
670   --log=*) logging="${opt#*=}"
671   ;;
672   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`; force_prefix=yes
673   ;;
674   --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`; force_libdir=yes
675   ;;
676   --incdir=*) incdir=`echo $opt | cut -d '=' -f 2`;
677   ;;
678   --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
679   ;;
680   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
681   ;;
682   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
683   ;;
684   --cross-compile) cross_compile=yes
685   ;;
686   --cc=*) cc=`echo $opt | cut -d '=' -f 2-`
687   ;;
688   --make=*) make=`echo $opt | cut -d '=' -f 2`
689   ;;
690   --extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
691   ;;
692   --extra-ldflags=*) FFLDFLAGS="$FFLDFLAGS ${opt#--extra-ldflags=}"
693   ;;
694   --extra-libs=*) extralibs=${opt#--extra-libs=}
695   ;;
696   --build-suffix=*) BUILDSUF=${opt#--build-suffix=}
697   ;;
698   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
699   ;;
700   --tune=*) tune=`echo $opt | cut -d '=' -f 2`
701   ;;
702   --powerpc-perf-enable) powerpc_perf="yes"
703   ;;
704   --disable-mmx) mmx="no"
705   ;;
706   --disable-iwmmxt) iwmmxt="no"
707   ;;
708   --disable-altivec) altivec="no"
709   ;;
710   --enable-gprof) gprof="yes"
711   ;;
712   --disable-v4l) v4l="no"
713   ;;
714   --disable-v4l2) v4l2="no"
715   ;;
716   --disable-bktr) bktr="no"
717   ;;
718   --disable-audio-oss) audio_oss="no"
719   ;;
720   --disable-audio-beos) audio_beos="no"
721   ;;
722   --disable-dv1394) dv1394="no"
723   ;;
724   --disable-network) network="no"; ffserver="no"
725   ;;
726   --disable-zlib) zlib="no"
727   ;;
728   --enable-a52) a52="yes"
729   ;;
730   --enable-a52bin) a52bin="yes"
731   ;;
732   --enable-dts) dts="yes"
733   ;;
734   --enable-pp) pp="yes"
735   ;;
736   --enable-libgsm) libgsm="yes"
737   ;;
738   --enable-mp3lame) mp3lame="yes"
739   ;;
740   --enable-libogg) libogg="yes"
741     pkg_requires="$pkg_requires ogg >= 1.1"
742   ;;
743   --enable-vorbis) vorbis="yes"
744     pkg_requires="$pkg_requires vorbis vorbisenc"
745   ;;
746   --enable-theora) theora="yes"
747     pkg_requires="$pkg_requires theora"
748   ;;
749   --enable-faad) faad="yes"
750   ;;
751   --enable-faadbin) faadbin="yes"
752   ;;
753   --enable-faac) faac="yes"
754   ;;
755   --enable-xvid) xvid="yes"
756   ;;
757   --enable-x264) x264="yes"
758   ;;
759   --enable-dc1394) dc1394="yes"
760     pkg_requires="$pkg_requires libraw1394"
761   ;;
762   --disable-vhook) vhook="no"
763   ;;
764   --disable-simple_idct) simpleidct="no"
765   ;;
766   --enable-mingw32) mingw32="yes"
767   ;;
768   --enable-mingwce) mingwce="yes"
769   ;;
770   --enable-static) lstatic="yes"
771   ;;
772   --disable-static) lstatic="no"
773   ;;
774   --enable-shared) lshared="yes"
775   ;;
776   --disable-shared) lshared="no"
777   ;;
778   --disable-debug) debug="no"
779   ;;
780   --disable-opts) optimize="no"
781   ;;
782   --disable-mpegaudio-hp) mpegaudio_hp="no"
783   ;;
784   --disable-protocols) protocols="no"; network="no"; ffserver="no"
785   ;;
786   --disable-ffserver) ffserver="no"
787   ;;
788   --disable-ffplay) ffplay="no"
789   ;;
790   --enable-small) optimize="small"
791   ;;
792   --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
793   ;;
794   --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
795   ;;
796   --enable-amr_wb) amr="yes"; amr_wb="yes"
797   ;;
798   --enable-amr_if2) amr="yes"; amr_if2="yes"
799   ;;
800   --enable-sunmlib) sunmlib="yes"
801   ;;
802   --enable-pthreads) pthreads="yes"
803   ;;
804   --enable-gpl) gpl="yes"
805   ;;
806   --enable-memalign-hack) memalignhack="yes"
807   ;;
808   --disable-strip) dostrip="no"
809   ;;
810   --enable-encoder=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-encoder=}_encoder"
811   ;;
812   --enable-decoder=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-decoder=}_decoder"
813   ;;
814   --disable-encoder=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-encoder=}_encoder##\"`"
815   ;;
816   --disable-decoder=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-decoder=}_decoder##\"`"
817   ;;
818   --disable-encoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*encoder//g'`"
819   ;;
820   --disable-decoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*decoder//g'`"
821   ;;
822   --disable-muxers) muxers="no"; ffserver="no"
823   ;;
824   --disable-demuxers) demuxers="no"
825   ;;
826   --enable-parser=*) PARSER_LIST="$PARSER_LIST ${opt#*=}_parser"
827   ;;
828   --disable-parser=*) PARSER_LIST="`echo $PARSER_LIST | sed -e \"s#${opt#*=}_parser##\"`"
829   ;;
830   --disable-parsers) PARSER_LIST=""
831   ;;
832   --help) show_help
833   ;;
834   *)
835   echo "Unknown option \"$opt\"."
836   echo "See $0 --help for available options."
837   exit 1
838   ;;
839   esac
840 done
841
842 if test "$logging" != no; then
843     test "$logging" = yes || logfile="$logging"
844     echo "# $0 $@" >$logfile
845     set >>$logfile
846 else
847     logfile=/dev/null
848 fi
849
850 # Combine FFLDFLAGS and the LDFLAGS environment variable
851 LDFLAGS="$FFLDFLAGS $LDFLAGS"
852
853 test -n "$cross_prefix" && cross_compile=yes
854 cc="${cross_prefix}${cc}"
855 ar="${cross_prefix}${ar}"
856 ranlib="${cross_prefix}${ranlib}"
857 strip="${cross_prefix}${strip}"
858
859 # we need to build at least one lib type
860 if test "$lstatic" = "no" && test "$lshared" = "no" ; then
861     cat <<EOF
862 At least one library type must be built.
863 Specify --enable-static to build the static libraries or --enable-shared to
864 build the shared libraries as well. To only build the shared libraries specify
865 --disable-static in addition to --enable-shared.
866 EOF
867     exit 1;
868 fi
869
870 if test "$theora" = "yes" ; then
871     if test "$libogg" = "no"; then
872         echo "libogg must be enabled to enable Theora."
873         fail="yes"
874         theora="no"
875     fi
876 fi
877
878 if test "$vorbis" = "yes" ; then
879     if test "$libogg" = "no"; then
880         echo "libogg must be enabled to enable Vorbis."
881         fail="yes"
882         vorbis="no"
883     fi
884 fi
885
886 if test "$gpl" != "yes"; then
887     if test "$pp" != "no"; then
888         echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
889         fail="yes"
890     fi
891
892     if test "$a52" != "no" -o "$a52bin" != "no"; then
893         echo "liba52 is under GPL and --enable-gpl is not specified."
894         fail="yes"
895     fi
896
897     if test "$xvid" != "no"; then
898         echo "libxvidcore is under GPL and --enable-gpl is not specified."
899         fail="yes"
900     fi
901
902     if test "$x264" != "no"; then
903         echo "x264 is under GPL and --enable-gpl is not specified."
904         fail="yes"
905     fi
906
907     if test "$dts" != "no"; then
908         echo "libdts is under GPL and --enable-gpl is not specified."
909         fail="yes"
910     fi
911
912     if test "$faad" != "no" -o "$faadbin" != "no"; then
913         if check_header faad.h; then
914             check_cc << EOF
915                 #include <faad.h>
916                 #ifndef FAAD2_VERSION
917                 ok faad1
918                 #endif
919                 int main( void ) { return 0; }
920 EOF
921             if test $? = 0 ; then
922                 echo "FAAD2 is under GPL and --enable-gpl is not specified."
923                 fail="yes"
924             fi
925         else
926             faad="no"
927             faadbin="no"
928             echo "FAAD test failed."
929         fi
930     fi
931
932
933     if test "$fail" = "yes"; then
934         exit 1
935     fi
936 fi
937
938 # compute MMX state
939 if test $mmx = "default"; then
940     if test $cpu = "x86" -o $cpu = "x86_64"; then
941         mmx="yes"
942     else
943         mmx="no"
944     fi
945 fi
946
947 # check iwmmxt support
948 if test $iwmmxt = "default" -a $cpu = "armv4l"; then
949     iwmmxt=no
950     check_cc <<EOF && iwmmxt=yes
951         int main(void) {
952         __asm__ __volatile__ ("wunpckelub wr6, wr4");
953         }
954 EOF
955 fi
956
957 #Darwin CC versions
958 needmdynamicnopic="no"
959 if test $targetos = Darwin; then
960     if test -n "`$cc -v 2>&1 | grep xlc`"; then
961         CFLAGS="$CFLAGS -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
962     else
963         gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
964         case "$gcc_version" in
965             *2.95*)
966                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
967                 ;;
968             *[34].*)
969                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer -force_cpusubtype_ALL -Wno-sign-compare"
970                 if test "$lshared" = no; then
971                    needmdynamicnopic="yes"
972                 fi
973                 ;;
974             *)
975                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
976                 if test "$lshared" = no; then
977                    needmdynamicnopic="yes"
978                 fi
979                 ;;
980         esac
981     fi
982 fi
983
984 # Can only do AltiVec on PowerPC
985 if test $altivec = "default"; then
986     if test $cpu = "powerpc"; then
987         altivec="yes"
988     else
989         altivec="no"
990     fi
991 fi
992
993 # Add processor-specific flags
994 TUNECPU="generic"
995 POWERPCMODE="32bits"
996 if test $tune != "generic"; then
997     case $tune in
998         601|ppc601|PowerPC601)
999             CFLAGS="$CFLAGS -mcpu=601"
1000             if test $altivec = "yes"; then
1001                 echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
1002             fi
1003             TUNECPU=ppc601
1004         ;;
1005         603*|ppc603*|PowerPC603*)
1006             CFLAGS="$CFLAGS -mcpu=603"
1007             if test $altivec = "yes"; then
1008                 echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
1009             fi
1010             TUNECPU=ppc603
1011         ;;
1012         604*|ppc604*|PowerPC604*)
1013             CFLAGS="$CFLAGS -mcpu=604"
1014             if test $altivec = "yes"; then
1015                 echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
1016             fi
1017             TUNECPU=ppc604
1018         ;;
1019         G3|g3|75*|ppc75*|PowerPC75*)
1020             CFLAGS="$CFLAGS -mcpu=750 -mtune=750 -mpowerpc-gfxopt"
1021             if test $altivec = "yes"; then
1022                 echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
1023             fi
1024             TUNECPU=ppc750
1025         ;;
1026         G4|g4|745*|ppc745*|PowerPC745*)
1027             CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
1028             if test $altivec = "no"; then
1029                 echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
1030             fi
1031             TUNECPU=ppc7450
1032         ;;
1033         74*|ppc74*|PowerPC74*)
1034             CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
1035             if test $altivec = "no"; then
1036                 echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
1037             fi
1038             TUNECPU=ppc7400
1039         ;;
1040         G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1041             CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc-gfxopt -mpowerpc64"
1042             if test $altivec = "no"; then
1043                 echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
1044             fi
1045             TUNECPU=ppc970
1046             POWERPCMODE="64bits"
1047         ;;
1048         i[3456]86|pentium|pentiumpro|pentium-mmx|pentium[234]|prescott|k6|k6-[23]|athlon|athlon-tbird|athlon-4|athlon-[mx]p|winchip-c6|winchip2|c3|nocona|athlon64|k8|opteron|athlon-fx)
1049             CFLAGS="$CFLAGS -march=$tune"
1050         ;;
1051         sparc64)
1052             CFLAGS="$CFLAGS -mcpu=ultrasparc -mtune=ultrasparc"
1053         ;;
1054         *)
1055         echo "WARNING: Unknown CPU \"$tune\", ignored."
1056         ;;
1057     esac
1058 fi
1059
1060 # compiler sanity check
1061 check_exec <<EOF
1062 int main(){
1063     return 0;
1064 }
1065 EOF
1066 if test "$?" != 0; then
1067     echo "$cc is unable to create an executable file."
1068     if test -z "$cross_prefix" -a "$cross_compile" = no; then
1069         echo "If $cc is a cross-compiler, use the --cross-compile option."
1070     fi
1071     die "C compiler test failed."
1072 fi
1073
1074 # check for SIMD availability
1075
1076 # AltiVec flags: The FSF version of GCC differs from the Apple version
1077 if test $cpu = "powerpc"; then
1078     if test $altivec = "yes"; then
1079         if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1080             CFLAGS="$CFLAGS -faltivec"
1081         else
1082             CFLAGS="$CFLAGS -maltivec -mabi=altivec"
1083         fi
1084     fi
1085 fi
1086
1087 check_header altivec.h && _altivec_h=yes || _altivec_h=no
1088
1089 # check if our compiler supports Motorola AltiVec C API
1090 if test $altivec = "yes"; then
1091     if test $_altivec_h = "yes"; then
1092         inc_altivec_h="#include <altivec.h>"
1093     else
1094         inc_altivec_h=
1095     fi
1096     check_cc <<EOF || altivec=no
1097 $inc_altivec_h
1098 int main(void) {
1099     vector signed int v1, v2, v3;
1100     v1 = vec_add(v2,v3);
1101     return 0;
1102 }
1103 EOF
1104 fi
1105
1106 # mmi only available on mips
1107 if test $mmi = "default"; then
1108     if test $cpu = "mips"; then
1109         mmi="yes"
1110     else
1111         mmi="no"
1112     fi
1113 fi
1114
1115 # check if our compiler supports mmi
1116 enabled mmi && check_cc <<EOF || mmi="no"
1117 int main(void) {
1118     __asm__ ("lq \$2, 0(\$2)");
1119     return 0;
1120 }
1121 EOF
1122
1123 # test gcc version to see if vector builtins can be used
1124 # currently only used on i386 for MMX builtins
1125 check_cc -msse <<EOF && builtin_vector=yes || builtin_vector=no
1126 #include <xmmintrin.h>
1127 int main(void) {
1128 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
1129 return 0;
1130 #else
1131 #error no vector builtins
1132 #endif
1133 }
1134 EOF
1135
1136 # test for mm3dnow.h
1137 test "$cpu" = "x86_64" && march=k8 || march=athlon
1138 check_cc -march=$march <<EOF && mm3dnow=yes || mm3dnow=no
1139 #include <mm3dnow.h>
1140 int main(void) {
1141 __m64 b1;
1142 b1 = _m_pswapd(b1);
1143 _m_femms();
1144 return 0;
1145 }
1146 EOF
1147
1148 if test "$mingw32" = "yes" -o "$mingwce" = "yes"; then
1149     if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
1150         cat <<EOF
1151 You can only build one library type at once on MinGW.
1152 Specify --disable-static --enable-shared to only build
1153 the shared libraries. To build only the static libraries
1154 you do not need to pass additional options.
1155 EOF
1156         exit 1
1157     fi
1158     v4l="no"
1159     v4l2="no"
1160     bktr="no"
1161     audio_oss="no"
1162     dv1394="no"
1163     dc1394="no"
1164     ffserver="no"
1165     network="no"
1166     if test "$mingwce" = "yes"; then
1167         protocols="no"
1168     fi
1169     LDFLAGS=-Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
1170     SLIBPREF=""
1171     SLIBSUF=".dll"
1172     EXESUF=".exe"
1173     if test "$force_prefix" != yes; then prefix="$PROGRAMFILES/FFmpeg"; fi
1174     if test "$force_libdir" != yes; then bindir="$prefix"; fi
1175 fi
1176
1177 # ---
1178 # big/little-endian test
1179 if test "$cross_compile" = "no"; then
1180     check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1181 #include <inttypes.h>
1182 int main(int argc, char ** argv){
1183         volatile uint32_t i=0x01234567;
1184         return (*((uint8_t*)(&i))) == 0x67;
1185 }
1186 EOF
1187 else
1188     # programs cannot be launched if cross compiling, so make a static guess
1189     if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
1190         bigendian="yes"
1191     fi
1192 fi
1193
1194 # ---
1195 # *inttypes.h* test
1196 check_header inttypes.h || inttypes=no
1197
1198 # ---
1199 # *int_fast* test
1200 check_cc <<EOF || emu_fast_int=yes
1201 #include <inttypes.h>
1202 int main(int argc, char ** argv){
1203         volatile uint_fast64_t i=0x01234567;
1204         return 0;
1205 }
1206 EOF
1207
1208 # ---
1209 # check availability of some header files
1210
1211 _memalign=no
1212 _malloc_h=no
1213 if check_header malloc.h; then
1214     _malloc_h=yes
1215     _memalign=yes
1216     check_func memalign || _memalign="no"
1217 fi
1218
1219 if test "$_memalign" = "no" -a "$mmx" = "yes" -a "$memalignhack" != "yes"; then
1220     die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1221 fi
1222
1223 check_func localtime_r && localtime_r=yes || localtime_r=no
1224 enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1225
1226 # check for some common methods of building with pthread support
1227 # do this before the optional library checks as some of them require pthreads
1228 if enabled pthreads; then
1229     { check_cflags -pthread && check_ldflags -pthread; } ||
1230     { check_cflags -pthreads && check_ldflags -pthreads; } ||
1231     check_lib pthread.h pthread_create -lpthread ||
1232     check_func pthread_create ||
1233     die "ERROR: can't find pthreads library"
1234 fi
1235
1236 # these are off by default, so fail if requested and not available
1237 enabled dts     && require libdts dts.h dts_init -ldts
1238 enabled libgsm  && require libgsm gsm.h gsm_create -lgsm
1239 enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame
1240 enabled vorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc
1241 enabled libogg  && require libogg ogg/ogg.h ogg_sync_init -logg
1242 enabled theora  && require libtheora theora/theora.h theora_info_init -ltheora
1243 enabled xvid    && require XviD xvid.h xvid_global -lxvidcore
1244 enabled x264    && require x264 x264.h x264_encoder_open -lx264
1245 enabled dc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1246 enabled sunmlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1247
1248 # Ugh, faac uses stdcall calling convention on win32 so we can't use
1249 # the generic test functions
1250 if enabled faac; then
1251     save_flags
1252     temp_extralibs -lfaac
1253     check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
1254 #include <stdint.h>
1255 #include <faac.h>
1256 int main(){
1257     char *id, *cpr;
1258     faacEncGetVersion(&id, &cpr);
1259     return 0;
1260 }
1261 EOF
1262     restore_flags
1263 fi
1264
1265 # Ugh, recent faad2 versions have renamed all functions and #define the
1266 # old names in faad.h.  Generic tests won't work.
1267 if enabled faad; then
1268     save_flags
1269     temp_extralibs -lfaad
1270     check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
1271 #include <faad.h>
1272 int main(){
1273     faacDecOpen();
1274     return 0;
1275 }
1276 EOF
1277     restore_flags
1278 fi
1279
1280 # test for lrintf in math.h
1281 check_exec <<EOF && have_lrintf=yes || have_lrintf=no
1282 #define _ISOC9X_SOURCE  1
1283 #include <math.h>
1284 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1285 EOF
1286
1287 _restrict=
1288 for restrict_keyword in restrict __restrict__ __restrict; do
1289     check_cc <<EOF && _restrict=$restrict_keyword && break
1290 void foo(char * $restrict_keyword p);
1291 EOF
1292 done
1293
1294 # dlopen/dlfcn.h probing
1295
1296 check_header dlfcn.h && dlfcn=yes
1297
1298 temp_extralibs -ldl
1299 if check_func dlopen; then
1300     dlopen=yes
1301     ldl=-ldl
1302 fi
1303 restore_flags
1304
1305 if check_func dlopen; then
1306     dlopen=yes
1307     ldl=
1308 fi
1309
1310 if test "$vhook" = "default"; then
1311     vhook="$dlopen"
1312 fi
1313
1314 if test "$vhook" = "yes" -o "$a52bin" = "yes" -o "$faadbin" = "yes"; then
1315     add_extralibs $ldl
1316 fi
1317
1318 if enabled vhook; then
1319     check_ldflags -rdynamic
1320     check_ldflags -export-dynamic
1321 fi
1322
1323 ##########################################
1324 # imlib check
1325
1326 temp_extralibs -lImlib2
1327 check_ld <<EOF && imlib2=yes || imlib2=no
1328 #include <X11/Xlib.h>
1329 #include <Imlib2.h>
1330 int main( void ) { return (int) imlib_load_font("foo"); }
1331 EOF
1332 restore_flags
1333
1334 ##########################################
1335 # FreeType check
1336
1337 freetype2=no
1338 if test "x$targetos" != "xBeOS"; then
1339   if (freetype-config --version) >/dev/null 2>&1 ; then
1340       temp_cflags `freetype-config --cflags`
1341       temp_extralibs `freetype-config --libs`
1342       check_ld <<EOF && freetype2=yes
1343 #include <ft2build.h>
1344 int main( void ) { return (int) FT_Init_FreeType(0); }
1345 EOF
1346       restore_flags
1347   fi
1348 fi
1349
1350 ##########################################
1351 # SDL check
1352
1353 sdl_too_old=no
1354 sdl=no
1355 SDL_CONFIG="${cross_prefix}sdl-config"
1356 if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
1357     temp_cflags `"${SDL_CONFIG}" --cflags`
1358     temp_extralibs `"${SDL_CONFIG}" --libs`
1359     check_ld <<EOF
1360 #include <SDL.h>
1361 #undef main /* We don't want SDL to override our main() */
1362 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1363 EOF
1364     if test $? = 0; then
1365         _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1366         if test "$_sdlversion" -lt 121 ; then
1367             sdl_too_old=yes
1368         else
1369             sdl=yes
1370             check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
1371 #include <SDL.h>
1372 int main(void){
1373     const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1374     int w = vi->current_w;
1375     return 0;
1376 }
1377 EOF
1378         fi
1379     fi
1380     restore_flags
1381 fi
1382
1383 enabled sdl || ffplay=no
1384
1385 ##########################################
1386 # texi2html check
1387
1388 texi2html=no
1389 if (texi2html -version) >/dev/null 2>&1; then
1390 texi2html=yes
1391 fi
1392
1393 ##########################################
1394 # IPv6 check
1395
1396 enabled network && check_ld <<EOF && ipv6=yes || ipv6=no
1397 #include <sys/types.h>
1398 #include <sys/socket.h>
1399 #include <netinet/in.h>
1400 #include <netdb.h>
1401 int main( void ) {
1402   struct sockaddr_storage saddr;
1403   struct ipv6_mreq mreq6;
1404   getaddrinfo(0,0,0,0);
1405   getnameinfo(0,0,0,0,0,0,0);
1406   IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1407 }
1408 EOF
1409
1410 # check for video4linux2 --- V4L2_PIX_FMT_YUV420
1411 enabled v4l2 && check_cc <<EOF || v4l2="no"
1412 #include <sys/time.h>
1413 #include <asm/types.h>
1414 #include <linux/videodev2.h>
1415 int dummy = V4L2_PIX_FMT_YUV420;
1416 struct v4l2_buffer dummy1;
1417 EOF
1418
1419 enabled debug && add_cflags -g
1420
1421 # add some useful compiler flags if supported
1422 check_cflags -Wdeclaration-after-statement
1423 check_cflags -Wall
1424 check_cflags -Wno-switch
1425
1426 # add some linker flags
1427 check_ldflags '-Wl,--as-needed' '-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec' '-Wl,-rpath-link,\$(BUILD_ROOT)/libavformat' '-Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
1428
1429 # not all compilers support -Os
1430 test "$optimize" = "small" && check_cflags -Os
1431
1432 if enabled optimize; then
1433     if test -n "`$cc -v 2>&1 | grep xlc`"; then
1434         CFLAGS="$CFLAGS -O5"
1435         LDFLAGS="$LDFLAGS -O5"
1436     else
1437         CFLAGS="-O3 $CFLAGS"
1438     fi
1439 fi
1440
1441 # PIC flags for shared library objects where they are needed
1442 if test "$lshared" = "yes" ; then
1443     # LIBOBJFLAGS may have already been set in the OS configuration
1444     if test -z "$LIBOBJFLAGS" ; then
1445         case "$cpu" in
1446             x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
1447         esac
1448     fi
1449 fi
1450
1451 if test x"$bindir" = x""; then
1452     bindir="${prefix}/bin"
1453 fi
1454
1455 if test x"$libdir" = x""; then
1456     libdir="${prefix}/lib"
1457 fi
1458
1459 if test x"$incdir" = x""; then
1460     incdir="${prefix}/include/ffmpeg"
1461 fi
1462
1463 if test x"$mandir" = x""; then
1464     mandir="${prefix}/man"
1465 fi
1466
1467 echo "install prefix   $prefix"
1468 echo "source path      $source_path"
1469 echo "C compiler       $cc"
1470 echo "make             $make"
1471 echo "CPU              $cpu ($tune)"
1472 if test "$BUILDSUF" != ""; then
1473     echo "build suffix     $BUILDSUF"
1474 fi
1475 echo "big-endian       $bigendian"
1476 echo "inttypes.h       $inttypes"
1477 echo "broken inttypes.h $emu_fast_int"
1478 if test $cpu = "x86" -o $cpu = "x86_64"; then
1479     echo "MMX enabled      $mmx"
1480     echo "Vector Builtins  $builtin_vector"
1481     echo "3DNow! Builtins  $mm3dnow"
1482 fi
1483 if test $cpu = "armv4l"; then
1484     echo "IWMMXT enabled   $iwmmxt"
1485 fi
1486 if test $cpu = "mips"; then
1487     echo "MMI enabled      $mmi"
1488 fi
1489 if test $cpu = "powerpc"; then
1490     echo "AltiVec enabled  $altivec"
1491 fi
1492 echo "gprof enabled    $gprof"
1493 echo "zlib enabled     $zlib"
1494 echo "libgsm enabled   $libgsm"
1495 echo "mp3lame enabled  $mp3lame"
1496 echo "libogg enabled   $libogg"
1497 echo "Vorbis enabled   $vorbis"
1498 echo "Theora enabled   $theora"
1499 echo "FAAD enabled     $faad"
1500 echo "faadbin enabled  $faadbin"
1501 echo "FAAC enabled     $faac"
1502 echo "XviD enabled     $xvid"
1503 echo "x264 enabled     $x264"
1504 echo "a52 support      $a52"
1505 echo "a52 dlopened     $a52bin"
1506 echo "DTS support      $dts"
1507 echo "pp support       $pp"
1508 echo "debug symbols    $debug"
1509 echo "strip symbols    $dostrip"
1510 echo "optimize         $optimize"
1511 echo "static           $lstatic"
1512 echo "shared           $lshared"
1513 echo "video hooking    $vhook"
1514 echo "SDL support      $sdl"
1515 if test $sdl_too_old = "yes"; then
1516     echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1517 fi
1518
1519 if test "$vhook" = "yes"; then
1520     echo "Imlib2 support   $imlib2"
1521     echo "FreeType support $freetype2"
1522 fi
1523 echo "Sun medialib support"  $sunmlib
1524 echo "pthreads support"      $pthreads
1525 echo "AMR-NB float support"  $amr_nb
1526 echo "AMR-NB fixed support"  $amr_nb_fixed
1527 echo "AMR-WB float support"  $amr_wb
1528 echo "AMR-WB IF2 support"    $amr_if2
1529 echo "network support      $network"
1530 if test "$network" = "yes" ; then
1531     echo "IPv6 support         $ipv6"
1532 fi
1533 if test "$gpl" = "no" ; then
1534     echo "License: LGPL"
1535 else
1536     echo "License: GPL"
1537 fi
1538
1539 echo "Creating config.mak and config.h..."
1540
1541 date >> config.log
1542 echo "   $0 $FFMPEG_CONFIGURATION" >> config.log
1543 echo "# Automatically generated by configure - do not modify!" > config.mak
1544 echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1545 echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
1546
1547 echo "prefix=\$(DESTDIR)$prefix" >> config.mak
1548 echo "libdir=\$(DESTDIR)$libdir" >> config.mak
1549 echo "incdir=\$(DESTDIR)$incdir" >> config.mak
1550 echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1551 echo "mandir=\$(DESTDIR)$mandir" >> config.mak
1552 echo "MAKE=$make" >> config.mak
1553 echo "CC=$cc" >> config.mak
1554 echo "AR=$ar" >> config.mak
1555 echo "RANLIB=$ranlib" >> config.mak
1556 if test "$dostrip" = "yes" ; then
1557     echo "STRIP=$strip" >> config.mak
1558     echo "INSTALLSTRIP=$installstrip" >> config.mak
1559 else
1560     echo "STRIP=echo ignoring strip" >> config.mak
1561     echo "INSTALLSTRIP=" >> config.mak
1562 fi
1563
1564 # SHCFLAGS is a copy of CFLAGS without -mdynamic-no-pic, used when building
1565 # shared modules on OS/X (vhook/Makefile).
1566 SHCFLAGS="$CFLAGS"
1567 test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
1568
1569 echo "OPTFLAGS=$CFLAGS" >> config.mak
1570 echo "SHCFLAGS=$SHCFLAGS">>config.mak
1571 echo "LDFLAGS=$LDFLAGS" >> config.mak
1572 echo "LDCONFIG=$LDCONFIG" >> config.mak
1573 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
1574 echo "SHFLAGS=$SHFLAGS" >> config.mak
1575 echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1576 echo "BUILD_STATIC=$lstatic" >> config.mak
1577 echo "BUILDSUF=$BUILDSUF" >> config.mak
1578 echo "LIBPREF=$LIBPREF" >> config.mak
1579 echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1580 if test "$lstatic" = "yes" ; then
1581   echo "LIB=$LIB" >> config.mak
1582 else # Some Make complain if this variable does not exist.
1583   echo "LIB=" >> config.mak
1584 fi
1585 echo "SLIBPREF=$SLIBPREF" >> config.mak
1586 echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1587 echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1588 echo "TARGET_OS=$TARGET_OS" >> config.mak
1589 if test "$cpu" = "x86" ; then
1590   echo "TARGET_ARCH_X86=yes" >> config.mak
1591   echo "#define ARCH_X86 1" >> $TMPH
1592 elif test "$cpu" = "x86_64" ; then
1593   echo "TARGET_ARCH_X86_64=yes" >> config.mak
1594   echo "#define ARCH_X86_64 1" >> $TMPH
1595 elif test "$cpu" = "armv4l" ; then
1596   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
1597   echo "#define ARCH_ARMV4L 1" >> $TMPH
1598 elif test "$cpu" = "alpha" ; then
1599   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
1600   echo "#define ARCH_ALPHA 1" >> $TMPH
1601 elif test "$cpu" = "sparc64" ; then
1602   echo "TARGET_ARCH_SPARC64=yes" >> config.mak
1603   echo "#define ARCH_SPARC64 1" >> $TMPH
1604   echo "TARGET_ARCH_SPARC=yes" >> config.mak
1605   echo "#define ARCH_SPARC 1" >> $TMPH
1606 elif test "$cpu" = "sparc" ; then
1607   echo "TARGET_ARCH_SPARC=yes" >> config.mak
1608   echo "#define ARCH_SPARC 1" >> $TMPH
1609 elif test "$cpu" = "powerpc" ; then
1610   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
1611   echo "#define ARCH_POWERPC 1" >> $TMPH
1612   if test $POWERPCMODE = "32bits"; then
1613     echo "#define POWERPC_MODE_32BITS 1" >> $TMPH
1614   else
1615     echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1616   fi
1617   if test "$powerpc_perf" = "yes"; then
1618     echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
1619   fi
1620 elif test "$cpu" = "mips" ; then
1621   echo "TARGET_ARCH_MIPS=yes" >> config.mak
1622   echo "#define ARCH_MIPS 1" >> $TMPH
1623 elif test "$cpu" = "sh4" ; then
1624   echo "TARGET_ARCH_SH4=yes" >> config.mak
1625   echo "#define ARCH_SH4 1" >> $TMPH
1626 elif test "$cpu" = "parisc" ; then
1627   echo "TARGET_ARCH_PARISC=yes" >> config.mak
1628   echo "#define ARCH_PARISC 1" >> $TMPH
1629 elif test "$cpu" = "s390" ; then
1630   echo "TARGET_ARCH_S390=yes" >> config.mak
1631   echo "#define ARCH_S390 1" >> $TMPH
1632 elif test "$cpu" = "m68k" ; then
1633   echo "TARGET_ARCH_M68K=yes" >> config.mak
1634   echo "#define ARCH_M68K 1" >> $TMPH
1635 elif test "$cpu" = "ia64" ; then
1636   echo "TARGET_ARCH_IA64=yes" >> config.mak
1637   echo "#define ARCH_IA64 1" >> $TMPH
1638 fi
1639 echo "#define TUNECPU $TUNECPU" >> $TMPH
1640 if test "$bigendian" = "yes" ; then
1641   echo "WORDS_BIGENDIAN=yes" >> config.mak
1642   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1643 fi
1644 if test "$inttypes" != "yes" ; then
1645   echo "#define EMULATE_INTTYPES 1" >> $TMPH
1646 fi
1647 if test "$emu_fast_int" = "yes" ; then
1648   echo "#define EMULATE_FAST_INT 1" >> $TMPH
1649 fi
1650 if test "$mmx" = "yes" ; then
1651   echo "TARGET_MMX=yes" >> config.mak
1652   echo "#define HAVE_MMX 1" >> $TMPH
1653   echo "#define __CPU__ 586" >> $TMPH
1654 fi
1655 if test "$builtin_vector" = "yes" ; then
1656   echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
1657   echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
1658 fi
1659 if test "$mm3dnow" = "yes" ; then
1660   echo "TARGET_BUILTIN_3DNOW=yes" >> config.mak
1661   echo "#define HAVE_MM3DNOW 1" >> $TMPH
1662 fi
1663 if test "$iwmmxt" = "yes" ; then
1664   echo "TARGET_IWMMXT=yes" >> config.mak
1665   echo "#define HAVE_IWMMXT 1" >> $TMPH
1666 fi
1667 if test "$mmi" = "yes" ; then
1668   echo "TARGET_MMI=yes" >> config.mak
1669   echo "#define HAVE_MMI 1" >> $TMPH
1670 fi
1671 if test "$altivec" = "yes" ; then
1672   echo "TARGET_ALTIVEC=yes" >> config.mak
1673   echo "#define HAVE_ALTIVEC 1" >> $TMPH
1674   echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
1675   echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
1676   if test "$_altivec_h" = "yes" ; then
1677     echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
1678   else
1679     echo "#undef HAVE_ALTIVEC_H" >> $TMPH
1680   fi
1681 fi
1682 if test "$gprof" = "yes" ; then
1683   echo "TARGET_GPROF=yes" >> config.mak
1684   echo "#define HAVE_GPROF 1" >> $TMPH
1685 fi
1686 if test "$localtime_r" = "yes" ; then
1687   echo "#define HAVE_LOCALTIME_R 1" >> $TMPH
1688 fi
1689 if test "$imlib2" = "yes" ; then
1690   echo "HAVE_IMLIB2=yes" >> config.mak
1691 fi
1692 if test "$freetype2" = "yes" ; then
1693   echo "HAVE_FREETYPE2=yes" >> config.mak
1694 fi
1695 if test "$sunmlib" = "yes" ; then
1696   echo "HAVE_MLIB=yes" >> config.mak
1697   echo "#define HAVE_MLIB 1" >> $TMPH
1698 fi
1699 if test "$pthreads" = "yes" ; then
1700   echo "HAVE_PTHREADS=yes" >> config.mak
1701   echo "#define HAVE_PTHREADS 1" >> $TMPH
1702   echo "#define HAVE_THREADS 1" >> $TMPH
1703 fi
1704 if test "$sdl" = "yes" ; then
1705   echo "CONFIG_SDL=yes" >> config.mak
1706   echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1707   echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1708   if test "$sdl_video_size" = "yes"; then
1709     echo "#define HAVE_SDL_VIDEO_SIZE 1" >> $TMPH
1710   fi
1711 fi
1712 if test "$texi2html" = "yes"; then
1713   echo "BUILD_DOC=yes" >> config.mak
1714 fi
1715 if test "$have_lrintf" = "yes" ; then
1716   echo "#define HAVE_LRINTF 1" >> $TMPH
1717 fi
1718 if test "$vhook" = "yes" ; then
1719   echo "BUILD_VHOOK=yes" >> config.mak
1720   echo "#define HAVE_VHOOK 1" >> $TMPH
1721 fi
1722
1723 pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1724 lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1725 lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1726 lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1727
1728
1729
1730 if test "$lshared" = "yes" ; then
1731   echo "#define BUILD_SHARED_AV 1" >> $TMPH
1732   echo "BUILD_SHARED=yes" >> config.mak
1733   echo "PIC=-fPIC -DPIC" >> config.mak
1734   echo "SPPMAJOR=${lavc_version%%.*}" >> config.mak
1735   echo "SPPVERSION=$lavc_version" >> config.mak
1736   echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1737   echo "LAVCVERSION=$lavc_version" >> config.mak
1738   echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1739   echo "LAVFVERSION=$lavf_version" >> config.mak
1740   echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1741   echo "LAVUVERSION=$lavu_version" >> config.mak
1742   echo "SLIBNAME=${SLIBNAME}" >> config.mak
1743   echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1744   echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1745 fi
1746 echo "EXTRALIBS=$extralibs" >> config.mak
1747
1748 # If you do not want to use encoders, disable them.
1749 if echo "$CODEC_LIST" | grep -q encoder; then
1750     echo "#define CONFIG_ENCODERS 1" >> $TMPH
1751     echo "CONFIG_ENCODERS=yes" >> config.mak
1752 fi
1753
1754 # If you do not want to use decoders, disable them.
1755 if echo "$CODEC_LIST" | grep -q decoder; then
1756     echo "#define CONFIG_DECODERS 1" >> $TMPH
1757     echo "CONFIG_DECODERS=yes" >> config.mak
1758 fi
1759
1760 # muxers
1761 if test "$muxers" = "yes" ; then
1762   echo "#define CONFIG_MUXERS 1" >> $TMPH
1763   echo "CONFIG_MUXERS=yes" >> config.mak
1764 fi
1765
1766 # demuxers
1767 if test "$demuxers" = "yes" ; then
1768   echo "#define CONFIG_DEMUXERS 1" >> $TMPH
1769   echo "CONFIG_DEMUXERS=yes" >> config.mak
1770 fi
1771
1772 # AC3
1773 if test "$a52" = "yes" ; then
1774   echo "#define CONFIG_AC3 1" >> $TMPH
1775   echo "CONFIG_AC3=yes" >> config.mak
1776
1777   if test "$a52bin" = "yes" ; then
1778     echo "#define CONFIG_A52BIN 1" >> $TMPH
1779     echo "CONFIG_A52BIN=yes" >> config.mak
1780   fi
1781 fi
1782
1783 # DTS
1784 if test "$dts" = "yes" ; then
1785   echo "#define CONFIG_DTS 1" >> $TMPH
1786   echo "CONFIG_DTS=yes" >> config.mak
1787 fi
1788
1789 # PP
1790 if test "$pp" = "yes" ; then
1791   echo "#define CONFIG_PP 1" >> $TMPH
1792   echo "CONFIG_PP=yes" >> config.mak
1793 fi
1794
1795 # MPEG audio high precision mode
1796 if test "$mpegaudio_hp" = "yes" ; then
1797   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
1798 fi
1799
1800 if test "$v4l" = "yes" ; then
1801   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
1802   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
1803 fi
1804
1805 if test "$v4l2" = "yes" ; then
1806   echo "#define CONFIG_VIDEO4LINUX2 1" >> $TMPH
1807   echo "CONFIG_VIDEO4LINUX2=yes" >> config.mak
1808 fi
1809
1810 if test "$bktr" = "yes" ; then
1811   echo "#define CONFIG_BKTR 1" >> $TMPH
1812   echo "CONFIG_BKTR=yes" >> config.mak
1813 fi
1814
1815 if test "$dv1394" = "yes" ; then
1816   echo "#define CONFIG_DV1394 1" >> $TMPH
1817   echo "CONFIG_DV1394=yes" >> config.mak
1818 fi
1819
1820 if test "$dc1394" = "yes" ; then
1821   echo "#define CONFIG_DC1394 1" >> $TMPH
1822   echo "CONFIG_DC1394=yes" >> config.mak
1823 fi
1824
1825 if test "$dlopen" = "yes" ; then
1826   echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
1827 fi
1828
1829 if test "$dlfcn" = "yes" ; then
1830   echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
1831 fi
1832
1833 if test "$audio_oss" = "yes" ; then
1834   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
1835   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
1836 fi
1837
1838 if test "$audio_beos" = "yes" ; then
1839   echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
1840   echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
1841 fi
1842
1843 if test "$network" = "yes" ; then
1844   echo "#define CONFIG_NETWORK 1" >> $TMPH
1845   echo "CONFIG_NETWORK=yes" >> config.mak
1846 fi
1847
1848 if test "$ipv6" = "yes" ; then
1849   echo "#define CONFIG_IPV6 1" >> $TMPH
1850 fi
1851
1852 if test "$zlib" = "yes" ; then
1853   echo "#define CONFIG_ZLIB 1" >> $TMPH
1854   echo "CONFIG_ZLIB=yes" >> config.mak
1855 fi
1856
1857 if test "$libgsm" = "yes" ; then
1858   echo "#define CONFIG_LIBGSM 1" >> $TMPH
1859   echo "CONFIG_LIBGSM=yes" >> config.mak
1860 fi
1861
1862 if test "$mp3lame" = "yes" ; then
1863   echo "#define CONFIG_MP3LAME 1" >> $TMPH
1864   echo "CONFIG_MP3LAME=yes" >> config.mak
1865 fi
1866
1867 if test "$libogg" = "yes" ; then
1868   echo "#define CONFIG_LIBOGG 1" >> $TMPH
1869   echo "CONFIG_LIBOGG=yes" >> config.mak
1870 fi
1871
1872 if test "$vorbis" = "yes" ; then
1873   echo "#define CONFIG_LIBVORBIS 1" >> $TMPH
1874   echo "CONFIG_LIBVORBIS=yes" >> config.mak
1875 fi
1876
1877 if test "$theora" = "yes" ; then
1878   echo "#define CONFIG_LIBTHEORA 1" >> $TMPH
1879   echo "CONFIG_LIBTHEORA=yes" >> config.mak
1880 fi
1881
1882 if test "$faad" = "yes" ; then
1883   echo "#define CONFIG_FAAD 1" >> $TMPH
1884   echo "CONFIG_FAAD=yes" >> config.mak
1885 fi
1886
1887 if test "$faadbin" = "yes" ; then
1888   echo "#define CONFIG_FAADBIN 1" >> $TMPH
1889   echo "CONFIG_FAADBIN=yes" >> config.mak
1890 fi
1891
1892 if test "$faac" = "yes" ; then
1893   echo "#define CONFIG_FAAC 1" >> $TMPH
1894   echo "CONFIG_FAAC=yes" >> config.mak
1895 fi
1896
1897 if test "$xvid" = "yes" ; then
1898   echo "#define CONFIG_XVID 1" >> $TMPH
1899   echo "CONFIG_XVID=yes" >> config.mak
1900 fi
1901
1902 if test "$x264" = "yes" ; then
1903   echo "#define CONFIG_X264 1" >> $TMPH
1904   echo "CONFIG_X264=yes" >> config.mak
1905 fi
1906
1907 if test "$mingw32" = "yes" ; then
1908   echo "#define CONFIG_WIN32 1" >> $TMPH
1909   echo "CONFIG_WIN32=yes" >> config.mak
1910   echo "HAVE_W32THREADS=yes" >> config.mak
1911   echo "#define HAVE_W32THREADS 1" >> $TMPH
1912   echo "#define HAVE_THREADS 1" >> $TMPH
1913   echo "#ifndef __MINGW32__" >> $TMPH
1914   echo "#define __MINGW32__ 1" >> $TMPH
1915   echo "#endif" >> $TMPH
1916 fi
1917
1918 if test "$mingwce" = "yes" ; then
1919   echo "#define CONFIG_WIN32 1" >> $TMPH
1920   echo "CONFIG_WIN32=yes" >> config.mak
1921   echo "#define CONFIG_WINCE 1" >> $TMPH
1922   echo "CONFIG_WINCE=yes" >> config.mak
1923   echo "#ifndef __MINGW32__" >> $TMPH
1924   echo "#define __MINGW32__ 1" >> $TMPH
1925   echo "#endif" >> $TMPH
1926 fi
1927
1928 if test "$os2" = "yes" ; then
1929   echo "#define CONFIG_OS2 1" >> $TMPH
1930   echo "CONFIG_OS2=yes" >> config.mak
1931   echo "HAVE_OS2THREADS=yes" >> config.mak
1932   echo "#define HAVE_OS2THREADS 1" >> $TMPH
1933   echo "#define HAVE_THREADS 1" >> $TMPH
1934 fi
1935
1936 if test "$TARGET_OS" = "SunOS" ; then
1937   echo "#define CONFIG_SUNOS 1" >> $TMPH
1938 fi
1939
1940 if test "$TARGET_OS" = "BeOS" ; then
1941   echo "HAVE_BEOSTHREADS=yes" >> config.mak
1942   echo "#define HAVE_BEOSTHREADS 1" >> $TMPH
1943   echo "#define HAVE_THREADS 1" >> $TMPH
1944 fi
1945
1946 if test "$darwin" = "yes"; then
1947   echo "#define CONFIG_DARWIN 1"  >> $TMPH
1948   echo "CONFIG_DARWIN=yes" >> config.mak
1949 fi
1950
1951 if test "$_malloc_h" = "yes" ; then
1952   echo "#define HAVE_MALLOC_H 1" >> $TMPH
1953 else
1954   echo "#undef  HAVE_MALLOC_H" >> $TMPH
1955 fi
1956
1957 if test "$_memalign" = "yes" ; then
1958   echo "#define HAVE_MEMALIGN 1" >> $TMPH
1959 else
1960   echo "#undef  HAVE_MEMALIGN" >> $TMPH
1961 fi
1962
1963 if test "$memalignhack" = "yes" ; then
1964   echo "#define MEMALIGN_HACK 1" >> $TMPH
1965 fi
1966
1967
1968 if test "$netserver" = "yes" ; then
1969   echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
1970   echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
1971 fi
1972
1973 if test "$need_inet_aton" = "yes" ; then
1974   echo "NEED_INET_ATON=yes" >> config.mak
1975 fi
1976
1977 if test "$simpleidct" = "yes" ; then
1978   echo "#define SIMPLE_IDCT 1" >> $TMPH
1979 fi
1980
1981 if test "$protocols" = "yes" ; then
1982   echo "#define CONFIG_PROTOCOLS 1" >> $TMPH
1983   echo "CONFIG_PROTOCOLS=yes" >> config.mak
1984 fi
1985
1986 if test "$ffserver" = "yes" ; then
1987   echo "#define CONFIG_FFSERVER 1" >> $TMPH
1988   echo "CONFIG_FFSERVER=yes" >> config.mak
1989 fi
1990
1991 if test "$ffplay" = "yes" ; then
1992   echo "CONFIG_FFPLAY=yes" >> config.mak
1993 fi
1994
1995 if test "$gpl" = "yes" ; then
1996   echo "#define CONFIG_GPL 1" >> $TMPH
1997   echo "CONFIG_GPL=yes" >> config.mak
1998 fi
1999
2000 echo "#define restrict $_restrict" >> $TMPH
2001
2002 if test "$optimize" = "small"; then
2003   echo "#define always_inline"  >> $TMPH
2004   echo "#define CONFIG_SMALL 1" >> $TMPH
2005 fi
2006
2007 # build tree in object directory if source path is different from current one
2008 if test "$source_path_used" = "yes" ; then
2009     DIRS="\
2010          doc \
2011          libavformat \
2012          libavcodec \
2013          libavcodec/alpha \
2014          libavcodec/armv4l \
2015          libavcodec/i386 \
2016          libavcodec/sparc \
2017          libavcodec/mlib \
2018          libavcodec/ppc \
2019          libavcodec/liba52 \
2020          libpostproc \
2021          libavutil \
2022          tests \
2023          vhook \
2024          "
2025     FILES="\
2026           Makefile \
2027           libavformat/Makefile \
2028           libavcodec/Makefile \
2029           libpostproc/Makefile \
2030           libavutil/Makefile \
2031           tests/Makefile \
2032           vhook/Makefile \
2033           doc/Makefile \
2034           doc/texi2pod.pl \
2035           "
2036     for dir in $DIRS ; do
2037             mkdir -p $dir
2038     done
2039     for f in $FILES ; do
2040         ln -sf "$source_path/$f" $f
2041     done
2042 fi
2043 echo "SRC_PATH=$source_path" >> config.mak
2044 echo "BUILD_ROOT=$PWD" >> config.mak
2045
2046 if test "$amr" = "yes" ; then
2047   echo "#define AMR 1" >> $TMPH
2048   echo "AMR=yes" >> config.mak
2049 fi
2050
2051 if test "$amr_wb" = "yes" ; then
2052   echo "#define AMR_WB 1" >> $TMPH
2053   echo "AMR_WB=yes" >> config.mak
2054   echo
2055   echo "AMR WB FLOAT NOTICE ! Make sure you have downloaded TS26.204"
2056   echo "V5.1.0 from "
2057   echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip"
2058   echo "and extracted the source to libavcodec/amrwb_float"
2059 fi
2060
2061 if test "$amr_nb" = "yes" ; then
2062   echo "#define AMR_NB 1" >> $TMPH
2063   echo "AMR_NB=yes" >> config.mak
2064   echo
2065   echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
2066   echo "REL-5 V5.1.0 from "
2067   echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip"
2068   echo "and extracted the source to libavcodec/amr_float"
2069   echo "If you try this on alpha, you may need to change Word32 to int in amr/typedef.h"
2070 fi
2071
2072 if test "$amr_nb_fixed" = "yes" ; then
2073   echo "#define AMR_NB_FIXED 1" >> $TMPH
2074   echo "AMR_NB_FIXED=yes" >> config.mak
2075   echo
2076   echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
2077   echo "REL-5 version 5.1.0 from "
2078   echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip"
2079   echo "and extracted src to libavcodec/amr"
2080   echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
2081   echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
2082 fi
2083
2084 if test "$amr_if2" = "yes" ; then
2085   echo "AMR_CFLAGS=-DIF2=1" >> config.mak
2086 fi
2087
2088
2089 for codec in $CODEC_LIST $PARSER_LIST; do
2090     echo "#define CONFIG_`echo $codec | tr a-z A-Z` 1" >> $TMPH
2091     echo "CONFIG_`echo $codec | tr a-z A-Z`=yes" >> config.mak
2092 done
2093
2094 # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2095 diff $TMPH config.h >/dev/null 2>&1
2096 if test "$?" != "0" ; then
2097         mv -f $TMPH config.h
2098 else
2099         echo "config.h is unchanged"
2100 fi
2101
2102 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2103
2104
2105 # build pkg-config files libav*.pc and libpostproc.pc
2106 # libavutil.pc
2107 cat <<EOF >libavutil.pc
2108 prefix=$prefix
2109 exec_prefix=\${prefix}
2110 libdir=\${exec_prefix}/lib
2111 includedir=\${prefix}/include
2112
2113 Name: libavutil
2114 Description: FFmpeg utility library
2115 Version: $lavu_version
2116 Requires:
2117 Conflicts:
2118 Libs: -L\${libdir} -lavutil
2119 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2120 EOF
2121
2122 cat <<EOF >libavutil-uninstalled.pc
2123 prefix=
2124 exec_prefix=
2125 libdir=\${pcfiledir}/libavutil
2126 includedir=\${pcfiledir}/libavutil
2127
2128 Name: libavutil
2129 Description: FFmpeg utility library
2130 Version: $lavu_version
2131 Requires:
2132 Conflicts:
2133 Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
2134 Cflags: -I\${includedir}
2135 EOF
2136
2137 # libavcodec.pc
2138 cat <<EOF >libavcodec.pc
2139 prefix=$prefix
2140 exec_prefix=\${prefix}
2141 libdir=\${exec_prefix}/lib
2142 includedir=\${prefix}/include
2143
2144 Name: libavcodec
2145 Description: FFmpeg codec library
2146 Version: $lavc_version
2147 Requires: $pkg_requires libavutil = $lavu_version
2148 Conflicts:
2149 Libs: -L\${libdir} -lavcodec $extralibs
2150 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2151 EOF
2152
2153 cat <<EOF >libavcodec-uninstalled.pc
2154 prefix=
2155 exec_prefix=
2156 libdir=\${pcfiledir}/libavcodec
2157 includedir=\${pcfiledir}/libavcodec
2158
2159 Name: libavcodec
2160 Description: FFmpeg codec library
2161 Version: $lavc_version
2162 Requires: $pkg_requires libavutil = $lavu_version
2163 Conflicts:
2164 Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
2165 Cflags: -I\${includedir}
2166 EOF
2167
2168 # libavformat.pc
2169 cat <<EOF >libavformat.pc
2170 prefix=$prefix
2171 exec_prefix=\${prefix}
2172 libdir=\${exec_prefix}/lib
2173 includedir=\${prefix}/include
2174
2175 Name: libavformat
2176 Description: FFmpeg container format library
2177 Version: $lavf_version
2178 Requires: $pkg_requires libavcodec = $lavc_version
2179 Conflicts:
2180 Libs: -L\${libdir} -lavformat $extralibs
2181 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2182 EOF
2183
2184 cat <<EOF >libavformat-uninstalled.pc
2185 prefix=
2186 exec_prefix=
2187 libdir=\${pcfiledir}/libavformat
2188 includedir=\${pcfiledir}/libavformat
2189
2190 Name: libavformat
2191 Description: FFmpeg container format library
2192 Version: $lavf_version
2193 Requires: $pkg_requires libavcodec = $lavc_version
2194 Conflicts:
2195 Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
2196 Cflags: -I\${includedir}
2197 EOF
2198
2199
2200 # libpostproc.pc
2201 cat <<EOF >libpostproc.pc
2202 prefix=$prefix
2203 exec_prefix=\${prefix}
2204 libdir=\${exec_prefix}/lib
2205 includedir=\${prefix}/include
2206
2207 Name: libpostproc
2208 Description: FFmpeg post processing library
2209 Version: $lavc_version
2210 Requires:
2211 Conflicts:
2212 Libs: -L\${libdir} -lpostproc
2213 Cflags: -I\${includedir} -I\${includedir}/postproc
2214 EOF
2215
2216 cat <<EOF >libpostproc-uninstalled.pc
2217 prefix=
2218 exec_prefix=
2219 libdir=\${pcfiledir}/libpostproc
2220 includedir=\${pcfiledir}/libpostproc
2221
2222 Name: libpostproc
2223 Description: FFmpeg post processing library
2224 Version: $lavc_version
2225 Requires:
2226 Conflicts:
2227 Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
2228 Cflags: -I\${includedir}
2229 EOF