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