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