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