]> git.sesse.net Git - ffmpeg/blob - configure
restore old tty in ffmpeg patch by (Roumen Petrov <ffmpeg at roumenpetrov dot info>)
[ffmpeg] / configure
1 #!/bin/sh
2 #
3 # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4 #
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
7     TMPDIR1="${TMPDIR}"
8 elif test ! -z "$TEMPDIR" ; then
9     TMPDIR1="${TEMPDIR}"
10 else
11     TMPDIR1="/tmp"
12 fi
13
14 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
19
20 # default parameters
21 prefix="/usr/local"
22 cross_prefix=""
23 cc="gcc"
24 ar="ar"
25 ranlib="ranlib"
26 make="make"
27 strip="strip"
28 cpu=`uname -m`
29 mmx="default"
30 altivec="default"
31 mmi="default"
32 case "$cpu" in
33   i386|i486|i586|i686|i86pc|BePC)
34     cpu="x86"
35   ;;
36   armv4l)
37     cpu="armv4l"
38   ;;
39   alpha)
40     cpu="alpha"
41   ;;
42   "Power Macintosh"|ppc)
43     cpu="powerpc"
44   ;;
45   mips)
46     cpu="mips"
47   ;;
48   *)
49     cpu="unknown"
50   ;;
51 esac
52 gprof="no"
53 v4l="yes"
54 audio_oss="yes"
55 audio_beos="no"
56 dv1394="yes"
57 network="yes"
58 zlib="yes"
59 mp3lame="no"
60 vorbis="no"
61 a52="yes"
62 a52bin="no"
63 pp="yes"
64 shared_pp="no"
65 win32="no"
66 mingw32="no"
67 cygwin="no"
68 os2="no"
69 lshared="no"
70 extralibs="-lm"
71 simpleidct="yes"
72 bigendian="no"
73 vhook="default"
74 dlfcn="no"
75 dlopen="no"
76 mpegaudio_hp="yes"
77 SHFLAGS=-shared
78 netserver="no"
79 need_inet_aton="no"
80 ffserver="yes"
81 LDFLAGS=-Wl,--warn-common
82 FFSLDFLAGS=-Wl,-E
83 LIBPREF="lib"
84 LIBSUF=".a"
85 SLIBPREF="lib"
86 SLIBSUF=".so"
87 risky="yes"
88 small="no"
89
90 # OS specific
91 targetos=`uname -s`
92 case $targetos in
93 BeOS)
94 prefix="/boot/home/config"
95 # helps building libavcodec
96 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
97 # 3 gcc releases known for BeOS, each with ugly bugs
98 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
99 case "$gcc_version" in
100 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
101 mmx="no"
102 ;;
103 *20010315*) echo "BeBits gcc"
104 CFLAGS="$CFLAGS -fno-expensive-optimizations"
105 ;;
106 esac
107 SHFLAGS=-nostart
108 # disable linux things
109 audio_oss="no"
110 v4l="no"
111 dv1394="no"
112 # enable beos things
113 audio_beos="yes"
114 # no need for libm, but the inet stuff
115 # Check for BONE
116 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
117 extralibs="-lbind -lsocket"
118 else
119 netserver="yes"
120 need_inet_aton="yes"
121 extralibs="-lnet"
122 fi ;;
123 SunOS)
124 v4l="no"
125 audio_oss="no"
126 dv1394="no"
127 make="gmake"
128 LDFLAGS=""
129 FFSLDFLAGS=""
130 need_inet_aton="yes"
131 extralibs="$extralibs -lsocket -lnsl"
132 ;;
133 FreeBSD)
134 v4l="no"
135 audio_oss="yes"
136 dv1394="no"
137 make="gmake"
138 LDFLAGS="$LDFLAGS -export-dynamic"
139 ;;
140 BSD/OS)
141 v4l="no"
142 audio_oss="yes"
143 dv1394="no"
144 extralibs="-lpoll -lgnugetopt -lm"
145 make="gmake"
146 ;;
147 Darwin)
148 cc="cc"
149 v4l="no"
150 audio_oss="no"
151 dv1394="no"
152 SHFLAGS="-dynamiclib"
153 extralibs=""
154 darwin="yes"
155 strip="strip -x"
156 LDFLAGS="-d"
157 FFSLDFLAGS=-Wl,-bind_at_load
158 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
159 case "$gcc_version" in
160 *2.95*) 
161 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
162 ;;
163 *) 
164 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
165 ;;
166 esac
167 ;;
168 MINGW32*)
169 v4l="no"
170 audio_oss="no"
171 dv1394="no"
172 ffserver="no"
173 network="no"
174 mingw32="yes"
175 ;;
176 CYGWIN*)
177 v4l="no"
178 audio_oss="yes"
179 dv1394="no"
180 extralibs=""
181 cygwin="yes"
182 test -f /usr/include/inttypes.h || \
183 test -f /usr/local/include/inttypes.h || \
184 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
185      "/usr/include/inttypes.h !!!"
186 ;;
187 Linux)
188 LDFLAGS="$LDFLAGS -rdynamic"
189 ;;
190 OS/2)
191 TMPE=$TMPE".exe"
192 ar="emxomfar -p64"
193 ranlib="echo ignoring ranlib"
194 strip="echo ignoring strip"
195 CFLAGS="-Zomf -O3"
196 LDFLAGS="-Zomf -Zstack 16384 -s"
197 SHFLAGS=""
198 FFSLDFLAGS=""
199 LIBPREF=""
200 LIBSUF=".lib"
201 SLIBPREF=""
202 SLIBSUF=".dll"
203 extralibs=""
204 v4l="no"
205 audio_oss="no"
206 dv1394="no"
207 network="no"
208 ffserver="no"
209 os2="yes"
210 ;;
211 *) ;;
212 esac
213
214 # From mplayer configure. We need TARGET_OS available
215 # to the Makefile, so it can distinguish between flavors
216 # of AltiVec on PowerPC
217 TARGET_OS=`( uname -s ) 2>&1`
218   case "$TARGET_OS" in
219   Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
220     ;;
221   IRIX*)
222     TARGET_OS=IRIX
223     ;;
224   HP-UX*)
225     TARGET_OS=HP-UX
226     ;;
227   [cC][yY][gG][wW][iI][nN]*)
228     TARGET_OS=CYGWIN
229     ;;
230   *)
231     TARGET_OS="$TARGET_OS-UNKNOWN"
232     ;;
233   esac
234
235 # find source path
236 # XXX: we assume an absolute path is given when launching configure, 
237 # except in './configure' case.
238 source_path="`echo $0 | sed -e 's#/configure##'`"
239 source_path_used="yes"
240 if test -z "$source_path" -o "$source_path" = "." ; then
241     source_path=`pwd`
242     source_path_used="no"
243 fi
244
245 for opt do
246   case "$opt" in
247   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
248   ;;
249   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
250   ;;
251   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
252   ;;
253   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
254   ;;
255   --make=*) make=`echo $opt | cut -d '=' -f 2`
256   ;;
257   --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
258   ;;
259   --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
260   ;;
261   --extra-libs=*) extralibs=${opt#--extra-libs=}
262   ;;
263   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
264   ;;
265   --disable-mmx) mmx="no"
266   ;;
267   --disable-altivec) altivec="no"
268   ;;
269   --enable-gprof) gprof="yes"
270   ;;
271   --disable-v4l) v4l="no"
272   ;;
273   --disable-audio-oss) audio_oss="no"
274   ;;
275   --disable-audio-beos) audio_beos="no"
276   ;;
277   --disable-dv1394) dv1394="no"
278   ;;
279   --disable-network) network="no"
280   ;;
281   --disable-zlib) zlib="no"
282   ;;
283   --disable-a52) a52="no"
284   ;;
285   --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
286   ;;
287   --disable-pp) pp="no"
288   ;;
289   --enable-shared-pp) shared_pp="yes"
290   ;;
291   --enable-mp3lame) mp3lame="yes"
292   ;;
293   --enable-vorbis) vorbis="yes"
294   ;;
295   --disable-vhook) vhook="no"
296   ;;
297   --disable-simple_idct) simpleidct="no"
298   ;;
299   --enable-win32) win32="yes"
300   ;;
301   --enable-mingw32) mingw32="yes"
302   ;;
303   --enable-shared) lshared="yes"
304   ;;
305   --disable-mpegaudio-hp) mpegaudio_hp="no"
306   ;;
307   --disable-ffserver) ffserver="no"
308   ;;
309   --disable-risky) risky="no"
310   ;;
311   --enable-small) small="yes"
312   ;;
313   esac
314 done
315
316 # compute mmx state
317 if test $mmx = "default"; then
318     if test $cpu = "x86"; then
319         mmx="yes"
320     else
321         mmx="no"
322     fi
323 fi
324
325 # Can only do AltiVec on PowerPC
326 if test $altivec = "default"; then
327     if test $cpu = "powerpc"; then
328         altivec="yes"
329     else
330         altivec="no"
331     fi
332 fi
333
334 # See does our compiler support Motorola AltiVec C API
335 if test $altivec = "yes"; then
336 cat > $TMPC << EOF
337 int main(void) {
338     vector signed int v1, v2, v3;
339     v1 = vec_add(v2,v3);
340     return 0;
341 }
342 EOF
343 $cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
344 fi
345
346 # Can only do mmi on mips
347 if test $mmi = "default"; then
348     if test $cpu = "mips"; then
349         mmi="yes"
350     else
351         mmi="no"
352     fi
353 fi
354
355 # See does our compiler support mmi
356 if test $mmi = "yes"; then
357 cat > $TMPC << EOF
358 int main(void) {
359     __asm__ ("lq \$2, 0(\$2)");
360     return 0;
361 }
362 EOF
363 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
364 fi
365
366 # Checking for CFLAGS
367 if test -z "$CFLAGS"; then
368     CFLAGS="-O3"
369 fi
370
371 if test "$win32" = "yes" ; then
372     cross_prefix="i386-mingw32msvc-"
373     v4l="no"
374     audio_oss="no"
375     dv1394="no"
376     network="no"
377 fi
378
379 if test "$mingw32" = "yes" ; then
380     cross_prefix=""
381     v4l="no"
382     audio_oss="no"
383     dv1394="no"
384     network="no"
385 fi
386
387 cc="${cross_prefix}${cc}"
388 ar="${cross_prefix}${ar}"
389 ranlib="${cross_prefix}${ranlib}"
390 strip="${cross_prefix}${strip}"
391
392 if test -z "$cross_prefix" ; then
393
394 # ---
395 # big/little endian test
396 cat > $TMPC << EOF
397 #include <inttypes.h>
398 int main(int argc, char ** argv){
399         volatile uint32_t i=0x01234567;
400         return (*((uint8_t*)(&i))) == 0x67;
401 }
402 EOF
403
404 if $cc -o $TMPE $TMPC 2>/dev/null ; then
405 $TMPE && bigendian="yes"
406 else
407 echo big/little test failed
408 fi
409
410 else
411
412 # if cross compiling, cannot launch a program, so make a static guess
413 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
414     bigendian="yes"
415 fi
416
417 fi
418
419 # ---
420 # check availability of some header files
421
422 cat > $TMPC << EOF
423 #include <malloc.h>
424 int main( void ) { return 0; }
425 EOF
426
427 _memalign=no
428 _malloc_h=no
429 if $cc -o $TMPE $TMPC 2> /dev/null ; then
430 _malloc_h=yes
431 _memalign=yes
432 # check for memalign - atmos
433 cat > $TMPC << EOF
434 #include <malloc.h>
435 int main ( void ) {
436 char *string = NULL;
437 string = memalign(64, sizeof(char));
438 return 0;
439 }
440 EOF
441 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
442 fi
443
444 cat > $TMPC << EOF
445 #define _GNU_SOURCE
446 #include <time.h>
447 int main( void ) { return *strptime("", "", 0); }
448 EOF
449
450 strptime=no
451 if $cc -o $TMPE $TMPC 2> /dev/null ; then
452   strptime=yes
453 fi
454
455 if test "$zlib" = "yes"; then
456 # check for zlib - mmu_man
457 cat > $TMPC << EOF
458 #include <zlib.h>
459 int main ( void ) {
460 if (zlibVersion() != ZLIB_VERSION)
461    puts("zlib version differs !!!");
462    return 1;
463 return 0;
464 }
465 EOF
466 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
467 # $TMPE 2> /dev/null > /dev/null || zlib="no"
468 # XXX: more tests needed - runtime test
469 fi
470 if test "$zlib" = "yes"; then
471 extralibs="$extralibs -lz"
472 fi
473
474 # test for lrintf in math.h
475 cat > $TMPC << EOF
476 #define _ISOC9X_SOURCE  1
477 #include <math.h>
478 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
479 EOF
480
481 have_lrintf="no"
482 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
483   have_lrintf="yes"
484   $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
485 fi
486
487 _restrict=
488 for restrict_keyword in restrict __restrict__ __restrict; do
489   echo "void foo(char * $restrict_keyword p);" > $TMPC
490   if $cc -c -o $TMPO $TMPC 2> /dev/null; then
491     _restrict=$restrict_keyword
492     break;
493   fi
494 done
495
496 # test gcc version to see if vector builtins can be used
497 # currently only used on i386 for MMX builtins
498 cat > $TMPC << EOF
499 int main(void) { 
500 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
501 return 0;
502 #else
503 #error no vector builtins
504 #endif
505 }
506 EOF
507
508 builtin_vector=no
509 if $cc -o $TMPO $TMPC 2> /dev/null ; then
510   builtin_vector=yes
511 fi
512
513 # dlopen/dlfcn.h probing
514
515 cat > $TMPC << EOF
516 #include <dlfcn.h>
517 int main( void ) { return (int) dlopen("foo", 0); }
518 EOF
519
520 ldl=-ldl
521
522 if $cc -o $TMPE $TMPC -ldl 2> /dev/null  ; then
523 dlfcn=yes
524 dlopen=yes
525 fi
526
527 if $cc -o $TMPE $TMPC 2> /dev/null  ; then
528 dlfcn=yes
529 dlopen=yes
530 ldl=""
531 fi
532
533 cat > $TMPC << EOF
534 int main( void ) { return (int) dlopen("foo", 0); }
535 EOF
536
537 if $cc -o $TMPE $TMPC -ldl 2> /dev/null  ; then
538 dlopen=yes
539 fi
540
541 if $cc -o $TMPE $TMPC 2> /dev/null  ; then
542 dlopen=yes
543 ldl=""
544 fi
545
546 if test "$vhook" = "default" ; then
547   vhook="$dlopen"
548 fi
549
550 cat > $TMPC << EOF
551 #include <X11/Xlib.h>
552 #include <Imlib2.h>
553 int main( void ) { return (int) imlib_load_font("foo"); }
554 EOF
555
556 imlib2=no
557 if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null  ; then
558 imlib2=yes
559 fi
560
561 cat > $TMPC << EOF
562 #include <ft2build.h>
563 int main( void ) { return (int) FT_Init_FreeType(0); }
564 EOF
565
566 freetype2=no
567 if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
568   which freetype-config > /dev/null
569   if test $? -eq 0; then
570     if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs`  2> /dev/null ; then
571       freetype2=yes
572     fi
573   fi
574 fi
575
576 if test "$small" = "yes"; then
577 #  CFLAGS=${CFLAGS//-O3/-Os}
578   CFLAGS="$CFLAGS -Os"
579 fi
580
581 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
582 cat << EOF
583
584 Usage: configure [options]
585 Options: [defaults in brackets after descriptions]
586
587 EOF
588 echo "Standard options:"
589 echo "  --help                   print this message"
590 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
591 echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
592 echo "  --enable-vorbis          enable vorbis support via libvorbisenc [default=no]"
593 echo "  --enable-win32           enable win32 cross compile"
594 echo "  --enable-mingw32         enable mingw32 native windows compile"
595 echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
596 echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
597 echo "  --disable-pp             disable GPL'ed post processing support [default=no]"
598 echo "  --enable-shared-pp       use libpostproc.so [default=no]"
599 echo "  --enable-shared          build shared libraries [default=no]"
600 echo ""
601 echo "Advanced options (experts only):"
602 echo "  --source-path=PATH       path of source code [$source_path]"
603 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
604 echo "  --cc=CC                  use C compiler CC [$cc]"
605 echo "  --make=MAKE              use specified make [$make]"
606 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
607 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
608 echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
609 echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
610 echo "  --disable-mmx            disable mmx usage"
611 echo "  --disable-altivec        disable AltiVec usage"
612 echo "  --disable-audio-oss      disable OSS audio support [default=no]"
613 echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
614 echo "  --disable-v4l            disable video4linux grabbing [default=no]"
615 echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
616 echo "  --disable-network        disable network support [default=no]"
617 echo "  --disable-zlib           disable zlib [default=no]"
618 echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
619 echo "  --disable-vhook          disable video hooking support"
620 echo "  --enable-gprof           enable profiling with gprof [$gprof]"
621 echo "  --disable-mpegaudio-hp   faster (but less accurate)"
622 echo "                           mpegaudio decoding [default=no]"
623 echo "  --disable-ffserver       disable ffserver build"
624 echo "  --disable-risky          disables patent encumbered codecs"
625 echo "  --enable-small           optimize for size instead of speed"
626 echo ""
627 echo "NOTE: The object files are build at the place where configure is launched"
628 exit 1
629 fi
630
631 echo "Install prefix   $prefix"
632 echo "Source path      $source_path"
633 echo "C compiler       $cc"
634 echo "make             $make"
635 echo "CPU              $cpu"
636 echo "Big Endian       $bigendian"
637 if test $cpu = "x86"; then
638 echo "MMX enabled      $mmx"
639 echo "Vector Builtins  $builtin_vector"
640 fi
641 if test $cpu = "mips"; then
642 echo "MMI enabled      $mmi"
643 fi
644 if test $cpu = "powerpc"; then
645 echo "AltiVec enabled  $altivec"
646 fi
647 echo "gprof enabled    $gprof"
648 echo "zlib enabled     $zlib"
649 echo "mp3lame enabled  $mp3lame"
650 echo "vorbis enabled   $vorbis"
651 echo "a52 support      $a52"
652 echo "a52 dlopened     $a52bin"
653 echo "pp support       $pp"
654 echo "shared pp        $shared_pp"
655 echo "Video hooking    $vhook"
656 echo "risky / patent encumbered codecs $risky"
657 echo "optimize for size $small"
658
659 if test "$vhook" = "yes" ; then
660 echo "Imlib2 support   $imlib2"
661 echo "freetype support $freetype2"
662 fi
663
664 echo "Creating config.mak and config.h"
665
666 echo "# Automatically generated by configure - do not modify" > config.mak
667 echo "/* Automatically generated by configure - do not modify */" > $TMPH
668
669 echo "prefix=$prefix" >> config.mak
670 echo "MAKE=$make" >> config.mak
671 echo "CC=$cc" >> config.mak
672 echo "AR=$ar" >> config.mak
673 echo "RANLIB=$ranlib" >> config.mak
674 echo "STRIP=$strip" >> config.mak
675 echo "OPTFLAGS=$CFLAGS" >> config.mak
676 echo "LDFLAGS=$LDFLAGS" >> config.mak
677 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
678 echo "SHFLAGS=$SHFLAGS" >> config.mak
679 echo "LIBPREF=$LIBPREF" >> config.mak
680 echo "LIBSUF=$LIBSUF" >> config.mak
681 echo "SLIBPREF=$SLIBPREF" >> config.mak
682 echo "SLIBSUF=$SLIBSUF" >> config.mak
683 echo "TARGET_OS=$TARGET_OS" >> config.mak
684 if test "$cpu" = "x86" ; then
685   echo "TARGET_ARCH_X86=yes" >> config.mak
686   echo "#define ARCH_X86 1" >> $TMPH
687 elif test "$cpu" = "armv4l" ; then
688   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
689   echo "#define ARCH_ARMV4L 1" >> $TMPH
690 elif test "$cpu" = "alpha" ; then
691   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
692   echo "#define ARCH_ALPHA 1" >> $TMPH
693 elif test "$cpu" = "sparc64" ; then
694   echo "TARGET_ARCH_SPARC64=yes" >> config.mak
695   echo "#define ARCH_SPARC64 1" >> $TMPH
696 elif test "$cpu" = "powerpc" ; then
697   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
698   echo "#define ARCH_POWERPC 1" >> $TMPH
699   echo "// Enable the next line to get PowerPC performance report" >> $TMPH
700   echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
701   echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
702   echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
703 elif test "$cpu" = "mips" ; then
704   echo "TARGET_ARCH_MIPS=yes" >> config.mak
705   echo "#define ARCH_MIPS 1" >> $TMPH
706 fi
707 if test "$bigendian" = "yes" ; then
708   echo "WORDS_BIGENDIAN=yes" >> config.mak
709   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
710 fi
711 if test "$mmx" = "yes" ; then
712   echo "TARGET_MMX=yes" >> config.mak
713   echo "#define HAVE_MMX 1" >> $TMPH
714 fi
715 if test "$builtin_vector" = "yes" ; then
716   echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
717   echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
718 fi
719 if test "$mmi" = "yes" ; then
720   echo "TARGET_MMI=yes" >> config.mak
721   echo "#define HAVE_MMI 1" >> $TMPH
722 fi
723 if test "$altivec" = "yes" ; then
724   echo "TARGET_ALTIVEC=yes" >> config.mak
725   echo "#define HAVE_ALTIVEC 1" >> $TMPH
726   echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
727   echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
728 fi
729 if test "$gprof" = "yes" ; then
730   echo "TARGET_GPROF=yes" >> config.mak
731   echo "#define HAVE_GPROF 1" >> $TMPH
732 fi
733 if test "$strptime" = "yes" ; then
734   echo "#define HAVE_STRPTIME 1" >> $TMPH
735 else
736   echo "BUILD_STRPTIME=yes" >> config.mak
737 fi
738 if test "$imlib2" = "yes" ; then
739   echo "HAVE_IMLIB2=yes" >> config.mak
740 fi
741 if test "$freetype2" = "yes" ; then
742   echo "HAVE_FREETYPE2=yes" >> config.mak
743 fi
744 if test "$have_lrintf" = "yes" ; then
745   echo "#define HAVE_LRINTF 1" >> $TMPH
746 fi
747 if test "$vhook" = "yes" ; then
748   echo "BUILD_VHOOK=yes" >> config.mak
749   echo "#define HAVE_VHOOK 1" >> $TMPH
750   extralibs="$extralibs $ldl"
751 fi
752 if test "$lshared" = "yes" ; then
753   echo "BUILD_SHARED=yes" >> config.mak
754   echo "PIC=-fPIC" >> config.mak
755 fi
756 echo "EXTRALIBS=$extralibs" >> config.mak
757 echo "VERSION=`head $source_path/VERSION`" >>config.mak
758 echo "" >>config.mak
759 # if you do not want to use encoders, disable that.
760 echo "#define CONFIG_ENCODERS 1" >> $TMPH
761 echo "CONFIG_ENCODERS=yes" >> config.mak
762
763 # if you do not want to use decoders, disable that.
764 echo "#define CONFIG_DECODERS 1" >> $TMPH
765 echo "CONFIG_DECODERS=yes" >> config.mak
766
767 # AC3
768 if test "$a52" = "yes" ; then
769   echo "#define CONFIG_AC3 1" >> $TMPH
770   echo "CONFIG_AC3=yes" >> config.mak
771
772   if test "$a52bin" = "yes" ; then
773     echo "#define CONFIG_A52BIN 1" >> $TMPH
774     echo "CONFIG_A52BIN=yes" >> config.mak
775   fi
776 fi
777
778 # PP
779 if test "$pp" = "yes" ; then
780   echo "#define CONFIG_PP 1" >> $TMPH
781   echo "CONFIG_PP=yes" >> config.mak
782
783   if test "$shared_pp" = "yes" ; then
784     echo "#define SHARED_PP 1" >> $TMPH
785     echo "SHARED_PP=yes" >> config.mak
786   fi
787 fi
788
789 # mpeg audio high precision mode
790 if test "$mpegaudio_hp" = "yes" ; then
791   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
792 fi
793
794 if test "$v4l" = "yes" ; then
795   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
796   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
797 fi
798
799 if test "$dv1394" = "yes" ; then
800   echo "#define CONFIG_DV1394 1" >> $TMPH
801   echo "CONFIG_DV1394=yes" >> config.mak
802 fi
803
804 if test "$dlopen" = "yes" ; then
805   echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
806 fi
807
808 if test "$dlfcn" = "yes" ; then
809   echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
810 fi
811
812 if test "$audio_oss" = "yes" ; then
813   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
814   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
815 fi
816
817 if test "$audio_beos" = "yes" ; then
818   echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
819   echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
820 fi
821
822 if test "$network" = "yes" ; then
823   echo "#define CONFIG_NETWORK 1" >> $TMPH
824   echo "CONFIG_NETWORK=yes" >> config.mak
825 fi
826
827 if test "$zlib" = "yes" ; then
828   echo "#define CONFIG_ZLIB 1" >> $TMPH
829   echo "CONFIG_ZLIB=yes" >> config.mak
830 fi
831
832 if test "$mp3lame" = "yes" ; then
833   echo "#define CONFIG_MP3LAME 1" >> $TMPH
834   echo "CONFIG_MP3LAME=yes" >> config.mak
835 fi
836
837 if test "$vorbis" = "yes" ; then
838   echo "#define CONFIG_VORBIS 1" >> $TMPH
839   echo "CONFIG_VORBIS=yes" >> config.mak
840 fi
841
842 if test "$win32" = "yes" ; then
843   echo "#define CONFIG_WIN32 1" >> $TMPH
844   echo "CONFIG_WIN32=yes" >> config.mak
845 fi
846
847 if test "$mingw32" = "yes" ; then
848   echo "#define CONFIG_WIN32 1" >> $TMPH
849   echo "CONFIG_WIN32=yes" >> config.mak
850   echo "#define __MINGW32__ 1" >> $TMPH
851   echo "__MINGW32__=1" >> config.mak
852 fi
853
854 if test "$cygwin" = "yes" ; then
855   # setup correct exesuffix
856   echo "CONFIG_WIN32=yes" >> config.mak
857 fi
858
859 if test "$os2" = "yes" ; then
860   echo "#define CONFIG_OS2 1" >> $TMPH
861   echo "CONFIG_OS2=yes" >> config.mak
862 fi
863
864 if test "$darwin" = "yes"; then
865   echo "#define CONFIG_DARWIN 1"  >> $TMPH
866   echo "CONFIG_DARWIN=yes" >> config.mak
867 fi
868
869 if test "$_malloc_h" = "yes" ; then
870   echo "#define HAVE_MALLOC_H 1" >> $TMPH
871 else
872   echo "#undef  HAVE_MALLOC_H" >> $TMPH
873 fi
874
875 if test "$_memalign" = "yes" ; then
876   echo "#define HAVE_MEMALIGN 1" >> $TMPH
877 else
878   echo "#undef  HAVE_MEMALIGN" >> $TMPH
879 fi
880
881 if test "$netserver" = "yes" ; then
882   echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
883   echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
884 fi
885
886 if test "$need_inet_aton" = "yes" ; then
887   echo "NEED_INET_ATON=yes" >> config.mak
888 fi
889
890 if test "$simpleidct" = "yes" ; then
891   echo "#define SIMPLE_IDCT 1" >> $TMPH
892 fi
893
894 if test "$ffserver" = "yes" ; then
895   echo "#define CONFIG_FFSERVER 1" >> $TMPH
896   echo "CONFIG_FFSERVER=yes" >> config.mak
897 fi
898
899 if test "$risky" = "yes" ; then
900   echo "#define CONFIG_RISKY 1" >> $TMPH
901   echo "CONFIG_RISKY=yes" >> config.mak
902 fi
903
904 echo "#define restrict $_restrict" >> $TMPH
905
906 # build tree in object directory if source path is different from current one
907 if test "$source_path_used" = "yes" ; then
908     DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
909           libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
910     FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
911     for dir in $DIRS ; do
912             mkdir -p $dir
913     done
914     for f in $FILES ; do
915         ln -sf $source_path/$f $f
916     done
917 fi
918 echo "SRC_PATH=$source_path" >> config.mak
919
920 diff $TMPH config.h >/dev/null 2>&1
921 if test $? -ne 0 ; then
922         mv -f $TMPH config.h
923 else
924         echo "config.h is unchanged"
925 fi
926
927 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH