* guess-systype: New shell script. Attempts to guess the
authorPer Bothner <per@bothner.com>
Wed, 20 Jan 1993 01:20:29 +0000 (01:20 +0000)
committerPer Bothner <per@bothner.com>
Wed, 20 Jan 1993 01:20:29 +0000 (01:20 +0000)
canonical host name of the executing host.
Only a few hosts are supported so far.
* configure:  Call guess-systype if no host is specified.

.Sanitize
guess-systype [new file with mode: 0755]

index ce7c344..ebe76d5 100644 (file)
--- a/.Sanitize
+++ b/.Sanitize
@@ -62,6 +62,7 @@ glob
 gprof
 grep
 groff
+guess-systype
 h8300sim
 include
 ispell
diff --git a/guess-systype b/guess-systype
new file mode 100755 (executable)
index 0000000..3d2bbce
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# This script attempts to guess a canonical system name
+# similar to the output of config.sub.
+# If it succeeds, it prints the system name on stdout, and exits with 0.
+# Otherwise, it prints an error message on stderr, and exits with 1.
+
+# The plan is that this can be called by configure scripts if you don't
+# specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list;
+# please add others (but try to keep the structure clean).
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    sun4*:SunOS:5.*:*)
+       echo sparc-sun-solaris
+       exit 0 ;;
+    sun4*:SunOS:*:*)
+       echo sparc-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    *:IRIX:*:*)
+       echo mips-sgi-irix${UNAME_RELEASE}
+       exit 0 ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit 0 ;;
+esac
+
+# uname didn't exit or help; try another approach.
+
+cat >dummy.c <<EOF
+main()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+    exit(1);
+#else
+    printf("m68k-sony-newsos\n");
+#endif
+#endif
+}
+EOF
+
+${CC-cc} dummy.c -o dummy && dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
+
+echo "(No uname comamnd or uname output not recognized." 1>&2
+echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+echo "Unable to guess system type)" 1>&2
+
+exit 1
+