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
94 prefix="/boot/home/config"
95 # helps building libavcodec
96 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
97 # 3 gcc releases known for BeOS, each with ugly bugs
98 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
99 case "$gcc_version" in
100 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
103 *20010315*) echo "BeBits gcc"
104 CFLAGS="$CFLAGS -fno-expensive-optimizations"
108 # disable linux things
114 # no need for libm, but the inet stuff
116 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
117 extralibs="-lbind -lsocket"
131 extralibs="$extralibs -lsocket -lnsl"
138 LDFLAGS="$LDFLAGS -export-dynamic"
144 extralibs="-lpoll -lgnugetopt -lm"
152 SHFLAGS="-dynamiclib"
157 FFSLDFLAGS=-Wl,-bind_at_load
158 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
159 case "$gcc_version" in
161 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
164 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
182 test -f /usr/include/inttypes.h || \
183 test -f /usr/local/include/inttypes.h || \
184 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
185 "/usr/include/inttypes.h !!!"
188 LDFLAGS="$LDFLAGS -rdynamic"
193 ranlib="echo ignoring ranlib"
194 strip="echo ignoring strip"
196 LDFLAGS="-Zomf -Zstack 16384 -s"
214 # From mplayer configure. We need TARGET_OS available
215 # to the Makefile, so it can distinguish between flavors
216 # of AltiVec on PowerPC
217 TARGET_OS=`( uname -s ) 2>&1`
219 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
227 [cC][yY][gG][wW][iI][nN]*)
231 TARGET_OS="$TARGET_OS-UNKNOWN"
236 # XXX: we assume an absolute path is given when launching configure,
237 # except in './configure' case.
238 source_path="`echo $0 | sed -e 's#/configure##'`"
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"
311 --enable-small) small="yes"
317 if test $mmx = "default"; then
318 if test $cpu = "x86"; then
325 # Can only do AltiVec on PowerPC
326 if test $altivec = "default"; then
327 if test $cpu = "powerpc"; then
334 # See does our compiler support Motorola AltiVec C API
335 if test $altivec = "yes"; then
338 vector signed int v1, v2, v3;
343 $cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
346 # Can only do mmi on mips
347 if test $mmi = "default"; then
348 if test $cpu = "mips"; then
355 # See does our compiler support mmi
356 if test $mmi = "yes"; then
359 __asm__ ("lq \$2, 0(\$2)");
363 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
366 # Checking for CFLAGS
367 if test -z "$CFLAGS"; then
371 if test "$win32" = "yes" ; then
372 cross_prefix="i386-mingw32msvc-"
379 if test "$mingw32" = "yes" ; then
387 cc="${cross_prefix}${cc}"
388 ar="${cross_prefix}${ar}"
389 ranlib="${cross_prefix}${ranlib}"
390 strip="${cross_prefix}${strip}"
392 if test -z "$cross_prefix" ; then
395 # big/little endian test
397 #include <inttypes.h>
398 int main(int argc, char ** argv){
399 volatile uint32_t i=0x01234567;
400 return (*((uint8_t*)(&i))) == 0x67;
404 if $cc -o $TMPE $TMPC 2>/dev/null ; then
405 $TMPE && bigendian="yes"
407 echo big/little test failed
412 # if cross compiling, cannot launch a program, so make a static guess
413 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
420 # check availability of some header files
424 int main( void ) { return 0; }
429 if $cc -o $TMPE $TMPC 2> /dev/null ; then
432 # check for memalign - atmos
437 string = memalign(64, sizeof(char));
441 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
447 int main( void ) { return *strptime("", "", 0); }
451 if $cc -o $TMPE $TMPC 2> /dev/null ; then
455 if test "$zlib" = "yes"; then
456 # check for zlib - mmu_man
460 if (zlibVersion() != ZLIB_VERSION)
461 puts("zlib version differs !!!");
466 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
467 # $TMPE 2> /dev/null > /dev/null || zlib="no"
468 # XXX: more tests needed - runtime test
470 if test "$zlib" = "yes"; then
471 extralibs="$extralibs -lz"
474 # test for lrintf in math.h
476 #define _ISOC9X_SOURCE 1
478 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
482 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
484 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
488 for restrict_keyword in restrict __restrict__ __restrict; do
489 echo "void foo(char * $restrict_keyword p);" > $TMPC
490 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
491 _restrict=$restrict_keyword
496 # test gcc version to see if vector builtins can be used
497 # currently only used on i386 for MMX builtins
500 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
503 #error no vector builtins
509 if $cc -o $TMPO $TMPC 2> /dev/null ; then
513 # dlopen/dlfcn.h probing
517 int main( void ) { return (int) dlopen("foo", 0); }
522 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
527 if $cc -o $TMPE $TMPC 2> /dev/null ; then
534 int main( void ) { return (int) dlopen("foo", 0); }
537 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
541 if $cc -o $TMPE $TMPC 2> /dev/null ; then
546 if test "$vhook" = "default" ; then
551 #include <X11/Xlib.h>
553 int main( void ) { return (int) imlib_load_font("foo"); }
557 if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
562 #include <ft2build.h>
563 int main( void ) { return (int) FT_Init_FreeType(0); }
567 if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
568 which freetype-config > /dev/null
569 if test $? -eq 0; then
570 if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then
576 if test "$small" = "yes"; then
577 # CFLAGS=${CFLAGS//-O3/-Os}
581 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
584 Usage: configure [options]
585 Options: [defaults in brackets after descriptions]
588 echo "Standard options:"
589 echo " --help print this message"
590 echo " --prefix=PREFIX install in PREFIX [$prefix]"
591 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
592 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
593 echo " --enable-win32 enable win32 cross compile"
594 echo " --enable-mingw32 enable mingw32 native windows compile"
595 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
596 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
597 echo " --disable-pp disable GPL'ed post processing support [default=no]"
598 echo " --enable-shared-pp use libpostproc.so [default=no]"
599 echo " --enable-shared build shared libraries [default=no]"
601 echo "Advanced options (experts only):"
602 echo " --source-path=PATH path of source code [$source_path]"
603 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
604 echo " --cc=CC use C compiler CC [$cc]"
605 echo " --make=MAKE use specified make [$make]"
606 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
607 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
608 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
609 echo " --cpu=CPU force cpu to CPU [$cpu]"
610 echo " --disable-mmx disable mmx usage"
611 echo " --disable-altivec disable AltiVec usage"
612 echo " --disable-audio-oss disable OSS audio support [default=no]"
613 echo " --disable-audio-beos disable BeOS audio support [default=no]"
614 echo " --disable-v4l disable video4linux grabbing [default=no]"
615 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
616 echo " --disable-network disable network support [default=no]"
617 echo " --disable-zlib disable zlib [default=no]"
618 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
619 echo " --disable-vhook disable video hooking support"
620 echo " --enable-gprof enable profiling with gprof [$gprof]"
621 echo " --disable-mpegaudio-hp faster (but less accurate)"
622 echo " mpegaudio decoding [default=no]"
623 echo " --disable-ffserver disable ffserver build"
624 echo " --disable-risky disables patent encumbered codecs"
625 echo " --enable-small optimize for size instead of speed"
627 echo "NOTE: The object files are build at the place where configure is launched"
631 echo "Install prefix $prefix"
632 echo "Source path $source_path"
633 echo "C compiler $cc"
636 echo "Big Endian $bigendian"
637 if test $cpu = "x86"; then
638 echo "MMX enabled $mmx"
639 echo "Vector Builtins $builtin_vector"
641 if test $cpu = "mips"; then
642 echo "MMI enabled $mmi"
644 if test $cpu = "powerpc"; then
645 echo "AltiVec enabled $altivec"
647 echo "gprof enabled $gprof"
648 echo "zlib enabled $zlib"
649 echo "mp3lame enabled $mp3lame"
650 echo "vorbis enabled $vorbis"
651 echo "a52 support $a52"
652 echo "a52 dlopened $a52bin"
653 echo "pp support $pp"
654 echo "shared pp $shared_pp"
655 echo "Video hooking $vhook"
656 echo "risky / patent encumbered codecs $risky"
657 echo "optimize for size $small"
659 if test "$vhook" = "yes" ; then
660 echo "Imlib2 support $imlib2"
661 echo "freetype support $freetype2"
664 echo "Creating config.mak and config.h"
666 echo "# Automatically generated by configure - do not modify" > config.mak
667 echo "/* Automatically generated by configure - do not modify */" > $TMPH
669 echo "prefix=$prefix" >> config.mak
670 echo "MAKE=$make" >> config.mak
671 echo "CC=$cc" >> config.mak
672 echo "AR=$ar" >> config.mak
673 echo "RANLIB=$ranlib" >> config.mak
674 echo "STRIP=$strip" >> config.mak
675 echo "OPTFLAGS=$CFLAGS" >> config.mak
676 echo "LDFLAGS=$LDFLAGS" >> config.mak
677 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
678 echo "SHFLAGS=$SHFLAGS" >> config.mak
679 echo "LIBPREF=$LIBPREF" >> config.mak
680 echo "LIBSUF=$LIBSUF" >> config.mak
681 echo "SLIBPREF=$SLIBPREF" >> config.mak
682 echo "SLIBSUF=$SLIBSUF" >> config.mak
683 echo "TARGET_OS=$TARGET_OS" >> config.mak
684 if test "$cpu" = "x86" ; then
685 echo "TARGET_ARCH_X86=yes" >> config.mak
686 echo "#define ARCH_X86 1" >> $TMPH
687 elif test "$cpu" = "armv4l" ; then
688 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
689 echo "#define ARCH_ARMV4L 1" >> $TMPH
690 elif test "$cpu" = "alpha" ; then
691 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
692 echo "#define ARCH_ALPHA 1" >> $TMPH
693 elif test "$cpu" = "sparc64" ; then
694 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
695 echo "#define ARCH_SPARC64 1" >> $TMPH
696 elif test "$cpu" = "powerpc" ; then
697 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
698 echo "#define ARCH_POWERPC 1" >> $TMPH
699 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
700 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
701 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
702 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
703 elif test "$cpu" = "mips" ; then
704 echo "TARGET_ARCH_MIPS=yes" >> config.mak
705 echo "#define ARCH_MIPS 1" >> $TMPH
707 if test "$bigendian" = "yes" ; then
708 echo "WORDS_BIGENDIAN=yes" >> config.mak
709 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
711 if test "$mmx" = "yes" ; then
712 echo "TARGET_MMX=yes" >> config.mak
713 echo "#define HAVE_MMX 1" >> $TMPH
715 if test "$builtin_vector" = "yes" ; then
716 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
717 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
719 if test "$mmi" = "yes" ; then
720 echo "TARGET_MMI=yes" >> config.mak
721 echo "#define HAVE_MMI 1" >> $TMPH
723 if test "$altivec" = "yes" ; then
724 echo "TARGET_ALTIVEC=yes" >> config.mak
725 echo "#define HAVE_ALTIVEC 1" >> $TMPH
726 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
727 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
729 if test "$gprof" = "yes" ; then
730 echo "TARGET_GPROF=yes" >> config.mak
731 echo "#define HAVE_GPROF 1" >> $TMPH
733 if test "$strptime" = "yes" ; then
734 echo "#define HAVE_STRPTIME 1" >> $TMPH
736 echo "BUILD_STRPTIME=yes" >> config.mak
738 if test "$imlib2" = "yes" ; then
739 echo "HAVE_IMLIB2=yes" >> config.mak
741 if test "$freetype2" = "yes" ; then
742 echo "HAVE_FREETYPE2=yes" >> config.mak
744 if test "$have_lrintf" = "yes" ; then
745 echo "#define HAVE_LRINTF 1" >> $TMPH
747 if test "$vhook" = "yes" ; then
748 echo "BUILD_VHOOK=yes" >> config.mak
749 echo "#define HAVE_VHOOK 1" >> $TMPH
750 extralibs="$extralibs $ldl"
752 if test "$lshared" = "yes" ; then
753 echo "BUILD_SHARED=yes" >> config.mak
754 echo "PIC=-fPIC" >> config.mak
756 echo "EXTRALIBS=$extralibs" >> config.mak
757 echo "VERSION=`head $source_path/VERSION`" >>config.mak
759 # if you do not want to use encoders, disable that.
760 echo "#define CONFIG_ENCODERS 1" >> $TMPH
761 echo "CONFIG_ENCODERS=yes" >> config.mak
763 # if you do not want to use decoders, disable that.
764 echo "#define CONFIG_DECODERS 1" >> $TMPH
765 echo "CONFIG_DECODERS=yes" >> config.mak
768 if test "$a52" = "yes" ; then
769 echo "#define CONFIG_AC3 1" >> $TMPH
770 echo "CONFIG_AC3=yes" >> config.mak
772 if test "$a52bin" = "yes" ; then
773 echo "#define CONFIG_A52BIN 1" >> $TMPH
774 echo "CONFIG_A52BIN=yes" >> config.mak
779 if test "$pp" = "yes" ; then
780 echo "#define CONFIG_PP 1" >> $TMPH
781 echo "CONFIG_PP=yes" >> config.mak
783 if test "$shared_pp" = "yes" ; then
784 echo "#define SHARED_PP 1" >> $TMPH
785 echo "SHARED_PP=yes" >> config.mak
789 # mpeg audio high precision mode
790 if test "$mpegaudio_hp" = "yes" ; then
791 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
794 if test "$v4l" = "yes" ; then
795 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
796 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
799 if test "$dv1394" = "yes" ; then
800 echo "#define CONFIG_DV1394 1" >> $TMPH
801 echo "CONFIG_DV1394=yes" >> config.mak
804 if test "$dlopen" = "yes" ; then
805 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
808 if test "$dlfcn" = "yes" ; then
809 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
812 if test "$audio_oss" = "yes" ; then
813 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
814 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
817 if test "$audio_beos" = "yes" ; then
818 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
819 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
822 if test "$network" = "yes" ; then
823 echo "#define CONFIG_NETWORK 1" >> $TMPH
824 echo "CONFIG_NETWORK=yes" >> config.mak
827 if test "$zlib" = "yes" ; then
828 echo "#define CONFIG_ZLIB 1" >> $TMPH
829 echo "CONFIG_ZLIB=yes" >> config.mak
832 if test "$mp3lame" = "yes" ; then
833 echo "#define CONFIG_MP3LAME 1" >> $TMPH
834 echo "CONFIG_MP3LAME=yes" >> config.mak
837 if test "$vorbis" = "yes" ; then
838 echo "#define CONFIG_VORBIS 1" >> $TMPH
839 echo "CONFIG_VORBIS=yes" >> config.mak
842 if test "$win32" = "yes" ; then
843 echo "#define CONFIG_WIN32 1" >> $TMPH
844 echo "CONFIG_WIN32=yes" >> config.mak
847 if test "$mingw32" = "yes" ; then
848 echo "#define CONFIG_WIN32 1" >> $TMPH
849 echo "CONFIG_WIN32=yes" >> config.mak
850 echo "#define __MINGW32__ 1" >> $TMPH
851 echo "__MINGW32__=1" >> config.mak
854 if test "$cygwin" = "yes" ; then
855 # setup correct exesuffix
856 echo "CONFIG_WIN32=yes" >> config.mak
859 if test "$os2" = "yes" ; then
860 echo "#define CONFIG_OS2 1" >> $TMPH
861 echo "CONFIG_OS2=yes" >> config.mak
864 if test "$darwin" = "yes"; then
865 echo "#define CONFIG_DARWIN 1" >> $TMPH
866 echo "CONFIG_DARWIN=yes" >> config.mak
869 if test "$_malloc_h" = "yes" ; then
870 echo "#define HAVE_MALLOC_H 1" >> $TMPH
872 echo "#undef HAVE_MALLOC_H" >> $TMPH
875 if test "$_memalign" = "yes" ; then
876 echo "#define HAVE_MEMALIGN 1" >> $TMPH
878 echo "#undef HAVE_MEMALIGN" >> $TMPH
881 if test "$netserver" = "yes" ; then
882 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
883 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
886 if test "$need_inet_aton" = "yes" ; then
887 echo "NEED_INET_ATON=yes" >> config.mak
890 if test "$simpleidct" = "yes" ; then
891 echo "#define SIMPLE_IDCT 1" >> $TMPH
894 if test "$ffserver" = "yes" ; then
895 echo "#define CONFIG_FFSERVER 1" >> $TMPH
896 echo "CONFIG_FFSERVER=yes" >> config.mak
899 if test "$risky" = "yes" ; then
900 echo "#define CONFIG_RISKY 1" >> $TMPH
901 echo "CONFIG_RISKY=yes" >> config.mak
904 echo "#define restrict $_restrict" >> $TMPH
906 # build tree in object directory if source path is different from current one
907 if test "$source_path_used" = "yes" ; then
908 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
909 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
910 FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
911 for dir in $DIRS ; do
915 ln -sf $source_path/$f $f
918 echo "SRC_PATH=$source_path" >> config.mak
920 diff $TMPH config.h >/dev/null 2>&1
921 if test $? -ne 0 ; then
924 echo "config.h is unchanged"
927 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH