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