Write correct MPEG2-PS streams patch by (mru at users dot sourceforge dot net (Måns...
[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"
f3ec2d46 16TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
0f3cb305
FB
17TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
18TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
19
de6d9b64
FB
20# default parameters
21prefix="/usr/local"
0f3cb305 22cross_prefix=""
de6d9b64
FB
23cc="gcc"
24ar="ar"
be7109c1 25ranlib="ranlib"
4a908fbc 26make="make"
0f3cb305 27strip="strip"
de6d9b64 28cpu=`uname -m`
a4adb608 29tune="generic"
e45a2872 30powerpc_perf="no"
0f3cb305 31mmx="default"
ab6c65f6 32altivec="default"
d46aba26 33mmi="default"
de6d9b64 34case "$cpu" in
ef0bc4c9 35 i386|i486|i586|i686|i86pc|BePC)
de6d9b64 36 cpu="x86"
de6d9b64 37 ;;
93caefc7
AB
38 # armv4l is a subset of armv5tel
39 armv4l|armv5tel)
6ed7422a 40 cpu="armv4l"
6ed7422a 41 ;;
91d1f1a4
NK
42 alpha)
43 cpu="alpha"
91d1f1a4 44 ;;
a43bd1d7 45 "Power Macintosh"|ppc)
90cee0c3
MN
46 cpu="powerpc"
47 ;;
d46aba26
LS
48 mips)
49 cpu="mips"
50 ;;
a7beab73
RS
51 sun4u)
52 cpu="sparc64"
53 ;;
de6d9b64 54 *)
0f3cb305 55 cpu="unknown"
de6d9b64
FB
56 ;;
57esac
58gprof="no"
5cbcf02c
FB
59v4l="yes"
60audio_oss="yes"
dfdfa47c 61audio_beos="no"
8aa3ee32 62dv1394="yes"
5cbcf02c 63network="yes"
0147f198 64zlib="yes"
a6741398 65mp3lame="no"
81e0d0b4 66vorbis="no"
0fc50e58
ZK
67faad="no"
68faadbin="no"
5cbcf02c 69a52="yes"
57514323 70a52bin="no"
bba9b16c
MN
71pp="yes"
72shared_pp="no"
daf8e955 73win32="no"
732d9245 74mingw32="no"
3f027ca7 75cygwin="no"
f3ec2d46 76os2="no"
83286d2a 77lshared="no"
ef0bc4c9 78extralibs="-lm"
c02dbee1 79simpleidct="yes"
0f3cb305 80bigendian="no"
a8721c09 81vhook="default"
adbc0510
PG
82dlfcn="no"
83dlopen="no"
1eb2212e 84mpegaudio_hp="yes"
e1707f52 85SHFLAGS=-shared
26b35efb 86netserver="no"
4baca069 87need_inet_aton="no"
8154d2e0 88ffserver="yes"
a86b921c 89ffplay="yes"
4baca069
PG
90LDFLAGS=-Wl,--warn-common
91FFSLDFLAGS=-Wl,-E
f3ec2d46
SG
92LIBPREF="lib"
93LIBSUF=".a"
94SLIBPREF="lib"
95SLIBSUF=".so"
1d0d55da 96risky="yes"
553a6284 97small="no"
891f64b3 98amr_nb="no"
bc634f6f 99amr_nb_fixed="no"
ef0bc4c9
FR
100
101# OS specific
102targetos=`uname -s`
103case $targetos in
104BeOS)
105prefix="/boot/home/config"
106# helps building libavcodec
e1707f52 107CFLAGS="-O3 -DPIC -fomit-frame-pointer"
31ba0b4d
FR
108# 3 gcc releases known for BeOS, each with ugly bugs
109gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
110case "$gcc_version" in
1112.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
112mmx="no"
113;;
114*20010315*) echo "BeBits gcc"
115CFLAGS="$CFLAGS -fno-expensive-optimizations"
116;;
117esac
e1707f52
MN
118SHFLAGS=-nostart
119# disable linux things
120audio_oss="no"
5cbcf02c 121v4l="no"
8aa3ee32 122dv1394="no"
dfdfa47c
FR
123# enable beos things
124audio_beos="yes"
ef0bc4c9
FR
125# no need for libm, but the inet stuff
126# Check for BONE
127if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
128extralibs="-lbind -lsocket"
129else
26b35efb 130netserver="yes"
4baca069 131need_inet_aton="yes"
26b35efb 132extralibs="-lnet"
ef0bc4c9 133fi ;;
4baca069
PG
134SunOS)
135v4l="no"
136audio_oss="no"
8aa3ee32 137dv1394="no"
4baca069
PG
138make="gmake"
139LDFLAGS=""
140FFSLDFLAGS=""
141need_inet_aton="yes"
142extralibs="$extralibs -lsocket -lnsl"
143;;
9c938e77
PG
144FreeBSD)
145v4l="no"
146audio_oss="yes"
8aa3ee32 147dv1394="no"
9c938e77 148make="gmake"
4baca069 149LDFLAGS="$LDFLAGS -export-dynamic"
9c938e77 150;;
4a908fbc 151BSD/OS)
5cbcf02c 152v4l="no"
6063bce7 153audio_oss="yes"
8aa3ee32 154dv1394="no"
4a908fbc
AB
155extralibs="-lpoll -lgnugetopt -lm"
156make="gmake"
157;;
90cee0c3 158Darwin)
a43bd1d7 159cc="cc"
90cee0c3
MN
160v4l="no"
161audio_oss="no"
8aa3ee32 162dv1394="no"
d3b15036 163ffserver="no"
a43bd1d7 164SHFLAGS="-dynamiclib"
90cee0c3 165extralibs=""
a43bd1d7 166darwin="yes"
47930f09 167strip="strip -x"
6207ba95 168LDFLAGS="-d"
4baca069
PG
169FFSLDFLAGS=-Wl,-bind_at_load
170gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
171case "$gcc_version" in
172*2.95*)
173CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
174;;
175*)
176CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
177;;
178esac
90cee0c3 179;;
732d9245
BE
180MINGW32*)
181v4l="no"
182audio_oss="no"
8aa3ee32 183dv1394="no"
732d9245
BE
184ffserver="no"
185network="no"
186mingw32="yes"
187;;
3f027ca7
FB
188CYGWIN*)
189v4l="no"
190audio_oss="yes"
8aa3ee32 191dv1394="no"
3f027ca7
FB
192extralibs=""
193cygwin="yes"
194test -f /usr/include/inttypes.h || \
195test -f /usr/local/include/inttypes.h || \
196echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
197 "/usr/include/inttypes.h !!!"
198;;
b55e4ef4 199Linux)
4baca069 200LDFLAGS="$LDFLAGS -rdynamic"
b55e4ef4 201;;
f3ec2d46
SG
202OS/2)
203TMPE=$TMPE".exe"
69db4e10
SG
204ar="emxomfar -p64"
205ranlib="echo ignoring ranlib"
206strip="echo ignoring strip"
207CFLAGS="-Zomf -O3"
208LDFLAGS="-Zomf -Zstack 16384 -s"
f3ec2d46
SG
209SHFLAGS=""
210FFSLDFLAGS=""
211LIBPREF=""
212LIBSUF=".lib"
213SLIBPREF=""
214SLIBSUF=".dll"
215extralibs=""
216v4l="no"
217audio_oss="no"
8aa3ee32 218dv1394="no"
f3ec2d46
SG
219network="no"
220ffserver="no"
221os2="yes"
222;;
ef0bc4c9
FR
223*) ;;
224esac
de6d9b64 225
6852ac95
RD
226# From mplayer configure. We need TARGET_OS available
227# to the Makefile, so it can distinguish between flavors
228# of AltiVec on PowerPC
229TARGET_OS=`( uname -s ) 2>&1`
230 case "$TARGET_OS" in
231 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
232 ;;
233 IRIX*)
234 TARGET_OS=IRIX
235 ;;
236 HP-UX*)
237 TARGET_OS=HP-UX
238 ;;
239 [cC][yY][gG][wW][iI][nN]*)
240 TARGET_OS=CYGWIN
241 ;;
242 *)
243 TARGET_OS="$TARGET_OS-UNKNOWN"
244 ;;
245 esac
246
0f3cb305
FB
247# find source path
248# XXX: we assume an absolute path is given when launching configure,
249# except in './configure' case.
586bc755 250source_path="`echo $0 | sed -e 's#/configure##'`"
0f3cb305
FB
251source_path_used="yes"
252if test -z "$source_path" -o "$source_path" = "." ; then
253 source_path=`pwd`
254 source_path_used="no"
de6d9b64
FB
255fi
256
257for opt do
258 case "$opt" in
259 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
260 ;;
0f3cb305
FB
261 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
262 ;;
263 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
264 ;;
de6d9b64
FB
265 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
266 ;;
4a908fbc
AB
267 --make=*) make=`echo $opt | cut -d '=' -f 2`
268 ;;
0f3cb305
FB
269 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
270 ;;
271 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
272 ;;
273 --extra-libs=*) extralibs=${opt#--extra-libs=}
274 ;;
de6d9b64
FB
275 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
276 ;;
a4adb608
MN
277 --tune=*) tune=`echo $opt | cut -d '=' -f 2`
278 ;;
e45a2872
RD
279 --powerpc-perf-enable) powerpc_perf="yes"
280 ;;
de6d9b64
FB
281 --disable-mmx) mmx="no"
282 ;;
ab6c65f6
BF
283 --disable-altivec) altivec="no"
284 ;;
de6d9b64
FB
285 --enable-gprof) gprof="yes"
286 ;;
5cbcf02c
FB
287 --disable-v4l) v4l="no"
288 ;;
289 --disable-audio-oss) audio_oss="no"
290 ;;
dfdfa47c
FR
291 --disable-audio-beos) audio_beos="no"
292 ;;
8aa3ee32
MK
293 --disable-dv1394) dv1394="no"
294 ;;
5cbcf02c
FB
295 --disable-network) network="no"
296 ;;
0147f198
FR
297 --disable-zlib) zlib="no"
298 ;;
5cbcf02c 299 --disable-a52) a52="no"
6ed7422a 300 ;;
9c938e77 301 --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
57514323 302 ;;
bba9b16c
MN
303 --disable-pp) pp="no"
304 ;;
305 --enable-shared-pp) shared_pp="yes"
306 ;;
a6741398
J
307 --enable-mp3lame) mp3lame="yes"
308 ;;
81e0d0b4
MH
309 --enable-vorbis) vorbis="yes"
310 ;;
445ad18d
ZK
311 --enable-faad) faad="yes"
312 ;;
313 --enable-faadbin) faadbin="yes"
314 ;;
68892110
PG
315 --disable-vhook) vhook="no"
316 ;;
c02dbee1 317 --disable-simple_idct) simpleidct="no"
045ed63f 318 ;;
daf8e955
FB
319 --enable-win32) win32="yes"
320 ;;
732d9245
BE
321 --enable-mingw32) mingw32="yes"
322 ;;
83286d2a 323 --enable-shared) lshared="yes"
0319c531 324 ;;
1eb2212e
FB
325 --disable-mpegaudio-hp) mpegaudio_hp="no"
326 ;;
8154d2e0
FB
327 --disable-ffserver) ffserver="no"
328 ;;
a86b921c
FB
329 --disable-ffplay) ffplay="no"
330 ;;
1d0d55da
MN
331 --disable-risky) risky="no"
332 ;;
553a6284
MN
333 --enable-small) small="yes"
334 ;;
891f64b3 335 --enable-amr_nb) amr_nb="yes"
336 ;;
bc634f6f
ZK
337 --enable-amr_nb-fixed) amr_nb_fixed="yes"
338 ;;
de6d9b64
FB
339 esac
340done
341
0f3cb305
FB
342# compute mmx state
343if test $mmx = "default"; then
344 if test $cpu = "x86"; then
345 mmx="yes"
346 else
347 mmx="no"
348 fi
349fi
350
ab6c65f6
BF
351# Can only do AltiVec on PowerPC
352if test $altivec = "default"; then
353 if test $cpu = "powerpc"; then
354 altivec="yes"
355 else
356 altivec="no"
357 fi
358fi
359
a4adb608
MN
360# Add processor-specific flags
361TUNECPU="generic"
362if test $tune != "generic"; then
363 case $tune in
364 601|ppc601|PowerPC601)
365 CFLAGS="$CFLAGS -mcpu=601"
366 if test $altivec = "yes"; then
367 echo "WARNING: tuning for PPC601 but altivec enabled !";
368 fi
369 TUNECPU=ppc601
370 ;;
371 603*|ppc603*|PowerPC603*)
372 CFLAGS="$CFLAGS -mcpu=603"
373 if test $altivec = "yes"; then
374 echo "WARNING: tuning for PPC603 but altivec enabled !";
375 fi
376 TUNECPU=ppc603
377 ;;
378 604*|ppc604*|PowerPC604*)
379 CFLAGS="$CFLAGS -mcpu=604"
380 if test $altivec = "yes"; then
381 echo "WARNING: tuning for PPC604 but altivec enabled !";
382 fi
383 TUNECPU=ppc604
384 ;;
385 G3|75*|ppc75*|PowerPC75*)
3efd4952 386 CFLAGS="$CFLAGS -mcpu=750 -mtune=750"
a4adb608
MN
387 if test $altivec = "yes"; then
388 echo "WARNING: tuning for PPC75x but altivec enabled !";
389 fi
390 TUNECPU=ppc750
391 ;;
3efd4952
RD
392 G4|745*|ppc745*|PowerPC745*)
393 CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450"
394 if test $altivec = "no"; then
395 echo "WARNING: tuning for PPC745x but altivec disabled !";
396 fi
397 TUNECPU=ppc7450
398 ;;
399 74*|ppc74*|PowerPC74*)
400 CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400"
a4adb608
MN
401 if test $altivec = "no"; then
402 echo "WARNING: tuning for PPC74xx but altivec disabled !";
403 fi
e45a2872 404 TUNECPU=ppc7400
a4adb608
MN
405 ;;
406 G5|970|ppc970|PowerPC970|power4*|Power4*)
407 CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc64 -force_cpusubtype_ALL "
408 if test $altivec = "no"; then
409 echo "WARNING: tuning for PPC970 but altivec disabled !";
410 fi
411 TUNECPU=ppc970
412 ;;
413 *)
414 echo "WARNING: unknown CPU "$tune", ignored"
415 ;;
416 esac
417fi
418
a9a07762
MN
419# See if we have <altivec.h>
420cat > $TMPC << EOF
421#include <altivec.h>
422int main( void ) { return 0; }
423EOF
424
425_altivec_h="no"
426if $cc -o $TMPE $TMPC 2> /dev/null ; then
427_altivec_h="yes"
428fi
429
ab6c65f6
BF
430# See does our compiler support Motorola AltiVec C API
431if test $altivec = "yes"; then
a9a07762 432if test $_altivec_h = "yes"; then
ab6c65f6 433cat > $TMPC << EOF
a9a07762 434#include <altivec.h>
ab6c65f6
BF
435int main(void) {
436 vector signed int v1, v2, v3;
437 v1 = vec_add(v2,v3);
438 return 0;
439}
440EOF
a9a07762
MN
441else
442cat > $TMPC << EOF
443int main(void) {
444 vector signed int v1, v2, v3;
445 v1 = vec_add(v2,v3);
446 return 0;
447}
448EOF
449fi
450if test "$darwin" = "yes"; then
f3ec2d46 451$cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
a9a07762
MN
452else
453$cc -o $TMPE $TMPC -maltivec -mabi=altivec 2> /dev/null || altivec="no"
454fi
ab6c65f6
BF
455fi
456
d46aba26
LS
457# Can only do mmi on mips
458if test $mmi = "default"; then
459 if test $cpu = "mips"; then
460 mmi="yes"
461 else
462 mmi="no"
463 fi
464fi
465
466# See does our compiler support mmi
467if test $mmi = "yes"; then
468cat > $TMPC << EOF
469int main(void) {
470 __asm__ ("lq \$2, 0(\$2)");
471 return 0;
472}
473EOF
f3ec2d46 474$cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
d46aba26
LS
475fi
476
daf8e955
FB
477# Checking for CFLAGS
478if test -z "$CFLAGS"; then
29482cb4 479 CFLAGS="-O3"
daf8e955
FB
480fi
481
57514323 482if test "$win32" = "yes" ; then
daf8e955 483 cross_prefix="i386-mingw32msvc-"
5cbcf02c
FB
484 v4l="no"
485 audio_oss="no"
8aa3ee32 486 dv1394="no"
5cbcf02c 487 network="no"
daf8e955
FB
488fi
489
732d9245
BE
490if test "$mingw32" = "yes" ; then
491 cross_prefix=""
492 v4l="no"
493 audio_oss="no"
8aa3ee32 494 dv1394="no"
732d9245
BE
495 network="no"
496fi
497
0f3cb305
FB
498cc="${cross_prefix}${cc}"
499ar="${cross_prefix}${ar}"
be7109c1 500ranlib="${cross_prefix}${ranlib}"
0f3cb305
FB
501strip="${cross_prefix}${strip}"
502
487a54d7
FB
503if test -z "$cross_prefix" ; then
504
3d204385 505# ---
a3999908
MN
506# big/little endian test
507cat > $TMPC << EOF
508#include <inttypes.h>
509int main(int argc, char ** argv){
510 volatile uint32_t i=0x01234567;
511 return (*((uint8_t*)(&i))) == 0x67;
512}
513EOF
514
f3ec2d46
SG
515if $cc -o $TMPE $TMPC 2>/dev/null ; then
516$TMPE && bigendian="yes"
a3999908
MN
517else
518echo big/little test failed
519fi
520
487a54d7
FB
521else
522
523# if cross compiling, cannot launch a program, so make a static guess
524if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
525 bigendian="yes"
526fi
527
528fi
529
a3999908 530# ---
3d204385
NK
531# check availability of some header files
532
533cat > $TMPC << EOF
534#include <malloc.h>
535int main( void ) { return 0; }
536EOF
537
538_memalign=no
539_malloc_h=no
f3ec2d46 540if $cc -o $TMPE $TMPC 2> /dev/null ; then
3d204385
NK
541_malloc_h=yes
542_memalign=yes
543# check for memalign - atmos
544cat > $TMPC << EOF
545#include <malloc.h>
546int main ( void ) {
547char *string = NULL;
548string = memalign(64, sizeof(char));
549return 0;
550}
551EOF
f3ec2d46 552$cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
3d204385
NK
553fi
554
68892110
PG
555cat > $TMPC << EOF
556#define _GNU_SOURCE
557#include <time.h>
558int main( void ) { return *strptime("", "", 0); }
559EOF
560
561strptime=no
f3ec2d46 562if $cc -o $TMPE $TMPC 2> /dev/null ; then
68892110
PG
563 strptime=yes
564fi
565
0147f198
FR
566if test "$zlib" = "yes"; then
567# check for zlib - mmu_man
568cat > $TMPC << EOF
569#include <zlib.h>
570int main ( void ) {
571if (zlibVersion() != ZLIB_VERSION)
572 puts("zlib version differs !!!");
573 return 1;
574return 0;
575}
576EOF
f3ec2d46
SG
577$cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
578# $TMPE 2> /dev/null > /dev/null || zlib="no"
0147f198
FR
579# XXX: more tests needed - runtime test
580fi
581if test "$zlib" = "yes"; then
582extralibs="$extralibs -lz"
583fi
584
95e2ce4a
MN
585# test for lrintf in math.h
586cat > $TMPC << EOF
587#define _ISOC9X_SOURCE 1
588#include <math.h>
589int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
590EOF
591
592have_lrintf="no"
f3ec2d46 593if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
95e2ce4a 594 have_lrintf="yes"
f3ec2d46 595 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
95e2ce4a
MN
596fi
597
c13e1abd
FH
598_restrict=
599for restrict_keyword in restrict __restrict__ __restrict; do
600 echo "void foo(char * $restrict_keyword p);" > $TMPC
601 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
602 _restrict=$restrict_keyword
603 break;
604 fi
605done
606
52b41d7f
FB
607# test gcc version to see if vector builtins can be used
608# currently only used on i386 for MMX builtins
609cat > $TMPC << EOF
610int main(void) {
611#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
612return 0;
613#else
614#error no vector builtins
615#endif
616}
617EOF
618
619builtin_vector=no
620if $cc -o $TMPO $TMPC 2> /dev/null ; then
621 builtin_vector=yes
a8721c09
FB
622fi
623
624# dlopen/dlfcn.h probing
625
626cat > $TMPC << EOF
627#include <dlfcn.h>
628int main( void ) { return (int) dlopen("foo", 0); }
629EOF
630
631ldl=-ldl
632
633if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
634dlfcn=yes
635dlopen=yes
636fi
637
638if $cc -o $TMPE $TMPC 2> /dev/null ; then
639dlfcn=yes
640dlopen=yes
641ldl=""
642fi
643
644cat > $TMPC << EOF
645int main( void ) { return (int) dlopen("foo", 0); }
646EOF
647
648if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
649dlopen=yes
650fi
651
652if $cc -o $TMPE $TMPC 2> /dev/null ; then
653dlopen=yes
654ldl=""
655fi
656
657if test "$vhook" = "default" ; then
658 vhook="$dlopen"
659fi
660
a86b921c
FB
661##########################################
662# imlib probe
663
a8721c09
FB
664cat > $TMPC << EOF
665#include <X11/Xlib.h>
666#include <Imlib2.h>
667int main( void ) { return (int) imlib_load_font("foo"); }
668EOF
669
670imlib2=no
671if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
672imlib2=yes
52b41d7f
FB
673fi
674
a86b921c
FB
675##########################################
676# freetype probe
677
04511d53
PG
678cat > $TMPC << EOF
679#include <ft2build.h>
680int main( void ) { return (int) FT_Init_FreeType(0); }
681EOF
682
683freetype2=no
69db4e10 684if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
6e023978 685 if test "`which freetype-config`" != ""; then
04511d53 686 if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then
dee076fc 687 freetype2=yes
04511d53 688 fi
dee076fc 689 fi
04511d53
PG
690fi
691
a86b921c
FB
692##########################################
693# SDL probe
694
695cat > $TMPC << EOF
696#include <SDL.h>
31319a8c 697#undef main /* We don't want SDL to override our main() */
a86b921c
FB
698int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
699EOF
700
701sdl_too_old=no
702sdl=no
703if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs` 2> /dev/null ; then
704_sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
705if test "$_sdlversion" -lt 121 ; then
706sdl_too_old=yes
707else
708sdl=yes
709fi
710fi
711
94a3401e
FB
712if test "$sdl" = "no" ; then
713 ffplay=no
714fi
715
c9f97d82 716if test "$small" = "yes"; then
98ca7790 717# CFLAGS=${CFLAGS//-O3/-Os}
553a6284
MN
718 CFLAGS="$CFLAGS -Os"
719fi
720
6063bce7 721if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
0f3cb305
FB
722cat << EOF
723
724Usage: configure [options]
725Options: [defaults in brackets after descriptions]
726
727EOF
728echo "Standard options:"
729echo " --help print this message"
730echo " --prefix=PREFIX install in PREFIX [$prefix]"
0f3cb305 731echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
81e0d0b4 732echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
0fc50e58
ZK
733echo " --enable-faad enable faad support via libfaad [default=no]"
734echo " --enable-faadbin build faad support with runtime linking [default=no]"
0f3cb305 735echo " --enable-win32 enable win32 cross compile"
732d9245 736echo " --enable-mingw32 enable mingw32 native windows compile"
5cbcf02c 737echo " --disable-a52 disable GPL'ed A52 support [default=no]"
0f3cb305 738echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
bba9b16c
MN
739echo " --disable-pp disable GPL'ed post processing support [default=no]"
740echo " --enable-shared-pp use libpostproc.so [default=no]"
0f3cb305 741echo " --enable-shared build shared libraries [default=no]"
bc634f6f
ZK
742echo " --enable-amr_nb enable amr_nb float audio codec"
743echo " --enable-amr_nb-fixed use fixed point for amr-nb codec"
0f3cb305
FB
744echo ""
745echo "Advanced options (experts only):"
746echo " --source-path=PATH path of source code [$source_path]"
747echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
748echo " --cc=CC use C compiler CC [$cc]"
4a908fbc 749echo " --make=MAKE use specified make [$make]"
0f3cb305
FB
750echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
751echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
752echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
753echo " --cpu=CPU force cpu to CPU [$cpu]"
a4adb608 754echo " --tune=PROCESSOR tune code for a particular CPU (may fails or misperforms on other CPUs)"
e45a2872 755echo " --powerpc-perf-enable enable performance report on PPC (requires enabling PMC)"
0f3cb305 756echo " --disable-mmx disable mmx usage"
ab6c65f6 757echo " --disable-altivec disable AltiVec usage"
5cbcf02c 758echo " --disable-audio-oss disable OSS audio support [default=no]"
dfdfa47c 759echo " --disable-audio-beos disable BeOS audio support [default=no]"
6063bce7 760echo " --disable-v4l disable video4linux grabbing [default=no]"
8aa3ee32 761echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
5cbcf02c 762echo " --disable-network disable network support [default=no]"
0147f198 763echo " --disable-zlib disable zlib [default=no]"
5cbcf02c 764echo " --disable-simple_idct disable simple IDCT routines [default=no]"
47930f09 765echo " --disable-vhook disable video hooking support"
0f3cb305 766echo " --enable-gprof enable profiling with gprof [$gprof]"
1eb2212e
FB
767echo " --disable-mpegaudio-hp faster (but less accurate)"
768echo " mpegaudio decoding [default=no]"
8154d2e0 769echo " --disable-ffserver disable ffserver build"
a86b921c 770echo " --disable-ffplay disable ffplay build"
1d0d55da 771echo " --disable-risky disables patent encumbered codecs"
553a6284 772echo " --enable-small optimize for size instead of speed"
0f3cb305
FB
773echo ""
774echo "NOTE: The object files are build at the place where configure is launched"
775exit 1
776fi
777
de6d9b64 778echo "Install prefix $prefix"
0f3cb305 779echo "Source path $source_path"
de6d9b64 780echo "C compiler $cc"
4a908fbc 781echo "make $make"
a4adb608 782echo "CPU $cpu ($tune)"
0f3cb305 783echo "Big Endian $bigendian"
e41e8342 784if test $cpu = "x86"; then
de6d9b64 785echo "MMX enabled $mmx"
52b41d7f 786echo "Vector Builtins $builtin_vector"
e41e8342
FB
787fi
788if test $cpu = "mips"; then
d46aba26 789echo "MMI enabled $mmi"
e41e8342
FB
790fi
791if test $cpu = "powerpc"; then
ab6c65f6 792echo "AltiVec enabled $altivec"
e41e8342 793fi
de6d9b64 794echo "gprof enabled $gprof"
0147f198 795echo "zlib enabled $zlib"
a6741398 796echo "mp3lame enabled $mp3lame"
81e0d0b4 797echo "vorbis enabled $vorbis"
445ad18d
ZK
798echo "faad enabled $faad"
799echo "faadbin enabled $faadbin"
5cbcf02c 800echo "a52 support $a52"
57514323 801echo "a52 dlopened $a52bin"
bba9b16c
MN
802echo "pp support $pp"
803echo "shared pp $shared_pp"
47930f09 804echo "Video hooking $vhook"
a86b921c
FB
805echo "SDL support $sdl"
806if test $sdl_too_old = "yes"; then
807echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
808fi
1d0d55da 809echo "risky / patent encumbered codecs $risky"
553a6284 810echo "optimize for size $small"
68892110
PG
811
812if test "$vhook" = "yes" ; then
47930f09 813echo "Imlib2 support $imlib2"
04511d53 814echo "freetype support $freetype2"
68892110 815fi
bc634f6f
ZK
816echo "AMR-NB float support" $amr_nb
817echo "AMR-NB fixed support" $amr_nb_fixed
de6d9b64 818
980fc7b8 819echo "Creating config.mak and config.h"
de6d9b64 820
980fc7b8 821echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 822echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 823
980fc7b8 824echo "prefix=$prefix" >> config.mak
4a908fbc 825echo "MAKE=$make" >> config.mak
980fc7b8
FB
826echo "CC=$cc" >> config.mak
827echo "AR=$ar" >> config.mak
be7109c1 828echo "RANLIB=$ranlib" >> config.mak
0f3cb305 829echo "STRIP=$strip" >> config.mak
a9b3f630 830echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 831echo "LDFLAGS=$LDFLAGS" >> config.mak
4baca069 832echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
e1707f52 833echo "SHFLAGS=$SHFLAGS" >> config.mak
f3ec2d46
SG
834echo "LIBPREF=$LIBPREF" >> config.mak
835echo "LIBSUF=$LIBSUF" >> config.mak
836echo "SLIBPREF=$SLIBPREF" >> config.mak
837echo "SLIBSUF=$SLIBSUF" >> config.mak
6852ac95 838echo "TARGET_OS=$TARGET_OS" >> config.mak
57514323 839if test "$cpu" = "x86" ; then
980fc7b8 840 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 841 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 842elif test "$cpu" = "armv4l" ; then
6ed7422a 843 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 844 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 845elif test "$cpu" = "alpha" ; then
91d1f1a4 846 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 847 echo "#define ARCH_ALPHA 1" >> $TMPH
35fedfc3
PG
848elif test "$cpu" = "sparc64" ; then
849 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
850 echo "#define ARCH_SPARC64 1" >> $TMPH
0f3cb305
FB
851elif test "$cpu" = "powerpc" ; then
852 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
853 echo "#define ARCH_POWERPC 1" >> $TMPH
e45a2872
RD
854 if test "$powerpc_perf" = "yes"; then
855 echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
856 fi
d46aba26
LS
857elif test "$cpu" = "mips" ; then
858 echo "TARGET_ARCH_MIPS=yes" >> config.mak
859 echo "#define ARCH_MIPS 1" >> $TMPH
0f3cb305 860fi
a4adb608 861echo "#define TUNECPU $TUNECPU" >> $TMPH
0f3cb305
FB
862if test "$bigendian" = "yes" ; then
863 echo "WORDS_BIGENDIAN=yes" >> config.mak
864 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 865fi
57514323 866if test "$mmx" = "yes" ; then
980fc7b8 867 echo "TARGET_MMX=yes" >> config.mak
045ed63f 868 echo "#define HAVE_MMX 1" >> $TMPH
e82c5a8c 869 echo "#define __CPU__ 586" >> $TMPH
de6d9b64 870fi
52b41d7f
FB
871if test "$builtin_vector" = "yes" ; then
872 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
873 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
874fi
d46aba26
LS
875if test "$mmi" = "yes" ; then
876 echo "TARGET_MMI=yes" >> config.mak
877 echo "#define HAVE_MMI 1" >> $TMPH
878fi
ab6c65f6
BF
879if test "$altivec" = "yes" ; then
880 echo "TARGET_ALTIVEC=yes" >> config.mak
881 echo "#define HAVE_ALTIVEC 1" >> $TMPH
db40a39a
MN
882 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
883 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
a9a07762
MN
884 if test "$_altivec_h" = "yes" ; then
885 echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
886 else
e67e14d5 887 echo "#undef HAVE_ALTIVEC_H" >> $TMPH
a9a07762 888 fi
ab6c65f6 889fi
57514323 890if test "$gprof" = "yes" ; then
980fc7b8 891 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 892 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 893fi
68892110
PG
894if test "$strptime" = "yes" ; then
895 echo "#define HAVE_STRPTIME 1" >> $TMPH
896else
897 echo "BUILD_STRPTIME=yes" >> config.mak
898fi
899if test "$imlib2" = "yes" ; then
900 echo "HAVE_IMLIB2=yes" >> config.mak
901fi
04511d53
PG
902if test "$freetype2" = "yes" ; then
903 echo "HAVE_FREETYPE2=yes" >> config.mak
904fi
a86b921c
FB
905if test "$sdl" = "yes" ; then
906 echo "CONFIG_SDL=yes" >> config.mak
907 echo "SDL_LIBS=`sdl-config --libs`" >> config.mak
908 echo "SDL_CFLAGS=`sdl-config --cflags`" >> config.mak
909fi
95e2ce4a
MN
910if test "$have_lrintf" = "yes" ; then
911 echo "#define HAVE_LRINTF 1" >> $TMPH
912fi
68892110
PG
913if test "$vhook" = "yes" ; then
914 echo "BUILD_VHOOK=yes" >> config.mak
915 echo "#define HAVE_VHOOK 1" >> $TMPH
9c938e77 916 extralibs="$extralibs $ldl"
68892110 917fi
57514323 918if test "$lshared" = "yes" ; then
0319c531 919 echo "BUILD_SHARED=yes" >> config.mak
5cbcf02c 920 echo "PIC=-fPIC" >> config.mak
0319c531 921fi
ef0bc4c9 922echo "EXTRALIBS=$extralibs" >> config.mak
586bc755 923echo "VERSION=`head $source_path/VERSION`" >>config.mak
0319c531 924echo "" >>config.mak
d771bcae 925# if you do not want to use encoders, disable that.
045ed63f 926echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
927echo "CONFIG_ENCODERS=yes" >> config.mak
928
929# if you do not want to use decoders, disable that.
045ed63f 930echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
931echo "CONFIG_DECODERS=yes" >> config.mak
932
5cbcf02c
FB
933# AC3
934if test "$a52" = "yes" ; then
935 echo "#define CONFIG_AC3 1" >> $TMPH
936 echo "CONFIG_AC3=yes" >> config.mak
d771bcae 937
5cbcf02c
FB
938 if test "$a52bin" = "yes" ; then
939 echo "#define CONFIG_A52BIN 1" >> $TMPH
940 echo "CONFIG_A52BIN=yes" >> config.mak
941 fi
942fi
943
bba9b16c
MN
944# PP
945if test "$pp" = "yes" ; then
946 echo "#define CONFIG_PP 1" >> $TMPH
947 echo "CONFIG_PP=yes" >> config.mak
948
949 if test "$shared_pp" = "yes" ; then
950 echo "#define SHARED_PP 1" >> $TMPH
951 echo "SHARED_PP=yes" >> config.mak
952 fi
953fi
954
1eb2212e
FB
955# mpeg audio high precision mode
956if test "$mpegaudio_hp" = "yes" ; then
957 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
958fi
959
5cbcf02c
FB
960if test "$v4l" = "yes" ; then
961 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
962 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
963fi
964
8aa3ee32
MK
965if test "$dv1394" = "yes" ; then
966 echo "#define CONFIG_DV1394 1" >> $TMPH
967 echo "CONFIG_DV1394=yes" >> config.mak
968fi
969
adbc0510
PG
970if test "$dlopen" = "yes" ; then
971 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
972fi
973
974if test "$dlfcn" = "yes" ; then
975 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
976fi
977
5cbcf02c
FB
978if test "$audio_oss" = "yes" ; then
979 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
980 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
57514323
ZK
981fi
982
dfdfa47c
FR
983if test "$audio_beos" = "yes" ; then
984 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
985 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
986fi
987
5cbcf02c
FB
988if test "$network" = "yes" ; then
989 echo "#define CONFIG_NETWORK 1" >> $TMPH
990 echo "CONFIG_NETWORK=yes" >> config.mak
6ed7422a 991fi
daf8e955 992
0147f198
FR
993if test "$zlib" = "yes" ; then
994 echo "#define CONFIG_ZLIB 1" >> $TMPH
995 echo "CONFIG_ZLIB=yes" >> config.mak
996fi
997
57514323 998if test "$mp3lame" = "yes" ; then
045ed63f 999 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
1000 echo "CONFIG_MP3LAME=yes" >> config.mak
1001fi
1002
81e0d0b4
MH
1003if test "$vorbis" = "yes" ; then
1004 echo "#define CONFIG_VORBIS 1" >> $TMPH
1005 echo "CONFIG_VORBIS=yes" >> config.mak
1006fi
1007
0fc50e58
ZK
1008if test "$faad" = "yes" ; then
1009 echo "#define CONFIG_FAAD 1" >> $TMPH
1010 echo "CONFIG_FAAD=yes" >> config.mak
1011fi
1012
1013if test "$faadbin" = "yes" ; then
1014 echo "#define CONFIG_FAADBIN 1" >> $TMPH
445ad18d 1015 echo "CONFIG_FAADBIN=yes" >> config.mak
0fc50e58
ZK
1016fi
1017
57514323 1018if test "$win32" = "yes" ; then
045ed63f 1019 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
1020 echo "CONFIG_WIN32=yes" >> config.mak
1021fi
3d204385 1022
732d9245
BE
1023if test "$mingw32" = "yes" ; then
1024 echo "#define CONFIG_WIN32 1" >> $TMPH
1025 echo "CONFIG_WIN32=yes" >> config.mak
1026 echo "#define __MINGW32__ 1" >> $TMPH
1027 echo "__MINGW32__=1" >> config.mak
1028fi
1029
3f027ca7
FB
1030if test "$cygwin" = "yes" ; then
1031 # setup correct exesuffix
1032 echo "CONFIG_WIN32=yes" >> config.mak
1033fi
1034
f3ec2d46
SG
1035if test "$os2" = "yes" ; then
1036 echo "#define CONFIG_OS2 1" >> $TMPH
1037 echo "CONFIG_OS2=yes" >> config.mak
1038fi
1039
6e023978
RS
1040if test "$TARGET_OS" = "SunOS" ; then
1041 echo "#define CONFIG_SUNOS 1" >> $TMPH
1042fi
1043
90cee0c3
MN
1044if test "$darwin" = "yes"; then
1045 echo "#define CONFIG_DARWIN 1" >> $TMPH
1046 echo "CONFIG_DARWIN=yes" >> config.mak
1047fi
1048
57514323 1049if test "$_malloc_h" = "yes" ; then
045ed63f 1050 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 1051else
045ed63f 1052 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
1053fi
1054
57514323 1055if test "$_memalign" = "yes" ; then
045ed63f
ZK
1056 echo "#define HAVE_MEMALIGN 1" >> $TMPH
1057else
1058 echo "#undef HAVE_MEMALIGN" >> $TMPH
1059fi
1060
26b35efb
FR
1061if test "$netserver" = "yes" ; then
1062 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
1063 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
1064fi
1065
4baca069
PG
1066if test "$need_inet_aton" = "yes" ; then
1067 echo "NEED_INET_ATON=yes" >> config.mak
1068fi
1069
57514323 1070if test "$simpleidct" = "yes" ; then
045ed63f
ZK
1071 echo "#define SIMPLE_IDCT 1" >> $TMPH
1072fi
1073
8154d2e0
FB
1074if test "$ffserver" = "yes" ; then
1075 echo "#define CONFIG_FFSERVER 1" >> $TMPH
1076 echo "CONFIG_FFSERVER=yes" >> config.mak
1077fi
1078
a86b921c
FB
1079if test "$ffplay" = "yes" ; then
1080 echo "CONFIG_FFPLAY=yes" >> config.mak
1081fi
1082
1d0d55da
MN
1083if test "$risky" = "yes" ; then
1084 echo "#define CONFIG_RISKY 1" >> $TMPH
1085 echo "CONFIG_RISKY=yes" >> config.mak
1086fi
1087
c13e1abd
FH
1088echo "#define restrict $_restrict" >> $TMPH
1089
0f3cb305
FB
1090# build tree in object directory if source path is different from current one
1091if test "$source_path_used" = "yes" ; then
a382b927 1092 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
5f6b58de
MR
1093 libavcodec/ppc libavcodec/liba52 libavcodec/mlib libavcodec/libpostproc tests vhook"
1094 FILES="Makefile libavformat/Makefile libavcodec/Makefile libavcodec/libpostproc/Makefile tests/Makefile vhook/Makefile"
0f3cb305
FB
1095 for dir in $DIRS ; do
1096 mkdir -p $dir
1097 done
1098 for f in $FILES ; do
1099 ln -sf $source_path/$f $f
1100 done
1101fi
1102echo "SRC_PATH=$source_path" >> config.mak
1103
891f64b3 1104if test "$amr_nb" = "yes" ; then
1105 echo "#define AMR_NB 1" >> $TMPH
1106 echo "AMR_NB=yes" >> config.mak
1107 echo
bc634f6f
ZK
1108if test "$amr_nb_fixed" = "yes" ; then
1109 echo "AMR_NB_FIXED=yes" >> config.mak
1110 echo "#define AMR_NB_FIXED 1" >> $TMPH
1111 echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
1112 echo "REL-5 version 5.1.0 from "
891f64b3 1113 echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-510.zip"
1114 echo "and extracted src to libavcodec/amr"
bc634f6f
ZK
1115 echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
1116 echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
1117 echo
1118else
1119 echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
1120 echo "REL-5 V5.1.0 from "
1121 echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-510.zip"
1122 echo "and extracted the source to libavcodec/amr_float"
891f64b3 1123 echo
1124fi
1125
bc634f6f
ZK
1126fi
1127
a7c02e25 1128diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
1129if test $? -ne 0 ; then
1130 mv -f $TMPH config.h
3d204385 1131else
045ed63f 1132 echo "config.h is unchanged"
3d204385
NK
1133fi
1134
f3ec2d46 1135rm -f $TMPO $TMPC $TMPE $TMPS $TMPH