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