# HG changeset patch # User attila # Date 1065308764 0 # Node ID 48b7d7aa444d2e09438191aad68386e7e33ee833 # Parent fae1fe725886431dd069b361692d84061e01a0ed configure altivec patch by Magnus Damm * CC is not checked for Altivec support (see above). The patch adds checks for FSF-style flags and Darwin-style flags. The check is performed regardless of the gcc version. * Disabling of Altivec. --disable-altivec is broken today if /proc/cpuinfo shows that your cpu supports altivec. The patch takes care of that. * "GCC & CPU optimization abilities" always show that it is optimizing for the cpu configure is running on, it should show the optimization that is enabled for gcc instead. Cosmetic change only, but confusing as it is today IMHO. * Runtime CPU-detection now enables altivec for powerpc. Now with the patch it should be possible to use --enable-altivec, --disable-altivec, --enable-runtime-cpudetection regardless of powerpc cpu type. The configure script handles altivec support in the following order: 1. Altivec is enabled by default if your cpu supports it. 2. --enable-runtime-cpudetection will enable altivec support. 3. If you have forced altivec on/off with --enable-altivec/--disable-altivec, then your selection will override the previous altivec configuration. 4. If altivec is enabled but the compiler doesn't support it, altivec gets turned off. diff -r fae1fe725886 -r 48b7d7aa444d configure --- a/configure Sat Oct 04 22:54:17 2003 +0000 +++ b/configure Sat Oct 04 23:06:04 2003 +0000 @@ -833,26 +833,29 @@ proc='' _march='' _mcpu='' + _optimizing='' _altivec=no - _altivec_gcc_flags='' echocheck "CPU type" if linux && test -n "$_cpuinfo"; then proc=`$_cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -b 2- | head -1` if test -n "`$_cpuinfo | grep altivec`"; then _altivec=yes - _altivec_gcc_flags='-maltivec -mabi=altivec' fi fi if darwin ; then if [ `sysctl -n hw.vectorunit` -eq 1 ]; then _altivec=yes - _altivec_gcc_flags='-faltivec' fi fi - echores "$proc" + if test "$_altivec" = yes; then + echores "$proc altivec" + else + echores "$proc" + fi echocheck "GCC & CPU optimization abilities" + if test -n "$proc"; then case "$proc" in 601) _march='-mcpu=601' _mcpu='-mtune=601' ;; @@ -872,11 +875,14 @@ esac fi fi - echores "$proc" - - _optimizing="$proc" - - _mcpu="$_mcpu $_altivec_gcc_flags" + + if test -n "$_mcpu"; then + _optimizing=`echo $_mcpu | cut -c 8-` + echores "$_optimizing" + else + echores "none" + fi + ;; alpha) @@ -987,7 +993,9 @@ _sse2=yes _mtrr=yes fi - _optimizing="Runtime CPU-Detection enabled" + if ppc; then + _altivec=yes + fi fi if x86 && test "$_runtime_cpudetection" = no ; then @@ -1604,6 +1612,87 @@ fi fi +if ppc ; then + + # check if altivec is supported by the compiler, and how to enable it + + _altivec_gcc_flags='' + + if test "$_altivec" = yes -o "$_runtime_cpudetection" = yes ; then + echocheck "GCC altivec support" + + p='' + cat > $TMPC << EOF +int main() { + return 0; +} +EOF + FSF_flags='-maltivec -mabi=altivec' + Darwin_flags='-faltivec' + + if test -z "$p"; then + cc_check $FSF_flags && p='FSF' + fi + if test -z "$p"; then + cc_check $Darwin_flags && p='Darwin' + fi + + case $p in + FSF) _altivec_gcc_flags="$FSF_flags" _altivec=yes ;; + Darwin) _altivec_gcc_flags="$Darwin_flags" _altivec=yes ;; + *) _altivec=no ;; + esac + + if test -z "$p"; then + p=none + else + p="$p-style ($_altivec_gcc_flags)" + fi + + echores "$p" + fi + + # check if should be included + + _def_altivec_h='#undef HAVE_ALTIVEC_H' + _def_altivec='#undef HAVE_ALTIVEC' + + if test "$_altivec" = yes ; then + echocheck "altivec.h" + cat > $TMPC << EOF +#include +int main(void) { return 0; } +EOF + _have_altivec_h=no + cc_check $_altivec_gcc_flags && _have_altivec_h=yes + if test "$_have_altivec_h" = yes ; then + _def_altivec_h='#define HAVE_ALTIVEC_H 1' + _def_altivec='#define HAVE_ALTIVEC 1' + fi + echores "$_have_altivec_h" + fi + + # disable runtime cpudetection if + # - we cannot generate altivec code + # - altivec is disabled by the user + + if test "$_runtime_cpudetection" = yes -a "$_altivec" = no ; then + _runtime_cpudetection=no + fi + + # show that we are optimizing for altivec (if enabled and supported) + + if test "$_runtime_cpudetection" = no -a "$_altivec" = yes ; then + _optimizing="$_optimizing altivec" + fi + + # if altivec is enabled, make sure the correct flags turn up in CFLAGS + + if test "$_altivec" = yes ; then + _mcpu="$_mcpu $_altivec_gcc_flags" + fi +fi + _def_mmx='#undef HAVE_MMX' test "$_mmx" = yes && _def_mmx='#define HAVE_MMX 1' _def_mmx2='#undef HAVE_MMX2' @@ -1616,9 +1705,6 @@ test "$_sse" = yes && _def_sse='#define HAVE_SSE 1' _def_sse2='#undef HAVE_SSE2' test "$_sse2" = yes && _def_sse2='#define HAVE_SSE2 1' -_def_altivec='#undef HAVE_ALTIVEC' -test "$_altivec" = yes && _def_altivec='#define HAVE_ALTIVEC 1' - # Checking kernel version... if x86 && linux ; then @@ -1796,6 +1882,7 @@ echocheck "runtime cpudetection" if test "$_runtime_cpudetection" = yes ; then + _optimizing="Runtime CPU-Detection enabled" _def_runtime_cpudetection='#define RUNTIME_CPUDETECT 1' else _def_runtime_cpudetection='#undef RUNTIME_CPUDETECT' @@ -2068,24 +2155,6 @@ fi echores "$_mman" -if ppc && test "$_altivec" = "yes" ; then -echocheck "altivec.h" -cat > $TMPC << EOF -#include -int main(void) { return 0; } -EOF -_have_altivec_h=no -cc_check $_altivec_gcc_flags && _have_altivec_h=yes -if test "$_have_altivec_h" = yes ; then - _def_altivec_h='#define HAVE_ALTIVEC_H 1' -else - _def_altivec_h='#undef HAVE_ALTIVEC_H' -fi -echores "$_have_altivec_h" -else - _def_altivec_h='#undef HAVE_ALTIVEC_H' -fi - echocheck "dynamic loader" cat > $TMPC << EOF #include