--- trunk/xvidcore/build/generic/configure.in 2004/03/22 22:36:25 1382 +++ trunk/xvidcore/build/generic/configure.in 2008/12/04 18:30:36 1845 @@ -1,28 +1,32 @@ dnl ========================================================================== dnl -dnl Autoconf script for XviD +dnl Autoconf script for Xvid dnl -dnl Copyright(C) 2003 Edouard Gomez +dnl Copyright(C) 2003-2004 Edouard Gomez dnl dnl ========================================================================== -AC_INIT([XviD], [1.0.0 rc3], [xvid-devel@xvid.org]) +AC_PREREQ([2.50]) + +AC_INIT([Xvid], [1.3.0], [xvid-devel@xvid.org]) AC_CONFIG_SRCDIR(configure.in) dnl Do not forget to increase that when needed. API_MAJOR="4" -API_MINOR="0" +API_MINOR="3" -dnl NASM version requirement -minimum_nasm_patch_version=34 +dnl NASM/YASM version requirement +minimum_yasm_minor_version=7 +minimum_nasm_minor_version=0 +minimum_nasm_major_version=2 nasm_prog="nasm" +yasm_prog="yasm" dnl Default CFLAGS -- Big impact on overall speed our_cflags_defaults="-Wall" our_cflags_defaults="$our_cflags_defaults -O2" our_cflags_defaults="$our_cflags_defaults -fstrength-reduce" our_cflags_defaults="$our_cflags_defaults -finline-functions" -our_cflags_defaults="$our_cflags_defaults -freduce-all-givs" our_cflags_defaults="$our_cflags_defaults -ffast-math" our_cflags_defaults="$our_cflags_defaults -fomit-frame-pointer" @@ -159,12 +163,14 @@ i[[3456]]86) AC_MSG_RESULT(ia32) ARCHITECTURE="IA32" + ;; + x86_64) + AC_MSG_RESULT(x86_64) + ARCHITECTURE="X86_64" ;; powerpc) AC_MSG_RESULT(PowerPC) - dnl ATM the ppc port is out of date - dnl ARCHITECTURE="PPC" - ARCHITECTURE="GENERIC" + ARCHITECTURE="PPC" ;; ia64) AC_MSG_RESULT(ia64) @@ -194,7 +200,7 @@ BUS="64BIT" ;; *) - AC_MSG_ERROR([XviD supports only 32/64 bit architectures]) + AC_MSG_ERROR([Xvid supports only 32/64 bit architectures]) ;; esac @@ -260,7 +266,14 @@ SPECIFIC_CFLAGS="" PRE_SHARED_LIB="" case "$target_os" in - *bsd*|linux*|irix*|solaris*) + linux*|solaris*) + AC_MSG_RESULT([ok]) + STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" + SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION).\$(API_MAJOR).\$(API_MINOR)" + SPECIFIC_LDFLAGS="-Wl,-soname,libxvidcore.\$(SHARED_EXTENSION).\$(API_MAJOR) -shared -Wl,--version-script=libxvidcore.ld -lc -lm" + SPECIFIC_CFLAGS="-fPIC" + ;; + *bsd*|irix*) AC_MSG_RESULT([ok]) STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION).\$(API_MAJOR).\$(API_MINOR)" @@ -297,7 +310,7 @@ ;; *) AC_MSG_RESULT([Unknown Platform (Using default -shared -lc -lm)]) - STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" + STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)" SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION)" SPECIFIC_LDFLAGS="" SPECIFIC_CFLAGS="" @@ -325,81 +338,201 @@ dnl IA32 dnl -if test "$ARCHITECTURE" = "IA32" ; then +if test "$ARCHITECTURE" = "IA32" -o "$ARCHITECTURE" = "X86_64" ; then dnl - dnl Checking nasm existence + dnl Checking for nasm compatible programs dnl - AC_CHECK_PROG([ac_nasm], [$nasm_prog], [yes], [no], , [yes]) - if test "$ac_nasm" = "yes" ; then - - dnl - dnl Checking nasm patch version - dnl - AC_MSG_CHECKING([for nasm patch version]) - nasm_patch=`nasm -r | cut -d '.' -f 3 | cut -d ' ' -f 1` - if test -z $nasm_patch ; then - nasm_patch=-1 - fi - AC_MSG_RESULT([$nasm_patch]) + found_nasm_comp_prog="no" + chosen_asm_prog="" - if test "$nasm_patch" -lt "$minimum_nasm_patch_version" ; then - AC_MSG_WARN([nasm patch version too old - Compiling generic sources only]) - ARCHITECTURE="GENERIC" - else + dnl Check for yasm first + AC_CHECK_PROG([ac_yasm], [$yasm_prog], [yes], [no], , [yes]) + if test "$ac_yasm" = "yes" ; then + dnl + dnl Checking yasm version + dnl + AC_MSG_CHECKING([for yasm version]) + yasm_minor=`$yasm_prog --version | cut -d '.' -f 2 | cut -d ' ' -f 1` + if test -z $yasm_minor ; then + yasm_minor=-1 + fi + AC_MSG_RESULT([$yasm_minor]) - dnl - dnl Checking nasm format - win32 or elf - dnl - AC_MSG_CHECKING([for nasm object format]) - case "$target_os" in - *bsd*|linux*|beos|irix*|solaris*) - AC_MSG_RESULT([elf]) - NASM_FORMAT="elf" - PREFIX="" - ;; - [[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]*|mingw32*|mks*) - AC_MSG_RESULT([win32]) - NASM_FORMAT="win32" - PREFIX="-DPREFIX" - ;; - esac - - AS=nasm - AFLAGS="-I\$(= 0.6.2 should be ok + dnl But I'm too lazy to check also the patch version... + if test "$yasm_minor" -lt "$minimum_yasm_minor_version" ; then + AC_MSG_WARN([yasm version is too old]) + else + found_nasm_comp_prog="yes" + chosen_asm_prog="$yasm_prog" fi + fi - else - AC_MSG_WARN([nasm not found - Compiling generic sources only]) - ARCHITECTURE="GENERIC" + dnl Check for nasm (not buggy version) + if test "$found_nasm_comp_prog" = "no" ; then + AC_CHECK_PROG([ac_nasm], [$nasm_prog], [yes], [no], , [yes]) + if test "$ac_nasm" = "yes" ; then + dnl + dnl Checking nasm version + dnl + AC_MSG_CHECKING([for nasm version]) + nasm_minor=`$nasm_prog -v | cut -d '.' -f 2 | cut -d ' ' -f 1` + nasm_major=`$nasm_prog -v | cut -d '.' -f 1 | cut -d ' ' -f 3` + if test -z $nasm_minor ; then + nasm_minor=-1 + fi + if test -z $nasm_major ; then + nasm_major=-1 + fi + AC_MSG_RESULT([$nasm_major]) + + dnl need nasm 2.x for SSE3/4 and X86_64 + if test "$nasm_major" -lt "$minimum_nasm_major_version" ; then + AC_MSG_WARN([nasm version is too old]) + else + found_nasm_comp_prog="yes" + chosen_asm_prog="$nasm_prog" + fi + fi fi + dnl + dnl Ok now sort what object format we must use + dnl + if test "$found_nasm_comp_prog" = "yes" ; then + AC_MSG_CHECKING([for asm object format]) + case "$target_os" in + *bsd*|linux*|beos|irix*|solaris*) + if test "$ARCHITECTURE" = "X86_64" ; then + AC_MSG_RESULT([elf64]) + NASM_FORMAT="elf64" + else + AC_MSG_RESULT([elf]) + NASM_FORMAT="elf" + fi + MARK_FUNCS="-DMARK_FUNCS" + PREFIX="" + ;; + [[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]*|mingw32*|mks*) + if test "$ARCHITECTURE" = "X86_64" ; then + AC_MSG_RESULT([win64]) + NASM_FORMAT="win64" + else + AC_MSG_RESULT([win32]) + NASM_FORMAT="win32" + fi + PREFIX="-DWINDOWS" + MARK_FUNCS="" + ;; + *darwin*) + AC_MSG_RESULT([macho]) + NASM_FORMAT="macho" + PREFIX="-DPREFIX" + MARK_FUNCS="" + ;; + esac + + AS="$chosen_asm_prog" + ASSEMBLY_EXTENSION="asm" + AFLAGS="-I\$( before using intrincic +dnl - define vectors with vec = {0,0,0,0} +dnl +dnl * The compile time option will be "injected" into SPECIFIC_CFLAGS variable +dnl * The need for altivec.h will also be injected into SPECIFIC_CFLAGS through +dnl a -DHAVE_ALTIVEC_H +dnl * The vector definition is handled in portab.h thx to +dnl HAVE_PARENTHESES/BRACES_ALTIVEC_DECL +dnl +PPC_ALTIVEC_SOURCES="" if test "$ARCHITECTURE" = "PPC" ; then AS="\$(CC)" - AFLAGS="-c" - ASSEMBLY_EXTENSION="s" - ASSEMBLY_SOURCES="SRC_PPC" - AC_MSG_CHECKING([for Altivec support]) - cat > conftest.S << EOF - .text - vxor 0,0,0 + AFLAGS="" + ASSEMBLY_EXTENSION=".s" + ASSEMBLY_SOURCES="" + + AC_MSG_CHECKING([for altivec.h]) +cat > conftest.c << EOF +#include +int main() { return(0); } EOF - if $CC -c conftest.S 2>/dev/null 1>/dev/null ; then + if $CC -faltivec -c conftest.c 2>/dev/null 1>/dev/null || \ + $CC -maltivec -mabi=altivec -c conftest.c 2>/dev/null 1>/dev/null ; then AC_MSG_RESULT(yes) - SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -DARCH_IS_PPC_ALTIVEC" - ASSEMBLY_SOURCES="SRC_ALTIVEC" + SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -DHAVE_ALTIVEC_H" + TEMP_ALTIVEC="-DHAVE_ALTIVEC_H" else AC_MSG_RESULT(no) + TEMP_ALTIVEC="" fi + + AC_MSG_CHECKING([for Altivec compiler support]) +cat > conftest.c << EOF +#ifdef HAVE_ALTIVEC_H +#include +#endif + +int main() +{ + vector unsigned int vartest2 = (vector unsigned int)(0); + vector unsigned int vartest3 = (vector unsigned int)(1); + vartest2 = vec_add(vartest2, vartest3); + return(0); +} +EOF + if $CC $TEMP_ALTIVEC -faltivec -c conftest.c 2>/dev/null 1>/dev/null ; then + AC_MSG_RESULT([yes (Apple)]) + SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -faltivec -DHAVE_ALTIVEC_PARENTHESES_DECL $TEMP_ALTIVEC" + PPC_ALTIVEC_SOURCES="SRC_PPC_ALTIVEC" + else +cat > conftest.c << EOF +#ifdef HAVE_ALTIVEC_H +#include +#endif + +int main() +{ + vector unsigned int vartest2 = (vector unsigned int){0}; + vector unsigned int vartest3 = (vector unsigned int){1}; + vartest2 = vec_add(vartest2, vartest3); + return(0); +} +EOF + if $CC $TEMP_ALTIVEC -maltivec -mabi=altivec -c conftest.c 2>/dev/null 1>/dev/null ; then + AC_MSG_RESULT([yes (GNU)]) + SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_BRACES_DECL $TEMP_ALTIVEC" + PPC_ALTIVEC_SOURCES="SRC_PPC_ALTIVEC" + else + AC_MSG_RESULT([no (ppc support won't be compiled in)]) + dnl Only C code can be compiled :-( + ARCHITECTURE="GENERIC" + fi + fi + rm -f conftest.* fi @@ -439,10 +572,34 @@ AC_CHECK_HEADERS( stdio.h \ signal.h \ + stdlib.h \ + string.h \ + assert.h \ + math.h \ , , AC_MSG_ERROR(Missing header file)) dnl ========================================================================== dnl +dnl Check for pthread +dnl +dnl ========================================================================== + +AC_CHECK_HEADER( + pthread.h, + AC_CHECK_LIB( + pthread, + pthread_create, + AC_CHECK_LIB( + pthread, + pthread_join, + SPECIFIC_CFLAGS="$SPECIFIC_CFLAGS -DHAVE_PTHREAD" + SPECIFIC_LDFLAGS="$SPECIFIC_LDFLAGS -lpthread", + AC_MSG_WARN(Pthread not supported. No SMP support)), + AC_MSG_WARN(Pthread not supported. No SMP support)), + AC_MSG_WARN(Pthread not supported. No SMP support)) + +dnl ========================================================================== +dnl dnl Now we can set CFLAGS if needed dnl dnl ========================================================================== @@ -467,6 +624,48 @@ fi dnl ========================================================================== +dnl Some gcc flags can't be used for gcc >= 3.4.0 +dnl ========================================================================== + +if test "$GCC" = "yes" ; then +cat << EOF > test.c +#include +int main(int argc, char **argv) +{ + if (*argv[[1]] == 'M') { + printf("%d", __GNUC__); + } + if (*argv[[1]] == 'm') { + printf("%d", __GNUC_MINOR__); + } + return 0; +} +EOF + $CC -o gcc-ver test.c + + GCC_MAJOR=`./gcc-ver M` + GCC_MINOR=`./gcc-ver m` + + rm -f test.c + rm -f gcc-ver + + # GCC 4.x + if test "${GCC_MAJOR}" -gt 3 ; then + CFLAGS=`echo $CFLAGS | sed s,"-mcpu","-mtune",g` + CFLAGS=`echo $CFLAGS | sed s,'-freduce-all-givs','',g` + CFLAGS=`echo $CFLAGS | sed s,'-fmove-all-movables','',g` + CFLAGS=`echo $CFLAGS | sed s,'-fnew-ra','',g` + CFLAGS=`echo $CFLAGS | sed s,'-fwritable-strings','',g` + fi + + # GCC 3.4.x + if test "${GCC_MAJOR}" -eq 3 && test "${GCC_MINOR}" -gt 3 ; then + CFLAGS=`echo $CFLAGS | sed s,"-mcpu","-mtune",g` + fi +fi + + +dnl ========================================================================== dnl dnl Substitions dnl @@ -490,6 +689,7 @@ AC_SUBST(SPECIFIC_LDFLAGS) AC_SUBST(SPECIFIC_CFLAGS) AC_SUBST(DCT_IA64_SOURCES) +AC_SUBST(PPC_ALTIVEC_SOURCES) AC_SUBST(RANLIB) AC_SUBST(API_MAJOR) AC_SUBST(API_MINOR)