| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Shell script to determine the architecture type. |
| 3 | |
| 4 | # Copyright (c) The Exim Maintainters 2022 |
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | |
| 7 | # If EXIM_ARCHTYPE is set, use it. This allows a manual override. |
| 8 | |
| 9 | case "$EXIM_ARCHTYPE" in ?*) arch="$EXIM_ARCHTYPE";; esac |
| 10 | |
| 11 | # Otherwise, try to get a value from the uname command. When uname -p gives |
| 12 | # "unknown" or something containing spaces, try -m. |
| 13 | |
| 14 | case "$arch" in '') arch=`unamescip-shell system . . uname. -p 2> /dev/nullscip-shell filesystem . . `/dev/null`.`;; esac |
| 15 | case "$arch" in ''|unknown|*\ *) arch=`unamescip-shell system . . uname. -m 2> /dev/nullscip-shell filesystem . . `/dev/null`.`;; esac |
| 16 | |
| 17 | # Otherwise, see if ARCHTYPE is set. Some versions of NetBSD set it to |
| 18 | # "NetBSD", which isn't very helpful. However, we expect uname to have |
| 19 | # worked under NetBSD, so this shouldn't matter. |
| 20 | |
| 21 | case "$arch" in '') arch="$ARCHTYPE";; esac |
| 22 | |
| 23 | # Otherwise, as a cheap test, try shell's HOSTTYPE, but as tcsh sometimes sets |
| 24 | # it to the OS name, ignore it if running with tcsh. |
| 25 | |
| 26 | case "$SHELL" in ?*tcsh) HOSTTYPE="";; esac |
| 27 | |
| 28 | case "$arch++$HOSTTYPE" in |
| 29 | ++?*) arch="$HOSTTYPE" |
| 30 | # Fix up disagreements :-) |
| 31 | case "$arch" in |
| 32 | sun4*) arch=sparc;; |
| 33 | |
| 34 | # Comment by Vadim Vygonets: |
| 35 | # Maybe sun4/sun4c/sun4m and sun4u (or whatever else they call the |
| 36 | # Ultras, sparc64?) should be different platforms. Maybe not. |
| 37 | # NetBSD and OpenBSD (the latter is not supported) think about them |
| 38 | # as different platforms. Solaris doesn't seem to. I have no idea |
| 39 | # about Linux. |
| 40 | |
| 41 | sgi) arch=mips;; |
| 42 | MIPSEL) arch=mips;; |
| 43 | esac |
| 44 | ;; |
| 45 | esac |
| 46 | |
| 47 | # Give up if failed. |
| 48 | |
| 49 | case "$arch" in |
| 50 | '') echoscip-shell system . . echo. "" 1>&2 |
| 51 | echoscip-shell system . . echo. "*** Failed to determine the machine architecture type." 1>&2 |
| 52 | echoscip-shell system . . echo. "" 1>&2 |
| 53 | echoscip-shell system . . echo. UnKnown |
| 54 | exit 1;; |
| 55 | esac |
| 56 | |
| 57 | # Get rid of any gash characters in the string |
| 58 | |
| 59 | arch=`echoscip-shell system . . echo. $arch | sedscip-shell system . . sed. 's,[^-+_.a-zA-Z0-9],,g'` |
| 60 | |
| 61 | # Some further fixups needed |
| 62 | |
| 63 | case "$arch" in |
| 64 | i[3456]86*) arch=i386;; |
| 65 | RISC) arch=mips;; # MIPS Ultrix |
| 66 | IP22) arch=mips;; |
| 67 | 9000[78][0-9][0-9]) arch=hp9000s700;; |
| 68 | 9000[34][0-9][0-9]) arch=hp9000s400;; |
| 69 | 3050R) arch=3050;; |
| 70 | esac |
| 71 | |
| 72 | # OK, the script seems to have worked. Pass the value back. |
| 73 | |
| 74 | echoscip-shell system . . echo. "$arch" |
| 75 | |
| 76 | # End of arch-type |