1c76ae52dSmrg#! /bin/sh
2c76ae52dSmrg# Configuration validation subroutine script.
325420f97Smrg#   Copyright 1992-2022 Free Software Foundation, Inc.
4c76ae52dSmrg
525420f97Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
625420f97Smrg
7de301c82Smrgtimestamp='2022-01-03'
8c76ae52dSmrg
9dff01e5aSmrg# This file is free software; you can redistribute it and/or modify it
10dff01e5aSmrg# under the terms of the GNU General Public License as published by
1125420f97Smrg# the Free Software Foundation, either version 3 of the License, or
12c76ae52dSmrg# (at your option) any later version.
13c76ae52dSmrg#
14dff01e5aSmrg# This program is distributed in the hope that it will be useful, but
15dff01e5aSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16dff01e5aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17dff01e5aSmrg# General Public License for more details.
18c76ae52dSmrg#
19c76ae52dSmrg# You should have received a copy of the GNU General Public License
208292847cSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21c76ae52dSmrg#
22c76ae52dSmrg# As a special exception to the GNU General Public License, if you
23c76ae52dSmrg# distribute this file as part of a program that contains a
24c76ae52dSmrg# configuration script generated by Autoconf, you may include it under
25dff01e5aSmrg# the same distribution terms that you use for the rest of that
26dff01e5aSmrg# program.  This Exception is an additional permission under section 7
27dff01e5aSmrg# of the GNU General Public License, version 3 ("GPLv3").
28c76ae52dSmrg
29c76ae52dSmrg
308292847cSmrg# Please send patches to <config-patches@gnu.org>.
31c76ae52dSmrg#
32c76ae52dSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33c76ae52dSmrg# Supply the specified configuration type as an argument.
34c76ae52dSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35c76ae52dSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36c76ae52dSmrg
37c2939121Smrg# You can get the latest version of this script from:
3825420f97Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39c2939121Smrg
40c76ae52dSmrg# This file is supposed to be the same for all GNU packages
41c76ae52dSmrg# and recognize all the CPU types, system types and aliases
42c76ae52dSmrg# that are meaningful with *any* GNU software.
43c76ae52dSmrg# Each package is responsible for reporting which valid configurations
44c76ae52dSmrg# it does not support.  The user should be able to distinguish
45c76ae52dSmrg# a failure to support a valid configuration from a meaningless
46c76ae52dSmrg# configuration.
47c76ae52dSmrg
48c76ae52dSmrg# The goal of this file is to map all the various variations of a given
49c76ae52dSmrg# machine specification into a single specification in the form:
50c76ae52dSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51c76ae52dSmrg# or in some cases, the newer four-part form:
52c76ae52dSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53c76ae52dSmrg# It is wrong to echo any other type of specification.
54c76ae52dSmrg
5525420f97Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
5625420f97Smrg# about features and limitations of the classic Bourne shell that were
5725420f97Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
5825420f97Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5925420f97Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6025420f97Smrg# have a pre-POSIX /bin/sh.
6125420f97Smrg
62c76ae52dSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63c76ae52dSmrg
64c76ae52dSmrgusage="\
658292847cSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66c76ae52dSmrg
67c76ae52dSmrgCanonicalize a configuration name.
68c76ae52dSmrg
698292847cSmrgOptions:
70c76ae52dSmrg  -h, --help         print this help, then exit
71c76ae52dSmrg  -t, --time-stamp   print date of last modification, then exit
72c76ae52dSmrg  -v, --version      print version number, then exit
73c76ae52dSmrg
74c76ae52dSmrgReport bugs and patches to <config-patches@gnu.org>."
75c76ae52dSmrg
76c76ae52dSmrgversion="\
77c76ae52dSmrgGNU config.sub ($timestamp)
78c76ae52dSmrg
7925420f97SmrgCopyright 1992-2022 Free Software Foundation, Inc.
80c76ae52dSmrg
81c76ae52dSmrgThis is free software; see the source for copying conditions.  There is NO
82c76ae52dSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83c76ae52dSmrg
84c76ae52dSmrghelp="
85c76ae52dSmrgTry \`$me --help' for more information."
86c76ae52dSmrg
87c76ae52dSmrg# Parse command line
88c76ae52dSmrgwhile test $# -gt 0 ; do
89c76ae52dSmrg  case $1 in
90c76ae52dSmrg    --time-stamp | --time* | -t )
91c76ae52dSmrg       echo "$timestamp" ; exit ;;
92c76ae52dSmrg    --version | -v )
93c76ae52dSmrg       echo "$version" ; exit ;;
94c76ae52dSmrg    --help | --h* | -h )
95c76ae52dSmrg       echo "$usage"; exit ;;
96c76ae52dSmrg    -- )     # Stop option processing
97c76ae52dSmrg       shift; break ;;
98c76ae52dSmrg    - )	# Use stdin as input.
99c76ae52dSmrg       break ;;
100c76ae52dSmrg    -* )
10125420f97Smrg       echo "$me: invalid option $1$help" >&2
102c76ae52dSmrg       exit 1 ;;
103c76ae52dSmrg
104c76ae52dSmrg    *local*)
105c76ae52dSmrg       # First pass through any local machine types.
1068292847cSmrg       echo "$1"
107c76ae52dSmrg       exit ;;
108c76ae52dSmrg
109c76ae52dSmrg    * )
110c76ae52dSmrg       break ;;
111c76ae52dSmrg  esac
112c76ae52dSmrgdone
113c76ae52dSmrg
114c76ae52dSmrgcase $# in
115c76ae52dSmrg 0) echo "$me: missing argument$help" >&2
116c76ae52dSmrg    exit 1;;
117c76ae52dSmrg 1) ;;
118c76ae52dSmrg *) echo "$me: too many arguments$help" >&2
119c76ae52dSmrg    exit 1;;
120c76ae52dSmrgesac
121c76ae52dSmrg
12225420f97Smrg# Split fields of configuration type
12325420f97Smrg# shellcheck disable=SC2162
12425420f97Smrgsaved_IFS=$IFS
12525420f97SmrgIFS="-" read field1 field2 field3 field4 <<EOF
12625420f97Smrg$1
12725420f97SmrgEOF
12825420f97SmrgIFS=$saved_IFS
129c76ae52dSmrg
13025420f97Smrg# Separate into logical components for further validation
13125420f97Smrgcase $1 in
13225420f97Smrg	*-*-*-*-*)
13325420f97Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
13425420f97Smrg		exit 1
135de3c0529Smrg		;;
13625420f97Smrg	*-*-*-*)
13725420f97Smrg		basic_machine=$field1-$field2
13825420f97Smrg		basic_os=$field3-$field4
139de3c0529Smrg		;;
14025420f97Smrg	*-*-*)
14125420f97Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14225420f97Smrg		# parts
14325420f97Smrg		maybe_os=$field2-$field3
14425420f97Smrg		case $maybe_os in
14525420f97Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
14625420f97Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14725420f97Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148de301c82Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
14925420f97Smrg				basic_machine=$field1
15025420f97Smrg				basic_os=$maybe_os
15125420f97Smrg				;;
15225420f97Smrg			android-linux)
15325420f97Smrg				basic_machine=$field1-unknown
15425420f97Smrg				basic_os=linux-android
15525420f97Smrg				;;
15625420f97Smrg			*)
15725420f97Smrg				basic_machine=$field1-$field2
15825420f97Smrg				basic_os=$field3
15925420f97Smrg				;;
16025420f97Smrg		esac
161de3c0529Smrg		;;
16225420f97Smrg	*-*)
16325420f97Smrg		# A lone config we happen to match not fitting any pattern
16425420f97Smrg		case $field1-$field2 in
16525420f97Smrg			decstation-3100)
16625420f97Smrg				basic_machine=mips-dec
16725420f97Smrg				basic_os=
16825420f97Smrg				;;
16925420f97Smrg			*-*)
17025420f97Smrg				# Second component is usually, but not always the OS
17125420f97Smrg				case $field2 in
17225420f97Smrg					# Prevent following clause from handling this valid os
17325420f97Smrg					sun*os*)
17425420f97Smrg						basic_machine=$field1
17525420f97Smrg						basic_os=$field2
17625420f97Smrg						;;
17725420f97Smrg					zephyr*)
17825420f97Smrg						basic_machine=$field1-unknown
17925420f97Smrg						basic_os=$field2
18025420f97Smrg						;;
18125420f97Smrg					# Manufacturers
18225420f97Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18325420f97Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18425420f97Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18525420f97Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18625420f97Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18725420f97Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18825420f97Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18925420f97Smrg					| microblaze* | sim | cisco \
19025420f97Smrg					| oki | wec | wrs | winbond)
19125420f97Smrg						basic_machine=$field1-$field2
19225420f97Smrg						basic_os=
19325420f97Smrg						;;
19425420f97Smrg					*)
19525420f97Smrg						basic_machine=$field1
19625420f97Smrg						basic_os=$field2
19725420f97Smrg						;;
19825420f97Smrg				esac
19925420f97Smrg			;;
20025420f97Smrg		esac
201de3c0529Smrg		;;
20225420f97Smrg	*)
20325420f97Smrg		# Convert single-component short-hands not valid as part of
20425420f97Smrg		# multi-component configurations.
20525420f97Smrg		case $field1 in
20625420f97Smrg			386bsd)
20725420f97Smrg				basic_machine=i386-pc
20825420f97Smrg				basic_os=bsd
20925420f97Smrg				;;
21025420f97Smrg			a29khif)
21125420f97Smrg				basic_machine=a29k-amd
21225420f97Smrg				basic_os=udi
21325420f97Smrg				;;
21425420f97Smrg			adobe68k)
21525420f97Smrg				basic_machine=m68010-adobe
21625420f97Smrg				basic_os=scout
21725420f97Smrg				;;
21825420f97Smrg			alliant)
21925420f97Smrg				basic_machine=fx80-alliant
22025420f97Smrg				basic_os=
22125420f97Smrg				;;
22225420f97Smrg			altos | altos3068)
22325420f97Smrg				basic_machine=m68k-altos
22425420f97Smrg				basic_os=
22525420f97Smrg				;;
22625420f97Smrg			am29k)
22725420f97Smrg				basic_machine=a29k-none
22825420f97Smrg				basic_os=bsd
22925420f97Smrg				;;
23025420f97Smrg			amdahl)
23125420f97Smrg				basic_machine=580-amdahl
23225420f97Smrg				basic_os=sysv
23325420f97Smrg				;;
23425420f97Smrg			amiga)
23525420f97Smrg				basic_machine=m68k-unknown
23625420f97Smrg				basic_os=
23725420f97Smrg				;;
23825420f97Smrg			amigaos | amigados)
23925420f97Smrg				basic_machine=m68k-unknown
24025420f97Smrg				basic_os=amigaos
24125420f97Smrg				;;
24225420f97Smrg			amigaunix | amix)
24325420f97Smrg				basic_machine=m68k-unknown
24425420f97Smrg				basic_os=sysv4
24525420f97Smrg				;;
24625420f97Smrg			apollo68)
24725420f97Smrg				basic_machine=m68k-apollo
24825420f97Smrg				basic_os=sysv
24925420f97Smrg				;;
25025420f97Smrg			apollo68bsd)
25125420f97Smrg				basic_machine=m68k-apollo
25225420f97Smrg				basic_os=bsd
25325420f97Smrg				;;
25425420f97Smrg			aros)
25525420f97Smrg				basic_machine=i386-pc
25625420f97Smrg				basic_os=aros
25725420f97Smrg				;;
25825420f97Smrg			aux)
25925420f97Smrg				basic_machine=m68k-apple
26025420f97Smrg				basic_os=aux
26125420f97Smrg				;;
26225420f97Smrg			balance)
26325420f97Smrg				basic_machine=ns32k-sequent
26425420f97Smrg				basic_os=dynix
26525420f97Smrg				;;
26625420f97Smrg			blackfin)
26725420f97Smrg				basic_machine=bfin-unknown
26825420f97Smrg				basic_os=linux
26925420f97Smrg				;;
27025420f97Smrg			cegcc)
27125420f97Smrg				basic_machine=arm-unknown
27225420f97Smrg				basic_os=cegcc
27325420f97Smrg				;;
27425420f97Smrg			convex-c1)
27525420f97Smrg				basic_machine=c1-convex
27625420f97Smrg				basic_os=bsd
27725420f97Smrg				;;
27825420f97Smrg			convex-c2)
27925420f97Smrg				basic_machine=c2-convex
28025420f97Smrg				basic_os=bsd
28125420f97Smrg				;;
28225420f97Smrg			convex-c32)
28325420f97Smrg				basic_machine=c32-convex
28425420f97Smrg				basic_os=bsd
28525420f97Smrg				;;
28625420f97Smrg			convex-c34)
28725420f97Smrg				basic_machine=c34-convex
28825420f97Smrg				basic_os=bsd
28925420f97Smrg				;;
29025420f97Smrg			convex-c38)
29125420f97Smrg				basic_machine=c38-convex
29225420f97Smrg				basic_os=bsd
29325420f97Smrg				;;
29425420f97Smrg			cray)
29525420f97Smrg				basic_machine=j90-cray
29625420f97Smrg				basic_os=unicos
29725420f97Smrg				;;
29825420f97Smrg			crds | unos)
29925420f97Smrg				basic_machine=m68k-crds
30025420f97Smrg				basic_os=
30125420f97Smrg				;;
30225420f97Smrg			da30)
30325420f97Smrg				basic_machine=m68k-da30
30425420f97Smrg				basic_os=
30525420f97Smrg				;;
30625420f97Smrg			decstation | pmax | pmin | dec3100 | decstatn)
30725420f97Smrg				basic_machine=mips-dec
30825420f97Smrg				basic_os=
30925420f97Smrg				;;
31025420f97Smrg			delta88)
31125420f97Smrg				basic_machine=m88k-motorola
31225420f97Smrg				basic_os=sysv3
31325420f97Smrg				;;
31425420f97Smrg			dicos)
31525420f97Smrg				basic_machine=i686-pc
31625420f97Smrg				basic_os=dicos
31725420f97Smrg				;;
31825420f97Smrg			djgpp)
31925420f97Smrg				basic_machine=i586-pc
32025420f97Smrg				basic_os=msdosdjgpp
32125420f97Smrg				;;
32225420f97Smrg			ebmon29k)
32325420f97Smrg				basic_machine=a29k-amd
32425420f97Smrg				basic_os=ebmon
32525420f97Smrg				;;
32625420f97Smrg			es1800 | OSE68k | ose68k | ose | OSE)
32725420f97Smrg				basic_machine=m68k-ericsson
32825420f97Smrg				basic_os=ose
32925420f97Smrg				;;
33025420f97Smrg			gmicro)
33125420f97Smrg				basic_machine=tron-gmicro
33225420f97Smrg				basic_os=sysv
33325420f97Smrg				;;
33425420f97Smrg			go32)
33525420f97Smrg				basic_machine=i386-pc
33625420f97Smrg				basic_os=go32
33725420f97Smrg				;;
33825420f97Smrg			h8300hms)
33925420f97Smrg				basic_machine=h8300-hitachi
34025420f97Smrg				basic_os=hms
34125420f97Smrg				;;
34225420f97Smrg			h8300xray)
34325420f97Smrg				basic_machine=h8300-hitachi
34425420f97Smrg				basic_os=xray
34525420f97Smrg				;;
34625420f97Smrg			h8500hms)
34725420f97Smrg				basic_machine=h8500-hitachi
34825420f97Smrg				basic_os=hms
34925420f97Smrg				;;
35025420f97Smrg			harris)
35125420f97Smrg				basic_machine=m88k-harris
35225420f97Smrg				basic_os=sysv3
35325420f97Smrg				;;
35425420f97Smrg			hp300 | hp300hpux)
35525420f97Smrg				basic_machine=m68k-hp
35625420f97Smrg				basic_os=hpux
35725420f97Smrg				;;
35825420f97Smrg			hp300bsd)
35925420f97Smrg				basic_machine=m68k-hp
36025420f97Smrg				basic_os=bsd
36125420f97Smrg				;;
36225420f97Smrg			hppaosf)
36325420f97Smrg				basic_machine=hppa1.1-hp
36425420f97Smrg				basic_os=osf
36525420f97Smrg				;;
36625420f97Smrg			hppro)
36725420f97Smrg				basic_machine=hppa1.1-hp
36825420f97Smrg				basic_os=proelf
36925420f97Smrg				;;
37025420f97Smrg			i386mach)
37125420f97Smrg				basic_machine=i386-mach
37225420f97Smrg				basic_os=mach
37325420f97Smrg				;;
37425420f97Smrg			isi68 | isi)
37525420f97Smrg				basic_machine=m68k-isi
37625420f97Smrg				basic_os=sysv
37725420f97Smrg				;;
37825420f97Smrg			m68knommu)
37925420f97Smrg				basic_machine=m68k-unknown
38025420f97Smrg				basic_os=linux
38125420f97Smrg				;;
38225420f97Smrg			magnum | m3230)
38325420f97Smrg				basic_machine=mips-mips
38425420f97Smrg				basic_os=sysv
38525420f97Smrg				;;
38625420f97Smrg			merlin)
38725420f97Smrg				basic_machine=ns32k-utek
38825420f97Smrg				basic_os=sysv
38925420f97Smrg				;;
39025420f97Smrg			mingw64)
39125420f97Smrg				basic_machine=x86_64-pc
39225420f97Smrg				basic_os=mingw64
39325420f97Smrg				;;
39425420f97Smrg			mingw32)
39525420f97Smrg				basic_machine=i686-pc
39625420f97Smrg				basic_os=mingw32
39725420f97Smrg				;;
39825420f97Smrg			mingw32ce)
39925420f97Smrg				basic_machine=arm-unknown
40025420f97Smrg				basic_os=mingw32ce
40125420f97Smrg				;;
40225420f97Smrg			monitor)
40325420f97Smrg				basic_machine=m68k-rom68k
40425420f97Smrg				basic_os=coff
40525420f97Smrg				;;
40625420f97Smrg			morphos)
40725420f97Smrg				basic_machine=powerpc-unknown
40825420f97Smrg				basic_os=morphos
40925420f97Smrg				;;
41025420f97Smrg			moxiebox)
41125420f97Smrg				basic_machine=moxie-unknown
41225420f97Smrg				basic_os=moxiebox
41325420f97Smrg				;;
41425420f97Smrg			msdos)
41525420f97Smrg				basic_machine=i386-pc
41625420f97Smrg				basic_os=msdos
41725420f97Smrg				;;
41825420f97Smrg			msys)
41925420f97Smrg				basic_machine=i686-pc
42025420f97Smrg				basic_os=msys
42125420f97Smrg				;;
42225420f97Smrg			mvs)
42325420f97Smrg				basic_machine=i370-ibm
42425420f97Smrg				basic_os=mvs
42525420f97Smrg				;;
42625420f97Smrg			nacl)
42725420f97Smrg				basic_machine=le32-unknown
42825420f97Smrg				basic_os=nacl
42925420f97Smrg				;;
43025420f97Smrg			ncr3000)
43125420f97Smrg				basic_machine=i486-ncr
43225420f97Smrg				basic_os=sysv4
43325420f97Smrg				;;
43425420f97Smrg			netbsd386)
43525420f97Smrg				basic_machine=i386-pc
43625420f97Smrg				basic_os=netbsd
43725420f97Smrg				;;
43825420f97Smrg			netwinder)
43925420f97Smrg				basic_machine=armv4l-rebel
44025420f97Smrg				basic_os=linux
44125420f97Smrg				;;
44225420f97Smrg			news | news700 | news800 | news900)
44325420f97Smrg				basic_machine=m68k-sony
44425420f97Smrg				basic_os=newsos
44525420f97Smrg				;;
44625420f97Smrg			news1000)
44725420f97Smrg				basic_machine=m68030-sony
44825420f97Smrg				basic_os=newsos
44925420f97Smrg				;;
45025420f97Smrg			necv70)
45125420f97Smrg				basic_machine=v70-nec
45225420f97Smrg				basic_os=sysv
45325420f97Smrg				;;
45425420f97Smrg			nh3000)
45525420f97Smrg				basic_machine=m68k-harris
45625420f97Smrg				basic_os=cxux
45725420f97Smrg				;;
45825420f97Smrg			nh[45]000)
45925420f97Smrg				basic_machine=m88k-harris
46025420f97Smrg				basic_os=cxux
46125420f97Smrg				;;
46225420f97Smrg			nindy960)
46325420f97Smrg				basic_machine=i960-intel
46425420f97Smrg				basic_os=nindy
46525420f97Smrg				;;
46625420f97Smrg			mon960)
46725420f97Smrg				basic_machine=i960-intel
46825420f97Smrg				basic_os=mon960
46925420f97Smrg				;;
47025420f97Smrg			nonstopux)
47125420f97Smrg				basic_machine=mips-compaq
47225420f97Smrg				basic_os=nonstopux
47325420f97Smrg				;;
47425420f97Smrg			os400)
47525420f97Smrg				basic_machine=powerpc-ibm
47625420f97Smrg				basic_os=os400
47725420f97Smrg				;;
47825420f97Smrg			OSE68000 | ose68000)
47925420f97Smrg				basic_machine=m68000-ericsson
48025420f97Smrg				basic_os=ose
48125420f97Smrg				;;
48225420f97Smrg			os68k)
48325420f97Smrg				basic_machine=m68k-none
48425420f97Smrg				basic_os=os68k
48525420f97Smrg				;;
48625420f97Smrg			paragon)
48725420f97Smrg				basic_machine=i860-intel
48825420f97Smrg				basic_os=osf
48925420f97Smrg				;;
49025420f97Smrg			parisc)
49125420f97Smrg				basic_machine=hppa-unknown
49225420f97Smrg				basic_os=linux
49325420f97Smrg				;;
49425420f97Smrg			psp)
49525420f97Smrg				basic_machine=mipsallegrexel-sony
49625420f97Smrg				basic_os=psp
49725420f97Smrg				;;
49825420f97Smrg			pw32)
49925420f97Smrg				basic_machine=i586-unknown
50025420f97Smrg				basic_os=pw32
50125420f97Smrg				;;
50225420f97Smrg			rdos | rdos64)
50325420f97Smrg				basic_machine=x86_64-pc
50425420f97Smrg				basic_os=rdos
50525420f97Smrg				;;
50625420f97Smrg			rdos32)
50725420f97Smrg				basic_machine=i386-pc
50825420f97Smrg				basic_os=rdos
50925420f97Smrg				;;
51025420f97Smrg			rom68k)
51125420f97Smrg				basic_machine=m68k-rom68k
51225420f97Smrg				basic_os=coff
51325420f97Smrg				;;
51425420f97Smrg			sa29200)
51525420f97Smrg				basic_machine=a29k-amd
51625420f97Smrg				basic_os=udi
51725420f97Smrg				;;
51825420f97Smrg			sei)
51925420f97Smrg				basic_machine=mips-sei
52025420f97Smrg				basic_os=seiux
52125420f97Smrg				;;
52225420f97Smrg			sequent)
52325420f97Smrg				basic_machine=i386-sequent
52425420f97Smrg				basic_os=
52525420f97Smrg				;;
52625420f97Smrg			sps7)
52725420f97Smrg				basic_machine=m68k-bull
52825420f97Smrg				basic_os=sysv2
52925420f97Smrg				;;
53025420f97Smrg			st2000)
53125420f97Smrg				basic_machine=m68k-tandem
53225420f97Smrg				basic_os=
53325420f97Smrg				;;
53425420f97Smrg			stratus)
53525420f97Smrg				basic_machine=i860-stratus
53625420f97Smrg				basic_os=sysv4
53725420f97Smrg				;;
53825420f97Smrg			sun2)
53925420f97Smrg				basic_machine=m68000-sun
54025420f97Smrg				basic_os=
54125420f97Smrg				;;
54225420f97Smrg			sun2os3)
54325420f97Smrg				basic_machine=m68000-sun
54425420f97Smrg				basic_os=sunos3
54525420f97Smrg				;;
54625420f97Smrg			sun2os4)
54725420f97Smrg				basic_machine=m68000-sun
54825420f97Smrg				basic_os=sunos4
54925420f97Smrg				;;
55025420f97Smrg			sun3)
55125420f97Smrg				basic_machine=m68k-sun
55225420f97Smrg				basic_os=
55325420f97Smrg				;;
55425420f97Smrg			sun3os3)
55525420f97Smrg				basic_machine=m68k-sun
55625420f97Smrg				basic_os=sunos3
55725420f97Smrg				;;
55825420f97Smrg			sun3os4)
55925420f97Smrg				basic_machine=m68k-sun
56025420f97Smrg				basic_os=sunos4
56125420f97Smrg				;;
56225420f97Smrg			sun4)
56325420f97Smrg				basic_machine=sparc-sun
56425420f97Smrg				basic_os=
56525420f97Smrg				;;
56625420f97Smrg			sun4os3)
56725420f97Smrg				basic_machine=sparc-sun
56825420f97Smrg				basic_os=sunos3
56925420f97Smrg				;;
57025420f97Smrg			sun4os4)
57125420f97Smrg				basic_machine=sparc-sun
57225420f97Smrg				basic_os=sunos4
57325420f97Smrg				;;
57425420f97Smrg			sun4sol2)
57525420f97Smrg				basic_machine=sparc-sun
57625420f97Smrg				basic_os=solaris2
57725420f97Smrg				;;
57825420f97Smrg			sun386 | sun386i | roadrunner)
57925420f97Smrg				basic_machine=i386-sun
58025420f97Smrg				basic_os=
58125420f97Smrg				;;
58225420f97Smrg			sv1)
58325420f97Smrg				basic_machine=sv1-cray
58425420f97Smrg				basic_os=unicos
58525420f97Smrg				;;
58625420f97Smrg			symmetry)
58725420f97Smrg				basic_machine=i386-sequent
58825420f97Smrg				basic_os=dynix
58925420f97Smrg				;;
59025420f97Smrg			t3e)
59125420f97Smrg				basic_machine=alphaev5-cray
59225420f97Smrg				basic_os=unicos
59325420f97Smrg				;;
59425420f97Smrg			t90)
59525420f97Smrg				basic_machine=t90-cray
59625420f97Smrg				basic_os=unicos
59725420f97Smrg				;;
59825420f97Smrg			toad1)
59925420f97Smrg				basic_machine=pdp10-xkl
60025420f97Smrg				basic_os=tops20
60125420f97Smrg				;;
60225420f97Smrg			tpf)
60325420f97Smrg				basic_machine=s390x-ibm
60425420f97Smrg				basic_os=tpf
60525420f97Smrg				;;
60625420f97Smrg			udi29k)
60725420f97Smrg				basic_machine=a29k-amd
60825420f97Smrg				basic_os=udi
60925420f97Smrg				;;
61025420f97Smrg			ultra3)
61125420f97Smrg				basic_machine=a29k-nyu
61225420f97Smrg				basic_os=sym1
61325420f97Smrg				;;
61425420f97Smrg			v810 | necv810)
61525420f97Smrg				basic_machine=v810-nec
61625420f97Smrg				basic_os=none
61725420f97Smrg				;;
61825420f97Smrg			vaxv)
61925420f97Smrg				basic_machine=vax-dec
62025420f97Smrg				basic_os=sysv
62125420f97Smrg				;;
62225420f97Smrg			vms)
62325420f97Smrg				basic_machine=vax-dec
62425420f97Smrg				basic_os=vms
62525420f97Smrg				;;
62625420f97Smrg			vsta)
62725420f97Smrg				basic_machine=i386-pc
62825420f97Smrg				basic_os=vsta
62925420f97Smrg				;;
63025420f97Smrg			vxworks960)
63125420f97Smrg				basic_machine=i960-wrs
63225420f97Smrg				basic_os=vxworks
63325420f97Smrg				;;
63425420f97Smrg			vxworks68)
63525420f97Smrg				basic_machine=m68k-wrs
63625420f97Smrg				basic_os=vxworks
63725420f97Smrg				;;
63825420f97Smrg			vxworks29k)
63925420f97Smrg				basic_machine=a29k-wrs
64025420f97Smrg				basic_os=vxworks
64125420f97Smrg				;;
64225420f97Smrg			xbox)
64325420f97Smrg				basic_machine=i686-pc
64425420f97Smrg				basic_os=mingw32
64525420f97Smrg				;;
64625420f97Smrg			ymp)
64725420f97Smrg				basic_machine=ymp-cray
64825420f97Smrg				basic_os=unicos
64925420f97Smrg				;;
65025420f97Smrg			*)
65125420f97Smrg				basic_machine=$1
65225420f97Smrg				basic_os=
65325420f97Smrg				;;
65425420f97Smrg		esac
655c76ae52dSmrg		;;
656c76ae52dSmrgesac
657c76ae52dSmrg
65825420f97Smrg# Decode 1-component or ad-hoc basic machines
659c76ae52dSmrgcase $basic_machine in
66025420f97Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66125420f97Smrg	# some cases the only manufacturer, in others, it is the most popular.
66225420f97Smrg	w89k)
66325420f97Smrg		cpu=hppa1.1
66425420f97Smrg		vendor=winbond
665c76ae52dSmrg		;;
66625420f97Smrg	op50n)
66725420f97Smrg		cpu=hppa1.1
66825420f97Smrg		vendor=oki
669c76ae52dSmrg		;;
67025420f97Smrg	op60c)
67125420f97Smrg		cpu=hppa1.1
67225420f97Smrg		vendor=oki
673dff01e5aSmrg		;;
67425420f97Smrg	ibm*)
67525420f97Smrg		cpu=i370
67625420f97Smrg		vendor=ibm
6772836776bSmrg		;;
67825420f97Smrg	orion105)
67925420f97Smrg		cpu=clipper
68025420f97Smrg		vendor=highlevel
681de3c0529Smrg		;;
68225420f97Smrg	mac | mpw | mac-mpw)
68325420f97Smrg		cpu=m68k
68425420f97Smrg		vendor=apple
6852836776bSmrg		;;
68625420f97Smrg	pmac | pmac-mpw)
68725420f97Smrg		cpu=powerpc
68825420f97Smrg		vendor=apple
689de3c0529Smrg		;;
690de3c0529Smrg
691c76ae52dSmrg	# Recognize the various machine names and aliases which stand
692c76ae52dSmrg	# for a CPU type and a company and sometimes even an OS.
693c76ae52dSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69425420f97Smrg		cpu=m68000
69525420f97Smrg		vendor=att
696c76ae52dSmrg		;;
697c76ae52dSmrg	3b*)
69825420f97Smrg		cpu=we32k
69925420f97Smrg		vendor=att
7000d590c07Smrg		;;
701c2939121Smrg	bluegene*)
70225420f97Smrg		cpu=powerpc
70325420f97Smrg		vendor=ibm
70425420f97Smrg		basic_os=cnk
705c76ae52dSmrg		;;
706c76ae52dSmrg	decsystem10* | dec10*)
70725420f97Smrg		cpu=pdp10
70825420f97Smrg		vendor=dec
70925420f97Smrg		basic_os=tops10
710c76ae52dSmrg		;;
711c76ae52dSmrg	decsystem20* | dec20*)
71225420f97Smrg		cpu=pdp10
71325420f97Smrg		vendor=dec
71425420f97Smrg		basic_os=tops20
715c76ae52dSmrg		;;
716c76ae52dSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717c76ae52dSmrg	      | 3300-motorola | delta-motorola)
71825420f97Smrg		cpu=m68k
71925420f97Smrg		vendor=motorola
720c76ae52dSmrg		;;
7218292847cSmrg	dpx2*)
72225420f97Smrg		cpu=m68k
72325420f97Smrg		vendor=bull
72425420f97Smrg		basic_os=sysv3
725de3c0529Smrg		;;
726de3c0529Smrg	encore | umax | mmax)
72725420f97Smrg		cpu=ns32k
72825420f97Smrg		vendor=encore
729de3c0529Smrg		;;
73025420f97Smrg	elxsi)
73125420f97Smrg		cpu=elxsi
73225420f97Smrg		vendor=elxsi
73325420f97Smrg		basic_os=${basic_os:-bsd}
734c76ae52dSmrg		;;
735c76ae52dSmrg	fx2800)
73625420f97Smrg		cpu=i860
73725420f97Smrg		vendor=alliant
738c76ae52dSmrg		;;
739c76ae52dSmrg	genix)
74025420f97Smrg		cpu=ns32k
74125420f97Smrg		vendor=ns
742c76ae52dSmrg		;;
743c76ae52dSmrg	h3050r* | hiux*)
74425420f97Smrg		cpu=hppa1.1
74525420f97Smrg		vendor=hitachi
74625420f97Smrg		basic_os=hiuxwe2
747c76ae52dSmrg		;;
748c76ae52dSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74925420f97Smrg		cpu=hppa1.0
75025420f97Smrg		vendor=hp
751c76ae52dSmrg		;;
752c76ae52dSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75325420f97Smrg		cpu=m68000
75425420f97Smrg		vendor=hp
755c76ae52dSmrg		;;
756c76ae52dSmrg	hp9k3[2-9][0-9])
75725420f97Smrg		cpu=m68k
75825420f97Smrg		vendor=hp
759c76ae52dSmrg		;;
760c76ae52dSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76125420f97Smrg		cpu=hppa1.0
76225420f97Smrg		vendor=hp
763c76ae52dSmrg		;;
764c76ae52dSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76525420f97Smrg		cpu=hppa1.1
76625420f97Smrg		vendor=hp
767c76ae52dSmrg		;;
768c76ae52dSmrg	hp9k78[0-9] | hp78[0-9])
769c76ae52dSmrg		# FIXME: really hppa2.0-hp
77025420f97Smrg		cpu=hppa1.1
77125420f97Smrg		vendor=hp
772c76ae52dSmrg		;;
773c76ae52dSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774c76ae52dSmrg		# FIXME: really hppa2.0-hp
77525420f97Smrg		cpu=hppa1.1
77625420f97Smrg		vendor=hp
777c76ae52dSmrg		;;
778c76ae52dSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77925420f97Smrg		cpu=hppa1.1
78025420f97Smrg		vendor=hp
781c76ae52dSmrg		;;
782c76ae52dSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78325420f97Smrg		cpu=hppa1.0
78425420f97Smrg		vendor=hp
785c76ae52dSmrg		;;
786c76ae52dSmrg	i*86v32)
78725420f97Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78825420f97Smrg		vendor=pc
78925420f97Smrg		basic_os=sysv32
790c76ae52dSmrg		;;
791c76ae52dSmrg	i*86v4*)
79225420f97Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79325420f97Smrg		vendor=pc
79425420f97Smrg		basic_os=sysv4
795c76ae52dSmrg		;;
796c76ae52dSmrg	i*86v)
79725420f97Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79825420f97Smrg		vendor=pc
79925420f97Smrg		basic_os=sysv
800c76ae52dSmrg		;;
801c76ae52dSmrg	i*86sol2)
80225420f97Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80325420f97Smrg		vendor=pc
80425420f97Smrg		basic_os=solaris2
805c76ae52dSmrg		;;
80625420f97Smrg	j90 | j90-cray)
80725420f97Smrg		cpu=j90
80825420f97Smrg		vendor=cray
80925420f97Smrg		basic_os=${basic_os:-unicos}
810c76ae52dSmrg		;;
811c76ae52dSmrg	iris | iris4d)
81225420f97Smrg		cpu=mips
81325420f97Smrg		vendor=sgi
81425420f97Smrg		case $basic_os in
81525420f97Smrg		    irix*)
816c76ae52dSmrg			;;
817c76ae52dSmrg		    *)
81825420f97Smrg			basic_os=irix4
819c76ae52dSmrg			;;
820c76ae52dSmrg		esac
821c76ae52dSmrg		;;
822c76ae52dSmrg	miniframe)
82325420f97Smrg		cpu=m68000
82425420f97Smrg		vendor=convergent
825de3c0529Smrg		;;
82625420f97Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82725420f97Smrg		cpu=m68k
82825420f97Smrg		vendor=atari
82925420f97Smrg		basic_os=mint
830c76ae52dSmrg		;;
831c76ae52dSmrg	news-3600 | risc-news)
83225420f97Smrg		cpu=mips
83325420f97Smrg		vendor=sony
83425420f97Smrg		basic_os=newsos
835c76ae52dSmrg		;;
8368292847cSmrg	next | m*-next)
83725420f97Smrg		cpu=m68k
83825420f97Smrg		vendor=next
83925420f97Smrg		case $basic_os in
84025420f97Smrg		    openstep*)
84125420f97Smrg		        ;;
84225420f97Smrg		    nextstep*)
843c76ae52dSmrg			;;
84425420f97Smrg		    ns2*)
84525420f97Smrg		      basic_os=nextstep2
846c76ae52dSmrg			;;
847c76ae52dSmrg		    *)
84825420f97Smrg		      basic_os=nextstep3
849c76ae52dSmrg			;;
850c76ae52dSmrg		esac
851c76ae52dSmrg		;;
852c76ae52dSmrg	np1)
85325420f97Smrg		cpu=np1
85425420f97Smrg		vendor=gould
8558292847cSmrg		;;
856c76ae52dSmrg	op50n-* | op60c-*)
85725420f97Smrg		cpu=hppa1.1
85825420f97Smrg		vendor=oki
85925420f97Smrg		basic_os=proelf
860c76ae52dSmrg		;;
861c76ae52dSmrg	pa-hitachi)
86225420f97Smrg		cpu=hppa1.1
86325420f97Smrg		vendor=hitachi
86425420f97Smrg		basic_os=hiuxwe2
8650d590c07Smrg		;;
866c76ae52dSmrg	pbd)
86725420f97Smrg		cpu=sparc
86825420f97Smrg		vendor=tti
869c76ae52dSmrg		;;
870c76ae52dSmrg	pbb)
87125420f97Smrg		cpu=m68k
87225420f97Smrg		vendor=tti
873de3c0529Smrg		;;
87425420f97Smrg	pc532)
87525420f97Smrg		cpu=ns32k
87625420f97Smrg		vendor=pc532
877c76ae52dSmrg		;;
878c76ae52dSmrg	pn)
87925420f97Smrg		cpu=pn
88025420f97Smrg		vendor=gould
881c76ae52dSmrg		;;
88225420f97Smrg	power)
88325420f97Smrg		cpu=power
88425420f97Smrg		vendor=ibm
885c76ae52dSmrg		;;
88625420f97Smrg	ps2)
88725420f97Smrg		cpu=i386
88825420f97Smrg		vendor=ibm
889c76ae52dSmrg		;;
89025420f97Smrg	rm[46]00)
89125420f97Smrg		cpu=mips
89225420f97Smrg		vendor=siemens
893c76ae52dSmrg		;;
89425420f97Smrg	rtpc | rtpc-*)
89525420f97Smrg		cpu=romp
89625420f97Smrg		vendor=ibm
897c76ae52dSmrg		;;
89825420f97Smrg	sde)
89925420f97Smrg		cpu=mipsisa32
90025420f97Smrg		vendor=sde
90125420f97Smrg		basic_os=${basic_os:-elf}
902dff01e5aSmrg		;;
90325420f97Smrg	simso-wrs)
90425420f97Smrg		cpu=sparclite
90525420f97Smrg		vendor=wrs
90625420f97Smrg		basic_os=vxworks
907c76ae52dSmrg		;;
90825420f97Smrg	tower | tower-32)
90925420f97Smrg		cpu=m68k
91025420f97Smrg		vendor=ncr
911c76ae52dSmrg		;;
91225420f97Smrg	vpp*|vx|vx-*)
91325420f97Smrg		cpu=f301
91425420f97Smrg		vendor=fujitsu
915c76ae52dSmrg		;;
91625420f97Smrg	w65)
91725420f97Smrg		cpu=w65
91825420f97Smrg		vendor=wdc
919c76ae52dSmrg		;;
92025420f97Smrg	w89k-*)
92125420f97Smrg		cpu=hppa1.1
92225420f97Smrg		vendor=winbond
92325420f97Smrg		basic_os=proelf
924c76ae52dSmrg		;;
92525420f97Smrg	none)
92625420f97Smrg		cpu=none
92725420f97Smrg		vendor=none
928c76ae52dSmrg		;;
92925420f97Smrg	leon|leon[3-9])
93025420f97Smrg		cpu=sparc
93125420f97Smrg		vendor=$basic_machine
932c76ae52dSmrg		;;
93325420f97Smrg	leon-*|leon[3-9]-*)
93425420f97Smrg		cpu=sparc
93525420f97Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936c76ae52dSmrg		;;
93725420f97Smrg
93825420f97Smrg	*-*)
93925420f97Smrg		# shellcheck disable=SC2162
94025420f97Smrg		saved_IFS=$IFS
94125420f97Smrg		IFS="-" read cpu vendor <<EOF
94225420f97Smrg$basic_machine
94325420f97SmrgEOF
94425420f97Smrg		IFS=$saved_IFS
945c76ae52dSmrg		;;
94625420f97Smrg	# We use `pc' rather than `unknown'
94725420f97Smrg	# because (1) that's what they normally are, and
94825420f97Smrg	# (2) the word "unknown" tends to confuse beginning users.
94925420f97Smrg	i*86 | x86_64)
95025420f97Smrg		cpu=$basic_machine
95125420f97Smrg		vendor=pc
9520d590c07Smrg		;;
95325420f97Smrg	# These rules are duplicated from below for sake of the special case above;
95425420f97Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
95525420f97Smrg	pc98)
95625420f97Smrg		cpu=i386
95725420f97Smrg		vendor=pc
958c76ae52dSmrg		;;
95925420f97Smrg	x64 | amd64)
96025420f97Smrg		cpu=x86_64
96125420f97Smrg		vendor=pc
962c76ae52dSmrg		;;
96325420f97Smrg	# Recognize the basic CPU types without company name.
96425420f97Smrg	*)
96525420f97Smrg		cpu=$basic_machine
96625420f97Smrg		vendor=unknown
9670d590c07Smrg		;;
96825420f97Smrgesac
96925420f97Smrg
97025420f97Smrgunset -v basic_machine
97125420f97Smrg
97225420f97Smrg# Decode basic machines in the full and proper CPU-Company form.
97325420f97Smrgcase $cpu-$vendor in
97425420f97Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97525420f97Smrg	# some cases the only manufacturer, in others, it is the most popular.
97625420f97Smrg	craynv-unknown)
97725420f97Smrg		vendor=cray
97825420f97Smrg		basic_os=${basic_os:-unicosmp}
979c76ae52dSmrg		;;
98025420f97Smrg	c90-unknown | c90-cray)
98125420f97Smrg		vendor=cray
98225420f97Smrg		basic_os=${Basic_os:-unicos}
983c76ae52dSmrg		;;
98425420f97Smrg	fx80-unknown)
98525420f97Smrg		vendor=alliant
986c76ae52dSmrg		;;
98725420f97Smrg	romp-unknown)
98825420f97Smrg		vendor=ibm
989c76ae52dSmrg		;;
99025420f97Smrg	mmix-unknown)
99125420f97Smrg		vendor=knuth
992c76ae52dSmrg		;;
99325420f97Smrg	microblaze-unknown | microblazeel-unknown)
99425420f97Smrg		vendor=xilinx
9952836776bSmrg		;;
99625420f97Smrg	rs6000-unknown)
99725420f97Smrg		vendor=ibm
998c76ae52dSmrg		;;
99925420f97Smrg	vax-unknown)
100025420f97Smrg		vendor=dec
1001c76ae52dSmrg		;;
100225420f97Smrg	pdp11-unknown)
100325420f97Smrg		vendor=dec
1004c76ae52dSmrg		;;
100525420f97Smrg	we32k-unknown)
100625420f97Smrg		vendor=att
1007c76ae52dSmrg		;;
100825420f97Smrg	cydra-unknown)
100925420f97Smrg		vendor=cydrome
1010c76ae52dSmrg		;;
101125420f97Smrg	i370-ibm*)
101225420f97Smrg		vendor=ibm
1013c76ae52dSmrg		;;
101425420f97Smrg	orion-unknown)
101525420f97Smrg		vendor=highlevel
1016c76ae52dSmrg		;;
101725420f97Smrg	xps-unknown | xps100-unknown)
101825420f97Smrg		cpu=xps100
101925420f97Smrg		vendor=honeywell
1020c76ae52dSmrg		;;
102125420f97Smrg
102225420f97Smrg	# Here we normalize CPU types with a missing or matching vendor
102325420f97Smrg	armh-unknown | armh-alt)
102425420f97Smrg		cpu=armv7l
102525420f97Smrg		vendor=alt
102625420f97Smrg		basic_os=${basic_os:-linux-gnueabihf}
1027c76ae52dSmrg		;;
102825420f97Smrg	dpx20-unknown | dpx20-bull)
102925420f97Smrg		cpu=rs6000
103025420f97Smrg		vendor=bull
103125420f97Smrg		basic_os=${basic_os:-bosx}
1032c76ae52dSmrg		;;
103325420f97Smrg
103425420f97Smrg	# Here we normalize CPU types irrespective of the vendor
103525420f97Smrg	amd64-*)
103625420f97Smrg		cpu=x86_64
1037c76ae52dSmrg		;;
103825420f97Smrg	blackfin-*)
103925420f97Smrg		cpu=bfin
104025420f97Smrg		basic_os=linux
1041c76ae52dSmrg		;;
104225420f97Smrg	c54x-*)
104325420f97Smrg		cpu=tic54x
1044c76ae52dSmrg		;;
104525420f97Smrg	c55x-*)
104625420f97Smrg		cpu=tic55x
1047c76ae52dSmrg		;;
104825420f97Smrg	c6x-*)
104925420f97Smrg		cpu=tic6x
1050c76ae52dSmrg		;;
105125420f97Smrg	e500v[12]-*)
105225420f97Smrg		cpu=powerpc
105325420f97Smrg		basic_os=${basic_os}"spe"
10540d590c07Smrg		;;
105525420f97Smrg	mips3*-*)
105625420f97Smrg		cpu=mips64
1057c76ae52dSmrg		;;
105825420f97Smrg	ms1-*)
105925420f97Smrg		cpu=mt
1060c76ae52dSmrg		;;
106125420f97Smrg	m68knommu-*)
106225420f97Smrg		cpu=m68k
106325420f97Smrg		basic_os=linux
1064c76ae52dSmrg		;;
106525420f97Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106625420f97Smrg		cpu=s12z
1067c76ae52dSmrg		;;
106825420f97Smrg	openrisc-*)
106925420f97Smrg		cpu=or32
1070c76ae52dSmrg		;;
107125420f97Smrg	parisc-*)
107225420f97Smrg		cpu=hppa
107325420f97Smrg		basic_os=linux
1074c76ae52dSmrg		;;
107525420f97Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107625420f97Smrg		cpu=i586
1077c76ae52dSmrg		;;
107825420f97Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
107925420f97Smrg		cpu=i686
1080c76ae52dSmrg		;;
108125420f97Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108225420f97Smrg		cpu=i686
1083c76ae52dSmrg		;;
108425420f97Smrg	pentium4-*)
108525420f97Smrg		cpu=i786
1086c76ae52dSmrg		;;
108725420f97Smrg	pc98-*)
108825420f97Smrg		cpu=i386
1089c76ae52dSmrg		;;
109025420f97Smrg	ppc-* | ppcbe-*)
109125420f97Smrg		cpu=powerpc
1092c76ae52dSmrg		;;
109325420f97Smrg	ppcle-* | powerpclittle-*)
109425420f97Smrg		cpu=powerpcle
1095c76ae52dSmrg		;;
109625420f97Smrg	ppc64-*)
109725420f97Smrg		cpu=powerpc64
1098c76ae52dSmrg		;;
109925420f97Smrg	ppc64le-* | powerpc64little-*)
110025420f97Smrg		cpu=powerpc64le
1101c76ae52dSmrg		;;
110225420f97Smrg	sb1-*)
110325420f97Smrg		cpu=mipsisa64sb1
1104de3c0529Smrg		;;
110525420f97Smrg	sb1el-*)
110625420f97Smrg		cpu=mipsisa64sb1el
1107c76ae52dSmrg		;;
110825420f97Smrg	sh5e[lb]-*)
110925420f97Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11108292847cSmrg		;;
111125420f97Smrg	spur-*)
111225420f97Smrg		cpu=spur
1113c76ae52dSmrg		;;
111425420f97Smrg	strongarm-* | thumb-*)
111525420f97Smrg		cpu=arm
1116de3c0529Smrg		;;
111725420f97Smrg	tx39-*)
111825420f97Smrg		cpu=mipstx39
1119de3c0529Smrg		;;
112025420f97Smrg	tx39el-*)
112125420f97Smrg		cpu=mipstx39el
1122de3c0529Smrg		;;
112325420f97Smrg	x64-*)
112425420f97Smrg		cpu=x86_64
1125c76ae52dSmrg		;;
11262836776bSmrg	xscale-* | xscalee[bl]-*)
112725420f97Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128de3c0529Smrg		;;
112925420f97Smrg	arm64-* | aarch64le-*)
113025420f97Smrg		cpu=aarch64
1131c76ae52dSmrg		;;
1132c76ae52dSmrg
113325420f97Smrg	# Recognize the canonical CPU Types that limit and/or modify the
113425420f97Smrg	# company names they are paired with.
113525420f97Smrg	cr16-*)
113625420f97Smrg		basic_os=${basic_os:-elf}
1137c76ae52dSmrg		;;
113825420f97Smrg	crisv32-* | etraxfs*-*)
113925420f97Smrg		cpu=crisv32
114025420f97Smrg		vendor=axis
1141c76ae52dSmrg		;;
114225420f97Smrg	cris-* | etrax*-*)
114325420f97Smrg		cpu=cris
114425420f97Smrg		vendor=axis
1145c76ae52dSmrg		;;
114625420f97Smrg	crx-*)
114725420f97Smrg		basic_os=${basic_os:-elf}
1148c76ae52dSmrg		;;
114925420f97Smrg	neo-tandem)
115025420f97Smrg		cpu=neo
115125420f97Smrg		vendor=tandem
1152c76ae52dSmrg		;;
115325420f97Smrg	nse-tandem)
115425420f97Smrg		cpu=nse
115525420f97Smrg		vendor=tandem
1156c76ae52dSmrg		;;
115725420f97Smrg	nsr-tandem)
115825420f97Smrg		cpu=nsr
115925420f97Smrg		vendor=tandem
1160de3c0529Smrg		;;
116125420f97Smrg	nsv-tandem)
116225420f97Smrg		cpu=nsv
116325420f97Smrg		vendor=tandem
1164de3c0529Smrg		;;
116525420f97Smrg	nsx-tandem)
116625420f97Smrg		cpu=nsx
116725420f97Smrg		vendor=tandem
1168de3c0529Smrg		;;
116925420f97Smrg	mipsallegrexel-sony)
117025420f97Smrg		cpu=mipsallegrexel
117125420f97Smrg		vendor=sony
1172de3c0529Smrg		;;
117325420f97Smrg	tile*-*)
117425420f97Smrg		basic_os=${basic_os:-linux-gnu}
1175c76ae52dSmrg		;;
117625420f97Smrg
1177c76ae52dSmrg	*)
117825420f97Smrg		# Recognize the canonical CPU types that are allowed with any
117925420f97Smrg		# company name.
118025420f97Smrg		case $cpu in
118125420f97Smrg			1750a | 580 \
118225420f97Smrg			| a29k \
118325420f97Smrg			| aarch64 | aarch64_be \
118425420f97Smrg			| abacus \
118525420f97Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118625420f97Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118725420f97Smrg			| alphapca5[67] | alpha64pca5[67] \
118825420f97Smrg			| am33_2.0 \
118925420f97Smrg			| amdgcn \
119025420f97Smrg			| arc | arceb | arc32 | arc64 \
119125420f97Smrg			| arm | arm[lb]e | arme[lb] | armv* \
119225420f97Smrg			| avr | avr32 \
119325420f97Smrg			| asmjs \
119425420f97Smrg			| ba \
119525420f97Smrg			| be32 | be64 \
119625420f97Smrg			| bfin | bpf | bs2000 \
119725420f97Smrg			| c[123]* | c30 | [cjt]90 | c4x \
119825420f97Smrg			| c8051 | clipper | craynv | csky | cydra \
119925420f97Smrg			| d10v | d30v | dlx | dsp16xx \
120025420f97Smrg			| e2k | elxsi | epiphany \
120125420f97Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120225420f97Smrg			| h8300 | h8500 \
120325420f97Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
120425420f97Smrg			| hexagon \
120525420f97Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120625420f97Smrg			| ip2k | iq2000 \
120725420f97Smrg			| k1om \
120825420f97Smrg			| le32 | le64 \
120925420f97Smrg			| lm32 \
1210de301c82Smrg			| loongarch32 | loongarch64 | loongarchx32 \
121125420f97Smrg			| m32c | m32r | m32rle \
121225420f97Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121325420f97Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121425420f97Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121525420f97Smrg			| microblaze | microblazeel \
121625420f97Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121725420f97Smrg			| mips16 \
121825420f97Smrg			| mips64 | mips64eb | mips64el \
121925420f97Smrg			| mips64octeon | mips64octeonel \
122025420f97Smrg			| mips64orion | mips64orionel \
122125420f97Smrg			| mips64r5900 | mips64r5900el \
122225420f97Smrg			| mips64vr | mips64vrel \
122325420f97Smrg			| mips64vr4100 | mips64vr4100el \
122425420f97Smrg			| mips64vr4300 | mips64vr4300el \
122525420f97Smrg			| mips64vr5000 | mips64vr5000el \
122625420f97Smrg			| mips64vr5900 | mips64vr5900el \
122725420f97Smrg			| mipsisa32 | mipsisa32el \
122825420f97Smrg			| mipsisa32r2 | mipsisa32r2el \
122925420f97Smrg			| mipsisa32r3 | mipsisa32r3el \
123025420f97Smrg			| mipsisa32r5 | mipsisa32r5el \
123125420f97Smrg			| mipsisa32r6 | mipsisa32r6el \
123225420f97Smrg			| mipsisa64 | mipsisa64el \
123325420f97Smrg			| mipsisa64r2 | mipsisa64r2el \
123425420f97Smrg			| mipsisa64r3 | mipsisa64r3el \
123525420f97Smrg			| mipsisa64r5 | mipsisa64r5el \
123625420f97Smrg			| mipsisa64r6 | mipsisa64r6el \
123725420f97Smrg			| mipsisa64sb1 | mipsisa64sb1el \
123825420f97Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
123925420f97Smrg			| mipsr5900 | mipsr5900el \
124025420f97Smrg			| mipstx39 | mipstx39el \
124125420f97Smrg			| mmix \
124225420f97Smrg			| mn10200 | mn10300 \
124325420f97Smrg			| moxie \
124425420f97Smrg			| mt \
124525420f97Smrg			| msp430 \
124625420f97Smrg			| nds32 | nds32le | nds32be \
124725420f97Smrg			| nfp \
124825420f97Smrg			| nios | nios2 | nios2eb | nios2el \
124925420f97Smrg			| none | np1 | ns16k | ns32k | nvptx \
125025420f97Smrg			| open8 \
125125420f97Smrg			| or1k* \
125225420f97Smrg			| or32 \
125325420f97Smrg			| orion \
125425420f97Smrg			| picochip \
125525420f97Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125625420f97Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125725420f97Smrg			| pru \
125825420f97Smrg			| pyramid \
125925420f97Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
126025420f97Smrg			| rl78 | romp | rs6000 | rx \
126125420f97Smrg			| s390 | s390x \
126225420f97Smrg			| score \
126325420f97Smrg			| sh | shl \
126425420f97Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126525420f97Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126625420f97Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126725420f97Smrg			| sparclite \
126825420f97Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126925420f97Smrg			| spu \
127025420f97Smrg			| tahoe \
127125420f97Smrg			| thumbv7* \
127225420f97Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
127325420f97Smrg			| tron \
127425420f97Smrg			| ubicom32 \
127525420f97Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127625420f97Smrg			| vax \
127725420f97Smrg			| visium \
127825420f97Smrg			| w65 \
127925420f97Smrg			| wasm32 | wasm64 \
128025420f97Smrg			| we32k \
128125420f97Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
128225420f97Smrg			| xstormy16 | xtensa* \
128325420f97Smrg			| ymp \
128425420f97Smrg			| z8k | z80)
128525420f97Smrg				;;
128625420f97Smrg
128725420f97Smrg			*)
128825420f97Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128925420f97Smrg				exit 1
129025420f97Smrg				;;
129125420f97Smrg		esac
1292c76ae52dSmrg		;;
1293c76ae52dSmrgesac
1294c76ae52dSmrg
1295c76ae52dSmrg# Here we canonicalize certain aliases for manufacturers.
129625420f97Smrgcase $vendor in
129725420f97Smrg	digital*)
129825420f97Smrg		vendor=dec
1299c76ae52dSmrg		;;
130025420f97Smrg	commodore*)
130125420f97Smrg		vendor=cbm
1302c76ae52dSmrg		;;
1303c76ae52dSmrg	*)
1304c76ae52dSmrg		;;
1305c76ae52dSmrgesac
1306c76ae52dSmrg
1307c76ae52dSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308c76ae52dSmrg
130925420f97Smrgif test x$basic_os != x
1310c76ae52dSmrgthen
131125420f97Smrg
131225420f97Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
131325420f97Smrg# set os.
131425420f97Smrgcase $basic_os in
131525420f97Smrg	gnu/linux*)
131625420f97Smrg		kernel=linux
131725420f97Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131825420f97Smrg		;;
131925420f97Smrg	os2-emx)
132025420f97Smrg		kernel=os2
132125420f97Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
132225420f97Smrg		;;
132325420f97Smrg	nto-qnx*)
132425420f97Smrg		kernel=nto
132525420f97Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132625420f97Smrg		;;
132725420f97Smrg	*-*)
132825420f97Smrg		# shellcheck disable=SC2162
132925420f97Smrg		saved_IFS=$IFS
133025420f97Smrg		IFS="-" read kernel os <<EOF
133125420f97Smrg$basic_os
133225420f97SmrgEOF
133325420f97Smrg		IFS=$saved_IFS
133425420f97Smrg		;;
133525420f97Smrg	# Default OS when just kernel was specified
133625420f97Smrg	nto*)
133725420f97Smrg		kernel=nto
133825420f97Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133925420f97Smrg		;;
134025420f97Smrg	linux*)
134125420f97Smrg		kernel=linux
134225420f97Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
134325420f97Smrg		;;
134425420f97Smrg	*)
134525420f97Smrg		kernel=
134625420f97Smrg		os=$basic_os
134725420f97Smrg		;;
134825420f97Smrgesac
134925420f97Smrg
135025420f97Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
135125420f97Smrg# etc.)
1352c76ae52dSmrgcase $os in
13538292847cSmrg	# First match some system type aliases that might get confused
13548292847cSmrg	# with valid system types.
135525420f97Smrg	# solaris* is a basic system type, with this one exception.
135625420f97Smrg	auroraux)
135725420f97Smrg		os=auroraux
1358c2939121Smrg		;;
135925420f97Smrg	bluegene*)
136025420f97Smrg		os=cnk
1361c76ae52dSmrg		;;
136225420f97Smrg	solaris1 | solaris1.*)
136325420f97Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1364c76ae52dSmrg		;;
136525420f97Smrg	solaris)
136625420f97Smrg		os=solaris2
1367c76ae52dSmrg		;;
136825420f97Smrg	unixware*)
136925420f97Smrg		os=sysv4.2uw
1370c76ae52dSmrg		;;
13718292847cSmrg	# es1800 is here to avoid being matched by es* (a different OS)
137225420f97Smrg	es1800*)
137325420f97Smrg		os=ose
1374c76ae52dSmrg		;;
137525420f97Smrg	# Some version numbers need modification
137625420f97Smrg	chorusos*)
137725420f97Smrg		os=chorusos
1378c76ae52dSmrg		;;
137925420f97Smrg	isc)
138025420f97Smrg		os=isc2.2
1381c76ae52dSmrg		;;
138225420f97Smrg	sco6)
138325420f97Smrg		os=sco5v6
1384c76ae52dSmrg		;;
138525420f97Smrg	sco5)
138625420f97Smrg		os=sco3.2v5
1387c76ae52dSmrg		;;
138825420f97Smrg	sco4)
138925420f97Smrg		os=sco3.2v4
1390c76ae52dSmrg		;;
139125420f97Smrg	sco3.2.[4-9]*)
139225420f97Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1393c76ae52dSmrg		;;
139425420f97Smrg	sco*v* | scout)
139525420f97Smrg		# Don't match below
1396c76ae52dSmrg		;;
139725420f97Smrg	sco*)
139825420f97Smrg		os=sco3.2v2
1399c76ae52dSmrg		;;
140025420f97Smrg	psos*)
140125420f97Smrg		os=psos
1402c76ae52dSmrg		;;
140325420f97Smrg	qnx*)
140425420f97Smrg		os=qnx
1405c76ae52dSmrg		;;
140625420f97Smrg	hiux*)
140725420f97Smrg		os=hiuxwe2
1408c76ae52dSmrg		;;
140925420f97Smrg	lynx*178)
141025420f97Smrg		os=lynxos178
1411c76ae52dSmrg		;;
141225420f97Smrg	lynx*5)
141325420f97Smrg		os=lynxos5
1414c76ae52dSmrg		;;
141525420f97Smrg	lynxos*)
141625420f97Smrg		# don't get caught up in next wildcard
1417c76ae52dSmrg		;;
141825420f97Smrg	lynx*)
141925420f97Smrg		os=lynxos
1420c76ae52dSmrg		;;
142125420f97Smrg	mac[0-9]*)
142225420f97Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1423c76ae52dSmrg		;;
142425420f97Smrg	opened*)
142525420f97Smrg		os=openedition
1426c76ae52dSmrg		;;
142725420f97Smrg	os400*)
142825420f97Smrg		os=os400
1429c76ae52dSmrg		;;
143025420f97Smrg	sunos5*)
143125420f97Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1432c76ae52dSmrg		;;
143325420f97Smrg	sunos6*)
143425420f97Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1435c76ae52dSmrg		;;
143625420f97Smrg	wince*)
143725420f97Smrg		os=wince
1438c76ae52dSmrg		;;
143925420f97Smrg	utek*)
144025420f97Smrg		os=bsd
1441c76ae52dSmrg		;;
144225420f97Smrg	dynix*)
144325420f97Smrg		os=bsd
1444c76ae52dSmrg		;;
144525420f97Smrg	acis*)
144625420f97Smrg		os=aos
1447c76ae52dSmrg		;;
144825420f97Smrg	atheos*)
144925420f97Smrg		os=atheos
1450c76ae52dSmrg		;;
145125420f97Smrg	syllable*)
145225420f97Smrg		os=syllable
145325420f97Smrg		;;
145425420f97Smrg	386bsd)
145525420f97Smrg		os=bsd
145625420f97Smrg		;;
145725420f97Smrg	ctix* | uts*)
145825420f97Smrg		os=sysv
145925420f97Smrg		;;
146025420f97Smrg	nova*)
146125420f97Smrg		os=rtmk-nova
146225420f97Smrg		;;
146325420f97Smrg	ns2)
146425420f97Smrg		os=nextstep2
146525420f97Smrg		;;
146625420f97Smrg	# Preserve the version number of sinix5.
146725420f97Smrg	sinix5.*)
146825420f97Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1469c76ae52dSmrg		;;
147025420f97Smrg	sinix*)
147125420f97Smrg		os=sysv4
1472c76ae52dSmrg		;;
147325420f97Smrg	tpf*)
147425420f97Smrg		os=tpf
1475c76ae52dSmrg		;;
147625420f97Smrg	triton*)
147725420f97Smrg		os=sysv3
1478c2939121Smrg		;;
147925420f97Smrg	oss*)
148025420f97Smrg		os=sysv3
148184febdacSmrg		;;
148225420f97Smrg	svr4*)
148325420f97Smrg		os=sysv4
148484febdacSmrg		;;
148525420f97Smrg	svr3)
148625420f97Smrg		os=sysv3
148784febdacSmrg		;;
148825420f97Smrg	sysvr4)
148925420f97Smrg		os=sysv4
149084febdacSmrg		;;
149125420f97Smrg	ose*)
149225420f97Smrg		os=ose
149384febdacSmrg		;;
149425420f97Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149525420f97Smrg		os=mint
149684febdacSmrg		;;
149725420f97Smrg	dicos*)
149825420f97Smrg		os=dicos
149925420f97Smrg		;;
150025420f97Smrg	pikeos*)
15018292847cSmrg		# Until real need of OS specific support for
15028292847cSmrg		# particular features comes up, bare metal
15038292847cSmrg		# configurations are quite functional.
150425420f97Smrg		case $cpu in
15058292847cSmrg		    arm*)
150625420f97Smrg			os=eabi
15078292847cSmrg			;;
15088292847cSmrg		    *)
150925420f97Smrg			os=elf
15108292847cSmrg			;;
15118292847cSmrg		esac
15128292847cSmrg		;;
1513c76ae52dSmrg	*)
151425420f97Smrg		# No normalization, but not necessarily accepted, that comes below.
1515c76ae52dSmrg		;;
1516c76ae52dSmrgesac
151725420f97Smrg
1518c76ae52dSmrgelse
1519c76ae52dSmrg
1520c76ae52dSmrg# Here we handle the default operating systems that come with various machines.
1521c76ae52dSmrg# The value should be what the vendor currently ships out the door with their
1522c76ae52dSmrg# machine or put another way, the most popular os provided with the machine.
1523c76ae52dSmrg
1524c76ae52dSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1525c76ae52dSmrg# "-sun"), then you have to tell the case statement up towards the top
1526c76ae52dSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1527c76ae52dSmrg# will signal an error saying that MANUFACTURER isn't an operating
1528c76ae52dSmrg# system, and we'll never get to this point.
1529c76ae52dSmrg
153025420f97Smrgkernel=
153125420f97Smrgcase $cpu-$vendor in
15322836776bSmrg	score-*)
153325420f97Smrg		os=elf
15340d590c07Smrg		;;
15352836776bSmrg	spu-*)
153625420f97Smrg		os=elf
15370d590c07Smrg		;;
1538c76ae52dSmrg	*-acorn)
153925420f97Smrg		os=riscix1.2
1540c76ae52dSmrg		;;
1541c76ae52dSmrg	arm*-rebel)
154225420f97Smrg		kernel=linux
154325420f97Smrg		os=gnu
1544c76ae52dSmrg		;;
1545c76ae52dSmrg	arm*-semi)
154625420f97Smrg		os=aout
1547c76ae52dSmrg		;;
15482836776bSmrg	c4x-* | tic4x-*)
154925420f97Smrg		os=coff
15500d590c07Smrg		;;
15518292847cSmrg	c8051-*)
155225420f97Smrg		os=elf
155325420f97Smrg		;;
155425420f97Smrg	clipper-intergraph)
155525420f97Smrg		os=clix
15568292847cSmrg		;;
1557dff01e5aSmrg	hexagon-*)
155825420f97Smrg		os=elf
1559dff01e5aSmrg		;;
1560c2939121Smrg	tic54x-*)
156125420f97Smrg		os=coff
1562c2939121Smrg		;;
1563c2939121Smrg	tic55x-*)
156425420f97Smrg		os=coff
1565c2939121Smrg		;;
1566c2939121Smrg	tic6x-*)
156725420f97Smrg		os=coff
1568c2939121Smrg		;;
1569c76ae52dSmrg	# This must come before the *-dec entry.
1570c76ae52dSmrg	pdp10-*)
157125420f97Smrg		os=tops20
1572c76ae52dSmrg		;;
1573c76ae52dSmrg	pdp11-*)
157425420f97Smrg		os=none
1575c76ae52dSmrg		;;
1576c76ae52dSmrg	*-dec | vax-*)
157725420f97Smrg		os=ultrix4.2
1578c76ae52dSmrg		;;
1579c76ae52dSmrg	m68*-apollo)
158025420f97Smrg		os=domain
1581c76ae52dSmrg		;;
1582c76ae52dSmrg	i386-sun)
158325420f97Smrg		os=sunos4.0.2
1584c76ae52dSmrg		;;
1585c76ae52dSmrg	m68000-sun)
158625420f97Smrg		os=sunos3
1587c76ae52dSmrg		;;
1588c76ae52dSmrg	m68*-cisco)
158925420f97Smrg		os=aout
1590c76ae52dSmrg		;;
15912836776bSmrg	mep-*)
159225420f97Smrg		os=elf
15930d590c07Smrg		;;
1594c76ae52dSmrg	mips*-cisco)
159525420f97Smrg		os=elf
1596c76ae52dSmrg		;;
1597c76ae52dSmrg	mips*-*)
159825420f97Smrg		os=elf
1599c76ae52dSmrg		;;
1600c76ae52dSmrg	or32-*)
160125420f97Smrg		os=coff
1602c76ae52dSmrg		;;
1603c76ae52dSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
160425420f97Smrg		os=sysv3
1605c76ae52dSmrg		;;
1606c76ae52dSmrg	sparc-* | *-sun)
160725420f97Smrg		os=sunos4.1.1
1608c76ae52dSmrg		;;
16098292847cSmrg	pru-*)
161025420f97Smrg		os=elf
16118292847cSmrg		;;
1612c76ae52dSmrg	*-be)
161325420f97Smrg		os=beos
1614c76ae52dSmrg		;;
1615c76ae52dSmrg	*-ibm)
161625420f97Smrg		os=aix
1617c76ae52dSmrg		;;
16182836776bSmrg	*-knuth)
161925420f97Smrg		os=mmixware
1620c76ae52dSmrg		;;
1621c76ae52dSmrg	*-wec)
162225420f97Smrg		os=proelf
1623c76ae52dSmrg		;;
1624c76ae52dSmrg	*-winbond)
162525420f97Smrg		os=proelf
1626c76ae52dSmrg		;;
1627c76ae52dSmrg	*-oki)
162825420f97Smrg		os=proelf
1629c76ae52dSmrg		;;
1630c76ae52dSmrg	*-hp)
163125420f97Smrg		os=hpux
1632c76ae52dSmrg		;;
1633c76ae52dSmrg	*-hitachi)
163425420f97Smrg		os=hiux
1635c76ae52dSmrg		;;
1636c76ae52dSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
163725420f97Smrg		os=sysv
1638c76ae52dSmrg		;;
1639c76ae52dSmrg	*-cbm)
164025420f97Smrg		os=amigaos
1641c76ae52dSmrg		;;
1642c76ae52dSmrg	*-dg)
164325420f97Smrg		os=dgux
1644c76ae52dSmrg		;;
1645c76ae52dSmrg	*-dolphin)
164625420f97Smrg		os=sysv3
1647c76ae52dSmrg		;;
1648c76ae52dSmrg	m68k-ccur)
164925420f97Smrg		os=rtu
1650c76ae52dSmrg		;;
1651c76ae52dSmrg	m88k-omron*)
165225420f97Smrg		os=luna
1653c76ae52dSmrg		;;
16548292847cSmrg	*-next)
165525420f97Smrg		os=nextstep
1656c76ae52dSmrg		;;
1657c76ae52dSmrg	*-sequent)
165825420f97Smrg		os=ptx
1659c76ae52dSmrg		;;
1660c76ae52dSmrg	*-crds)
166125420f97Smrg		os=unos
1662c76ae52dSmrg		;;
1663c76ae52dSmrg	*-ns)
166425420f97Smrg		os=genix
1665c76ae52dSmrg		;;
1666c76ae52dSmrg	i370-*)
166725420f97Smrg		os=mvs
1668c76ae52dSmrg		;;
1669c76ae52dSmrg	*-gould)
167025420f97Smrg		os=sysv
1671c76ae52dSmrg		;;
1672c76ae52dSmrg	*-highlevel)
167325420f97Smrg		os=bsd
1674c76ae52dSmrg		;;
1675c76ae52dSmrg	*-encore)
167625420f97Smrg		os=bsd
1677c76ae52dSmrg		;;
1678c76ae52dSmrg	*-sgi)
167925420f97Smrg		os=irix
1680c76ae52dSmrg		;;
1681c76ae52dSmrg	*-siemens)
168225420f97Smrg		os=sysv4
1683c76ae52dSmrg		;;
1684c76ae52dSmrg	*-masscomp)
168525420f97Smrg		os=rtu
1686c76ae52dSmrg		;;
1687c76ae52dSmrg	f30[01]-fujitsu | f700-fujitsu)
168825420f97Smrg		os=uxpv
1689c76ae52dSmrg		;;
1690c76ae52dSmrg	*-rom68k)
169125420f97Smrg		os=coff
1692c76ae52dSmrg		;;
1693c76ae52dSmrg	*-*bug)
169425420f97Smrg		os=coff
1695c76ae52dSmrg		;;
1696c76ae52dSmrg	*-apple)
169725420f97Smrg		os=macos
1698c76ae52dSmrg		;;
1699c76ae52dSmrg	*-atari*)
170025420f97Smrg		os=mint
170125420f97Smrg		;;
170225420f97Smrg	*-wrs)
170325420f97Smrg		os=vxworks
1704c76ae52dSmrg		;;
1705c76ae52dSmrg	*)
170625420f97Smrg		os=none
1707c76ae52dSmrg		;;
1708c76ae52dSmrgesac
170925420f97Smrg
1710c76ae52dSmrgfi
1711c76ae52dSmrg
171225420f97Smrg# Now, validate our (potentially fixed-up) OS.
171325420f97Smrgcase $os in
171425420f97Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
171525420f97Smrg	musl* | newlib* | relibc* | uclibc*)
171625420f97Smrg		;;
171725420f97Smrg	# Likewise for "kernel-abi"
171825420f97Smrg	eabi* | gnueabi*)
171925420f97Smrg		;;
172025420f97Smrg	# VxWorks passes extra cpu info in the 4th filed.
172125420f97Smrg	simlinux | simwindows | spe)
172225420f97Smrg		;;
172325420f97Smrg	# Now accept the basic system types.
172425420f97Smrg	# The portable systems comes first.
172525420f97Smrg	# Each alternative MUST end in a * to match a version number.
172625420f97Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
172725420f97Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
172825420f97Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
172925420f97Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
173025420f97Smrg	     | hiux* | abug | nacl* | netware* | windows* \
173125420f97Smrg	     | os9* | macos* | osx* | ios* \
173225420f97Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
173325420f97Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
173425420f97Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173525420f97Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
173625420f97Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
173725420f97Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
173825420f97Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
173925420f97Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
174025420f97Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
174125420f97Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
174225420f97Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
174325420f97Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
174425420f97Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174525420f97Smrg	     | midipix* | mingw32* | mingw64* | mint* \
174625420f97Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
174725420f97Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
174825420f97Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
174925420f97Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
175025420f97Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
175125420f97Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
175225420f97Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
175325420f97Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
175425420f97Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175525420f97Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
175625420f97Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1757de301c82Smrg	     | fiwix* )
175825420f97Smrg		;;
175925420f97Smrg	# This one is extra strict with allowed versions
176025420f97Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
176125420f97Smrg		# Don't forget version if it is 3.2v4 or newer.
176225420f97Smrg		;;
176325420f97Smrg	none)
176425420f97Smrg		;;
176525420f97Smrg	*)
176625420f97Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
176725420f97Smrg		exit 1
176825420f97Smrg		;;
176925420f97Smrgesac
177025420f97Smrg
177125420f97Smrg# As a final step for OS-related things, validate the OS-kernel combination
177225420f97Smrg# (given a valid OS), if there is a kernel.
177325420f97Smrgcase $kernel-$os in
177425420f97Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1775de301c82Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
177625420f97Smrg		;;
177725420f97Smrg	uclinux-uclibc* )
177825420f97Smrg		;;
1779de301c82Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
178025420f97Smrg		# These are just libc implementations, not actual OSes, and thus
178125420f97Smrg		# require a kernel.
178225420f97Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
178325420f97Smrg		exit 1
178425420f97Smrg		;;
178525420f97Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
178625420f97Smrg		;;
178725420f97Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
178825420f97Smrg		;;
178925420f97Smrg	nto-qnx*)
179025420f97Smrg		;;
179125420f97Smrg	os2-emx)
179225420f97Smrg		;;
179325420f97Smrg	*-eabi* | *-gnueabi*)
179425420f97Smrg		;;
179525420f97Smrg	-*)
179625420f97Smrg		# Blank kernel with real OS is always fine.
179725420f97Smrg		;;
179825420f97Smrg	*-*)
179925420f97Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
180025420f97Smrg		exit 1
180125420f97Smrg		;;
180225420f97Smrgesac
180325420f97Smrg
1804c76ae52dSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1805c76ae52dSmrg# manufacturer.  We pick the logical manufacturer.
180625420f97Smrgcase $vendor in
180725420f97Smrg	unknown)
180825420f97Smrg		case $cpu-$os in
180925420f97Smrg			*-riscix*)
1810c76ae52dSmrg				vendor=acorn
1811c76ae52dSmrg				;;
181225420f97Smrg			*-sunos*)
1813c76ae52dSmrg				vendor=sun
1814c76ae52dSmrg				;;
181525420f97Smrg			*-cnk* | *-aix*)
1816c76ae52dSmrg				vendor=ibm
1817c76ae52dSmrg				;;
181825420f97Smrg			*-beos*)
1819c76ae52dSmrg				vendor=be
1820c76ae52dSmrg				;;
182125420f97Smrg			*-hpux*)
1822c76ae52dSmrg				vendor=hp
1823c76ae52dSmrg				;;
182425420f97Smrg			*-mpeix*)
1825c76ae52dSmrg				vendor=hp
1826c76ae52dSmrg				;;
182725420f97Smrg			*-hiux*)
1828c76ae52dSmrg				vendor=hitachi
1829c76ae52dSmrg				;;
183025420f97Smrg			*-unos*)
1831c76ae52dSmrg				vendor=crds
1832c76ae52dSmrg				;;
183325420f97Smrg			*-dgux*)
1834c76ae52dSmrg				vendor=dg
1835c76ae52dSmrg				;;
183625420f97Smrg			*-luna*)
1837c76ae52dSmrg				vendor=omron
1838c76ae52dSmrg				;;
183925420f97Smrg			*-genix*)
1840c76ae52dSmrg				vendor=ns
1841c76ae52dSmrg				;;
184225420f97Smrg			*-clix*)
184325420f97Smrg				vendor=intergraph
184425420f97Smrg				;;
184525420f97Smrg			*-mvs* | *-opened*)
184625420f97Smrg				vendor=ibm
184725420f97Smrg				;;
184825420f97Smrg			*-os400*)
1849c76ae52dSmrg				vendor=ibm
1850c76ae52dSmrg				;;
185125420f97Smrg			s390-* | s390x-*)
1852c76ae52dSmrg				vendor=ibm
1853c76ae52dSmrg				;;
185425420f97Smrg			*-ptx*)
1855c76ae52dSmrg				vendor=sequent
1856c76ae52dSmrg				;;
185725420f97Smrg			*-tpf*)
1858c76ae52dSmrg				vendor=ibm
1859c76ae52dSmrg				;;
186025420f97Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1861c76ae52dSmrg				vendor=wrs
1862c76ae52dSmrg				;;
186325420f97Smrg			*-aux*)
1864c76ae52dSmrg				vendor=apple
1865c76ae52dSmrg				;;
186625420f97Smrg			*-hms*)
1867c76ae52dSmrg				vendor=hitachi
1868c76ae52dSmrg				;;
186925420f97Smrg			*-mpw* | *-macos*)
1870c76ae52dSmrg				vendor=apple
1871c76ae52dSmrg				;;
187225420f97Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1873c76ae52dSmrg				vendor=atari
1874c76ae52dSmrg				;;
187525420f97Smrg			*-vos*)
1876c76ae52dSmrg				vendor=stratus
1877c76ae52dSmrg				;;
1878c76ae52dSmrg		esac
1879c76ae52dSmrg		;;
1880c76ae52dSmrgesac
1881c76ae52dSmrg
188225420f97Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1883c76ae52dSmrgexit
1884c76ae52dSmrg
1885c76ae52dSmrg# Local variables:
188625420f97Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1887c76ae52dSmrg# time-stamp-start: "timestamp='"
1888c76ae52dSmrg# time-stamp-format: "%:y-%02m-%02d"
1889c76ae52dSmrg# time-stamp-end: "'"
1890c76ae52dSmrg# End:
1891