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