fixing rv10, this isnt the cleanest solution (parsing the packet header in the codec...
[libav.git] / 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 # ---
271 # big/little endian test
272 cat > $TMPC << EOF
273 #include <inttypes.h>
274 int main(int argc, char ** argv){
275 volatile uint32_t i=0x01234567;
276 return (*((uint8_t*)(&i))) == 0x67;
277 }
278 EOF
279
280 if $cc -o $TMPO $TMPC 2>/dev/null ; then
281 $TMPO && bigendian="yes"
282 else
283 echo big/little test failed
284 fi
285
286 # ---
287 # check availability of some header files
288
289 cat > $TMPC << EOF
290 #include <malloc.h>
291 int main( void ) { return 0; }
292 EOF
293
294 _memalign=no
295 _malloc_h=no
296 if $cc -o $TMPO $TMPC 2> /dev/null ; then
297 _malloc_h=yes
298 _memalign=yes
299 # check for memalign - atmos
300 cat > $TMPC << EOF
301 #include <malloc.h>
302 int main ( void ) {
303 char *string = NULL;
304 string = memalign(64, sizeof(char));
305 return 0;
306 }
307 EOF
308 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
309 fi
310
311 cat > $TMPC << EOF
312 #define _GNU_SOURCE
313 #include <time.h>
314 int main( void ) { return *strptime("", "", 0); }
315 EOF
316
317 strptime=no
318 if $cc -o $TMPO $TMPC 2> /dev/null ; then
319 strptime=yes
320 fi
321
322 if test "$zlib" = "yes"; then
323 # check for zlib - mmu_man
324 cat > $TMPC << EOF
325 #include <zlib.h>
326 int main ( void ) {
327 if (zlibVersion() != ZLIB_VERSION)
328 puts("zlib version differs !!!");
329 return 1;
330 return 0;
331 }
332 EOF
333 $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
334 # $TMPO 2> /dev/null > /dev/null || zlib="no"
335 # XXX: more tests needed - runtime test
336 fi
337 if test "$zlib" = "yes"; then
338 extralibs="$extralibs -lz"
339 fi
340
341 _restrict=
342 for restrict_keyword in restrict __restrict__ __restrict; do
343 echo "void foo(char * $restrict_keyword p);" > $TMPC
344 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
345 _restrict=$restrict_keyword
346 break;
347 fi
348 done
349
350 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
351 cat << EOF
352
353 Usage: configure [options]
354 Options: [defaults in brackets after descriptions]
355
356 EOF
357 echo "Standard options:"
358 echo " --help print this message"
359 echo " --prefix=PREFIX install in PREFIX [$prefix]"
360 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
361 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
362 echo " --enable-win32 enable win32 cross compile"
363 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
364 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
365 echo " --enable-shared build shared libraries [default=no]"
366 echo ""
367 echo "Advanced options (experts only):"
368 echo " --source-path=PATH path of source code [$source_path]"
369 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
370 echo " --cc=CC use C compiler CC [$cc]"
371 echo " --make=MAKE use specified make [$make]"
372 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
373 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
374 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
375 echo " --cpu=CPU force cpu to CPU [$cpu]"
376 echo " --disable-mmx disable mmx usage"
377 echo " --disable-altivec disable AltiVec usage"
378 echo " --disable-audio-oss disable OSS audio support [default=no]"
379 echo " --disable-v4l disable video4linux grabbing [default=no]"
380 echo " --disable-network disable network support [default=no]"
381 echo " --disable-zlib disable zlib [default=no]"
382 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
383 # echo " --disable-vhook disable video hooking support"
384 echo " --enable-gprof enable profiling with gprof [$gprof]"
385 echo " --disable-mpegaudio-hp faster (but less accurate)"
386 echo " mpegaudio decoding [default=no]"
387 echo ""
388 echo "NOTE: The object files are build at the place where configure is launched"
389 exit 1
390 fi
391
392 echo "Install prefix $prefix"
393 echo "Source path $source_path"
394 echo "C compiler $cc"
395 echo "make $make"
396 echo "CPU $cpu"
397 echo "Big Endian $bigendian"
398 echo "MMX enabled $mmx"
399 echo "MMI enabled $mmi"
400 echo "AltiVec enabled $altivec"
401 echo "gprof enabled $gprof"
402 echo "zlib enabled $zlib"
403 echo "mp3lame enabled $mp3lame"
404 echo "vorbis enabled $vorbis"
405 echo "a52 support $a52"
406 echo "a52 dlopened $a52bin"
407 # echo "Video hooking $vhook"
408
409 if test "$vhook" = "yes" ; then
410 : echo "Imlib2 support $imlib2"
411 fi
412
413 echo "Creating config.mak and config.h"
414
415 echo "# Automatically generated by configure - do not modify" > config.mak
416 echo "/* Automatically generated by configure - do not modify */" > $TMPH
417
418 echo "prefix=$prefix" >> config.mak
419 echo "MAKE=$make" >> config.mak
420 echo "CC=$cc" >> config.mak
421 echo "AR=$ar" >> config.mak
422 echo "RANLIB=$ranlib" >> config.mak
423 echo "STRIP=$strip" >> config.mak
424 echo "OPTFLAGS=$CFLAGS" >> config.mak
425 echo "LDFLAGS=$LDFLAGS" >> config.mak
426 echo "SHFLAGS=$SHFLAGS" >> config.mak
427 if test "$cpu" = "x86" ; then
428 echo "TARGET_ARCH_X86=yes" >> config.mak
429 echo "#define ARCH_X86 1" >> $TMPH
430 elif test "$cpu" = "armv4l" ; then
431 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
432 echo "#define ARCH_ARMV4L 1" >> $TMPH
433 elif test "$cpu" = "alpha" ; then
434 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
435 echo "#define ARCH_ALPHA 1" >> $TMPH
436 elif test "$cpu" = "powerpc" ; then
437 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
438 echo "#define ARCH_POWERPC 1" >> $TMPH
439 elif test "$cpu" = "mips" ; then
440 echo "TARGET_ARCH_MIPS=yes" >> config.mak
441 echo "#define ARCH_MIPS 1" >> $TMPH
442 fi
443 if test "$bigendian" = "yes" ; then
444 echo "WORDS_BIGENDIAN=yes" >> config.mak
445 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
446 fi
447 if test "$mmx" = "yes" ; then
448 echo "TARGET_MMX=yes" >> config.mak
449 echo "#define HAVE_MMX 1" >> $TMPH
450 fi
451 if test "$mmi" = "yes" ; then
452 echo "TARGET_MMI=yes" >> config.mak
453 echo "#define HAVE_MMI 1" >> $TMPH
454 fi
455 if test "$altivec" = "yes" ; then
456 echo "TARGET_ALTIVEC=yes" >> config.mak
457 echo "#define HAVE_ALTIVEC 1" >> $TMPH
458 fi
459 if test "$gprof" = "yes" ; then
460 echo "TARGET_GPROF=yes" >> config.mak
461 echo "#define HAVE_GPROF 1" >> $TMPH
462 fi
463 if test "$strptime" = "yes" ; then
464 echo "#define HAVE_STRPTIME 1" >> $TMPH
465 else
466 echo "BUILD_STRPTIME=yes" >> config.mak
467 fi
468 if test "$imlib2" = "yes" ; then
469 echo "HAVE_IMLIB2=yes" >> config.mak
470 fi
471 if test "$vhook" = "yes" ; then
472 echo "BUILD_VHOOK=yes" >> config.mak
473 echo "#define HAVE_VHOOK 1" >> $TMPH
474 extralibs="$extralibs -ldl"
475 fi
476 if test "$lshared" = "yes" ; then
477 echo "BUILD_SHARED=yes" >> config.mak
478 echo "PIC=-fPIC" >> config.mak
479 fi
480 echo "EXTRALIBS=$extralibs" >> config.mak
481 echo -n "VERSION=" >>config.mak
482 head $source_path/VERSION >>config.mak
483 echo "" >>config.mak
484 # if you do not want to use encoders, disable that.
485 echo "#define CONFIG_ENCODERS 1" >> $TMPH
486 echo "CONFIG_ENCODERS=yes" >> config.mak
487
488 # if you do not want to use decoders, disable that.
489 echo "#define CONFIG_DECODERS 1" >> $TMPH
490 echo "CONFIG_DECODERS=yes" >> config.mak
491
492 # AC3
493 if test "$a52" = "yes" ; then
494 echo "#define CONFIG_AC3 1" >> $TMPH
495 echo "CONFIG_AC3=yes" >> config.mak
496
497 if test "$a52bin" = "yes" ; then
498 echo "#define CONFIG_A52BIN 1" >> $TMPH
499 echo "CONFIG_A52BIN=yes" >> config.mak
500 fi
501 fi
502
503 # mpeg audio high precision mode
504 if test "$mpegaudio_hp" = "yes" ; then
505 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
506 fi
507
508 if test "$v4l" = "yes" ; then
509 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
510 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
511 fi
512
513 if test "$audio_oss" = "yes" ; then
514 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
515 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
516 fi
517
518 if test "$network" = "yes" ; then
519 echo "#define CONFIG_NETWORK 1" >> $TMPH
520 echo "CONFIG_NETWORK=yes" >> config.mak
521 fi
522
523 if test "$zlib" = "yes" ; then
524 echo "#define CONFIG_ZLIB 1" >> $TMPH
525 echo "CONFIG_ZLIB=yes" >> config.mak
526 fi
527
528 if test "$mp3lame" = "yes" ; then
529 echo "#define CONFIG_MP3LAME 1" >> $TMPH
530 echo "CONFIG_MP3LAME=yes" >> config.mak
531 fi
532
533 if test "$vorbis" = "yes" ; then
534 echo "#define CONFIG_VORBIS 1" >> $TMPH
535 echo "CONFIG_VORBIS=yes" >> config.mak
536 fi
537
538 if test "$win32" = "yes" ; then
539 echo "#define CONFIG_WIN32 1" >> $TMPH
540 echo "CONFIG_WIN32=yes" >> config.mak
541 fi
542
543 if test "$cygwin" = "yes" ; then
544 # setup correct exesuffix
545 echo "CONFIG_WIN32=yes" >> config.mak
546 fi
547
548 if test "$darwin" = "yes"; then
549 echo "#define CONFIG_DARWIN 1" >> $TMPH
550 echo "CONFIG_DARWIN=yes" >> config.mak
551 fi
552
553 if test "$_malloc_h" = "yes" ; then
554 echo "#define HAVE_MALLOC_H 1" >> $TMPH
555 else
556 echo "#undef HAVE_MALLOC_H" >> $TMPH
557 fi
558
559 if test "$_memalign" = "yes" ; then
560 echo "#define HAVE_MEMALIGN 1" >> $TMPH
561 else
562 echo "#undef HAVE_MEMALIGN" >> $TMPH
563 fi
564
565 if test "$simpleidct" = "yes" ; then
566 echo "#define SIMPLE_IDCT 1" >> $TMPH
567 fi
568
569 echo "#define restrict $_restrict" >> $TMPH
570
571 # build tree in object directory if source path is different from current one
572 if test "$source_path_used" = "yes" ; then
573 DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
574 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
575 FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
576 for dir in $DIRS ; do
577 mkdir -p $dir
578 done
579 for f in $FILES ; do
580 ln -sf $source_path/$f $f
581 done
582 fi
583 echo "SRC_PATH=$source_path" >> config.mak
584
585 diff $TMPH config.h >/dev/null 2>&1
586 if test $? -ne 0 ; then
587 mv -f $TMPH config.h
588 else
589 echo "config.h is unchanged"
590 fi
591
592 rm -f $TMPO $TMPC $TMPS $TMPH