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