tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
[libav.git] / configure
CommitLineData
de6d9b64 1#!/bin/sh
0f3cb305 2#
5cbcf02c 3# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
0f3cb305
FB
4#
5# set temporary file name
57514323 6if test ! -z "$TMPDIR" ; then
0f3cb305 7 TMPDIR1="${TMPDIR}"
57514323 8elif test ! -z "$TEMPDIR" ; then
0f3cb305 9 TMPDIR1="${TEMPDIR}"
3d204385 10else
0f3cb305 11 TMPDIR1="/tmp"
3d204385
NK
12fi
13
0f3cb305
FB
14TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
17TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
18
de6d9b64
FB
19# default parameters
20prefix="/usr/local"
0f3cb305 21cross_prefix=""
de6d9b64
FB
22cc="gcc"
23ar="ar"
be7109c1 24ranlib="ranlib"
4a908fbc 25make="make"
0f3cb305 26strip="strip"
de6d9b64 27cpu=`uname -m`
0f3cb305 28mmx="default"
ab6c65f6 29altivec="default"
de6d9b64 30case "$cpu" in
ef0bc4c9 31 i386|i486|i586|i686|i86pc|BePC)
de6d9b64 32 cpu="x86"
de6d9b64 33 ;;
6ed7422a
FB
34 armv4l)
35 cpu="armv4l"
6ed7422a 36 ;;
91d1f1a4
NK
37 alpha)
38 cpu="alpha"
91d1f1a4 39 ;;
a43bd1d7 40 "Power Macintosh"|ppc)
90cee0c3
MN
41 cpu="powerpc"
42 ;;
de6d9b64 43 *)
0f3cb305 44 cpu="unknown"
de6d9b64
FB
45 ;;
46esac
47gprof="no"
5cbcf02c
FB
48v4l="yes"
49audio_oss="yes"
50network="yes"
0147f198 51zlib="yes"
a6741398 52mp3lame="no"
81e0d0b4 53vorbis="no"
5cbcf02c 54a52="yes"
57514323 55a52bin="no"
daf8e955 56win32="no"
3f027ca7 57cygwin="no"
83286d2a 58lshared="no"
ef0bc4c9 59extralibs="-lm"
c02dbee1 60simpleidct="yes"
0f3cb305 61bigendian="no"
68892110 62vhook="no"
1eb2212e 63mpegaudio_hp="yes"
e1707f52 64SHFLAGS=-shared
ef0bc4c9
FR
65
66# OS specific
67targetos=`uname -s`
68case $targetos in
69BeOS)
70prefix="/boot/home/config"
71# helps building libavcodec
e1707f52
MN
72CFLAGS="-O3 -DPIC -fomit-frame-pointer"
73SHFLAGS=-nostart
74# disable linux things
75audio_oss="no"
5cbcf02c 76v4l="no"
ef0bc4c9
FR
77# no need for libm, but the inet stuff
78# Check for BONE
79if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
80extralibs="-lbind -lsocket"
81else
82echo "Not sure building for net_server will succeed... good luck."
83extralibs="-lsocket"
84fi ;;
4a908fbc 85BSD/OS)
5cbcf02c 86v4l="no"
6063bce7 87audio_oss="yes"
4a908fbc
AB
88extralibs="-lpoll -lgnugetopt -lm"
89make="gmake"
90;;
90cee0c3 91Darwin)
a43bd1d7 92cc="cc"
90cee0c3
MN
93v4l="no"
94audio_oss="no"
95CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
a43bd1d7 96SHFLAGS="-dynamiclib"
90cee0c3 97extralibs=""
a43bd1d7 98darwin="yes"
90cee0c3 99;;
3f027ca7
FB
100CYGWIN*)
101v4l="no"
102audio_oss="yes"
103extralibs=""
104cygwin="yes"
105test -f /usr/include/inttypes.h || \
106test -f /usr/local/include/inttypes.h || \
107echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
108 "/usr/include/inttypes.h !!!"
109;;
ef0bc4c9
FR
110*) ;;
111esac
de6d9b64 112
0f3cb305
FB
113# find source path
114# XXX: we assume an absolute path is given when launching configure,
115# except in './configure' case.
116source_path=${0%configure}
117source_path=${source_path%/}
118source_path_used="yes"
119if test -z "$source_path" -o "$source_path" = "." ; then
120 source_path=`pwd`
121 source_path_used="no"
de6d9b64
FB
122fi
123
68892110
PG
124cat > $TMPC << EOF
125#include <dlfcn.h>
126int main( void ) { return (int) dlopen("foo", 0); }
127EOF
128
129if $cc -o $TMPO $TMPC -ldl 2> /dev/null ; then
130: vhook=yes
131fi
132
133cat > $TMPC << EOF
134#include <X11/Xlib.h>
135#include <Imlib2.h>
136int main( void ) { return (int) imlib_load_font("foo"); }
137EOF
138
139imlib2=no
140if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null ; then
141imlib2=yes
142fi
143
de6d9b64
FB
144for opt do
145 case "$opt" in
146 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
147 ;;
0f3cb305
FB
148 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
149 ;;
150 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
151 ;;
de6d9b64
FB
152 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
153 ;;
4a908fbc
AB
154 --make=*) make=`echo $opt | cut -d '=' -f 2`
155 ;;
0f3cb305
FB
156 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
157 ;;
158 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
159 ;;
160 --extra-libs=*) extralibs=${opt#--extra-libs=}
161 ;;
de6d9b64
FB
162 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
163 ;;
164 --disable-mmx) mmx="no"
165 ;;
ab6c65f6
BF
166 --disable-altivec) altivec="no"
167 ;;
de6d9b64
FB
168 --enable-gprof) gprof="yes"
169 ;;
5cbcf02c
FB
170 --disable-v4l) v4l="no"
171 ;;
172 --disable-audio-oss) audio_oss="no"
173 ;;
174 --disable-network) network="no"
175 ;;
0147f198
FR
176 --disable-zlib) zlib="no"
177 ;;
5cbcf02c 178 --disable-a52) a52="no"
6ed7422a 179 ;;
57514323
ZK
180 --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
181 ;;
a6741398
J
182 --enable-mp3lame) mp3lame="yes"
183 ;;
81e0d0b4
MH
184 --enable-vorbis) vorbis="yes"
185 ;;
68892110
PG
186 --disable-vhook) vhook="no"
187 ;;
c02dbee1 188 --disable-simple_idct) simpleidct="no"
045ed63f 189 ;;
daf8e955
FB
190 --enable-win32) win32="yes"
191 ;;
83286d2a 192 --enable-shared) lshared="yes"
0319c531 193 ;;
1eb2212e
FB
194 --disable-mpegaudio-hp) mpegaudio_hp="no"
195 ;;
de6d9b64
FB
196 esac
197done
198
0f3cb305
FB
199# compute mmx state
200if test $mmx = "default"; then
201 if test $cpu = "x86"; then
202 mmx="yes"
203 else
204 mmx="no"
205 fi
206fi
207
ab6c65f6
BF
208# Can only do AltiVec on PowerPC
209if test $altivec = "default"; then
210 if test $cpu = "powerpc"; then
211 altivec="yes"
212 else
213 altivec="no"
214 fi
215fi
216
217# See does our compiler support Motorola AltiVec C API
218if test $altivec = "yes"; then
219cat > $TMPC << EOF
220int main(void) {
221 vector signed int v1, v2, v3;
222 v1 = vec_add(v2,v3);
223 return 0;
224}
225EOF
226$cc -o $TMPO $TMPC -faltivec 2> /dev/null || altivec="no"
227fi
228
daf8e955
FB
229# Checking for CFLAGS
230if test -z "$CFLAGS"; then
29482cb4 231 CFLAGS="-O3"
daf8e955
FB
232fi
233
57514323 234if test "$win32" = "yes" ; then
daf8e955 235 cross_prefix="i386-mingw32msvc-"
5cbcf02c
FB
236 v4l="no"
237 audio_oss="no"
238 network="no"
daf8e955
FB
239fi
240
0f3cb305
FB
241cc="${cross_prefix}${cc}"
242ar="${cross_prefix}${ar}"
be7109c1 243ranlib="${cross_prefix}${ranlib}"
0f3cb305
FB
244strip="${cross_prefix}${strip}"
245
3d204385 246# ---
a3999908
MN
247# big/little endian test
248cat > $TMPC << EOF
249#include <inttypes.h>
250int main(int argc, char ** argv){
251 volatile uint32_t i=0x01234567;
252 return (*((uint8_t*)(&i))) == 0x67;
253}
254EOF
255
256if $cc -o $TMPO $TMPC 2>/dev/null ; then
257$TMPO && bigendian="yes"
258else
259echo big/little test failed
260fi
261
262# ---
3d204385
NK
263# check availability of some header files
264
265cat > $TMPC << EOF
266#include <malloc.h>
267int main( void ) { return 0; }
268EOF
269
270_memalign=no
271_malloc_h=no
272if $cc -o $TMPO $TMPC 2> /dev/null ; then
273_malloc_h=yes
274_memalign=yes
275# check for memalign - atmos
276cat > $TMPC << EOF
277#include <malloc.h>
278int main ( void ) {
279char *string = NULL;
280string = memalign(64, sizeof(char));
281return 0;
282}
283EOF
284$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
285fi
286
68892110
PG
287cat > $TMPC << EOF
288#define _GNU_SOURCE
289#include <time.h>
290int main( void ) { return *strptime("", "", 0); }
291EOF
292
293strptime=no
294if $cc -o $TMPO $TMPC 2> /dev/null ; then
295 strptime=yes
296fi
297
0147f198
FR
298if test "$zlib" = "yes"; then
299# check for zlib - mmu_man
300cat > $TMPC << EOF
301#include <zlib.h>
302int main ( void ) {
303if (zlibVersion() != ZLIB_VERSION)
304 puts("zlib version differs !!!");
305 return 1;
306return 0;
307}
308EOF
309$cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
310# $TMPO 2> /dev/null > /dev/null || zlib="no"
311# XXX: more tests needed - runtime test
312fi
313if test "$zlib" = "yes"; then
314extralibs="$extralibs -lz"
315fi
316
c13e1abd
FH
317_restrict=
318for restrict_keyword in restrict __restrict__ __restrict; do
319 echo "void foo(char * $restrict_keyword p);" > $TMPC
320 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
321 _restrict=$restrict_keyword
322 break;
323 fi
324done
325
6063bce7 326if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
0f3cb305
FB
327cat << EOF
328
329Usage: configure [options]
330Options: [defaults in brackets after descriptions]
331
332EOF
333echo "Standard options:"
334echo " --help print this message"
335echo " --prefix=PREFIX install in PREFIX [$prefix]"
0f3cb305 336echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
81e0d0b4 337echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
0f3cb305 338echo " --enable-win32 enable win32 cross compile"
5cbcf02c 339echo " --disable-a52 disable GPL'ed A52 support [default=no]"
0f3cb305
FB
340echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
341echo " --enable-shared build shared libraries [default=no]"
342echo ""
343echo "Advanced options (experts only):"
344echo " --source-path=PATH path of source code [$source_path]"
345echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
346echo " --cc=CC use C compiler CC [$cc]"
4a908fbc 347echo " --make=MAKE use specified make [$make]"
0f3cb305
FB
348echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
349echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
350echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
351echo " --cpu=CPU force cpu to CPU [$cpu]"
352echo " --disable-mmx disable mmx usage"
ab6c65f6 353echo " --disable-altivec disable AltiVec usage"
5cbcf02c 354echo " --disable-audio-oss disable OSS audio support [default=no]"
6063bce7 355echo " --disable-v4l disable video4linux grabbing [default=no]"
5cbcf02c 356echo " --disable-network disable network support [default=no]"
0147f198 357echo " --disable-zlib disable zlib [default=no]"
5cbcf02c 358echo " --disable-simple_idct disable simple IDCT routines [default=no]"
68892110 359# echo " --disable-vhook disable video hooking support"
0f3cb305 360echo " --enable-gprof enable profiling with gprof [$gprof]"
1eb2212e
FB
361echo " --disable-mpegaudio-hp faster (but less accurate)"
362echo " mpegaudio decoding [default=no]"
0f3cb305
FB
363echo ""
364echo "NOTE: The object files are build at the place where configure is launched"
365exit 1
366fi
367
de6d9b64 368echo "Install prefix $prefix"
0f3cb305 369echo "Source path $source_path"
de6d9b64 370echo "C compiler $cc"
4a908fbc 371echo "make $make"
de6d9b64 372echo "CPU $cpu"
0f3cb305 373echo "Big Endian $bigendian"
de6d9b64 374echo "MMX enabled $mmx"
ab6c65f6 375echo "AltiVec enabled $altivec"
de6d9b64 376echo "gprof enabled $gprof"
0147f198 377echo "zlib enabled $zlib"
a6741398 378echo "mp3lame enabled $mp3lame"
81e0d0b4 379echo "vorbis enabled $vorbis"
5cbcf02c 380echo "a52 support $a52"
57514323 381echo "a52 dlopened $a52bin"
68892110
PG
382# echo "Video hooking $vhook"
383
384if test "$vhook" = "yes" ; then
385: echo "Imlib2 support $imlib2"
386fi
de6d9b64 387
980fc7b8 388echo "Creating config.mak and config.h"
de6d9b64 389
980fc7b8 390echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 391echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 392
980fc7b8 393echo "prefix=$prefix" >> config.mak
4a908fbc 394echo "MAKE=$make" >> config.mak
980fc7b8
FB
395echo "CC=$cc" >> config.mak
396echo "AR=$ar" >> config.mak
be7109c1 397echo "RANLIB=$ranlib" >> config.mak
0f3cb305 398echo "STRIP=$strip" >> config.mak
a9b3f630 399echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 400echo "LDFLAGS=$LDFLAGS" >> config.mak
e1707f52 401echo "SHFLAGS=$SHFLAGS" >> config.mak
57514323 402if test "$cpu" = "x86" ; then
980fc7b8 403 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 404 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 405elif test "$cpu" = "armv4l" ; then
6ed7422a 406 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 407 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 408elif test "$cpu" = "alpha" ; then
91d1f1a4 409 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 410 echo "#define ARCH_ALPHA 1" >> $TMPH
0f3cb305
FB
411elif test "$cpu" = "powerpc" ; then
412 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
413 echo "#define ARCH_POWERPC 1" >> $TMPH
414fi
415if test "$bigendian" = "yes" ; then
416 echo "WORDS_BIGENDIAN=yes" >> config.mak
417 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 418fi
57514323 419if test "$mmx" = "yes" ; then
980fc7b8 420 echo "TARGET_MMX=yes" >> config.mak
045ed63f 421 echo "#define HAVE_MMX 1" >> $TMPH
de6d9b64 422fi
ab6c65f6
BF
423if test "$altivec" = "yes" ; then
424 echo "TARGET_ALTIVEC=yes" >> config.mak
425 echo "#define HAVE_ALTIVEC 1" >> $TMPH
426fi
57514323 427if test "$gprof" = "yes" ; then
980fc7b8 428 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 429 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 430fi
68892110
PG
431if test "$strptime" = "yes" ; then
432 echo "#define HAVE_STRPTIME 1" >> $TMPH
433else
434 echo "BUILD_STRPTIME=yes" >> config.mak
435fi
436if test "$imlib2" = "yes" ; then
437 echo "HAVE_IMLIB2=yes" >> config.mak
438fi
439if test "$vhook" = "yes" ; then
440 echo "BUILD_VHOOK=yes" >> config.mak
441 echo "#define HAVE_VHOOK 1" >> $TMPH
442 extralibs="$extralibs -ldl"
443fi
57514323 444if test "$lshared" = "yes" ; then
0319c531 445 echo "BUILD_SHARED=yes" >> config.mak
5cbcf02c 446 echo "PIC=-fPIC" >> config.mak
0319c531 447fi
ef0bc4c9 448echo "EXTRALIBS=$extralibs" >> config.mak
0319c531 449echo -n "VERSION=" >>config.mak
0f3cb305 450head $source_path/VERSION >>config.mak
0319c531 451echo "" >>config.mak
d771bcae 452# if you do not want to use encoders, disable that.
045ed63f 453echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
454echo "CONFIG_ENCODERS=yes" >> config.mak
455
456# if you do not want to use decoders, disable that.
045ed63f 457echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
458echo "CONFIG_DECODERS=yes" >> config.mak
459
5cbcf02c
FB
460# AC3
461if test "$a52" = "yes" ; then
462 echo "#define CONFIG_AC3 1" >> $TMPH
463 echo "CONFIG_AC3=yes" >> config.mak
d771bcae 464
5cbcf02c
FB
465 if test "$a52bin" = "yes" ; then
466 echo "#define CONFIG_A52BIN 1" >> $TMPH
467 echo "CONFIG_A52BIN=yes" >> config.mak
468 fi
469fi
470
1eb2212e
FB
471# mpeg audio high precision mode
472if test "$mpegaudio_hp" = "yes" ; then
473 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
474fi
475
5cbcf02c
FB
476if test "$v4l" = "yes" ; then
477 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
478 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
479fi
480
481if test "$audio_oss" = "yes" ; then
482 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
483 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
57514323
ZK
484fi
485
5cbcf02c
FB
486if test "$network" = "yes" ; then
487 echo "#define CONFIG_NETWORK 1" >> $TMPH
488 echo "CONFIG_NETWORK=yes" >> config.mak
6ed7422a 489fi
daf8e955 490
0147f198
FR
491if test "$zlib" = "yes" ; then
492 echo "#define CONFIG_ZLIB 1" >> $TMPH
493 echo "CONFIG_ZLIB=yes" >> config.mak
494fi
495
57514323 496if test "$mp3lame" = "yes" ; then
045ed63f 497 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
498 echo "CONFIG_MP3LAME=yes" >> config.mak
499fi
500
81e0d0b4
MH
501if test "$vorbis" = "yes" ; then
502 echo "#define CONFIG_VORBIS 1" >> $TMPH
503 echo "CONFIG_VORBIS=yes" >> config.mak
504fi
505
57514323 506if test "$win32" = "yes" ; then
045ed63f 507 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
508 echo "CONFIG_WIN32=yes" >> config.mak
509fi
3d204385 510
3f027ca7
FB
511if test "$cygwin" = "yes" ; then
512 # setup correct exesuffix
513 echo "CONFIG_WIN32=yes" >> config.mak
514fi
515
90cee0c3
MN
516if test "$darwin" = "yes"; then
517 echo "#define CONFIG_DARWIN 1" >> $TMPH
518 echo "CONFIG_DARWIN=yes" >> config.mak
519fi
520
57514323 521if test "$_malloc_h" = "yes" ; then
045ed63f 522 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 523else
045ed63f 524 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
525fi
526
57514323 527if test "$_memalign" = "yes" ; then
045ed63f
ZK
528 echo "#define HAVE_MEMALIGN 1" >> $TMPH
529else
530 echo "#undef HAVE_MEMALIGN" >> $TMPH
531fi
532
57514323 533if test "$simpleidct" = "yes" ; then
045ed63f
ZK
534 echo "#define SIMPLE_IDCT 1" >> $TMPH
535fi
536
c13e1abd
FH
537echo "#define restrict $_restrict" >> $TMPH
538
0f3cb305
FB
539# build tree in object directory if source path is different from current one
540if test "$source_path_used" = "yes" ; then
541 DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
59925ef2 542 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
0f3cb305
FB
543 FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
544 for dir in $DIRS ; do
545 mkdir -p $dir
546 done
547 for f in $FILES ; do
548 ln -sf $source_path/$f $f
549 done
550fi
551echo "SRC_PATH=$source_path" >> config.mak
552
a7c02e25 553diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
554if test $? -ne 0 ; then
555 mv -f $TMPH config.h
3d204385 556else
045ed63f 557 echo "config.h is unchanged"
3d204385
NK
558fi
559
045ed63f 560rm -f $TMPO $TMPC $TMPS $TMPH