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