]> git.sesse.net Git - ffmpeg/blob - configure
BeOS Audio ouput patch by (François Revol <revol at free dot fr>)
[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 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
17 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
18
19 # default parameters
20 prefix="/usr/local"
21 cross_prefix=""
22 cc="gcc"
23 ar="ar"
24 ranlib="ranlib"
25 make="make"
26 strip="strip"
27 cpu=`uname -m`
28 mmx="default"
29 altivec="default"
30 mmi="default"
31 case "$cpu" in
32   i386|i486|i586|i686|i86pc|BePC)
33     cpu="x86"
34   ;;
35   armv4l)
36     cpu="armv4l"
37   ;;
38   alpha)
39     cpu="alpha"
40   ;;
41   "Power Macintosh"|ppc)
42     cpu="powerpc"
43   ;;
44   mips)
45     cpu="mips"
46   ;;
47   *)
48     cpu="unknown"
49   ;;
50 esac
51 gprof="no"
52 v4l="yes"
53 audio_oss="yes"
54 audio_beos="no"
55 network="yes"
56 zlib="yes"
57 mp3lame="no"
58 vorbis="no"
59 a52="yes"
60 a52bin="no"
61 win32="no"
62 cygwin="no"
63 lshared="no"
64 extralibs="-lm"
65 simpleidct="yes"
66 bigendian="no"
67 vhook="no"
68 mpegaudio_hp="yes"
69 SHFLAGS=-shared
70 netserver="no"
71
72 # OS specific
73 targetos=`uname -s`
74 case $targetos in
75 BeOS)
76 prefix="/boot/home/config"
77 # helps building libavcodec
78 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
79 # 3 gcc releases known for BeOS, each with ugly bugs
80 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
81 case "$gcc_version" in
82 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
83 mmx="no"
84 ;;
85 *20010315*) echo "BeBits gcc"
86 CFLAGS="$CFLAGS -fno-expensive-optimizations"
87 ;;
88 esac
89 SHFLAGS=-nostart
90 # disable linux things
91 audio_oss="no"
92 v4l="no"
93 # enable beos things
94 audio_beos="yes"
95 # no need for libm, but the inet stuff
96 # Check for BONE
97 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
98 extralibs="-lbind -lsocket"
99 else
100 netserver="yes"
101 extralibs="-lnet"
102 fi ;;
103 BSD/OS)
104 v4l="no"
105 audio_oss="yes"
106 extralibs="-lpoll -lgnugetopt -lm"
107 make="gmake"
108 ;;
109 Darwin)
110 cc="cc"
111 v4l="no"
112 audio_oss="no"
113 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
114 SHFLAGS="-dynamiclib"
115 extralibs=""
116 darwin="yes"
117 ;;
118 CYGWIN*)
119 v4l="no"
120 audio_oss="yes"
121 extralibs=""
122 cygwin="yes"
123 test -f /usr/include/inttypes.h || \
124 test -f /usr/local/include/inttypes.h || \
125 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
126      "/usr/include/inttypes.h !!!"
127 ;;
128 *) ;;
129 esac
130
131 # find source path
132 # XXX: we assume an absolute path is given when launching configure, 
133 # except in './configure' case.
134 source_path=${0%configure}
135 source_path=${source_path%/}
136 source_path_used="yes"
137 if test -z "$source_path" -o "$source_path" = "." ; then
138     source_path=`pwd`
139     source_path_used="no"
140 fi
141
142 cat > $TMPC << EOF
143 #include <dlfcn.h>
144 int main( void ) { return (int) dlopen("foo", 0); }
145 EOF
146
147 if $cc -o $TMPO $TMPC -ldl 2> /dev/null  ; then
148 : vhook=yes
149 fi
150
151 cat > $TMPC << EOF
152 #include <X11/Xlib.h>
153 #include <Imlib2.h>
154 int main( void ) { return (int) imlib_load_font("foo"); }
155 EOF
156
157 imlib2=no
158 if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null  ; then
159 imlib2=yes
160 fi
161
162 for opt do
163   case "$opt" in
164   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
165   ;;
166   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
167   ;;
168   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
169   ;;
170   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
171   ;;
172   --make=*) make=`echo $opt | cut -d '=' -f 2`
173   ;;
174   --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
175   ;;
176   --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
177   ;;
178   --extra-libs=*) extralibs=${opt#--extra-libs=}
179   ;;
180   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
181   ;;
182   --disable-mmx) mmx="no"
183   ;;
184   --disable-altivec) altivec="no"
185   ;;
186   --enable-gprof) gprof="yes"
187   ;;
188   --disable-v4l) v4l="no"
189   ;;
190   --disable-audio-oss) audio_oss="no"
191   ;;
192   --disable-audio-beos) audio_beos="no"
193   ;;
194   --disable-network) network="no"
195   ;;
196   --disable-zlib) zlib="no"
197   ;;
198   --disable-a52) a52="no"
199   ;;
200   --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
201   ;;
202   --enable-mp3lame) mp3lame="yes"
203   ;;
204   --enable-vorbis) vorbis="yes"
205   ;;
206   --disable-vhook) vhook="no"
207   ;;
208   --disable-simple_idct) simpleidct="no"
209   ;;
210   --enable-win32) win32="yes"
211   ;;
212   --enable-shared) lshared="yes"
213   ;;
214   --disable-mpegaudio-hp) mpegaudio_hp="no"
215   ;;
216   esac
217 done
218
219 # compute mmx state
220 if test $mmx = "default"; then
221     if test $cpu = "x86"; then
222         mmx="yes"
223     else
224         mmx="no"
225     fi
226 fi
227
228 # Can only do AltiVec on PowerPC
229 if test $altivec = "default"; then
230     if test $cpu = "powerpc"; then
231         altivec="yes"
232     else
233         altivec="no"
234     fi
235 fi
236
237 # See does our compiler support Motorola AltiVec C API
238 if test $altivec = "yes"; then
239 cat > $TMPC << EOF
240 int main(void) {
241     vector signed int v1, v2, v3;
242     v1 = vec_add(v2,v3);
243     return 0;
244 }
245 EOF
246 $cc -o $TMPO $TMPC -faltivec 2> /dev/null || altivec="no"
247 fi
248
249 # Can only do mmi on mips
250 if test $mmi = "default"; then
251     if test $cpu = "mips"; then
252         mmi="yes"
253     else
254         mmi="no"
255     fi
256 fi
257
258 # See does our compiler support mmi
259 if test $mmi = "yes"; then
260 cat > $TMPC << EOF
261 int main(void) {
262     __asm__ ("lq \$2, 0(\$2)");
263     return 0;
264 }
265 EOF
266 $cc -o $TMPO $TMPC 2> /dev/null || mmi="no"
267 fi
268
269 # Checking for CFLAGS
270 if test -z "$CFLAGS"; then
271     CFLAGS="-O3"
272 fi
273
274 if test "$win32" = "yes" ; then
275     cross_prefix="i386-mingw32msvc-"
276     v4l="no"
277     audio_oss="no"
278     network="no"
279 fi
280
281 cc="${cross_prefix}${cc}"
282 ar="${cross_prefix}${ar}"
283 ranlib="${cross_prefix}${ranlib}"
284 strip="${cross_prefix}${strip}"
285
286 if test -z "$cross_prefix" ; then
287
288 # ---
289 # big/little endian test
290 cat > $TMPC << EOF
291 #include <inttypes.h>
292 int main(int argc, char ** argv){
293         volatile uint32_t i=0x01234567;
294         return (*((uint8_t*)(&i))) == 0x67;
295 }
296 EOF
297
298 if $cc -o $TMPO $TMPC 2>/dev/null ; then
299 $TMPO && bigendian="yes"
300 else
301 echo big/little test failed
302 fi
303
304 else
305
306 # if cross compiling, cannot launch a program, so make a static guess
307 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
308     bigendian="yes"
309 fi
310
311 fi
312
313 # ---
314 # check availability of some header files
315
316 cat > $TMPC << EOF
317 #include <malloc.h>
318 int main( void ) { return 0; }
319 EOF
320
321 _memalign=no
322 _malloc_h=no
323 if $cc -o $TMPO $TMPC 2> /dev/null ; then
324 _malloc_h=yes
325 _memalign=yes
326 # check for memalign - atmos
327 cat > $TMPC << EOF
328 #include <malloc.h>
329 int main ( void ) {
330 char *string = NULL;
331 string = memalign(64, sizeof(char));
332 return 0;
333 }
334 EOF
335 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
336 fi
337
338 cat > $TMPC << EOF
339 #define _GNU_SOURCE
340 #include <time.h>
341 int main( void ) { return *strptime("", "", 0); }
342 EOF
343
344 strptime=no
345 if $cc -o $TMPO $TMPC 2> /dev/null ; then
346   strptime=yes
347 fi
348
349 if test "$zlib" = "yes"; then
350 # check for zlib - mmu_man
351 cat > $TMPC << EOF
352 #include <zlib.h>
353 int main ( void ) {
354 if (zlibVersion() != ZLIB_VERSION)
355    puts("zlib version differs !!!");
356    return 1;
357 return 0;
358 }
359 EOF
360 $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
361 # $TMPO 2> /dev/null > /dev/null || zlib="no"
362 # XXX: more tests needed - runtime test
363 fi
364 if test "$zlib" = "yes"; then
365 extralibs="$extralibs -lz"
366 fi
367
368 # test for lrintf in math.h
369 cat > $TMPC << EOF
370 #define _ISOC9X_SOURCE  1
371 #include <math.h>
372 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
373 EOF
374
375 have_lrintf="no"
376 if $cc $extralibs -o $TMPO $TMPC 2> /dev/null ; then
377   have_lrintf="yes"
378   $TMPO 2> /dev/null > /dev/null || have_lrintf="no"
379 fi
380
381 _restrict=
382 for restrict_keyword in restrict __restrict__ __restrict; do
383   echo "void foo(char * $restrict_keyword p);" > $TMPC
384   if $cc -c -o $TMPO $TMPC 2> /dev/null; then
385     _restrict=$restrict_keyword
386     break;
387   fi
388 done
389
390 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
391 cat << EOF
392
393 Usage: configure [options]
394 Options: [defaults in brackets after descriptions]
395
396 EOF
397 echo "Standard options:"
398 echo "  --help                   print this message"
399 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
400 echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
401 echo "  --enable-vorbis          enable vorbis support via libvorbisenc [default=no]"
402 echo "  --enable-win32           enable win32 cross compile"
403 echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
404 echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
405 echo "  --enable-shared          build shared libraries [default=no]"
406 echo ""
407 echo "Advanced options (experts only):"
408 echo "  --source-path=PATH       path of source code [$source_path]"
409 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
410 echo "  --cc=CC                  use C compiler CC [$cc]"
411 echo "  --make=MAKE              use specified make [$make]"
412 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
413 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
414 echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
415 echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
416 echo "  --disable-mmx            disable mmx usage"
417 echo "  --disable-altivec        disable AltiVec usage"
418 echo "  --disable-audio-oss      disable OSS audio support [default=no]"
419 echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
420 echo "  --disable-v4l            disable video4linux grabbing [default=no]"
421 echo "  --disable-network        disable network support [default=no]"
422 echo "  --disable-zlib           disable zlib [default=no]"
423 echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
424 # echo "  --disable-vhook          disable video hooking support"
425 echo "  --enable-gprof           enable profiling with gprof [$gprof]"
426 echo "  --disable-mpegaudio-hp   faster (but less accurate)"
427 echo "                           mpegaudio decoding [default=no]"
428 echo ""
429 echo "NOTE: The object files are build at the place where configure is launched"
430 exit 1
431 fi
432
433 echo "Install prefix   $prefix"
434 echo "Source path      $source_path"
435 echo "C compiler       $cc"
436 echo "make             $make"
437 echo "CPU              $cpu"
438 echo "Big Endian       $bigendian"
439 if test $cpu = "x86"; then
440 echo "MMX enabled      $mmx"
441 fi
442 if test $cpu = "mips"; then
443 echo "MMI enabled      $mmi"
444 fi
445 if test $cpu = "powerpc"; then
446 echo "AltiVec enabled  $altivec"
447 fi
448 echo "gprof enabled    $gprof"
449 echo "zlib enabled     $zlib"
450 echo "mp3lame enabled  $mp3lame"
451 echo "vorbis enabled   $vorbis"
452 echo "a52 support      $a52"
453 echo "a52 dlopened     $a52bin"
454 # echo "Video hooking    $vhook"
455
456 if test "$vhook" = "yes" ; then
457 : echo "Imlib2 support   $imlib2"
458 fi
459
460 echo "Creating config.mak and config.h"
461
462 echo "# Automatically generated by configure - do not modify" > config.mak
463 echo "/* Automatically generated by configure - do not modify */" > $TMPH
464
465 echo "prefix=$prefix" >> config.mak
466 echo "MAKE=$make" >> config.mak
467 echo "CC=$cc" >> config.mak
468 echo "AR=$ar" >> config.mak
469 echo "RANLIB=$ranlib" >> config.mak
470 echo "STRIP=$strip" >> config.mak
471 echo "OPTFLAGS=$CFLAGS" >> config.mak
472 echo "LDFLAGS=$LDFLAGS" >> config.mak
473 echo "SHFLAGS=$SHFLAGS" >> config.mak
474 if test "$cpu" = "x86" ; then
475   echo "TARGET_ARCH_X86=yes" >> config.mak
476   echo "#define ARCH_X86 1" >> $TMPH
477 elif test "$cpu" = "armv4l" ; then
478   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
479   echo "#define ARCH_ARMV4L 1" >> $TMPH
480 elif test "$cpu" = "alpha" ; then
481   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
482   echo "#define ARCH_ALPHA 1" >> $TMPH
483 elif test "$cpu" = "powerpc" ; then
484   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
485   echo "#define ARCH_POWERPC 1" >> $TMPH
486 elif test "$cpu" = "mips" ; then
487   echo "TARGET_ARCH_MIPS=yes" >> config.mak
488   echo "#define ARCH_MIPS 1" >> $TMPH
489 fi
490 if test "$bigendian" = "yes" ; then
491   echo "WORDS_BIGENDIAN=yes" >> config.mak
492   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
493 fi
494 if test "$mmx" = "yes" ; then
495   echo "TARGET_MMX=yes" >> config.mak
496   echo "#define HAVE_MMX 1" >> $TMPH
497 fi
498 if test "$mmi" = "yes" ; then
499   echo "TARGET_MMI=yes" >> config.mak
500   echo "#define HAVE_MMI 1" >> $TMPH
501 fi
502 if test "$altivec" = "yes" ; then
503   echo "TARGET_ALTIVEC=yes" >> config.mak
504   echo "#define HAVE_ALTIVEC 1" >> $TMPH
505 fi
506 if test "$gprof" = "yes" ; then
507   echo "TARGET_GPROF=yes" >> config.mak
508   echo "#define HAVE_GPROF 1" >> $TMPH
509 fi
510 if test "$strptime" = "yes" ; then
511   echo "#define HAVE_STRPTIME 1" >> $TMPH
512 else
513   echo "BUILD_STRPTIME=yes" >> config.mak
514 fi
515 if test "$imlib2" = "yes" ; then
516   echo "HAVE_IMLIB2=yes" >> config.mak
517 fi
518 if test "$have_lrintf" = "yes" ; then
519   echo "#define HAVE_LRINTF 1" >> $TMPH
520 fi
521 if test "$vhook" = "yes" ; then
522   echo "BUILD_VHOOK=yes" >> config.mak
523   echo "#define HAVE_VHOOK 1" >> $TMPH
524   extralibs="$extralibs -ldl"
525 fi
526 if test "$lshared" = "yes" ; then
527   echo "BUILD_SHARED=yes" >> config.mak
528   echo "PIC=-fPIC" >> config.mak
529 fi
530 echo "EXTRALIBS=$extralibs" >> config.mak
531 echo -n "VERSION=" >>config.mak
532 head $source_path/VERSION >>config.mak
533 echo "" >>config.mak
534 # if you do not want to use encoders, disable that.
535 echo "#define CONFIG_ENCODERS 1" >> $TMPH
536 echo "CONFIG_ENCODERS=yes" >> config.mak
537
538 # if you do not want to use decoders, disable that.
539 echo "#define CONFIG_DECODERS 1" >> $TMPH
540 echo "CONFIG_DECODERS=yes" >> config.mak
541
542 # AC3
543 if test "$a52" = "yes" ; then
544   echo "#define CONFIG_AC3 1" >> $TMPH
545   echo "CONFIG_AC3=yes" >> config.mak
546
547   if test "$a52bin" = "yes" ; then
548     echo "#define CONFIG_A52BIN 1" >> $TMPH
549     echo "CONFIG_A52BIN=yes" >> config.mak
550   fi
551 fi
552
553 # mpeg audio high precision mode
554 if test "$mpegaudio_hp" = "yes" ; then
555   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
556 fi
557
558 if test "$v4l" = "yes" ; then
559   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
560   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
561 fi
562
563 if test "$audio_oss" = "yes" ; then
564   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
565   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
566 fi
567
568 if test "$audio_beos" = "yes" ; then
569   echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
570   echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
571 fi
572
573 if test "$network" = "yes" ; then
574   echo "#define CONFIG_NETWORK 1" >> $TMPH
575   echo "CONFIG_NETWORK=yes" >> config.mak
576 fi
577
578 if test "$zlib" = "yes" ; then
579   echo "#define CONFIG_ZLIB 1" >> $TMPH
580   echo "CONFIG_ZLIB=yes" >> config.mak
581 fi
582
583 if test "$mp3lame" = "yes" ; then
584   echo "#define CONFIG_MP3LAME 1" >> $TMPH
585   echo "CONFIG_MP3LAME=yes" >> config.mak
586 fi
587
588 if test "$vorbis" = "yes" ; then
589   echo "#define CONFIG_VORBIS 1" >> $TMPH
590   echo "CONFIG_VORBIS=yes" >> config.mak
591 fi
592
593 if test "$win32" = "yes" ; then
594   echo "#define CONFIG_WIN32 1" >> $TMPH
595   echo "CONFIG_WIN32=yes" >> config.mak
596 fi
597
598 if test "$cygwin" = "yes" ; then
599   # setup correct exesuffix
600   echo "CONFIG_WIN32=yes" >> config.mak
601 fi
602
603 if test "$darwin" = "yes"; then
604   echo "#define CONFIG_DARWIN 1"  >> $TMPH
605   echo "CONFIG_DARWIN=yes" >> config.mak
606 fi
607
608 if test "$_malloc_h" = "yes" ; then
609   echo "#define HAVE_MALLOC_H 1" >> $TMPH
610 else
611   echo "#undef  HAVE_MALLOC_H" >> $TMPH
612 fi
613
614 if test "$_memalign" = "yes" ; then
615   echo "#define HAVE_MEMALIGN 1" >> $TMPH
616 else
617   echo "#undef  HAVE_MEMALIGN" >> $TMPH
618 fi
619
620 if test "$netserver" = "yes" ; then
621   echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
622   echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
623 fi
624
625 if test "$simpleidct" = "yes" ; then
626   echo "#define SIMPLE_IDCT 1" >> $TMPH
627 fi
628
629 echo "#define restrict $_restrict" >> $TMPH
630
631 # build tree in object directory if source path is different from current one
632 if test "$source_path_used" = "yes" ; then
633     DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
634           libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
635     FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
636     for dir in $DIRS ; do
637             mkdir -p $dir
638     done
639     for f in $FILES ; do
640         ln -sf $source_path/$f $f
641     done
642 fi
643 echo "SRC_PATH=$source_path" >> config.mak
644
645 diff $TMPH config.h >/dev/null 2>&1
646 if test $? -ne 0 ; then
647         mv -f $TMPH config.h
648 else
649         echo "config.h is unchanged"
650 fi
651
652 rm -f $TMPO $TMPC $TMPS $TMPH