1b3307321Smrg#! /bin/sh
2b3307321Smrg# Configuration validation subroutine script.
36728f30eSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4b3307321Smrg
574b97a6cSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
674b97a6cSmrg
76728f30eSmrgtimestamp='2023-01-21'
8b3307321Smrg
974a3f230Smrg# This file is free software; you can redistribute it and/or modify it
1074a3f230Smrg# under the terms of the GNU General Public License as published by
116728f30eSmrg# the Free Software Foundation, either version 3 of the License, or
12b3307321Smrg# (at your option) any later version.
13b3307321Smrg#
1474a3f230Smrg# This program is distributed in the hope that it will be useful, but
1574a3f230Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1674a3f230Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1774a3f230Smrg# General Public License for more details.
18b3307321Smrg#
19b3307321Smrg# You should have received a copy of the GNU General Public License
2006ef0fecSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21afe13c8eSmrg#
22b3307321Smrg# As a special exception to the GNU General Public License, if you
23b3307321Smrg# distribute this file as part of a program that contains a
24b3307321Smrg# configuration script generated by Autoconf, you may include it under
2574a3f230Smrg# the same distribution terms that you use for the rest of that
2674a3f230Smrg# program.  This Exception is an additional permission under section 7
2774a3f230Smrg# of the GNU General Public License, version 3 ("GPLv3").
28b3307321Smrg
29afe13c8eSmrg
3006ef0fecSmrg# Please send patches to <config-patches@gnu.org>.
31b3307321Smrg#
32b3307321Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33b3307321Smrg# Supply the specified configuration type as an argument.
34b3307321Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35b3307321Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36b3307321Smrg
3729cb5710Smrg# You can get the latest version of this script from:
3874b97a6cSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3929cb5710Smrg
40b3307321Smrg# This file is supposed to be the same for all GNU packages
41b3307321Smrg# and recognize all the CPU types, system types and aliases
42b3307321Smrg# that are meaningful with *any* GNU software.
43b3307321Smrg# Each package is responsible for reporting which valid configurations
44b3307321Smrg# it does not support.  The user should be able to distinguish
45b3307321Smrg# a failure to support a valid configuration from a meaningless
46b3307321Smrg# configuration.
47b3307321Smrg
48b3307321Smrg# The goal of this file is to map all the various variations of a given
49b3307321Smrg# machine specification into a single specification in the form:
50b3307321Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51b3307321Smrg# or in some cases, the newer four-part form:
52b3307321Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53b3307321Smrg# It is wrong to echo any other type of specification.
54b3307321Smrg
5574b97a6cSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
5674b97a6cSmrg# about features and limitations of the classic Bourne shell that were
5774b97a6cSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
5874b97a6cSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5974b97a6cSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6074b97a6cSmrg# have a pre-POSIX /bin/sh.
6174b97a6cSmrg
62b3307321Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63b3307321Smrg
64b3307321Smrgusage="\
6506ef0fecSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66b3307321Smrg
67b3307321SmrgCanonicalize a configuration name.
68b3307321Smrg
6906ef0fecSmrgOptions:
70b3307321Smrg  -h, --help         print this help, then exit
71b3307321Smrg  -t, --time-stamp   print date of last modification, then exit
72b3307321Smrg  -v, --version      print version number, then exit
73b3307321Smrg
74b3307321SmrgReport bugs and patches to <config-patches@gnu.org>."
75b3307321Smrg
76b3307321Smrgversion="\
77b3307321SmrgGNU config.sub ($timestamp)
78b3307321Smrg
796728f30eSmrgCopyright 1992-2023 Free Software Foundation, Inc.
80b3307321Smrg
81b3307321SmrgThis is free software; see the source for copying conditions.  There is NO
82b3307321Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83b3307321Smrg
84b3307321Smrghelp="
85b3307321SmrgTry \`$me --help' for more information."
86b3307321Smrg
87b3307321Smrg# Parse command line
88b3307321Smrgwhile test $# -gt 0 ; do
89b3307321Smrg  case $1 in
90b3307321Smrg    --time-stamp | --time* | -t )
91afe13c8eSmrg       echo "$timestamp" ; exit ;;
92b3307321Smrg    --version | -v )
93afe13c8eSmrg       echo "$version" ; exit ;;
94b3307321Smrg    --help | --h* | -h )
95afe13c8eSmrg       echo "$usage"; exit ;;
96b3307321Smrg    -- )     # Stop option processing
97b3307321Smrg       shift; break ;;
98b3307321Smrg    - )	# Use stdin as input.
99b3307321Smrg       break ;;
100b3307321Smrg    -* )
10174b97a6cSmrg       echo "$me: invalid option $1$help" >&2
102b3307321Smrg       exit 1 ;;
103b3307321Smrg
104b3307321Smrg    *local*)
105b3307321Smrg       # First pass through any local machine types.
10606ef0fecSmrg       echo "$1"
107afe13c8eSmrg       exit ;;
108b3307321Smrg
109b3307321Smrg    * )
110b3307321Smrg       break ;;
111b3307321Smrg  esac
112b3307321Smrgdone
113b3307321Smrg
114b3307321Smrgcase $# in
115b3307321Smrg 0) echo "$me: missing argument$help" >&2
116b3307321Smrg    exit 1;;
117b3307321Smrg 1) ;;
118b3307321Smrg *) echo "$me: too many arguments$help" >&2
119b3307321Smrg    exit 1;;
120b3307321Smrgesac
121b3307321Smrg
12274b97a6cSmrg# Split fields of configuration type
12374b97a6cSmrg# shellcheck disable=SC2162
1246728f30eSmrgsaved_IFS=$IFS
12574b97a6cSmrgIFS="-" read field1 field2 field3 field4 <<EOF
12674b97a6cSmrg$1
12774b97a6cSmrgEOF
1286728f30eSmrgIFS=$saved_IFS
129b3307321Smrg
13074b97a6cSmrg# Separate into logical components for further validation
13174b97a6cSmrgcase $1 in
13274b97a6cSmrg	*-*-*-*-*)
13374b97a6cSmrg		echo Invalid configuration \`"$1"\': more than four components >&2
13474b97a6cSmrg		exit 1
13574a3f230Smrg		;;
13674b97a6cSmrg	*-*-*-*)
13774b97a6cSmrg		basic_machine=$field1-$field2
13874b97a6cSmrg		basic_os=$field3-$field4
139b3307321Smrg		;;
14074b97a6cSmrg	*-*-*)
14174b97a6cSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14274b97a6cSmrg		# parts
14374b97a6cSmrg		maybe_os=$field2-$field3
14474b97a6cSmrg		case $maybe_os in
14574b97a6cSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
14674b97a6cSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14774b97a6cSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1486728f30eSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
14974b97a6cSmrg				basic_machine=$field1
15074b97a6cSmrg				basic_os=$maybe_os
15174b97a6cSmrg				;;
15274b97a6cSmrg			android-linux)
15374b97a6cSmrg				basic_machine=$field1-unknown
15474b97a6cSmrg				basic_os=linux-android
15574b97a6cSmrg				;;
15674b97a6cSmrg			*)
15774b97a6cSmrg				basic_machine=$field1-$field2
15874b97a6cSmrg				basic_os=$field3
15974b97a6cSmrg				;;
16074b97a6cSmrg		esac
161b3307321Smrg		;;
16274b97a6cSmrg	*-*)
16374b97a6cSmrg		# A lone config we happen to match not fitting any pattern
16474b97a6cSmrg		case $field1-$field2 in
16574b97a6cSmrg			decstation-3100)
16674b97a6cSmrg				basic_machine=mips-dec
16774b97a6cSmrg				basic_os=
16874b97a6cSmrg				;;
16974b97a6cSmrg			*-*)
17074b97a6cSmrg				# Second component is usually, but not always the OS
17174b97a6cSmrg				case $field2 in
17274b97a6cSmrg					# Prevent following clause from handling this valid os
17374b97a6cSmrg					sun*os*)
17474b97a6cSmrg						basic_machine=$field1
17574b97a6cSmrg						basic_os=$field2
17674b97a6cSmrg						;;
1776728f30eSmrg					zephyr*)
1786728f30eSmrg						basic_machine=$field1-unknown
1796728f30eSmrg						basic_os=$field2
1806728f30eSmrg						;;
18174b97a6cSmrg					# Manufacturers
18274b97a6cSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18374b97a6cSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18474b97a6cSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18574b97a6cSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18674b97a6cSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18774b97a6cSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18874b97a6cSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18974b97a6cSmrg					| microblaze* | sim | cisco \
19074b97a6cSmrg					| oki | wec | wrs | winbond)
19174b97a6cSmrg						basic_machine=$field1-$field2
19274b97a6cSmrg						basic_os=
19374b97a6cSmrg						;;
19474b97a6cSmrg					*)
19574b97a6cSmrg						basic_machine=$field1
19674b97a6cSmrg						basic_os=$field2
19774b97a6cSmrg						;;
19874b97a6cSmrg				esac
19974b97a6cSmrg			;;
20074b97a6cSmrg		esac
201b3307321Smrg		;;
20274b97a6cSmrg	*)
20374b97a6cSmrg		# Convert single-component short-hands not valid as part of
20474b97a6cSmrg		# multi-component configurations.
20574b97a6cSmrg		case $field1 in
20674b97a6cSmrg			386bsd)
20774b97a6cSmrg				basic_machine=i386-pc
20874b97a6cSmrg				basic_os=bsd
20974b97a6cSmrg				;;
21074b97a6cSmrg			a29khif)
21174b97a6cSmrg				basic_machine=a29k-amd
21274b97a6cSmrg				basic_os=udi
21374b97a6cSmrg				;;
21474b97a6cSmrg			adobe68k)
21574b97a6cSmrg				basic_machine=m68010-adobe
21674b97a6cSmrg				basic_os=scout
21774b97a6cSmrg				;;
21874b97a6cSmrg			alliant)
21974b97a6cSmrg				basic_machine=fx80-alliant
22074b97a6cSmrg				basic_os=
22174b97a6cSmrg				;;
22274b97a6cSmrg			altos | altos3068)
22374b97a6cSmrg				basic_machine=m68k-altos
22474b97a6cSmrg				basic_os=
22574b97a6cSmrg				;;
22674b97a6cSmrg			am29k)
22774b97a6cSmrg				basic_machine=a29k-none
22874b97a6cSmrg				basic_os=bsd
22974b97a6cSmrg				;;
23074b97a6cSmrg			amdahl)
23174b97a6cSmrg				basic_machine=580-amdahl
23274b97a6cSmrg				basic_os=sysv
23374b97a6cSmrg				;;
23474b97a6cSmrg			amiga)
23574b97a6cSmrg				basic_machine=m68k-unknown
23674b97a6cSmrg				basic_os=
23774b97a6cSmrg				;;
23874b97a6cSmrg			amigaos | amigados)
23974b97a6cSmrg				basic_machine=m68k-unknown
24074b97a6cSmrg				basic_os=amigaos
24174b97a6cSmrg				;;
24274b97a6cSmrg			amigaunix | amix)
24374b97a6cSmrg				basic_machine=m68k-unknown
24474b97a6cSmrg				basic_os=sysv4
24574b97a6cSmrg				;;
24674b97a6cSmrg			apollo68)
24774b97a6cSmrg				basic_machine=m68k-apollo
24874b97a6cSmrg				basic_os=sysv
24974b97a6cSmrg				;;
25074b97a6cSmrg			apollo68bsd)
25174b97a6cSmrg				basic_machine=m68k-apollo
25274b97a6cSmrg				basic_os=bsd
25374b97a6cSmrg				;;
25474b97a6cSmrg			aros)
25574b97a6cSmrg				basic_machine=i386-pc
25674b97a6cSmrg				basic_os=aros
25774b97a6cSmrg				;;
25874b97a6cSmrg			aux)
25974b97a6cSmrg				basic_machine=m68k-apple
26074b97a6cSmrg				basic_os=aux
26174b97a6cSmrg				;;
26274b97a6cSmrg			balance)
26374b97a6cSmrg				basic_machine=ns32k-sequent
26474b97a6cSmrg				basic_os=dynix
26574b97a6cSmrg				;;
26674b97a6cSmrg			blackfin)
26774b97a6cSmrg				basic_machine=bfin-unknown
26874b97a6cSmrg				basic_os=linux
26974b97a6cSmrg				;;
27074b97a6cSmrg			cegcc)
27174b97a6cSmrg				basic_machine=arm-unknown
27274b97a6cSmrg				basic_os=cegcc
27374b97a6cSmrg				;;
27474b97a6cSmrg			convex-c1)
27574b97a6cSmrg				basic_machine=c1-convex
27674b97a6cSmrg				basic_os=bsd
27774b97a6cSmrg				;;
27874b97a6cSmrg			convex-c2)
27974b97a6cSmrg				basic_machine=c2-convex
28074b97a6cSmrg				basic_os=bsd
28174b97a6cSmrg				;;
28274b97a6cSmrg			convex-c32)
28374b97a6cSmrg				basic_machine=c32-convex
28474b97a6cSmrg				basic_os=bsd
28574b97a6cSmrg				;;
28674b97a6cSmrg			convex-c34)
28774b97a6cSmrg				basic_machine=c34-convex
28874b97a6cSmrg				basic_os=bsd
28974b97a6cSmrg				;;
29074b97a6cSmrg			convex-c38)
29174b97a6cSmrg				basic_machine=c38-convex
29274b97a6cSmrg				basic_os=bsd
29374b97a6cSmrg				;;
29474b97a6cSmrg			cray)
29574b97a6cSmrg				basic_machine=j90-cray
29674b97a6cSmrg				basic_os=unicos
29774b97a6cSmrg				;;
29874b97a6cSmrg			crds | unos)
29974b97a6cSmrg				basic_machine=m68k-crds
30074b97a6cSmrg				basic_os=
30174b97a6cSmrg				;;
30274b97a6cSmrg			da30)
30374b97a6cSmrg				basic_machine=m68k-da30
30474b97a6cSmrg				basic_os=
30574b97a6cSmrg				;;
30674b97a6cSmrg			decstation | pmax | pmin | dec3100 | decstatn)
30774b97a6cSmrg				basic_machine=mips-dec
30874b97a6cSmrg				basic_os=
30974b97a6cSmrg				;;
31074b97a6cSmrg			delta88)
31174b97a6cSmrg				basic_machine=m88k-motorola
31274b97a6cSmrg				basic_os=sysv3
31374b97a6cSmrg				;;
31474b97a6cSmrg			dicos)
31574b97a6cSmrg				basic_machine=i686-pc
31674b97a6cSmrg				basic_os=dicos
31774b97a6cSmrg				;;
31874b97a6cSmrg			djgpp)
31974b97a6cSmrg				basic_machine=i586-pc
32074b97a6cSmrg				basic_os=msdosdjgpp
32174b97a6cSmrg				;;
32274b97a6cSmrg			ebmon29k)
32374b97a6cSmrg				basic_machine=a29k-amd
32474b97a6cSmrg				basic_os=ebmon
32574b97a6cSmrg				;;
32674b97a6cSmrg			es1800 | OSE68k | ose68k | ose | OSE)
32774b97a6cSmrg				basic_machine=m68k-ericsson
32874b97a6cSmrg				basic_os=ose
32974b97a6cSmrg				;;
33074b97a6cSmrg			gmicro)
33174b97a6cSmrg				basic_machine=tron-gmicro
33274b97a6cSmrg				basic_os=sysv
33374b97a6cSmrg				;;
33474b97a6cSmrg			go32)
33574b97a6cSmrg				basic_machine=i386-pc
33674b97a6cSmrg				basic_os=go32
33774b97a6cSmrg				;;
33874b97a6cSmrg			h8300hms)
33974b97a6cSmrg				basic_machine=h8300-hitachi
34074b97a6cSmrg				basic_os=hms
34174b97a6cSmrg				;;
34274b97a6cSmrg			h8300xray)
34374b97a6cSmrg				basic_machine=h8300-hitachi
34474b97a6cSmrg				basic_os=xray
34574b97a6cSmrg				;;
34674b97a6cSmrg			h8500hms)
34774b97a6cSmrg				basic_machine=h8500-hitachi
34874b97a6cSmrg				basic_os=hms
34974b97a6cSmrg				;;
35074b97a6cSmrg			harris)
35174b97a6cSmrg				basic_machine=m88k-harris
35274b97a6cSmrg				basic_os=sysv3
35374b97a6cSmrg				;;
35474b97a6cSmrg			hp300 | hp300hpux)
35574b97a6cSmrg				basic_machine=m68k-hp
35674b97a6cSmrg				basic_os=hpux
35774b97a6cSmrg				;;
35874b97a6cSmrg			hp300bsd)
35974b97a6cSmrg				basic_machine=m68k-hp
36074b97a6cSmrg				basic_os=bsd
36174b97a6cSmrg				;;
36274b97a6cSmrg			hppaosf)
36374b97a6cSmrg				basic_machine=hppa1.1-hp
36474b97a6cSmrg				basic_os=osf
36574b97a6cSmrg				;;
36674b97a6cSmrg			hppro)
36774b97a6cSmrg				basic_machine=hppa1.1-hp
36874b97a6cSmrg				basic_os=proelf
36974b97a6cSmrg				;;
37074b97a6cSmrg			i386mach)
37174b97a6cSmrg				basic_machine=i386-mach
37274b97a6cSmrg				basic_os=mach
37374b97a6cSmrg				;;
37474b97a6cSmrg			isi68 | isi)
37574b97a6cSmrg				basic_machine=m68k-isi
37674b97a6cSmrg				basic_os=sysv
37774b97a6cSmrg				;;
37874b97a6cSmrg			m68knommu)
37974b97a6cSmrg				basic_machine=m68k-unknown
38074b97a6cSmrg				basic_os=linux
38174b97a6cSmrg				;;
38274b97a6cSmrg			magnum | m3230)
38374b97a6cSmrg				basic_machine=mips-mips
38474b97a6cSmrg				basic_os=sysv
38574b97a6cSmrg				;;
38674b97a6cSmrg			merlin)
38774b97a6cSmrg				basic_machine=ns32k-utek
38874b97a6cSmrg				basic_os=sysv
38974b97a6cSmrg				;;
39074b97a6cSmrg			mingw64)
39174b97a6cSmrg				basic_machine=x86_64-pc
39274b97a6cSmrg				basic_os=mingw64
39374b97a6cSmrg				;;
39474b97a6cSmrg			mingw32)
39574b97a6cSmrg				basic_machine=i686-pc
39674b97a6cSmrg				basic_os=mingw32
39774b97a6cSmrg				;;
39874b97a6cSmrg			mingw32ce)
39974b97a6cSmrg				basic_machine=arm-unknown
40074b97a6cSmrg				basic_os=mingw32ce
40174b97a6cSmrg				;;
40274b97a6cSmrg			monitor)
40374b97a6cSmrg				basic_machine=m68k-rom68k
40474b97a6cSmrg				basic_os=coff
40574b97a6cSmrg				;;
40674b97a6cSmrg			morphos)
40774b97a6cSmrg				basic_machine=powerpc-unknown
40874b97a6cSmrg				basic_os=morphos
40974b97a6cSmrg				;;
41074b97a6cSmrg			moxiebox)
41174b97a6cSmrg				basic_machine=moxie-unknown
41274b97a6cSmrg				basic_os=moxiebox
41374b97a6cSmrg				;;
41474b97a6cSmrg			msdos)
41574b97a6cSmrg				basic_machine=i386-pc
41674b97a6cSmrg				basic_os=msdos
41774b97a6cSmrg				;;
41874b97a6cSmrg			msys)
41974b97a6cSmrg				basic_machine=i686-pc
42074b97a6cSmrg				basic_os=msys
42174b97a6cSmrg				;;
42274b97a6cSmrg			mvs)
42374b97a6cSmrg				basic_machine=i370-ibm
42474b97a6cSmrg				basic_os=mvs
42574b97a6cSmrg				;;
42674b97a6cSmrg			nacl)
42774b97a6cSmrg				basic_machine=le32-unknown
42874b97a6cSmrg				basic_os=nacl
42974b97a6cSmrg				;;
43074b97a6cSmrg			ncr3000)
43174b97a6cSmrg				basic_machine=i486-ncr
43274b97a6cSmrg				basic_os=sysv4
43374b97a6cSmrg				;;
43474b97a6cSmrg			netbsd386)
43574b97a6cSmrg				basic_machine=i386-pc
43674b97a6cSmrg				basic_os=netbsd
43774b97a6cSmrg				;;
43874b97a6cSmrg			netwinder)
43974b97a6cSmrg				basic_machine=armv4l-rebel
44074b97a6cSmrg				basic_os=linux
44174b97a6cSmrg				;;
44274b97a6cSmrg			news | news700 | news800 | news900)
44374b97a6cSmrg				basic_machine=m68k-sony
44474b97a6cSmrg				basic_os=newsos
44574b97a6cSmrg				;;
44674b97a6cSmrg			news1000)
44774b97a6cSmrg				basic_machine=m68030-sony
44874b97a6cSmrg				basic_os=newsos
44974b97a6cSmrg				;;
45074b97a6cSmrg			necv70)
45174b97a6cSmrg				basic_machine=v70-nec
45274b97a6cSmrg				basic_os=sysv
45374b97a6cSmrg				;;
45474b97a6cSmrg			nh3000)
45574b97a6cSmrg				basic_machine=m68k-harris
45674b97a6cSmrg				basic_os=cxux
45774b97a6cSmrg				;;
45874b97a6cSmrg			nh[45]000)
45974b97a6cSmrg				basic_machine=m88k-harris
46074b97a6cSmrg				basic_os=cxux
46174b97a6cSmrg				;;
46274b97a6cSmrg			nindy960)
46374b97a6cSmrg				basic_machine=i960-intel
46474b97a6cSmrg				basic_os=nindy
46574b97a6cSmrg				;;
46674b97a6cSmrg			mon960)
46774b97a6cSmrg				basic_machine=i960-intel
46874b97a6cSmrg				basic_os=mon960
46974b97a6cSmrg				;;
47074b97a6cSmrg			nonstopux)
47174b97a6cSmrg				basic_machine=mips-compaq
47274b97a6cSmrg				basic_os=nonstopux
47374b97a6cSmrg				;;
47474b97a6cSmrg			os400)
47574b97a6cSmrg				basic_machine=powerpc-ibm
47674b97a6cSmrg				basic_os=os400
47774b97a6cSmrg				;;
47874b97a6cSmrg			OSE68000 | ose68000)
47974b97a6cSmrg				basic_machine=m68000-ericsson
48074b97a6cSmrg				basic_os=ose
48174b97a6cSmrg				;;
48274b97a6cSmrg			os68k)
48374b97a6cSmrg				basic_machine=m68k-none
48474b97a6cSmrg				basic_os=os68k
48574b97a6cSmrg				;;
48674b97a6cSmrg			paragon)
48774b97a6cSmrg				basic_machine=i860-intel
48874b97a6cSmrg				basic_os=osf
48974b97a6cSmrg				;;
49074b97a6cSmrg			parisc)
49174b97a6cSmrg				basic_machine=hppa-unknown
49274b97a6cSmrg				basic_os=linux
49374b97a6cSmrg				;;
49474b97a6cSmrg			psp)
49574b97a6cSmrg				basic_machine=mipsallegrexel-sony
49674b97a6cSmrg				basic_os=psp
49774b97a6cSmrg				;;
49874b97a6cSmrg			pw32)
49974b97a6cSmrg				basic_machine=i586-unknown
50074b97a6cSmrg				basic_os=pw32
50174b97a6cSmrg				;;
50274b97a6cSmrg			rdos | rdos64)
50374b97a6cSmrg				basic_machine=x86_64-pc
50474b97a6cSmrg				basic_os=rdos
50574b97a6cSmrg				;;
50674b97a6cSmrg			rdos32)
50774b97a6cSmrg				basic_machine=i386-pc
50874b97a6cSmrg				basic_os=rdos
50974b97a6cSmrg				;;
51074b97a6cSmrg			rom68k)
51174b97a6cSmrg				basic_machine=m68k-rom68k
51274b97a6cSmrg				basic_os=coff
51374b97a6cSmrg				;;
51474b97a6cSmrg			sa29200)
51574b97a6cSmrg				basic_machine=a29k-amd
51674b97a6cSmrg				basic_os=udi
51774b97a6cSmrg				;;
51874b97a6cSmrg			sei)
51974b97a6cSmrg				basic_machine=mips-sei
52074b97a6cSmrg				basic_os=seiux
52174b97a6cSmrg				;;
52274b97a6cSmrg			sequent)
52374b97a6cSmrg				basic_machine=i386-sequent
52474b97a6cSmrg				basic_os=
52574b97a6cSmrg				;;
52674b97a6cSmrg			sps7)
52774b97a6cSmrg				basic_machine=m68k-bull
52874b97a6cSmrg				basic_os=sysv2
52974b97a6cSmrg				;;
53074b97a6cSmrg			st2000)
53174b97a6cSmrg				basic_machine=m68k-tandem
53274b97a6cSmrg				basic_os=
53374b97a6cSmrg				;;
53474b97a6cSmrg			stratus)
53574b97a6cSmrg				basic_machine=i860-stratus
53674b97a6cSmrg				basic_os=sysv4
53774b97a6cSmrg				;;
53874b97a6cSmrg			sun2)
53974b97a6cSmrg				basic_machine=m68000-sun
54074b97a6cSmrg				basic_os=
54174b97a6cSmrg				;;
54274b97a6cSmrg			sun2os3)
54374b97a6cSmrg				basic_machine=m68000-sun
54474b97a6cSmrg				basic_os=sunos3
54574b97a6cSmrg				;;
54674b97a6cSmrg			sun2os4)
54774b97a6cSmrg				basic_machine=m68000-sun
54874b97a6cSmrg				basic_os=sunos4
54974b97a6cSmrg				;;
55074b97a6cSmrg			sun3)
55174b97a6cSmrg				basic_machine=m68k-sun
55274b97a6cSmrg				basic_os=
55374b97a6cSmrg				;;
55474b97a6cSmrg			sun3os3)
55574b97a6cSmrg				basic_machine=m68k-sun
55674b97a6cSmrg				basic_os=sunos3
55774b97a6cSmrg				;;
55874b97a6cSmrg			sun3os4)
55974b97a6cSmrg				basic_machine=m68k-sun
56074b97a6cSmrg				basic_os=sunos4
56174b97a6cSmrg				;;
56274b97a6cSmrg			sun4)
56374b97a6cSmrg				basic_machine=sparc-sun
56474b97a6cSmrg				basic_os=
56574b97a6cSmrg				;;
56674b97a6cSmrg			sun4os3)
56774b97a6cSmrg				basic_machine=sparc-sun
56874b97a6cSmrg				basic_os=sunos3
56974b97a6cSmrg				;;
57074b97a6cSmrg			sun4os4)
57174b97a6cSmrg				basic_machine=sparc-sun
57274b97a6cSmrg				basic_os=sunos4
57374b97a6cSmrg				;;
57474b97a6cSmrg			sun4sol2)
57574b97a6cSmrg				basic_machine=sparc-sun
57674b97a6cSmrg				basic_os=solaris2
57774b97a6cSmrg				;;
57874b97a6cSmrg			sun386 | sun386i | roadrunner)
57974b97a6cSmrg				basic_machine=i386-sun
58074b97a6cSmrg				basic_os=
58174b97a6cSmrg				;;
58274b97a6cSmrg			sv1)
58374b97a6cSmrg				basic_machine=sv1-cray
58474b97a6cSmrg				basic_os=unicos
58574b97a6cSmrg				;;
58674b97a6cSmrg			symmetry)
58774b97a6cSmrg				basic_machine=i386-sequent
58874b97a6cSmrg				basic_os=dynix
58974b97a6cSmrg				;;
59074b97a6cSmrg			t3e)
59174b97a6cSmrg				basic_machine=alphaev5-cray
59274b97a6cSmrg				basic_os=unicos
59374b97a6cSmrg				;;
59474b97a6cSmrg			t90)
59574b97a6cSmrg				basic_machine=t90-cray
59674b97a6cSmrg				basic_os=unicos
59774b97a6cSmrg				;;
59874b97a6cSmrg			toad1)
59974b97a6cSmrg				basic_machine=pdp10-xkl
60074b97a6cSmrg				basic_os=tops20
60174b97a6cSmrg				;;
60274b97a6cSmrg			tpf)
60374b97a6cSmrg				basic_machine=s390x-ibm
60474b97a6cSmrg				basic_os=tpf
60574b97a6cSmrg				;;
60674b97a6cSmrg			udi29k)
60774b97a6cSmrg				basic_machine=a29k-amd
60874b97a6cSmrg				basic_os=udi
60974b97a6cSmrg				;;
61074b97a6cSmrg			ultra3)
61174b97a6cSmrg				basic_machine=a29k-nyu
61274b97a6cSmrg				basic_os=sym1
61374b97a6cSmrg				;;
61474b97a6cSmrg			v810 | necv810)
61574b97a6cSmrg				basic_machine=v810-nec
61674b97a6cSmrg				basic_os=none
61774b97a6cSmrg				;;
61874b97a6cSmrg			vaxv)
61974b97a6cSmrg				basic_machine=vax-dec
62074b97a6cSmrg				basic_os=sysv
62174b97a6cSmrg				;;
62274b97a6cSmrg			vms)
62374b97a6cSmrg				basic_machine=vax-dec
62474b97a6cSmrg				basic_os=vms
62574b97a6cSmrg				;;
62674b97a6cSmrg			vsta)
62774b97a6cSmrg				basic_machine=i386-pc
62874b97a6cSmrg				basic_os=vsta
62974b97a6cSmrg				;;
63074b97a6cSmrg			vxworks960)
63174b97a6cSmrg				basic_machine=i960-wrs
63274b97a6cSmrg				basic_os=vxworks
63374b97a6cSmrg				;;
63474b97a6cSmrg			vxworks68)
63574b97a6cSmrg				basic_machine=m68k-wrs
63674b97a6cSmrg				basic_os=vxworks
63774b97a6cSmrg				;;
63874b97a6cSmrg			vxworks29k)
63974b97a6cSmrg				basic_machine=a29k-wrs
64074b97a6cSmrg				basic_os=vxworks
64174b97a6cSmrg				;;
64274b97a6cSmrg			xbox)
64374b97a6cSmrg				basic_machine=i686-pc
64474b97a6cSmrg				basic_os=mingw32
64574b97a6cSmrg				;;
64674b97a6cSmrg			ymp)
64774b97a6cSmrg				basic_machine=ymp-cray
64874b97a6cSmrg				basic_os=unicos
64974b97a6cSmrg				;;
65074b97a6cSmrg			*)
65174b97a6cSmrg				basic_machine=$1
65274b97a6cSmrg				basic_os=
65374b97a6cSmrg				;;
65474b97a6cSmrg		esac
655b3307321Smrg		;;
656b3307321Smrgesac
657b3307321Smrg
65874b97a6cSmrg# Decode 1-component or ad-hoc basic machines
659b3307321Smrgcase $basic_machine in
66074b97a6cSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66174b97a6cSmrg	# some cases the only manufacturer, in others, it is the most popular.
66274b97a6cSmrg	w89k)
66374b97a6cSmrg		cpu=hppa1.1
66474b97a6cSmrg		vendor=winbond
66506ef0fecSmrg		;;
66674b97a6cSmrg	op50n)
66774b97a6cSmrg		cpu=hppa1.1
66874b97a6cSmrg		vendor=oki
669b3307321Smrg		;;
67074b97a6cSmrg	op60c)
67174b97a6cSmrg		cpu=hppa1.1
67274b97a6cSmrg		vendor=oki
673b3307321Smrg		;;
67474b97a6cSmrg	ibm*)
67574b97a6cSmrg		cpu=i370
67674b97a6cSmrg		vendor=ibm
677afe13c8eSmrg		;;
67874b97a6cSmrg	orion105)
67974b97a6cSmrg		cpu=clipper
68074b97a6cSmrg		vendor=highlevel
68174a3f230Smrg		;;
68274b97a6cSmrg	mac | mpw | mac-mpw)
68374b97a6cSmrg		cpu=m68k
68474b97a6cSmrg		vendor=apple
68574a3f230Smrg		;;
68674b97a6cSmrg	pmac | pmac-mpw)
68774b97a6cSmrg		cpu=powerpc
68874b97a6cSmrg		vendor=apple
68974a3f230Smrg		;;
69074a3f230Smrg
691b3307321Smrg	# Recognize the various machine names and aliases which stand
692b3307321Smrg	# for a CPU type and a company and sometimes even an OS.
693b3307321Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69474b97a6cSmrg		cpu=m68000
69574b97a6cSmrg		vendor=att
696b3307321Smrg		;;
697b3307321Smrg	3b*)
69874b97a6cSmrg		cpu=we32k
69974b97a6cSmrg		vendor=att
700afe13c8eSmrg		;;
70129cb5710Smrg	bluegene*)
70274b97a6cSmrg		cpu=powerpc
70374b97a6cSmrg		vendor=ibm
70474b97a6cSmrg		basic_os=cnk
705b3307321Smrg		;;
706b3307321Smrg	decsystem10* | dec10*)
70774b97a6cSmrg		cpu=pdp10
70874b97a6cSmrg		vendor=dec
70974b97a6cSmrg		basic_os=tops10
710b3307321Smrg		;;
711b3307321Smrg	decsystem20* | dec20*)
71274b97a6cSmrg		cpu=pdp10
71374b97a6cSmrg		vendor=dec
71474b97a6cSmrg		basic_os=tops20
715b3307321Smrg		;;
716b3307321Smrg	delta | 3300 | motorola-3300 | motorola-delta \
717b3307321Smrg	      | 3300-motorola | delta-motorola)
71874b97a6cSmrg		cpu=m68k
71974b97a6cSmrg		vendor=motorola
720b3307321Smrg		;;
72106ef0fecSmrg	dpx2*)
72274b97a6cSmrg		cpu=m68k
72374b97a6cSmrg		vendor=bull
72474b97a6cSmrg		basic_os=sysv3
725b3307321Smrg		;;
726b3307321Smrg	encore | umax | mmax)
72774b97a6cSmrg		cpu=ns32k
72874b97a6cSmrg		vendor=encore
729b3307321Smrg		;;
73074b97a6cSmrg	elxsi)
73174b97a6cSmrg		cpu=elxsi
73274b97a6cSmrg		vendor=elxsi
73374b97a6cSmrg		basic_os=${basic_os:-bsd}
734b3307321Smrg		;;
735b3307321Smrg	fx2800)
73674b97a6cSmrg		cpu=i860
73774b97a6cSmrg		vendor=alliant
738b3307321Smrg		;;
739b3307321Smrg	genix)
74074b97a6cSmrg		cpu=ns32k
74174b97a6cSmrg		vendor=ns
742b3307321Smrg		;;
743b3307321Smrg	h3050r* | hiux*)
74474b97a6cSmrg		cpu=hppa1.1
74574b97a6cSmrg		vendor=hitachi
74674b97a6cSmrg		basic_os=hiuxwe2
747b3307321Smrg		;;
748b3307321Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74974b97a6cSmrg		cpu=hppa1.0
75074b97a6cSmrg		vendor=hp
751b3307321Smrg		;;
752b3307321Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75374b97a6cSmrg		cpu=m68000
75474b97a6cSmrg		vendor=hp
755b3307321Smrg		;;
756b3307321Smrg	hp9k3[2-9][0-9])
75774b97a6cSmrg		cpu=m68k
75874b97a6cSmrg		vendor=hp
759b3307321Smrg		;;
760b3307321Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76174b97a6cSmrg		cpu=hppa1.0
76274b97a6cSmrg		vendor=hp
763b3307321Smrg		;;
764b3307321Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76574b97a6cSmrg		cpu=hppa1.1
76674b97a6cSmrg		vendor=hp
767b3307321Smrg		;;
768b3307321Smrg	hp9k78[0-9] | hp78[0-9])
769b3307321Smrg		# FIXME: really hppa2.0-hp
77074b97a6cSmrg		cpu=hppa1.1
77174b97a6cSmrg		vendor=hp
772b3307321Smrg		;;
773b3307321Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774b3307321Smrg		# FIXME: really hppa2.0-hp
77574b97a6cSmrg		cpu=hppa1.1
77674b97a6cSmrg		vendor=hp
777b3307321Smrg		;;
778b3307321Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77974b97a6cSmrg		cpu=hppa1.1
78074b97a6cSmrg		vendor=hp
781b3307321Smrg		;;
782b3307321Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78374b97a6cSmrg		cpu=hppa1.0
78474b97a6cSmrg		vendor=hp
785b3307321Smrg		;;
786b3307321Smrg	i*86v32)
78774b97a6cSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78874b97a6cSmrg		vendor=pc
78974b97a6cSmrg		basic_os=sysv32
790b3307321Smrg		;;
791b3307321Smrg	i*86v4*)
79274b97a6cSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79374b97a6cSmrg		vendor=pc
79474b97a6cSmrg		basic_os=sysv4
795b3307321Smrg		;;
796b3307321Smrg	i*86v)
79774b97a6cSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79874b97a6cSmrg		vendor=pc
79974b97a6cSmrg		basic_os=sysv
800b3307321Smrg		;;
801b3307321Smrg	i*86sol2)
80274b97a6cSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80374b97a6cSmrg		vendor=pc
80474b97a6cSmrg		basic_os=solaris2
805b3307321Smrg		;;
80674b97a6cSmrg	j90 | j90-cray)
80774b97a6cSmrg		cpu=j90
80874b97a6cSmrg		vendor=cray
80974b97a6cSmrg		basic_os=${basic_os:-unicos}
810b3307321Smrg		;;
811b3307321Smrg	iris | iris4d)
81274b97a6cSmrg		cpu=mips
81374b97a6cSmrg		vendor=sgi
81474b97a6cSmrg		case $basic_os in
81574b97a6cSmrg		    irix*)
816b3307321Smrg			;;
817b3307321Smrg		    *)
81874b97a6cSmrg			basic_os=irix4
819b3307321Smrg			;;
820b3307321Smrg		esac
821b3307321Smrg		;;
822b3307321Smrg	miniframe)
82374b97a6cSmrg		cpu=m68000
82474b97a6cSmrg		vendor=convergent
825b3307321Smrg		;;
82674b97a6cSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82774b97a6cSmrg		cpu=m68k
82874b97a6cSmrg		vendor=atari
82974b97a6cSmrg		basic_os=mint
830b3307321Smrg		;;
831b3307321Smrg	news-3600 | risc-news)
83274b97a6cSmrg		cpu=mips
83374b97a6cSmrg		vendor=sony
83474b97a6cSmrg		basic_os=newsos
835b3307321Smrg		;;
83606ef0fecSmrg	next | m*-next)
83774b97a6cSmrg		cpu=m68k
83874b97a6cSmrg		vendor=next
83974b97a6cSmrg		case $basic_os in
84074b97a6cSmrg		    openstep*)
84174b97a6cSmrg		        ;;
84274b97a6cSmrg		    nextstep*)
843b3307321Smrg			;;
84474b97a6cSmrg		    ns2*)
84574b97a6cSmrg		      basic_os=nextstep2
846b3307321Smrg			;;
847b3307321Smrg		    *)
84874b97a6cSmrg		      basic_os=nextstep3
849b3307321Smrg			;;
850b3307321Smrg		esac
851b3307321Smrg		;;
852b3307321Smrg	np1)
85374b97a6cSmrg		cpu=np1
85474b97a6cSmrg		vendor=gould
85506ef0fecSmrg		;;
856b3307321Smrg	op50n-* | op60c-*)
85774b97a6cSmrg		cpu=hppa1.1
85874b97a6cSmrg		vendor=oki
85974b97a6cSmrg		basic_os=proelf
860b3307321Smrg		;;
861b3307321Smrg	pa-hitachi)
86274b97a6cSmrg		cpu=hppa1.1
86374b97a6cSmrg		vendor=hitachi
86474b97a6cSmrg		basic_os=hiuxwe2
865afe13c8eSmrg		;;
866b3307321Smrg	pbd)
86774b97a6cSmrg		cpu=sparc
86874b97a6cSmrg		vendor=tti
869b3307321Smrg		;;
870b3307321Smrg	pbb)
87174b97a6cSmrg		cpu=m68k
87274b97a6cSmrg		vendor=tti
873afe13c8eSmrg		;;
87474b97a6cSmrg	pc532)
87574b97a6cSmrg		cpu=ns32k
87674b97a6cSmrg		vendor=pc532
877b3307321Smrg		;;
878b3307321Smrg	pn)
87974b97a6cSmrg		cpu=pn
88074b97a6cSmrg		vendor=gould
881b3307321Smrg		;;
88274b97a6cSmrg	power)
88374b97a6cSmrg		cpu=power
88474b97a6cSmrg		vendor=ibm
885b3307321Smrg		;;
88674b97a6cSmrg	ps2)
88774b97a6cSmrg		cpu=i386
88874b97a6cSmrg		vendor=ibm
889b3307321Smrg		;;
89074b97a6cSmrg	rm[46]00)
89174b97a6cSmrg		cpu=mips
89274b97a6cSmrg		vendor=siemens
893b3307321Smrg		;;
89474b97a6cSmrg	rtpc | rtpc-*)
89574b97a6cSmrg		cpu=romp
89674b97a6cSmrg		vendor=ibm
897b3307321Smrg		;;
89874b97a6cSmrg	sde)
89974b97a6cSmrg		cpu=mipsisa32
90074b97a6cSmrg		vendor=sde
90174b97a6cSmrg		basic_os=${basic_os:-elf}
902b3307321Smrg		;;
90374b97a6cSmrg	simso-wrs)
90474b97a6cSmrg		cpu=sparclite
90574b97a6cSmrg		vendor=wrs
90674b97a6cSmrg		basic_os=vxworks
907b3307321Smrg		;;
90874b97a6cSmrg	tower | tower-32)
90974b97a6cSmrg		cpu=m68k
91074b97a6cSmrg		vendor=ncr
911b3307321Smrg		;;
91274b97a6cSmrg	vpp*|vx|vx-*)
91374b97a6cSmrg		cpu=f301
91474b97a6cSmrg		vendor=fujitsu
91574a3f230Smrg		;;
91674b97a6cSmrg	w65)
91774b97a6cSmrg		cpu=w65
91874b97a6cSmrg		vendor=wdc
919afe13c8eSmrg		;;
92074b97a6cSmrg	w89k-*)
92174b97a6cSmrg		cpu=hppa1.1
92274b97a6cSmrg		vendor=winbond
92374b97a6cSmrg		basic_os=proelf
924b3307321Smrg		;;
92574b97a6cSmrg	none)
92674b97a6cSmrg		cpu=none
92774b97a6cSmrg		vendor=none
928b3307321Smrg		;;
92974b97a6cSmrg	leon|leon[3-9])
93074b97a6cSmrg		cpu=sparc
93174b97a6cSmrg		vendor=$basic_machine
932b3307321Smrg		;;
93374b97a6cSmrg	leon-*|leon[3-9]-*)
93474b97a6cSmrg		cpu=sparc
93574b97a6cSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936afe13c8eSmrg		;;
93774b97a6cSmrg
93874b97a6cSmrg	*-*)
93974b97a6cSmrg		# shellcheck disable=SC2162
9406728f30eSmrg		saved_IFS=$IFS
94174b97a6cSmrg		IFS="-" read cpu vendor <<EOF
94274b97a6cSmrg$basic_machine
94374b97a6cSmrgEOF
9446728f30eSmrg		IFS=$saved_IFS
945afe13c8eSmrg		;;
94674b97a6cSmrg	# We use `pc' rather than `unknown'
94774b97a6cSmrg	# because (1) that's what they normally are, and
94874b97a6cSmrg	# (2) the word "unknown" tends to confuse beginning users.
94974b97a6cSmrg	i*86 | x86_64)
95074b97a6cSmrg		cpu=$basic_machine
95174b97a6cSmrg		vendor=pc
952b3307321Smrg		;;
95374b97a6cSmrg	# These rules are duplicated from below for sake of the special case above;
95474b97a6cSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
95574b97a6cSmrg	pc98)
95674b97a6cSmrg		cpu=i386
95774b97a6cSmrg		vendor=pc
958b3307321Smrg		;;
95974b97a6cSmrg	x64 | amd64)
96074b97a6cSmrg		cpu=x86_64
96174b97a6cSmrg		vendor=pc
962b3307321Smrg		;;
96374b97a6cSmrg	# Recognize the basic CPU types without company name.
96474b97a6cSmrg	*)
96574b97a6cSmrg		cpu=$basic_machine
96674b97a6cSmrg		vendor=unknown
967afe13c8eSmrg		;;
96874b97a6cSmrgesac
96974b97a6cSmrg
97074b97a6cSmrgunset -v basic_machine
97174b97a6cSmrg
97274b97a6cSmrg# Decode basic machines in the full and proper CPU-Company form.
97374b97a6cSmrgcase $cpu-$vendor in
97474b97a6cSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97574b97a6cSmrg	# some cases the only manufacturer, in others, it is the most popular.
97674b97a6cSmrg	craynv-unknown)
97774b97a6cSmrg		vendor=cray
97874b97a6cSmrg		basic_os=${basic_os:-unicosmp}
979b3307321Smrg		;;
98074b97a6cSmrg	c90-unknown | c90-cray)
98174b97a6cSmrg		vendor=cray
98274b97a6cSmrg		basic_os=${Basic_os:-unicos}
983b3307321Smrg		;;
98474b97a6cSmrg	fx80-unknown)
98574b97a6cSmrg		vendor=alliant
986afe13c8eSmrg		;;
98774b97a6cSmrg	romp-unknown)
98874b97a6cSmrg		vendor=ibm
989b3307321Smrg		;;
99074b97a6cSmrg	mmix-unknown)
99174b97a6cSmrg		vendor=knuth
992b3307321Smrg		;;
99374b97a6cSmrg	microblaze-unknown | microblazeel-unknown)
99474b97a6cSmrg		vendor=xilinx
995b3307321Smrg		;;
99674b97a6cSmrg	rs6000-unknown)
99774b97a6cSmrg		vendor=ibm
998b3307321Smrg		;;
99974b97a6cSmrg	vax-unknown)
100074b97a6cSmrg		vendor=dec
1001b3307321Smrg		;;
100274b97a6cSmrg	pdp11-unknown)
100374b97a6cSmrg		vendor=dec
100474a3f230Smrg		;;
100574b97a6cSmrg	we32k-unknown)
100674b97a6cSmrg		vendor=att
1007b3307321Smrg		;;
100874b97a6cSmrg	cydra-unknown)
100974b97a6cSmrg		vendor=cydrome
1010b3307321Smrg		;;
101174b97a6cSmrg	i370-ibm*)
101274b97a6cSmrg		vendor=ibm
1013b3307321Smrg		;;
101474b97a6cSmrg	orion-unknown)
101574b97a6cSmrg		vendor=highlevel
1016b3307321Smrg		;;
101774b97a6cSmrg	xps-unknown | xps100-unknown)
101874b97a6cSmrg		cpu=xps100
101974b97a6cSmrg		vendor=honeywell
1020b3307321Smrg		;;
102174b97a6cSmrg
102274b97a6cSmrg	# Here we normalize CPU types with a missing or matching vendor
10236728f30eSmrg	armh-unknown | armh-alt)
10246728f30eSmrg		cpu=armv7l
10256728f30eSmrg		vendor=alt
10266728f30eSmrg		basic_os=${basic_os:-linux-gnueabihf}
10276728f30eSmrg		;;
102874b97a6cSmrg	dpx20-unknown | dpx20-bull)
102974b97a6cSmrg		cpu=rs6000
103074b97a6cSmrg		vendor=bull
103174b97a6cSmrg		basic_os=${basic_os:-bosx}
1032b3307321Smrg		;;
103374b97a6cSmrg
103474b97a6cSmrg	# Here we normalize CPU types irrespective of the vendor
103574b97a6cSmrg	amd64-*)
103674b97a6cSmrg		cpu=x86_64
1037b3307321Smrg		;;
103874b97a6cSmrg	blackfin-*)
103974b97a6cSmrg		cpu=bfin
104074b97a6cSmrg		basic_os=linux
1041b3307321Smrg		;;
104274b97a6cSmrg	c54x-*)
104374b97a6cSmrg		cpu=tic54x
1044b3307321Smrg		;;
104574b97a6cSmrg	c55x-*)
104674b97a6cSmrg		cpu=tic55x
1047b3307321Smrg		;;
104874b97a6cSmrg	c6x-*)
104974b97a6cSmrg		cpu=tic6x
1050b3307321Smrg		;;
105174b97a6cSmrg	e500v[12]-*)
105274b97a6cSmrg		cpu=powerpc
105374b97a6cSmrg		basic_os=${basic_os}"spe"
1054b3307321Smrg		;;
105574b97a6cSmrg	mips3*-*)
105674b97a6cSmrg		cpu=mips64
1057b3307321Smrg		;;
105874b97a6cSmrg	ms1-*)
105974b97a6cSmrg		cpu=mt
1060b3307321Smrg		;;
106174b97a6cSmrg	m68knommu-*)
106274b97a6cSmrg		cpu=m68k
106374b97a6cSmrg		basic_os=linux
1064b3307321Smrg		;;
106574b97a6cSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106674b97a6cSmrg		cpu=s12z
1067afe13c8eSmrg		;;
106874b97a6cSmrg	openrisc-*)
106974b97a6cSmrg		cpu=or32
1070b3307321Smrg		;;
107174b97a6cSmrg	parisc-*)
107274b97a6cSmrg		cpu=hppa
107374b97a6cSmrg		basic_os=linux
1074b3307321Smrg		;;
107574b97a6cSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107674b97a6cSmrg		cpu=i586
1077b3307321Smrg		;;
10786728f30eSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
107974b97a6cSmrg		cpu=i686
1080b3307321Smrg		;;
108174b97a6cSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108274b97a6cSmrg		cpu=i686
1083afe13c8eSmrg		;;
108474b97a6cSmrg	pentium4-*)
108574b97a6cSmrg		cpu=i786
1086b3307321Smrg		;;
108774b97a6cSmrg	pc98-*)
108874b97a6cSmrg		cpu=i386
1089b3307321Smrg		;;
109074b97a6cSmrg	ppc-* | ppcbe-*)
109174b97a6cSmrg		cpu=powerpc
1092b3307321Smrg		;;
109374b97a6cSmrg	ppcle-* | powerpclittle-*)
109474b97a6cSmrg		cpu=powerpcle
1095b3307321Smrg		;;
109674b97a6cSmrg	ppc64-*)
109774b97a6cSmrg		cpu=powerpc64
1098b3307321Smrg		;;
109974b97a6cSmrg	ppc64le-* | powerpc64little-*)
110074b97a6cSmrg		cpu=powerpc64le
1101b3307321Smrg		;;
110274b97a6cSmrg	sb1-*)
110374b97a6cSmrg		cpu=mipsisa64sb1
1104b3307321Smrg		;;
110574b97a6cSmrg	sb1el-*)
110674b97a6cSmrg		cpu=mipsisa64sb1el
1107b3307321Smrg		;;
110874b97a6cSmrg	sh5e[lb]-*)
110974b97a6cSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110b3307321Smrg		;;
111174b97a6cSmrg	spur-*)
111274b97a6cSmrg		cpu=spur
1113b3307321Smrg		;;
111474b97a6cSmrg	strongarm-* | thumb-*)
111574b97a6cSmrg		cpu=arm
1116b3307321Smrg		;;
111774b97a6cSmrg	tx39-*)
111874b97a6cSmrg		cpu=mipstx39
111906ef0fecSmrg		;;
112074b97a6cSmrg	tx39el-*)
112174b97a6cSmrg		cpu=mipstx39el
1122afe13c8eSmrg		;;
112374b97a6cSmrg	x64-*)
112474b97a6cSmrg		cpu=x86_64
1125b3307321Smrg		;;
112674a3f230Smrg	xscale-* | xscalee[bl]-*)
112774b97a6cSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112874a3f230Smrg		;;
11296728f30eSmrg	arm64-* | aarch64le-*)
113074b97a6cSmrg		cpu=aarch64
1131b3307321Smrg		;;
1132b3307321Smrg
113374b97a6cSmrg	# Recognize the canonical CPU Types that limit and/or modify the
113474b97a6cSmrg	# company names they are paired with.
113574b97a6cSmrg	cr16-*)
113674b97a6cSmrg		basic_os=${basic_os:-elf}
1137b3307321Smrg		;;
113874b97a6cSmrg	crisv32-* | etraxfs*-*)
113974b97a6cSmrg		cpu=crisv32
114074b97a6cSmrg		vendor=axis
1141afe13c8eSmrg		;;
114274b97a6cSmrg	cris-* | etrax*-*)
114374b97a6cSmrg		cpu=cris
114474b97a6cSmrg		vendor=axis
1145b3307321Smrg		;;
114674b97a6cSmrg	crx-*)
114774b97a6cSmrg		basic_os=${basic_os:-elf}
1148b3307321Smrg		;;
114974b97a6cSmrg	neo-tandem)
115074b97a6cSmrg		cpu=neo
115174b97a6cSmrg		vendor=tandem
1152b3307321Smrg		;;
115374b97a6cSmrg	nse-tandem)
115474b97a6cSmrg		cpu=nse
115574b97a6cSmrg		vendor=tandem
1156b3307321Smrg		;;
115774b97a6cSmrg	nsr-tandem)
115874b97a6cSmrg		cpu=nsr
115974b97a6cSmrg		vendor=tandem
1160b3307321Smrg		;;
116174b97a6cSmrg	nsv-tandem)
116274b97a6cSmrg		cpu=nsv
116374b97a6cSmrg		vendor=tandem
1164b3307321Smrg		;;
116574b97a6cSmrg	nsx-tandem)
116674b97a6cSmrg		cpu=nsx
116774b97a6cSmrg		vendor=tandem
1168b3307321Smrg		;;
116974b97a6cSmrg	mipsallegrexel-sony)
117074b97a6cSmrg		cpu=mipsallegrexel
117174b97a6cSmrg		vendor=sony
1172b3307321Smrg		;;
117374b97a6cSmrg	tile*-*)
117474b97a6cSmrg		basic_os=${basic_os:-linux-gnu}
1175b3307321Smrg		;;
117674b97a6cSmrg
1177b3307321Smrg	*)
117874b97a6cSmrg		# Recognize the canonical CPU types that are allowed with any
117974b97a6cSmrg		# company name.
118074b97a6cSmrg		case $cpu in
118174b97a6cSmrg			1750a | 580 \
118274b97a6cSmrg			| a29k \
118374b97a6cSmrg			| aarch64 | aarch64_be \
118474b97a6cSmrg			| abacus \
118574b97a6cSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118674b97a6cSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118774b97a6cSmrg			| alphapca5[67] | alpha64pca5[67] \
118874b97a6cSmrg			| am33_2.0 \
118974b97a6cSmrg			| amdgcn \
119074b97a6cSmrg			| arc | arceb | arc32 | arc64 \
119174b97a6cSmrg			| arm | arm[lb]e | arme[lb] | armv* \
119274b97a6cSmrg			| avr | avr32 \
119374b97a6cSmrg			| asmjs \
119474b97a6cSmrg			| ba \
119574b97a6cSmrg			| be32 | be64 \
119674b97a6cSmrg			| bfin | bpf | bs2000 \
119774b97a6cSmrg			| c[123]* | c30 | [cjt]90 | c4x \
119874b97a6cSmrg			| c8051 | clipper | craynv | csky | cydra \
119974b97a6cSmrg			| d10v | d30v | dlx | dsp16xx \
120074b97a6cSmrg			| e2k | elxsi | epiphany \
120174b97a6cSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120274b97a6cSmrg			| h8300 | h8500 \
120374b97a6cSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
120474b97a6cSmrg			| hexagon \
120574b97a6cSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120674b97a6cSmrg			| ip2k | iq2000 \
120774b97a6cSmrg			| k1om \
120874b97a6cSmrg			| le32 | le64 \
120974b97a6cSmrg			| lm32 \
12106728f30eSmrg			| loongarch32 | loongarch64 \
121174b97a6cSmrg			| m32c | m32r | m32rle \
121274b97a6cSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121374b97a6cSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121474b97a6cSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121574b97a6cSmrg			| microblaze | microblazeel \
121674b97a6cSmrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121774b97a6cSmrg			| mips16 \
121874b97a6cSmrg			| mips64 | mips64eb | mips64el \
121974b97a6cSmrg			| mips64octeon | mips64octeonel \
122074b97a6cSmrg			| mips64orion | mips64orionel \
122174b97a6cSmrg			| mips64r5900 | mips64r5900el \
122274b97a6cSmrg			| mips64vr | mips64vrel \
122374b97a6cSmrg			| mips64vr4100 | mips64vr4100el \
122474b97a6cSmrg			| mips64vr4300 | mips64vr4300el \
122574b97a6cSmrg			| mips64vr5000 | mips64vr5000el \
122674b97a6cSmrg			| mips64vr5900 | mips64vr5900el \
122774b97a6cSmrg			| mipsisa32 | mipsisa32el \
122874b97a6cSmrg			| mipsisa32r2 | mipsisa32r2el \
122974b97a6cSmrg			| mipsisa32r3 | mipsisa32r3el \
123074b97a6cSmrg			| mipsisa32r5 | mipsisa32r5el \
123174b97a6cSmrg			| mipsisa32r6 | mipsisa32r6el \
123274b97a6cSmrg			| mipsisa64 | mipsisa64el \
123374b97a6cSmrg			| mipsisa64r2 | mipsisa64r2el \
123474b97a6cSmrg			| mipsisa64r3 | mipsisa64r3el \
123574b97a6cSmrg			| mipsisa64r5 | mipsisa64r5el \
123674b97a6cSmrg			| mipsisa64r6 | mipsisa64r6el \
123774b97a6cSmrg			| mipsisa64sb1 | mipsisa64sb1el \
123874b97a6cSmrg			| mipsisa64sr71k | mipsisa64sr71kel \
123974b97a6cSmrg			| mipsr5900 | mipsr5900el \
124074b97a6cSmrg			| mipstx39 | mipstx39el \
124174b97a6cSmrg			| mmix \
124274b97a6cSmrg			| mn10200 | mn10300 \
124374b97a6cSmrg			| moxie \
124474b97a6cSmrg			| mt \
124574b97a6cSmrg			| msp430 \
124674b97a6cSmrg			| nds32 | nds32le | nds32be \
124774b97a6cSmrg			| nfp \
124874b97a6cSmrg			| nios | nios2 | nios2eb | nios2el \
124974b97a6cSmrg			| none | np1 | ns16k | ns32k | nvptx \
125074b97a6cSmrg			| open8 \
125174b97a6cSmrg			| or1k* \
125274b97a6cSmrg			| or32 \
125374b97a6cSmrg			| orion \
125474b97a6cSmrg			| picochip \
125574b97a6cSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125674b97a6cSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125774b97a6cSmrg			| pru \
125874b97a6cSmrg			| pyramid \
125974b97a6cSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
126074b97a6cSmrg			| rl78 | romp | rs6000 | rx \
126174b97a6cSmrg			| s390 | s390x \
126274b97a6cSmrg			| score \
126374b97a6cSmrg			| sh | shl \
126474b97a6cSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126574b97a6cSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126674b97a6cSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126774b97a6cSmrg			| sparclite \
126874b97a6cSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126974b97a6cSmrg			| spu \
127074b97a6cSmrg			| tahoe \
127174b97a6cSmrg			| thumbv7* \
127274b97a6cSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
127374b97a6cSmrg			| tron \
127474b97a6cSmrg			| ubicom32 \
127574b97a6cSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127674b97a6cSmrg			| vax \
127774b97a6cSmrg			| visium \
127874b97a6cSmrg			| w65 \
127974b97a6cSmrg			| wasm32 | wasm64 \
128074b97a6cSmrg			| we32k \
128174b97a6cSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
128274b97a6cSmrg			| xstormy16 | xtensa* \
128374b97a6cSmrg			| ymp \
128474b97a6cSmrg			| z8k | z80)
128574b97a6cSmrg				;;
128674b97a6cSmrg
128774b97a6cSmrg			*)
128874b97a6cSmrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128974b97a6cSmrg				exit 1
129074b97a6cSmrg				;;
129174b97a6cSmrg		esac
1292b3307321Smrg		;;
1293b3307321Smrgesac
1294b3307321Smrg
1295b3307321Smrg# Here we canonicalize certain aliases for manufacturers.
129674b97a6cSmrgcase $vendor in
129774b97a6cSmrg	digital*)
129874b97a6cSmrg		vendor=dec
1299b3307321Smrg		;;
130074b97a6cSmrg	commodore*)
130174b97a6cSmrg		vendor=cbm
1302b3307321Smrg		;;
1303b3307321Smrg	*)
1304b3307321Smrg		;;
1305b3307321Smrgesac
1306b3307321Smrg
1307b3307321Smrg# Decode manufacturer-specific aliases for certain operating systems.
1308b3307321Smrg
130974b97a6cSmrgif test x$basic_os != x
1310b3307321Smrgthen
131174b97a6cSmrg
13126728f30eSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
131374b97a6cSmrg# set os.
131474b97a6cSmrgcase $basic_os in
131574b97a6cSmrg	gnu/linux*)
131674b97a6cSmrg		kernel=linux
131774b97a6cSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131874b97a6cSmrg		;;
131974b97a6cSmrg	os2-emx)
132074b97a6cSmrg		kernel=os2
132174b97a6cSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
132274b97a6cSmrg		;;
132374b97a6cSmrg	nto-qnx*)
132474b97a6cSmrg		kernel=nto
132574b97a6cSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132674b97a6cSmrg		;;
132774b97a6cSmrg	*-*)
132874b97a6cSmrg		# shellcheck disable=SC2162
13296728f30eSmrg		saved_IFS=$IFS
133074b97a6cSmrg		IFS="-" read kernel os <<EOF
133174b97a6cSmrg$basic_os
133274b97a6cSmrgEOF
13336728f30eSmrg		IFS=$saved_IFS
133474b97a6cSmrg		;;
133574b97a6cSmrg	# Default OS when just kernel was specified
133674b97a6cSmrg	nto*)
133774b97a6cSmrg		kernel=nto
133874b97a6cSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133974b97a6cSmrg		;;
134074b97a6cSmrg	linux*)
134174b97a6cSmrg		kernel=linux
134274b97a6cSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
134374b97a6cSmrg		;;
13446728f30eSmrg	managarm*)
13456728f30eSmrg		kernel=managarm
13466728f30eSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13476728f30eSmrg		;;
134874b97a6cSmrg	*)
134974b97a6cSmrg		kernel=
135074b97a6cSmrg		os=$basic_os
135174b97a6cSmrg		;;
135274b97a6cSmrgesac
135374b97a6cSmrg
135474b97a6cSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
135574b97a6cSmrg# etc.)
1356b3307321Smrgcase $os in
135706ef0fecSmrg	# First match some system type aliases that might get confused
135806ef0fecSmrg	# with valid system types.
135974b97a6cSmrg	# solaris* is a basic system type, with this one exception.
136074b97a6cSmrg	auroraux)
136174b97a6cSmrg		os=auroraux
136229cb5710Smrg		;;
136374b97a6cSmrg	bluegene*)
136474b97a6cSmrg		os=cnk
1365b3307321Smrg		;;
136674b97a6cSmrg	solaris1 | solaris1.*)
136774b97a6cSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368b3307321Smrg		;;
136974b97a6cSmrg	solaris)
137074b97a6cSmrg		os=solaris2
1371b3307321Smrg		;;
137274b97a6cSmrg	unixware*)
137374b97a6cSmrg		os=sysv4.2uw
1374b3307321Smrg		;;
137506ef0fecSmrg	# es1800 is here to avoid being matched by es* (a different OS)
137674b97a6cSmrg	es1800*)
137774b97a6cSmrg		os=ose
137806ef0fecSmrg		;;
137974b97a6cSmrg	# Some version numbers need modification
138074b97a6cSmrg	chorusos*)
138174b97a6cSmrg		os=chorusos
1382b3307321Smrg		;;
138374b97a6cSmrg	isc)
138474b97a6cSmrg		os=isc2.2
1385b3307321Smrg		;;
138674b97a6cSmrg	sco6)
138774b97a6cSmrg		os=sco5v6
1388b3307321Smrg		;;
138974b97a6cSmrg	sco5)
139074b97a6cSmrg		os=sco3.2v5
1391b3307321Smrg		;;
139274b97a6cSmrg	sco4)
139374b97a6cSmrg		os=sco3.2v4
1394b3307321Smrg		;;
139574b97a6cSmrg	sco3.2.[4-9]*)
139674b97a6cSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397afe13c8eSmrg		;;
139874b97a6cSmrg	sco*v* | scout)
139974b97a6cSmrg		# Don't match below
1400b3307321Smrg		;;
140174b97a6cSmrg	sco*)
140274b97a6cSmrg		os=sco3.2v2
1403b3307321Smrg		;;
140474b97a6cSmrg	psos*)
140574b97a6cSmrg		os=psos
1406b3307321Smrg		;;
140774b97a6cSmrg	qnx*)
140874b97a6cSmrg		os=qnx
1409b3307321Smrg		;;
141074b97a6cSmrg	hiux*)
141174b97a6cSmrg		os=hiuxwe2
1412afe13c8eSmrg		;;
141374b97a6cSmrg	lynx*178)
141474b97a6cSmrg		os=lynxos178
1415b3307321Smrg		;;
141674b97a6cSmrg	lynx*5)
141774b97a6cSmrg		os=lynxos5
1418b3307321Smrg		;;
141974b97a6cSmrg	lynxos*)
142074b97a6cSmrg		# don't get caught up in next wildcard
1421b3307321Smrg		;;
142274b97a6cSmrg	lynx*)
142374b97a6cSmrg		os=lynxos
1424b3307321Smrg		;;
142574b97a6cSmrg	mac[0-9]*)
142674b97a6cSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427b3307321Smrg		;;
142874b97a6cSmrg	opened*)
142974b97a6cSmrg		os=openedition
1430afe13c8eSmrg		;;
143174b97a6cSmrg	os400*)
143274b97a6cSmrg		os=os400
1433b3307321Smrg		;;
143474b97a6cSmrg	sunos5*)
143574b97a6cSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436b3307321Smrg		;;
143774b97a6cSmrg	sunos6*)
143874b97a6cSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439b3307321Smrg		;;
144074b97a6cSmrg	wince*)
144174b97a6cSmrg		os=wince
1442b3307321Smrg		;;
144374b97a6cSmrg	utek*)
144474b97a6cSmrg		os=bsd
1445b3307321Smrg		;;
144674b97a6cSmrg	dynix*)
144774b97a6cSmrg		os=bsd
1448b3307321Smrg		;;
144974b97a6cSmrg	acis*)
145074b97a6cSmrg		os=aos
1451b3307321Smrg		;;
145274b97a6cSmrg	atheos*)
145374b97a6cSmrg		os=atheos
1454afe13c8eSmrg		;;
145574b97a6cSmrg	syllable*)
145674b97a6cSmrg		os=syllable
1457b3307321Smrg		;;
145874b97a6cSmrg	386bsd)
145974b97a6cSmrg		os=bsd
1460b3307321Smrg		;;
146174b97a6cSmrg	ctix* | uts*)
146274b97a6cSmrg		os=sysv
1463b3307321Smrg		;;
146474b97a6cSmrg	nova*)
146574b97a6cSmrg		os=rtmk-nova
1466b3307321Smrg		;;
146774b97a6cSmrg	ns2)
146874b97a6cSmrg		os=nextstep2
1469b3307321Smrg		;;
147074b97a6cSmrg	# Preserve the version number of sinix5.
147174b97a6cSmrg	sinix5.*)
147274b97a6cSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473b3307321Smrg		;;
147474b97a6cSmrg	sinix*)
147574b97a6cSmrg		os=sysv4
1476b3307321Smrg		;;
147774b97a6cSmrg	tpf*)
147874b97a6cSmrg		os=tpf
1479b3307321Smrg		;;
148074b97a6cSmrg	triton*)
148174b97a6cSmrg		os=sysv3
1482afe13c8eSmrg		;;
148374b97a6cSmrg	oss*)
148474b97a6cSmrg		os=sysv3
14855e358ecaSmrg		;;
148674b97a6cSmrg	svr4*)
148774b97a6cSmrg		os=sysv4
148874b97a6cSmrg		;;
148974b97a6cSmrg	svr3)
149074b97a6cSmrg		os=sysv3
149174b97a6cSmrg		;;
149274b97a6cSmrg	sysvr4)
149374b97a6cSmrg		os=sysv4
149474b97a6cSmrg		;;
149574b97a6cSmrg	ose*)
149674b97a6cSmrg		os=ose
149774b97a6cSmrg		;;
149874b97a6cSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149974b97a6cSmrg		os=mint
150074b97a6cSmrg		;;
150174b97a6cSmrg	dicos*)
150274b97a6cSmrg		os=dicos
150374b97a6cSmrg		;;
150474b97a6cSmrg	pikeos*)
150506ef0fecSmrg		# Until real need of OS specific support for
150606ef0fecSmrg		# particular features comes up, bare metal
150706ef0fecSmrg		# configurations are quite functional.
150874b97a6cSmrg		case $cpu in
150906ef0fecSmrg		    arm*)
151074b97a6cSmrg			os=eabi
151106ef0fecSmrg			;;
151206ef0fecSmrg		    *)
151374b97a6cSmrg			os=elf
151406ef0fecSmrg			;;
151506ef0fecSmrg		esac
151606ef0fecSmrg		;;
1517b3307321Smrg	*)
151874b97a6cSmrg		# No normalization, but not necessarily accepted, that comes below.
1519b3307321Smrg		;;
1520b3307321Smrgesac
152174b97a6cSmrg
1522b3307321Smrgelse
1523b3307321Smrg
1524b3307321Smrg# Here we handle the default operating systems that come with various machines.
1525b3307321Smrg# The value should be what the vendor currently ships out the door with their
1526b3307321Smrg# machine or put another way, the most popular os provided with the machine.
1527b3307321Smrg
1528b3307321Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529b3307321Smrg# "-sun"), then you have to tell the case statement up towards the top
1530b3307321Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531b3307321Smrg# will signal an error saying that MANUFACTURER isn't an operating
1532b3307321Smrg# system, and we'll never get to this point.
1533b3307321Smrg
153474b97a6cSmrgkernel=
153574b97a6cSmrgcase $cpu-$vendor in
153674a3f230Smrg	score-*)
153774b97a6cSmrg		os=elf
1538afe13c8eSmrg		;;
153974a3f230Smrg	spu-*)
154074b97a6cSmrg		os=elf
1541afe13c8eSmrg		;;
1542b3307321Smrg	*-acorn)
154374b97a6cSmrg		os=riscix1.2
1544b3307321Smrg		;;
1545b3307321Smrg	arm*-rebel)
154674b97a6cSmrg		kernel=linux
154774b97a6cSmrg		os=gnu
1548b3307321Smrg		;;
1549b3307321Smrg	arm*-semi)
155074b97a6cSmrg		os=aout
1551b3307321Smrg		;;
155274a3f230Smrg	c4x-* | tic4x-*)
155374b97a6cSmrg		os=coff
155474a3f230Smrg		;;
155506ef0fecSmrg	c8051-*)
155674b97a6cSmrg		os=elf
155774b97a6cSmrg		;;
155874b97a6cSmrg	clipper-intergraph)
155974b97a6cSmrg		os=clix
156006ef0fecSmrg		;;
156174a3f230Smrg	hexagon-*)
156274b97a6cSmrg		os=elf
1563b3307321Smrg		;;
156429cb5710Smrg	tic54x-*)
156574b97a6cSmrg		os=coff
156629cb5710Smrg		;;
156729cb5710Smrg	tic55x-*)
156874b97a6cSmrg		os=coff
156929cb5710Smrg		;;
157029cb5710Smrg	tic6x-*)
157174b97a6cSmrg		os=coff
157229cb5710Smrg		;;
1573b3307321Smrg	# This must come before the *-dec entry.
1574b3307321Smrg	pdp10-*)
157574b97a6cSmrg		os=tops20
1576b3307321Smrg		;;
1577b3307321Smrg	pdp11-*)
157874b97a6cSmrg		os=none
1579b3307321Smrg		;;
1580b3307321Smrg	*-dec | vax-*)
158174b97a6cSmrg		os=ultrix4.2
1582b3307321Smrg		;;
1583b3307321Smrg	m68*-apollo)
158474b97a6cSmrg		os=domain
1585b3307321Smrg		;;
1586b3307321Smrg	i386-sun)
158774b97a6cSmrg		os=sunos4.0.2
1588b3307321Smrg		;;
1589b3307321Smrg	m68000-sun)
159074b97a6cSmrg		os=sunos3
1591b3307321Smrg		;;
1592b3307321Smrg	m68*-cisco)
159374b97a6cSmrg		os=aout
1594b3307321Smrg		;;
159574a3f230Smrg	mep-*)
159674b97a6cSmrg		os=elf
1597afe13c8eSmrg		;;
1598b3307321Smrg	mips*-cisco)
159974b97a6cSmrg		os=elf
1600b3307321Smrg		;;
1601b3307321Smrg	mips*-*)
160274b97a6cSmrg		os=elf
1603b3307321Smrg		;;
1604b3307321Smrg	or32-*)
160574b97a6cSmrg		os=coff
1606b3307321Smrg		;;
1607b3307321Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
160874b97a6cSmrg		os=sysv3
1609b3307321Smrg		;;
1610b3307321Smrg	sparc-* | *-sun)
161174b97a6cSmrg		os=sunos4.1.1
1612b3307321Smrg		;;
161306ef0fecSmrg	pru-*)
161474b97a6cSmrg		os=elf
161506ef0fecSmrg		;;
1616b3307321Smrg	*-be)
161774b97a6cSmrg		os=beos
1618b3307321Smrg		;;
1619b3307321Smrg	*-ibm)
162074b97a6cSmrg		os=aix
1621b3307321Smrg		;;
162274a3f230Smrg	*-knuth)
162374b97a6cSmrg		os=mmixware
1624afe13c8eSmrg		;;
1625b3307321Smrg	*-wec)
162674b97a6cSmrg		os=proelf
1627b3307321Smrg		;;
1628b3307321Smrg	*-winbond)
162974b97a6cSmrg		os=proelf
1630b3307321Smrg		;;
1631b3307321Smrg	*-oki)
163274b97a6cSmrg		os=proelf
1633b3307321Smrg		;;
1634b3307321Smrg	*-hp)
163574b97a6cSmrg		os=hpux
1636b3307321Smrg		;;
1637b3307321Smrg	*-hitachi)
163874b97a6cSmrg		os=hiux
1639b3307321Smrg		;;
1640b3307321Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
164174b97a6cSmrg		os=sysv
1642b3307321Smrg		;;
1643b3307321Smrg	*-cbm)
164474b97a6cSmrg		os=amigaos
1645b3307321Smrg		;;
1646b3307321Smrg	*-dg)
164774b97a6cSmrg		os=dgux
1648b3307321Smrg		;;
1649b3307321Smrg	*-dolphin)
165074b97a6cSmrg		os=sysv3
1651b3307321Smrg		;;
1652b3307321Smrg	m68k-ccur)
165374b97a6cSmrg		os=rtu
1654b3307321Smrg		;;
1655b3307321Smrg	m88k-omron*)
165674b97a6cSmrg		os=luna
1657b3307321Smrg		;;
165806ef0fecSmrg	*-next)
165974b97a6cSmrg		os=nextstep
1660b3307321Smrg		;;
1661b3307321Smrg	*-sequent)
166274b97a6cSmrg		os=ptx
1663b3307321Smrg		;;
1664b3307321Smrg	*-crds)
166574b97a6cSmrg		os=unos
1666b3307321Smrg		;;
1667b3307321Smrg	*-ns)
166874b97a6cSmrg		os=genix
1669b3307321Smrg		;;
1670b3307321Smrg	i370-*)
167174b97a6cSmrg		os=mvs
1672b3307321Smrg		;;
1673b3307321Smrg	*-gould)
167474b97a6cSmrg		os=sysv
1675b3307321Smrg		;;
1676b3307321Smrg	*-highlevel)
167774b97a6cSmrg		os=bsd
1678b3307321Smrg		;;
1679b3307321Smrg	*-encore)
168074b97a6cSmrg		os=bsd
1681b3307321Smrg		;;
1682b3307321Smrg	*-sgi)
168374b97a6cSmrg		os=irix
1684b3307321Smrg		;;
1685b3307321Smrg	*-siemens)
168674b97a6cSmrg		os=sysv4
1687b3307321Smrg		;;
1688b3307321Smrg	*-masscomp)
168974b97a6cSmrg		os=rtu
1690b3307321Smrg		;;
1691b3307321Smrg	f30[01]-fujitsu | f700-fujitsu)
169274b97a6cSmrg		os=uxpv
1693b3307321Smrg		;;
1694b3307321Smrg	*-rom68k)
169574b97a6cSmrg		os=coff
1696b3307321Smrg		;;
1697b3307321Smrg	*-*bug)
169874b97a6cSmrg		os=coff
1699b3307321Smrg		;;
1700b3307321Smrg	*-apple)
170174b97a6cSmrg		os=macos
1702b3307321Smrg		;;
1703b3307321Smrg	*-atari*)
170474b97a6cSmrg		os=mint
170574b97a6cSmrg		;;
170674b97a6cSmrg	*-wrs)
170774b97a6cSmrg		os=vxworks
1708b3307321Smrg		;;
1709b3307321Smrg	*)
171074b97a6cSmrg		os=none
1711b3307321Smrg		;;
1712b3307321Smrgesac
171374b97a6cSmrg
1714b3307321Smrgfi
1715b3307321Smrg
171674b97a6cSmrg# Now, validate our (potentially fixed-up) OS.
171774b97a6cSmrgcase $os in
171874b97a6cSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17196728f30eSmrg	musl* | newlib* | relibc* | uclibc*)
172074b97a6cSmrg		;;
172174b97a6cSmrg	# Likewise for "kernel-abi"
172274b97a6cSmrg	eabi* | gnueabi*)
172374b97a6cSmrg		;;
172474b97a6cSmrg	# VxWorks passes extra cpu info in the 4th filed.
172574b97a6cSmrg	simlinux | simwindows | spe)
172674b97a6cSmrg		;;
172774b97a6cSmrg	# Now accept the basic system types.
172874b97a6cSmrg	# The portable systems comes first.
172974b97a6cSmrg	# Each alternative MUST end in a * to match a version number.
173074b97a6cSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
173174b97a6cSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
173274b97a6cSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
173374b97a6cSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
173474b97a6cSmrg	     | hiux* | abug | nacl* | netware* | windows* \
173574b97a6cSmrg	     | os9* | macos* | osx* | ios* \
173674b97a6cSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
173774b97a6cSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
173874b97a6cSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173974b97a6cSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
174074b97a6cSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
174174b97a6cSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
174274b97a6cSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
174374b97a6cSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
174474b97a6cSmrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
174574b97a6cSmrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
174674b97a6cSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
174774b97a6cSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
174874b97a6cSmrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174974b97a6cSmrg	     | midipix* | mingw32* | mingw64* | mint* \
175074b97a6cSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
175174b97a6cSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
175274b97a6cSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
175374b97a6cSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
175474b97a6cSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
175574b97a6cSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
175674b97a6cSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
175774b97a6cSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
175874b97a6cSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175974b97a6cSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17606728f30eSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17616728f30eSmrg	     | fiwix* | mlibc* )
176274b97a6cSmrg		;;
176374b97a6cSmrg	# This one is extra strict with allowed versions
176474b97a6cSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
176574b97a6cSmrg		# Don't forget version if it is 3.2v4 or newer.
176674b97a6cSmrg		;;
176774b97a6cSmrg	none)
176874b97a6cSmrg		;;
17696728f30eSmrg	kernel* )
17706728f30eSmrg		# Restricted further below
17716728f30eSmrg		;;
177274b97a6cSmrg	*)
177374b97a6cSmrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
177474b97a6cSmrg		exit 1
177574b97a6cSmrg		;;
177674b97a6cSmrgesac
177774b97a6cSmrg
177874b97a6cSmrg# As a final step for OS-related things, validate the OS-kernel combination
177974b97a6cSmrg# (given a valid OS), if there is a kernel.
178074b97a6cSmrgcase $kernel-$os in
17816728f30eSmrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
17826728f30eSmrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
178374b97a6cSmrg		;;
178474b97a6cSmrg	uclinux-uclibc* )
178574b97a6cSmrg		;;
17866728f30eSmrg	managarm-mlibc* | managarm-kernel* )
17876728f30eSmrg		;;
17886728f30eSmrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
178974b97a6cSmrg		# These are just libc implementations, not actual OSes, and thus
179074b97a6cSmrg		# require a kernel.
179174b97a6cSmrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
179274b97a6cSmrg		exit 1
179374b97a6cSmrg		;;
17946728f30eSmrg	-kernel* )
17956728f30eSmrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
17966728f30eSmrg		exit 1
17976728f30eSmrg		;;
17986728f30eSmrg	*-kernel* )
17996728f30eSmrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
18006728f30eSmrg		exit 1
18016728f30eSmrg		;;
180274b97a6cSmrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
180374b97a6cSmrg		;;
180474b97a6cSmrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
180574b97a6cSmrg		;;
180674b97a6cSmrg	nto-qnx*)
180774b97a6cSmrg		;;
180874b97a6cSmrg	os2-emx)
180974b97a6cSmrg		;;
181074b97a6cSmrg	*-eabi* | *-gnueabi*)
181174b97a6cSmrg		;;
181274b97a6cSmrg	-*)
181374b97a6cSmrg		# Blank kernel with real OS is always fine.
181474b97a6cSmrg		;;
181574b97a6cSmrg	*-*)
181674b97a6cSmrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
181774b97a6cSmrg		exit 1
181874b97a6cSmrg		;;
181974b97a6cSmrgesac
182074b97a6cSmrg
1821b3307321Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1822b3307321Smrg# manufacturer.  We pick the logical manufacturer.
182374b97a6cSmrgcase $vendor in
182474b97a6cSmrg	unknown)
182574b97a6cSmrg		case $cpu-$os in
182674b97a6cSmrg			*-riscix*)
1827b3307321Smrg				vendor=acorn
1828b3307321Smrg				;;
182974b97a6cSmrg			*-sunos*)
1830b3307321Smrg				vendor=sun
1831b3307321Smrg				;;
183274b97a6cSmrg			*-cnk* | *-aix*)
1833b3307321Smrg				vendor=ibm
1834b3307321Smrg				;;
183574b97a6cSmrg			*-beos*)
1836b3307321Smrg				vendor=be
1837b3307321Smrg				;;
183874b97a6cSmrg			*-hpux*)
1839b3307321Smrg				vendor=hp
1840b3307321Smrg				;;
184174b97a6cSmrg			*-mpeix*)
1842b3307321Smrg				vendor=hp
1843b3307321Smrg				;;
184474b97a6cSmrg			*-hiux*)
1845b3307321Smrg				vendor=hitachi
1846b3307321Smrg				;;
184774b97a6cSmrg			*-unos*)
1848b3307321Smrg				vendor=crds
1849b3307321Smrg				;;
185074b97a6cSmrg			*-dgux*)
1851b3307321Smrg				vendor=dg
1852b3307321Smrg				;;
185374b97a6cSmrg			*-luna*)
1854b3307321Smrg				vendor=omron
1855b3307321Smrg				;;
185674b97a6cSmrg			*-genix*)
1857b3307321Smrg				vendor=ns
1858b3307321Smrg				;;
185974b97a6cSmrg			*-clix*)
186074b97a6cSmrg				vendor=intergraph
186174b97a6cSmrg				;;
186274b97a6cSmrg			*-mvs* | *-opened*)
186374b97a6cSmrg				vendor=ibm
186474b97a6cSmrg				;;
186574b97a6cSmrg			*-os400*)
1866b3307321Smrg				vendor=ibm
1867b3307321Smrg				;;
186874b97a6cSmrg			s390-* | s390x-*)
1869afe13c8eSmrg				vendor=ibm
1870afe13c8eSmrg				;;
187174b97a6cSmrg			*-ptx*)
1872b3307321Smrg				vendor=sequent
1873b3307321Smrg				;;
187474b97a6cSmrg			*-tpf*)
1875afe13c8eSmrg				vendor=ibm
1876afe13c8eSmrg				;;
187774b97a6cSmrg			*-vxsim* | *-vxworks* | *-windiss*)
1878b3307321Smrg				vendor=wrs
1879b3307321Smrg				;;
188074b97a6cSmrg			*-aux*)
1881b3307321Smrg				vendor=apple
1882b3307321Smrg				;;
188374b97a6cSmrg			*-hms*)
1884b3307321Smrg				vendor=hitachi
1885b3307321Smrg				;;
188674b97a6cSmrg			*-mpw* | *-macos*)
1887b3307321Smrg				vendor=apple
1888b3307321Smrg				;;
188974b97a6cSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890b3307321Smrg				vendor=atari
1891b3307321Smrg				;;
189274b97a6cSmrg			*-vos*)
1893b3307321Smrg				vendor=stratus
1894b3307321Smrg				;;
1895b3307321Smrg		esac
1896b3307321Smrg		;;
1897b3307321Smrgesac
1898b3307321Smrg
189974b97a6cSmrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900afe13c8eSmrgexit
1901b3307321Smrg
1902b3307321Smrg# Local variables:
190374b97a6cSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904b3307321Smrg# time-stamp-start: "timestamp='"
1905b3307321Smrg# time-stamp-format: "%:y-%02m-%02d"
1906b3307321Smrg# time-stamp-end: "'"
1907b3307321Smrg# End:
1908