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