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