1a966c04fSmrg#! /bin/sh
2a966c04fSmrg# Configuration validation subroutine script.
352dc082bSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4a966c04fSmrg
574835918Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
674835918Smrg
752dc082bSmrgtimestamp='2023-01-21'
8a966c04fSmrg
9ac92798bSmrg# This file is free software; you can redistribute it and/or modify it
10ac92798bSmrg# under the terms of the GNU General Public License as published by
1174835918Smrg# the Free Software Foundation, either version 3 of the License, or
12a966c04fSmrg# (at your option) any later version.
13a966c04fSmrg#
14ac92798bSmrg# This program is distributed in the hope that it will be useful, but
15ac92798bSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16ac92798bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17ac92798bSmrg# General Public License for more details.
18a966c04fSmrg#
19a966c04fSmrg# You should have received a copy of the GNU General Public License
20edce3322Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21a966c04fSmrg#
22a966c04fSmrg# As a special exception to the GNU General Public License, if you
23a966c04fSmrg# distribute this file as part of a program that contains a
24a966c04fSmrg# configuration script generated by Autoconf, you may include it under
25ac92798bSmrg# the same distribution terms that you use for the rest of that
26ac92798bSmrg# program.  This Exception is an additional permission under section 7
27ac92798bSmrg# of the GNU General Public License, version 3 ("GPLv3").
28a966c04fSmrg
29a966c04fSmrg
30edce3322Smrg# Please send patches to <config-patches@gnu.org>.
31a966c04fSmrg#
32a966c04fSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33a966c04fSmrg# Supply the specified configuration type as an argument.
34a966c04fSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35a966c04fSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36a966c04fSmrg
376e7d3316Smrg# You can get the latest version of this script from:
3874835918Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
396e7d3316Smrg
40a966c04fSmrg# This file is supposed to be the same for all GNU packages
41a966c04fSmrg# and recognize all the CPU types, system types and aliases
42a966c04fSmrg# that are meaningful with *any* GNU software.
43a966c04fSmrg# Each package is responsible for reporting which valid configurations
44a966c04fSmrg# it does not support.  The user should be able to distinguish
45a966c04fSmrg# a failure to support a valid configuration from a meaningless
46a966c04fSmrg# configuration.
47a966c04fSmrg
48a966c04fSmrg# The goal of this file is to map all the various variations of a given
49a966c04fSmrg# machine specification into a single specification in the form:
50a966c04fSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51a966c04fSmrg# or in some cases, the newer four-part form:
52a966c04fSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53a966c04fSmrg# It is wrong to echo any other type of specification.
54a966c04fSmrg
5574835918Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
5674835918Smrg# about features and limitations of the classic Bourne shell that were
5774835918Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
5874835918Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5974835918Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6074835918Smrg# have a pre-POSIX /bin/sh.
6174835918Smrg
62a966c04fSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63a966c04fSmrg
64a966c04fSmrgusage="\
65edce3322SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66a966c04fSmrg
67a966c04fSmrgCanonicalize a configuration name.
68a966c04fSmrg
69edce3322SmrgOptions:
70a966c04fSmrg  -h, --help         print this help, then exit
71a966c04fSmrg  -t, --time-stamp   print date of last modification, then exit
72a966c04fSmrg  -v, --version      print version number, then exit
73a966c04fSmrg
74a966c04fSmrgReport bugs and patches to <config-patches@gnu.org>."
75a966c04fSmrg
76a966c04fSmrgversion="\
77a966c04fSmrgGNU config.sub ($timestamp)
78a966c04fSmrg
7952dc082bSmrgCopyright 1992-2023 Free Software Foundation, Inc.
80a966c04fSmrg
81a966c04fSmrgThis is free software; see the source for copying conditions.  There is NO
82a966c04fSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83a966c04fSmrg
84a966c04fSmrghelp="
85a966c04fSmrgTry \`$me --help' for more information."
86a966c04fSmrg
87a966c04fSmrg# Parse command line
88a966c04fSmrgwhile test $# -gt 0 ; do
89a966c04fSmrg  case $1 in
90a966c04fSmrg    --time-stamp | --time* | -t )
91a966c04fSmrg       echo "$timestamp" ; exit ;;
92a966c04fSmrg    --version | -v )
93a966c04fSmrg       echo "$version" ; exit ;;
94a966c04fSmrg    --help | --h* | -h )
95a966c04fSmrg       echo "$usage"; exit ;;
96a966c04fSmrg    -- )     # Stop option processing
97a966c04fSmrg       shift; break ;;
98a966c04fSmrg    - )	# Use stdin as input.
99a966c04fSmrg       break ;;
100a966c04fSmrg    -* )
10174835918Smrg       echo "$me: invalid option $1$help" >&2
102a966c04fSmrg       exit 1 ;;
103a966c04fSmrg
104a966c04fSmrg    *local*)
105a966c04fSmrg       # First pass through any local machine types.
106edce3322Smrg       echo "$1"
107a966c04fSmrg       exit ;;
108a966c04fSmrg
109a966c04fSmrg    * )
110a966c04fSmrg       break ;;
111a966c04fSmrg  esac
112a966c04fSmrgdone
113a966c04fSmrg
114a966c04fSmrgcase $# in
115a966c04fSmrg 0) echo "$me: missing argument$help" >&2
116a966c04fSmrg    exit 1;;
117a966c04fSmrg 1) ;;
118a966c04fSmrg *) echo "$me: too many arguments$help" >&2
119a966c04fSmrg    exit 1;;
120a966c04fSmrgesac
121a966c04fSmrg
12274835918Smrg# Split fields of configuration type
12374835918Smrg# shellcheck disable=SC2162
12474835918Smrgsaved_IFS=$IFS
12574835918SmrgIFS="-" read field1 field2 field3 field4 <<EOF
12674835918Smrg$1
12774835918SmrgEOF
12874835918SmrgIFS=$saved_IFS
129a966c04fSmrg
13074835918Smrg# Separate into logical components for further validation
13174835918Smrgcase $1 in
13274835918Smrg	*-*-*-*-*)
13374835918Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
13474835918Smrg		exit 1
1351c235774Smrg		;;
13674835918Smrg	*-*-*-*)
13774835918Smrg		basic_machine=$field1-$field2
13874835918Smrg		basic_os=$field3-$field4
1391c235774Smrg		;;
14074835918Smrg	*-*-*)
14174835918Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14274835918Smrg		# parts
14374835918Smrg		maybe_os=$field2-$field3
14474835918Smrg		case $maybe_os in
14574835918Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
14674835918Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14774835918Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14874835918Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
14974835918Smrg				basic_machine=$field1
15074835918Smrg				basic_os=$maybe_os
15174835918Smrg				;;
15274835918Smrg			android-linux)
15374835918Smrg				basic_machine=$field1-unknown
15474835918Smrg				basic_os=linux-android
15574835918Smrg				;;
15674835918Smrg			*)
15774835918Smrg				basic_machine=$field1-$field2
15874835918Smrg				basic_os=$field3
15974835918Smrg				;;
16074835918Smrg		esac
1611c235774Smrg		;;
16274835918Smrg	*-*)
16374835918Smrg		# A lone config we happen to match not fitting any pattern
16474835918Smrg		case $field1-$field2 in
16574835918Smrg			decstation-3100)
16674835918Smrg				basic_machine=mips-dec
16774835918Smrg				basic_os=
16874835918Smrg				;;
16974835918Smrg			*-*)
17074835918Smrg				# Second component is usually, but not always the OS
17174835918Smrg				case $field2 in
17274835918Smrg					# Prevent following clause from handling this valid os
17374835918Smrg					sun*os*)
17474835918Smrg						basic_machine=$field1
17574835918Smrg						basic_os=$field2
17674835918Smrg						;;
17774835918Smrg					zephyr*)
17874835918Smrg						basic_machine=$field1-unknown
17974835918Smrg						basic_os=$field2
18074835918Smrg						;;
18174835918Smrg					# Manufacturers
18274835918Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18374835918Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18474835918Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18574835918Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18674835918Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18774835918Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18874835918Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18974835918Smrg					| microblaze* | sim | cisco \
19074835918Smrg					| oki | wec | wrs | winbond)
19174835918Smrg						basic_machine=$field1-$field2
19274835918Smrg						basic_os=
19374835918Smrg						;;
19474835918Smrg					*)
19574835918Smrg						basic_machine=$field1
19674835918Smrg						basic_os=$field2
19774835918Smrg						;;
19874835918Smrg				esac
19974835918Smrg			;;
20074835918Smrg		esac
2011c235774Smrg		;;
20274835918Smrg	*)
20374835918Smrg		# Convert single-component short-hands not valid as part of
20474835918Smrg		# multi-component configurations.
20574835918Smrg		case $field1 in
20674835918Smrg			386bsd)
20774835918Smrg				basic_machine=i386-pc
20874835918Smrg				basic_os=bsd
20974835918Smrg				;;
21074835918Smrg			a29khif)
21174835918Smrg				basic_machine=a29k-amd
21274835918Smrg				basic_os=udi
21374835918Smrg				;;
21474835918Smrg			adobe68k)
21574835918Smrg				basic_machine=m68010-adobe
21674835918Smrg				basic_os=scout
21774835918Smrg				;;
21874835918Smrg			alliant)
21974835918Smrg				basic_machine=fx80-alliant
22074835918Smrg				basic_os=
22174835918Smrg				;;
22274835918Smrg			altos | altos3068)
22374835918Smrg				basic_machine=m68k-altos
22474835918Smrg				basic_os=
22574835918Smrg				;;
22674835918Smrg			am29k)
22774835918Smrg				basic_machine=a29k-none
22874835918Smrg				basic_os=bsd
22974835918Smrg				;;
23074835918Smrg			amdahl)
23174835918Smrg				basic_machine=580-amdahl
23274835918Smrg				basic_os=sysv
23374835918Smrg				;;
23474835918Smrg			amiga)
23574835918Smrg				basic_machine=m68k-unknown
23674835918Smrg				basic_os=
23774835918Smrg				;;
23874835918Smrg			amigaos | amigados)
23974835918Smrg				basic_machine=m68k-unknown
24074835918Smrg				basic_os=amigaos
24174835918Smrg				;;
24274835918Smrg			amigaunix | amix)
24374835918Smrg				basic_machine=m68k-unknown
24474835918Smrg				basic_os=sysv4
24574835918Smrg				;;
24674835918Smrg			apollo68)
24774835918Smrg				basic_machine=m68k-apollo
24874835918Smrg				basic_os=sysv
24974835918Smrg				;;
25074835918Smrg			apollo68bsd)
25174835918Smrg				basic_machine=m68k-apollo
25274835918Smrg				basic_os=bsd
25374835918Smrg				;;
25474835918Smrg			aros)
25574835918Smrg				basic_machine=i386-pc
25674835918Smrg				basic_os=aros
25774835918Smrg				;;
25874835918Smrg			aux)
25974835918Smrg				basic_machine=m68k-apple
26074835918Smrg				basic_os=aux
26174835918Smrg				;;
26274835918Smrg			balance)
26374835918Smrg				basic_machine=ns32k-sequent
26474835918Smrg				basic_os=dynix
26574835918Smrg				;;
26674835918Smrg			blackfin)
26774835918Smrg				basic_machine=bfin-unknown
26874835918Smrg				basic_os=linux
26974835918Smrg				;;
27074835918Smrg			cegcc)
27174835918Smrg				basic_machine=arm-unknown
27274835918Smrg				basic_os=cegcc
27374835918Smrg				;;
27474835918Smrg			convex-c1)
27574835918Smrg				basic_machine=c1-convex
27674835918Smrg				basic_os=bsd
27774835918Smrg				;;
27874835918Smrg			convex-c2)
27974835918Smrg				basic_machine=c2-convex
28074835918Smrg				basic_os=bsd
28174835918Smrg				;;
28274835918Smrg			convex-c32)
28374835918Smrg				basic_machine=c32-convex
28474835918Smrg				basic_os=bsd
28574835918Smrg				;;
28674835918Smrg			convex-c34)
28774835918Smrg				basic_machine=c34-convex
28874835918Smrg				basic_os=bsd
28974835918Smrg				;;
29074835918Smrg			convex-c38)
29174835918Smrg				basic_machine=c38-convex
29274835918Smrg				basic_os=bsd
29374835918Smrg				;;
29474835918Smrg			cray)
29574835918Smrg				basic_machine=j90-cray
29674835918Smrg				basic_os=unicos
29774835918Smrg				;;
29874835918Smrg			crds | unos)
29974835918Smrg				basic_machine=m68k-crds
30074835918Smrg				basic_os=
30174835918Smrg				;;
30274835918Smrg			da30)
30374835918Smrg				basic_machine=m68k-da30
30474835918Smrg				basic_os=
30574835918Smrg				;;
30674835918Smrg			decstation | pmax | pmin | dec3100 | decstatn)
30774835918Smrg				basic_machine=mips-dec
30874835918Smrg				basic_os=
30974835918Smrg				;;
31074835918Smrg			delta88)
31174835918Smrg				basic_machine=m88k-motorola
31274835918Smrg				basic_os=sysv3
31374835918Smrg				;;
31474835918Smrg			dicos)
31574835918Smrg				basic_machine=i686-pc
31674835918Smrg				basic_os=dicos
31774835918Smrg				;;
31874835918Smrg			djgpp)
31974835918Smrg				basic_machine=i586-pc
32074835918Smrg				basic_os=msdosdjgpp
32174835918Smrg				;;
32274835918Smrg			ebmon29k)
32374835918Smrg				basic_machine=a29k-amd
32474835918Smrg				basic_os=ebmon
32574835918Smrg				;;
32674835918Smrg			es1800 | OSE68k | ose68k | ose | OSE)
32774835918Smrg				basic_machine=m68k-ericsson
32874835918Smrg				basic_os=ose
32974835918Smrg				;;
33074835918Smrg			gmicro)
33174835918Smrg				basic_machine=tron-gmicro
33274835918Smrg				basic_os=sysv
33374835918Smrg				;;
33474835918Smrg			go32)
33574835918Smrg				basic_machine=i386-pc
33674835918Smrg				basic_os=go32
33774835918Smrg				;;
33874835918Smrg			h8300hms)
33974835918Smrg				basic_machine=h8300-hitachi
34074835918Smrg				basic_os=hms
34174835918Smrg				;;
34274835918Smrg			h8300xray)
34374835918Smrg				basic_machine=h8300-hitachi
34474835918Smrg				basic_os=xray
34574835918Smrg				;;
34674835918Smrg			h8500hms)
34774835918Smrg				basic_machine=h8500-hitachi
34874835918Smrg				basic_os=hms
34974835918Smrg				;;
35074835918Smrg			harris)
35174835918Smrg				basic_machine=m88k-harris
35274835918Smrg				basic_os=sysv3
35374835918Smrg				;;
35474835918Smrg			hp300 | hp300hpux)
35574835918Smrg				basic_machine=m68k-hp
35674835918Smrg				basic_os=hpux
35774835918Smrg				;;
35874835918Smrg			hp300bsd)
35974835918Smrg				basic_machine=m68k-hp
36074835918Smrg				basic_os=bsd
36174835918Smrg				;;
36274835918Smrg			hppaosf)
36374835918Smrg				basic_machine=hppa1.1-hp
36474835918Smrg				basic_os=osf
36574835918Smrg				;;
36674835918Smrg			hppro)
36774835918Smrg				basic_machine=hppa1.1-hp
36874835918Smrg				basic_os=proelf
36974835918Smrg				;;
37074835918Smrg			i386mach)
37174835918Smrg				basic_machine=i386-mach
37274835918Smrg				basic_os=mach
37374835918Smrg				;;
37474835918Smrg			isi68 | isi)
37574835918Smrg				basic_machine=m68k-isi
37674835918Smrg				basic_os=sysv
37774835918Smrg				;;
37874835918Smrg			m68knommu)
37974835918Smrg				basic_machine=m68k-unknown
38074835918Smrg				basic_os=linux
38174835918Smrg				;;
38274835918Smrg			magnum | m3230)
38374835918Smrg				basic_machine=mips-mips
38474835918Smrg				basic_os=sysv
38574835918Smrg				;;
38674835918Smrg			merlin)
38774835918Smrg				basic_machine=ns32k-utek
38874835918Smrg				basic_os=sysv
38974835918Smrg				;;
39074835918Smrg			mingw64)
39174835918Smrg				basic_machine=x86_64-pc
39274835918Smrg				basic_os=mingw64
39374835918Smrg				;;
39474835918Smrg			mingw32)
39574835918Smrg				basic_machine=i686-pc
39674835918Smrg				basic_os=mingw32
39774835918Smrg				;;
39874835918Smrg			mingw32ce)
39974835918Smrg				basic_machine=arm-unknown
40074835918Smrg				basic_os=mingw32ce
40174835918Smrg				;;
40274835918Smrg			monitor)
40374835918Smrg				basic_machine=m68k-rom68k
40474835918Smrg				basic_os=coff
40574835918Smrg				;;
40674835918Smrg			morphos)
40774835918Smrg				basic_machine=powerpc-unknown
40874835918Smrg				basic_os=morphos
40974835918Smrg				;;
41074835918Smrg			moxiebox)
41174835918Smrg				basic_machine=moxie-unknown
41274835918Smrg				basic_os=moxiebox
41374835918Smrg				;;
41474835918Smrg			msdos)
41574835918Smrg				basic_machine=i386-pc
41674835918Smrg				basic_os=msdos
41774835918Smrg				;;
41874835918Smrg			msys)
41974835918Smrg				basic_machine=i686-pc
42074835918Smrg				basic_os=msys
42174835918Smrg				;;
42274835918Smrg			mvs)
42374835918Smrg				basic_machine=i370-ibm
42474835918Smrg				basic_os=mvs
42574835918Smrg				;;
42674835918Smrg			nacl)
42774835918Smrg				basic_machine=le32-unknown
42874835918Smrg				basic_os=nacl
42974835918Smrg				;;
43074835918Smrg			ncr3000)
43174835918Smrg				basic_machine=i486-ncr
43274835918Smrg				basic_os=sysv4
43374835918Smrg				;;
43474835918Smrg			netbsd386)
43574835918Smrg				basic_machine=i386-pc
43674835918Smrg				basic_os=netbsd
43774835918Smrg				;;
43874835918Smrg			netwinder)
43974835918Smrg				basic_machine=armv4l-rebel
44074835918Smrg				basic_os=linux
44174835918Smrg				;;
44274835918Smrg			news | news700 | news800 | news900)
44374835918Smrg				basic_machine=m68k-sony
44474835918Smrg				basic_os=newsos
44574835918Smrg				;;
44674835918Smrg			news1000)
44774835918Smrg				basic_machine=m68030-sony
44874835918Smrg				basic_os=newsos
44974835918Smrg				;;
45074835918Smrg			necv70)
45174835918Smrg				basic_machine=v70-nec
45274835918Smrg				basic_os=sysv
45374835918Smrg				;;
45474835918Smrg			nh3000)
45574835918Smrg				basic_machine=m68k-harris
45674835918Smrg				basic_os=cxux
45774835918Smrg				;;
45874835918Smrg			nh[45]000)
45974835918Smrg				basic_machine=m88k-harris
46074835918Smrg				basic_os=cxux
46174835918Smrg				;;
46274835918Smrg			nindy960)
46374835918Smrg				basic_machine=i960-intel
46474835918Smrg				basic_os=nindy
46574835918Smrg				;;
46674835918Smrg			mon960)
46774835918Smrg				basic_machine=i960-intel
46874835918Smrg				basic_os=mon960
46974835918Smrg				;;
47074835918Smrg			nonstopux)
47174835918Smrg				basic_machine=mips-compaq
47274835918Smrg				basic_os=nonstopux
47374835918Smrg				;;
47474835918Smrg			os400)
47574835918Smrg				basic_machine=powerpc-ibm
47674835918Smrg				basic_os=os400
47774835918Smrg				;;
47874835918Smrg			OSE68000 | ose68000)
47974835918Smrg				basic_machine=m68000-ericsson
48074835918Smrg				basic_os=ose
48174835918Smrg				;;
48274835918Smrg			os68k)
48374835918Smrg				basic_machine=m68k-none
48474835918Smrg				basic_os=os68k
48574835918Smrg				;;
48674835918Smrg			paragon)
48774835918Smrg				basic_machine=i860-intel
48874835918Smrg				basic_os=osf
48974835918Smrg				;;
49074835918Smrg			parisc)
49174835918Smrg				basic_machine=hppa-unknown
49274835918Smrg				basic_os=linux
49374835918Smrg				;;
49474835918Smrg			psp)
49574835918Smrg				basic_machine=mipsallegrexel-sony
49674835918Smrg				basic_os=psp
49774835918Smrg				;;
49874835918Smrg			pw32)
49974835918Smrg				basic_machine=i586-unknown
50074835918Smrg				basic_os=pw32
50174835918Smrg				;;
50274835918Smrg			rdos | rdos64)
50374835918Smrg				basic_machine=x86_64-pc
50474835918Smrg				basic_os=rdos
50574835918Smrg				;;
50674835918Smrg			rdos32)
50774835918Smrg				basic_machine=i386-pc
50874835918Smrg				basic_os=rdos
50974835918Smrg				;;
51074835918Smrg			rom68k)
51174835918Smrg				basic_machine=m68k-rom68k
51274835918Smrg				basic_os=coff
51374835918Smrg				;;
51474835918Smrg			sa29200)
51574835918Smrg				basic_machine=a29k-amd
51674835918Smrg				basic_os=udi
51774835918Smrg				;;
51874835918Smrg			sei)
51974835918Smrg				basic_machine=mips-sei
52074835918Smrg				basic_os=seiux
52174835918Smrg				;;
52274835918Smrg			sequent)
52374835918Smrg				basic_machine=i386-sequent
52474835918Smrg				basic_os=
52574835918Smrg				;;
52674835918Smrg			sps7)
52774835918Smrg				basic_machine=m68k-bull
52874835918Smrg				basic_os=sysv2
52974835918Smrg				;;
53074835918Smrg			st2000)
53174835918Smrg				basic_machine=m68k-tandem
53274835918Smrg				basic_os=
53374835918Smrg				;;
53474835918Smrg			stratus)
53574835918Smrg				basic_machine=i860-stratus
53674835918Smrg				basic_os=sysv4
53774835918Smrg				;;
53874835918Smrg			sun2)
53974835918Smrg				basic_machine=m68000-sun
54074835918Smrg				basic_os=
54174835918Smrg				;;
54274835918Smrg			sun2os3)
54374835918Smrg				basic_machine=m68000-sun
54474835918Smrg				basic_os=sunos3
54574835918Smrg				;;
54674835918Smrg			sun2os4)
54774835918Smrg				basic_machine=m68000-sun
54874835918Smrg				basic_os=sunos4
54974835918Smrg				;;
55074835918Smrg			sun3)
55174835918Smrg				basic_machine=m68k-sun
55274835918Smrg				basic_os=
55374835918Smrg				;;
55474835918Smrg			sun3os3)
55574835918Smrg				basic_machine=m68k-sun
55674835918Smrg				basic_os=sunos3
55774835918Smrg				;;
55874835918Smrg			sun3os4)
55974835918Smrg				basic_machine=m68k-sun
56074835918Smrg				basic_os=sunos4
56174835918Smrg				;;
56274835918Smrg			sun4)
56374835918Smrg				basic_machine=sparc-sun
56474835918Smrg				basic_os=
56574835918Smrg				;;
56674835918Smrg			sun4os3)
56774835918Smrg				basic_machine=sparc-sun
56874835918Smrg				basic_os=sunos3
56974835918Smrg				;;
57074835918Smrg			sun4os4)
57174835918Smrg				basic_machine=sparc-sun
57274835918Smrg				basic_os=sunos4
57374835918Smrg				;;
57474835918Smrg			sun4sol2)
57574835918Smrg				basic_machine=sparc-sun
57674835918Smrg				basic_os=solaris2
57774835918Smrg				;;
57874835918Smrg			sun386 | sun386i | roadrunner)
57974835918Smrg				basic_machine=i386-sun
58074835918Smrg				basic_os=
58174835918Smrg				;;
58274835918Smrg			sv1)
58374835918Smrg				basic_machine=sv1-cray
58474835918Smrg				basic_os=unicos
58574835918Smrg				;;
58674835918Smrg			symmetry)
58774835918Smrg				basic_machine=i386-sequent
58874835918Smrg				basic_os=dynix
58974835918Smrg				;;
59074835918Smrg			t3e)
59174835918Smrg				basic_machine=alphaev5-cray
59274835918Smrg				basic_os=unicos
59374835918Smrg				;;
59474835918Smrg			t90)
59574835918Smrg				basic_machine=t90-cray
59674835918Smrg				basic_os=unicos
59774835918Smrg				;;
59874835918Smrg			toad1)
59974835918Smrg				basic_machine=pdp10-xkl
60074835918Smrg				basic_os=tops20
60174835918Smrg				;;
60274835918Smrg			tpf)
60374835918Smrg				basic_machine=s390x-ibm
60474835918Smrg				basic_os=tpf
60574835918Smrg				;;
60674835918Smrg			udi29k)
60774835918Smrg				basic_machine=a29k-amd
60874835918Smrg				basic_os=udi
60974835918Smrg				;;
61074835918Smrg			ultra3)
61174835918Smrg				basic_machine=a29k-nyu
61274835918Smrg				basic_os=sym1
61374835918Smrg				;;
61474835918Smrg			v810 | necv810)
61574835918Smrg				basic_machine=v810-nec
61674835918Smrg				basic_os=none
61774835918Smrg				;;
61874835918Smrg			vaxv)
61974835918Smrg				basic_machine=vax-dec
62074835918Smrg				basic_os=sysv
62174835918Smrg				;;
62274835918Smrg			vms)
62374835918Smrg				basic_machine=vax-dec
62474835918Smrg				basic_os=vms
62574835918Smrg				;;
62674835918Smrg			vsta)
62774835918Smrg				basic_machine=i386-pc
62874835918Smrg				basic_os=vsta
62974835918Smrg				;;
63074835918Smrg			vxworks960)
63174835918Smrg				basic_machine=i960-wrs
63274835918Smrg				basic_os=vxworks
63374835918Smrg				;;
63474835918Smrg			vxworks68)
63574835918Smrg				basic_machine=m68k-wrs
63674835918Smrg				basic_os=vxworks
63774835918Smrg				;;
63874835918Smrg			vxworks29k)
63974835918Smrg				basic_machine=a29k-wrs
64074835918Smrg				basic_os=vxworks
64174835918Smrg				;;
64274835918Smrg			xbox)
64374835918Smrg				basic_machine=i686-pc
64474835918Smrg				basic_os=mingw32
64574835918Smrg				;;
64674835918Smrg			ymp)
64774835918Smrg				basic_machine=ymp-cray
64874835918Smrg				basic_os=unicos
64974835918Smrg				;;
65074835918Smrg			*)
65174835918Smrg				basic_machine=$1
65274835918Smrg				basic_os=
65374835918Smrg				;;
65474835918Smrg		esac
655a966c04fSmrg		;;
656a966c04fSmrgesac
657a966c04fSmrg
65874835918Smrg# Decode 1-component or ad-hoc basic machines
659a966c04fSmrgcase $basic_machine in
66074835918Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66174835918Smrg	# some cases the only manufacturer, in others, it is the most popular.
66274835918Smrg	w89k)
66374835918Smrg		cpu=hppa1.1
66474835918Smrg		vendor=winbond
665ac92798bSmrg		;;
66674835918Smrg	op50n)
66774835918Smrg		cpu=hppa1.1
66874835918Smrg		vendor=oki
669ac92798bSmrg		;;
67074835918Smrg	op60c)
67174835918Smrg		cpu=hppa1.1
67274835918Smrg		vendor=oki
673ac92798bSmrg		;;
67474835918Smrg	ibm*)
67574835918Smrg		cpu=i370
67674835918Smrg		vendor=ibm
677a966c04fSmrg		;;
67874835918Smrg	orion105)
67974835918Smrg		cpu=clipper
68074835918Smrg		vendor=highlevel
6811c235774Smrg		;;
68274835918Smrg	mac | mpw | mac-mpw)
68374835918Smrg		cpu=m68k
68474835918Smrg		vendor=apple
685a966c04fSmrg		;;
68674835918Smrg	pmac | pmac-mpw)
68774835918Smrg		cpu=powerpc
68874835918Smrg		vendor=apple
6891c235774Smrg		;;
6901c235774Smrg
691a966c04fSmrg	# Recognize the various machine names and aliases which stand
692a966c04fSmrg	# for a CPU type and a company and sometimes even an OS.
693a966c04fSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69474835918Smrg		cpu=m68000
69574835918Smrg		vendor=att
696a966c04fSmrg		;;
697a966c04fSmrg	3b*)
69874835918Smrg		cpu=we32k
69974835918Smrg		vendor=att
7002e2dd055Smrg		;;
7016e7d3316Smrg	bluegene*)
70274835918Smrg		cpu=powerpc
70374835918Smrg		vendor=ibm
70474835918Smrg		basic_os=cnk
705a966c04fSmrg		;;
706a966c04fSmrg	decsystem10* | dec10*)
70774835918Smrg		cpu=pdp10
70874835918Smrg		vendor=dec
70974835918Smrg		basic_os=tops10
710a966c04fSmrg		;;
711a966c04fSmrg	decsystem20* | dec20*)
71274835918Smrg		cpu=pdp10
71374835918Smrg		vendor=dec
71474835918Smrg		basic_os=tops20
715a966c04fSmrg		;;
716a966c04fSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717a966c04fSmrg	      | 3300-motorola | delta-motorola)
71874835918Smrg		cpu=m68k
71974835918Smrg		vendor=motorola
7206e7d3316Smrg		;;
721edce3322Smrg	dpx2*)
72274835918Smrg		cpu=m68k
72374835918Smrg		vendor=bull
72474835918Smrg		basic_os=sysv3
7251c235774Smrg		;;
7261c235774Smrg	encore | umax | mmax)
72774835918Smrg		cpu=ns32k
72874835918Smrg		vendor=encore
7291c235774Smrg		;;
73074835918Smrg	elxsi)
73174835918Smrg		cpu=elxsi
73274835918Smrg		vendor=elxsi
73374835918Smrg		basic_os=${basic_os:-bsd}
734a966c04fSmrg		;;
735a966c04fSmrg	fx2800)
73674835918Smrg		cpu=i860
73774835918Smrg		vendor=alliant
738a966c04fSmrg		;;
739a966c04fSmrg	genix)
74074835918Smrg		cpu=ns32k
74174835918Smrg		vendor=ns
742a966c04fSmrg		;;
743a966c04fSmrg	h3050r* | hiux*)
74474835918Smrg		cpu=hppa1.1
74574835918Smrg		vendor=hitachi
74674835918Smrg		basic_os=hiuxwe2
747a966c04fSmrg		;;
748a966c04fSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74974835918Smrg		cpu=hppa1.0
75074835918Smrg		vendor=hp
751a966c04fSmrg		;;
752a966c04fSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75374835918Smrg		cpu=m68000
75474835918Smrg		vendor=hp
755a966c04fSmrg		;;
756a966c04fSmrg	hp9k3[2-9][0-9])
75774835918Smrg		cpu=m68k
75874835918Smrg		vendor=hp
759a966c04fSmrg		;;
760a966c04fSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76174835918Smrg		cpu=hppa1.0
76274835918Smrg		vendor=hp
763a966c04fSmrg		;;
764a966c04fSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76574835918Smrg		cpu=hppa1.1
76674835918Smrg		vendor=hp
767a966c04fSmrg		;;
768a966c04fSmrg	hp9k78[0-9] | hp78[0-9])
769a966c04fSmrg		# FIXME: really hppa2.0-hp
77074835918Smrg		cpu=hppa1.1
77174835918Smrg		vendor=hp
772a966c04fSmrg		;;
773a966c04fSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774a966c04fSmrg		# FIXME: really hppa2.0-hp
77574835918Smrg		cpu=hppa1.1
77674835918Smrg		vendor=hp
777a966c04fSmrg		;;
778a966c04fSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77974835918Smrg		cpu=hppa1.1
78074835918Smrg		vendor=hp
781a966c04fSmrg		;;
782a966c04fSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78374835918Smrg		cpu=hppa1.0
78474835918Smrg		vendor=hp
785a966c04fSmrg		;;
786a966c04fSmrg	i*86v32)
78774835918Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78874835918Smrg		vendor=pc
78974835918Smrg		basic_os=sysv32
790a966c04fSmrg		;;
791a966c04fSmrg	i*86v4*)
79274835918Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79374835918Smrg		vendor=pc
79474835918Smrg		basic_os=sysv4
795a966c04fSmrg		;;
796a966c04fSmrg	i*86v)
79774835918Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79874835918Smrg		vendor=pc
79974835918Smrg		basic_os=sysv
800a966c04fSmrg		;;
801a966c04fSmrg	i*86sol2)
80274835918Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80374835918Smrg		vendor=pc
80474835918Smrg		basic_os=solaris2
8051c235774Smrg		;;
80674835918Smrg	j90 | j90-cray)
80774835918Smrg		cpu=j90
80874835918Smrg		vendor=cray
80974835918Smrg		basic_os=${basic_os:-unicos}
810a966c04fSmrg		;;
811a966c04fSmrg	iris | iris4d)
81274835918Smrg		cpu=mips
81374835918Smrg		vendor=sgi
81474835918Smrg		case $basic_os in
81574835918Smrg		    irix*)
816a966c04fSmrg			;;
817a966c04fSmrg		    *)
81874835918Smrg			basic_os=irix4
819a966c04fSmrg			;;
820a966c04fSmrg		esac
821a966c04fSmrg		;;
822a966c04fSmrg	miniframe)
82374835918Smrg		cpu=m68000
82474835918Smrg		vendor=convergent
8251c235774Smrg		;;
82674835918Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82774835918Smrg		cpu=m68k
82874835918Smrg		vendor=atari
82974835918Smrg		basic_os=mint
830a966c04fSmrg		;;
831a966c04fSmrg	news-3600 | risc-news)
83274835918Smrg		cpu=mips
83374835918Smrg		vendor=sony
83474835918Smrg		basic_os=newsos
835a966c04fSmrg		;;
836edce3322Smrg	next | m*-next)
83774835918Smrg		cpu=m68k
83874835918Smrg		vendor=next
83974835918Smrg		case $basic_os in
84074835918Smrg		    openstep*)
84174835918Smrg		        ;;
84274835918Smrg		    nextstep*)
843a966c04fSmrg			;;
84474835918Smrg		    ns2*)
84574835918Smrg		      basic_os=nextstep2
846a966c04fSmrg			;;
847a966c04fSmrg		    *)
84874835918Smrg		      basic_os=nextstep3
849a966c04fSmrg			;;
850a966c04fSmrg		esac
851a966c04fSmrg		;;
852a966c04fSmrg	np1)
85374835918Smrg		cpu=np1
85474835918Smrg		vendor=gould
855a966c04fSmrg		;;
856a966c04fSmrg	op50n-* | op60c-*)
85774835918Smrg		cpu=hppa1.1
85874835918Smrg		vendor=oki
85974835918Smrg		basic_os=proelf
860a966c04fSmrg		;;
861a966c04fSmrg	pa-hitachi)
86274835918Smrg		cpu=hppa1.1
86374835918Smrg		vendor=hitachi
86474835918Smrg		basic_os=hiuxwe2
8652e2dd055Smrg		;;
866a966c04fSmrg	pbd)
86774835918Smrg		cpu=sparc
86874835918Smrg		vendor=tti
869a966c04fSmrg		;;
870a966c04fSmrg	pbb)
87174835918Smrg		cpu=m68k
87274835918Smrg		vendor=tti
8731c235774Smrg		;;
87474835918Smrg	pc532)
87574835918Smrg		cpu=ns32k
87674835918Smrg		vendor=pc532
877a966c04fSmrg		;;
878a966c04fSmrg	pn)
87974835918Smrg		cpu=pn
88074835918Smrg		vendor=gould
881a966c04fSmrg		;;
88274835918Smrg	power)
88374835918Smrg		cpu=power
88474835918Smrg		vendor=ibm
885a966c04fSmrg		;;
88674835918Smrg	ps2)
88774835918Smrg		cpu=i386
88874835918Smrg		vendor=ibm
889a966c04fSmrg		;;
89074835918Smrg	rm[46]00)
89174835918Smrg		cpu=mips
89274835918Smrg		vendor=siemens
893a966c04fSmrg		;;
89474835918Smrg	rtpc | rtpc-*)
89574835918Smrg		cpu=romp
89674835918Smrg		vendor=ibm
8972e2dd055Smrg		;;
89874835918Smrg	sde)
89974835918Smrg		cpu=mipsisa32
90074835918Smrg		vendor=sde
90174835918Smrg		basic_os=${basic_os:-elf}
902a966c04fSmrg		;;
90374835918Smrg	simso-wrs)
90474835918Smrg		cpu=sparclite
90574835918Smrg		vendor=wrs
90674835918Smrg		basic_os=vxworks
907a966c04fSmrg		;;
90874835918Smrg	tower | tower-32)
90974835918Smrg		cpu=m68k
91074835918Smrg		vendor=ncr
911a966c04fSmrg		;;
91274835918Smrg	vpp*|vx|vx-*)
91374835918Smrg		cpu=f301
91474835918Smrg		vendor=fujitsu
9152e2dd055Smrg		;;
91674835918Smrg	w65)
91774835918Smrg		cpu=w65
91874835918Smrg		vendor=wdc
919a966c04fSmrg		;;
92074835918Smrg	w89k-*)
92174835918Smrg		cpu=hppa1.1
92274835918Smrg		vendor=winbond
92374835918Smrg		basic_os=proelf
924a966c04fSmrg		;;
92574835918Smrg	none)
92674835918Smrg		cpu=none
92774835918Smrg		vendor=none
928a966c04fSmrg		;;
92974835918Smrg	leon|leon[3-9])
93074835918Smrg		cpu=sparc
93174835918Smrg		vendor=$basic_machine
932a966c04fSmrg		;;
93374835918Smrg	leon-*|leon[3-9]-*)
93474835918Smrg		cpu=sparc
93574835918Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936a966c04fSmrg		;;
93774835918Smrg
93874835918Smrg	*-*)
93974835918Smrg		# shellcheck disable=SC2162
94074835918Smrg		saved_IFS=$IFS
94174835918Smrg		IFS="-" read cpu vendor <<EOF
94274835918Smrg$basic_machine
94374835918SmrgEOF
94474835918Smrg		IFS=$saved_IFS
945a966c04fSmrg		;;
94674835918Smrg	# We use `pc' rather than `unknown'
94774835918Smrg	# because (1) that's what they normally are, and
94874835918Smrg	# (2) the word "unknown" tends to confuse beginning users.
94974835918Smrg	i*86 | x86_64)
95074835918Smrg		cpu=$basic_machine
95174835918Smrg		vendor=pc
952ac92798bSmrg		;;
95374835918Smrg	# These rules are duplicated from below for sake of the special case above;
95474835918Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
95574835918Smrg	pc98)
95674835918Smrg		cpu=i386
95774835918Smrg		vendor=pc
958a966c04fSmrg		;;
95974835918Smrg	x64 | amd64)
96074835918Smrg		cpu=x86_64
96174835918Smrg		vendor=pc
962a966c04fSmrg		;;
96374835918Smrg	# Recognize the basic CPU types without company name.
96474835918Smrg	*)
96574835918Smrg		cpu=$basic_machine
96674835918Smrg		vendor=unknown
967a966c04fSmrg		;;
96874835918Smrgesac
96974835918Smrg
97074835918Smrgunset -v basic_machine
97174835918Smrg
97274835918Smrg# Decode basic machines in the full and proper CPU-Company form.
97374835918Smrgcase $cpu-$vendor in
97474835918Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97574835918Smrg	# some cases the only manufacturer, in others, it is the most popular.
97674835918Smrg	craynv-unknown)
97774835918Smrg		vendor=cray
97874835918Smrg		basic_os=${basic_os:-unicosmp}
979a966c04fSmrg		;;
98074835918Smrg	c90-unknown | c90-cray)
98174835918Smrg		vendor=cray
98274835918Smrg		basic_os=${Basic_os:-unicos}
983a966c04fSmrg		;;
98474835918Smrg	fx80-unknown)
98574835918Smrg		vendor=alliant
986a966c04fSmrg		;;
98774835918Smrg	romp-unknown)
98874835918Smrg		vendor=ibm
989a966c04fSmrg		;;
99074835918Smrg	mmix-unknown)
99174835918Smrg		vendor=knuth
992a966c04fSmrg		;;
99374835918Smrg	microblaze-unknown | microblazeel-unknown)
99474835918Smrg		vendor=xilinx
995a966c04fSmrg		;;
99674835918Smrg	rs6000-unknown)
99774835918Smrg		vendor=ibm
998a966c04fSmrg		;;
99974835918Smrg	vax-unknown)
100074835918Smrg		vendor=dec
1001a966c04fSmrg		;;
100274835918Smrg	pdp11-unknown)
100374835918Smrg		vendor=dec
1004a966c04fSmrg		;;
100574835918Smrg	we32k-unknown)
100674835918Smrg		vendor=att
1007a966c04fSmrg		;;
100874835918Smrg	cydra-unknown)
100974835918Smrg		vendor=cydrome
1010a966c04fSmrg		;;
101174835918Smrg	i370-ibm*)
101274835918Smrg		vendor=ibm
1013a966c04fSmrg		;;
101474835918Smrg	orion-unknown)
101574835918Smrg		vendor=highlevel
10162e2dd055Smrg		;;
101774835918Smrg	xps-unknown | xps100-unknown)
101874835918Smrg		cpu=xps100
101974835918Smrg		vendor=honeywell
1020a966c04fSmrg		;;
102174835918Smrg
102274835918Smrg	# Here we normalize CPU types with a missing or matching vendor
102374835918Smrg	armh-unknown | armh-alt)
102474835918Smrg		cpu=armv7l
102574835918Smrg		vendor=alt
102674835918Smrg		basic_os=${basic_os:-linux-gnueabihf}
1027a966c04fSmrg		;;
102874835918Smrg	dpx20-unknown | dpx20-bull)
102974835918Smrg		cpu=rs6000
103074835918Smrg		vendor=bull
103174835918Smrg		basic_os=${basic_os:-bosx}
1032a966c04fSmrg		;;
103374835918Smrg
103474835918Smrg	# Here we normalize CPU types irrespective of the vendor
103574835918Smrg	amd64-*)
103674835918Smrg		cpu=x86_64
1037a966c04fSmrg		;;
103874835918Smrg	blackfin-*)
103974835918Smrg		cpu=bfin
104074835918Smrg		basic_os=linux
1041a966c04fSmrg		;;
104274835918Smrg	c54x-*)
104374835918Smrg		cpu=tic54x
1044a966c04fSmrg		;;
104574835918Smrg	c55x-*)
104674835918Smrg		cpu=tic55x
1047a966c04fSmrg		;;
104874835918Smrg	c6x-*)
104974835918Smrg		cpu=tic6x
1050a966c04fSmrg		;;
105174835918Smrg	e500v[12]-*)
105274835918Smrg		cpu=powerpc
105374835918Smrg		basic_os=${basic_os}"spe"
1054a966c04fSmrg		;;
105574835918Smrg	mips3*-*)
105674835918Smrg		cpu=mips64
1057a966c04fSmrg		;;
105874835918Smrg	ms1-*)
105974835918Smrg		cpu=mt
1060a966c04fSmrg		;;
106174835918Smrg	m68knommu-*)
106274835918Smrg		cpu=m68k
106374835918Smrg		basic_os=linux
1064a966c04fSmrg		;;
106574835918Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106674835918Smrg		cpu=s12z
1067a966c04fSmrg		;;
106874835918Smrg	openrisc-*)
106974835918Smrg		cpu=or32
1070a966c04fSmrg		;;
107174835918Smrg	parisc-*)
107274835918Smrg		cpu=hppa
107374835918Smrg		basic_os=linux
1074a966c04fSmrg		;;
107574835918Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107674835918Smrg		cpu=i586
1077a966c04fSmrg		;;
107852dc082bSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
107974835918Smrg		cpu=i686
1080a966c04fSmrg		;;
108174835918Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108274835918Smrg		cpu=i686
1083a966c04fSmrg		;;
108474835918Smrg	pentium4-*)
108574835918Smrg		cpu=i786
1086ac92798bSmrg		;;
108774835918Smrg	pc98-*)
108874835918Smrg		cpu=i386
1089a966c04fSmrg		;;
109074835918Smrg	ppc-* | ppcbe-*)
109174835918Smrg		cpu=powerpc
1092a966c04fSmrg		;;
109374835918Smrg	ppcle-* | powerpclittle-*)
109474835918Smrg		cpu=powerpcle
10956e7d3316Smrg		;;
109674835918Smrg	ppc64-*)
109774835918Smrg		cpu=powerpc64
1098a966c04fSmrg		;;
109974835918Smrg	ppc64le-* | powerpc64little-*)
110074835918Smrg		cpu=powerpc64le
1101a966c04fSmrg		;;
110274835918Smrg	sb1-*)
110374835918Smrg		cpu=mipsisa64sb1
1104a966c04fSmrg		;;
110574835918Smrg	sb1el-*)
110674835918Smrg		cpu=mipsisa64sb1el
1107a966c04fSmrg		;;
110874835918Smrg	sh5e[lb]-*)
110974835918Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110a966c04fSmrg		;;
111174835918Smrg	spur-*)
111274835918Smrg		cpu=spur
11131c235774Smrg		;;
111474835918Smrg	strongarm-* | thumb-*)
111574835918Smrg		cpu=arm
11161c235774Smrg		;;
111774835918Smrg	tx39-*)
111874835918Smrg		cpu=mipstx39
11191c235774Smrg		;;
112074835918Smrg	tx39el-*)
112174835918Smrg		cpu=mipstx39el
11221c235774Smrg		;;
112374835918Smrg	x64-*)
112474835918Smrg		cpu=x86_64
1125a966c04fSmrg		;;
1126edce3322Smrg	xscale-* | xscalee[bl]-*)
112774835918Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128a966c04fSmrg		;;
112974835918Smrg	arm64-* | aarch64le-*)
113074835918Smrg		cpu=aarch64
113119569120Smrg		;;
1132edce3322Smrg
113374835918Smrg	# Recognize the canonical CPU Types that limit and/or modify the
113474835918Smrg	# company names they are paired with.
113574835918Smrg	cr16-*)
113674835918Smrg		basic_os=${basic_os:-elf}
1137a966c04fSmrg		;;
113874835918Smrg	crisv32-* | etraxfs*-*)
113974835918Smrg		cpu=crisv32
114074835918Smrg		vendor=axis
1141a966c04fSmrg		;;
114274835918Smrg	cris-* | etrax*-*)
114374835918Smrg		cpu=cris
114474835918Smrg		vendor=axis
1145a966c04fSmrg		;;
114674835918Smrg	crx-*)
114774835918Smrg		basic_os=${basic_os:-elf}
1148a966c04fSmrg		;;
114974835918Smrg	neo-tandem)
115074835918Smrg		cpu=neo
115174835918Smrg		vendor=tandem
1152a966c04fSmrg		;;
115374835918Smrg	nse-tandem)
115474835918Smrg		cpu=nse
115574835918Smrg		vendor=tandem
11561c235774Smrg		;;
115774835918Smrg	nsr-tandem)
115874835918Smrg		cpu=nsr
115974835918Smrg		vendor=tandem
11601c235774Smrg		;;
116174835918Smrg	nsv-tandem)
116274835918Smrg		cpu=nsv
116374835918Smrg		vendor=tandem
11641c235774Smrg		;;
116574835918Smrg	nsx-tandem)
116674835918Smrg		cpu=nsx
116774835918Smrg		vendor=tandem
11681c235774Smrg		;;
116974835918Smrg	mipsallegrexel-sony)
117074835918Smrg		cpu=mipsallegrexel
117174835918Smrg		vendor=sony
11721c235774Smrg		;;
117374835918Smrg	tile*-*)
117474835918Smrg		basic_os=${basic_os:-linux-gnu}
1175a966c04fSmrg		;;
117674835918Smrg
1177a966c04fSmrg	*)
117874835918Smrg		# Recognize the canonical CPU types that are allowed with any
117974835918Smrg		# company name.
118074835918Smrg		case $cpu in
118174835918Smrg			1750a | 580 \
118274835918Smrg			| a29k \
118374835918Smrg			| aarch64 | aarch64_be \
118474835918Smrg			| abacus \
118574835918Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118674835918Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118774835918Smrg			| alphapca5[67] | alpha64pca5[67] \
118874835918Smrg			| am33_2.0 \
118974835918Smrg			| amdgcn \
119074835918Smrg			| arc | arceb | arc32 | arc64 \
119174835918Smrg			| arm | arm[lb]e | arme[lb] | armv* \
119274835918Smrg			| avr | avr32 \
119374835918Smrg			| asmjs \
119474835918Smrg			| ba \
119574835918Smrg			| be32 | be64 \
119674835918Smrg			| bfin | bpf | bs2000 \
119774835918Smrg			| c[123]* | c30 | [cjt]90 | c4x \
119874835918Smrg			| c8051 | clipper | craynv | csky | cydra \
119974835918Smrg			| d10v | d30v | dlx | dsp16xx \
120074835918Smrg			| e2k | elxsi | epiphany \
120174835918Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120274835918Smrg			| h8300 | h8500 \
120374835918Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
120474835918Smrg			| hexagon \
120574835918Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120674835918Smrg			| ip2k | iq2000 \
120774835918Smrg			| k1om \
120874835918Smrg			| le32 | le64 \
120974835918Smrg			| lm32 \
121074835918Smrg			| loongarch32 | loongarch64 \
121174835918Smrg			| m32c | m32r | m32rle \
121274835918Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121374835918Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121474835918Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121574835918Smrg			| microblaze | microblazeel \
121674835918Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121774835918Smrg			| mips16 \
121874835918Smrg			| mips64 | mips64eb | mips64el \
121974835918Smrg			| mips64octeon | mips64octeonel \
122074835918Smrg			| mips64orion | mips64orionel \
122174835918Smrg			| mips64r5900 | mips64r5900el \
122274835918Smrg			| mips64vr | mips64vrel \
122374835918Smrg			| mips64vr4100 | mips64vr4100el \
122474835918Smrg			| mips64vr4300 | mips64vr4300el \
122574835918Smrg			| mips64vr5000 | mips64vr5000el \
122674835918Smrg			| mips64vr5900 | mips64vr5900el \
122774835918Smrg			| mipsisa32 | mipsisa32el \
122874835918Smrg			| mipsisa32r2 | mipsisa32r2el \
122974835918Smrg			| mipsisa32r3 | mipsisa32r3el \
123074835918Smrg			| mipsisa32r5 | mipsisa32r5el \
123174835918Smrg			| mipsisa32r6 | mipsisa32r6el \
123274835918Smrg			| mipsisa64 | mipsisa64el \
123374835918Smrg			| mipsisa64r2 | mipsisa64r2el \
123474835918Smrg			| mipsisa64r3 | mipsisa64r3el \
123574835918Smrg			| mipsisa64r5 | mipsisa64r5el \
123674835918Smrg			| mipsisa64r6 | mipsisa64r6el \
123774835918Smrg			| mipsisa64sb1 | mipsisa64sb1el \
123874835918Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
123974835918Smrg			| mipsr5900 | mipsr5900el \
124074835918Smrg			| mipstx39 | mipstx39el \
124174835918Smrg			| mmix \
124274835918Smrg			| mn10200 | mn10300 \
124374835918Smrg			| moxie \
124474835918Smrg			| mt \
124574835918Smrg			| msp430 \
124674835918Smrg			| nds32 | nds32le | nds32be \
124774835918Smrg			| nfp \
124874835918Smrg			| nios | nios2 | nios2eb | nios2el \
124974835918Smrg			| none | np1 | ns16k | ns32k | nvptx \
125074835918Smrg			| open8 \
125174835918Smrg			| or1k* \
125274835918Smrg			| or32 \
125374835918Smrg			| orion \
125474835918Smrg			| picochip \
125574835918Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125674835918Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125774835918Smrg			| pru \
125874835918Smrg			| pyramid \
125974835918Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
126074835918Smrg			| rl78 | romp | rs6000 | rx \
126174835918Smrg			| s390 | s390x \
126274835918Smrg			| score \
126374835918Smrg			| sh | shl \
126474835918Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126574835918Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126674835918Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126774835918Smrg			| sparclite \
126874835918Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126974835918Smrg			| spu \
127074835918Smrg			| tahoe \
127174835918Smrg			| thumbv7* \
127274835918Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
127374835918Smrg			| tron \
127474835918Smrg			| ubicom32 \
127574835918Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127674835918Smrg			| vax \
127774835918Smrg			| visium \
127874835918Smrg			| w65 \
127974835918Smrg			| wasm32 | wasm64 \
128074835918Smrg			| we32k \
128174835918Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
128274835918Smrg			| xstormy16 | xtensa* \
128374835918Smrg			| ymp \
128474835918Smrg			| z8k | z80)
128574835918Smrg				;;
128674835918Smrg
128774835918Smrg			*)
128874835918Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128974835918Smrg				exit 1
129074835918Smrg				;;
129174835918Smrg		esac
1292a966c04fSmrg		;;
1293a966c04fSmrgesac
1294a966c04fSmrg
1295a966c04fSmrg# Here we canonicalize certain aliases for manufacturers.
129674835918Smrgcase $vendor in
129774835918Smrg	digital*)
129874835918Smrg		vendor=dec
1299a966c04fSmrg		;;
130074835918Smrg	commodore*)
130174835918Smrg		vendor=cbm
1302a966c04fSmrg		;;
1303a966c04fSmrg	*)
1304a966c04fSmrg		;;
1305a966c04fSmrgesac
1306a966c04fSmrg
1307a966c04fSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308a966c04fSmrg
130974835918Smrgif test x$basic_os != x
1310a966c04fSmrgthen
131174835918Smrg
131274835918Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
131374835918Smrg# set os.
131474835918Smrgcase $basic_os in
131574835918Smrg	gnu/linux*)
131674835918Smrg		kernel=linux
131774835918Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131874835918Smrg		;;
131974835918Smrg	os2-emx)
132074835918Smrg		kernel=os2
132174835918Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
132274835918Smrg		;;
132374835918Smrg	nto-qnx*)
132474835918Smrg		kernel=nto
132574835918Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132674835918Smrg		;;
132774835918Smrg	*-*)
132874835918Smrg		# shellcheck disable=SC2162
132974835918Smrg		saved_IFS=$IFS
133074835918Smrg		IFS="-" read kernel os <<EOF
133174835918Smrg$basic_os
133274835918SmrgEOF
133374835918Smrg		IFS=$saved_IFS
133474835918Smrg		;;
133574835918Smrg	# Default OS when just kernel was specified
133674835918Smrg	nto*)
133774835918Smrg		kernel=nto
133874835918Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133974835918Smrg		;;
134074835918Smrg	linux*)
134174835918Smrg		kernel=linux
134274835918Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
134374835918Smrg		;;
134474835918Smrg	managarm*)
134574835918Smrg		kernel=managarm
134674835918Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
134774835918Smrg		;;
134874835918Smrg	*)
134974835918Smrg		kernel=
135074835918Smrg		os=$basic_os
135174835918Smrg		;;
135274835918Smrgesac
135374835918Smrg
135474835918Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
135574835918Smrg# etc.)
1356a966c04fSmrgcase $os in
1357edce3322Smrg	# First match some system type aliases that might get confused
1358edce3322Smrg	# with valid system types.
135974835918Smrg	# solaris* is a basic system type, with this one exception.
136074835918Smrg	auroraux)
136174835918Smrg		os=auroraux
13626e7d3316Smrg		;;
136374835918Smrg	bluegene*)
136474835918Smrg		os=cnk
1365a966c04fSmrg		;;
136674835918Smrg	solaris1 | solaris1.*)
136774835918Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368a966c04fSmrg		;;
136974835918Smrg	solaris)
137074835918Smrg		os=solaris2
1371a966c04fSmrg		;;
137274835918Smrg	unixware*)
137374835918Smrg		os=sysv4.2uw
1374a966c04fSmrg		;;
1375edce3322Smrg	# es1800 is here to avoid being matched by es* (a different OS)
137674835918Smrg	es1800*)
137774835918Smrg		os=ose
1378edce3322Smrg		;;
137974835918Smrg	# Some version numbers need modification
138074835918Smrg	chorusos*)
138174835918Smrg		os=chorusos
1382edce3322Smrg		;;
138374835918Smrg	isc)
138474835918Smrg		os=isc2.2
1385edce3322Smrg		;;
138674835918Smrg	sco6)
138774835918Smrg		os=sco5v6
1388edce3322Smrg		;;
138974835918Smrg	sco5)
139074835918Smrg		os=sco3.2v5
1391a966c04fSmrg		;;
139274835918Smrg	sco4)
139374835918Smrg		os=sco3.2v4
1394a966c04fSmrg		;;
139574835918Smrg	sco3.2.[4-9]*)
139674835918Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397a966c04fSmrg		;;
139874835918Smrg	sco*v* | scout)
139974835918Smrg		# Don't match below
1400a966c04fSmrg		;;
140174835918Smrg	sco*)
140274835918Smrg		os=sco3.2v2
140319569120Smrg		;;
140474835918Smrg	psos*)
140574835918Smrg		os=psos
1406a966c04fSmrg		;;
140774835918Smrg	qnx*)
140874835918Smrg		os=qnx
1409a966c04fSmrg		;;
141074835918Smrg	hiux*)
141174835918Smrg		os=hiuxwe2
1412a966c04fSmrg		;;
141374835918Smrg	lynx*178)
141474835918Smrg		os=lynxos178
1415a966c04fSmrg		;;
141674835918Smrg	lynx*5)
141774835918Smrg		os=lynxos5
1418a966c04fSmrg		;;
141974835918Smrg	lynxos*)
142074835918Smrg		# don't get caught up in next wildcard
1421a966c04fSmrg		;;
142274835918Smrg	lynx*)
142374835918Smrg		os=lynxos
1424a966c04fSmrg		;;
142574835918Smrg	mac[0-9]*)
142674835918Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427a966c04fSmrg		;;
142874835918Smrg	opened*)
142974835918Smrg		os=openedition
1430a966c04fSmrg		;;
143174835918Smrg	os400*)
143274835918Smrg		os=os400
1433a966c04fSmrg		;;
143474835918Smrg	sunos5*)
143574835918Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436a966c04fSmrg		;;
143774835918Smrg	sunos6*)
143874835918Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439a966c04fSmrg		;;
144074835918Smrg	wince*)
144174835918Smrg		os=wince
1442a966c04fSmrg		;;
144374835918Smrg	utek*)
144474835918Smrg		os=bsd
1445a966c04fSmrg		;;
144674835918Smrg	dynix*)
144774835918Smrg		os=bsd
144874835918Smrg		;;
144974835918Smrg	acis*)
145074835918Smrg		os=aos
145174835918Smrg		;;
145274835918Smrg	atheos*)
145374835918Smrg		os=atheos
145474835918Smrg		;;
145574835918Smrg	syllable*)
145674835918Smrg		os=syllable
1457edce3322Smrg		;;
145874835918Smrg	386bsd)
145974835918Smrg		os=bsd
146074835918Smrg		;;
146174835918Smrg	ctix* | uts*)
146274835918Smrg		os=sysv
1463edce3322Smrg		;;
146474835918Smrg	nova*)
146574835918Smrg		os=rtmk-nova
1466a966c04fSmrg		;;
146774835918Smrg	ns2)
146874835918Smrg		os=nextstep2
146974835918Smrg		;;
147074835918Smrg	# Preserve the version number of sinix5.
147174835918Smrg	sinix5.*)
147274835918Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473a966c04fSmrg		;;
147474835918Smrg	sinix*)
147574835918Smrg		os=sysv4
1476a966c04fSmrg		;;
147774835918Smrg	tpf*)
147874835918Smrg		os=tpf
1479a966c04fSmrg		;;
148074835918Smrg	triton*)
148174835918Smrg		os=sysv3
1482a966c04fSmrg		;;
148374835918Smrg	oss*)
148474835918Smrg		os=sysv3
1485a966c04fSmrg		;;
148674835918Smrg	svr4*)
148774835918Smrg		os=sysv4
1488a966c04fSmrg		;;
148974835918Smrg	svr3)
149074835918Smrg		os=sysv3
1491a966c04fSmrg		;;
149274835918Smrg	sysvr4)
149374835918Smrg		os=sysv4
1494a966c04fSmrg		;;
149574835918Smrg	ose*)
149674835918Smrg		os=ose
1497a966c04fSmrg		;;
149874835918Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149974835918Smrg		os=mint
1500a966c04fSmrg		;;
150174835918Smrg	dicos*)
150274835918Smrg		os=dicos
150374835918Smrg		;;
150474835918Smrg	pikeos*)
1505edce3322Smrg		# Until real need of OS specific support for
1506edce3322Smrg		# particular features comes up, bare metal
1507edce3322Smrg		# configurations are quite functional.
150874835918Smrg		case $cpu in
1509edce3322Smrg		    arm*)
151074835918Smrg			os=eabi
1511edce3322Smrg			;;
1512edce3322Smrg		    *)
151374835918Smrg			os=elf
1514edce3322Smrg			;;
1515edce3322Smrg		esac
1516a966c04fSmrg		;;
1517a966c04fSmrg	*)
151874835918Smrg		# No normalization, but not necessarily accepted, that comes below.
1519a966c04fSmrg		;;
1520a966c04fSmrgesac
152174835918Smrg
1522a966c04fSmrgelse
1523a966c04fSmrg
1524a966c04fSmrg# Here we handle the default operating systems that come with various machines.
1525a966c04fSmrg# The value should be what the vendor currently ships out the door with their
1526a966c04fSmrg# machine or put another way, the most popular os provided with the machine.
1527a966c04fSmrg
1528a966c04fSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529a966c04fSmrg# "-sun"), then you have to tell the case statement up towards the top
1530a966c04fSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531a966c04fSmrg# will signal an error saying that MANUFACTURER isn't an operating
1532a966c04fSmrg# system, and we'll never get to this point.
1533a966c04fSmrg
153474835918Smrgkernel=
153574835918Smrgcase $cpu-$vendor in
1536ac92798bSmrg	score-*)
153774835918Smrg		os=elf
15382e2dd055Smrg		;;
1539ac92798bSmrg	spu-*)
154074835918Smrg		os=elf
15412e2dd055Smrg		;;
1542a966c04fSmrg	*-acorn)
154374835918Smrg		os=riscix1.2
1544a966c04fSmrg		;;
1545a966c04fSmrg	arm*-rebel)
154674835918Smrg		kernel=linux
154774835918Smrg		os=gnu
1548a966c04fSmrg		;;
1549a966c04fSmrg	arm*-semi)
155074835918Smrg		os=aout
1551a966c04fSmrg		;;
1552ac92798bSmrg	c4x-* | tic4x-*)
155374835918Smrg		os=coff
1554ac92798bSmrg		;;
15559f00f3a1Smrg	c8051-*)
155674835918Smrg		os=elf
155774835918Smrg		;;
155874835918Smrg	clipper-intergraph)
155974835918Smrg		os=clix
15609f00f3a1Smrg		;;
1561ac92798bSmrg	hexagon-*)
156274835918Smrg		os=elf
15632e2dd055Smrg		;;
15646e7d3316Smrg	tic54x-*)
156574835918Smrg		os=coff
15666e7d3316Smrg		;;
15676e7d3316Smrg	tic55x-*)
156874835918Smrg		os=coff
15696e7d3316Smrg		;;
15706e7d3316Smrg	tic6x-*)
157174835918Smrg		os=coff
15726e7d3316Smrg		;;
1573a966c04fSmrg	# This must come before the *-dec entry.
1574a966c04fSmrg	pdp10-*)
157574835918Smrg		os=tops20
1576a966c04fSmrg		;;
1577a966c04fSmrg	pdp11-*)
157874835918Smrg		os=none
1579a966c04fSmrg		;;
1580a966c04fSmrg	*-dec | vax-*)
158174835918Smrg		os=ultrix4.2
1582a966c04fSmrg		;;
1583a966c04fSmrg	m68*-apollo)
158474835918Smrg		os=domain
1585a966c04fSmrg		;;
1586a966c04fSmrg	i386-sun)
158774835918Smrg		os=sunos4.0.2
1588a966c04fSmrg		;;
1589a966c04fSmrg	m68000-sun)
159074835918Smrg		os=sunos3
1591a966c04fSmrg		;;
1592a966c04fSmrg	m68*-cisco)
159374835918Smrg		os=aout
1594a966c04fSmrg		;;
1595ac92798bSmrg	mep-*)
159674835918Smrg		os=elf
15972e2dd055Smrg		;;
1598a966c04fSmrg	mips*-cisco)
159974835918Smrg		os=elf
1600a966c04fSmrg		;;
1601a966c04fSmrg	mips*-*)
160274835918Smrg		os=elf
1603ac92798bSmrg		;;
1604a966c04fSmrg	or32-*)
160574835918Smrg		os=coff
1606a966c04fSmrg		;;
1607a966c04fSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
160874835918Smrg		os=sysv3
1609a966c04fSmrg		;;
1610a966c04fSmrg	sparc-* | *-sun)
161174835918Smrg		os=sunos4.1.1
1612a966c04fSmrg		;;
1613edce3322Smrg	pru-*)
161474835918Smrg		os=elf
1615a966c04fSmrg		;;
1616edce3322Smrg	*-be)
161774835918Smrg		os=beos
1618a966c04fSmrg		;;
1619a966c04fSmrg	*-ibm)
162074835918Smrg		os=aix
1621a966c04fSmrg		;;
1622ac92798bSmrg	*-knuth)
162374835918Smrg		os=mmixware
1624a966c04fSmrg		;;
1625a966c04fSmrg	*-wec)
162674835918Smrg		os=proelf
1627a966c04fSmrg		;;
1628a966c04fSmrg	*-winbond)
162974835918Smrg		os=proelf
1630a966c04fSmrg		;;
1631a966c04fSmrg	*-oki)
163274835918Smrg		os=proelf
1633a966c04fSmrg		;;
1634a966c04fSmrg	*-hp)
163574835918Smrg		os=hpux
1636a966c04fSmrg		;;
1637a966c04fSmrg	*-hitachi)
163874835918Smrg		os=hiux
1639a966c04fSmrg		;;
1640a966c04fSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
164174835918Smrg		os=sysv
1642a966c04fSmrg		;;
1643a966c04fSmrg	*-cbm)
164474835918Smrg		os=amigaos
1645a966c04fSmrg		;;
1646a966c04fSmrg	*-dg)
164774835918Smrg		os=dgux
1648a966c04fSmrg		;;
1649a966c04fSmrg	*-dolphin)
165074835918Smrg		os=sysv3
1651a966c04fSmrg		;;
1652a966c04fSmrg	m68k-ccur)
165374835918Smrg		os=rtu
1654a966c04fSmrg		;;
1655a966c04fSmrg	m88k-omron*)
165674835918Smrg		os=luna
1657a966c04fSmrg		;;
1658edce3322Smrg	*-next)
165974835918Smrg		os=nextstep
1660a966c04fSmrg		;;
1661a966c04fSmrg	*-sequent)
166274835918Smrg		os=ptx
1663a966c04fSmrg		;;
1664a966c04fSmrg	*-crds)
166574835918Smrg		os=unos
1666a966c04fSmrg		;;
1667a966c04fSmrg	*-ns)
166874835918Smrg		os=genix
1669a966c04fSmrg		;;
1670a966c04fSmrg	i370-*)
167174835918Smrg		os=mvs
1672a966c04fSmrg		;;
1673a966c04fSmrg	*-gould)
167474835918Smrg		os=sysv
1675a966c04fSmrg		;;
1676a966c04fSmrg	*-highlevel)
167774835918Smrg		os=bsd
1678a966c04fSmrg		;;
1679a966c04fSmrg	*-encore)
168074835918Smrg		os=bsd
1681a966c04fSmrg		;;
1682a966c04fSmrg	*-sgi)
168374835918Smrg		os=irix
1684a966c04fSmrg		;;
1685a966c04fSmrg	*-siemens)
168674835918Smrg		os=sysv4
1687a966c04fSmrg		;;
1688a966c04fSmrg	*-masscomp)
168974835918Smrg		os=rtu
1690a966c04fSmrg		;;
1691a966c04fSmrg	f30[01]-fujitsu | f700-fujitsu)
169274835918Smrg		os=uxpv
1693a966c04fSmrg		;;
1694a966c04fSmrg	*-rom68k)
169574835918Smrg		os=coff
1696a966c04fSmrg		;;
1697a966c04fSmrg	*-*bug)
169874835918Smrg		os=coff
1699a966c04fSmrg		;;
1700a966c04fSmrg	*-apple)
170174835918Smrg		os=macos
1702a966c04fSmrg		;;
1703a966c04fSmrg	*-atari*)
170474835918Smrg		os=mint
170574835918Smrg		;;
170674835918Smrg	*-wrs)
170774835918Smrg		os=vxworks
1708a966c04fSmrg		;;
1709a966c04fSmrg	*)
171074835918Smrg		os=none
1711a966c04fSmrg		;;
1712a966c04fSmrgesac
171374835918Smrg
1714a966c04fSmrgfi
1715a966c04fSmrg
171674835918Smrg# Now, validate our (potentially fixed-up) OS.
171774835918Smrgcase $os in
171874835918Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
171974835918Smrg	musl* | newlib* | relibc* | uclibc*)
172074835918Smrg		;;
172174835918Smrg	# Likewise for "kernel-abi"
172274835918Smrg	eabi* | gnueabi*)
172374835918Smrg		;;
172474835918Smrg	# VxWorks passes extra cpu info in the 4th filed.
172574835918Smrg	simlinux | simwindows | spe)
172674835918Smrg		;;
172774835918Smrg	# Now accept the basic system types.
172874835918Smrg	# The portable systems comes first.
172974835918Smrg	# Each alternative MUST end in a * to match a version number.
173074835918Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
173174835918Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
173274835918Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
173374835918Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
173474835918Smrg	     | hiux* | abug | nacl* | netware* | windows* \
173574835918Smrg	     | os9* | macos* | osx* | ios* \
173674835918Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
173774835918Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
173874835918Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173974835918Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
174074835918Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
174174835918Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
174274835918Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
174374835918Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
174474835918Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
174574835918Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
174674835918Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
174774835918Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
174874835918Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174974835918Smrg	     | midipix* | mingw32* | mingw64* | mint* \
175074835918Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
175174835918Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
175274835918Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
175374835918Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
175474835918Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
175574835918Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
175674835918Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
175774835918Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
175874835918Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175974835918Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
176074835918Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
176174835918Smrg	     | fiwix* | mlibc* )
176274835918Smrg		;;
176374835918Smrg	# This one is extra strict with allowed versions
176474835918Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
176574835918Smrg		# Don't forget version if it is 3.2v4 or newer.
176674835918Smrg		;;
176774835918Smrg	none)
176874835918Smrg		;;
176974835918Smrg	kernel* )
177074835918Smrg		# Restricted further below
177174835918Smrg		;;
177274835918Smrg	*)
177374835918Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
177474835918Smrg		exit 1
177574835918Smrg		;;
177674835918Smrgesac
177774835918Smrg
177874835918Smrg# As a final step for OS-related things, validate the OS-kernel combination
177974835918Smrg# (given a valid OS), if there is a kernel.
178074835918Smrgcase $kernel-$os in
178174835918Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
178274835918Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
178374835918Smrg		;;
178474835918Smrg	uclinux-uclibc* )
178574835918Smrg		;;
178674835918Smrg	managarm-mlibc* | managarm-kernel* )
178774835918Smrg		;;
178874835918Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
178974835918Smrg		# These are just libc implementations, not actual OSes, and thus
179074835918Smrg		# require a kernel.
179174835918Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
179274835918Smrg		exit 1
179374835918Smrg		;;
179474835918Smrg	-kernel* )
179574835918Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
179674835918Smrg		exit 1
179774835918Smrg		;;
179874835918Smrg	*-kernel* )
179974835918Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
180074835918Smrg		exit 1
180174835918Smrg		;;
180274835918Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
180374835918Smrg		;;
180474835918Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
180574835918Smrg		;;
180674835918Smrg	nto-qnx*)
180774835918Smrg		;;
180874835918Smrg	os2-emx)
180974835918Smrg		;;
181074835918Smrg	*-eabi* | *-gnueabi*)
181174835918Smrg		;;
181274835918Smrg	-*)
181374835918Smrg		# Blank kernel with real OS is always fine.
181474835918Smrg		;;
181574835918Smrg	*-*)
181674835918Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
181774835918Smrg		exit 1
181874835918Smrg		;;
181974835918Smrgesac
182074835918Smrg
1821a966c04fSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1822a966c04fSmrg# manufacturer.  We pick the logical manufacturer.
182374835918Smrgcase $vendor in
182474835918Smrg	unknown)
182574835918Smrg		case $cpu-$os in
182674835918Smrg			*-riscix*)
1827a966c04fSmrg				vendor=acorn
1828a966c04fSmrg				;;
182974835918Smrg			*-sunos*)
1830a966c04fSmrg				vendor=sun
1831a966c04fSmrg				;;
183274835918Smrg			*-cnk* | *-aix*)
1833a966c04fSmrg				vendor=ibm
1834a966c04fSmrg				;;
183574835918Smrg			*-beos*)
1836a966c04fSmrg				vendor=be
1837a966c04fSmrg				;;
183874835918Smrg			*-hpux*)
1839a966c04fSmrg				vendor=hp
1840a966c04fSmrg				;;
184174835918Smrg			*-mpeix*)
1842a966c04fSmrg				vendor=hp
1843a966c04fSmrg				;;
184474835918Smrg			*-hiux*)
1845a966c04fSmrg				vendor=hitachi
1846a966c04fSmrg				;;
184774835918Smrg			*-unos*)
1848a966c04fSmrg				vendor=crds
1849a966c04fSmrg				;;
185074835918Smrg			*-dgux*)
1851a966c04fSmrg				vendor=dg
1852a966c04fSmrg				;;
185374835918Smrg			*-luna*)
1854a966c04fSmrg				vendor=omron
1855a966c04fSmrg				;;
185674835918Smrg			*-genix*)
1857a966c04fSmrg				vendor=ns
1858a966c04fSmrg				;;
185974835918Smrg			*-clix*)
186074835918Smrg				vendor=intergraph
186174835918Smrg				;;
186274835918Smrg			*-mvs* | *-opened*)
186374835918Smrg				vendor=ibm
186474835918Smrg				;;
186574835918Smrg			*-os400*)
1866a966c04fSmrg				vendor=ibm
1867a966c04fSmrg				;;
186874835918Smrg			s390-* | s390x-*)
1869a966c04fSmrg				vendor=ibm
1870a966c04fSmrg				;;
187174835918Smrg			*-ptx*)
1872a966c04fSmrg				vendor=sequent
1873a966c04fSmrg				;;
187474835918Smrg			*-tpf*)
1875a966c04fSmrg				vendor=ibm
1876a966c04fSmrg				;;
187774835918Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1878a966c04fSmrg				vendor=wrs
1879a966c04fSmrg				;;
188074835918Smrg			*-aux*)
1881a966c04fSmrg				vendor=apple
1882a966c04fSmrg				;;
188374835918Smrg			*-hms*)
1884a966c04fSmrg				vendor=hitachi
1885a966c04fSmrg				;;
188674835918Smrg			*-mpw* | *-macos*)
1887a966c04fSmrg				vendor=apple
1888a966c04fSmrg				;;
188974835918Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890a966c04fSmrg				vendor=atari
1891a966c04fSmrg				;;
189274835918Smrg			*-vos*)
1893a966c04fSmrg				vendor=stratus
1894a966c04fSmrg				;;
1895a966c04fSmrg		esac
1896a966c04fSmrg		;;
1897a966c04fSmrgesac
1898a966c04fSmrg
189974835918Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900a966c04fSmrgexit
1901a966c04fSmrg
1902a966c04fSmrg# Local variables:
190374835918Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904a966c04fSmrg# time-stamp-start: "timestamp='"
1905a966c04fSmrg# time-stamp-format: "%:y-%02m-%02d"
1906a966c04fSmrg# time-stamp-end: "'"
1907a966c04fSmrg# End:
1908