Shared objects support
[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"
de6d9b64
FB
61exit 1
62fi
63
64for opt do
65 case "$opt" in
66 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
67 ;;
68 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
69 ;;
70 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
71 ;;
72 --disable-mmx) mmx="no"
73 ;;
74 --enable-gprof) gprof="yes"
75 ;;
6ed7422a
FB
76 --disable-grab) grab="no"
77 ;;
daf8e955
FB
78 --enable-win32) win32="yes"
79 ;;
de6d9b64
FB
80 esac
81done
82
daf8e955
FB
83# Checking for CFLAGS
84if test -z "$CFLAGS"; then
85 CFLAGS="-O2"
86fi
87
88if [ "$win32" = "yes" ] ; then
89 cross_prefix="i386-mingw32msvc-"
90 cc="${cross_prefix}gcc"
91 ar="${cross_prefix}ar"
92 grab="no"
93fi
94
3d204385
NK
95# ---
96# check availability of some header files
97
98cat > $TMPC << EOF
99#include <malloc.h>
100int main( void ) { return 0; }
101EOF
102
103_memalign=no
104_malloc_h=no
105if $cc -o $TMPO $TMPC 2> /dev/null ; then
106_malloc_h=yes
107_memalign=yes
108# check for memalign - atmos
109cat > $TMPC << EOF
110#include <malloc.h>
111int main ( void ) {
112char *string = NULL;
113string = memalign(64, sizeof(char));
114return 0;
115}
116EOF
117$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
118fi
119
de6d9b64
FB
120echo "Install prefix $prefix"
121echo "C compiler $cc"
122echo "CPU $cpu"
123echo "MMX enabled $mmx"
124echo "gprof enabled $gprof"
6ed7422a 125echo "grab enabled $grab"
de6d9b64 126
980fc7b8 127echo "Creating config.mak and config.h"
de6d9b64 128
980fc7b8 129echo "# Automatically generated by configure - do not modify" > config.mak
de6d9b64
FB
130echo "/* Automatically generated by configure - do not modify */" > config.h
131
980fc7b8 132echo "prefix=$prefix" >> config.mak
2cc8ae96 133echo "MAKE=make" >> config.mak
980fc7b8
FB
134echo "CC=$cc" >> config.mak
135echo "AR=$ar" >> config.mak
a9b3f630 136echo "OPTFLAGS=$CFLAGS" >> config.mak
de6d9b64 137if [ "$cpu" = "x86" ] ; then
980fc7b8
FB
138 echo "TARGET_ARCH_X86=yes" >> config.mak
139 echo "#define ARCH_X86 1" >> config.h
de6d9b64 140fi
6ed7422a
FB
141if [ "$cpu" = "armv4l" ]; then
142 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
143 echo "#define ARCH_ARMV4L 1" >> config.h
144fi
de6d9b64 145if [ "$mmx" = "yes" ] ; then
980fc7b8
FB
146 echo "TARGET_MMX=yes" >> config.mak
147 echo "#define HAVE_MMX 1" >> config.h
de6d9b64
FB
148fi
149if [ "$gprof" = "yes" ] ; then
980fc7b8
FB
150 echo "TARGET_GPROF=yes" >> config.mak
151 echo "#define HAVE_GPROF 1" >> config.h
de6d9b64 152fi
d771bcae
FB
153
154# if you do not want to use encoders, disable that.
155echo "#define CONFIG_ENCODERS 1" >> config.h
156echo "CONFIG_ENCODERS=yes" >> config.mak
157
158# if you do not want to use decoders, disable that.
159echo "#define CONFIG_DECODERS 1" >> config.h
160echo "CONFIG_DECODERS=yes" >> config.mak
161
d2b7bcd2 162# special AC3 stuff in case you already have it
d771bcae
FB
163# without libavcodec.
164echo "#define CONFIG_AC3 1" >> config.h
165echo "CONFIG_AC3=yes" >> config.mak
166
6ed7422a
FB
167if [ "$grab" = "yes" ] ; then
168 echo "#define CONFIG_GRAB 1" >> config.h
169 echo "CONFIG_GRAB=yes" >> config.mak
170fi
daf8e955
FB
171
172if [ "$win32" = "yes" ] ; then
173 echo "#define CONFIG_WIN32 1" >> config.h
174 echo "CONFIG_WIN32=yes" >> config.mak
175fi
3d204385
NK
176
177if [ "$_malloc_h" = "yes" ]; then
178 echo "#define HAVE_MALLOC_H 1" >> config.h
179else
180 echo "#undef HAVE_MALLOC_H" >> config.h
181fi
182
183if [ "$_memalign" = "yes" ]; then
184 echo "#define HAVE_MEMALIGN 1" >> config.h
185else
186 echo "#undef HAVE_MEMALIGN" >> config.h
187fi
188
189rm -f $TMPO $TMPC $TMPS