If we get to the bottom of the big switch in config.guess without
having a guess, we try two things, in this order:

- Compiling and running a C program that knows about a bunch of
  really old systems that did not have a uname command.

- A specific test for Apollo systems, which doesn’t require a C
  compiler, but does expect certain environment variables to be set.

I *think* it is inappropriate to run the C program in any case where
a uname command is available, but we are doing it unconditionally.
This means, if you try to run config.guess on a system that *does*
have uname, *doesn’t* have a C compiler, and is unrecognized because
it’s too *new* for your copy of config.guess, the revised diagnostic
mode from the previous patch will tell you to install a C compiler
even though that won’t help.

Address this by, first, moving the Apollo check above the C program
and having it succeed only if the expected environment variables are
in fact set, and second, compiling and running the C program only if
all four of $UNAME_MACHINE, $UNAME_SYSTEM, $UNAME_RELEASE, $UNAME_VERSION
are equal to “unknown”.

Note that the test for unknown:unknown:unknown:unknown cannot be
combined with the big switch because some cases of the big switch
can fall through to this point without setting $GUESS.
---
 config.guess | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/config.guess b/config.guess
index d28bbe4..41b8a45 100755
--- a/config.guess
+++ b/config.guess
@@ -4,7 +4,7 @@
 
 # shellcheck disable=SC2006,SC2268 # see below for rationale
 
-timestamp='2024-05-12'
+timestamp='2024-05-13'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -1602,8 +1602,18 @@ if test "x$GUESS" != x; then
 fi
 
 # No uname command or uname output not recognized.
-set_cc_for_build
-cat > "$dummy.c" <<EOF
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo &&
+    test x"$ISP" != x &&
+    test x"$SYSTYPE" != x &&
+    { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
+# If there was no uname command, maybe the C compiler can help us.
+if test x:"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" = \
+        x:unknown:unknown:unknown:unknown; then
+    set_cc_for_build
+    cat > "$dummy.c" <<EOF
 #include <stdio.h>
 #ifdef _SEQUENT_
 #include <sys/types.h>
@@ -1731,12 +1741,10 @@ main ()
   return 1;
 }
 EOF
-
-$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
+    $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null &&
+       SYSTEM_NAME=`"$dummy"` &&
        { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+fi # no uname
 
 echo >&2 "$0: unable to guess system type
 
@@ -1825,6 +1833,7 @@ EOF
 command_uname=`(command -v uname) 2>/dev/null || echo not found`
 if [ x"$command_uname" = "xnot found" ]; then
     echo "command -v uname  = not found"
+    echo
 else
     echo "command -v uname  = $command_uname"
     cat <<EOF
@@ -1833,6 +1842,7 @@ uname -m = `"$command_uname" -m`
 uname -r = `"$command_uname" -r`
 uname -s = `"$command_uname" -s`
 uname -v = `"$command_uname" -v`
+
 EOF
 fi
 
-- 
2.43.2


Reply via email to