From 4e8e6d70a32a793ec13b4866e284e6ef913145e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 29 Mar 2010 11:08:03 +0200
Subject: [PATCH] (ABI): Detect which ABI the compiler is using. On x86_64,
 also check for __arch64__.

Rev: nettle/ChangeLog:1.68
Rev: nettle/configure.ac:1.16
---
 ChangeLog    |  5 +++++
 configure.ac | 47 ++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 37e0b628..0a0ba844 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-29  Niels M�ller  <nisse@lysator.liu.se>
+
+	* configure.ac (ABI): Detect which ABI the compiler is using.
+	On x86_64, also check for __arch64__.
+
 2010-03-28  Niels M�ller  <nisse@lysator.liu.se>
 
 	* configure.ac (asm_path): For x86_64, check if compiler is
diff --git a/configure.ac b/configure.ac
index 95a4f948..f4cfd3aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,21 +116,19 @@ if test x$enable_dependency_tracking = xyes ; then
 ])
 fi
 
-# Select assembler code
-asm_path=
+# Figure out ABI. Currently, configurable only be setting CFLAGS.
+ABI=standard
+
 case "$host_cpu" in
-  [i?86* | k[5-8]* | pentium* | athlon])
-    asm_path=x86
-    ;;
   [x86_64 | amd64])
     AC_TRY_COMPILE([
-#if defined(__i386__)
-#error 32-bit x86
+#if defined(__x86_64__) || defined(__arch64__)
+#error 64-bit x86
 #endif
     ], [], [
-      asm_path=x86_64
+      ABI=32
     ], [
-      asm_path=x86
+      ABI=64
     ])
     ;;
   *sparc*)
@@ -139,11 +137,38 @@ case "$host_cpu" in
 #error 64-bit sparc
 #endif
     ], [], [
-      asm_path=sparc32
+      ABI=32
     ], [
-      asm_path=sparc64
+      ABI=64
     ])
     ;;
+esac
+
+if test "x$ABI" != xstandard ; then
+  AC_MSG_NOTICE([Compiler uses $ABI-bit ABI. To change, set CFLAGS.])
+  AC_MSG_NOTICE([You may want to set libdir!])
+fi
+
+# Select assembler code
+asm_path=
+case "$host_cpu" in
+  [i?86* | k[5-8]* | pentium* | athlon])
+    asm_path=x86
+    ;;
+  [x86_64 | amd64])
+    if test "x$ABI" = 64 ; then
+      asm_path=x86_64
+    else
+      asm_path=x86
+    fi
+    ;;
+  *sparc*)
+    if test "x$ABI" = 64 ; then
+      asm_path=sparc64
+    else
+      asm_path=sparc32
+    fi
+    ;;
   *)
     enable_assembler=no
     ;;
-- 
GitLab