Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
[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"
6
7if [ ! -z "$TMPDIR" ]; then
8 TMPC="${TMPDIR}/${TMPC}"
9 TMPCPP="${TMPDIR}/${TMPCPP}"
10 TMPO="${TMPDIR}/${TMPO}"
11 TMPS="${TMPDIR}/${TMPS}"
12elif [ ! -z "$TEMPDIR" ]; then
13 TMPC="${TEMPDIR}/${TMPC}"
14 TMPCPP="${TEMPDIR}/${TMPCPP}"
15 TMPO="${TEMPDIR}/${TMPO}"
16 TMPS="${TEMPDIR}/${TMPS}"
17else
18 TMPC="/tmp/${TMPC}"
19 TMPCPP="/tmp/${TMPCPP}"
20 TMPO="/tmp/${TMPO}"
21 TMPS="/tmp/${TMPS}"
22fi
23
de6d9b64
FB
24# default parameters
25prefix="/usr/local"
26cc="gcc"
27ar="ar"
28cpu=`uname -m`
29case "$cpu" in
123ba071 30 i386|i486|i586|i686|i86pc)
de6d9b64
FB
31 cpu="x86"
32 mmx="yes"
33 ;;
6ed7422a
FB
34 armv4l)
35 cpu="armv4l"
36 mmx="no"
37 ;;
de6d9b64
FB
38 *)
39 mmx="no"
40 ;;
41esac
42gprof="no"
6ed7422a 43grab="yes"
daf8e955 44win32="no"
de6d9b64
FB
45
46if [ "$1" = "-h" -o "$1" = "--help" ] ; then
47cat << EOF
48
49Usage: configure [options]
50Options: [defaults in brackets after descriptions]
51
52 --help print this message
53EOF
54echo " --prefix=PREFIX install in PREFIX [$prefix]"
55echo " --cc=CC use C compiler CC [$cc]"
56echo " --cpu=CPU force cpu to CPU [$cpu]"
57echo " --disable-mmx disable mmx usage"
58echo " --enable-gprof enable profiling with gprof [$gprof]"
6ed7422a 59echo " --disable-grab disable audio/video grabbing code"
daf8e955 60echo " --enable-win32 enable win32 cross compile"
0319c531 61echo " --enable-shared build shared libraries [default=no]"
de6d9b64
FB
62exit 1
63fi
64
0319c531 65lshared=no
de6d9b64
FB
66for opt do
67 case "$opt" in
68 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
69 ;;
70 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
71 ;;
72 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
73 ;;
74 --disable-mmx) mmx="no"
75 ;;
76 --enable-gprof) gprof="yes"
77 ;;
6ed7422a
FB
78 --disable-grab) grab="no"
79 ;;
daf8e955
FB
80 --enable-win32) win32="yes"
81 ;;
0319c531
NK
82 --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
83 ;;
de6d9b64
FB
84 esac
85done
86
daf8e955
FB
87# Checking for CFLAGS
88if test -z "$CFLAGS"; then
89 CFLAGS="-O2"
90fi
91
92if [ "$win32" = "yes" ] ; then
93 cross_prefix="i386-mingw32msvc-"
94 cc="${cross_prefix}gcc"
95 ar="${cross_prefix}ar"
96 grab="no"
97fi
98
3d204385
NK
99# ---
100# check availability of some header files
101
102cat > $TMPC << EOF
103#include <malloc.h>
104int main( void ) { return 0; }
105EOF
106
107_memalign=no
108_malloc_h=no
109if $cc -o $TMPO $TMPC 2> /dev/null ; then
110_malloc_h=yes
111_memalign=yes
112# check for memalign - atmos
113cat > $TMPC << EOF
114#include <malloc.h>
115int main ( void ) {
116char *string = NULL;
117string = memalign(64, sizeof(char));
118return 0;
119}
120EOF
121$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
122fi
123
de6d9b64
FB
124echo "Install prefix $prefix"
125echo "C compiler $cc"
126echo "CPU $cpu"
127echo "MMX enabled $mmx"
128echo "gprof enabled $gprof"
6ed7422a 129echo "grab enabled $grab"
de6d9b64 130
980fc7b8 131echo "Creating config.mak and config.h"
de6d9b64 132
980fc7b8 133echo "# Automatically generated by configure - do not modify" > config.mak
de6d9b64
FB
134echo "/* Automatically generated by configure - do not modify */" > config.h
135
980fc7b8 136echo "prefix=$prefix" >> config.mak
2cc8ae96 137echo "MAKE=make" >> config.mak
980fc7b8
FB
138echo "CC=$cc" >> config.mak
139echo "AR=$ar" >> config.mak
a9b3f630 140echo "OPTFLAGS=$CFLAGS" >> config.mak
de6d9b64 141if [ "$cpu" = "x86" ] ; then
980fc7b8
FB
142 echo "TARGET_ARCH_X86=yes" >> config.mak
143 echo "#define ARCH_X86 1" >> config.h
de6d9b64 144fi
6ed7422a
FB
145if [ "$cpu" = "armv4l" ]; then
146 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
147 echo "#define ARCH_ARMV4L 1" >> config.h
148fi
de6d9b64 149if [ "$mmx" = "yes" ] ; then
980fc7b8
FB
150 echo "TARGET_MMX=yes" >> config.mak
151 echo "#define HAVE_MMX 1" >> config.h
de6d9b64
FB
152fi
153if [ "$gprof" = "yes" ] ; then
980fc7b8
FB
154 echo "TARGET_GPROF=yes" >> config.mak
155 echo "#define HAVE_GPROF 1" >> config.h
de6d9b64 156fi
0319c531
NK
157if [ "$lshared" = "yes" ] ; then
158 echo "BUILD_SHARED=yes" >> config.mak
159else
160 echo "BUILD_SHARED=no" >> config.mak
161fi
162echo -n "VERSION=" >>config.mak
163head VERSION >>config.mak
164echo "" >>config.mak
d771bcae
FB
165# if you do not want to use encoders, disable that.
166echo "#define CONFIG_ENCODERS 1" >> config.h
167echo "CONFIG_ENCODERS=yes" >> config.mak
168
169# if you do not want to use decoders, disable that.
170echo "#define CONFIG_DECODERS 1" >> config.h
171echo "CONFIG_DECODERS=yes" >> config.mak
172
d2b7bcd2 173# special AC3 stuff in case you already have it
d771bcae
FB
174# without libavcodec.
175echo "#define CONFIG_AC3 1" >> config.h
176echo "CONFIG_AC3=yes" >> config.mak
177
6ed7422a
FB
178if [ "$grab" = "yes" ] ; then
179 echo "#define CONFIG_GRAB 1" >> config.h
180 echo "CONFIG_GRAB=yes" >> config.mak
181fi
daf8e955
FB
182
183if [ "$win32" = "yes" ] ; then
184 echo "#define CONFIG_WIN32 1" >> config.h
185 echo "CONFIG_WIN32=yes" >> config.mak
186fi
3d204385
NK
187
188if [ "$_malloc_h" = "yes" ]; then
189 echo "#define HAVE_MALLOC_H 1" >> config.h
190else
191 echo "#undef HAVE_MALLOC_H" >> config.h
192fi
193
194if [ "$_memalign" = "yes" ]; then
195 echo "#define HAVE_MEMALIGN 1" >> config.h
196else
197 echo "#undef HAVE_MEMALIGN" >> config.h
198fi
199
200rm -f $TMPO $TMPC $TMPS