* Now we do not delete the feed file if it was created with the same
[libav.git] / configure
CommitLineData
de6d9b64 1#!/bin/sh
0f3cb305 2#
5cbcf02c 3# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
0f3cb305
FB
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"
5cbcf02c
FB
43v4l="yes"
44audio_oss="yes"
45network="yes"
0147f198 46zlib="yes"
a6741398 47mp3lame="no"
5cbcf02c 48a52="yes"
57514323 49a52bin="no"
daf8e955 50win32="no"
83286d2a 51lshared="no"
ef0bc4c9 52extralibs="-lm"
c02dbee1 53simpleidct="yes"
0f3cb305 54bigendian="no"
68892110 55vhook="no"
1eb2212e 56mpegaudio_hp="yes"
e1707f52 57SHFLAGS=-shared
ef0bc4c9
FR
58
59# OS specific
60targetos=`uname -s`
61case $targetos in
62BeOS)
63prefix="/boot/home/config"
64# helps building libavcodec
e1707f52
MN
65CFLAGS="-O3 -DPIC -fomit-frame-pointer"
66SHFLAGS=-nostart
67# disable linux things
68audio_oss="no"
5cbcf02c 69v4l="no"
ef0bc4c9
FR
70# no need for libm, but the inet stuff
71# Check for BONE
72if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
73extralibs="-lbind -lsocket"
74else
75echo "Not sure building for net_server will succeed... good luck."
76extralibs="-lsocket"
77fi ;;
4a908fbc 78BSD/OS)
5cbcf02c 79v4l="no"
6063bce7 80audio_oss="yes"
4a908fbc
AB
81extralibs="-lpoll -lgnugetopt -lm"
82make="gmake"
83;;
ef0bc4c9
FR
84*) ;;
85esac
de6d9b64 86
0f3cb305
FB
87# find source path
88# XXX: we assume an absolute path is given when launching configure,
89# except in './configure' case.
90source_path=${0%configure}
91source_path=${source_path%/}
92source_path_used="yes"
93if test -z "$source_path" -o "$source_path" = "." ; then
94 source_path=`pwd`
95 source_path_used="no"
de6d9b64
FB
96fi
97
68892110
PG
98cat > $TMPC << EOF
99#include <dlfcn.h>
100int main( void ) { return (int) dlopen("foo", 0); }
101EOF
102
103if $cc -o $TMPO $TMPC -ldl 2> /dev/null ; then
104: vhook=yes
105fi
106
107cat > $TMPC << EOF
108#include <X11/Xlib.h>
109#include <Imlib2.h>
110int main( void ) { return (int) imlib_load_font("foo"); }
111EOF
112
113imlib2=no
114if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null ; then
115imlib2=yes
116fi
117
de6d9b64
FB
118for opt do
119 case "$opt" in
120 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
121 ;;
0f3cb305
FB
122 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
123 ;;
124 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
125 ;;
de6d9b64
FB
126 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
127 ;;
4a908fbc
AB
128 --make=*) make=`echo $opt | cut -d '=' -f 2`
129 ;;
0f3cb305
FB
130 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
131 ;;
132 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
133 ;;
134 --extra-libs=*) extralibs=${opt#--extra-libs=}
135 ;;
de6d9b64
FB
136 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
137 ;;
138 --disable-mmx) mmx="no"
139 ;;
140 --enable-gprof) gprof="yes"
141 ;;
5cbcf02c
FB
142 --disable-v4l) v4l="no"
143 ;;
144 --disable-audio-oss) audio_oss="no"
145 ;;
146 --disable-network) network="no"
147 ;;
0147f198
FR
148 --disable-zlib) zlib="no"
149 ;;
5cbcf02c 150 --disable-a52) a52="no"
6ed7422a 151 ;;
57514323
ZK
152 --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
153 ;;
a6741398
J
154 --enable-mp3lame) mp3lame="yes"
155 ;;
68892110
PG
156 --disable-vhook) vhook="no"
157 ;;
c02dbee1 158 --disable-simple_idct) simpleidct="no"
045ed63f 159 ;;
daf8e955
FB
160 --enable-win32) win32="yes"
161 ;;
83286d2a 162 --enable-shared) lshared="yes"
0319c531 163 ;;
1eb2212e
FB
164 --disable-mpegaudio-hp) mpegaudio_hp="no"
165 ;;
de6d9b64
FB
166 esac
167done
168
0f3cb305
FB
169# compute mmx state
170if test $mmx = "default"; then
171 if test $cpu = "x86"; then
172 mmx="yes"
173 else
174 mmx="no"
175 fi
176fi
177
daf8e955
FB
178# Checking for CFLAGS
179if test -z "$CFLAGS"; then
29482cb4 180 CFLAGS="-O3"
daf8e955
FB
181fi
182
57514323 183if test "$win32" = "yes" ; then
daf8e955 184 cross_prefix="i386-mingw32msvc-"
5cbcf02c
FB
185 v4l="no"
186 audio_oss="no"
187 network="no"
daf8e955
FB
188fi
189
0f3cb305
FB
190# endianness : guess with cpu type. Should also use prefix
191if test "$cpu" = "powerpc"; then
192 bigendian="yes"
193fi
194
195cc="${cross_prefix}${cc}"
196ar="${cross_prefix}${ar}"
197strip="${cross_prefix}${strip}"
198
3d204385
NK
199# ---
200# check availability of some header files
201
202cat > $TMPC << EOF
203#include <malloc.h>
204int main( void ) { return 0; }
205EOF
206
207_memalign=no
208_malloc_h=no
209if $cc -o $TMPO $TMPC 2> /dev/null ; then
210_malloc_h=yes
211_memalign=yes
212# check for memalign - atmos
213cat > $TMPC << EOF
214#include <malloc.h>
215int main ( void ) {
216char *string = NULL;
217string = memalign(64, sizeof(char));
218return 0;
219}
220EOF
221$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
222fi
223
68892110
PG
224cat > $TMPC << EOF
225#define _GNU_SOURCE
226#include <time.h>
227int main( void ) { return *strptime("", "", 0); }
228EOF
229
230strptime=no
231if $cc -o $TMPO $TMPC 2> /dev/null ; then
232 strptime=yes
233fi
234
0147f198
FR
235if test "$zlib" = "yes"; then
236# check for zlib - mmu_man
237cat > $TMPC << EOF
238#include <zlib.h>
239int main ( void ) {
240if (zlibVersion() != ZLIB_VERSION)
241 puts("zlib version differs !!!");
242 return 1;
243return 0;
244}
245EOF
246$cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
247# $TMPO 2> /dev/null > /dev/null || zlib="no"
248# XXX: more tests needed - runtime test
249fi
250if test "$zlib" = "yes"; then
251extralibs="$extralibs -lz"
252fi
253
c13e1abd
FH
254_restrict=
255for restrict_keyword in restrict __restrict__ __restrict; do
256 echo "void foo(char * $restrict_keyword p);" > $TMPC
257 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
258 _restrict=$restrict_keyword
259 break;
260 fi
261done
262
6063bce7 263if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
0f3cb305
FB
264cat << EOF
265
266Usage: configure [options]
267Options: [defaults in brackets after descriptions]
268
269EOF
270echo "Standard options:"
271echo " --help print this message"
272echo " --prefix=PREFIX install in PREFIX [$prefix]"
0f3cb305
FB
273echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
274echo " --enable-win32 enable win32 cross compile"
5cbcf02c 275echo " --disable-a52 disable GPL'ed A52 support [default=no]"
0f3cb305
FB
276echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
277echo " --enable-shared build shared libraries [default=no]"
278echo ""
279echo "Advanced options (experts only):"
280echo " --source-path=PATH path of source code [$source_path]"
281echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
282echo " --cc=CC use C compiler CC [$cc]"
4a908fbc 283echo " --make=MAKE use specified make [$make]"
0f3cb305
FB
284echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
285echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
286echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
287echo " --cpu=CPU force cpu to CPU [$cpu]"
288echo " --disable-mmx disable mmx usage"
5cbcf02c 289echo " --disable-audio-oss disable OSS audio support [default=no]"
6063bce7 290echo " --disable-v4l disable video4linux grabbing [default=no]"
5cbcf02c 291echo " --disable-network disable network support [default=no]"
0147f198 292echo " --disable-zlib disable zlib [default=no]"
5cbcf02c 293echo " --disable-simple_idct disable simple IDCT routines [default=no]"
68892110 294# echo " --disable-vhook disable video hooking support"
0f3cb305 295echo " --enable-gprof enable profiling with gprof [$gprof]"
1eb2212e
FB
296echo " --disable-mpegaudio-hp faster (but less accurate)"
297echo " mpegaudio decoding [default=no]"
0f3cb305
FB
298echo ""
299echo "NOTE: The object files are build at the place where configure is launched"
300exit 1
301fi
302
de6d9b64 303echo "Install prefix $prefix"
0f3cb305 304echo "Source path $source_path"
de6d9b64 305echo "C compiler $cc"
4a908fbc 306echo "make $make"
de6d9b64 307echo "CPU $cpu"
0f3cb305 308echo "Big Endian $bigendian"
de6d9b64
FB
309echo "MMX enabled $mmx"
310echo "gprof enabled $gprof"
0147f198 311echo "zlib enabled $zlib"
a6741398 312echo "mp3lame enabled $mp3lame"
5cbcf02c 313echo "a52 support $a52"
57514323 314echo "a52 dlopened $a52bin"
68892110
PG
315# echo "Video hooking $vhook"
316
317if test "$vhook" = "yes" ; then
318: echo "Imlib2 support $imlib2"
319fi
de6d9b64 320
980fc7b8 321echo "Creating config.mak and config.h"
de6d9b64 322
980fc7b8 323echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 324echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 325
980fc7b8 326echo "prefix=$prefix" >> config.mak
4a908fbc 327echo "MAKE=$make" >> config.mak
980fc7b8
FB
328echo "CC=$cc" >> config.mak
329echo "AR=$ar" >> config.mak
0f3cb305 330echo "STRIP=$strip" >> config.mak
a9b3f630 331echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 332echo "LDFLAGS=$LDFLAGS" >> config.mak
e1707f52 333echo "SHFLAGS=$SHFLAGS" >> config.mak
57514323 334if test "$cpu" = "x86" ; then
980fc7b8 335 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 336 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 337elif test "$cpu" = "armv4l" ; then
6ed7422a 338 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 339 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 340elif test "$cpu" = "alpha" ; then
91d1f1a4 341 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 342 echo "#define ARCH_ALPHA 1" >> $TMPH
0f3cb305
FB
343elif test "$cpu" = "powerpc" ; then
344 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
345 echo "#define ARCH_POWERPC 1" >> $TMPH
346fi
347if test "$bigendian" = "yes" ; then
348 echo "WORDS_BIGENDIAN=yes" >> config.mak
349 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 350fi
57514323 351if test "$mmx" = "yes" ; then
980fc7b8 352 echo "TARGET_MMX=yes" >> config.mak
045ed63f 353 echo "#define HAVE_MMX 1" >> $TMPH
de6d9b64 354fi
57514323 355if test "$gprof" = "yes" ; then
980fc7b8 356 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 357 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 358fi
68892110
PG
359if test "$strptime" = "yes" ; then
360 echo "#define HAVE_STRPTIME 1" >> $TMPH
361else
362 echo "BUILD_STRPTIME=yes" >> config.mak
363fi
364if test "$imlib2" = "yes" ; then
365 echo "HAVE_IMLIB2=yes" >> config.mak
366fi
367if test "$vhook" = "yes" ; then
368 echo "BUILD_VHOOK=yes" >> config.mak
369 echo "#define HAVE_VHOOK 1" >> $TMPH
370 extralibs="$extralibs -ldl"
371fi
57514323 372if test "$lshared" = "yes" ; then
0319c531 373 echo "BUILD_SHARED=yes" >> config.mak
5cbcf02c 374 echo "PIC=-fPIC" >> config.mak
0319c531 375fi
ef0bc4c9 376echo "EXTRALIBS=$extralibs" >> config.mak
0319c531 377echo -n "VERSION=" >>config.mak
0f3cb305 378head $source_path/VERSION >>config.mak
0319c531 379echo "" >>config.mak
d771bcae 380# if you do not want to use encoders, disable that.
045ed63f 381echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
382echo "CONFIG_ENCODERS=yes" >> config.mak
383
384# if you do not want to use decoders, disable that.
045ed63f 385echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
386echo "CONFIG_DECODERS=yes" >> config.mak
387
5cbcf02c
FB
388# AC3
389if test "$a52" = "yes" ; then
390 echo "#define CONFIG_AC3 1" >> $TMPH
391 echo "CONFIG_AC3=yes" >> config.mak
d771bcae 392
5cbcf02c
FB
393 if test "$a52bin" = "yes" ; then
394 echo "#define CONFIG_A52BIN 1" >> $TMPH
395 echo "CONFIG_A52BIN=yes" >> config.mak
396 fi
397fi
398
1eb2212e
FB
399# mpeg audio high precision mode
400if test "$mpegaudio_hp" = "yes" ; then
401 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
402fi
403
5cbcf02c
FB
404if test "$v4l" = "yes" ; then
405 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
406 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
407fi
408
409if test "$audio_oss" = "yes" ; then
410 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
411 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
57514323
ZK
412fi
413
5cbcf02c
FB
414if test "$network" = "yes" ; then
415 echo "#define CONFIG_NETWORK 1" >> $TMPH
416 echo "CONFIG_NETWORK=yes" >> config.mak
6ed7422a 417fi
daf8e955 418
0147f198
FR
419if test "$zlib" = "yes" ; then
420 echo "#define CONFIG_ZLIB 1" >> $TMPH
421 echo "CONFIG_ZLIB=yes" >> config.mak
422fi
423
57514323 424if test "$mp3lame" = "yes" ; then
045ed63f 425 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
426 echo "CONFIG_MP3LAME=yes" >> config.mak
427fi
428
57514323 429if test "$win32" = "yes" ; then
045ed63f 430 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
431 echo "CONFIG_WIN32=yes" >> config.mak
432fi
3d204385 433
57514323 434if test "$_malloc_h" = "yes" ; then
045ed63f 435 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 436else
045ed63f 437 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
438fi
439
57514323 440if test "$_memalign" = "yes" ; then
045ed63f
ZK
441 echo "#define HAVE_MEMALIGN 1" >> $TMPH
442else
443 echo "#undef HAVE_MEMALIGN" >> $TMPH
444fi
445
57514323 446if test "$simpleidct" = "yes" ; then
045ed63f
ZK
447 echo "#define SIMPLE_IDCT 1" >> $TMPH
448fi
449
c13e1abd
FH
450echo "#define restrict $_restrict" >> $TMPH
451
0f3cb305
FB
452# build tree in object directory if source path is different from current one
453if test "$source_path_used" = "yes" ; then
454 DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
455 libavcodec/liba52 libavcodec/mlib tests"
456 FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
457 for dir in $DIRS ; do
458 mkdir -p $dir
459 done
460 for f in $FILES ; do
461 ln -sf $source_path/$f $f
462 done
463fi
464echo "SRC_PATH=$source_path" >> config.mak
465
a7c02e25 466diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
467if test $? -ne 0 ; then
468 mv -f $TMPH config.h
3d204385 469else
045ed63f 470 echo "config.h is unchanged"
3d204385
NK
471fi
472
045ed63f 473rm -f $TMPO $TMPC $TMPS $TMPH