license/copyright change
[libav.git] / configure
CommitLineData
de6d9b64 1#!/bin/sh
0f3cb305
FB
2#
3# ffmpeg configure script (c) 2000, 2001, 2002 Gerard Lantau
4#
5# set temporary file name
57514323 6if test ! -z "$TMPDIR" ; then
0f3cb305 7 TMPDIR1="${TMPDIR}"
57514323 8elif test ! -z "$TEMPDIR" ; then
0f3cb305 9 TMPDIR1="${TEMPDIR}"
3d204385 10else
0f3cb305 11 TMPDIR1="/tmp"
3d204385
NK
12fi
13
0f3cb305
FB
14TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
17TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
18
de6d9b64
FB
19# default parameters
20prefix="/usr/local"
0f3cb305 21cross_prefix=""
de6d9b64
FB
22cc="gcc"
23ar="ar"
4a908fbc 24make="make"
0f3cb305 25strip="strip"
de6d9b64 26cpu=`uname -m`
0f3cb305 27mmx="default"
de6d9b64 28case "$cpu" in
ef0bc4c9 29 i386|i486|i586|i686|i86pc|BePC)
de6d9b64 30 cpu="x86"
de6d9b64 31 ;;
6ed7422a
FB
32 armv4l)
33 cpu="armv4l"
6ed7422a 34 ;;
91d1f1a4
NK
35 alpha)
36 cpu="alpha"
91d1f1a4 37 ;;
de6d9b64 38 *)
0f3cb305 39 cpu="unknown"
de6d9b64
FB
40 ;;
41esac
42gprof="no"
6ed7422a 43grab="yes"
a6741398 44mp3lame="no"
57514323 45a52bin="no"
daf8e955 46win32="no"
83286d2a 47lshared="no"
ef0bc4c9 48extralibs="-lm"
c02dbee1 49simpleidct="yes"
0f3cb305 50bigendian="no"
ef0bc4c9
FR
51
52# OS specific
53targetos=`uname -s`
54case $targetos in
55BeOS)
56prefix="/boot/home/config"
57# helps building libavcodec
58grab="no"
59CFLAGS="-O2 -DPIC"
60# no need for libm, but the inet stuff
61# Check for BONE
62if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
63extralibs="-lbind -lsocket"
64else
65echo "Not sure building for net_server will succeed... good luck."
66extralibs="-lsocket"
67fi ;;
4a908fbc
AB
68BSD/OS)
69grab="no"
70extralibs="-lpoll -lgnugetopt -lm"
71make="gmake"
72;;
ef0bc4c9
FR
73*) ;;
74esac
de6d9b64 75
0f3cb305
FB
76# find source path
77# XXX: we assume an absolute path is given when launching configure,
78# except in './configure' case.
79source_path=${0%configure}
80source_path=${source_path%/}
81source_path_used="yes"
82if test -z "$source_path" -o "$source_path" = "." ; then
83 source_path=`pwd`
84 source_path_used="no"
de6d9b64
FB
85fi
86
87for opt do
88 case "$opt" in
89 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
90 ;;
0f3cb305
FB
91 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
92 ;;
93 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
94 ;;
de6d9b64
FB
95 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
96 ;;
4a908fbc
AB
97 --make=*) make=`echo $opt | cut -d '=' -f 2`
98 ;;
0f3cb305
FB
99 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
100 ;;
101 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
102 ;;
103 --extra-libs=*) extralibs=${opt#--extra-libs=}
104 ;;
de6d9b64
FB
105 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
106 ;;
107 --disable-mmx) mmx="no"
108 ;;
109 --enable-gprof) gprof="yes"
110 ;;
6ed7422a
FB
111 --disable-grab) grab="no"
112 ;;
57514323
ZK
113 --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
114 ;;
a6741398
J
115 --enable-mp3lame) mp3lame="yes"
116 ;;
c02dbee1 117 --disable-simple_idct) simpleidct="no"
045ed63f 118 ;;
daf8e955
FB
119 --enable-win32) win32="yes"
120 ;;
83286d2a 121 --enable-shared) lshared="yes"
0319c531 122 ;;
de6d9b64
FB
123 esac
124done
125
0f3cb305
FB
126# compute mmx state
127if test $mmx = "default"; then
128 if test $cpu = "x86"; then
129 mmx="yes"
130 else
131 mmx="no"
132 fi
133fi
134
daf8e955
FB
135# Checking for CFLAGS
136if test -z "$CFLAGS"; then
137 CFLAGS="-O2"
138fi
139
57514323 140if test "$win32" = "yes" ; then
daf8e955 141 cross_prefix="i386-mingw32msvc-"
daf8e955
FB
142 grab="no"
143fi
144
0f3cb305
FB
145# endianness : guess with cpu type. Should also use prefix
146if test "$cpu" = "powerpc"; then
147 bigendian="yes"
148fi
149
150cc="${cross_prefix}${cc}"
151ar="${cross_prefix}${ar}"
152strip="${cross_prefix}${strip}"
153
3d204385
NK
154# ---
155# check availability of some header files
156
157cat > $TMPC << EOF
158#include <malloc.h>
159int main( void ) { return 0; }
160EOF
161
162_memalign=no
163_malloc_h=no
164if $cc -o $TMPO $TMPC 2> /dev/null ; then
165_malloc_h=yes
166_memalign=yes
167# check for memalign - atmos
168cat > $TMPC << EOF
169#include <malloc.h>
170int main ( void ) {
171char *string = NULL;
172string = memalign(64, sizeof(char));
173return 0;
174}
175EOF
176$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
177fi
178
0f3cb305
FB
179if test "$1" = "-h" -o "$1" = "--help" ; then
180cat << EOF
181
182Usage: configure [options]
183Options: [defaults in brackets after descriptions]
184
185EOF
186echo "Standard options:"
187echo " --help print this message"
188echo " --prefix=PREFIX install in PREFIX [$prefix]"
189echo " --disable-grab disable audio/video grabbing code"
190echo " --disable-simple_idct disable simple IDCT routines [default=no]"
191echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
192echo " --enable-win32 enable win32 cross compile"
193echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
194echo " --enable-shared build shared libraries [default=no]"
195echo ""
196echo "Advanced options (experts only):"
197echo " --source-path=PATH path of source code [$source_path]"
198echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
199echo " --cc=CC use C compiler CC [$cc]"
4a908fbc 200echo " --make=MAKE use specified make [$make]"
0f3cb305
FB
201echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
202echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
203echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
204echo " --cpu=CPU force cpu to CPU [$cpu]"
205echo " --disable-mmx disable mmx usage"
206echo " --enable-gprof enable profiling with gprof [$gprof]"
207echo ""
208echo "NOTE: The object files are build at the place where configure is launched"
209exit 1
210fi
211
de6d9b64 212echo "Install prefix $prefix"
0f3cb305 213echo "Source path $source_path"
de6d9b64 214echo "C compiler $cc"
4a908fbc 215echo "make $make"
de6d9b64 216echo "CPU $cpu"
0f3cb305 217echo "Big Endian $bigendian"
de6d9b64
FB
218echo "MMX enabled $mmx"
219echo "gprof enabled $gprof"
6ed7422a 220echo "grab enabled $grab"
a6741398 221echo "mp3lame enabled $mp3lame"
57514323 222echo "a52 dlopened $a52bin"
de6d9b64 223
980fc7b8 224echo "Creating config.mak and config.h"
de6d9b64 225
980fc7b8 226echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 227echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 228
980fc7b8 229echo "prefix=$prefix" >> config.mak
4a908fbc 230echo "MAKE=$make" >> config.mak
980fc7b8
FB
231echo "CC=$cc" >> config.mak
232echo "AR=$ar" >> config.mak
0f3cb305 233echo "STRIP=$strip" >> config.mak
a9b3f630 234echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 235echo "LDFLAGS=$LDFLAGS" >> config.mak
57514323 236if test "$cpu" = "x86" ; then
980fc7b8 237 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 238 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 239elif test "$cpu" = "armv4l" ; then
6ed7422a 240 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 241 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 242elif test "$cpu" = "alpha" ; then
91d1f1a4 243 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 244 echo "#define ARCH_ALPHA 1" >> $TMPH
0f3cb305
FB
245elif test "$cpu" = "powerpc" ; then
246 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
247 echo "#define ARCH_POWERPC 1" >> $TMPH
248fi
249if test "$bigendian" = "yes" ; then
250 echo "WORDS_BIGENDIAN=yes" >> config.mak
251 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 252fi
57514323 253if test "$mmx" = "yes" ; then
980fc7b8 254 echo "TARGET_MMX=yes" >> config.mak
045ed63f 255 echo "#define HAVE_MMX 1" >> $TMPH
de6d9b64 256fi
57514323 257if test "$gprof" = "yes" ; then
980fc7b8 258 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 259 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 260fi
57514323 261if test "$lshared" = "yes" ; then
0319c531
NK
262 echo "BUILD_SHARED=yes" >> config.mak
263else
264 echo "BUILD_SHARED=no" >> config.mak
265fi
ef0bc4c9 266echo "EXTRALIBS=$extralibs" >> config.mak
0319c531 267echo -n "VERSION=" >>config.mak
0f3cb305 268head $source_path/VERSION >>config.mak
0319c531 269echo "" >>config.mak
d771bcae 270# if you do not want to use encoders, disable that.
045ed63f 271echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
272echo "CONFIG_ENCODERS=yes" >> config.mak
273
274# if you do not want to use decoders, disable that.
045ed63f 275echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
276echo "CONFIG_DECODERS=yes" >> config.mak
277
d2b7bcd2 278# special AC3 stuff in case you already have it
d771bcae 279# without libavcodec.
045ed63f 280echo "#define CONFIG_AC3 1" >> $TMPH
d771bcae
FB
281echo "CONFIG_AC3=yes" >> config.mak
282
57514323
ZK
283if test "$a52bin" = "yes" ; then
284 echo "#define CONFIG_A52BIN 1" >> $TMPH
285 echo "CONFIG_A52BIN=yes" >> config.mak
286else
287 echo "CONFIG_A52BIN=no" >> config.mak
288fi
289
290if test "$grab" = "yes" ; then
045ed63f 291 echo "#define CONFIG_GRAB 1" >> $TMPH
6ed7422a
FB
292 echo "CONFIG_GRAB=yes" >> config.mak
293fi
daf8e955 294
57514323 295if test "$mp3lame" = "yes" ; then
045ed63f 296 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
297 echo "CONFIG_MP3LAME=yes" >> config.mak
298fi
299
57514323 300if test "$win32" = "yes" ; then
045ed63f 301 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
302 echo "CONFIG_WIN32=yes" >> config.mak
303fi
3d204385 304
57514323 305if test "$_malloc_h" = "yes" ; then
045ed63f 306 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 307else
045ed63f 308 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
309fi
310
57514323 311if test "$_memalign" = "yes" ; then
045ed63f
ZK
312 echo "#define HAVE_MEMALIGN 1" >> $TMPH
313else
314 echo "#undef HAVE_MEMALIGN" >> $TMPH
315fi
316
57514323 317if test "$simpleidct" = "yes" ; then
045ed63f
ZK
318 echo "#define SIMPLE_IDCT 1" >> $TMPH
319fi
320
0f3cb305
FB
321# build tree in object directory if source path is different from current one
322if test "$source_path_used" = "yes" ; then
323 DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
324 libavcodec/liba52 libavcodec/mlib tests"
325 FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
326 for dir in $DIRS ; do
327 mkdir -p $dir
328 done
329 for f in $FILES ; do
330 ln -sf $source_path/$f $f
331 done
332fi
333echo "SRC_PATH=$source_path" >> config.mak
334
a7c02e25 335diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
336if test $? -ne 0 ; then
337 mv -f $TMPH config.h
3d204385 338else
045ed63f 339 echo "config.h is unchanged"
3d204385
NK
340fi
341
045ed63f 342rm -f $TMPO $TMPC $TMPS $TMPH