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