Index: configure =================================================================== --- configure £¨ÐÞ¶©°æ 21606£© +++ configure £¨¹¤×÷¿½±´£© @@ -806,6 +806,12 @@ } fi +if test "$_runtime_cpudetection" = yes ; then + if not x86 && not x86_64 && not ppc ; then + echo "Runtime CPU detection only works for x86, x86-64 and ppc!" + $_runtime_cpudetection=no + fi +fi # --- # now that we know what compiler should be used for compilation, try to find @@ -832,14 +838,16 @@ elif aix; then # use 'lsattr' on AIX _cpuinfo="lsattr -E -l proc0 -a type" -elif x86 || x86_64; then +elif (x86 || x86_64) && test "$_runtime_cpudetection" = no && + test -z "$_target" ; then # all other OSes try to extract CPU information from a small helper # program TOOLS/cpuinfo instead $_cc -o TOOLS/cpuinfo TOOLS/cpuinfo.c _cpuinfo="TOOLS/cpuinfo" fi -if x86 || x86_64 ; then +if (x86 || x86_64) && test "$_runtime_cpudetection" = no && + test -z "$_target" ; then # gather more CPU information pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | _head 1` pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | _head 1` @@ -874,6 +882,7 @@ _target_arch="TARGET_ARCH_X86_32 = yes" + if test "$_runtime_cpudetection" = no && test -z "$_target" ; then case "$pvendor" in AuthenticAMD) case "$pfamily" in @@ -981,6 +990,7 @@ *) proc=i586 iproc=586 ;; esac + fi # check that gcc supports our CPU, if not, fall back to earlier ones # LGB: check -mcpu and -march swithing step by step with enabling @@ -998,7 +1008,7 @@ cat > $TMPC << EOF int main(void) { return 0; } EOF - if test "$_runtime_cpudetection" = no ; then + if test "$_runtime_cpudetection" = no && test -z "$_target" ; then if test "$proc" = "k8"; then cc_check -march=$proc $cpuopt=$proc || proc=athlon-xp fi @@ -1052,18 +1062,19 @@ _mcpu="$cpuopt=$proc" _optimizing="$proc" fi - else # if test "$_runtime_cpudetection" = no + elif test -z "$_target" ; then # runtime cpu detection + proc="generic" # i686 is probably the most common CPU - optimize for it _mcpu="$cpuopt=i686" # at least i486 required, for bswap instruction _march="-march=i486" + iproc=486 cc_check $_mcpu || _mcpu="" cc_check $_march $_mcpu || _march="" - fi + else # --target used ## Gabucino : --target takes effect here (hopefully...) by overwriting ## autodetected mcpu/march parameters - if test "$_target" ; then # TODO: it may be a good idea to check GCC and fall back in all cases if test "$host_arch" = "i586-i686"; then _march="-march=i586" @@ -1110,6 +1121,7 @@ else cpuopt=-mcpu fi + if test "$_runtime_cpudetection" = no ; then case "$pvendor" in AuthenticAMD) proc=k8;; @@ -1125,6 +1137,7 @@ *) proc=error;; esac + fi echocheck "GCC & CPU optimization abilities" cat > $TMPC << EOF @@ -1164,6 +1177,7 @@ # x86-64 is an undocumented option, an intersection of k8 and nocona. _march="-march=x86-64" _mcpu="$cpuopt=x86-64" + proc="generic" cc_check $_mcpu || _mcpu="" cc_check $_march $_mcpu || _march="" fi @@ -1464,6 +1478,10 @@ if test "$_runtime_cpudetection" = yes ; then if x86; then _cmov=no + elif x86_64 ; then + _cmov=yes + fi + if x86 || x86_64 ; then _mmx=yes _3dnow=yes _3dnowext=yes @@ -1477,7 +1495,7 @@ fi fi -if x86 && test "$_runtime_cpudetection" = no ; then +if x86 && test "$_runtime_cpudetection" = no && test -z "$_target" ; then extcheck() { if test "$1" = yes ; then echocheck "kernel support of $2" @@ -2141,17 +2159,18 @@ ;; --enable-sse) _sse=yes ;; - --disable-sse) _sse=no ;; + --disable-sse) test "$_runtime_cpudetection" = "no" && _sse=no ;; --enable-sse2) _sse2=yes ;; - --disable-sse2) _sse2=no ;; + --disable-sse2) test "$_runtime_cpudetection" = "no" && _sse2=no ;; --enable-mmxext) _mmxext=yes ;; - --disable-mmxext) _mmxext=no ;; + --disable-mmxext) test "$_runtime_cpudetection" = "no" && _mmxext=no ;; --enable-3dnow) _3dnow=yes ;; - --disable-3dnow) _3dnow=no _3dnowext=no ;; + --disable-3dnow) + test "$_runtime_cpudetection" = "no" && _3dnow=no _3dnowext=no ;; --enable-3dnowext) _3dnow=yes _3dnowext=yes ;; - --disable-3dnowext) _3dnowext=no ;; - --enable-cmov) _cmov=yes ;; - --disable-cmov) _cmov=no ;; + --disable-3dnowext) test "$_runtime_cpudetection" = "no" && _3dnowext=no ;; + --enable-cmov) test "$_runtime_cpudetection" = "no" && _cmov=yes ;; + --disable-cmov) test "$_runtime_cpudetection" = "no" && _cmov=no ;; --enable-altivec) _altivec=yes ;; --disable-altivec) _altivec=no ;; --enable-armv5te) _armv5te=yes ;; @@ -2160,6 +2179,7 @@ --disable-iwmmxt) _iwmmxt=no ;; --enable-mmx) _mmx=yes ;; --disable-mmx) # 3Dnow! and MMX2 require MMX + test "$_runtime_cpudetection" = "no" && _3dnow=no _3dnowext=no _mmx=no _mmxext=no ;; --enable-win32) _win32=yes ;;