about summary refs log tree commit diff
path: root/configure.ac
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-11-16T20·39+0000
committerLudovic Courtès <ludo@gnu.org>2011-11-16T20·39+0000
commit45ec69cbdf7e5e7ff19d28c8f25c7f650105b253 (patch)
tree0ee53e1f6c1ea2d51a1f11400ed15eb8aaa05730 /configure.ac
parentf8e609c3413e38d403d986020079f24a2b82c063 (diff)
configure: Rely on `AC_CANONICAL_HOST' to determine the Nix system name.
This should be more robust and also plays better with
cross-compilation---it uses the host name, instead of using the build
name.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac43
1 files changed, 13 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac
index 6a1a0e913dee..6840120a4803 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,42 +5,25 @@ AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 
 AC_DEFINE_UNQUOTED(NIX_VERSION, ["$VERSION"], [Nix version.])
 
-AC_CANONICAL_HOST
-
+AC_PROG_SED
 
 # Construct a Nix system name (like "i686-linux").
+AC_CANONICAL_HOST
 AC_MSG_CHECKING([for the canonical Nix system name])
-cpu_name=$(uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' 'abcdefghijklmnopqrstuvwxyz_')
-machine_name=$(uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' 'abcdefghijklmnopqrstuvwxyz_')
-
-case $machine_name in
-    i*86)
-        machine_name=i686
-        ;;
-    x86_64)
-        machine_name=x86_64
-        ;;
-    ppc)
-        machine_name=powerpc
-        ;;
-    *)
-        if test "$cpu_name" != "unknown"; then
-            machine_name=$cpu_name
-        fi
-        ;;
-esac
-
-sys_name=$(uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' 'abcdefghijklmnopqrstuvwxyz_')
-
-case $sys_name in
-    cygwin*)
-        sys_name=cygwin
-        ;;
-esac
 
 AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
   [Platform identifier (e.g., `i686-linux').]),
-  system=$withval, system="${machine_name}-${sys_name}")
+  [system=$withval],
+  [case "$host_os" in
+     linux-gnu*)
+	# For backward compatibility, strip the `-gnu' part.
+	system="$host_cpu-linux";;
+     *)
+        # Strip the version number from names such as `gnu0.3',
+        # `darwin10.2.0', etc.
+	system="$host_cpu-`echo $host_os | "$SED" -e's/[0-9.]\+$//g'`";;
+   esac])
+
 AC_MSG_RESULT($system)
 AC_SUBST(system)
 AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier (`cpu-os')])