configure 9.7 KB
Newer Older
glantau's avatar
glantau committed
1
#!/bin/sh
2
#
glantau's avatar
glantau committed
3
# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4 5
#
# set temporary file name
kabi's avatar
kabi committed
6
if test ! -z "$TMPDIR" ; then
7
    TMPDIR1="${TMPDIR}"
kabi's avatar
kabi committed
8
elif test ! -z "$TEMPDIR" ; then
9
    TMPDIR1="${TEMPDIR}"
nickols_k's avatar
nickols_k committed
10
else
11
    TMPDIR1="/tmp"
nickols_k's avatar
nickols_k committed
12 13
fi

14 15 16 17 18
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"

glantau's avatar
glantau committed
19 20
# default parameters
prefix="/usr/local"
21
cross_prefix=""
glantau's avatar
glantau committed
22 23
cc="gcc"
ar="ar"
al3x's avatar
al3x committed
24
make="make"
25
strip="strip"
glantau's avatar
glantau committed
26
cpu=`uname -m`
27
mmx="default"
glantau's avatar
glantau committed
28
case "$cpu" in
29
  i386|i486|i586|i686|i86pc|BePC)
glantau's avatar
glantau committed
30 31
    cpu="x86"
  ;;
32 33 34
  armv4l)
    cpu="armv4l"
  ;;
35 36 37
  alpha)
    cpu="alpha"
  ;;
glantau's avatar
glantau committed
38
  *)
39
    cpu="unknown"
glantau's avatar
glantau committed
40 41 42
  ;;
esac
gprof="no"
glantau's avatar
glantau committed
43 44 45
v4l="yes"
audio_oss="yes"
network="yes"
46
mp3lame="no"
glantau's avatar
glantau committed
47
a52="yes"
kabi's avatar
kabi committed
48
a52bin="no"
glantau's avatar
glantau committed
49
win32="no"
kabi's avatar
kabi committed
50
lshared="no"
51
extralibs="-lm"
michaelni's avatar
 
michaelni committed
52
simpleidct="yes"
53
bigendian="no"
54
mpegaudio_hp="yes"
55 56 57 58 59 60 61 62

# OS specific
targetos=`uname -s`
case $targetos in
BeOS)
prefix="/boot/home/config"
# helps building libavcodec
CFLAGS="-O2 -DPIC"
glantau's avatar
glantau committed
63
v4l="no"
64 65 66 67 68 69 70 71
# 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 ;;
al3x's avatar
al3x committed
72
BSD/OS)
glantau's avatar
glantau committed
73
v4l="no"
bellard's avatar
bellard committed
74
audio_oss="yes"
al3x's avatar
al3x committed
75 76 77
extralibs="-lpoll -lgnugetopt -lm"
make="gmake"
;;
78 79
*) ;;
esac
glantau's avatar
glantau committed
80

81 82 83 84 85 86 87 88 89
# find source path
# XXX: we assume an absolute path is given when launching configure, 
# except in './configure' case.
source_path=${0%configure}
source_path=${source_path%/}
source_path_used="yes"
if test -z "$source_path" -o "$source_path" = "." ; then
    source_path=`pwd`
    source_path_used="no"
glantau's avatar
glantau committed
90 91 92 93 94 95
fi

for opt do
  case "$opt" in
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  ;;
96 97 98 99
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  ;;
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  ;;
glantau's avatar
glantau committed
100 101
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  ;;
al3x's avatar
al3x committed
102 103
  --make=*) make=`echo $opt | cut -d '=' -f 2`
  ;;
104 105 106 107 108 109
  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
  ;;
  --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
  ;;
  --extra-libs=*) extralibs=${opt#--extra-libs=}
  ;;
glantau's avatar
glantau committed
110 111 112 113 114 115
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  ;;
  --disable-mmx) mmx="no"
  ;;
  --enable-gprof) gprof="yes"
  ;;
glantau's avatar
glantau committed
116 117 118 119 120 121 122
  --disable-v4l) v4l="no"
  ;;
  --disable-audio-oss) audio_oss="no"
  ;;
  --disable-network) network="no"
  ;;
  --disable-a52) a52="no"
123
  ;;
kabi's avatar
kabi committed
124 125
  --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  ;;
126 127
  --enable-mp3lame) mp3lame="yes"
  ;;
michaelni's avatar
 
michaelni committed
128
  --disable-simple_idct) simpleidct="no"
kabi's avatar
kabi committed
129
  ;;
glantau's avatar
glantau committed
130 131
  --enable-win32) win32="yes"
  ;;
kabi's avatar
kabi committed
132
  --enable-shared) lshared="yes"
nickols_k's avatar
nickols_k committed
133
  ;;
134 135
  --disable-mpegaudio-hp) mpegaudio_hp="no"
  ;;
glantau's avatar
glantau committed
136 137 138
  esac
done

139 140 141 142 143 144 145 146 147
# compute mmx state
if test $mmx = "default"; then
    if test $cpu = "x86"; then
        mmx="yes"
    else
        mmx="no"
    fi
fi

glantau's avatar
glantau committed
148 149 150 151 152
# Checking for CFLAGS
if test -z "$CFLAGS"; then
    CFLAGS="-O2"
fi

kabi's avatar
kabi committed
153
if test "$win32" = "yes" ; then
glantau's avatar
glantau committed
154
    cross_prefix="i386-mingw32msvc-"
glantau's avatar
glantau committed
155 156 157
    v4l="no"
    audio_oss="no"
    network="no"
glantau's avatar
glantau committed
158 159
fi

160 161 162 163 164 165 166 167 168
# endianness : guess with cpu type. Should also use prefix
if test "$cpu" = "powerpc"; then
    bigendian="yes"
fi

cc="${cross_prefix}${cc}"
ar="${cross_prefix}${ar}"
strip="${cross_prefix}${strip}"

nickols_k's avatar
nickols_k committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
# ---
# 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

mellum's avatar
mellum committed
194 195 196 197 198 199 200 201 202
_restrict=
for restrict_keyword in restrict __restrict__ __restrict; do
  echo "void foo(char * $restrict_keyword p);" > $TMPC
  if $cc -c -o $TMPO $TMPC 2> /dev/null; then
    _restrict=$restrict_keyword
    break;
  fi
done

bellard's avatar
bellard committed
203
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
204 205 206 207 208 209 210 211 212 213 214
cat << EOF

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

EOF
echo "Standard options:"
echo "  --help                   print this message"
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
echo "  --enable-win32           enable win32 cross compile"
glantau's avatar
glantau committed
215
echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
216 217 218 219 220 221 222
echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
echo "  --enable-shared          build shared libraries [default=no]"
echo ""
echo "Advanced options (experts only):"
echo "  --source-path=PATH       path of source code [$source_path]"
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
echo "  --cc=CC                  use C compiler CC [$cc]"
al3x's avatar
al3x committed
223
echo "  --make=MAKE              use specified make [$make]"
224 225 226 227 228
echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
echo "  --disable-mmx            disable mmx usage"
glantau's avatar
glantau committed
229
echo "  --disable-audio-oss      disable OSS audio support [default=no]"
bellard's avatar
bellard committed
230
echo "  --disable-v4l            disable video4linux grabbing [default=no]"
glantau's avatar
glantau committed
231 232
echo "  --disable-network        disable network support [default=no]"
echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
233
echo "  --enable-gprof           enable profiling with gprof [$gprof]"
234 235
echo "  --disable-mpegaudio-hp   faster (but less accurate)"
echo "                           mpegaudio decoding [default=no]"
236 237 238 239 240
echo ""
echo "NOTE: The object files are build at the place where configure is launched"
exit 1
fi

glantau's avatar
glantau committed
241
echo "Install prefix   $prefix"
242
echo "Source path      $source_path"
glantau's avatar
glantau committed
243
echo "C compiler       $cc"
al3x's avatar
al3x committed
244
echo "make             $make"
glantau's avatar
glantau committed
245
echo "CPU              $cpu"
246
echo "Big Endian       $bigendian"
glantau's avatar
glantau committed
247 248
echo "MMX enabled      $mmx"
echo "gprof enabled    $gprof"
249
echo "mp3lame enabled  $mp3lame"
glantau's avatar
glantau committed
250
echo "a52 support      $a52"
kabi's avatar
kabi committed
251
echo "a52 dlopened     $a52bin"
glantau's avatar
glantau committed
252

253
echo "Creating config.mak and config.h"
glantau's avatar
glantau committed
254

255
echo "# Automatically generated by configure - do not modify" > config.mak
kabi's avatar
kabi committed
256
echo "/* Automatically generated by configure - do not modify */" > $TMPH
glantau's avatar
glantau committed
257

258
echo "prefix=$prefix" >> config.mak
al3x's avatar
al3x committed
259
echo "MAKE=$make" >> config.mak
260 261
echo "CC=$cc" >> config.mak
echo "AR=$ar" >> config.mak
262
echo "STRIP=$strip" >> config.mak
nickols_k's avatar
nickols_k committed
263
echo "OPTFLAGS=$CFLAGS" >> config.mak
264
echo "LDFLAGS=$LDFLAGS" >> config.mak
kabi's avatar
kabi committed
265
if test "$cpu" = "x86" ; then
266
  echo "TARGET_ARCH_X86=yes" >> config.mak
kabi's avatar
kabi committed
267
  echo "#define ARCH_X86 1" >> $TMPH
268
elif test "$cpu" = "armv4l" ; then
269
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
kabi's avatar
kabi committed
270
  echo "#define ARCH_ARMV4L 1" >> $TMPH
271
elif test "$cpu" = "alpha" ; then
272
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
kabi's avatar
kabi committed
273
  echo "#define ARCH_ALPHA 1" >> $TMPH
274 275 276 277 278 279 280
elif test "$cpu" = "powerpc" ; then
  echo "TARGET_ARCH_POWERPC=yes" >> config.mak
  echo "#define ARCH_POWERPC 1" >> $TMPH
fi
if test "$bigendian" = "yes" ; then
  echo "WORDS_BIGENDIAN=yes" >> config.mak
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
281
fi
kabi's avatar
kabi committed
282
if test "$mmx" = "yes" ; then
283
  echo "TARGET_MMX=yes" >> config.mak
kabi's avatar
kabi committed
284
  echo "#define HAVE_MMX 1" >> $TMPH
glantau's avatar
glantau committed
285
fi
kabi's avatar
kabi committed
286
if test "$gprof" = "yes" ; then
287
  echo "TARGET_GPROF=yes" >> config.mak
kabi's avatar
kabi committed
288
  echo "#define HAVE_GPROF 1" >> $TMPH
glantau's avatar
glantau committed
289
fi
kabi's avatar
kabi committed
290
if test "$lshared" = "yes" ; then
nickols_k's avatar
nickols_k committed
291
  echo "BUILD_SHARED=yes" >> config.mak
glantau's avatar
glantau committed
292
  echo "PIC=-fPIC" >> config.mak
nickols_k's avatar
nickols_k committed
293
fi
294
echo "EXTRALIBS=$extralibs" >> config.mak
nickols_k's avatar
nickols_k committed
295
echo -n "VERSION=" >>config.mak
296
head $source_path/VERSION >>config.mak
nickols_k's avatar
nickols_k committed
297
echo "" >>config.mak
298
# if you do not want to use encoders, disable that.
kabi's avatar
kabi committed
299
echo "#define CONFIG_ENCODERS 1" >> $TMPH
300 301 302
echo "CONFIG_ENCODERS=yes" >> config.mak

# if you do not want to use decoders, disable that.
kabi's avatar
kabi committed
303
echo "#define CONFIG_DECODERS 1" >> $TMPH
304 305
echo "CONFIG_DECODERS=yes" >> config.mak

glantau's avatar
glantau committed
306 307 308 309
# AC3
if test "$a52" = "yes" ; then
  echo "#define CONFIG_AC3 1" >> $TMPH
  echo "CONFIG_AC3=yes" >> config.mak
310

glantau's avatar
glantau committed
311 312 313 314 315 316
  if test "$a52bin" = "yes" ; then
    echo "#define CONFIG_A52BIN 1" >> $TMPH
    echo "CONFIG_A52BIN=yes" >> config.mak
  fi
fi

317 318 319 320 321
# mpeg audio high precision mode
if test "$mpegaudio_hp" = "yes" ; then
  echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
fi

glantau's avatar
glantau committed
322 323 324 325 326 327 328 329
if test "$v4l" = "yes" ; then
  echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
  echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
fi

if test "$audio_oss" = "yes" ; then
  echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
  echo "CONFIG_AUDIO_OSS=yes" >> config.mak
kabi's avatar
kabi committed
330 331
fi

glantau's avatar
glantau committed
332 333 334
if test "$network" = "yes" ; then
  echo "#define CONFIG_NETWORK 1" >> $TMPH
  echo "CONFIG_NETWORK=yes" >> config.mak
335
fi
glantau's avatar
glantau committed
336

kabi's avatar
kabi committed
337
if test "$mp3lame" = "yes" ; then
kabi's avatar
kabi committed
338
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
339 340 341
  echo "CONFIG_MP3LAME=yes" >> config.mak
fi

kabi's avatar
kabi committed
342
if test "$win32" = "yes" ; then
kabi's avatar
kabi committed
343
  echo "#define CONFIG_WIN32 1" >> $TMPH
glantau's avatar
glantau committed
344 345
  echo "CONFIG_WIN32=yes" >> config.mak
fi
nickols_k's avatar
nickols_k committed
346

kabi's avatar
kabi committed
347
if test "$_malloc_h" = "yes" ; then
kabi's avatar
kabi committed
348
  echo "#define HAVE_MALLOC_H 1" >> $TMPH
nickols_k's avatar
nickols_k committed
349
else
kabi's avatar
kabi committed
350
  echo "#undef  HAVE_MALLOC_H" >> $TMPH
nickols_k's avatar
nickols_k committed
351 352
fi

kabi's avatar
kabi committed
353
if test "$_memalign" = "yes" ; then
kabi's avatar
kabi committed
354 355 356 357 358
  echo "#define HAVE_MEMALIGN 1" >> $TMPH
else
  echo "#undef  HAVE_MEMALIGN" >> $TMPH
fi

kabi's avatar
kabi committed
359
if test "$simpleidct" = "yes" ; then
kabi's avatar
kabi committed
360 361 362
  echo "#define SIMPLE_IDCT 1" >> $TMPH
fi

mellum's avatar
mellum committed
363 364
echo "#define restrict $_restrict" >> $TMPH

365 366 367 368 369 370 371 372 373 374 375 376 377 378
# build tree in object directory if source path is different from current one
if test "$source_path_used" = "yes" ; then
    DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
          libavcodec/liba52 libavcodec/mlib tests"
    FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
    for dir in $DIRS ; do
            mkdir -p $dir
    done
    for f in $FILES ; do
        ln -sf $source_path/$f $f
    done
fi
echo "SRC_PATH=$source_path" >> config.mak

kabi's avatar
kabi committed
379
diff $TMPH config.h >/dev/null 2>&1
kabi's avatar
kabi committed
380 381
if test $? -ne 0 ; then
	mv -f $TMPH config.h
nickols_k's avatar
nickols_k committed
382
else
kabi's avatar
kabi committed
383
	echo "config.h is unchanged"
nickols_k's avatar
nickols_k committed
384 385
fi

kabi's avatar
kabi committed
386
rm -f $TMPO $TMPC $TMPS $TMPH