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