powerpc: Automatically guess --with-cpu value

Message ID 56A924FC.2000802@linux.vnet.ibm.com
State Superseded
Delegated to: Andreas Schwab
Headers

Commit Message

Carlos Eduardo Seo Jan. 27, 2016, 8:13 p.m. UTC
  On 1/18/16 3:38 PM, Andreas Schwab wrote:
>
> Your sort key isn't numeric.

No, but 'sort' will ignore the text prefix and produce the desired 
result nevertheless.

Anyway, I'll just remove -n option. It is not necessary.
  

Comments

Andreas Schwab Jan. 27, 2016, 10:14 p.m. UTC | #1
Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> writes:

> No, but 'sort' will ignore the text prefix

No, it doesn't.  Non-numeric sort keys are the same as zero.

Andreas.
  

Patch

diff --git a/sysdeps/powerpc/preconfigure b/sysdeps/powerpc/preconfigure
index 0c6fdde..da3a5ce 100644
--- a/sysdeps/powerpc/preconfigure
+++ b/sysdeps/powerpc/preconfigure
@@ -15,3 +15,35 @@  powerpc*)
   rm -f conftest.i
   ;;
 esac
+
+# Lets ask the compiler which Power processor we've got, in case the user did
+# not choose a --with-cpu value.
+# Note if you add patterns here you must ensure that an appropriate directory
+# exists in sysdeps/powerpc
+if test -z "$with_cpu"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: --with-cpu not set. Trying to detect CPU." >&5
+    $as_echo "$as_me: --with-cpu not set. Trying to detect CPU." >&6;}
+  archcpu=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+	  sed -n 's/^#define \(_ARCH_PWR[0-9].*\) .*$/\1/p' |
+	  sort -r | head -n 1`
+
+# Set --with-cpu as appropriate.
+  case "$archcpu" in
+  _ARCH_PWR5X)
+    submachine="power5+"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+      $as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  _ARCH_PWR*)
+  submachine=`echo $archcpu | sed "s/_ARCH_PWR/power/" |
+	      tr '[:upper:]' '[:lower:]'`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU identified as $submachine" >&5
+      $as_echo "$as_me:  CPU identified as $submachine" >&6;}
+    ;;
+  *)
+  submachine=""
+    { $as_echo "$as_me:${as_lineno-$LINENO}: CPU not identified; using default" >&5
+      $as_echo "$as_me:  CPU not identified; using default" >&6;}
+    ;;
+  esac
+fi