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)
81 LDFLAGS=-Wl,--warn-common
93 prefix="/boot/home/config"
94 # helps building libavcodec
95 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
96 # 3 gcc releases known for BeOS, each with ugly bugs
97 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
98 case "$gcc_version" in
99 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
102 *20010315*) echo "BeBits gcc"
103 CFLAGS="$CFLAGS -fno-expensive-optimizations"
107 # disable linux things
113 # no need for libm, but the inet stuff
115 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
116 extralibs="-lbind -lsocket"
130 extralibs="$extralibs -lsocket -lnsl"
137 LDFLAGS="$LDFLAGS -export-dynamic"
143 extralibs="-lpoll -lgnugetopt -lm"
151 SHFLAGS="-dynamiclib"
156 FFSLDFLAGS=-Wl,-bind_at_load
157 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
158 case "$gcc_version" in
160 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
163 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
181 test -f /usr/include/inttypes.h || \
182 test -f /usr/local/include/inttypes.h || \
183 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
184 "/usr/include/inttypes.h !!!"
187 LDFLAGS="$LDFLAGS -rdynamic"
192 ranlib="echo ignoring ranlib"
193 strip="echo ignoring strip"
195 LDFLAGS="-Zomf -Zstack 16384 -s"
213 # From mplayer configure. We need TARGET_OS available
214 # to the Makefile, so it can distinguish between flavors
215 # of AltiVec on PowerPC
216 TARGET_OS=`( uname -s ) 2>&1`
218 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
226 [cC][yY][gG][wW][iI][nN]*)
230 TARGET_OS="$TARGET_OS-UNKNOWN"
235 # XXX: we assume an absolute path is given when launching configure,
236 # except in './configure' case.
237 source_path=${0%configure}
238 source_path=${source_path%/}
239 source_path_used="yes"
240 if test -z "$source_path" -o "$source_path" = "." ; then
242 source_path_used="no"
247 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
249 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
251 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
253 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
255 --make=*) make=`echo $opt | cut -d '=' -f 2`
257 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
259 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
261 --extra-libs=*) extralibs=${opt#--extra-libs=}
263 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
265 --disable-mmx) mmx="no"
267 --disable-altivec) altivec="no"
269 --enable-gprof) gprof="yes"
271 --disable-v4l) v4l="no"
273 --disable-audio-oss) audio_oss="no"
275 --disable-audio-beos) audio_beos="no"
277 --disable-dv1394) dv1394="no"
279 --disable-network) network="no"
281 --disable-zlib) zlib="no"
283 --disable-a52) a52="no"
285 --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
287 --disable-pp) pp="no"
289 --enable-shared-pp) shared_pp="yes"
291 --enable-mp3lame) mp3lame="yes"
293 --enable-vorbis) vorbis="yes"
295 --disable-vhook) vhook="no"
297 --disable-simple_idct) simpleidct="no"
299 --enable-win32) win32="yes"
301 --enable-mingw32) mingw32="yes"
303 --enable-shared) lshared="yes"
305 --disable-mpegaudio-hp) mpegaudio_hp="no"
307 --disable-ffserver) ffserver="no"
309 --disable-risky) risky="no"
315 if test $mmx = "default"; then
316 if test $cpu = "x86"; then
323 # Can only do AltiVec on PowerPC
324 if test $altivec = "default"; then
325 if test $cpu = "powerpc"; then
332 # See does our compiler support Motorola AltiVec C API
333 if test $altivec = "yes"; then
336 vector signed int v1, v2, v3;
341 $cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
344 # Can only do mmi on mips
345 if test $mmi = "default"; then
346 if test $cpu = "mips"; then
353 # See does our compiler support mmi
354 if test $mmi = "yes"; then
357 __asm__ ("lq \$2, 0(\$2)");
361 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
364 # Checking for CFLAGS
365 if test -z "$CFLAGS"; then
369 if test "$win32" = "yes" ; then
370 cross_prefix="i386-mingw32msvc-"
377 if test "$mingw32" = "yes" ; then
385 cc="${cross_prefix}${cc}"
386 ar="${cross_prefix}${ar}"
387 ranlib="${cross_prefix}${ranlib}"
388 strip="${cross_prefix}${strip}"
390 if test -z "$cross_prefix" ; then
393 # big/little endian test
395 #include <inttypes.h>
396 int main(int argc, char ** argv){
397 volatile uint32_t i=0x01234567;
398 return (*((uint8_t*)(&i))) == 0x67;
402 if $cc -o $TMPE $TMPC 2>/dev/null ; then
403 $TMPE && bigendian="yes"
405 echo big/little test failed
410 # if cross compiling, cannot launch a program, so make a static guess
411 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
418 # check availability of some header files
422 int main( void ) { return 0; }
427 if $cc -o $TMPE $TMPC 2> /dev/null ; then
430 # check for memalign - atmos
435 string = memalign(64, sizeof(char));
439 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
445 int main( void ) { return *strptime("", "", 0); }
449 if $cc -o $TMPE $TMPC 2> /dev/null ; then
453 if test "$zlib" = "yes"; then
454 # check for zlib - mmu_man
458 if (zlibVersion() != ZLIB_VERSION)
459 puts("zlib version differs !!!");
464 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
465 # $TMPE 2> /dev/null > /dev/null || zlib="no"
466 # XXX: more tests needed - runtime test
468 if test "$zlib" = "yes"; then
469 extralibs="$extralibs -lz"
472 # test for lrintf in math.h
474 #define _ISOC9X_SOURCE 1
476 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
480 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
482 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
486 for restrict_keyword in restrict __restrict__ __restrict; do
487 echo "void foo(char * $restrict_keyword p);" > $TMPC
488 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
489 _restrict=$restrict_keyword
494 # test gcc version to see if vector builtins can be used
495 # currently only used on i386 for MMX builtins
498 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
501 #error no vector builtins
507 if $cc -o $TMPO $TMPC 2> /dev/null ; then
511 # dlopen/dlfcn.h probing
515 int main( void ) { return (int) dlopen("foo", 0); }
520 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
525 if $cc -o $TMPE $TMPC 2> /dev/null ; then
532 int main( void ) { return (int) dlopen("foo", 0); }
535 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
539 if $cc -o $TMPE $TMPC 2> /dev/null ; then
544 if test "$vhook" = "default" ; then
549 #include <X11/Xlib.h>
551 int main( void ) { return (int) imlib_load_font("foo"); }
555 if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
560 #include <ft2build.h>
561 int main( void ) { return (int) FT_Init_FreeType(0); }
565 if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
566 which freetype-config > /dev/null
567 if test $? -eq 0; then
568 if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then
574 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
577 Usage: configure [options]
578 Options: [defaults in brackets after descriptions]
581 echo "Standard options:"
582 echo " --help print this message"
583 echo " --prefix=PREFIX install in PREFIX [$prefix]"
584 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
585 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
586 echo " --enable-win32 enable win32 cross compile"
587 echo " --enable-mingw32 enable mingw32 native windows compile"
588 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
589 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
590 echo " --disable-pp disable GPL'ed post processing support [default=no]"
591 echo " --enable-shared-pp use libpostproc.so [default=no]"
592 echo " --enable-shared build shared libraries [default=no]"
594 echo "Advanced options (experts only):"
595 echo " --source-path=PATH path of source code [$source_path]"
596 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
597 echo " --cc=CC use C compiler CC [$cc]"
598 echo " --make=MAKE use specified make [$make]"
599 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
600 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
601 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
602 echo " --cpu=CPU force cpu to CPU [$cpu]"
603 echo " --disable-mmx disable mmx usage"
604 echo " --disable-altivec disable AltiVec usage"
605 echo " --disable-audio-oss disable OSS audio support [default=no]"
606 echo " --disable-audio-beos disable BeOS audio support [default=no]"
607 echo " --disable-v4l disable video4linux grabbing [default=no]"
608 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
609 echo " --disable-network disable network support [default=no]"
610 echo " --disable-zlib disable zlib [default=no]"
611 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
612 echo " --disable-vhook disable video hooking support"
613 echo " --enable-gprof enable profiling with gprof [$gprof]"
614 echo " --disable-mpegaudio-hp faster (but less accurate)"
615 echo " mpegaudio decoding [default=no]"
616 echo " --disable-ffserver disable ffserver build"
617 echo " --disable-risky disables patent encumbered codecs"
619 echo "NOTE: The object files are build at the place where configure is launched"
623 echo "Install prefix $prefix"
624 echo "Source path $source_path"
625 echo "C compiler $cc"
628 echo "Big Endian $bigendian"
629 if test $cpu = "x86"; then
630 echo "MMX enabled $mmx"
631 echo "Vector Builtins $builtin_vector"
633 if test $cpu = "mips"; then
634 echo "MMI enabled $mmi"
636 if test $cpu = "powerpc"; then
637 echo "AltiVec enabled $altivec"
639 echo "gprof enabled $gprof"
640 echo "zlib enabled $zlib"
641 echo "mp3lame enabled $mp3lame"
642 echo "vorbis enabled $vorbis"
643 echo "a52 support $a52"
644 echo "a52 dlopened $a52bin"
645 echo "pp support $pp"
646 echo "shared pp $shared_pp"
647 echo "Video hooking $vhook"
648 echo "risky / patent encumbered codecs $risky"
650 if test "$vhook" = "yes" ; then
651 echo "Imlib2 support $imlib2"
652 echo "freetype support $freetype2"
655 echo "Creating config.mak and config.h"
657 echo "# Automatically generated by configure - do not modify" > config.mak
658 echo "/* Automatically generated by configure - do not modify */" > $TMPH
660 echo "prefix=$prefix" >> config.mak
661 echo "MAKE=$make" >> config.mak
662 echo "CC=$cc" >> config.mak
663 echo "AR=$ar" >> config.mak
664 echo "RANLIB=$ranlib" >> config.mak
665 echo "STRIP=$strip" >> config.mak
666 echo "OPTFLAGS=$CFLAGS" >> config.mak
667 echo "LDFLAGS=$LDFLAGS" >> config.mak
668 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
669 echo "SHFLAGS=$SHFLAGS" >> config.mak
670 echo "LIBPREF=$LIBPREF" >> config.mak
671 echo "LIBSUF=$LIBSUF" >> config.mak
672 echo "SLIBPREF=$SLIBPREF" >> config.mak
673 echo "SLIBSUF=$SLIBSUF" >> config.mak
674 echo "TARGET_OS=$TARGET_OS" >> config.mak
675 if test "$cpu" = "x86" ; then
676 echo "TARGET_ARCH_X86=yes" >> config.mak
677 echo "#define ARCH_X86 1" >> $TMPH
678 elif test "$cpu" = "armv4l" ; then
679 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
680 echo "#define ARCH_ARMV4L 1" >> $TMPH
681 elif test "$cpu" = "alpha" ; then
682 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
683 echo "#define ARCH_ALPHA 1" >> $TMPH
684 elif test "$cpu" = "sparc64" ; then
685 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
686 echo "#define ARCH_SPARC64 1" >> $TMPH
687 elif test "$cpu" = "powerpc" ; then
688 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
689 echo "#define ARCH_POWERPC 1" >> $TMPH
690 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
691 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
692 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
693 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
694 elif test "$cpu" = "mips" ; then
695 echo "TARGET_ARCH_MIPS=yes" >> config.mak
696 echo "#define ARCH_MIPS 1" >> $TMPH
698 if test "$bigendian" = "yes" ; then
699 echo "WORDS_BIGENDIAN=yes" >> config.mak
700 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
702 if test "$mmx" = "yes" ; then
703 echo "TARGET_MMX=yes" >> config.mak
704 echo "#define HAVE_MMX 1" >> $TMPH
706 if test "$builtin_vector" = "yes" ; then
707 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
708 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
710 if test "$mmi" = "yes" ; then
711 echo "TARGET_MMI=yes" >> config.mak
712 echo "#define HAVE_MMI 1" >> $TMPH
714 if test "$altivec" = "yes" ; then
715 echo "TARGET_ALTIVEC=yes" >> config.mak
716 echo "#define HAVE_ALTIVEC 1" >> $TMPH
717 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
718 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
720 if test "$gprof" = "yes" ; then
721 echo "TARGET_GPROF=yes" >> config.mak
722 echo "#define HAVE_GPROF 1" >> $TMPH
724 if test "$strptime" = "yes" ; then
725 echo "#define HAVE_STRPTIME 1" >> $TMPH
727 echo "BUILD_STRPTIME=yes" >> config.mak
729 if test "$imlib2" = "yes" ; then
730 echo "HAVE_IMLIB2=yes" >> config.mak
732 if test "$freetype2" = "yes" ; then
733 echo "HAVE_FREETYPE2=yes" >> config.mak
735 if test "$have_lrintf" = "yes" ; then
736 echo "#define HAVE_LRINTF 1" >> $TMPH
738 if test "$vhook" = "yes" ; then
739 echo "BUILD_VHOOK=yes" >> config.mak
740 echo "#define HAVE_VHOOK 1" >> $TMPH
741 extralibs="$extralibs $ldl"
743 if test "$lshared" = "yes" ; then
744 echo "BUILD_SHARED=yes" >> config.mak
745 echo "PIC=-fPIC" >> config.mak
747 echo "EXTRALIBS=$extralibs" >> config.mak
748 echo -n "VERSION=" >>config.mak
749 head $source_path/VERSION >>config.mak
751 # if you do not want to use encoders, disable that.
752 echo "#define CONFIG_ENCODERS 1" >> $TMPH
753 echo "CONFIG_ENCODERS=yes" >> config.mak
755 # if you do not want to use decoders, disable that.
756 echo "#define CONFIG_DECODERS 1" >> $TMPH
757 echo "CONFIG_DECODERS=yes" >> config.mak
760 if test "$a52" = "yes" ; then
761 echo "#define CONFIG_AC3 1" >> $TMPH
762 echo "CONFIG_AC3=yes" >> config.mak
764 if test "$a52bin" = "yes" ; then
765 echo "#define CONFIG_A52BIN 1" >> $TMPH
766 echo "CONFIG_A52BIN=yes" >> config.mak
771 if test "$pp" = "yes" ; then
772 echo "#define CONFIG_PP 1" >> $TMPH
773 echo "CONFIG_PP=yes" >> config.mak
775 if test "$shared_pp" = "yes" ; then
776 echo "#define SHARED_PP 1" >> $TMPH
777 echo "SHARED_PP=yes" >> config.mak
781 # mpeg audio high precision mode
782 if test "$mpegaudio_hp" = "yes" ; then
783 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
786 if test "$v4l" = "yes" ; then
787 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
788 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
791 if test "$dv1394" = "yes" ; then
792 echo "#define CONFIG_DV1394 1" >> $TMPH
793 echo "CONFIG_DV1394=yes" >> config.mak
796 if test "$dlopen" = "yes" ; then
797 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
800 if test "$dlfcn" = "yes" ; then
801 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
804 if test "$audio_oss" = "yes" ; then
805 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
806 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
809 if test "$audio_beos" = "yes" ; then
810 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
811 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
814 if test "$network" = "yes" ; then
815 echo "#define CONFIG_NETWORK 1" >> $TMPH
816 echo "CONFIG_NETWORK=yes" >> config.mak
819 if test "$zlib" = "yes" ; then
820 echo "#define CONFIG_ZLIB 1" >> $TMPH
821 echo "CONFIG_ZLIB=yes" >> config.mak
824 if test "$mp3lame" = "yes" ; then
825 echo "#define CONFIG_MP3LAME 1" >> $TMPH
826 echo "CONFIG_MP3LAME=yes" >> config.mak
829 if test "$vorbis" = "yes" ; then
830 echo "#define CONFIG_VORBIS 1" >> $TMPH
831 echo "CONFIG_VORBIS=yes" >> config.mak
834 if test "$win32" = "yes" ; then
835 echo "#define CONFIG_WIN32 1" >> $TMPH
836 echo "CONFIG_WIN32=yes" >> config.mak
839 if test "$mingw32" = "yes" ; then
840 echo "#define CONFIG_WIN32 1" >> $TMPH
841 echo "CONFIG_WIN32=yes" >> config.mak
842 echo "#define __MINGW32__ 1" >> $TMPH
843 echo "__MINGW32__=1" >> config.mak
846 if test "$cygwin" = "yes" ; then
847 # setup correct exesuffix
848 echo "CONFIG_WIN32=yes" >> config.mak
851 if test "$os2" = "yes" ; then
852 echo "#define CONFIG_OS2 1" >> $TMPH
853 echo "CONFIG_OS2=yes" >> config.mak
856 if test "$darwin" = "yes"; then
857 echo "#define CONFIG_DARWIN 1" >> $TMPH
858 echo "CONFIG_DARWIN=yes" >> config.mak
861 if test "$_malloc_h" = "yes" ; then
862 echo "#define HAVE_MALLOC_H 1" >> $TMPH
864 echo "#undef HAVE_MALLOC_H" >> $TMPH
867 if test "$_memalign" = "yes" ; then
868 echo "#define HAVE_MEMALIGN 1" >> $TMPH
870 echo "#undef HAVE_MEMALIGN" >> $TMPH
873 if test "$netserver" = "yes" ; then
874 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
875 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
878 if test "$need_inet_aton" = "yes" ; then
879 echo "NEED_INET_ATON=yes" >> config.mak
882 if test "$simpleidct" = "yes" ; then
883 echo "#define SIMPLE_IDCT 1" >> $TMPH
886 if test "$ffserver" = "yes" ; then
887 echo "#define CONFIG_FFSERVER 1" >> $TMPH
888 echo "CONFIG_FFSERVER=yes" >> config.mak
891 if test "$risky" = "yes" ; then
892 echo "#define CONFIG_RISKY 1" >> $TMPH
893 echo "CONFIG_RISKY=yes" >> config.mak
896 echo "#define restrict $_restrict" >> $TMPH
898 # build tree in object directory if source path is different from current one
899 if test "$source_path_used" = "yes" ; then
900 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
901 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
902 FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
903 for dir in $DIRS ; do
907 ln -sf $source_path/$f $f
910 echo "SRC_PATH=$source_path" >> config.mak
912 diff $TMPH config.h >/dev/null 2>&1
913 if test $? -ne 0 ; then
916 echo "config.h is unchanged"
919 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH