]> git.sesse.net Git - ffmpeg/blob - configure
'#elseif' needs to be '#elif' patch by ("Steven M. Schultz": sms, 2BSD COM)
[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 "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
17 echo "  --mandir=DIR             man documentation in DIR [PREFIX/man]"
18 echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
19 echo "  --enable-libogg          enable ogg support via libogg [default=no]"
20 echo "  --enable-vorbis          enable vorbis support via libvorbis [default=no]"
21 echo "  --enable-theora          enable theora support via libtheora [default=no]"
22 echo "  --enable-faad            enable faad support via libfaad [default=no]"
23 echo "  --enable-faadbin         build faad support with runtime linking [default=no]"
24 echo "  --enable-faac            enable faac support via libfaac [default=no]"
25 echo "  --enable-libgsm          enable gsm support via libgsm [default=no]"
26 echo "  --enable-xvid            enable xvid support via xvidcore [default=no]"
27 echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
28 echo "  --enable-mingw32         enable mingw32 native/cross windows compile"
29 echo "  --enable-a52             enable GPL'ed A52 support [default=no]"
30 echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
31 echo "  --enable-dts             enable GPL'ed DTS support [default=no]"
32 echo "  --enable-pp              enable GPL'ed post processing support [default=no]"
33 echo "  --enable-shared-pp       use libpostproc.so [default=no]"
34 echo "  --enable-shared          build shared libraries [default=no]"
35 echo "  --enable-amr_nb          enable amr_nb float audio codec"
36 echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
37 echo "  --enable-amr_wb          enable amr_wb float audio codec"
38 echo "  --enable-sunmlib         use Sun medialib [default=no]"
39 echo "  --enable-pthreads        use pthreads [default=no]"
40 echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394 and libraw1394 [default=no]"
41 echo "  --enable-gpl             allow use of gpl code, the resulting libav* and ffmpeg will be under gpl [default=no]"
42 echo ""
43 echo "Advanced options (experts only):"
44 echo "  --source-path=PATH       path of source code [$source_path]"
45 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
46 echo "  --cc=CC                  use C compiler CC [$cc]"
47 echo "  --make=MAKE              use specified make [$make]"
48 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
49 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
50 echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
51 echo "  --build-suffix=SUFFIX    suffix for application specific build []"
52 echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
53 echo "  --tune=PROCESSOR         tune code for a particular CPU (may fails or misperforms on other CPUs)"
54 echo "  --powerpc-perf-enable    enable performance report on PPC (requires enabling PMC)"
55 echo "  --disable-mmx            disable mmx usage"
56 echo "  --disable-iwmmxt         disable iwmmxt usage"
57 echo "  --disable-altivec        disable AltiVec usage"
58 echo "  --disable-audio-oss      disable OSS audio support [default=no]"
59 echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
60 echo "  --disable-v4l            disable video4linux grabbing [default=no]"
61 echo "  --disable-bktr           disable bktr video grabbing [default=no]"
62 echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
63 echo "  --disable-network        disable network support [default=no]"
64 echo "  --disable-zlib           disable zlib [default=no]"
65 echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
66 echo "  --disable-vhook          disable video hooking support"
67 echo "  --enable-gprof           enable profiling with gprof [$gprof]"
68 echo "  --disable-debug          disable debugging symbols"
69 echo "  --disable-opts           disable compiler optimizations"
70 echo "  --disable-mpegaudio-hp   faster (but less accurate)"
71 echo "                           mpegaudio decoding [default=no]"
72 echo "  --disable-ffserver       disable ffserver build"
73 echo "  --disable-ffplay         disable ffplay build"
74 echo "  --enable-small           optimize for size instead of speed"
75 echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
76 echo "  --disable-strip          disable stripping of executables and shared libraries"
77 echo "  --enable-codec=codec     enables codec"
78 echo "  --disable-codec=codec    disables codec"
79 echo "  --disable-encoders       disables all encoders"
80 echo "  --disable-decoders       disables all decoders"
81 echo ""
82 echo "NOTE: The object files are build at the place where configure is launched"
83 exit 1
84 fi
85
86 # set temporary file name
87 if test ! -z "$TMPDIR" ; then
88     TMPDIR1="${TMPDIR}"
89 elif test ! -z "$TEMPDIR" ; then
90     TMPDIR1="${TEMPDIR}"
91 else
92     TMPDIR1="/tmp"
93 fi
94
95 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
96 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
97 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
98 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
99 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
100
101 # default parameters
102 prefix="/usr/local"
103 libdir=""
104 mandir=""
105 bindir=""
106 cross_prefix=""
107 cc="gcc"
108 ar="ar"
109 ranlib="ranlib"
110 make="make"
111 strip="strip"
112 cpu=`uname -m`
113 tune="generic"
114 powerpc_perf="no"
115 mmx="default"
116 iwmmxt="default"
117 altivec="default"
118 mmi="default"
119 case "$cpu" in
120   i386|i486|i586|i686|i86pc|BePC)
121     cpu="x86"
122   ;;
123   x86_64|amd64)
124     cpu="x86"
125     canon_arch="`cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
126     if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
127       if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
128         cpu="x86_64"
129       fi
130     fi
131   ;;
132   # armv4l is a subset of armv5tel
133   armv4l|armv5tel)
134     cpu="armv4l"
135   ;;
136   alpha)
137     cpu="alpha"
138   ;;
139   "Power Macintosh"|ppc)
140     cpu="powerpc"
141   ;;
142   mips)
143     cpu="mips"
144   ;;
145   sun4u|sparc64)
146     cpu="sparc64"
147   ;;
148   sparc)
149     cpu="sparc"
150   ;;
151   sh4)
152     cpu="sh4"
153   ;;
154   *)
155     cpu="unknown"
156   ;;
157 esac
158 gprof="no"
159 v4l="yes"
160 bktr="no"
161 audio_oss="yes"
162 audio_beos="no"
163 dv1394="yes"
164 dc1394="no"
165 network="yes"
166 zlib="yes"
167 libgsm="no"
168 mp3lame="no"
169 libogg="no"
170 vorbis="no"
171 theora="no"
172 faad="no"
173 faadbin="no"
174 faac="no"
175 xvid="no"
176 x264="no"
177 a52="no"
178 a52bin="no"
179 dts="no"
180 pp="no"
181 shared_pp="no"
182 mingw32="no"
183 cygwin="no"
184 os2="no"
185 lshared="no"
186 optimize="yes"
187 debug="yes"
188 dostrip="yes"
189 extralibs="-lm"
190 simpleidct="yes"
191 bigendian="no"
192 inttypes="yes"
193 emu_fast_int="no"
194 vhook="default"
195 dlfcn="no"
196 dlopen="no"
197 mpegaudio_hp="yes"
198 SHFLAGS=-shared
199 netserver="no"
200 need_inet_aton="no"
201 ffserver="yes"
202 ffplay="yes"
203 LIBOBJFLAGS=""
204 LDFLAGS=-Wl,--warn-common
205 FFSLDFLAGS=-Wl,-E
206 LDCONFIG="ldconfig"
207 LIBPREF="lib"
208 LIBSUF=".a"
209 SLIBPREF="lib"
210 SLIBSUF=".so"
211 EXESUF=""
212 BUILDSUF=""
213 amr_nb="no"
214 amr_wb="no"
215 amr_nb_fixed="no"
216 amr_if2="no"
217 sunmlib="no"
218 pthreads="no"
219 gpl="no"
220 memalignhack="no"
221
222 # OS specific
223 targetos=`uname -s`
224 case $targetos in
225 BeOS)
226 prefix="/boot/home/config"
227 # helps building libavcodec
228 CFLAGS="-DPIC -fomit-frame-pointer"
229 # 3 gcc releases known for BeOS, each with ugly bugs
230 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
231 case "$gcc_version" in
232 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
233 mmx="no"
234 ;;
235 *20010315*) echo "BeBits gcc"
236 CFLAGS="$CFLAGS -fno-expensive-optimizations"
237 ;;
238 esac
239 SHFLAGS=-nostart
240 # disable linux things
241 audio_oss="no"
242 v4l="no"
243 dv1394="no"
244 # enable beos things
245 audio_beos="yes"
246 # no need for libm, but the inet stuff
247 # Check for BONE
248 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
249 extralibs="-lbind -lsocket"
250 else
251 netserver="yes"
252 need_inet_aton="yes"
253 extralibs="-lnet"
254 fi ;;
255 SunOS)
256 v4l="no"
257 audio_oss="no"
258 dv1394="no"
259 make="gmake"
260 LDFLAGS=""
261 FFSLDFLAGS=""
262 need_inet_aton="yes"
263 extralibs="$extralibs -lsocket -lnsl"
264 ;;
265 NetBSD)
266 v4l="no"
267 bktr="yes"
268 audio_oss="yes"
269 dv1394="no"
270 make="gmake"
271 LDFLAGS="$LDFLAGS -export-dynamic"
272 case `uname -r` in
273 2.*) extralibs="-lossaudio"
274 ;;
275 esac
276 ;;
277 OpenBSD)
278 v4l="no"
279 bktr="yes"
280 audio_oss="yes"
281 dv1394="no"
282 make="gmake"
283 LIBOBJFLAGS="\$(PIC)"
284 LDFLAGS="$LDFLAGS -export-dynamic -pthread"
285 LDCONFIG="ldconfig -m \$(libdir)"
286 extralibs="$extralibs -lossaudio"
287 ;;
288 FreeBSD)
289 v4l="no"
290 bktr="yes"
291 audio_oss="yes"
292 dv1394="no"
293 make="gmake"
294 CFLAGS="-pthread"
295 LDFLAGS="$LDFLAGS -export-dynamic -pthread"
296 ;;
297 BSD/OS)
298 v4l="no"
299 bktr="yes"
300 audio_oss="yes"
301 dv1394="no"
302 extralibs="-lpoll -lgnugetopt -lm"
303 make="gmake"
304 ;;
305 Darwin)
306 cc="cc"
307 v4l="no"
308 audio_oss="no"
309 dv1394="no"
310 ffserver="no"
311 SHFLAGS="-dynamiclib"
312 extralibs=""
313 darwin="yes"
314 strip="strip -x"
315 LDFLAGS="-Wl,-search_paths_first"
316 FFSLDFLAGS=-Wl,-bind_at_load
317 ;;
318 MINGW32*)
319 # Note: the rest of the mingw32 config is done afterwards as mingw32
320 # can be forced on command line for linux cross compilation
321 mingw32="yes"
322 ;;
323 CYGWIN*)
324 v4l="no"
325 audio_oss="yes"
326 dv1394="no"
327 ffserver="no"
328 extralibs=""
329 cygwin="yes"
330 EXESUF=".exe"
331 ;;
332 Linux)
333 LDFLAGS="$LDFLAGS -rdynamic"
334 ;;
335 IRIX*)
336 ranlib="echo ignoring ranlib"
337 v4l="no"
338 audio_oss="no"
339 make="gmake"
340 ;;
341 OS/2)
342 TMPE=$TMPE".exe"
343 ar="emxomfar -p128"
344 ranlib="echo ignoring ranlib"
345 strip="echo ignoring strip"
346 CFLAGS="-Zomf"
347 LDFLAGS="-Zomf -Zstack 16384 -s"
348 SHFLAGS="-Zdll -Zomf"
349 FFSLDFLAGS=""
350 LIBPREF=""
351 LIBSUF=".lib"
352 SLIBPREF=""
353 SLIBSUF=".dll"
354 EXESUF=".exe"
355 extralibs=""
356 v4l="no"
357 audio_oss="no"
358 dv1394="no"
359 network="no"
360 ffserver="no"
361 vhook="no"
362 os2="yes"
363
364 ;;
365 *) ;;
366 esac
367
368 # From mplayer configure. We need TARGET_OS available
369 # to the Makefile, so it can distinguish between flavors
370 # of AltiVec on PowerPC
371 TARGET_OS=`( uname -s ) 2>&1`
372   case "$TARGET_OS" in
373   Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS)
374     ;;
375   IRIX*)
376     TARGET_OS=IRIX
377     ;;
378   HP-UX*)
379     TARGET_OS=HP-UX
380     ;;
381   [cC][yY][gG][wW][iI][nN]*)
382     TARGET_OS=CYGWIN
383     ;;
384   *)
385     TARGET_OS="$TARGET_OS-UNKNOWN"
386     ;;
387   esac
388
389 # find source path
390 source_path="`echo $0 | sed -e 's#/configure##'`"
391 source_path_used="yes"
392 if test -z "$source_path" -o "$source_path" = "." ; then
393     source_path=`pwd`
394     source_path_used="no"
395 else
396     source_path="`cd \"$source_path\"; pwd`"
397 fi
398
399 FFMPEG_CONFIGURATION=" "
400 for opt do
401   FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
402 done
403
404 CODEC_LIST=`grep 'register_avcodec(&[a-z]' $source_path/libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
405
406 for opt do
407   case "$opt" in
408   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`; force_prefix=yes
409   ;;
410   --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`; force_libdir=yes
411   ;;
412   --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
413   ;;
414   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
415   ;;
416   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
417   ;;
418   --cc=*) cc=`echo $opt | cut -d '=' -f 2-`
419   ;;
420   --make=*) make=`echo $opt | cut -d '=' -f 2`
421   ;;
422   --extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
423   ;;
424   --extra-ldflags=*) LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
425   ;;
426   --extra-libs=*) extralibs=${opt#--extra-libs=}
427   ;;
428   --build-suffix=*) BUILDSUF=${opt#--build-suffix=}
429   ;;
430   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
431   ;;
432   --tune=*) tune=`echo $opt | cut -d '=' -f 2`
433   ;;
434   --powerpc-perf-enable) powerpc_perf="yes"
435   ;;
436   --disable-mmx) mmx="no"
437   ;;
438   --disable-iwmmxt) iwmmxt="no"
439   ;;
440   --disable-altivec) altivec="no"
441   ;;
442   --enable-gprof) gprof="yes"
443   ;;
444   --disable-v4l) v4l="no"
445   ;;
446   --disable-bktr) bktr="no"
447   ;;
448   --disable-audio-oss) audio_oss="no"
449   ;;
450   --disable-audio-beos) audio_beos="no"
451   ;;
452   --disable-dv1394) dv1394="no"
453   ;;
454   --disable-network) network="no"; ffserver="no"
455   ;;
456   --disable-zlib) zlib="no"
457   ;;
458   --enable-a52) a52="yes"
459   ;;
460   --enable-a52bin) a52bin="yes"
461   ;;
462   --enable-dts) dts="yes" ; extralibs="$extralibs -ldts"
463   ;;
464   --enable-pp) pp="yes"
465   ;;
466   --enable-shared-pp) shared_pp="yes"
467   ;;
468   --enable-libgsm) libgsm="yes"
469   ;;
470   --enable-mp3lame) mp3lame="yes"
471   ;;
472   --enable-libogg) libogg="yes"
473   ;;
474   --enable-vorbis) vorbis="yes"
475   ;;
476   --enable-theora) theora="yes"
477   ;;
478   --enable-faad) faad="yes"
479   ;;
480   --enable-faadbin) faadbin="yes"
481   ;;
482   --enable-faac) faac="yes"
483   ;;
484   --enable-xvid) xvid="yes"
485   ;;
486   --enable-x264) x264="yes"; extralibs="$extralibs -lx264"
487   ;;
488   --enable-dc1394) dc1394="yes"
489   ;;
490   --disable-vhook) vhook="no"
491   ;;
492   --disable-simple_idct) simpleidct="no"
493   ;;
494   --enable-mingw32) mingw32="yes"
495   ;;
496   --enable-shared) lshared="yes"
497   ;;
498   --disable-debug) debug="no"
499   ;;
500   --disable-opts) optimize="no"
501   ;;
502   --disable-mpegaudio-hp) mpegaudio_hp="no"
503   ;;
504   --disable-ffserver) ffserver="no"
505   ;;
506   --disable-ffplay) ffplay="no"
507   ;;
508   --enable-small) optimize="small"
509   ;;
510   --enable-amr_nb) amr_nb="yes"
511   ;;
512   --enable-amr_nb-fixed) amr_nb_fixed="yes"
513   ;;
514   --enable-amr_wb) amr_wb="yes"
515   ;; 
516   --enable-amr_if2) amr_if2="yes"
517   ;;
518   --enable-sunmlib) sunmlib="yes"
519   ;;
520   --enable-pthreads) pthreads="yes"
521   ;;
522   --enable-gpl) gpl="yes"
523   ;;
524   --enable-memalign-hack) memalignhack="yes"
525   ;;
526   --disable-strip) dostrip="no"
527   ;;
528   --enable-codec=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-codec=}"
529   ;;
530   --disable-codec=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-codec=}##\"`"
531   ;;
532   --disable-encoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*encoder//g'`"
533   ;;
534   --disable-decoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*decoder//g'`"
535   ;;
536   esac
537 done
538
539 if test "$theora" = "yes" ; then
540     if test "$libogg" = "no"; then
541         echo "libogg must be enabled to enable Theora"     
542         fail="yes"
543         theora="no"
544     fi
545 fi
546
547 if test "$vorbis" = "yes" ; then
548     if test "$libogg" = "no"; then
549         echo "libogg must be enabled to enable Vorbis"
550         fail="yes"
551         vorbis="no"
552     fi
553 fi
554
555 if test "$gpl" != "yes"; then
556     if test "$pp" != "no" -o "$shared_pp" != "no"; then
557         echo "The Postprocessing code is under GPL and --enable-gpl is not specified"
558         fail="yes"
559     fi
560
561     if test "$a52" != "no" -o "$a52bin" != "no"; then
562         echo "liba52 is under GPL and --enable-gpl is not specified"
563         fail="yes"
564     fi
565
566     if test "$xvid" != "no"; then
567         echo "libxvidcore is under GPL and --enable-gpl is not specified"
568         fail="yes"
569     fi
570
571     if test "$x264" != "no"; then
572         echo "x264 is under GPL and --enable-gpl is not specified"
573         fail="yes"
574     fi
575
576     if test "$dts" != "no"; then
577         echo "libdts is under GPL and --enable-gpl is not specified"
578         fail="yes"
579     fi
580     
581     if test "$faad" != "no" -o "$faadbin" != "no"; then
582         cat > $TMPC << EOF
583             #include <faad.h>
584             int main( void ) { return 0; }
585 EOF
586     
587         if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
588             cat > $TMPC << EOF
589                 #include <faad.h>
590                 #ifndef FAAD2_VERSION
591                 ok faad1
592                 #endif
593                 int main( void ) { return 0; }
594 EOF
595             if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
596                 echo "faad2 is under GPL and --enable-gpl is not specified"
597                 fail="yes"
598             fi
599         else
600             faad="no"
601             faadbin="no"
602             echo "faad test failed"
603         fi
604     fi
605    
606
607     if test "$fail" = "yes"; then
608         exit 1
609     fi
610 fi
611
612 # compute mmx state
613 if test $mmx = "default"; then
614     if test $cpu = "x86" -o $cpu = "x86_64"; then
615         mmx="yes"
616     else
617         mmx="no"
618     fi
619 fi
620
621 # check iwmmxt support
622 if test $iwmmxt = "default" -a $cpu = "armv4l"; then
623     cat > $TMPC << EOF
624         int main(void) { 
625         __asm__ __volatile__ ("wunpckelub wr6, wr4");
626         }
627 EOF
628
629     iwmmxt=no
630     if ${cross_prefix}${cc} -o $TMPO $TMPC 2> /dev/null ; then
631         iwmmxt=yes
632     fi
633 fi
634
635 #Darwin CC versions
636 needmdynamicnopic="no"
637 if test $targetos = Darwin; then
638     if test -n "`$cc -v 2>&1 | grep xlc`"; then
639         CFLAGS="$CFLAGS -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
640     else
641         gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
642         case "$gcc_version" in
643             *2.95*) 
644                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
645                 ;;
646             *[34].*)
647                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer -force_cpusubtype_ALL -Wno-sign-compare"
648                 if test "$lshared" = no; then
649                    needmdynamicnopic="yes"
650                 fi
651                 ;;
652             *)
653                 CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
654                 if test "$lshared" = no; then
655                    needmdynamicnopic="yes"
656                 fi
657                 ;;
658         esac
659     fi
660 fi
661
662 # Can only do AltiVec on PowerPC
663 if test $altivec = "default"; then
664     if test $cpu = "powerpc"; then
665         altivec="yes"
666     else
667         altivec="no"
668     fi
669 fi
670
671 # Add processor-specific flags
672 TUNECPU="generic"
673 POWERPCMODE="32bits"
674 if test $tune != "generic"; then
675     case $tune in
676         601|ppc601|PowerPC601)
677             CFLAGS="$CFLAGS -mcpu=601"
678             if test $altivec = "yes"; then
679                 echo "WARNING: tuning for PPC601 but altivec enabled !";
680             fi
681             TUNECPU=ppc601
682         ;;
683         603*|ppc603*|PowerPC603*)
684             CFLAGS="$CFLAGS -mcpu=603"
685             if test $altivec = "yes"; then
686                 echo "WARNING: tuning for PPC603 but altivec enabled !";
687             fi
688             TUNECPU=ppc603
689         ;;
690         604*|ppc604*|PowerPC604*)
691             CFLAGS="$CFLAGS -mcpu=604"
692             if test $altivec = "yes"; then
693                 echo "WARNING: tuning for PPC604 but altivec enabled !";
694             fi
695             TUNECPU=ppc604
696         ;;
697         G3|g3|75*|ppc75*|PowerPC75*)
698             CFLAGS="$CFLAGS -mcpu=750 -mtune=750 -mpowerpc-gfxopt"
699             if test $altivec = "yes"; then
700                 echo "WARNING: tuning for PPC75x but altivec enabled !";
701             fi
702             TUNECPU=ppc750
703         ;;
704         G4|g4|745*|ppc745*|PowerPC745*)
705             CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
706             if test $altivec = "no"; then
707                 echo "WARNING: tuning for PPC745x but altivec disabled !";
708             fi
709             TUNECPU=ppc7450
710         ;;
711         74*|ppc74*|PowerPC74*)
712             CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
713             if test $altivec = "no"; then
714                 echo "WARNING: tuning for PPC74xx but altivec disabled !";
715             fi
716             TUNECPU=ppc7400
717         ;;
718         G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
719             CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc-gfxopt -mpowerpc64"
720             if test $altivec = "no"; then
721                 echo "WARNING: tuning for PPC970 but altivec disabled !";
722             fi
723             TUNECPU=ppc970
724             POWERPCMODE="64bits"
725         ;;
726         i[3456]86|pentium|pentiumpro|pentium-mmx|pentium[234]|prescott|k6|k6-[23]|athlon|athlon-tbird|athlon-4|athlon-[mx]p|winchip-c6|winchip2|c3|nocona)
727             CFLAGS="$CFLAGS -march=$tune"
728         ;;
729         *)
730         echo "WARNING: unknown CPU \"$tune\", ignored"
731         ;;
732     esac
733 fi
734
735 # AltiVec flags: The FSF version of GCC differs from the Apple version 
736 if test $cpu = "powerpc"; then
737     if test $altivec = "yes"; then
738         if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
739             CFLAGS="$CFLAGS -faltivec -maltivec"
740         else
741             CFLAGS="$CFLAGS -maltivec -mabi=altivec"
742         fi
743     fi
744 fi
745
746 # See if we have <altivec.h>
747 cat > $TMPC << EOF
748 #include <altivec.h>
749 int main( void ) { return 0; }
750 EOF
751
752 _altivec_h="no"
753 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
754 _altivec_h="yes"
755 fi
756
757 # See does our compiler support Motorola AltiVec C API
758 if test $altivec = "yes"; then
759 if test $_altivec_h = "yes"; then
760 cat > $TMPC << EOF
761 #include <altivec.h>
762 int main(void) {
763     vector signed int v1, v2, v3;
764     v1 = vec_add(v2,v3);
765     return 0;
766 }
767 EOF
768 else
769 cat > $TMPC << EOF
770 int main(void) {
771     vector signed int v1, v2, v3;
772     v1 = vec_add(v2,v3);
773     return 0;
774 }
775 EOF
776 fi
777 $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null || altivec="no"
778 fi
779
780 # Can only do mmi on mips
781 if test $mmi = "default"; then
782     if test $cpu = "mips"; then
783         mmi="yes"
784     else
785         mmi="no"
786     fi
787 fi
788
789 # See does our compiler support mmi
790 if test $mmi = "yes"; then
791 cat > $TMPC << EOF
792 int main(void) {
793     __asm__ ("lq \$2, 0(\$2)");
794     return 0;
795 }
796 EOF
797 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
798 fi
799
800 if test "$mingw32" = "yes" ; then
801     v4l="no"
802     bktr="no"
803     audio_oss="no"
804     dv1394="no"
805     dc1394="no"
806     ffserver="no"
807     network="no"
808     SLIBPREF=""
809     SLIBSUF=".dll"
810     EXESUF=".exe"
811     if test "$force_prefix" != yes; then prefix="/c/Program Files/FFmpeg"; fi
812     if test "$force_libdir" != yes; then bindir="$prefix"; fi
813 fi
814
815 cc="${cross_prefix}${cc}"
816 ar="${cross_prefix}${ar}"
817 ranlib="${cross_prefix}${ranlib}"
818 strip="${cross_prefix}${strip}"
819
820 if test -z "$cross_prefix" ; then
821
822 # ---
823 # big/little endian test
824 cat > $TMPC << EOF
825 #include <inttypes.h>
826 int main(int argc, char ** argv){
827         volatile uint32_t i=0x01234567;
828         return (*((uint8_t*)(&i))) == 0x67;
829 }
830 EOF
831
832 if $cc -o $TMPE $TMPC 2>/dev/null ; then
833 $TMPE && bigendian="yes"
834 else
835 echo big/little test failed
836 fi
837
838 else
839
840 # if cross compiling, cannot launch a program, so make a static guess
841 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
842     bigendian="yes"
843 fi
844
845 fi
846
847 # ---
848 # *inttypes.h* test
849 cat > $TMPC << EOF
850 #include <inttypes.h>
851 int main(int argc, char ** argv){
852     return 0;
853 }
854 EOF
855
856 $cc -o $TMPE $TMPC 2>/dev/null || inttypes="no"
857
858 # ---
859 # *int_fast* test
860 cat > $TMPC << EOF
861 #include <inttypes.h>
862 int main(int argc, char ** argv){
863         volatile uint_fast64_t i=0x01234567;
864         return 0;
865 }
866 EOF
867
868 $cc -o $TMPE $TMPC 2>/dev/null || emu_fast_int="yes"
869
870 # ---
871 # check availability of some header files
872
873 cat > $TMPC << EOF
874 #include <malloc.h>
875 int main( void ) { return 0; }
876 EOF
877
878 _memalign=no
879 _malloc_h=no
880 if $cc -o $TMPE $TMPC 2> /dev/null ; then
881 _malloc_h=yes
882 _memalign=yes
883 # check for memalign - atmos
884 cat > $TMPC << EOF
885 #include <stdio.h>
886 #include <malloc.h>
887 int main ( void ) {
888 char *string = NULL;
889 string = memalign(64, sizeof(char));
890 return 0;
891 }
892 EOF
893 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
894 fi
895
896 if test "$_memalign" = "no" -a "$mmx" = "yes" -a "$memalignhack" != "yes"; then
897     echo "error, no memalign() but sse enabled, either disable it or use --enable-memalign-hack"
898     exit 1
899 fi
900
901 cat > $TMPC << EOF
902 #include <time.h>
903 int main( void ) { localtime_r(NULL, NULL); }
904 EOF
905
906 localtime_r=no
907 if $cc -o $TMPE $TMPC 2> /dev/null ; then
908   localtime_r=yes
909 fi
910
911 if test "$zlib" = "yes"; then
912 # check for zlib - mmu_man
913 cat > $TMPC << EOF
914 #include <zlib.h>
915 int main ( void ) {
916 if (zlibVersion() != ZLIB_VERSION)
917    puts("zlib version differs !!!");
918    return 1;
919 return 0;
920 }
921 EOF
922 $cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
923 # $TMPE 2> /dev/null > /dev/null || zlib="no"
924 # XXX: more tests needed - runtime test
925 fi
926 if test "$zlib" = "yes"; then
927 extralibs="$extralibs -lz"
928 fi
929
930 # test for lrintf in math.h
931 cat > $TMPC << EOF
932 #define _ISOC9X_SOURCE  1
933 #include <math.h>
934 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
935 EOF
936
937 have_lrintf="no"
938 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
939   have_lrintf="yes"
940   # allanc@chickenandporn.com: cannot execute cross-compiled
941   # code on the host.  Only execute if not cross-compiling.
942   if test -z "$cross_prefix" ; then
943     $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
944   fi
945 fi
946
947 _restrict=
948 for restrict_keyword in restrict __restrict__ __restrict; do
949   echo "void foo(char * $restrict_keyword p);" > $TMPC
950   if $cc -c -o $TMPO $TMPC 2> /dev/null; then
951     _restrict=$restrict_keyword
952     break;
953   fi
954 done
955
956 # test gcc version to see if vector builtins can be used
957 # currently only used on i386 for MMX builtins
958 cat > $TMPC << EOF
959 #include <xmmintrin.h>
960 int main(void) { 
961 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
962 return 0;
963 #else
964 #error no vector builtins
965 #endif
966 }
967 EOF
968
969 builtin_vector=no
970 if $cc -msse -o $TMPO $TMPC 2> /dev/null ; then
971   builtin_vector=yes
972 fi
973
974 # dlopen/dlfcn.h probing
975
976 cat > $TMPC << EOF
977 #include <dlfcn.h>
978 int main( void ) { return (int) dlopen("foo", 0); }
979 EOF
980
981 ldl=-ldl
982
983 if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1 ; then
984 dlfcn=yes
985 dlopen=yes
986 fi
987
988 if $cc -o $TMPE $TMPC > /dev/null 2>&1 ; then
989 dlfcn=yes
990 dlopen=yes
991 ldl=""
992 fi
993
994 cat > $TMPC << EOF
995 int main( void ) { return (int) dlopen("foo", 0); }
996 EOF
997
998 if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1  ; then
999 dlopen=yes
1000 fi
1001
1002 if $cc -o $TMPE $TMPC > /dev/null 2>&1  ; then
1003 dlopen=yes
1004 ldl=""
1005 fi
1006
1007 if test "$vhook" = "default" ; then
1008   vhook="$dlopen"
1009 fi
1010
1011 if test "$vhook" = "yes" -o "$a52bin" = "yes" -o "$faadbin" = "yes"; then
1012   extralibs="$extralibs $ldl"
1013 fi
1014
1015
1016 ##########################################
1017 # imlib probe
1018
1019 cat > $TMPC << EOF
1020 #include <X11/Xlib.h>
1021 #include <Imlib2.h>
1022 int main( void ) { return (int) imlib_load_font("foo"); }
1023 EOF
1024
1025 imlib2=no
1026 if $cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lImlib2 -lm > /dev/null 2>&1  ; then
1027 imlib2=yes
1028 fi
1029
1030 ##########################################
1031 # freetype probe
1032
1033 cat > $TMPC << EOF
1034 #include <ft2build.h>
1035 int main( void ) { return (int) FT_Init_FreeType(0); }
1036 EOF
1037
1038 freetype2=no
1039 if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
1040   if (freetype-config --version) >/dev/null 2>&1 ; then
1041     if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs`  > /dev/null 2>&1 ; then
1042       freetype2=yes
1043     fi
1044   fi
1045 fi
1046
1047 ##########################################
1048 # SDL probe
1049
1050 cat > $TMPC << EOF
1051 #include <SDL.h>
1052 #undef main /* We don't want SDL to override our main() */
1053 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1054 EOF
1055
1056 sdl_too_old=no
1057 sdl=no
1058 if (sdl-config --version) >/dev/null 2>&1 ; then
1059 if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs`  > /dev/null 2>&1  ; then
1060 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
1061 if test "$_sdlversion" -lt 121 ; then
1062 sdl_too_old=yes
1063 else
1064 sdl=yes
1065 fi
1066 fi
1067 fi
1068
1069 ##########################################
1070 # texi2html probe
1071
1072 texi2html=no
1073 if (texi2html -version) >/dev/null 2>&1; then
1074 texi2html=yes
1075 fi
1076
1077 if test "$network" = "yes" ; then
1078 ##########################################
1079 # IPv6 probe
1080
1081 cat > $TMPC << EOF
1082 #include <sys/types.h>
1083 #include <sys/socket.h>
1084 #include <netinet/in.h>
1085 #include <netdb.h>
1086 int main( void ) {
1087   struct sockaddr_storage saddr;
1088   struct ipv6_mreq mreq6;
1089   getaddrinfo(0,0,0,0);
1090   getnameinfo(0,0,0,0,0,0,0);
1091   IN6_IS_ADDR_MULTICAST(0);
1092 }
1093 EOF
1094
1095 ipv6=no
1096 if $cc -o $TMPE $TMPC > /dev/null 2>&1  ; then
1097 ipv6=yes
1098 fi
1099 fi
1100
1101 case "`$cc -v 2>&1 | grep version`" in
1102     *gcc*)
1103         CFLAGS="-Wall -Wno-switch $CFLAGS"
1104         ;;
1105     *)
1106         ;;
1107 esac
1108
1109 if test "$sdl" = "no" ; then
1110    ffplay=no
1111 fi
1112
1113 if test "$debug" = "yes"; then
1114         CFLAGS="-g $CFLAGS"
1115 fi
1116
1117 if test "$optimize" = "small"; then
1118 #  CFLAGS=${CFLAGS//-O3/-Os}
1119   CFLAGS="$CFLAGS -Os"
1120 fi
1121
1122 if test "$optimize" = "yes"; then
1123     if test -n "`$cc -v 2>&1 | grep xlc`"; then
1124         CFLAGS="$CFLAGS -O5"
1125         LDFLAGS="$LDFLAGS -O5"
1126     else
1127         CFLAGS="-O3 $CFLAGS"
1128     fi
1129 fi
1130
1131 # PIC flags for shared library objects where they are needed
1132 if test "$lshared" = "yes" ; then
1133   # LIBOBJFLAGS may have already been set in the OS configuration
1134   if test -z "$LIBOBJFLAGS" ; then
1135     if test "$cpu" = "x86_64" -o "$cpu" = "ia64" ; then
1136       LIBOBJFLAGS="\$(PIC)"
1137     fi
1138   fi
1139 fi
1140
1141 if test x"$bindir" = x""; then
1142 bindir="${prefix}/bin"
1143 fi
1144
1145 if test x"$libdir" = x""; then
1146 libdir="${prefix}/lib"
1147 fi
1148
1149 if test x"$mandir" = x""; then
1150 mandir="${prefix}/man"
1151 fi
1152
1153 echo "Install prefix   $prefix"
1154 echo "Source path      $source_path"
1155 echo "C compiler       $cc"
1156 echo "make             $make"
1157 echo "CPU              $cpu ($tune)"
1158 if test "$BUILDSUF" != ""; then
1159 echo "Build suffix     $BUILDSUF"
1160 fi
1161 echo "Big Endian       $bigendian"
1162 echo "inttypes.h       $inttypes"
1163 echo "broken inttypes.h $emu_fast_int"
1164 if test $cpu = "x86" -o $cpu = "x86_64"; then
1165 echo "MMX enabled      $mmx"
1166 echo "Vector Builtins  $builtin_vector"
1167 fi
1168 if test $cpu = "armv4l"; then
1169 echo "IWMMXT enabled   $iwmmxt"
1170 fi
1171 if test $cpu = "mips"; then
1172 echo "MMI enabled      $mmi"
1173 fi
1174 if test $cpu = "powerpc"; then
1175 echo "AltiVec enabled  $altivec"
1176 fi
1177 echo "gprof enabled    $gprof"
1178 echo "zlib enabled     $zlib"
1179 echo "libgsm enabled   $libgsm"
1180 echo "mp3lame enabled  $mp3lame"
1181 echo "libogg enabled   $libogg"
1182 echo "vorbis enabled   $vorbis"
1183 echo "theora enabled   $theora"
1184 echo "faad enabled     $faad"
1185 echo "faadbin enabled  $faadbin"
1186 echo "faac enabled     $faac"
1187 echo "xvid enabled     $xvid"
1188 echo "x264 enabled     $x264"
1189 echo "a52 support      $a52"
1190 echo "a52 dlopened     $a52bin"
1191 echo "dts support      $dts"
1192 echo "pp support       $pp"
1193 echo "debug symbols    $debug"
1194 echo "strip symbols    $dostrip"
1195 echo "optimize         $optimize"
1196 echo "shared pp        $shared_pp"
1197 echo "Video hooking    $vhook"
1198 echo "SDL support      $sdl"
1199 if test $sdl_too_old = "yes"; then
1200 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
1201 fi
1202
1203 if test "$vhook" = "yes" ; then
1204 echo "Imlib2 support   $imlib2"
1205 echo "freetype support $freetype2"
1206 fi
1207 echo "Sun medialib support"  $sunmlib
1208 echo "pthreads support"      $pthreads
1209 echo "AMR-NB float support"  $amr_nb
1210 echo "AMR-NB fixed support"  $amr_nb_fixed
1211 echo "AMR-WB float support"  $amr_wb
1212 echo "AMR-WB IF2 support"    $amr_if2
1213 echo "network support      $network"
1214 if test "$network" = "yes" ; then
1215 echo "IPv6 support         $ipv6"
1216 fi
1217 if test "$gpl" = "no" ; then
1218 echo "License: LGPL"
1219 else
1220 echo "License: GPL"
1221 fi
1222
1223 echo "Creating config.mak and config.h"
1224
1225 date >> config.log
1226 echo "   $0 $FFMPEG_CONFIGURATION" >> config.log
1227 echo "# Automatically generated by configure - do not modify" > config.mak
1228 echo "/* Automatically generated by configure - do not modify */" > $TMPH
1229 echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
1230
1231 echo "prefix=$prefix" >> config.mak
1232 echo "libdir=$libdir" >> config.mak
1233 echo "bindir=$bindir" >> config.mak
1234 echo "mandir=$mandir" >> config.mak
1235 echo "MAKE=$make" >> config.mak
1236 echo "CC=$cc" >> config.mak
1237 echo "AR=$ar" >> config.mak
1238 echo "RANLIB=$ranlib" >> config.mak
1239 if test "$dostrip" = "yes" ; then
1240 echo "STRIP=$strip" >> config.mak
1241 echo "INSTALLSTRIP=-s" >> config.mak
1242 else
1243 echo "STRIP=echo ignoring strip" >> config.mak
1244 echo "INSTALLSTRIP=" >> config.mak
1245 fi
1246
1247 # SHCFLAGS is a copy of CFLAGS without -mdynamic-no-pic.  Used when building 
1248 # shared modules on OS/X (vhook/Makefile).
1249 SHCFLAGS=$CFLAGS
1250 if test "$needmdynamicnopic" = yes; then
1251    CFLAGS="$CFLAGS -mdynamic-no-pic"
1252 fi
1253
1254 echo "OPTFLAGS=$CFLAGS" >> config.mak
1255 echo "SHCFLAGS=$SHCFLAGS">>config.mak
1256 echo "LDFLAGS=$LDFLAGS" >> config.mak
1257 echo "LDCONFIG=$LDCONFIG" >> config.mak
1258 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
1259 echo "SHFLAGS=$SHFLAGS" >> config.mak
1260 echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1261 echo "BUILDSUF=$BUILDSUF" >> config.mak
1262 echo "LIBPREF=$LIBPREF" >> config.mak
1263 echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1264 echo "SLIBPREF=$SLIBPREF" >> config.mak
1265 echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1266 echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1267 echo "TARGET_OS=$TARGET_OS" >> config.mak
1268 if test "$cpu" = "x86" ; then
1269   echo "TARGET_ARCH_X86=yes" >> config.mak
1270   echo "#define ARCH_X86 1" >> $TMPH
1271 elif test "$cpu" = "x86_64" ; then
1272   echo "TARGET_ARCH_X86_64=yes" >> config.mak
1273   echo "#define ARCH_X86_64 1" >> $TMPH
1274 elif test "$cpu" = "armv4l" ; then
1275   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
1276   echo "#define ARCH_ARMV4L 1" >> $TMPH
1277 elif test "$cpu" = "alpha" ; then
1278   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
1279   echo "#define ARCH_ALPHA 1" >> $TMPH
1280 elif test "$cpu" = "sparc64" ; then
1281   echo "TARGET_ARCH_SPARC64=yes" >> config.mak
1282   echo "#define ARCH_SPARC64 1" >> $TMPH
1283   echo "TARGET_ARCH_SPARC=yes" >> config.mak
1284   echo "#define ARCH_SPARC 1" >> $TMPH
1285 elif test "$cpu" = "sparc" ; then
1286   echo "TARGET_ARCH_SPARC=yes" >> config.mak
1287   echo "#define ARCH_SPARC 1" >> $TMPH
1288 elif test "$cpu" = "powerpc" ; then
1289   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
1290   echo "#define ARCH_POWERPC 1" >> $TMPH
1291   if test $POWERPCMODE = "32bits"; then
1292     echo "#define POWERPC_MODE_32BITS 1" >> $TMPH
1293   else
1294     echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1295   fi
1296   if test "$powerpc_perf" = "yes"; then
1297     echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
1298   fi
1299 elif test "$cpu" = "mips" ; then
1300   echo "TARGET_ARCH_MIPS=yes" >> config.mak
1301   echo "#define ARCH_MIPS 1" >> $TMPH
1302 elif test "$cpu" = "sh4" ; then
1303   echo "TARGET_ARCH_SH4=yes" >> config.mak
1304   echo "#define ARCH_SH4 1" >> $TMPH
1305 fi
1306 echo "#define TUNECPU $TUNECPU" >> $TMPH
1307 if test "$bigendian" = "yes" ; then
1308   echo "WORDS_BIGENDIAN=yes" >> config.mak
1309   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1310 fi
1311 if test "$inttypes" != "yes" ; then
1312   echo "#define EMULATE_INTTYPES 1" >> $TMPH
1313 fi
1314 if test "$emu_fast_int" = "yes" ; then
1315   echo "#define EMULATE_FAST_INT 1" >> $TMPH
1316 fi
1317 if test "$mmx" = "yes" ; then
1318   echo "TARGET_MMX=yes" >> config.mak
1319   echo "#define HAVE_MMX 1" >> $TMPH
1320   echo "#define __CPU__ 586" >> $TMPH
1321 fi
1322 if test "$builtin_vector" = "yes" ; then
1323   echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
1324   echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
1325 fi
1326 if test "$iwmmxt" = "yes" ; then
1327   echo "TARGET_IWMMXT=yes" >> config.mak
1328   echo "#define HAVE_IWMMXT 1" >> $TMPH
1329 fi
1330 if test "$mmi" = "yes" ; then
1331   echo "TARGET_MMI=yes" >> config.mak
1332   echo "#define HAVE_MMI 1" >> $TMPH
1333 fi
1334 if test "$altivec" = "yes" ; then
1335   echo "TARGET_ALTIVEC=yes" >> config.mak
1336   echo "#define HAVE_ALTIVEC 1" >> $TMPH
1337   echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
1338   echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
1339   if test "$_altivec_h" = "yes" ; then
1340     echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
1341   else
1342     echo "#undef HAVE_ALTIVEC_H" >> $TMPH
1343   fi
1344 fi
1345 if test "$gprof" = "yes" ; then
1346   echo "TARGET_GPROF=yes" >> config.mak
1347   echo "#define HAVE_GPROF 1" >> $TMPH
1348 fi
1349 if test "$localtime_r" = "yes" ; then
1350   echo "#define HAVE_LOCALTIME_R 1" >> $TMPH
1351 fi
1352 if test "$imlib2" = "yes" ; then
1353   echo "HAVE_IMLIB2=yes" >> config.mak
1354 fi
1355 if test "$freetype2" = "yes" ; then
1356   echo "HAVE_FREETYPE2=yes" >> config.mak
1357 fi
1358 if test "$sunmlib" = "yes" ; then
1359   echo "HAVE_MLIB=yes" >> config.mak
1360   echo "#define HAVE_MLIB 1" >> $TMPH
1361   extralibs="$extralibs -lmlib"
1362 fi
1363 if test "$pthreads" = "yes" ; then
1364   echo "HAVE_PTHREADS=yes" >> config.mak
1365   echo "#define HAVE_PTHREADS 1" >> $TMPH
1366   echo "#define HAVE_THREADS 1" >> $TMPH
1367   if test $targetos != FreeBSD -a $targetos != OpenBSD ; then
1368      extralibs="$extralibs -lpthread"
1369   fi
1370 fi
1371 if test "$sdl" = "yes" ; then
1372   echo "CONFIG_SDL=yes" >> config.mak
1373   echo "SDL_LIBS=`sdl-config --libs`" >> config.mak
1374   echo "SDL_CFLAGS=`sdl-config --cflags`" >> config.mak
1375 fi
1376 if test "$texi2html" = "yes"; then
1377   echo "BUILD_DOC=yes" >> config.mak
1378 fi
1379 if test "$have_lrintf" = "yes" ; then
1380   echo "#define HAVE_LRINTF 1" >> $TMPH
1381 fi
1382 if test "$vhook" = "yes" ; then
1383   echo "BUILD_VHOOK=yes" >> config.mak
1384   echo "#define HAVE_VHOOK 1" >> $TMPH
1385 fi
1386 if test "$lshared" = "yes" ; then
1387   echo "BUILD_SHARED=yes" >> config.mak
1388   echo "PIC=-fPIC -DPIC" >> config.mak
1389 fi
1390 echo "EXTRALIBS=$extralibs" >> config.mak
1391 version=`grep '#define FFMPEG_VERSION ' "$source_path/libavcodec/avcodec.h" |
1392  cut -d '"' -f 2`
1393 echo "VERSION=$version" >>config.mak
1394 # if you do not want to use encoders, disable that.
1395 echo "#define CONFIG_ENCODERS 1" >> $TMPH
1396 echo "CONFIG_ENCODERS=yes" >> config.mak
1397
1398 # if you do not want to use decoders, disable that.
1399 echo "#define CONFIG_DECODERS 1" >> $TMPH
1400 echo "CONFIG_DECODERS=yes" >> config.mak
1401
1402 # AC3
1403 if test "$a52" = "yes" ; then
1404   echo "#define CONFIG_AC3 1" >> $TMPH
1405   echo "CONFIG_AC3=yes" >> config.mak
1406
1407   if test "$a52bin" = "yes" ; then
1408     echo "#define CONFIG_A52BIN 1" >> $TMPH
1409     echo "CONFIG_A52BIN=yes" >> config.mak
1410   fi
1411 fi
1412
1413 # DTS
1414 if test "$dts" = "yes" ; then
1415   echo "#define CONFIG_DTS 1" >> $TMPH
1416   echo "CONFIG_DTS=yes" >> config.mak
1417 fi
1418
1419 # PP
1420 if test "$pp" = "yes" ; then
1421   echo "#define CONFIG_PP 1" >> $TMPH
1422   echo "CONFIG_PP=yes" >> config.mak
1423
1424   if test "$shared_pp" = "yes" ; then
1425     echo "#define SHARED_PP 1" >> $TMPH
1426     echo "SHARED_PP=yes" >> config.mak
1427   fi
1428 fi
1429
1430 # mpeg audio high precision mode
1431 if test "$mpegaudio_hp" = "yes" ; then
1432   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
1433 fi
1434
1435 if test "$v4l" = "yes" ; then
1436   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
1437   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
1438 fi
1439
1440 if test "$bktr" = "yes" ; then
1441   echo "#define CONFIG_BKTR 1" >> $TMPH
1442   echo "CONFIG_BKTR=yes" >> config.mak
1443 fi
1444
1445 if test "$dv1394" = "yes" ; then
1446   echo "#define CONFIG_DV1394 1" >> $TMPH
1447   echo "CONFIG_DV1394=yes" >> config.mak
1448 fi
1449
1450 if test "$dc1394" = "yes" ; then
1451   echo "#define CONFIG_DC1394 1" >> $TMPH
1452   echo "CONFIG_DC1394=yes" >> config.mak
1453 fi
1454
1455 if test "$dlopen" = "yes" ; then
1456   echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
1457 fi
1458
1459 if test "$dlfcn" = "yes" ; then
1460   echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
1461 fi
1462
1463 if test "$audio_oss" = "yes" ; then
1464   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
1465   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
1466 fi
1467
1468 if test "$audio_beos" = "yes" ; then
1469   echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
1470   echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
1471 fi
1472
1473 if test "$network" = "yes" ; then
1474   echo "#define CONFIG_NETWORK 1" >> $TMPH
1475   echo "CONFIG_NETWORK=yes" >> config.mak
1476 fi
1477
1478 if test "$ipv6" = "yes" ; then
1479   echo "#define CONFIG_IPV6 1" >> $TMPH
1480 fi
1481
1482 if test "$zlib" = "yes" ; then
1483   echo "#define CONFIG_ZLIB 1" >> $TMPH
1484   echo "CONFIG_ZLIB=yes" >> config.mak
1485 fi
1486
1487 if test "$libgsm" = "yes" ; then
1488   echo "#define CONFIG_LIBGSM 1" >> $TMPH
1489   echo "CONFIG_LIBGSM=yes" >> config.mak
1490 fi
1491
1492 if test "$mp3lame" = "yes" ; then
1493   echo "#define CONFIG_MP3LAME 1" >> $TMPH
1494   echo "CONFIG_MP3LAME=yes" >> config.mak
1495 fi
1496
1497 if test "$libogg" = "yes" ; then
1498   echo "#define CONFIG_LIBOGG 1" >> $TMPH
1499   echo "CONFIG_LIBOGG=yes" >> config.mak
1500 fi
1501
1502 if test "$vorbis" = "yes" ; then
1503   echo "#define CONFIG_LIBVORBIS 1" >> $TMPH
1504   echo "CONFIG_LIBVORBIS=yes" >> config.mak
1505 fi
1506
1507 if test "$theora" = "yes" ; then
1508   echo "#define CONFIG_LIBTHEORA 1" >> $TMPH
1509   echo "CONFIG_LIBTHEORA=yes" >> config.mak
1510 fi
1511
1512 if test "$faad" = "yes" ; then
1513   echo "#define CONFIG_FAAD 1" >> $TMPH
1514   echo "CONFIG_FAAD=yes" >> config.mak
1515 fi
1516
1517 if test "$faadbin" = "yes" ; then
1518   echo "#define CONFIG_FAADBIN 1" >> $TMPH
1519   echo "CONFIG_FAADBIN=yes" >> config.mak
1520 fi
1521
1522 if test "$faac" = "yes" ; then
1523   echo "#define CONFIG_FAAC 1" >> $TMPH
1524   echo "CONFIG_FAAC=yes" >> config.mak
1525 fi
1526
1527 if test "$xvid" = "yes" ; then
1528   echo "#define CONFIG_XVID 1" >> $TMPH
1529   echo "CONFIG_XVID=yes" >> config.mak
1530 fi
1531
1532 if test "$x264" = "yes" ; then
1533   echo "#define CONFIG_X264 1" >> $TMPH
1534   echo "CONFIG_X264=yes" >> config.mak
1535 fi
1536
1537 if test "$mingw32" = "yes" ; then
1538   echo "#define CONFIG_WIN32 1" >> $TMPH
1539   echo "CONFIG_WIN32=yes" >> config.mak
1540   echo "HAVE_W32THREADS=yes" >> config.mak
1541   echo "#define HAVE_W32THREADS 1" >> $TMPH
1542   echo "#define HAVE_THREADS 1" >> $TMPH
1543   echo "#ifndef __MINGW32__" >> $TMPH
1544   echo "#define __MINGW32__ 1" >> $TMPH
1545   echo "#endif" >> $TMPH
1546 fi
1547
1548 if test "$os2" = "yes" ; then
1549   echo "#define CONFIG_OS2 1" >> $TMPH
1550   echo "CONFIG_OS2=yes" >> config.mak
1551 fi
1552
1553 if test "$TARGET_OS" = "SunOS" ; then
1554   echo "#define CONFIG_SUNOS 1" >> $TMPH
1555 fi
1556
1557 if test "$TARGET_OS" = "BeOS" ; then
1558   echo "HAVE_BEOSTHREADS=yes" >> config.mak
1559   echo "#define HAVE_BEOSTHREADS 1" >> $TMPH
1560   echo "#define HAVE_THREADS 1" >> $TMPH
1561 fi
1562
1563 if test "$darwin" = "yes"; then
1564   echo "#define CONFIG_DARWIN 1"  >> $TMPH
1565   echo "CONFIG_DARWIN=yes" >> config.mak
1566 fi
1567
1568 if test "$_malloc_h" = "yes" ; then
1569   echo "#define HAVE_MALLOC_H 1" >> $TMPH
1570 else
1571   echo "#undef  HAVE_MALLOC_H" >> $TMPH
1572 fi
1573
1574 if test "$_memalign" = "yes" ; then
1575   echo "#define HAVE_MEMALIGN 1" >> $TMPH
1576 else
1577   echo "#undef  HAVE_MEMALIGN" >> $TMPH
1578 fi
1579
1580 if test "$memalignhack" = "yes" ; then
1581   echo "#define MEMALIGN_HACK 1" >> $TMPH
1582 fi
1583
1584
1585 if test "$netserver" = "yes" ; then
1586   echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
1587   echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
1588 fi
1589
1590 if test "$need_inet_aton" = "yes" ; then
1591   echo "NEED_INET_ATON=yes" >> config.mak
1592 fi
1593
1594 if test "$simpleidct" = "yes" ; then
1595   echo "#define SIMPLE_IDCT 1" >> $TMPH
1596 fi
1597
1598 if test "$ffserver" = "yes" ; then
1599   echo "#define CONFIG_FFSERVER 1" >> $TMPH
1600   echo "CONFIG_FFSERVER=yes" >> config.mak
1601 fi
1602
1603 if test "$ffplay" = "yes" ; then
1604   echo "CONFIG_FFPLAY=yes" >> config.mak
1605 fi
1606
1607 if test "$gpl" = "yes" ; then
1608   echo "#define CONFIG_GPL 1" >> $TMPH
1609   echo "CONFIG_GPL=yes" >> config.mak
1610 fi
1611
1612 echo "#define restrict $_restrict" >> $TMPH
1613
1614 if test "$optimize" = "small"; then
1615   echo "#define always_inline"  >> $TMPH
1616 fi
1617
1618 # build tree in object directory if source path is different from current one
1619 if test "$source_path_used" = "yes" ; then
1620     DIRS="\
1621          doc \
1622          libavformat \
1623          libavcodec \
1624          libavcodec/alpha \
1625          libavcodec/armv4l \
1626          libavcodec/i386 \
1627          libavcodec/sparc \
1628          libavcodec/mlib \
1629          libavcodec/ppc \
1630          libavcodec/liba52 \
1631          libavcodec/libpostproc \
1632          libavutil \
1633          tests \
1634          vhook \
1635          "
1636     FILES="\
1637           Makefile \
1638           libavformat/Makefile \
1639           libavcodec/Makefile \
1640           libavcodec/libpostproc/Makefile \
1641           libavutil/Makefile \
1642           tests/Makefile \
1643           vhook/Makefile \
1644           doc/Makefile \
1645           doc/texi2pod.pl \
1646           "
1647     for dir in $DIRS ; do
1648             mkdir -p $dir
1649     done
1650     for f in $FILES ; do
1651         ln -sf "$source_path/$f" $f
1652     done
1653     echo "SRC_PATH=$source_path" >> config.mak
1654 else
1655     echo "SRC_PATH='$source_path'" >> config.mak
1656 fi
1657
1658 if test "$amr_wb" = "yes" ; then
1659   echo "#define AMR_WB 1" >> $TMPH
1660   echo "AMR_WB=yes" >> config.mak
1661   echo
1662   echo "AMR WB FLOAT NOTICE ! Make sure you have downloaded TS26.204"
1663   echo "V5.1.0 from "
1664   echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip"
1665   echo "and extracted the source to libavcodec/amrwb_float"
1666   echo
1667 fi
1668
1669 if test "$amr_nb" = "yes" ; then
1670   echo "#define AMR_NB 1" >> $TMPH
1671   echo "AMR_NB=yes" >> config.mak
1672   echo
1673 if test "$amr_nb_fixed" = "yes" ; then
1674   echo "AMR_NB_FIXED=yes" >> config.mak
1675   echo "#define AMR_NB_FIXED 1" >> $TMPH
1676   echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
1677   echo "REL-5 version 5.1.0 from "
1678   echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-5??.zip"
1679   echo "and extracted src to libavcodec/amr"
1680   echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
1681   echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
1682   echo
1683 else
1684   echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
1685   echo "REL-5 V5.1.0 from "
1686   echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-5??.zip"
1687   echo "and extracted the source to libavcodec/amr_float"
1688   echo "and if u try this on an alpha, u may need to change Word32 to int in amr/typedef.h"
1689   echo
1690 fi
1691
1692 if test "$amr_if2" = "yes" ; then
1693   echo "AMR_CFLAGS=-DIF2=1" >> config.mak
1694 fi
1695
1696 fi
1697
1698 for codec in $CODEC_LIST ; do
1699     echo "#define CONFIG_`echo $codec | tr a-z A-Z` 1" >> $TMPH
1700     echo "CONFIG_`echo $codec | tr a-z A-Z`=yes" >> config.mak
1701 done
1702
1703 diff $TMPH config.h >/dev/null 2>&1
1704 if test $? -ne 0 ; then
1705         mv -f $TMPH config.h
1706 else
1707         echo "config.h is unchanged"
1708 fi
1709
1710 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
1711
1712
1713 # build pkg-config files libavcodec.pc, libavformat.pc and libpostproc.pc 
1714 lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1715 lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1716 lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1717
1718 requires=
1719 test "$libogg" = "yes" && requires="$requires ogg >= 1.1"
1720 test "$vorbis" = "yes" && requires="$requires vorbis"
1721 test "$theora" = "yes" && requires="$requires theora"
1722 test "$faad" = "yes" && test "$faadbin" = "no" && extralibs="$extralibs -lfaad"
1723
1724 # libavutil.pc
1725 cat <<EOF >libavutil.pc
1726 prefix=$prefix
1727 exec_prefix=\${prefix}
1728 libdir=\${exec_prefix}/lib
1729 includedir=\${prefix}/include
1730
1731 Name: libavutil
1732 Description: FFmpeg utility library
1733 Version: $lavu_version
1734 Requires: 
1735 Conflicts:
1736 Libs: -L\${libdir} -lavutil
1737 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
1738 EOF
1739
1740 cat <<EOF >libavutil-uninstalled.pc
1741 prefix=
1742 exec_prefix=
1743 libdir=\${pcfiledir}/libavutil
1744 includedir=\${pcfiledir}/libavutil
1745
1746 Name: libavutil
1747 Description: FFmpeg utility library
1748 Version: $lavu_version
1749 Requires: 
1750 Conflicts:
1751 Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
1752 Cflags: -I\${includedir}
1753 EOF
1754
1755 # libavcodec.pc
1756 cat <<EOF >libavcodec.pc
1757 prefix=$prefix
1758 exec_prefix=\${prefix}
1759 libdir=\${exec_prefix}/lib
1760 includedir=\${prefix}/include
1761
1762 Name: libavcodec
1763 Description: FFmpeg codec library
1764 Version: $lavc_version
1765 Requires: $requires libavutil = $lavu_version
1766 Conflicts:
1767 Libs: -L\${libdir} -lavcodec $extralibs
1768 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
1769 EOF
1770
1771 cat <<EOF >libavcodec-uninstalled.pc
1772 prefix=
1773 exec_prefix=
1774 libdir=\${pcfiledir}/libavcodec
1775 includedir=\${pcfiledir}/libavcodec
1776
1777 Name: libavcodec
1778 Description: FFmpeg codec library
1779 Version: $lavc_version
1780 Requires: $requires libavutil = $lavu_version
1781 Conflicts:
1782 Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
1783 Cflags: -I\${includedir}
1784 EOF
1785
1786 # libavformat.pc
1787 cat <<EOF >libavformat.pc
1788 prefix=$prefix
1789 exec_prefix=\${prefix}
1790 libdir=\${exec_prefix}/lib
1791 includedir=\${prefix}/include
1792
1793 Name: libavformat
1794 Description: FFmpeg container format library
1795 Version: $lavf_version
1796 Requires: $requires libavcodec = $lavc_version
1797 Conflicts:
1798 Libs: -L\${libdir} -lavformat $extralibs
1799 Cflags: -I\${includedir} -I\${includedir}/ffmpeg
1800 EOF
1801
1802 cat <<EOF >libavformat-uninstalled.pc
1803 prefix=
1804 exec_prefix=
1805 libdir=\${pcfiledir}/libavformat
1806 includedir=\${pcfiledir}/libavformat
1807
1808 Name: libavformat
1809 Description: FFmpeg container format library
1810 Version: $lavf_version
1811 Requires: $requires libavcodec = $lavc_version
1812 Conflicts:
1813 Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
1814 Cflags: -I\${includedir}
1815 EOF
1816
1817
1818 # libpostproc.pc
1819 cat <<EOF >libpostproc.pc
1820 prefix=$prefix
1821 exec_prefix=\${prefix}
1822 libdir=\${exec_prefix}/lib
1823 includedir=\${prefix}/include
1824
1825 Name: libpostproc
1826 Description: FFmpeg post processing library
1827 Version: $lavc_version
1828 Requires: 
1829 Conflicts:
1830 Libs: -L\${libdir} -lpostproc
1831 Cflags: -I\${includedir} -I\${includedir}/postproc
1832 EOF
1833
1834 cat <<EOF >libpostproc-uninstalled.pc
1835 prefix=
1836 exec_prefix=
1837 libdir=\${pcfiledir}/libavcodec/libpostproc
1838 includedir=\${pcfiledir}/libavcodec/libpostproc
1839
1840 Name: libpostproc
1841 Description: FFmpeg post processing library
1842 Version: $lavc_version
1843 Requires: 
1844 Conflicts:
1845 Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
1846 Cflags: -I\${includedir}
1847 EOF