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