3 # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
8 elif test ! -z "$TEMPDIR" ; then
14 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
33 i386|i486|i586|i686|i86pc|BePC)
42 "Power Macintosh"|ppc)
79 LDFLAGS=-Wl,--warn-common
91 prefix="/boot/home/config"
92 # helps building libavcodec
93 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
94 # 3 gcc releases known for BeOS, each with ugly bugs
95 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
96 case "$gcc_version" in
97 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
100 *20010315*) echo "BeBits gcc"
101 CFLAGS="$CFLAGS -fno-expensive-optimizations"
105 # disable linux things
111 # no need for libm, but the inet stuff
113 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
114 extralibs="-lbind -lsocket"
128 extralibs="$extralibs -lsocket -lnsl"
135 LDFLAGS="$LDFLAGS -export-dynamic"
141 extralibs="-lpoll -lgnugetopt -lm"
149 SHFLAGS="-dynamiclib"
154 FFSLDFLAGS=-Wl,-bind_at_load
155 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
156 case "$gcc_version" in
158 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
161 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
179 test -f /usr/include/inttypes.h || \
180 test -f /usr/local/include/inttypes.h || \
181 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
182 "/usr/include/inttypes.h !!!"
185 LDFLAGS="$LDFLAGS -rdynamic"
190 strip="echo ignore strip"
192 LDFLAGS="-Zomf -Zstack 16384"
210 # From mplayer configure. We need TARGET_OS available
211 # to the Makefile, so it can distinguish between flavors
212 # of AltiVec on PowerPC
213 TARGET_OS=`( uname -s ) 2>&1`
215 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
223 [cC][yY][gG][wW][iI][nN]*)
227 TARGET_OS="$TARGET_OS-UNKNOWN"
232 # XXX: we assume an absolute path is given when launching configure,
233 # except in './configure' case.
234 source_path=${0%configure}
235 source_path=${source_path%/}
236 source_path_used="yes"
237 if test -z "$source_path" -o "$source_path" = "." ; then
239 source_path_used="no"
244 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
246 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
248 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
250 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
252 --make=*) make=`echo $opt | cut -d '=' -f 2`
254 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
256 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
258 --extra-libs=*) extralibs=${opt#--extra-libs=}
260 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
262 --disable-mmx) mmx="no"
264 --disable-altivec) altivec="no"
266 --enable-gprof) gprof="yes"
268 --disable-v4l) v4l="no"
270 --disable-audio-oss) audio_oss="no"
272 --disable-audio-beos) audio_beos="no"
274 --disable-dv1394) dv1394="no"
276 --disable-network) network="no"
278 --disable-zlib) zlib="no"
280 --disable-a52) a52="no"
282 --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
284 --enable-mp3lame) mp3lame="yes"
286 --enable-vorbis) vorbis="yes"
288 --disable-vhook) vhook="no"
290 --disable-simple_idct) simpleidct="no"
292 --enable-win32) win32="yes"
294 --enable-mingw32) mingw32="yes"
296 --enable-shared) lshared="yes"
298 --disable-mpegaudio-hp) mpegaudio_hp="no"
300 --disable-ffserver) ffserver="no"
302 --disable-risky) risky="no"
308 if test $mmx = "default"; then
309 if test $cpu = "x86"; then
316 # Can only do AltiVec on PowerPC
317 if test $altivec = "default"; then
318 if test $cpu = "powerpc"; then
325 # See does our compiler support Motorola AltiVec C API
326 if test $altivec = "yes"; then
329 vector signed int v1, v2, v3;
334 $cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
337 # Can only do mmi on mips
338 if test $mmi = "default"; then
339 if test $cpu = "mips"; then
346 # See does our compiler support mmi
347 if test $mmi = "yes"; then
350 __asm__ ("lq \$2, 0(\$2)");
354 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
357 # Checking for CFLAGS
358 if test -z "$CFLAGS"; then
362 if test "$win32" = "yes" ; then
363 cross_prefix="i386-mingw32msvc-"
370 if test "$mingw32" = "yes" ; then
378 cc="${cross_prefix}${cc}"
379 ar="${cross_prefix}${ar}"
380 ranlib="${cross_prefix}${ranlib}"
381 strip="${cross_prefix}${strip}"
383 if test -z "$cross_prefix" ; then
386 # big/little endian test
388 #include <inttypes.h>
389 int main(int argc, char ** argv){
390 volatile uint32_t i=0x01234567;
391 return (*((uint8_t*)(&i))) == 0x67;
395 if $cc -o $TMPE $TMPC 2>/dev/null ; then
396 $TMPE && bigendian="yes"
398 echo big/little test failed
403 # if cross compiling, cannot launch a program, so make a static guess
404 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
411 # check availability of some header files
415 int main( void ) { return 0; }
420 if $cc -o $TMPE $TMPC 2> /dev/null ; then
423 # check for memalign - atmos
428 string = memalign(64, sizeof(char));
432 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
438 int main( void ) { return *strptime("", "", 0); }
442 if $cc -o $TMPE $TMPC 2> /dev/null ; then
446 if test "$zlib" = "yes"; then
447 # check for zlib - mmu_man
451 if (zlibVersion() != ZLIB_VERSION)
452 puts("zlib version differs !!!");
457 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
458 # $TMPE 2> /dev/null > /dev/null || zlib="no"
459 # XXX: more tests needed - runtime test
461 if test "$zlib" = "yes"; then
462 extralibs="$extralibs -lz"
465 # test for lrintf in math.h
467 #define _ISOC9X_SOURCE 1
469 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
473 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
475 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
479 for restrict_keyword in restrict __restrict__ __restrict; do
480 echo "void foo(char * $restrict_keyword p);" > $TMPC
481 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
482 _restrict=$restrict_keyword
487 # test gcc version to see if vector builtins can be used
488 # currently only used on i386 for MMX builtins
491 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
494 #error no vector builtins
500 if $cc -o $TMPO $TMPC 2> /dev/null ; then
504 # dlopen/dlfcn.h probing
508 int main( void ) { return (int) dlopen("foo", 0); }
513 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
518 if $cc -o $TMPE $TMPC 2> /dev/null ; then
525 int main( void ) { return (int) dlopen("foo", 0); }
528 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
532 if $cc -o $TMPE $TMPC 2> /dev/null ; then
537 if test "$vhook" = "default" ; then
542 #include <X11/Xlib.h>
544 int main( void ) { return (int) imlib_load_font("foo"); }
548 if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
552 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
555 Usage: configure [options]
556 Options: [defaults in brackets after descriptions]
559 echo "Standard options:"
560 echo " --help print this message"
561 echo " --prefix=PREFIX install in PREFIX [$prefix]"
562 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
563 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
564 echo " --enable-win32 enable win32 cross compile"
565 echo " --enable-mingw32 enable mingw32 native windows compile"
566 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
567 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
568 echo " --enable-shared build shared libraries [default=no]"
570 echo "Advanced options (experts only):"
571 echo " --source-path=PATH path of source code [$source_path]"
572 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
573 echo " --cc=CC use C compiler CC [$cc]"
574 echo " --make=MAKE use specified make [$make]"
575 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
576 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
577 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
578 echo " --cpu=CPU force cpu to CPU [$cpu]"
579 echo " --disable-mmx disable mmx usage"
580 echo " --disable-altivec disable AltiVec usage"
581 echo " --disable-audio-oss disable OSS audio support [default=no]"
582 echo " --disable-audio-beos disable BeOS audio support [default=no]"
583 echo " --disable-v4l disable video4linux grabbing [default=no]"
584 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
585 echo " --disable-network disable network support [default=no]"
586 echo " --disable-zlib disable zlib [default=no]"
587 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
588 echo " --disable-vhook disable video hooking support"
589 echo " --enable-gprof enable profiling with gprof [$gprof]"
590 echo " --disable-mpegaudio-hp faster (but less accurate)"
591 echo " mpegaudio decoding [default=no]"
592 echo " --disable-ffserver disable ffserver build"
593 echo " --disable-risky disables patent encumbered codecs"
595 echo "NOTE: The object files are build at the place where configure is launched"
599 echo "Install prefix $prefix"
600 echo "Source path $source_path"
601 echo "C compiler $cc"
604 echo "Big Endian $bigendian"
605 if test $cpu = "x86"; then
606 echo "MMX enabled $mmx"
607 echo "Vector Builtins $builtin_vector"
609 if test $cpu = "mips"; then
610 echo "MMI enabled $mmi"
612 if test $cpu = "powerpc"; then
613 echo "AltiVec enabled $altivec"
615 echo "gprof enabled $gprof"
616 echo "zlib enabled $zlib"
617 echo "mp3lame enabled $mp3lame"
618 echo "vorbis enabled $vorbis"
619 echo "a52 support $a52"
620 echo "a52 dlopened $a52bin"
621 echo "Video hooking $vhook"
622 echo "risky / patent encumbered codecs $risky"
624 if test "$vhook" = "yes" ; then
625 echo "Imlib2 support $imlib2"
628 echo "Creating config.mak and config.h"
630 echo "# Automatically generated by configure - do not modify" > config.mak
631 echo "/* Automatically generated by configure - do not modify */" > $TMPH
633 echo "prefix=$prefix" >> config.mak
634 echo "MAKE=$make" >> config.mak
635 echo "CC=$cc" >> config.mak
636 echo "AR=$ar" >> config.mak
637 echo "RANLIB=$ranlib" >> config.mak
638 echo "STRIP=$strip" >> config.mak
639 echo "OPTFLAGS=$CFLAGS" >> config.mak
640 echo "LDFLAGS=$LDFLAGS" >> config.mak
641 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
642 echo "SHFLAGS=$SHFLAGS" >> config.mak
643 echo "LIBPREF=$LIBPREF" >> config.mak
644 echo "LIBSUF=$LIBSUF" >> config.mak
645 echo "SLIBPREF=$SLIBPREF" >> config.mak
646 echo "SLIBSUF=$SLIBSUF" >> config.mak
647 echo "TARGET_OS=$TARGET_OS" >> config.mak
648 if test "$cpu" = "x86" ; then
649 echo "TARGET_ARCH_X86=yes" >> config.mak
650 echo "#define ARCH_X86 1" >> $TMPH
651 elif test "$cpu" = "armv4l" ; then
652 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
653 echo "#define ARCH_ARMV4L 1" >> $TMPH
654 elif test "$cpu" = "alpha" ; then
655 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
656 echo "#define ARCH_ALPHA 1" >> $TMPH
657 elif test "$cpu" = "sparc64" ; then
658 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
659 echo "#define ARCH_SPARC64 1" >> $TMPH
660 elif test "$cpu" = "powerpc" ; then
661 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
662 echo "#define ARCH_POWERPC 1" >> $TMPH
663 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
664 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
665 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
666 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
667 elif test "$cpu" = "mips" ; then
668 echo "TARGET_ARCH_MIPS=yes" >> config.mak
669 echo "#define ARCH_MIPS 1" >> $TMPH
671 if test "$bigendian" = "yes" ; then
672 echo "WORDS_BIGENDIAN=yes" >> config.mak
673 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
675 if test "$mmx" = "yes" ; then
676 echo "TARGET_MMX=yes" >> config.mak
677 echo "#define HAVE_MMX 1" >> $TMPH
679 if test "$builtin_vector" = "yes" ; then
680 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
681 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
683 if test "$mmi" = "yes" ; then
684 echo "TARGET_MMI=yes" >> config.mak
685 echo "#define HAVE_MMI 1" >> $TMPH
687 if test "$altivec" = "yes" ; then
688 echo "TARGET_ALTIVEC=yes" >> config.mak
689 echo "#define HAVE_ALTIVEC 1" >> $TMPH
690 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
691 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
693 if test "$gprof" = "yes" ; then
694 echo "TARGET_GPROF=yes" >> config.mak
695 echo "#define HAVE_GPROF 1" >> $TMPH
697 if test "$strptime" = "yes" ; then
698 echo "#define HAVE_STRPTIME 1" >> $TMPH
700 echo "BUILD_STRPTIME=yes" >> config.mak
702 if test "$imlib2" = "yes" ; then
703 echo "HAVE_IMLIB2=yes" >> config.mak
705 if test "$have_lrintf" = "yes" ; then
706 echo "#define HAVE_LRINTF 1" >> $TMPH
708 if test "$vhook" = "yes" ; then
709 echo "BUILD_VHOOK=yes" >> config.mak
710 echo "#define HAVE_VHOOK 1" >> $TMPH
711 extralibs="$extralibs $ldl"
713 if test "$lshared" = "yes" ; then
714 echo "BUILD_SHARED=yes" >> config.mak
715 echo "PIC=-fPIC" >> config.mak
717 echo "EXTRALIBS=$extralibs" >> config.mak
718 echo -n "VERSION=" >>config.mak
719 head $source_path/VERSION >>config.mak
721 # if you do not want to use encoders, disable that.
722 echo "#define CONFIG_ENCODERS 1" >> $TMPH
723 echo "CONFIG_ENCODERS=yes" >> config.mak
725 # if you do not want to use decoders, disable that.
726 echo "#define CONFIG_DECODERS 1" >> $TMPH
727 echo "CONFIG_DECODERS=yes" >> config.mak
730 if test "$a52" = "yes" ; then
731 echo "#define CONFIG_AC3 1" >> $TMPH
732 echo "CONFIG_AC3=yes" >> config.mak
734 if test "$a52bin" = "yes" ; then
735 echo "#define CONFIG_A52BIN 1" >> $TMPH
736 echo "CONFIG_A52BIN=yes" >> config.mak
740 # mpeg audio high precision mode
741 if test "$mpegaudio_hp" = "yes" ; then
742 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
745 if test "$v4l" = "yes" ; then
746 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
747 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
750 if test "$dv1394" = "yes" ; then
751 echo "#define CONFIG_DV1394 1" >> $TMPH
752 echo "CONFIG_DV1394=yes" >> config.mak
755 if test "$dlopen" = "yes" ; then
756 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
759 if test "$dlfcn" = "yes" ; then
760 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
763 if test "$audio_oss" = "yes" ; then
764 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
765 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
768 if test "$audio_beos" = "yes" ; then
769 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
770 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
773 if test "$network" = "yes" ; then
774 echo "#define CONFIG_NETWORK 1" >> $TMPH
775 echo "CONFIG_NETWORK=yes" >> config.mak
778 if test "$zlib" = "yes" ; then
779 echo "#define CONFIG_ZLIB 1" >> $TMPH
780 echo "CONFIG_ZLIB=yes" >> config.mak
783 if test "$mp3lame" = "yes" ; then
784 echo "#define CONFIG_MP3LAME 1" >> $TMPH
785 echo "CONFIG_MP3LAME=yes" >> config.mak
788 if test "$vorbis" = "yes" ; then
789 echo "#define CONFIG_VORBIS 1" >> $TMPH
790 echo "CONFIG_VORBIS=yes" >> config.mak
793 if test "$win32" = "yes" ; then
794 echo "#define CONFIG_WIN32 1" >> $TMPH
795 echo "CONFIG_WIN32=yes" >> config.mak
798 if test "$mingw32" = "yes" ; then
799 echo "#define CONFIG_WIN32 1" >> $TMPH
800 echo "CONFIG_WIN32=yes" >> config.mak
801 echo "#define __MINGW32__ 1" >> $TMPH
802 echo "__MINGW32__=1" >> config.mak
805 if test "$cygwin" = "yes" ; then
806 # setup correct exesuffix
807 echo "CONFIG_WIN32=yes" >> config.mak
810 if test "$os2" = "yes" ; then
811 echo "#define CONFIG_OS2 1" >> $TMPH
812 echo "CONFIG_OS2=yes" >> config.mak
815 if test "$darwin" = "yes"; then
816 echo "#define CONFIG_DARWIN 1" >> $TMPH
817 echo "CONFIG_DARWIN=yes" >> config.mak
820 if test "$_malloc_h" = "yes" ; then
821 echo "#define HAVE_MALLOC_H 1" >> $TMPH
823 echo "#undef HAVE_MALLOC_H" >> $TMPH
826 if test "$_memalign" = "yes" ; then
827 echo "#define HAVE_MEMALIGN 1" >> $TMPH
829 echo "#undef HAVE_MEMALIGN" >> $TMPH
832 if test "$netserver" = "yes" ; then
833 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
834 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
837 if test "$need_inet_aton" = "yes" ; then
838 echo "NEED_INET_ATON=yes" >> config.mak
841 if test "$simpleidct" = "yes" ; then
842 echo "#define SIMPLE_IDCT 1" >> $TMPH
845 if test "$ffserver" = "yes" ; then
846 echo "#define CONFIG_FFSERVER 1" >> $TMPH
847 echo "CONFIG_FFSERVER=yes" >> config.mak
850 if test "$risky" = "yes" ; then
851 echo "#define CONFIG_RISKY 1" >> $TMPH
852 echo "CONFIG_RISKY=yes" >> config.mak
855 echo "#define restrict $_restrict" >> $TMPH
857 # build tree in object directory if source path is different from current one
858 if test "$source_path_used" = "yes" ; then
859 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
860 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
861 FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
862 for dir in $DIRS ; do
866 ln -sf $source_path/$f $f
869 echo "SRC_PATH=$source_path" >> config.mak
871 diff $TMPH config.h >/dev/null 2>&1
872 if test $? -ne 0 ; then
875 echo "config.h is unchanged"
878 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH