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
553 #include <ft2build.h>
554 int main( void ) { return (int) FT_Init_FreeType(0); }
558 which freetype-config > /dev/null
559 if test $? -eq 0; then
560 if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then
565 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
568 Usage: configure [options]
569 Options: [defaults in brackets after descriptions]
572 echo "Standard options:"
573 echo " --help print this message"
574 echo " --prefix=PREFIX install in PREFIX [$prefix]"
575 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
576 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
577 echo " --enable-win32 enable win32 cross compile"
578 echo " --enable-mingw32 enable mingw32 native windows compile"
579 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
580 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
581 echo " --enable-shared build shared libraries [default=no]"
583 echo "Advanced options (experts only):"
584 echo " --source-path=PATH path of source code [$source_path]"
585 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
586 echo " --cc=CC use C compiler CC [$cc]"
587 echo " --make=MAKE use specified make [$make]"
588 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
589 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
590 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
591 echo " --cpu=CPU force cpu to CPU [$cpu]"
592 echo " --disable-mmx disable mmx usage"
593 echo " --disable-altivec disable AltiVec usage"
594 echo " --disable-audio-oss disable OSS audio support [default=no]"
595 echo " --disable-audio-beos disable BeOS audio support [default=no]"
596 echo " --disable-v4l disable video4linux grabbing [default=no]"
597 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
598 echo " --disable-network disable network support [default=no]"
599 echo " --disable-zlib disable zlib [default=no]"
600 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
601 echo " --disable-vhook disable video hooking support"
602 echo " --enable-gprof enable profiling with gprof [$gprof]"
603 echo " --disable-mpegaudio-hp faster (but less accurate)"
604 echo " mpegaudio decoding [default=no]"
605 echo " --disable-ffserver disable ffserver build"
606 echo " --disable-risky disables patent encumbered codecs"
608 echo "NOTE: The object files are build at the place where configure is launched"
612 echo "Install prefix $prefix"
613 echo "Source path $source_path"
614 echo "C compiler $cc"
617 echo "Big Endian $bigendian"
618 if test $cpu = "x86"; then
619 echo "MMX enabled $mmx"
620 echo "Vector Builtins $builtin_vector"
622 if test $cpu = "mips"; then
623 echo "MMI enabled $mmi"
625 if test $cpu = "powerpc"; then
626 echo "AltiVec enabled $altivec"
628 echo "gprof enabled $gprof"
629 echo "zlib enabled $zlib"
630 echo "mp3lame enabled $mp3lame"
631 echo "vorbis enabled $vorbis"
632 echo "a52 support $a52"
633 echo "a52 dlopened $a52bin"
634 echo "Video hooking $vhook"
635 echo "risky / patent encumbered codecs $risky"
637 if test "$vhook" = "yes" ; then
638 echo "Imlib2 support $imlib2"
639 echo "freetype support $freetype2"
642 echo "Creating config.mak and config.h"
644 echo "# Automatically generated by configure - do not modify" > config.mak
645 echo "/* Automatically generated by configure - do not modify */" > $TMPH
647 echo "prefix=$prefix" >> config.mak
648 echo "MAKE=$make" >> config.mak
649 echo "CC=$cc" >> config.mak
650 echo "AR=$ar" >> config.mak
651 echo "RANLIB=$ranlib" >> config.mak
652 echo "STRIP=$strip" >> config.mak
653 echo "OPTFLAGS=$CFLAGS" >> config.mak
654 echo "LDFLAGS=$LDFLAGS" >> config.mak
655 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
656 echo "SHFLAGS=$SHFLAGS" >> config.mak
657 echo "LIBPREF=$LIBPREF" >> config.mak
658 echo "LIBSUF=$LIBSUF" >> config.mak
659 echo "SLIBPREF=$SLIBPREF" >> config.mak
660 echo "SLIBSUF=$SLIBSUF" >> config.mak
661 echo "TARGET_OS=$TARGET_OS" >> config.mak
662 if test "$cpu" = "x86" ; then
663 echo "TARGET_ARCH_X86=yes" >> config.mak
664 echo "#define ARCH_X86 1" >> $TMPH
665 elif test "$cpu" = "armv4l" ; then
666 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
667 echo "#define ARCH_ARMV4L 1" >> $TMPH
668 elif test "$cpu" = "alpha" ; then
669 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
670 echo "#define ARCH_ALPHA 1" >> $TMPH
671 elif test "$cpu" = "sparc64" ; then
672 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
673 echo "#define ARCH_SPARC64 1" >> $TMPH
674 elif test "$cpu" = "powerpc" ; then
675 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
676 echo "#define ARCH_POWERPC 1" >> $TMPH
677 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
678 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
679 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
680 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
681 elif test "$cpu" = "mips" ; then
682 echo "TARGET_ARCH_MIPS=yes" >> config.mak
683 echo "#define ARCH_MIPS 1" >> $TMPH
685 if test "$bigendian" = "yes" ; then
686 echo "WORDS_BIGENDIAN=yes" >> config.mak
687 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
689 if test "$mmx" = "yes" ; then
690 echo "TARGET_MMX=yes" >> config.mak
691 echo "#define HAVE_MMX 1" >> $TMPH
693 if test "$builtin_vector" = "yes" ; then
694 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
695 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
697 if test "$mmi" = "yes" ; then
698 echo "TARGET_MMI=yes" >> config.mak
699 echo "#define HAVE_MMI 1" >> $TMPH
701 if test "$altivec" = "yes" ; then
702 echo "TARGET_ALTIVEC=yes" >> config.mak
703 echo "#define HAVE_ALTIVEC 1" >> $TMPH
704 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
705 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
707 if test "$gprof" = "yes" ; then
708 echo "TARGET_GPROF=yes" >> config.mak
709 echo "#define HAVE_GPROF 1" >> $TMPH
711 if test "$strptime" = "yes" ; then
712 echo "#define HAVE_STRPTIME 1" >> $TMPH
714 echo "BUILD_STRPTIME=yes" >> config.mak
716 if test "$imlib2" = "yes" ; then
717 echo "HAVE_IMLIB2=yes" >> config.mak
719 if test "$freetype2" = "yes" ; then
720 echo "HAVE_FREETYPE2=yes" >> config.mak
722 if test "$have_lrintf" = "yes" ; then
723 echo "#define HAVE_LRINTF 1" >> $TMPH
725 if test "$vhook" = "yes" ; then
726 echo "BUILD_VHOOK=yes" >> config.mak
727 echo "#define HAVE_VHOOK 1" >> $TMPH
728 extralibs="$extralibs $ldl"
730 if test "$lshared" = "yes" ; then
731 echo "BUILD_SHARED=yes" >> config.mak
732 echo "PIC=-fPIC" >> config.mak
734 echo "EXTRALIBS=$extralibs" >> config.mak
735 echo -n "VERSION=" >>config.mak
736 head $source_path/VERSION >>config.mak
738 # if you do not want to use encoders, disable that.
739 echo "#define CONFIG_ENCODERS 1" >> $TMPH
740 echo "CONFIG_ENCODERS=yes" >> config.mak
742 # if you do not want to use decoders, disable that.
743 echo "#define CONFIG_DECODERS 1" >> $TMPH
744 echo "CONFIG_DECODERS=yes" >> config.mak
747 if test "$a52" = "yes" ; then
748 echo "#define CONFIG_AC3 1" >> $TMPH
749 echo "CONFIG_AC3=yes" >> config.mak
751 if test "$a52bin" = "yes" ; then
752 echo "#define CONFIG_A52BIN 1" >> $TMPH
753 echo "CONFIG_A52BIN=yes" >> config.mak
757 # mpeg audio high precision mode
758 if test "$mpegaudio_hp" = "yes" ; then
759 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
762 if test "$v4l" = "yes" ; then
763 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
764 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
767 if test "$dv1394" = "yes" ; then
768 echo "#define CONFIG_DV1394 1" >> $TMPH
769 echo "CONFIG_DV1394=yes" >> config.mak
772 if test "$dlopen" = "yes" ; then
773 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
776 if test "$dlfcn" = "yes" ; then
777 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
780 if test "$audio_oss" = "yes" ; then
781 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
782 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
785 if test "$audio_beos" = "yes" ; then
786 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
787 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
790 if test "$network" = "yes" ; then
791 echo "#define CONFIG_NETWORK 1" >> $TMPH
792 echo "CONFIG_NETWORK=yes" >> config.mak
795 if test "$zlib" = "yes" ; then
796 echo "#define CONFIG_ZLIB 1" >> $TMPH
797 echo "CONFIG_ZLIB=yes" >> config.mak
800 if test "$mp3lame" = "yes" ; then
801 echo "#define CONFIG_MP3LAME 1" >> $TMPH
802 echo "CONFIG_MP3LAME=yes" >> config.mak
805 if test "$vorbis" = "yes" ; then
806 echo "#define CONFIG_VORBIS 1" >> $TMPH
807 echo "CONFIG_VORBIS=yes" >> config.mak
810 if test "$win32" = "yes" ; then
811 echo "#define CONFIG_WIN32 1" >> $TMPH
812 echo "CONFIG_WIN32=yes" >> config.mak
815 if test "$mingw32" = "yes" ; then
816 echo "#define CONFIG_WIN32 1" >> $TMPH
817 echo "CONFIG_WIN32=yes" >> config.mak
818 echo "#define __MINGW32__ 1" >> $TMPH
819 echo "__MINGW32__=1" >> config.mak
822 if test "$cygwin" = "yes" ; then
823 # setup correct exesuffix
824 echo "CONFIG_WIN32=yes" >> config.mak
827 if test "$os2" = "yes" ; then
828 echo "#define CONFIG_OS2 1" >> $TMPH
829 echo "CONFIG_OS2=yes" >> config.mak
832 if test "$darwin" = "yes"; then
833 echo "#define CONFIG_DARWIN 1" >> $TMPH
834 echo "CONFIG_DARWIN=yes" >> config.mak
837 if test "$_malloc_h" = "yes" ; then
838 echo "#define HAVE_MALLOC_H 1" >> $TMPH
840 echo "#undef HAVE_MALLOC_H" >> $TMPH
843 if test "$_memalign" = "yes" ; then
844 echo "#define HAVE_MEMALIGN 1" >> $TMPH
846 echo "#undef HAVE_MEMALIGN" >> $TMPH
849 if test "$netserver" = "yes" ; then
850 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
851 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
854 if test "$need_inet_aton" = "yes" ; then
855 echo "NEED_INET_ATON=yes" >> config.mak
858 if test "$simpleidct" = "yes" ; then
859 echo "#define SIMPLE_IDCT 1" >> $TMPH
862 if test "$ffserver" = "yes" ; then
863 echo "#define CONFIG_FFSERVER 1" >> $TMPH
864 echo "CONFIG_FFSERVER=yes" >> config.mak
867 if test "$risky" = "yes" ; then
868 echo "#define CONFIG_RISKY 1" >> $TMPH
869 echo "CONFIG_RISKY=yes" >> config.mak
872 echo "#define restrict $_restrict" >> $TMPH
874 # build tree in object directory if source path is different from current one
875 if test "$source_path_used" = "yes" ; then
876 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
877 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
878 FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
879 for dir in $DIRS ; do
883 ln -sf $source_path/$f $f
886 echo "SRC_PATH=$source_path" >> config.mak
888 diff $TMPH config.h >/dev/null 2>&1
889 if test $? -ne 0 ; then
892 echo "config.h is unchanged"
895 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH