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