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