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