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