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