* using some small char buffer - needed for sprintf
[libav.git] / configure
CommitLineData
de6d9b64
FB
1#!/bin/sh
2
3d204385
NK
3TMPC="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
4TMPO="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
5TMPS="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
045ed63f 6TMPH="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
3d204385
NK
7
8if [ ! -z "$TMPDIR" ]; then
9 TMPC="${TMPDIR}/${TMPC}"
10 TMPCPP="${TMPDIR}/${TMPCPP}"
11 TMPO="${TMPDIR}/${TMPO}"
12 TMPS="${TMPDIR}/${TMPS}"
045ed63f 13 TMPH="${TMPDIR}/${TMPH}"
3d204385
NK
14elif [ ! -z "$TEMPDIR" ]; then
15 TMPC="${TEMPDIR}/${TMPC}"
16 TMPCPP="${TEMPDIR}/${TMPCPP}"
17 TMPO="${TEMPDIR}/${TMPO}"
18 TMPS="${TEMPDIR}/${TMPS}"
045ed63f 19 TMPH="${TEMPDIR}/${TMPH}"
3d204385
NK
20else
21 TMPC="/tmp/${TMPC}"
22 TMPCPP="/tmp/${TMPCPP}"
23 TMPO="/tmp/${TMPO}"
24 TMPS="/tmp/${TMPS}"
045ed63f 25 TMPH="/tmp/${TMPH}"
3d204385
NK
26fi
27
de6d9b64
FB
28# default parameters
29prefix="/usr/local"
30cc="gcc"
31ar="ar"
32cpu=`uname -m`
33case "$cpu" in
ef0bc4c9 34 i386|i486|i586|i686|i86pc|BePC)
de6d9b64
FB
35 cpu="x86"
36 mmx="yes"
37 ;;
6ed7422a
FB
38 armv4l)
39 cpu="armv4l"
40 mmx="no"
41 ;;
91d1f1a4
NK
42 alpha)
43 cpu="alpha"
44 mmx="no"
45 ;;
de6d9b64
FB
46 *)
47 mmx="no"
48 ;;
49esac
50gprof="no"
6ed7422a 51grab="yes"
a6741398 52mp3lame="no"
daf8e955 53win32="no"
ef0bc4c9
FR
54extralibs="-lm"
55
56# OS specific
57targetos=`uname -s`
58case $targetos in
59BeOS)
60prefix="/boot/home/config"
61# helps building libavcodec
62grab="no"
63CFLAGS="-O2 -DPIC"
64# no need for libm, but the inet stuff
65# Check for BONE
66if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
67extralibs="-lbind -lsocket"
68else
69echo "Not sure building for net_server will succeed... good luck."
70extralibs="-lsocket"
71fi ;;
72*) ;;
73esac
de6d9b64
FB
74
75if [ "$1" = "-h" -o "$1" = "--help" ] ; then
76cat << EOF
77
78Usage: configure [options]
79Options: [defaults in brackets after descriptions]
80
81 --help print this message
82EOF
83echo " --prefix=PREFIX install in PREFIX [$prefix]"
84echo " --cc=CC use C compiler CC [$cc]"
85echo " --cpu=CPU force cpu to CPU [$cpu]"
86echo " --disable-mmx disable mmx usage"
87echo " --enable-gprof enable profiling with gprof [$gprof]"
6ed7422a 88echo " --disable-grab disable audio/video grabbing code"
e4986da9 89echo " --enable-simple_idct use simple IDCT routines"
a6741398 90echo " --enable-mp3lame enable mp3 encoding via libmp3lame"
daf8e955 91echo " --enable-win32 enable win32 cross compile"
0319c531 92echo " --enable-shared build shared libraries [default=no]"
de6d9b64
FB
93exit 1
94fi
95
0319c531 96lshared=no
de6d9b64
FB
97for opt do
98 case "$opt" in
99 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
100 ;;
101 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
102 ;;
103 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
104 ;;
105 --disable-mmx) mmx="no"
106 ;;
107 --enable-gprof) gprof="yes"
108 ;;
6ed7422a
FB
109 --disable-grab) grab="no"
110 ;;
a6741398
J
111 --enable-mp3lame) mp3lame="yes"
112 ;;
045ed63f
ZK
113 --enable-simple_idct) simpleidct="yes"
114 ;;
daf8e955
FB
115 --enable-win32) win32="yes"
116 ;;
0319c531
NK
117 --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
118 ;;
de6d9b64
FB
119 esac
120done
121
daf8e955
FB
122# Checking for CFLAGS
123if test -z "$CFLAGS"; then
124 CFLAGS="-O2"
125fi
126
127if [ "$win32" = "yes" ] ; then
128 cross_prefix="i386-mingw32msvc-"
129 cc="${cross_prefix}gcc"
130 ar="${cross_prefix}ar"
131 grab="no"
132fi
133
3d204385
NK
134# ---
135# check availability of some header files
136
137cat > $TMPC << EOF
138#include <malloc.h>
139int main( void ) { return 0; }
140EOF
141
142_memalign=no
143_malloc_h=no
144if $cc -o $TMPO $TMPC 2> /dev/null ; then
145_malloc_h=yes
146_memalign=yes
147# check for memalign - atmos
148cat > $TMPC << EOF
149#include <malloc.h>
150int main ( void ) {
151char *string = NULL;
152string = memalign(64, sizeof(char));
153return 0;
154}
155EOF
156$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
157fi
158
de6d9b64
FB
159echo "Install prefix $prefix"
160echo "C compiler $cc"
161echo "CPU $cpu"
162echo "MMX enabled $mmx"
163echo "gprof enabled $gprof"
6ed7422a 164echo "grab enabled $grab"
a6741398 165echo "mp3lame enabled $mp3lame"
de6d9b64 166
980fc7b8 167echo "Creating config.mak and config.h"
de6d9b64 168
980fc7b8 169echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 170echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 171
980fc7b8 172echo "prefix=$prefix" >> config.mak
2cc8ae96 173echo "MAKE=make" >> config.mak
980fc7b8
FB
174echo "CC=$cc" >> config.mak
175echo "AR=$ar" >> config.mak
a9b3f630 176echo "OPTFLAGS=$CFLAGS" >> config.mak
de6d9b64 177if [ "$cpu" = "x86" ] ; then
980fc7b8 178 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 179 echo "#define ARCH_X86 1" >> $TMPH
de6d9b64 180fi
6ed7422a
FB
181if [ "$cpu" = "armv4l" ]; then
182 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 183 echo "#define ARCH_ARMV4L 1" >> $TMPH
6ed7422a 184fi
91d1f1a4
NK
185if [ "$cpu" = "alpha" ]; then
186 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 187 echo "#define ARCH_ALPHA 1" >> $TMPH
91d1f1a4 188fi
de6d9b64 189if [ "$mmx" = "yes" ] ; then
980fc7b8 190 echo "TARGET_MMX=yes" >> config.mak
045ed63f 191 echo "#define HAVE_MMX 1" >> $TMPH
de6d9b64
FB
192fi
193if [ "$gprof" = "yes" ] ; then
980fc7b8 194 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 195 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 196fi
0319c531
NK
197if [ "$lshared" = "yes" ] ; then
198 echo "BUILD_SHARED=yes" >> config.mak
199else
200 echo "BUILD_SHARED=no" >> config.mak
201fi
ef0bc4c9 202echo "EXTRALIBS=$extralibs" >> config.mak
0319c531
NK
203echo -n "VERSION=" >>config.mak
204head VERSION >>config.mak
205echo "" >>config.mak
d771bcae 206# if you do not want to use encoders, disable that.
045ed63f 207echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
208echo "CONFIG_ENCODERS=yes" >> config.mak
209
210# if you do not want to use decoders, disable that.
045ed63f 211echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
212echo "CONFIG_DECODERS=yes" >> config.mak
213
d2b7bcd2 214# special AC3 stuff in case you already have it
d771bcae 215# without libavcodec.
045ed63f 216echo "#define CONFIG_AC3 1" >> $TMPH
d771bcae
FB
217echo "CONFIG_AC3=yes" >> config.mak
218
6ed7422a 219if [ "$grab" = "yes" ] ; then
045ed63f 220 echo "#define CONFIG_GRAB 1" >> $TMPH
6ed7422a
FB
221 echo "CONFIG_GRAB=yes" >> config.mak
222fi
daf8e955 223
a6741398 224if [ "$mp3lame" = "yes" ] ; then
045ed63f 225 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
226 echo "CONFIG_MP3LAME=yes" >> config.mak
227fi
228
daf8e955 229if [ "$win32" = "yes" ] ; then
045ed63f 230 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
231 echo "CONFIG_WIN32=yes" >> config.mak
232fi
3d204385
NK
233
234if [ "$_malloc_h" = "yes" ]; then
045ed63f 235 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 236else
045ed63f 237 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
238fi
239
240if [ "$_memalign" = "yes" ]; then
045ed63f
ZK
241 echo "#define HAVE_MEMALIGN 1" >> $TMPH
242else
243 echo "#undef HAVE_MEMALIGN" >> $TMPH
244fi
245
246if [ "$simpleidct" = "yes" ]; then
247 echo "#define SIMPLE_IDCT 1" >> $TMPH
248fi
249
a7c02e25 250diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
251if test $? -ne 0 ; then
252 mv -f $TMPH config.h
3d204385 253else
045ed63f 254 echo "config.h is unchanged"
3d204385
NK
255fi
256
045ed63f 257rm -f $TMPO $TMPC $TMPS $TMPH