configure 6.19 KB
Newer Older
Fabrice Bellard's avatar
Fabrice Bellard committed
1 2
#!/bin/sh

Nick Kurshev's avatar
Nick Kurshev committed
3 4 5
TMPC="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
TMPS="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
6
TMPH="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
Nick Kurshev's avatar
Nick Kurshev committed
7

Zdenek Kabelac's avatar
Zdenek Kabelac committed
8
if test ! -z "$TMPDIR" ; then
Nick Kurshev's avatar
Nick Kurshev committed
9 10 11 12
	TMPC="${TMPDIR}/${TMPC}"
	TMPCPP="${TMPDIR}/${TMPCPP}"
	TMPO="${TMPDIR}/${TMPO}"
	TMPS="${TMPDIR}/${TMPS}"
13
	TMPH="${TMPDIR}/${TMPH}"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
14
elif test ! -z "$TEMPDIR" ; then
Nick Kurshev's avatar
Nick Kurshev committed
15 16 17 18
	TMPC="${TEMPDIR}/${TMPC}"
	TMPCPP="${TEMPDIR}/${TMPCPP}"
	TMPO="${TEMPDIR}/${TMPO}"
	TMPS="${TEMPDIR}/${TMPS}"
19
	TMPH="${TEMPDIR}/${TMPH}"
Nick Kurshev's avatar
Nick Kurshev committed
20 21 22 23 24
else
	TMPC="/tmp/${TMPC}"
	TMPCPP="/tmp/${TMPCPP}"
	TMPO="/tmp/${TMPO}"
	TMPS="/tmp/${TMPS}"
25
	TMPH="/tmp/${TMPH}"
Nick Kurshev's avatar
Nick Kurshev committed
26 27
fi

Fabrice Bellard's avatar
Fabrice Bellard committed
28 29 30 31 32 33
# default parameters
prefix="/usr/local"
cc="gcc"
ar="ar"
cpu=`uname -m`
case "$cpu" in
34
  i386|i486|i586|i686|i86pc|BePC)
Fabrice Bellard's avatar
Fabrice Bellard committed
35 36 37
    cpu="x86"
    mmx="yes"
  ;;
38 39 40 41
  armv4l)
    cpu="armv4l"
    mmx="no"
  ;;
42 43 44 45
  alpha)
    cpu="alpha"
    mmx="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
46 47 48 49 50
  *)
    mmx="no"
  ;;
esac
gprof="no"
51
grab="yes"
52
mp3lame="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
53
a52bin="no"
54
win32="no"
55
lshared="no"
56
extralibs="-lm"
57
simpleidct="yes"
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

# OS specific
targetos=`uname -s`
case $targetos in
BeOS)
prefix="/boot/home/config"
# helps building libavcodec
grab="no"
CFLAGS="-O2 -DPIC"
# no need for libm, but the inet stuff
# Check for BONE
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
extralibs="-lbind -lsocket"
else
echo "Not sure building for net_server will succeed... good luck."
extralibs="-lsocket"
fi ;;
*) ;;
esac
Fabrice Bellard's avatar
Fabrice Bellard committed
77

Zdenek Kabelac's avatar
Zdenek Kabelac committed
78
if test "$1" = "-h" -o "$1" = "--help" ; then
Fabrice Bellard's avatar
Fabrice Bellard committed
79 80 81 82 83 84 85 86 87 88 89 90
cat << EOF

Usage: configure [options]
Options: [defaults in brackets after descriptions]

  --help                  print this message
EOF
echo "  --prefix=PREFIX         install in PREFIX [$prefix]"
echo "  --cc=CC                 use C compiler CC [$cc]"
echo "  --cpu=CPU               force cpu to CPU  [$cpu]"
echo "  --disable-mmx           disable mmx usage"
echo "  --enable-gprof          enable profiling with gprof [$gprof]"
91
echo "  --disable-grab          disable audio/video grabbing code"
92
echo "  --disable-simple_idct   disable simple IDCT routines [default=no]"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
93
echo "  --enable-mp3lame        enable mp3 encoding via libmp3lame [default=no]"
94
echo "  --enable-win32          enable win32 cross compile"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
95
echo "  --enable-a52bin         open liba52.so.0 at runtime [default=no]"
Nick Kurshev's avatar
Nick Kurshev committed
96
echo "  --enable-shared         build shared libraries [default=no]"
Fabrice Bellard's avatar
Fabrice Bellard committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
exit 1
fi

for opt do
  case "$opt" in
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  ;;
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  ;;
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  ;;
  --disable-mmx) mmx="no"
  ;;
  --enable-gprof) gprof="yes"
  ;;
112 113
  --disable-grab) grab="no"
  ;;
Zdenek Kabelac's avatar
Zdenek Kabelac committed
114 115
  --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  ;;
116 117
  --enable-mp3lame) mp3lame="yes"
  ;;
118
  --disable-simple_idct) simpleidct="no"
119
  ;;
120 121
  --enable-win32) win32="yes"
  ;;
122
  --enable-shared) lshared="yes"
Nick Kurshev's avatar
Nick Kurshev committed
123
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
124 125 126
  esac
done

127 128 129 130 131
# Checking for CFLAGS
if test -z "$CFLAGS"; then
    CFLAGS="-O2"
fi

Zdenek Kabelac's avatar
Zdenek Kabelac committed
132
if test "$win32" = "yes" ; then
133 134 135 136 137 138
    cross_prefix="i386-mingw32msvc-"
    cc="${cross_prefix}gcc"
    ar="${cross_prefix}ar"
    grab="no"
fi

Nick Kurshev's avatar
Nick Kurshev committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
# ---
# check availability of some header files

cat > $TMPC << EOF
#include <malloc.h>
int main( void ) { return 0; }
EOF

_memalign=no
_malloc_h=no
if $cc -o $TMPO $TMPC 2> /dev/null ; then
_malloc_h=yes
_memalign=yes
# check for memalign - atmos
cat > $TMPC << EOF
#include <malloc.h>
int main ( void ) {
char *string = NULL;
string = memalign(64, sizeof(char));
return 0;
}
EOF
$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
fi

Fabrice Bellard's avatar
Fabrice Bellard committed
164 165 166 167 168
echo "Install prefix   $prefix"
echo "C compiler       $cc"
echo "CPU              $cpu"
echo "MMX enabled      $mmx"
echo "gprof enabled    $gprof"
169
echo "grab enabled     $grab"
170
echo "mp3lame enabled  $mp3lame"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
171
echo "a52 dlopened     $a52bin"
Fabrice Bellard's avatar
Fabrice Bellard committed
172

173
echo "Creating config.mak and config.h"
Fabrice Bellard's avatar
Fabrice Bellard committed
174

175
echo "# Automatically generated by configure - do not modify" > config.mak
176
echo "/* Automatically generated by configure - do not modify */" > $TMPH
Fabrice Bellard's avatar
Fabrice Bellard committed
177

178
echo "prefix=$prefix" >> config.mak
Fabrice Bellard's avatar
Fabrice Bellard committed
179
echo "MAKE=make" >> config.mak
180 181
echo "CC=$cc" >> config.mak
echo "AR=$ar" >> config.mak
Nick Kurshev's avatar
Nick Kurshev committed
182
echo "OPTFLAGS=$CFLAGS" >> config.mak
Zdenek Kabelac's avatar
Zdenek Kabelac committed
183
if test "$cpu" = "x86" ; then
184
  echo "TARGET_ARCH_X86=yes" >> config.mak
185
  echo "#define ARCH_X86 1" >> $TMPH
Fabrice Bellard's avatar
Fabrice Bellard committed
186
fi
Zdenek Kabelac's avatar
Zdenek Kabelac committed
187
if test "$cpu" = "armv4l" ; then
188
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
189
  echo "#define ARCH_ARMV4L 1" >> $TMPH
190
fi
Zdenek Kabelac's avatar
Zdenek Kabelac committed
191
if test "$cpu" = "alpha" ; then
192
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
193
  echo "#define ARCH_ALPHA 1" >> $TMPH
194
fi
Zdenek Kabelac's avatar
Zdenek Kabelac committed
195
if test "$mmx" = "yes" ; then
196
  echo "TARGET_MMX=yes" >> config.mak
197
  echo "#define HAVE_MMX 1" >> $TMPH
Fabrice Bellard's avatar
Fabrice Bellard committed
198
fi
Zdenek Kabelac's avatar
Zdenek Kabelac committed
199
if test "$gprof" = "yes" ; then
200
  echo "TARGET_GPROF=yes" >> config.mak
201
  echo "#define HAVE_GPROF 1" >> $TMPH
Fabrice Bellard's avatar
Fabrice Bellard committed
202
fi
Zdenek Kabelac's avatar
Zdenek Kabelac committed
203
if test "$lshared" = "yes" ; then
Nick Kurshev's avatar
Nick Kurshev committed
204 205 206 207
  echo "BUILD_SHARED=yes" >> config.mak
else
  echo "BUILD_SHARED=no" >> config.mak
fi
208
echo "EXTRALIBS=$extralibs" >> config.mak
Nick Kurshev's avatar
Nick Kurshev committed
209 210 211
echo -n "VERSION=" >>config.mak
head VERSION >>config.mak
echo "" >>config.mak
212
# if you do not want to use encoders, disable that.
213
echo "#define CONFIG_ENCODERS 1" >> $TMPH
214 215 216
echo "CONFIG_ENCODERS=yes" >> config.mak

# if you do not want to use decoders, disable that.
217
echo "#define CONFIG_DECODERS 1" >> $TMPH
218 219
echo "CONFIG_DECODERS=yes" >> config.mak

Fabrice Bellard's avatar
Fabrice Bellard committed
220
# special AC3 stuff in case you already have it
221
# without libavcodec.
222
echo "#define CONFIG_AC3 1" >> $TMPH
223 224
echo "CONFIG_AC3=yes" >> config.mak

Zdenek Kabelac's avatar
Zdenek Kabelac committed
225 226 227 228 229 230 231 232
if test "$a52bin" = "yes" ; then
  echo "#define CONFIG_A52BIN 1" >> $TMPH
  echo "CONFIG_A52BIN=yes" >> config.mak
else
  echo "CONFIG_A52BIN=no" >> config.mak
fi

if test "$grab" = "yes" ; then
233
  echo "#define CONFIG_GRAB 1" >> $TMPH
234 235
  echo "CONFIG_GRAB=yes" >> config.mak
fi
236

Zdenek Kabelac's avatar
Zdenek Kabelac committed
237
if test "$mp3lame" = "yes" ; then
238
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
239 240 241
  echo "CONFIG_MP3LAME=yes" >> config.mak
fi

Zdenek Kabelac's avatar
Zdenek Kabelac committed
242
if test "$win32" = "yes" ; then
243
  echo "#define CONFIG_WIN32 1" >> $TMPH
244 245
  echo "CONFIG_WIN32=yes" >> config.mak
fi
Nick Kurshev's avatar
Nick Kurshev committed
246

Zdenek Kabelac's avatar
Zdenek Kabelac committed
247
if test "$_malloc_h" = "yes" ; then
248
  echo "#define HAVE_MALLOC_H 1" >> $TMPH
Nick Kurshev's avatar
Nick Kurshev committed
249
else
250
  echo "#undef  HAVE_MALLOC_H" >> $TMPH
Nick Kurshev's avatar
Nick Kurshev committed
251 252
fi

Zdenek Kabelac's avatar
Zdenek Kabelac committed
253
if test "$_memalign" = "yes" ; then
254 255 256 257 258
  echo "#define HAVE_MEMALIGN 1" >> $TMPH
else
  echo "#undef  HAVE_MEMALIGN" >> $TMPH
fi

Zdenek Kabelac's avatar
Zdenek Kabelac committed
259
if test "$simpleidct" = "yes" ; then
260 261 262
  echo "#define SIMPLE_IDCT 1" >> $TMPH
fi

Zdenek Kabelac's avatar
Zdenek Kabelac committed
263
diff $TMPH config.h >/dev/null 2>&1
264 265
if test $? -ne 0 ; then
	mv -f $TMPH config.h
Nick Kurshev's avatar
Nick Kurshev committed
266
else
267
	echo "config.h is unchanged"
Nick Kurshev's avatar
Nick Kurshev committed
268 269
fi

270
rm -f $TMPO $TMPC $TMPS $TMPH