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

Nick Kurshev's avatar
Nick Kurshev committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
TMPC="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
TMPS="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"

if [ ! -z "$TMPDIR" ]; then
	TMPC="${TMPDIR}/${TMPC}"
	TMPCPP="${TMPDIR}/${TMPCPP}"
	TMPO="${TMPDIR}/${TMPO}"
	TMPS="${TMPDIR}/${TMPS}"
elif [ ! -z "$TEMPDIR" ]; then
	TMPC="${TEMPDIR}/${TMPC}"
	TMPCPP="${TEMPDIR}/${TMPCPP}"
	TMPO="${TEMPDIR}/${TMPO}"
	TMPS="${TEMPDIR}/${TMPS}"
else
	TMPC="/tmp/${TMPC}"
	TMPCPP="/tmp/${TMPCPP}"
	TMPO="/tmp/${TMPO}"
	TMPS="/tmp/${TMPS}"
fi

Fabrice Bellard's avatar
Fabrice Bellard committed
24 25 26 27 28 29
# default parameters
prefix="/usr/local"
cc="gcc"
ar="ar"
cpu=`uname -m`
case "$cpu" in
30
  i386|i486|i586|i686|i86pc)
Fabrice Bellard's avatar
Fabrice Bellard committed
31 32 33
    cpu="x86"
    mmx="yes"
  ;;
34 35 36 37
  armv4l)
    cpu="armv4l"
    mmx="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
38 39 40 41 42
  *)
    mmx="no"
  ;;
esac
gprof="no"
43
grab="yes"
44
win32="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58

if [ "$1" = "-h" -o "$1" = "--help" ] ; then
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]"
59
echo "  --disable-grab          disable audio/video grabbing code"
60
echo "  --enable-win32          enable win32 cross compile"
Nick Kurshev's avatar
Nick Kurshev committed
61
echo "  --enable-shared         build shared libraries [default=no]"
Fabrice Bellard's avatar
Fabrice Bellard committed
62 63 64
exit 1
fi

Nick Kurshev's avatar
Nick Kurshev committed
65
lshared=no
Fabrice Bellard's avatar
Fabrice Bellard committed
66 67 68 69 70 71 72 73 74 75 76 77
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"
  ;;
78 79
  --disable-grab) grab="no"
  ;;
80 81
  --enable-win32) win32="yes"
  ;;
Nick Kurshev's avatar
Nick Kurshev committed
82 83
  --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
84 85 86
  esac
done

87 88 89 90 91 92 93 94 95 96 97 98
# Checking for CFLAGS
if test -z "$CFLAGS"; then
    CFLAGS="-O2"
fi

if [ "$win32" = "yes" ] ; then
    cross_prefix="i386-mingw32msvc-"
    cc="${cross_prefix}gcc"
    ar="${cross_prefix}ar"
    grab="no"
fi

Nick Kurshev's avatar
Nick Kurshev committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
# ---
# 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
124 125 126 127 128
echo "Install prefix   $prefix"
echo "C compiler       $cc"
echo "CPU              $cpu"
echo "MMX enabled      $mmx"
echo "gprof enabled    $gprof"
129
echo "grab enabled     $grab"
Fabrice Bellard's avatar
Fabrice Bellard committed
130

131
echo "Creating config.mak and config.h"
Fabrice Bellard's avatar
Fabrice Bellard committed
132

133
echo "# Automatically generated by configure - do not modify" > config.mak
Fabrice Bellard's avatar
Fabrice Bellard committed
134 135
echo "/* Automatically generated by configure - do not modify */" > config.h

136
echo "prefix=$prefix" >> config.mak
Fabrice Bellard's avatar
Fabrice Bellard committed
137
echo "MAKE=make" >> config.mak
138 139
echo "CC=$cc" >> config.mak
echo "AR=$ar" >> config.mak
Nick Kurshev's avatar
Nick Kurshev committed
140
echo "OPTFLAGS=$CFLAGS" >> config.mak
Fabrice Bellard's avatar
Fabrice Bellard committed
141
if [ "$cpu" = "x86" ] ; then
142 143
  echo "TARGET_ARCH_X86=yes" >> config.mak
  echo "#define ARCH_X86 1" >> config.h
Fabrice Bellard's avatar
Fabrice Bellard committed
144
fi
145 146 147 148
if [ "$cpu" = "armv4l" ]; then
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  echo "#define ARCH_ARMV4L 1" >> config.h
fi
Fabrice Bellard's avatar
Fabrice Bellard committed
149
if [ "$mmx" = "yes" ] ; then
150 151
  echo "TARGET_MMX=yes" >> config.mak
  echo "#define HAVE_MMX 1" >> config.h
Fabrice Bellard's avatar
Fabrice Bellard committed
152 153
fi
if [ "$gprof" = "yes" ] ; then
154 155
  echo "TARGET_GPROF=yes" >> config.mak
  echo "#define HAVE_GPROF 1" >> config.h
Fabrice Bellard's avatar
Fabrice Bellard committed
156
fi
Nick Kurshev's avatar
Nick Kurshev committed
157 158 159 160 161 162 163 164
if [ "$lshared" = "yes" ] ; then
  echo "BUILD_SHARED=yes" >> config.mak
else
  echo "BUILD_SHARED=no" >> config.mak
fi
echo -n "VERSION=" >>config.mak
head VERSION >>config.mak
echo "" >>config.mak
165 166 167 168 169 170 171 172
# if you do not want to use encoders, disable that.
echo "#define CONFIG_ENCODERS 1" >> config.h
echo "CONFIG_ENCODERS=yes" >> config.mak

# if you do not want to use decoders, disable that.
echo "#define CONFIG_DECODERS 1" >> config.h
echo "CONFIG_DECODERS=yes" >> config.mak

173
# special AC3 stuff in case you already have it
174 175 176 177
# without libavcodec.
echo "#define CONFIG_AC3 1" >> config.h
echo "CONFIG_AC3=yes" >> config.mak

178 179 180 181
if [ "$grab" = "yes" ] ; then
  echo "#define CONFIG_GRAB 1" >> config.h
  echo "CONFIG_GRAB=yes" >> config.mak
fi
182 183 184 185 186

if [ "$win32" = "yes" ] ; then
  echo "#define CONFIG_WIN32 1" >> config.h
  echo "CONFIG_WIN32=yes" >> config.mak
fi
Nick Kurshev's avatar
Nick Kurshev committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200

if [ "$_malloc_h" = "yes" ]; then
  echo "#define HAVE_MALLOC_H 1" >> config.h
else
  echo "#undef  HAVE_MALLOC_H" >> config.h
fi

if [ "$_memalign" = "yes" ]; then
  echo "#define HAVE_MEMALIGN 1" >> config.h
else
  echo "#undef  HAVE_MEMALIGN" >> config.h
fi

rm -f $TMPO $TMPC $TMPS