]> git.sesse.net Git - ffmpeg/blob - configure
h263 alternative inter vlc support
[ffmpeg] / configure
1 #!/bin/sh
2 #
3 # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4 #
5
6 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
7 cat << EOF
8
9 Usage: configure [options]
10 Options: [defaults in brackets after descriptions]
11
12 EOF
13 echo "Standard options:"
14 echo "  --help                   print this message"
15 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
16 echo "  --mandir=DIR             man documentation in DIR [PREFIX/man]"
17 echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
18 echo "  --enable-vorbis          enable vorbis support via libvorbisenc [default=no]"
19 echo "  --enable-faad            enable faad support via libfaad [default=no]"
20 echo "  --enable-faadbin         build faad support with runtime linking [default=no]"
21 echo "  --enable-faac            enable faac support via libfaac [default=no]"
22 echo "  --enable-mingw32         enable mingw32 native/cross windows compile"
23 echo "  --enable-a52             enable GPL'ed A52 support [default=no]"
24 echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
25 echo "  --enable-pp              enable GPL'ed post processing support [default=no]"
26 echo "  --enable-shared-pp       use libpostproc.so [default=no]"
27 echo "  --enable-shared          build shared libraries [default=no]"
28 echo "  --enable-amr_nb          enable amr_nb float audio codec"
29 echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
30 echo "  --enable-sunmlib         use Sun medialib [default=no]"
31 echo ""
32 echo "Advanced options (experts only):"
33 echo "  --source-path=PATH       path of source code [$source_path]"
34 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
35 echo "  --cc=CC                  use C compiler CC [$cc]"
36 echo "  --make=MAKE              use specified make [$make]"
37 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
38 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
39 echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
40 echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
41 echo "  --tune=PROCESSOR         tune code for a particular CPU (may fails or misperforms on other CPUs)"
42 echo "  --powerpc-perf-enable    enable performance report on PPC (requires enabling PMC)"
43 echo "  --disable-mmx            disable mmx usage"
44 echo "  --disable-altivec        disable AltiVec usage"
45 echo "  --disable-audio-oss      disable OSS audio support [default=no]"
46 echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
47 echo "  --disable-v4l            disable video4linux grabbing [default=no]"
48 echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
49 echo "  --disable-network        disable network support [default=no]"
50 echo "  --disable-zlib           disable zlib [default=no]"
51 echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
52 echo "  --disable-vhook          disable video hooking support"
53 echo "  --enable-gprof           enable profiling with gprof [$gprof]"
54 echo "  --disable-debug          disable debugging symbols"
55 echo "  --disable-opts           disable compiler optimizations"
56 echo "  --disable-mpegaudio-hp   faster (but less accurate)"
57 echo "                           mpegaudio decoding [default=no]"
58 echo "  --disable-ffserver       disable ffserver build"
59 echo "  --disable-ffplay         disable ffplay build"
60 echo "  --disable-risky          disables patent encumbered codecs"
61 echo "  --enable-small           optimize for size instead of speed"
62 echo ""
63 echo "NOTE: The object files are build at the place where configure is launched"
64 exit 1
65 fi
66
67 # set temporary file name
68 if test ! -z "$TMPDIR" ; then
69     TMPDIR1="${TMPDIR}"
70 elif test ! -z "$TEMPDIR" ; then
71     TMPDIR1="${TEMPDIR}"
72 else
73     TMPDIR1="/tmp"
74 fi
75
76 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
77 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
78 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
79 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
80 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
81
82 # default parameters
83 prefix="/usr/local"
84 mandir=""
85 bindir=""
86 cross_prefix=""
87 cc="gcc"
88 ar="ar"
89 ranlib="ranlib"
90 make="make"
91 strip="strip"
92 cpu=`uname -m`
93 tune="generic"
94 powerpc_perf="no"
95 mmx="default"
96 altivec="default"
97 mmi="default"
98 case "$cpu" in
99   i386|i486|i586|i686|i86pc|BePC)
100     cpu="x86"
101   ;;
102   # armv4l is a subset of armv5tel
103   armv4l|armv5tel)
104     cpu="armv4l"
105   ;;
106   alpha)
107     cpu="alpha"
108   ;;
109   "Power Macintosh"|ppc)
110     cpu="powerpc"
111   ;;
112   mips)
113     cpu="mips"
114   ;;
115   sun4u)
116     cpu="sparc64"
117   ;;
118   sh4)
119     cpu="sh4"
120   ;;
121   *)
122     cpu="unknown"
123   ;;
124 esac
125 gprof="no"
126 v4l="yes"
127 audio_oss="yes"
128 audio_beos="no"
129 dv1394="yes"
130 network="yes"
131 zlib="yes"
132 mp3lame="no"
133 vorbis="no"
134 faad="no"
135 faadbin="no"
136 faac="no"
137 a52="no"
138 a52bin="no"
139 pp="no"
140 shared_pp="no"
141 mingw32="no"
142 cygwin="no"
143 os2="no"
144 lshared="no"
145 optimize="yes"
146 debug="yes"
147 extralibs="-lm"
148 simpleidct="yes"
149 bigendian="no"
150 emu_fast_int="no"
151 vhook="default"
152 dlfcn="no"
153 dlopen="no"
154 mpegaudio_hp="yes"
155 SHFLAGS=-shared
156 netserver="no"
157 need_inet_aton="no"
158 ffserver="yes"
159 ffplay="yes"
160 LDFLAGS=-Wl,--warn-common
161 FFSLDFLAGS=-Wl,-E
162 LIBPREF="lib"
163 LIBSUF=".a"
164 SLIBPREF="lib"
165 SLIBSUF=".so"
166 EXESUF=""
167 risky="yes"
168 amr_nb="no"
169 amr_wb="no"
170 amr_nb_fixed="no"
171 sunmlib="no"
172
173 # OS specific
174 targetos=`uname -s`
175 case $targetos in
176 BeOS)
177 prefix="/boot/home/config"
178 # helps building libavcodec
179 CFLAGS="-DPIC -fomit-frame-pointer"
180 # 3 gcc releases known for BeOS, each with ugly bugs
181 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
182 case "$gcc_version" in
183 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
184 mmx="no"
185 ;;
186 *20010315*) echo "BeBits gcc"
187 CFLAGS="$CFLAGS -fno-expensive-optimizations"
188 ;;
189 esac
190 SHFLAGS=-nostart
191 # disable linux things
192 audio_oss="no"
193 v4l="no"
194 dv1394="no"
195 # enable beos things
196 audio_beos="yes"
197 # no need for libm, but the inet stuff
198 # Check for BONE
199 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
200 extralibs="-lbind -lsocket"
201 else
202 netserver="yes"
203 need_inet_aton="yes"
204 extralibs="-lnet"
205 fi ;;
206 SunOS)
207 v4l="no"
208 audio_oss="no"
209 dv1394="no"
210 make="gmake"
211 LDFLAGS=""
212 FFSLDFLAGS=""
213 need_inet_aton="yes"
214 extralibs="$extralibs -lsocket -lnsl"
215 ;;
216 FreeBSD)
217 v4l="no"
218 audio_oss="yes"
219 dv1394="no"
220 make="gmake"
221 LDFLAGS="$LDFLAGS -export-dynamic"
222 ;;
223 BSD/OS)
224 v4l="no"
225 audio_oss="yes"
226 dv1394="no"
227 extralibs="-lpoll -lgnugetopt -lm"
228 make="gmake"
229 ;;
230 Darwin)
231 cc="cc"
232 v4l="no"
233 audio_oss="no"
234 dv1394="no"
235 ffserver="no"
236 SHFLAGS="-dynamiclib"
237 extralibs=""
238 darwin="yes"
239 strip="strip -x"
240 LDFLAGS="-d"
241 FFSLDFLAGS=-Wl,-bind_at_load
242 ;;
243 MINGW32*)
244 # Note: the rest of the mingw32 config is done afterwards as mingw32
245 # can be forced on command line for linux cross compilation
246 mingw32="yes"
247 ;;
248 CYGWIN*)
249 v4l="no"
250 audio_oss="yes"
251 dv1394="no"
252 extralibs=""
253 cygwin="yes"
254 test -f /usr/include/inttypes.h || \
255 test -f /usr/local/include/inttypes.h || \
256 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
257      "/usr/include/inttypes.h !!!"
258 ;;
259 Linux)
260 LDFLAGS="$LDFLAGS -rdynamic"
261 ;;
262 IRIX*)
263 ranlib="echo ignoring ranlib"
264 v4l="no"
265 audio_oss="no"
266 make="gmake"
267 ;;
268 OS/2)
269 TMPE=$TMPE".exe"
270 ar="emxomfar -p64"
271 ranlib="echo ignoring ranlib"
272 strip="echo ignoring strip"
273 CFLAGS="-Zomf"
274 LDFLAGS="-Zomf -Zstack 16384 -s"
275 SHFLAGS=""
276 FFSLDFLAGS=""
277 LIBPREF=""
278 LIBSUF=".lib"
279 SLIBPREF=""
280 SLIBSUF=".dll"
281 EXESUF=".exe"
282 extralibs=""
283 v4l="no"
284 audio_oss="no"
285 dv1394="no"
286 network="no"
287 ffserver="no"
288 os2="yes"
289 ;;
290 *) ;;
291 esac
292
293 # From mplayer configure. We need TARGET_OS available
294 # to the Makefile, so it can distinguish between flavors
295 # of AltiVec on PowerPC
296 TARGET_OS=`( uname -s ) 2>&1`
297   case "$TARGET_OS" in
298   Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
299     ;;
300   IRIX*)
301     TARGET_OS=IRIX
302     ;;
303   HP-UX*)
304     TARGET_OS=HP-UX
305     ;;
306   [cC][yY][gG][wW][iI][nN]*)
307     TARGET_OS=CYGWIN
308     ;;
309   *)
310     TARGET_OS="$TARGET_OS-UNKNOWN"
311     ;;
312   esac
313
314 # find source path
315 # XXX: we assume an absolute path is given when launching configure, 
316 # except in './configure' case.
317 source_path="`echo $0 | sed -e 's#/configure##'`"
318 source_path_used="yes"
319 if test -z "$source_path" -o "$source_path" = "." ; then
320     source_path=`pwd`
321     source_path_used="no"
322 fi
323
324 for opt do
325   case "$opt" in
326   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
327   ;;
328   --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
329   ;;
330   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
331   ;;
332   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
333   ;;
334   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
335   ;;
336   --make=*) make=`echo $opt | cut -d '=' -f 2`
337   ;;
338   --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
339   ;;
340   --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
341   ;;
342   --extra-libs=*) extralibs=${opt#--extra-libs=}
343   ;;
344   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
345   ;;
346   --tune=*) tune=`echo $opt | cut -d '=' -f 2`
347   ;;
348   --powerpc-perf-enable) powerpc_perf="yes"
349   ;;
350   --disable-mmx) mmx="no"
351   ;;
352   --disable-altivec) altivec="no"
353   ;;
354   --enable-gprof) gprof="yes"
355   ;;
356   --disable-v4l) v4l="no"
357   ;;
358   --disable-audio-oss) audio_oss="no"
359   ;;
360   --disable-audio-beos) audio_beos="no"
361   ;;
362   --disable-dv1394) dv1394="no"
363   ;;
364   --disable-network) network="no"
365   ;;
366   --disable-zlib) zlib="no"
367   ;;
368   --enable-a52) a52="yes"
369   ;;
370   --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
371   ;;
372   --enable-pp) pp="yes"
373   ;;
374   --enable-shared-pp) shared_pp="yes"
375   ;;
376   --enable-mp3lame) mp3lame="yes"
377   ;;
378   --enable-vorbis) vorbis="yes"
379   ;;
380   --enable-faad) faad="yes"
381   ;;
382   --enable-faadbin) faadbin="yes"
383   ;;
384   --enable-faac) faac="yes"
385   ;;
386   --disable-vhook) vhook="no"
387   ;;
388   --disable-simple_idct) simpleidct="no"
389   ;;
390   --enable-mingw32) mingw32="yes"
391   ;;
392   --enable-shared) lshared="yes"
393   ;;
394   --disable-debug) debug="no"
395   ;;
396   --disable-opts) optimize="no"
397   ;;
398   --disable-mpegaudio-hp) mpegaudio_hp="no"
399   ;;
400   --disable-ffserver) ffserver="no"
401   ;;
402   --disable-ffplay) ffplay="no"
403   ;;
404   --disable-risky) risky="no"
405   ;;
406   --enable-small) optimize="small"
407   ;;
408   --enable-amr_nb) amr_nb="yes"
409   ;;
410   --enable-amr_nb-fixed) amr_nb_fixed="yes"
411   ;;
412   --enable-sunmlib) sunmlib="yes"
413   ;;
414   esac
415 done
416
417 # compute mmx state
418 if test $mmx = "default"; then
419     if test $cpu = "x86"; then
420         mmx="yes"
421     else
422         mmx="no"
423     fi
424 fi
425
426 #Darwin CC versions
427 needmdynamicnopic="no"
428 if test $targetos = Darwin; then
429     if test -n "`$cc -v 2>&1 | grep xlc`"; then
430         CFLAGS="-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
431     else
432         gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
433         case "$gcc_version" in
434             *2.95*) 
435                 CFLAGS="-no-cpp-precomp -pipe -fomit-frame-pointer"
436                 ;;
437             *3.*)
438                 CFLAGS="-no-cpp-precomp -pipe -fomit-frame-pointer -force_cpusubtype_ALL -Wno-sign-compare"
439                 if test "$lshared" = no; then
440                    needmdynamicnopic="yes"
441                 fi
442                 ;;
443             *)
444                 CFLAGS="-no-cpp-precomp -pipe -fomit-frame-pointer"
445                 if test "$lshared" = no; then
446                    needmdynamicnopic="yes"
447                 fi
448                 ;;
449         esac
450     fi
451 fi
452
453 # Can only do AltiVec on PowerPC
454 if test $altivec = "default"; then
455     if test $cpu = "powerpc"; then
456         altivec="yes"
457     else
458         altivec="no"
459     fi
460 fi
461
462 # Add processor-specific flags
463 TUNECPU="generic"
464 if test $tune != "generic"; then
465     case $tune in
466         601|ppc601|PowerPC601)
467             CFLAGS="$CFLAGS -mcpu=601"
468             if test $altivec = "yes"; then
469                 echo "WARNING: tuning for PPC601 but altivec enabled !";
470             fi
471             TUNECPU=ppc601
472         ;;
473         603*|ppc603*|PowerPC603*)
474             CFLAGS="$CFLAGS -mcpu=603"
475             if test $altivec = "yes"; then
476                 echo "WARNING: tuning for PPC603 but altivec enabled !";
477             fi
478             TUNECPU=ppc603
479         ;;
480         604*|ppc604*|PowerPC604*)
481             CFLAGS="$CFLAGS -mcpu=604"
482             if test $altivec = "yes"; then
483                 echo "WARNING: tuning for PPC604 but altivec enabled !";
484             fi
485             TUNECPU=ppc604
486         ;;
487         G3|g3|75*|ppc75*|PowerPC75*)
488             CFLAGS="$CFLAGS -mcpu=750 -mtune=750 -mpowerpc-gfxopt"
489             if test $altivec = "yes"; then
490                 echo "WARNING: tuning for PPC75x but altivec enabled !";
491             fi
492             TUNECPU=ppc750
493         ;;
494         G4|g4|745*|ppc745*|PowerPC745*)
495             CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
496             if test $altivec = "no"; then
497                 echo "WARNING: tuning for PPC745x but altivec disabled !";
498             fi
499             TUNECPU=ppc7450
500         ;;
501         74*|ppc74*|PowerPC74*)
502             CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
503             if test $altivec = "no"; then
504                 echo "WARNING: tuning for PPC74xx but altivec disabled !";
505             fi
506             TUNECPU=ppc7400
507         ;;
508         G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
509             CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc64 -force_cpusubtype_ALL "
510             if test $altivec = "no"; then
511                 echo "WARNING: tuning for PPC970 but altivec disabled !";
512             fi
513             TUNECPU=ppc970
514         ;;
515         *)
516         echo "WARNING: unknown CPU "$tune", ignored"
517         ;;
518     esac
519 fi
520
521 # AltiVec flags: The FSF version of GCC differs from the Apple version 
522 if test $cpu = "powerpc"; then
523     if test $altivec = "yes"; then
524         if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
525             CFLAGS="$CFLAGS -faltivec"
526         else
527             CFLAGS="$CFLAGS -maltivec -mabi=altivec"
528         fi
529     fi
530 fi
531
532 # See if we have <altivec.h>
533 cat > $TMPC << EOF
534 #include <altivec.h>
535 int main( void ) { return 0; }
536 EOF
537
538 _altivec_h="no"
539 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
540 _altivec_h="yes"
541 fi
542
543 # See does our compiler support Motorola AltiVec C API
544 if test $altivec = "yes"; then
545 if test $_altivec_h = "yes"; then
546 cat > $TMPC << EOF
547 #include <altivec.h>
548 int main(void) {
549     vector signed int v1, v2, v3;
550     v1 = vec_add(v2,v3);
551     return 0;
552 }
553 EOF
554 else
555 cat > $TMPC << EOF
556 int main(void) {
557     vector signed int v1, v2, v3;
558     v1 = vec_add(v2,v3);
559     return 0;
560 }
561 EOF
562 fi
563 $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null || altivec="no"
564 fi
565
566 # Can only do mmi on mips
567 if test $mmi = "default"; then
568     if test $cpu = "mips"; then
569         mmi="yes"
570     else
571         mmi="no"
572     fi
573 fi
574
575 # See does our compiler support mmi
576 if test $mmi = "yes"; then
577 cat > $TMPC << EOF
578 int main(void) {
579     __asm__ ("lq \$2, 0(\$2)");
580     return 0;
581 }
582 EOF
583 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
584 fi
585
586 if test "$mingw32" = "yes" ; then
587     v4l="no"
588     audio_oss="no"
589     dv1394="no"
590     ffserver="no"
591     network="no"
592     LIBPREF=""
593     LIBSUF=".lib"
594     SLIBPREF=""
595     SLIBSUF=".dll"
596     EXESUF=".exe"
597     prefix="/c/Program Files/FFmpeg"
598     bindir="$prefix"
599 fi
600
601 cc="${cross_prefix}${cc}"
602 ar="${cross_prefix}${ar}"
603 ranlib="${cross_prefix}${ranlib}"
604 strip="${cross_prefix}${strip}"
605
606 if test -z "$cross_prefix" ; then
607
608 # ---
609 # big/little endian test
610 cat > $TMPC << EOF
611 #include <inttypes.h>
612 int main(int argc, char ** argv){
613         volatile uint32_t i=0x01234567;
614         return (*((uint8_t*)(&i))) == 0x67;
615 }
616 EOF
617
618 if $cc -o $TMPE $TMPC 2>/dev/null ; then
619 $TMPE && bigendian="yes"
620 else
621 echo big/little test failed
622 fi
623
624 else
625
626 # if cross compiling, cannot launch a program, so make a static guess
627 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
628     bigendian="yes"
629 fi
630
631 fi
632
633 # ---
634 # *int_fast* test
635 cat > $TMPC << EOF
636 #include <inttypes.h>
637 int main(int argc, char ** argv){
638         volatile uint_fast64_t i=0x01234567;
639         return 0;
640 }
641 EOF
642
643 $cc -o $TMPE $TMPC 2>/dev/null || emu_fast_int="yes"
644
645 # ---
646 # check availability of some header files
647
648 cat > $TMPC << EOF
649 #include <malloc.h>
650 int main( void ) { return 0; }
651 EOF
652
653 _memalign=no
654 _malloc_h=no
655 if $cc -o $TMPE $TMPC 2> /dev/null ; then
656 _malloc_h=yes
657 _memalign=yes
658 # check for memalign - atmos
659 cat > $TMPC << EOF
660 #include <malloc.h>
661 int main ( void ) {
662 char *string = NULL;
663 string = memalign(64, sizeof(char));
664 return 0;
665 }
666 EOF
667 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
668 fi
669
670 cat > $TMPC << EOF
671 #include <time.h>
672 int main( void ) { localtime_r(NULL, NULL); }
673 EOF
674
675 localtime_r=no
676 if $cc -o $TMPE $TMPC 2> /dev/null ; then
677   localtime_r=yes
678 fi
679
680 if test "$zlib" = "yes"; then
681 # check for zlib - mmu_man
682 cat > $TMPC << EOF
683 #include <zlib.h>
684 int main ( void ) {
685 if (zlibVersion() != ZLIB_VERSION)
686    puts("zlib version differs !!!");
687    return 1;
688 return 0;
689 }
690 EOF
691 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
692 # $TMPE 2> /dev/null > /dev/null || zlib="no"
693 # XXX: more tests needed - runtime test
694 fi
695 if test "$zlib" = "yes"; then
696 extralibs="$extralibs -lz"
697 fi
698
699 # test for lrintf in math.h
700 cat > $TMPC << EOF
701 #define _ISOC9X_SOURCE  1
702 #include <math.h>
703 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
704 EOF
705
706 have_lrintf="no"
707 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
708   have_lrintf="yes"
709   $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
710 fi
711
712 _restrict=
713 for restrict_keyword in restrict __restrict__ __restrict; do
714   echo "void foo(char * $restrict_keyword p);" > $TMPC
715   if $cc -c -o $TMPO $TMPC 2> /dev/null; then
716     _restrict=$restrict_keyword
717     break;
718   fi
719 done
720
721 # test gcc version to see if vector builtins can be used
722 # currently only used on i386 for MMX builtins
723 cat > $TMPC << EOF
724 int main(void) { 
725 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
726 return 0;
727 #else
728 #error no vector builtins
729 #endif
730 }
731 EOF
732
733 builtin_vector=no
734 if $cc -o $TMPO $TMPC 2> /dev/null ; then
735   builtin_vector=yes
736 fi
737
738 # dlopen/dlfcn.h probing
739
740 cat > $TMPC << EOF
741 #include <dlfcn.h>
742 int main( void ) { return (int) dlopen("foo", 0); }
743 EOF
744
745 ldl=-ldl
746
747 if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1 ; then
748 dlfcn=yes
749 dlopen=yes
750 fi
751
752 if $cc -o $TMPE $TMPC > /dev/null 2>&1 ; then
753 dlfcn=yes
754 dlopen=yes
755 ldl=""
756 fi
757
758 cat > $TMPC << EOF
759 int main( void ) { return (int) dlopen("foo", 0); }
760 EOF
761
762 if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1  ; then
763 dlopen=yes
764 fi
765
766 if $cc -o $TMPE $TMPC > /dev/null 2>&1  ; then
767 dlopen=yes
768 ldl=""
769 fi
770
771 if test "$vhook" = "default" ; then
772   vhook="$dlopen"
773 fi
774
775 ##########################################
776 # imlib probe
777
778 cat > $TMPC << EOF
779 #include <X11/Xlib.h>
780 #include <Imlib2.h>
781 int main( void ) { return (int) imlib_load_font("foo"); }
782 EOF
783
784 imlib2=no
785 if $cc -o $TMPE $TMPC -lImlib2 > /dev/null 2>&1  ; then
786 imlib2=yes
787 fi
788
789 ##########################################
790 # freetype probe
791
792 cat > $TMPC << EOF
793 #include <ft2build.h>
794 int main( void ) { return (int) FT_Init_FreeType(0); }
795 EOF
796
797 freetype2=no
798 if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
799   if test "`which freetype-config`" != ""; then
800     if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs`  > /dev/null 2>&1 ; then
801       freetype2=yes
802     fi
803   fi
804 fi
805
806 ##########################################
807 # SDL probe
808
809 cat > $TMPC << EOF
810 #include <SDL.h>
811 #undef main /* We don't want SDL to override our main() */
812 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
813 EOF
814
815 sdl_too_old=no
816 sdl=no
817 if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs`  > /dev/null 2>&1  ; then
818 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
819 if test "$_sdlversion" -lt 121 ; then
820 sdl_too_old=yes
821 else
822 sdl=yes
823 fi
824 fi
825
826 case "`$cc -v 2>&1 | grep version`" in
827     *gcc*)
828         CFLAGS="-Wall $CFLAGS"
829         ;;
830     *)
831         ;;
832 esac
833
834 if test "$sdl" = "no" ; then
835    ffplay=no
836 fi
837
838 if test "$debug" = "yes"; then
839         CFLAGS="$CFLAGS -g"
840 fi
841
842 if test "$optimize" = "small"; then
843 #  CFLAGS=${CFLAGS//-O3/-Os}
844   CFLAGS="$CFLAGS -Os"
845 fi
846
847 if test "$optimize" = "yes"; then
848     if test -n "`$cc -v 2>&1 | grep xlc`"; then
849         CFLAGS="$CFLAGS -O5"
850         LDFLAGS="$LDFLAGS -O5"
851     else
852         CFLAGS="$CFLAGS -O3"
853     fi
854 fi
855
856 if test x"$bindir" = x""; then
857 bindir="${prefix}/bin"
858 fi
859
860 if test x"$mandir" = x""; then
861 mandir="${prefix}/man"
862 fi
863
864 echo "Install prefix   $prefix"
865 echo "Source path      $source_path"
866 echo "C compiler       $cc"
867 echo "make             $make"
868 echo "CPU              $cpu ($tune)"
869 echo "Big Endian       $bigendian"
870 echo "broken inttypes.h $emu_fast_int"
871 if test $cpu = "x86"; then
872 echo "MMX enabled      $mmx"
873 echo "Vector Builtins  $builtin_vector"
874 fi
875 if test $cpu = "mips"; then
876 echo "MMI enabled      $mmi"
877 fi
878 if test $cpu = "powerpc"; then
879 echo "AltiVec enabled  $altivec"
880 fi
881 echo "gprof enabled    $gprof"
882 echo "zlib enabled     $zlib"
883 echo "mp3lame enabled  $mp3lame"
884 echo "vorbis enabled   $vorbis"
885 echo "faad enabled     $faad"
886 echo "faadbin enabled  $faadbin"
887 echo "faac enabled     $faac"
888 echo "a52 support      $a52"
889 echo "a52 dlopened     $a52bin"
890 echo "pp support       $pp"
891 echo "debug symbols    $debug"
892 echo "optimize         $optimize"
893 echo "shared pp        $shared_pp"
894 echo "Video hooking    $vhook"
895 echo "SDL support      $sdl"
896 if test $sdl_too_old = "yes"; then
897 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
898 fi
899 echo "risky / patent encumbered codecs $risky"
900
901 if test "$vhook" = "yes" ; then
902 echo "Imlib2 support   $imlib2"
903 echo "freetype support $freetype2"
904 fi
905 echo "Sun medialib support"  $sunmlib
906 echo "AMR-NB float support"  $amr_nb
907 echo "AMR-NB fixed support"  $amr_nb_fixed
908 echo "AMR-WB float support"  $amr_wb
909
910 echo "Creating config.mak and config.h"
911
912 echo "# Automatically generated by configure - do not modify" > config.mak
913 echo "/* Automatically generated by configure - do not modify */" > $TMPH
914
915 echo "prefix=$prefix" >> config.mak
916 echo "bindir=$bindir" >> config.mak
917 echo "mandir=$mandir" >> config.mak
918 echo "MAKE=$make" >> config.mak
919 echo "CC=$cc" >> config.mak
920 echo "AR=$ar" >> config.mak
921 echo "RANLIB=$ranlib" >> config.mak
922 echo "STRIP=$strip" >> config.mak
923
924 # SHCFLAGS is a copy of CFLAGS without -mdynamic-no-pic.  Used when building 
925 # shared modules on OS/X (vhook/Makefile).
926 SHCFLAGS=$CFLAGS
927 if test "$needmdynamicnopic" = yes; then
928    CFLAGS="$CFLAGS -mdynamic-no-pic"
929 fi
930
931 echo "OPTFLAGS=$CFLAGS" >> config.mak
932 echo "SHCFLAGS=$SHCFLAGS">>config.mak
933 echo "LDFLAGS=$LDFLAGS" >> config.mak
934 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
935 echo "SHFLAGS=$SHFLAGS" >> config.mak
936 echo "LIBPREF=$LIBPREF" >> config.mak
937 echo "LIBSUF=$LIBSUF" >> config.mak
938 echo "SLIBPREF=$SLIBPREF" >> config.mak
939 echo "SLIBSUF=$SLIBSUF" >> config.mak
940 echo "EXESUF=$EXESUF" >> config.mak
941 echo "TARGET_OS=$TARGET_OS" >> config.mak
942 if test "$cpu" = "x86" ; then
943   echo "TARGET_ARCH_X86=yes" >> config.mak
944   echo "#define ARCH_X86 1" >> $TMPH
945 elif test "$cpu" = "armv4l" ; then
946   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
947   echo "#define ARCH_ARMV4L 1" >> $TMPH
948 elif test "$cpu" = "alpha" ; then
949   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
950   echo "#define ARCH_ALPHA 1" >> $TMPH
951 elif test "$cpu" = "sparc64" ; then
952   echo "TARGET_ARCH_SPARC64=yes" >> config.mak
953   echo "#define ARCH_SPARC64 1" >> $TMPH
954 elif test "$cpu" = "powerpc" ; then
955   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
956   echo "#define ARCH_POWERPC 1" >> $TMPH
957   if test "$powerpc_perf" = "yes"; then
958     echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
959   fi
960 elif test "$cpu" = "mips" ; then
961   echo "TARGET_ARCH_MIPS=yes" >> config.mak
962   echo "#define ARCH_MIPS 1" >> $TMPH
963 elif test "$cpu" = "sh4" ; then
964   echo "TARGET_ARCH_SH4=yes" >> config.mak
965   echo "#define ARCH_SH4 1" >> $TMPH
966 fi
967 echo "#define TUNECPU $TUNECPU" >> $TMPH
968 if test "$bigendian" = "yes" ; then
969   echo "WORDS_BIGENDIAN=yes" >> config.mak
970   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
971 fi
972 if test "$emu_fast_int" = "yes" ; then
973   echo "#define EMULATE_FAST_INT 1" >> $TMPH
974 fi
975 if test "$mmx" = "yes" ; then
976   echo "TARGET_MMX=yes" >> config.mak
977   echo "#define HAVE_MMX 1" >> $TMPH
978   echo "#define __CPU__ 586" >> $TMPH
979 fi
980 if test "$builtin_vector" = "yes" ; then
981   echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
982   echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
983 fi
984 if test "$mmi" = "yes" ; then
985   echo "TARGET_MMI=yes" >> config.mak
986   echo "#define HAVE_MMI 1" >> $TMPH
987 fi
988 if test "$altivec" = "yes" ; then
989   echo "TARGET_ALTIVEC=yes" >> config.mak
990   echo "#define HAVE_ALTIVEC 1" >> $TMPH
991   echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
992   echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
993   if test "$_altivec_h" = "yes" ; then
994     echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
995   else
996     echo "#undef HAVE_ALTIVEC_H" >> $TMPH
997   fi
998 fi
999 if test "$gprof" = "yes" ; then
1000   echo "TARGET_GPROF=yes" >> config.mak
1001   echo "#define HAVE_GPROF 1" >> $TMPH
1002 fi
1003 if test "$localtime_r" = "yes" ; then
1004   echo "#define HAVE_LOCALTIME_R 1" >> $TMPH
1005 fi
1006 if test "$imlib2" = "yes" ; then
1007   echo "HAVE_IMLIB2=yes" >> config.mak
1008 fi
1009 if test "$freetype2" = "yes" ; then
1010   echo "HAVE_FREETYPE2=yes" >> config.mak
1011 fi
1012 if test "$sunmlib" = "yes" ; then
1013   echo "HAVE_MLIB=yes" >> config.mak
1014   echo "#define HAVE_MLIB 1" >> $TMPH
1015   extralibs="$extralibs -lmlib"
1016 fi
1017 if test "$sdl" = "yes" ; then
1018   echo "CONFIG_SDL=yes" >> config.mak
1019   echo "SDL_LIBS=`sdl-config --libs`" >> config.mak
1020   echo "SDL_CFLAGS=`sdl-config --cflags`" >> config.mak
1021 fi
1022 if test "$have_lrintf" = "yes" ; then
1023   echo "#define HAVE_LRINTF 1" >> $TMPH
1024 fi
1025 if test "$vhook" = "yes" ; then
1026   echo "BUILD_VHOOK=yes" >> config.mak
1027   echo "#define HAVE_VHOOK 1" >> $TMPH
1028   extralibs="$extralibs $ldl"
1029 fi
1030 if test "$lshared" = "yes" ; then
1031   echo "BUILD_SHARED=yes" >> config.mak
1032   echo "PIC=-fPIC" >> config.mak
1033 fi
1034 echo "EXTRALIBS=$extralibs" >> config.mak
1035 version=`grep '#define FFMPEG_VERSION ' $source_path/libavcodec/avcodec.h |
1036  cut -d '"' -f 2`
1037 echo "VERSION=$version" >>config.mak
1038 # if you do not want to use encoders, disable that.
1039 echo "#define CONFIG_ENCODERS 1" >> $TMPH
1040 echo "CONFIG_ENCODERS=yes" >> config.mak
1041
1042 # if you do not want to use decoders, disable that.
1043 echo "#define CONFIG_DECODERS 1" >> $TMPH
1044 echo "CONFIG_DECODERS=yes" >> config.mak
1045
1046 # AC3
1047 if test "$a52" = "yes" ; then
1048   echo "#define CONFIG_AC3 1" >> $TMPH
1049   echo "CONFIG_AC3=yes" >> config.mak
1050
1051   if test "$a52bin" = "yes" ; then
1052     echo "#define CONFIG_A52BIN 1" >> $TMPH
1053     echo "CONFIG_A52BIN=yes" >> config.mak
1054   fi
1055 fi
1056
1057 # PP
1058 if test "$pp" = "yes" ; then
1059   echo "#define CONFIG_PP 1" >> $TMPH
1060   echo "CONFIG_PP=yes" >> config.mak
1061
1062   if test "$shared_pp" = "yes" ; then
1063     echo "#define SHARED_PP 1" >> $TMPH
1064     echo "SHARED_PP=yes" >> config.mak
1065   fi
1066 fi
1067
1068 # mpeg audio high precision mode
1069 if test "$mpegaudio_hp" = "yes" ; then
1070   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
1071 fi
1072
1073 if test "$v4l" = "yes" ; then
1074   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
1075   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
1076 fi
1077
1078 if test "$dv1394" = "yes" ; then
1079   echo "#define CONFIG_DV1394 1" >> $TMPH
1080   echo "CONFIG_DV1394=yes" >> config.mak
1081 fi
1082
1083 if test "$dlopen" = "yes" ; then
1084   echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
1085 fi
1086
1087 if test "$dlfcn" = "yes" ; then
1088   echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
1089 fi
1090
1091 if test "$audio_oss" = "yes" ; then
1092   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
1093   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
1094 fi
1095
1096 if test "$audio_beos" = "yes" ; then
1097   echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
1098   echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
1099 fi
1100
1101 if test "$network" = "yes" ; then
1102   echo "#define CONFIG_NETWORK 1" >> $TMPH
1103   echo "CONFIG_NETWORK=yes" >> config.mak
1104 fi
1105
1106 if test "$zlib" = "yes" ; then
1107   echo "#define CONFIG_ZLIB 1" >> $TMPH
1108   echo "CONFIG_ZLIB=yes" >> config.mak
1109 fi
1110
1111 if test "$mp3lame" = "yes" ; then
1112   echo "#define CONFIG_MP3LAME 1" >> $TMPH
1113   echo "CONFIG_MP3LAME=yes" >> config.mak
1114 fi
1115
1116 if test "$vorbis" = "yes" ; then
1117   echo "#define CONFIG_VORBIS 1" >> $TMPH
1118   echo "CONFIG_VORBIS=yes" >> config.mak
1119 fi
1120
1121 if test "$faad" = "yes" ; then
1122   echo "#define CONFIG_FAAD 1" >> $TMPH
1123   echo "CONFIG_FAAD=yes" >> config.mak
1124 fi
1125
1126 if test "$faadbin" = "yes" ; then
1127   echo "#define CONFIG_FAADBIN 1" >> $TMPH
1128   echo "CONFIG_FAADBIN=yes" >> config.mak
1129 fi
1130
1131 if test "$faac" = "yes" ; then
1132   echo "#define CONFIG_FAAC 1" >> $TMPH
1133   echo "CONFIG_FAAC=yes" >> config.mak
1134 fi
1135
1136 if test "$mingw32" = "yes" ; then
1137   echo "#define CONFIG_WIN32 1" >> $TMPH
1138   echo "CONFIG_WIN32=yes" >> config.mak
1139   echo "#ifndef __MINGW32__" >> $TMPH
1140   echo "#define __MINGW32__ 1" >> $TMPH
1141   echo "#endif" >> $TMPH
1142 fi
1143
1144 if test "$os2" = "yes" ; then
1145   echo "#define CONFIG_OS2 1" >> $TMPH
1146   echo "CONFIG_OS2=yes" >> config.mak
1147 fi
1148
1149 if test "$TARGET_OS" = "SunOS" ; then
1150   echo "#define CONFIG_SUNOS 1" >> $TMPH
1151 fi
1152
1153 if test "$darwin" = "yes"; then
1154   echo "#define CONFIG_DARWIN 1"  >> $TMPH
1155   echo "CONFIG_DARWIN=yes" >> config.mak
1156 fi
1157
1158 if test "$_malloc_h" = "yes" ; then
1159   echo "#define HAVE_MALLOC_H 1" >> $TMPH
1160 else
1161   echo "#undef  HAVE_MALLOC_H" >> $TMPH
1162 fi
1163
1164 if test "$_memalign" = "yes" ; then
1165   echo "#define HAVE_MEMALIGN 1" >> $TMPH
1166 else
1167   echo "#undef  HAVE_MEMALIGN" >> $TMPH
1168 fi
1169
1170 if test "$netserver" = "yes" ; then
1171   echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
1172   echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
1173 fi
1174
1175 if test "$need_inet_aton" = "yes" ; then
1176   echo "NEED_INET_ATON=yes" >> config.mak
1177 fi
1178
1179 if test "$simpleidct" = "yes" ; then
1180   echo "#define SIMPLE_IDCT 1" >> $TMPH
1181 fi
1182
1183 if test "$ffserver" = "yes" ; then
1184   echo "#define CONFIG_FFSERVER 1" >> $TMPH
1185   echo "CONFIG_FFSERVER=yes" >> config.mak
1186 fi
1187
1188 if test "$ffplay" = "yes" ; then
1189   echo "CONFIG_FFPLAY=yes" >> config.mak
1190 fi
1191
1192 if test "$risky" = "yes" ; then
1193   echo "#define CONFIG_RISKY 1" >> $TMPH
1194   echo "CONFIG_RISKY=yes" >> config.mak
1195 fi
1196
1197 echo "#define restrict $_restrict" >> $TMPH
1198
1199 # build tree in object directory if source path is different from current one
1200 if test "$source_path_used" = "yes" ; then
1201     DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
1202           libavcodec/ppc libavcodec/liba52 libavcodec/mlib libavcodec/libpostproc tests vhook"
1203     FILES="Makefile libavformat/Makefile libavcodec/Makefile libavcodec/libpostproc/Makefile tests/Makefile vhook/Makefile"
1204     for dir in $DIRS ; do
1205             mkdir -p $dir
1206     done
1207     for f in $FILES ; do
1208         ln -sf $source_path/$f $f
1209     done
1210 fi
1211 echo "SRC_PATH=$source_path" >> config.mak
1212
1213 if test "$amr_wb" = "yes" ; then
1214   echo "#define AMR_WB 1" >> $TMPH
1215   echo "AMR_WB=yes" >> config.mak
1216   echo
1217   echo "AMR WB FLOAT NOTICE ! Make sure you have downloaded TS26.204"
1218   echo "V5.1.0 from "
1219   echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip"
1220   echo "and extracted the source to libavcodec/amrwb_float"
1221   echo
1222 fi
1223
1224 if test "$amr_nb" = "yes" ; then
1225   echo "#define AMR_NB 1" >> $TMPH
1226   echo "AMR_NB=yes" >> config.mak
1227   echo
1228 if test "$amr_nb_fixed" = "yes" ; then
1229   echo "AMR_NB_FIXED=yes" >> config.mak
1230   echo "#define AMR_NB_FIXED 1" >> $TMPH
1231   echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
1232   echo "REL-5 version 5.1.0 from "
1233   echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-510.zip"
1234   echo "and extracted src to libavcodec/amr"
1235   echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
1236   echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
1237   echo
1238 else
1239   echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
1240   echo "REL-5 V5.1.0 from "
1241   echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-510.zip"
1242   echo "and extracted the source to libavcodec/amr_float"
1243   echo
1244 fi
1245
1246 fi
1247
1248 diff $TMPH config.h >/dev/null 2>&1
1249 if test $? -ne 0 ; then
1250         mv -f $TMPH config.h
1251 else
1252         echo "config.h is unchanged"
1253 fi
1254
1255 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH