1c7484f1fSmrg#! /bin/sh
2c7484f1fSmrg# Configuration validation subroutine script.
3d5e55f73Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4c7484f1fSmrg
563323ee5Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
663323ee5Smrg
7d5e55f73Smrgtimestamp='2023-01-21'
8c7484f1fSmrg
9e6ecbdaeSmrg# This file is free software; you can redistribute it and/or modify it
10e6ecbdaeSmrg# under the terms of the GNU General Public License as published by
11d5e55f73Smrg# the Free Software Foundation, either version 3 of the License, or
12c7484f1fSmrg# (at your option) any later version.
13c7484f1fSmrg#
14e6ecbdaeSmrg# This program is distributed in the hope that it will be useful, but
15e6ecbdaeSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16e6ecbdaeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17e6ecbdaeSmrg# General Public License for more details.
18c7484f1fSmrg#
19c7484f1fSmrg# You should have received a copy of the GNU General Public License
2063323ee5Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21c7484f1fSmrg#
22c7484f1fSmrg# As a special exception to the GNU General Public License, if you
23c7484f1fSmrg# distribute this file as part of a program that contains a
24c7484f1fSmrg# configuration script generated by Autoconf, you may include it under
25e6ecbdaeSmrg# the same distribution terms that you use for the rest of that
26e6ecbdaeSmrg# program.  This Exception is an additional permission under section 7
27e6ecbdaeSmrg# of the GNU General Public License, version 3 ("GPLv3").
28c7484f1fSmrg
29c7484f1fSmrg
30ebb1c56dSmrg# Please send patches to <config-patches@gnu.org>.
31c7484f1fSmrg#
32c7484f1fSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33c7484f1fSmrg# Supply the specified configuration type as an argument.
34c7484f1fSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35c7484f1fSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36c7484f1fSmrg
37baed689fSmrg# You can get the latest version of this script from:
3863323ee5Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39baed689fSmrg
40c7484f1fSmrg# This file is supposed to be the same for all GNU packages
41c7484f1fSmrg# and recognize all the CPU types, system types and aliases
42c7484f1fSmrg# that are meaningful with *any* GNU software.
43c7484f1fSmrg# Each package is responsible for reporting which valid configurations
44c7484f1fSmrg# it does not support.  The user should be able to distinguish
45c7484f1fSmrg# a failure to support a valid configuration from a meaningless
46c7484f1fSmrg# configuration.
47c7484f1fSmrg
48c7484f1fSmrg# The goal of this file is to map all the various variations of a given
49c7484f1fSmrg# machine specification into a single specification in the form:
50c7484f1fSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51c7484f1fSmrg# or in some cases, the newer four-part form:
52c7484f1fSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53c7484f1fSmrg# It is wrong to echo any other type of specification.
54c7484f1fSmrg
5563323ee5Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
5663323ee5Smrg# about features and limitations of the classic Bourne shell that were
5763323ee5Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
5863323ee5Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5963323ee5Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6063323ee5Smrg# have a pre-POSIX /bin/sh.
6163323ee5Smrg
62c7484f1fSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63c7484f1fSmrg
64c7484f1fSmrgusage="\
65ebb1c56dSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66c7484f1fSmrg
67c7484f1fSmrgCanonicalize a configuration name.
68c7484f1fSmrg
6963323ee5SmrgOptions:
70c7484f1fSmrg  -h, --help         print this help, then exit
71c7484f1fSmrg  -t, --time-stamp   print date of last modification, then exit
72c7484f1fSmrg  -v, --version      print version number, then exit
73c7484f1fSmrg
74c7484f1fSmrgReport bugs and patches to <config-patches@gnu.org>."
75c7484f1fSmrg
76c7484f1fSmrgversion="\
77c7484f1fSmrgGNU config.sub ($timestamp)
78c7484f1fSmrg
79d5e55f73SmrgCopyright 1992-2023 Free Software Foundation, Inc.
80c7484f1fSmrg
81c7484f1fSmrgThis is free software; see the source for copying conditions.  There is NO
82c7484f1fSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83c7484f1fSmrg
84c7484f1fSmrghelp="
85c7484f1fSmrgTry \`$me --help' for more information."
86c7484f1fSmrg
87c7484f1fSmrg# Parse command line
88c7484f1fSmrgwhile test $# -gt 0 ; do
89c7484f1fSmrg  case $1 in
90c7484f1fSmrg    --time-stamp | --time* | -t )
91c7484f1fSmrg       echo "$timestamp" ; exit ;;
92c7484f1fSmrg    --version | -v )
93c7484f1fSmrg       echo "$version" ; exit ;;
94c7484f1fSmrg    --help | --h* | -h )
95c7484f1fSmrg       echo "$usage"; exit ;;
96c7484f1fSmrg    -- )     # Stop option processing
97c7484f1fSmrg       shift; break ;;
98c7484f1fSmrg    - )	# Use stdin as input.
99c7484f1fSmrg       break ;;
100c7484f1fSmrg    -* )
10163323ee5Smrg       echo "$me: invalid option $1$help" >&2
102c7484f1fSmrg       exit 1 ;;
103c7484f1fSmrg
104c7484f1fSmrg    *local*)
105c7484f1fSmrg       # First pass through any local machine types.
10663323ee5Smrg       echo "$1"
107c7484f1fSmrg       exit ;;
108c7484f1fSmrg
109c7484f1fSmrg    * )
110c7484f1fSmrg       break ;;
111c7484f1fSmrg  esac
112c7484f1fSmrgdone
113c7484f1fSmrg
114c7484f1fSmrgcase $# in
115c7484f1fSmrg 0) echo "$me: missing argument$help" >&2
116c7484f1fSmrg    exit 1;;
117c7484f1fSmrg 1) ;;
118c7484f1fSmrg *) echo "$me: too many arguments$help" >&2
119c7484f1fSmrg    exit 1;;
120c7484f1fSmrgesac
121c7484f1fSmrg
12263323ee5Smrg# Split fields of configuration type
12363323ee5Smrg# shellcheck disable=SC2162
12463323ee5Smrgsaved_IFS=$IFS
12563323ee5SmrgIFS="-" read field1 field2 field3 field4 <<EOF
12663323ee5Smrg$1
12763323ee5SmrgEOF
12863323ee5SmrgIFS=$saved_IFS
129c7484f1fSmrg
13063323ee5Smrg# Separate into logical components for further validation
13163323ee5Smrgcase $1 in
13263323ee5Smrg	*-*-*-*-*)
13363323ee5Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
13463323ee5Smrg		exit 1
135c7484f1fSmrg		;;
13663323ee5Smrg	*-*-*-*)
13763323ee5Smrg		basic_machine=$field1-$field2
13863323ee5Smrg		basic_os=$field3-$field4
139c7484f1fSmrg		;;
14063323ee5Smrg	*-*-*)
14163323ee5Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14263323ee5Smrg		# parts
14363323ee5Smrg		maybe_os=$field2-$field3
14463323ee5Smrg		case $maybe_os in
14563323ee5Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
14663323ee5Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14763323ee5Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148d5e55f73Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
14963323ee5Smrg				basic_machine=$field1
15063323ee5Smrg				basic_os=$maybe_os
15163323ee5Smrg				;;
15263323ee5Smrg			android-linux)
15363323ee5Smrg				basic_machine=$field1-unknown
15463323ee5Smrg				basic_os=linux-android
15563323ee5Smrg				;;
15663323ee5Smrg			*)
15763323ee5Smrg				basic_machine=$field1-$field2
15863323ee5Smrg				basic_os=$field3
15963323ee5Smrg				;;
16063323ee5Smrg		esac
161c7484f1fSmrg		;;
16263323ee5Smrg	*-*)
16363323ee5Smrg		# A lone config we happen to match not fitting any pattern
16463323ee5Smrg		case $field1-$field2 in
16563323ee5Smrg			decstation-3100)
16663323ee5Smrg				basic_machine=mips-dec
16763323ee5Smrg				basic_os=
16863323ee5Smrg				;;
16963323ee5Smrg			*-*)
17063323ee5Smrg				# Second component is usually, but not always the OS
17163323ee5Smrg				case $field2 in
17263323ee5Smrg					# Prevent following clause from handling this valid os
17363323ee5Smrg					sun*os*)
17463323ee5Smrg						basic_machine=$field1
17563323ee5Smrg						basic_os=$field2
17663323ee5Smrg						;;
17763323ee5Smrg					zephyr*)
17863323ee5Smrg						basic_machine=$field1-unknown
17963323ee5Smrg						basic_os=$field2
18063323ee5Smrg						;;
18163323ee5Smrg					# Manufacturers
18263323ee5Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18363323ee5Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18463323ee5Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18563323ee5Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18663323ee5Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18763323ee5Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18863323ee5Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18963323ee5Smrg					| microblaze* | sim | cisco \
19063323ee5Smrg					| oki | wec | wrs | winbond)
19163323ee5Smrg						basic_machine=$field1-$field2
19263323ee5Smrg						basic_os=
19363323ee5Smrg						;;
19463323ee5Smrg					*)
19563323ee5Smrg						basic_machine=$field1
19663323ee5Smrg						basic_os=$field2
19763323ee5Smrg						;;
19863323ee5Smrg				esac
19963323ee5Smrg			;;
20063323ee5Smrg		esac
201c7484f1fSmrg		;;
20263323ee5Smrg	*)
20363323ee5Smrg		# Convert single-component short-hands not valid as part of
20463323ee5Smrg		# multi-component configurations.
20563323ee5Smrg		case $field1 in
20663323ee5Smrg			386bsd)
20763323ee5Smrg				basic_machine=i386-pc
20863323ee5Smrg				basic_os=bsd
20963323ee5Smrg				;;
21063323ee5Smrg			a29khif)
21163323ee5Smrg				basic_machine=a29k-amd
21263323ee5Smrg				basic_os=udi
21363323ee5Smrg				;;
21463323ee5Smrg			adobe68k)
21563323ee5Smrg				basic_machine=m68010-adobe
21663323ee5Smrg				basic_os=scout
21763323ee5Smrg				;;
21863323ee5Smrg			alliant)
21963323ee5Smrg				basic_machine=fx80-alliant
22063323ee5Smrg				basic_os=
22163323ee5Smrg				;;
22263323ee5Smrg			altos | altos3068)
22363323ee5Smrg				basic_machine=m68k-altos
22463323ee5Smrg				basic_os=
22563323ee5Smrg				;;
22663323ee5Smrg			am29k)
22763323ee5Smrg				basic_machine=a29k-none
22863323ee5Smrg				basic_os=bsd
22963323ee5Smrg				;;
23063323ee5Smrg			amdahl)
23163323ee5Smrg				basic_machine=580-amdahl
23263323ee5Smrg				basic_os=sysv
23363323ee5Smrg				;;
23463323ee5Smrg			amiga)
23563323ee5Smrg				basic_machine=m68k-unknown
23663323ee5Smrg				basic_os=
23763323ee5Smrg				;;
23863323ee5Smrg			amigaos | amigados)
23963323ee5Smrg				basic_machine=m68k-unknown
24063323ee5Smrg				basic_os=amigaos
24163323ee5Smrg				;;
24263323ee5Smrg			amigaunix | amix)
24363323ee5Smrg				basic_machine=m68k-unknown
24463323ee5Smrg				basic_os=sysv4
24563323ee5Smrg				;;
24663323ee5Smrg			apollo68)
24763323ee5Smrg				basic_machine=m68k-apollo
24863323ee5Smrg				basic_os=sysv
24963323ee5Smrg				;;
25063323ee5Smrg			apollo68bsd)
25163323ee5Smrg				basic_machine=m68k-apollo
25263323ee5Smrg				basic_os=bsd
25363323ee5Smrg				;;
25463323ee5Smrg			aros)
25563323ee5Smrg				basic_machine=i386-pc
25663323ee5Smrg				basic_os=aros
25763323ee5Smrg				;;
25863323ee5Smrg			aux)
25963323ee5Smrg				basic_machine=m68k-apple
26063323ee5Smrg				basic_os=aux
26163323ee5Smrg				;;
26263323ee5Smrg			balance)
26363323ee5Smrg				basic_machine=ns32k-sequent
26463323ee5Smrg				basic_os=dynix
26563323ee5Smrg				;;
26663323ee5Smrg			blackfin)
26763323ee5Smrg				basic_machine=bfin-unknown
26863323ee5Smrg				basic_os=linux
26963323ee5Smrg				;;
27063323ee5Smrg			cegcc)
27163323ee5Smrg				basic_machine=arm-unknown
27263323ee5Smrg				basic_os=cegcc
27363323ee5Smrg				;;
27463323ee5Smrg			convex-c1)
27563323ee5Smrg				basic_machine=c1-convex
27663323ee5Smrg				basic_os=bsd
27763323ee5Smrg				;;
27863323ee5Smrg			convex-c2)
27963323ee5Smrg				basic_machine=c2-convex
28063323ee5Smrg				basic_os=bsd
28163323ee5Smrg				;;
28263323ee5Smrg			convex-c32)
28363323ee5Smrg				basic_machine=c32-convex
28463323ee5Smrg				basic_os=bsd
28563323ee5Smrg				;;
28663323ee5Smrg			convex-c34)
28763323ee5Smrg				basic_machine=c34-convex
28863323ee5Smrg				basic_os=bsd
28963323ee5Smrg				;;
29063323ee5Smrg			convex-c38)
29163323ee5Smrg				basic_machine=c38-convex
29263323ee5Smrg				basic_os=bsd
29363323ee5Smrg				;;
29463323ee5Smrg			cray)
29563323ee5Smrg				basic_machine=j90-cray
29663323ee5Smrg				basic_os=unicos
29763323ee5Smrg				;;
29863323ee5Smrg			crds | unos)
29963323ee5Smrg				basic_machine=m68k-crds
30063323ee5Smrg				basic_os=
30163323ee5Smrg				;;
30263323ee5Smrg			da30)
30363323ee5Smrg				basic_machine=m68k-da30
30463323ee5Smrg				basic_os=
30563323ee5Smrg				;;
30663323ee5Smrg			decstation | pmax | pmin | dec3100 | decstatn)
30763323ee5Smrg				basic_machine=mips-dec
30863323ee5Smrg				basic_os=
30963323ee5Smrg				;;
31063323ee5Smrg			delta88)
31163323ee5Smrg				basic_machine=m88k-motorola
31263323ee5Smrg				basic_os=sysv3
31363323ee5Smrg				;;
31463323ee5Smrg			dicos)
31563323ee5Smrg				basic_machine=i686-pc
31663323ee5Smrg				basic_os=dicos
31763323ee5Smrg				;;
31863323ee5Smrg			djgpp)
31963323ee5Smrg				basic_machine=i586-pc
32063323ee5Smrg				basic_os=msdosdjgpp
32163323ee5Smrg				;;
32263323ee5Smrg			ebmon29k)
32363323ee5Smrg				basic_machine=a29k-amd
32463323ee5Smrg				basic_os=ebmon
32563323ee5Smrg				;;
32663323ee5Smrg			es1800 | OSE68k | ose68k | ose | OSE)
32763323ee5Smrg				basic_machine=m68k-ericsson
32863323ee5Smrg				basic_os=ose
32963323ee5Smrg				;;
33063323ee5Smrg			gmicro)
33163323ee5Smrg				basic_machine=tron-gmicro
33263323ee5Smrg				basic_os=sysv
33363323ee5Smrg				;;
33463323ee5Smrg			go32)
33563323ee5Smrg				basic_machine=i386-pc
33663323ee5Smrg				basic_os=go32
33763323ee5Smrg				;;
33863323ee5Smrg			h8300hms)
33963323ee5Smrg				basic_machine=h8300-hitachi
34063323ee5Smrg				basic_os=hms
34163323ee5Smrg				;;
34263323ee5Smrg			h8300xray)
34363323ee5Smrg				basic_machine=h8300-hitachi
34463323ee5Smrg				basic_os=xray
34563323ee5Smrg				;;
34663323ee5Smrg			h8500hms)
34763323ee5Smrg				basic_machine=h8500-hitachi
34863323ee5Smrg				basic_os=hms
34963323ee5Smrg				;;
35063323ee5Smrg			harris)
35163323ee5Smrg				basic_machine=m88k-harris
35263323ee5Smrg				basic_os=sysv3
35363323ee5Smrg				;;
35463323ee5Smrg			hp300 | hp300hpux)
35563323ee5Smrg				basic_machine=m68k-hp
35663323ee5Smrg				basic_os=hpux
35763323ee5Smrg				;;
35863323ee5Smrg			hp300bsd)
35963323ee5Smrg				basic_machine=m68k-hp
36063323ee5Smrg				basic_os=bsd
36163323ee5Smrg				;;
36263323ee5Smrg			hppaosf)
36363323ee5Smrg				basic_machine=hppa1.1-hp
36463323ee5Smrg				basic_os=osf
36563323ee5Smrg				;;
36663323ee5Smrg			hppro)
36763323ee5Smrg				basic_machine=hppa1.1-hp
36863323ee5Smrg				basic_os=proelf
36963323ee5Smrg				;;
37063323ee5Smrg			i386mach)
37163323ee5Smrg				basic_machine=i386-mach
37263323ee5Smrg				basic_os=mach
37363323ee5Smrg				;;
37463323ee5Smrg			isi68 | isi)
37563323ee5Smrg				basic_machine=m68k-isi
37663323ee5Smrg				basic_os=sysv
37763323ee5Smrg				;;
37863323ee5Smrg			m68knommu)
37963323ee5Smrg				basic_machine=m68k-unknown
38063323ee5Smrg				basic_os=linux
38163323ee5Smrg				;;
38263323ee5Smrg			magnum | m3230)
38363323ee5Smrg				basic_machine=mips-mips
38463323ee5Smrg				basic_os=sysv
38563323ee5Smrg				;;
38663323ee5Smrg			merlin)
38763323ee5Smrg				basic_machine=ns32k-utek
38863323ee5Smrg				basic_os=sysv
38963323ee5Smrg				;;
39063323ee5Smrg			mingw64)
39163323ee5Smrg				basic_machine=x86_64-pc
39263323ee5Smrg				basic_os=mingw64
39363323ee5Smrg				;;
39463323ee5Smrg			mingw32)
39563323ee5Smrg				basic_machine=i686-pc
39663323ee5Smrg				basic_os=mingw32
39763323ee5Smrg				;;
39863323ee5Smrg			mingw32ce)
39963323ee5Smrg				basic_machine=arm-unknown
40063323ee5Smrg				basic_os=mingw32ce
40163323ee5Smrg				;;
40263323ee5Smrg			monitor)
40363323ee5Smrg				basic_machine=m68k-rom68k
40463323ee5Smrg				basic_os=coff
40563323ee5Smrg				;;
40663323ee5Smrg			morphos)
40763323ee5Smrg				basic_machine=powerpc-unknown
40863323ee5Smrg				basic_os=morphos
40963323ee5Smrg				;;
41063323ee5Smrg			moxiebox)
41163323ee5Smrg				basic_machine=moxie-unknown
41263323ee5Smrg				basic_os=moxiebox
41363323ee5Smrg				;;
41463323ee5Smrg			msdos)
41563323ee5Smrg				basic_machine=i386-pc
41663323ee5Smrg				basic_os=msdos
41763323ee5Smrg				;;
41863323ee5Smrg			msys)
41963323ee5Smrg				basic_machine=i686-pc
42063323ee5Smrg				basic_os=msys
42163323ee5Smrg				;;
42263323ee5Smrg			mvs)
42363323ee5Smrg				basic_machine=i370-ibm
42463323ee5Smrg				basic_os=mvs
42563323ee5Smrg				;;
42663323ee5Smrg			nacl)
42763323ee5Smrg				basic_machine=le32-unknown
42863323ee5Smrg				basic_os=nacl
42963323ee5Smrg				;;
43063323ee5Smrg			ncr3000)
43163323ee5Smrg				basic_machine=i486-ncr
43263323ee5Smrg				basic_os=sysv4
43363323ee5Smrg				;;
43463323ee5Smrg			netbsd386)
43563323ee5Smrg				basic_machine=i386-pc
43663323ee5Smrg				basic_os=netbsd
43763323ee5Smrg				;;
43863323ee5Smrg			netwinder)
43963323ee5Smrg				basic_machine=armv4l-rebel
44063323ee5Smrg				basic_os=linux
44163323ee5Smrg				;;
44263323ee5Smrg			news | news700 | news800 | news900)
44363323ee5Smrg				basic_machine=m68k-sony
44463323ee5Smrg				basic_os=newsos
44563323ee5Smrg				;;
44663323ee5Smrg			news1000)
44763323ee5Smrg				basic_machine=m68030-sony
44863323ee5Smrg				basic_os=newsos
44963323ee5Smrg				;;
45063323ee5Smrg			necv70)
45163323ee5Smrg				basic_machine=v70-nec
45263323ee5Smrg				basic_os=sysv
45363323ee5Smrg				;;
45463323ee5Smrg			nh3000)
45563323ee5Smrg				basic_machine=m68k-harris
45663323ee5Smrg				basic_os=cxux
45763323ee5Smrg				;;
45863323ee5Smrg			nh[45]000)
45963323ee5Smrg				basic_machine=m88k-harris
46063323ee5Smrg				basic_os=cxux
46163323ee5Smrg				;;
46263323ee5Smrg			nindy960)
46363323ee5Smrg				basic_machine=i960-intel
46463323ee5Smrg				basic_os=nindy
46563323ee5Smrg				;;
46663323ee5Smrg			mon960)
46763323ee5Smrg				basic_machine=i960-intel
46863323ee5Smrg				basic_os=mon960
46963323ee5Smrg				;;
47063323ee5Smrg			nonstopux)
47163323ee5Smrg				basic_machine=mips-compaq
47263323ee5Smrg				basic_os=nonstopux
47363323ee5Smrg				;;
47463323ee5Smrg			os400)
47563323ee5Smrg				basic_machine=powerpc-ibm
47663323ee5Smrg				basic_os=os400
47763323ee5Smrg				;;
47863323ee5Smrg			OSE68000 | ose68000)
47963323ee5Smrg				basic_machine=m68000-ericsson
48063323ee5Smrg				basic_os=ose
48163323ee5Smrg				;;
48263323ee5Smrg			os68k)
48363323ee5Smrg				basic_machine=m68k-none
48463323ee5Smrg				basic_os=os68k
48563323ee5Smrg				;;
48663323ee5Smrg			paragon)
48763323ee5Smrg				basic_machine=i860-intel
48863323ee5Smrg				basic_os=osf
48963323ee5Smrg				;;
49063323ee5Smrg			parisc)
49163323ee5Smrg				basic_machine=hppa-unknown
49263323ee5Smrg				basic_os=linux
49363323ee5Smrg				;;
49463323ee5Smrg			psp)
49563323ee5Smrg				basic_machine=mipsallegrexel-sony
49663323ee5Smrg				basic_os=psp
49763323ee5Smrg				;;
49863323ee5Smrg			pw32)
49963323ee5Smrg				basic_machine=i586-unknown
50063323ee5Smrg				basic_os=pw32
50163323ee5Smrg				;;
50263323ee5Smrg			rdos | rdos64)
50363323ee5Smrg				basic_machine=x86_64-pc
50463323ee5Smrg				basic_os=rdos
50563323ee5Smrg				;;
50663323ee5Smrg			rdos32)
50763323ee5Smrg				basic_machine=i386-pc
50863323ee5Smrg				basic_os=rdos
50963323ee5Smrg				;;
51063323ee5Smrg			rom68k)
51163323ee5Smrg				basic_machine=m68k-rom68k
51263323ee5Smrg				basic_os=coff
51363323ee5Smrg				;;
51463323ee5Smrg			sa29200)
51563323ee5Smrg				basic_machine=a29k-amd
51663323ee5Smrg				basic_os=udi
51763323ee5Smrg				;;
51863323ee5Smrg			sei)
51963323ee5Smrg				basic_machine=mips-sei
52063323ee5Smrg				basic_os=seiux
52163323ee5Smrg				;;
52263323ee5Smrg			sequent)
52363323ee5Smrg				basic_machine=i386-sequent
52463323ee5Smrg				basic_os=
52563323ee5Smrg				;;
52663323ee5Smrg			sps7)
52763323ee5Smrg				basic_machine=m68k-bull
52863323ee5Smrg				basic_os=sysv2
52963323ee5Smrg				;;
53063323ee5Smrg			st2000)
53163323ee5Smrg				basic_machine=m68k-tandem
53263323ee5Smrg				basic_os=
53363323ee5Smrg				;;
53463323ee5Smrg			stratus)
53563323ee5Smrg				basic_machine=i860-stratus
53663323ee5Smrg				basic_os=sysv4
53763323ee5Smrg				;;
53863323ee5Smrg			sun2)
53963323ee5Smrg				basic_machine=m68000-sun
54063323ee5Smrg				basic_os=
54163323ee5Smrg				;;
54263323ee5Smrg			sun2os3)
54363323ee5Smrg				basic_machine=m68000-sun
54463323ee5Smrg				basic_os=sunos3
54563323ee5Smrg				;;
54663323ee5Smrg			sun2os4)
54763323ee5Smrg				basic_machine=m68000-sun
54863323ee5Smrg				basic_os=sunos4
54963323ee5Smrg				;;
55063323ee5Smrg			sun3)
55163323ee5Smrg				basic_machine=m68k-sun
55263323ee5Smrg				basic_os=
55363323ee5Smrg				;;
55463323ee5Smrg			sun3os3)
55563323ee5Smrg				basic_machine=m68k-sun
55663323ee5Smrg				basic_os=sunos3
55763323ee5Smrg				;;
55863323ee5Smrg			sun3os4)
55963323ee5Smrg				basic_machine=m68k-sun
56063323ee5Smrg				basic_os=sunos4
56163323ee5Smrg				;;
56263323ee5Smrg			sun4)
56363323ee5Smrg				basic_machine=sparc-sun
56463323ee5Smrg				basic_os=
56563323ee5Smrg				;;
56663323ee5Smrg			sun4os3)
56763323ee5Smrg				basic_machine=sparc-sun
56863323ee5Smrg				basic_os=sunos3
56963323ee5Smrg				;;
57063323ee5Smrg			sun4os4)
57163323ee5Smrg				basic_machine=sparc-sun
57263323ee5Smrg				basic_os=sunos4
57363323ee5Smrg				;;
57463323ee5Smrg			sun4sol2)
57563323ee5Smrg				basic_machine=sparc-sun
57663323ee5Smrg				basic_os=solaris2
57763323ee5Smrg				;;
57863323ee5Smrg			sun386 | sun386i | roadrunner)
57963323ee5Smrg				basic_machine=i386-sun
58063323ee5Smrg				basic_os=
58163323ee5Smrg				;;
58263323ee5Smrg			sv1)
58363323ee5Smrg				basic_machine=sv1-cray
58463323ee5Smrg				basic_os=unicos
58563323ee5Smrg				;;
58663323ee5Smrg			symmetry)
58763323ee5Smrg				basic_machine=i386-sequent
58863323ee5Smrg				basic_os=dynix
58963323ee5Smrg				;;
59063323ee5Smrg			t3e)
59163323ee5Smrg				basic_machine=alphaev5-cray
59263323ee5Smrg				basic_os=unicos
59363323ee5Smrg				;;
59463323ee5Smrg			t90)
59563323ee5Smrg				basic_machine=t90-cray
59663323ee5Smrg				basic_os=unicos
59763323ee5Smrg				;;
59863323ee5Smrg			toad1)
59963323ee5Smrg				basic_machine=pdp10-xkl
60063323ee5Smrg				basic_os=tops20
60163323ee5Smrg				;;
60263323ee5Smrg			tpf)
60363323ee5Smrg				basic_machine=s390x-ibm
60463323ee5Smrg				basic_os=tpf
60563323ee5Smrg				;;
60663323ee5Smrg			udi29k)
60763323ee5Smrg				basic_machine=a29k-amd
60863323ee5Smrg				basic_os=udi
60963323ee5Smrg				;;
61063323ee5Smrg			ultra3)
61163323ee5Smrg				basic_machine=a29k-nyu
61263323ee5Smrg				basic_os=sym1
61363323ee5Smrg				;;
61463323ee5Smrg			v810 | necv810)
61563323ee5Smrg				basic_machine=v810-nec
61663323ee5Smrg				basic_os=none
61763323ee5Smrg				;;
61863323ee5Smrg			vaxv)
61963323ee5Smrg				basic_machine=vax-dec
62063323ee5Smrg				basic_os=sysv
62163323ee5Smrg				;;
62263323ee5Smrg			vms)
62363323ee5Smrg				basic_machine=vax-dec
62463323ee5Smrg				basic_os=vms
62563323ee5Smrg				;;
62663323ee5Smrg			vsta)
62763323ee5Smrg				basic_machine=i386-pc
62863323ee5Smrg				basic_os=vsta
62963323ee5Smrg				;;
63063323ee5Smrg			vxworks960)
63163323ee5Smrg				basic_machine=i960-wrs
63263323ee5Smrg				basic_os=vxworks
63363323ee5Smrg				;;
63463323ee5Smrg			vxworks68)
63563323ee5Smrg				basic_machine=m68k-wrs
63663323ee5Smrg				basic_os=vxworks
63763323ee5Smrg				;;
63863323ee5Smrg			vxworks29k)
63963323ee5Smrg				basic_machine=a29k-wrs
64063323ee5Smrg				basic_os=vxworks
64163323ee5Smrg				;;
64263323ee5Smrg			xbox)
64363323ee5Smrg				basic_machine=i686-pc
64463323ee5Smrg				basic_os=mingw32
64563323ee5Smrg				;;
64663323ee5Smrg			ymp)
64763323ee5Smrg				basic_machine=ymp-cray
64863323ee5Smrg				basic_os=unicos
64963323ee5Smrg				;;
65063323ee5Smrg			*)
65163323ee5Smrg				basic_machine=$1
65263323ee5Smrg				basic_os=
65363323ee5Smrg				;;
65463323ee5Smrg		esac
655c7484f1fSmrg		;;
656c7484f1fSmrgesac
657c7484f1fSmrg
65863323ee5Smrg# Decode 1-component or ad-hoc basic machines
659c7484f1fSmrgcase $basic_machine in
66063323ee5Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66163323ee5Smrg	# some cases the only manufacturer, in others, it is the most popular.
66263323ee5Smrg	w89k)
66363323ee5Smrg		cpu=hppa1.1
66463323ee5Smrg		vendor=winbond
665c7484f1fSmrg		;;
66663323ee5Smrg	op50n)
66763323ee5Smrg		cpu=hppa1.1
66863323ee5Smrg		vendor=oki
669c7484f1fSmrg		;;
67063323ee5Smrg	op60c)
67163323ee5Smrg		cpu=hppa1.1
67263323ee5Smrg		vendor=oki
673c7484f1fSmrg		;;
67463323ee5Smrg	ibm*)
67563323ee5Smrg		cpu=i370
67663323ee5Smrg		vendor=ibm
677e6ecbdaeSmrg		;;
67863323ee5Smrg	orion105)
67963323ee5Smrg		cpu=clipper
68063323ee5Smrg		vendor=highlevel
681e6ecbdaeSmrg		;;
68263323ee5Smrg	mac | mpw | mac-mpw)
68363323ee5Smrg		cpu=m68k
68463323ee5Smrg		vendor=apple
685e6ecbdaeSmrg		;;
68663323ee5Smrg	pmac | pmac-mpw)
68763323ee5Smrg		cpu=powerpc
68863323ee5Smrg		vendor=apple
689e6ecbdaeSmrg		;;
690e6ecbdaeSmrg
691c7484f1fSmrg	# Recognize the various machine names and aliases which stand
692c7484f1fSmrg	# for a CPU type and a company and sometimes even an OS.
693c7484f1fSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69463323ee5Smrg		cpu=m68000
69563323ee5Smrg		vendor=att
696c7484f1fSmrg		;;
697c7484f1fSmrg	3b*)
69863323ee5Smrg		cpu=we32k
69963323ee5Smrg		vendor=att
700baed689fSmrg		;;
701baed689fSmrg	bluegene*)
70263323ee5Smrg		cpu=powerpc
70363323ee5Smrg		vendor=ibm
70463323ee5Smrg		basic_os=cnk
705c7484f1fSmrg		;;
706c7484f1fSmrg	decsystem10* | dec10*)
70763323ee5Smrg		cpu=pdp10
70863323ee5Smrg		vendor=dec
70963323ee5Smrg		basic_os=tops10
710c7484f1fSmrg		;;
711c7484f1fSmrg	decsystem20* | dec20*)
71263323ee5Smrg		cpu=pdp10
71363323ee5Smrg		vendor=dec
71463323ee5Smrg		basic_os=tops20
715c7484f1fSmrg		;;
716c7484f1fSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717c7484f1fSmrg	      | 3300-motorola | delta-motorola)
71863323ee5Smrg		cpu=m68k
71963323ee5Smrg		vendor=motorola
720c7484f1fSmrg		;;
72163323ee5Smrg	dpx2*)
72263323ee5Smrg		cpu=m68k
72363323ee5Smrg		vendor=bull
72463323ee5Smrg		basic_os=sysv3
725c7484f1fSmrg		;;
726c7484f1fSmrg	encore | umax | mmax)
72763323ee5Smrg		cpu=ns32k
72863323ee5Smrg		vendor=encore
729c7484f1fSmrg		;;
73063323ee5Smrg	elxsi)
73163323ee5Smrg		cpu=elxsi
73263323ee5Smrg		vendor=elxsi
73363323ee5Smrg		basic_os=${basic_os:-bsd}
734c7484f1fSmrg		;;
735c7484f1fSmrg	fx2800)
73663323ee5Smrg		cpu=i860
73763323ee5Smrg		vendor=alliant
738c7484f1fSmrg		;;
739c7484f1fSmrg	genix)
74063323ee5Smrg		cpu=ns32k
74163323ee5Smrg		vendor=ns
742c7484f1fSmrg		;;
743c7484f1fSmrg	h3050r* | hiux*)
74463323ee5Smrg		cpu=hppa1.1
74563323ee5Smrg		vendor=hitachi
74663323ee5Smrg		basic_os=hiuxwe2
747c7484f1fSmrg		;;
748c7484f1fSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74963323ee5Smrg		cpu=hppa1.0
75063323ee5Smrg		vendor=hp
751c7484f1fSmrg		;;
752c7484f1fSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75363323ee5Smrg		cpu=m68000
75463323ee5Smrg		vendor=hp
755c7484f1fSmrg		;;
756c7484f1fSmrg	hp9k3[2-9][0-9])
75763323ee5Smrg		cpu=m68k
75863323ee5Smrg		vendor=hp
759c7484f1fSmrg		;;
760c7484f1fSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76163323ee5Smrg		cpu=hppa1.0
76263323ee5Smrg		vendor=hp
763c7484f1fSmrg		;;
764c7484f1fSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76563323ee5Smrg		cpu=hppa1.1
76663323ee5Smrg		vendor=hp
767c7484f1fSmrg		;;
768c7484f1fSmrg	hp9k78[0-9] | hp78[0-9])
769c7484f1fSmrg		# FIXME: really hppa2.0-hp
77063323ee5Smrg		cpu=hppa1.1
77163323ee5Smrg		vendor=hp
772c7484f1fSmrg		;;
773c7484f1fSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774c7484f1fSmrg		# FIXME: really hppa2.0-hp
77563323ee5Smrg		cpu=hppa1.1
77663323ee5Smrg		vendor=hp
777c7484f1fSmrg		;;
778c7484f1fSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77963323ee5Smrg		cpu=hppa1.1
78063323ee5Smrg		vendor=hp
781c7484f1fSmrg		;;
782c7484f1fSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78363323ee5Smrg		cpu=hppa1.0
78463323ee5Smrg		vendor=hp
785c7484f1fSmrg		;;
786c7484f1fSmrg	i*86v32)
78763323ee5Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78863323ee5Smrg		vendor=pc
78963323ee5Smrg		basic_os=sysv32
790c7484f1fSmrg		;;
791c7484f1fSmrg	i*86v4*)
79263323ee5Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79363323ee5Smrg		vendor=pc
79463323ee5Smrg		basic_os=sysv4
795c7484f1fSmrg		;;
796c7484f1fSmrg	i*86v)
79763323ee5Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79863323ee5Smrg		vendor=pc
79963323ee5Smrg		basic_os=sysv
800c7484f1fSmrg		;;
801c7484f1fSmrg	i*86sol2)
80263323ee5Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80363323ee5Smrg		vendor=pc
80463323ee5Smrg		basic_os=solaris2
805c7484f1fSmrg		;;
80663323ee5Smrg	j90 | j90-cray)
80763323ee5Smrg		cpu=j90
80863323ee5Smrg		vendor=cray
80963323ee5Smrg		basic_os=${basic_os:-unicos}
810c7484f1fSmrg		;;
811c7484f1fSmrg	iris | iris4d)
81263323ee5Smrg		cpu=mips
81363323ee5Smrg		vendor=sgi
81463323ee5Smrg		case $basic_os in
81563323ee5Smrg		    irix*)
816c7484f1fSmrg			;;
817c7484f1fSmrg		    *)
81863323ee5Smrg			basic_os=irix4
819c7484f1fSmrg			;;
820c7484f1fSmrg		esac
821c7484f1fSmrg		;;
822c7484f1fSmrg	miniframe)
82363323ee5Smrg		cpu=m68000
82463323ee5Smrg		vendor=convergent
825c7484f1fSmrg		;;
82663323ee5Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82763323ee5Smrg		cpu=m68k
82863323ee5Smrg		vendor=atari
82963323ee5Smrg		basic_os=mint
830c7484f1fSmrg		;;
831c7484f1fSmrg	news-3600 | risc-news)
83263323ee5Smrg		cpu=mips
83363323ee5Smrg		vendor=sony
83463323ee5Smrg		basic_os=newsos
83563323ee5Smrg		;;
83663323ee5Smrg	next | m*-next)
83763323ee5Smrg		cpu=m68k
83863323ee5Smrg		vendor=next
83963323ee5Smrg		case $basic_os in
84063323ee5Smrg		    openstep*)
84163323ee5Smrg		        ;;
84263323ee5Smrg		    nextstep*)
843c7484f1fSmrg			;;
84463323ee5Smrg		    ns2*)
84563323ee5Smrg		      basic_os=nextstep2
846c7484f1fSmrg			;;
847c7484f1fSmrg		    *)
84863323ee5Smrg		      basic_os=nextstep3
849c7484f1fSmrg			;;
850c7484f1fSmrg		esac
851c7484f1fSmrg		;;
852c7484f1fSmrg	np1)
85363323ee5Smrg		cpu=np1
85463323ee5Smrg		vendor=gould
855c7484f1fSmrg		;;
856c7484f1fSmrg	op50n-* | op60c-*)
85763323ee5Smrg		cpu=hppa1.1
85863323ee5Smrg		vendor=oki
85963323ee5Smrg		basic_os=proelf
860c7484f1fSmrg		;;
861c7484f1fSmrg	pa-hitachi)
86263323ee5Smrg		cpu=hppa1.1
86363323ee5Smrg		vendor=hitachi
86463323ee5Smrg		basic_os=hiuxwe2
865baed689fSmrg		;;
866c7484f1fSmrg	pbd)
86763323ee5Smrg		cpu=sparc
86863323ee5Smrg		vendor=tti
869c7484f1fSmrg		;;
870c7484f1fSmrg	pbb)
87163323ee5Smrg		cpu=m68k
87263323ee5Smrg		vendor=tti
873c7484f1fSmrg		;;
87463323ee5Smrg	pc532)
87563323ee5Smrg		cpu=ns32k
87663323ee5Smrg		vendor=pc532
877c7484f1fSmrg		;;
878c7484f1fSmrg	pn)
87963323ee5Smrg		cpu=pn
88063323ee5Smrg		vendor=gould
881c7484f1fSmrg		;;
88263323ee5Smrg	power)
88363323ee5Smrg		cpu=power
88463323ee5Smrg		vendor=ibm
885c7484f1fSmrg		;;
886c7484f1fSmrg	ps2)
88763323ee5Smrg		cpu=i386
88863323ee5Smrg		vendor=ibm
889c7484f1fSmrg		;;
890c7484f1fSmrg	rm[46]00)
89163323ee5Smrg		cpu=mips
89263323ee5Smrg		vendor=siemens
893c7484f1fSmrg		;;
894c7484f1fSmrg	rtpc | rtpc-*)
89563323ee5Smrg		cpu=romp
89663323ee5Smrg		vendor=ibm
897c7484f1fSmrg		;;
89863323ee5Smrg	sde)
89963323ee5Smrg		cpu=mipsisa32
90063323ee5Smrg		vendor=sde
90163323ee5Smrg		basic_os=${basic_os:-elf}
902c7484f1fSmrg		;;
90363323ee5Smrg	simso-wrs)
90463323ee5Smrg		cpu=sparclite
90563323ee5Smrg		vendor=wrs
90663323ee5Smrg		basic_os=vxworks
907c7484f1fSmrg		;;
90863323ee5Smrg	tower | tower-32)
90963323ee5Smrg		cpu=m68k
91063323ee5Smrg		vendor=ncr
911c7484f1fSmrg		;;
91263323ee5Smrg	vpp*|vx|vx-*)
91363323ee5Smrg		cpu=f301
91463323ee5Smrg		vendor=fujitsu
915c7484f1fSmrg		;;
91663323ee5Smrg	w65)
91763323ee5Smrg		cpu=w65
91863323ee5Smrg		vendor=wdc
919c7484f1fSmrg		;;
92063323ee5Smrg	w89k-*)
92163323ee5Smrg		cpu=hppa1.1
92263323ee5Smrg		vendor=winbond
92363323ee5Smrg		basic_os=proelf
924c7484f1fSmrg		;;
92563323ee5Smrg	none)
92663323ee5Smrg		cpu=none
92763323ee5Smrg		vendor=none
928baed689fSmrg		;;
92963323ee5Smrg	leon|leon[3-9])
93063323ee5Smrg		cpu=sparc
93163323ee5Smrg		vendor=$basic_machine
932c7484f1fSmrg		;;
93363323ee5Smrg	leon-*|leon[3-9]-*)
93463323ee5Smrg		cpu=sparc
93563323ee5Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936c7484f1fSmrg		;;
93763323ee5Smrg
93863323ee5Smrg	*-*)
93963323ee5Smrg		# shellcheck disable=SC2162
94063323ee5Smrg		saved_IFS=$IFS
94163323ee5Smrg		IFS="-" read cpu vendor <<EOF
94263323ee5Smrg$basic_machine
94363323ee5SmrgEOF
94463323ee5Smrg		IFS=$saved_IFS
945c7484f1fSmrg		;;
94663323ee5Smrg	# We use `pc' rather than `unknown'
94763323ee5Smrg	# because (1) that's what they normally are, and
94863323ee5Smrg	# (2) the word "unknown" tends to confuse beginning users.
94963323ee5Smrg	i*86 | x86_64)
95063323ee5Smrg		cpu=$basic_machine
95163323ee5Smrg		vendor=pc
952c7484f1fSmrg		;;
95363323ee5Smrg	# These rules are duplicated from below for sake of the special case above;
95463323ee5Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
95563323ee5Smrg	pc98)
95663323ee5Smrg		cpu=i386
95763323ee5Smrg		vendor=pc
958c7484f1fSmrg		;;
95963323ee5Smrg	x64 | amd64)
96063323ee5Smrg		cpu=x86_64
96163323ee5Smrg		vendor=pc
962c7484f1fSmrg		;;
96363323ee5Smrg	# Recognize the basic CPU types without company name.
96463323ee5Smrg	*)
96563323ee5Smrg		cpu=$basic_machine
96663323ee5Smrg		vendor=unknown
967e6ecbdaeSmrg		;;
96863323ee5Smrgesac
96963323ee5Smrg
97063323ee5Smrgunset -v basic_machine
97163323ee5Smrg
97263323ee5Smrg# Decode basic machines in the full and proper CPU-Company form.
97363323ee5Smrgcase $cpu-$vendor in
97463323ee5Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97563323ee5Smrg	# some cases the only manufacturer, in others, it is the most popular.
97663323ee5Smrg	craynv-unknown)
97763323ee5Smrg		vendor=cray
97863323ee5Smrg		basic_os=${basic_os:-unicosmp}
979c7484f1fSmrg		;;
98063323ee5Smrg	c90-unknown | c90-cray)
98163323ee5Smrg		vendor=cray
98263323ee5Smrg		basic_os=${Basic_os:-unicos}
983c7484f1fSmrg		;;
98463323ee5Smrg	fx80-unknown)
98563323ee5Smrg		vendor=alliant
986c7484f1fSmrg		;;
98763323ee5Smrg	romp-unknown)
98863323ee5Smrg		vendor=ibm
989c7484f1fSmrg		;;
99063323ee5Smrg	mmix-unknown)
99163323ee5Smrg		vendor=knuth
992c7484f1fSmrg		;;
99363323ee5Smrg	microblaze-unknown | microblazeel-unknown)
99463323ee5Smrg		vendor=xilinx
995c7484f1fSmrg		;;
99663323ee5Smrg	rs6000-unknown)
99763323ee5Smrg		vendor=ibm
998c7484f1fSmrg		;;
99963323ee5Smrg	vax-unknown)
100063323ee5Smrg		vendor=dec
1001c7484f1fSmrg		;;
100263323ee5Smrg	pdp11-unknown)
100363323ee5Smrg		vendor=dec
1004c7484f1fSmrg		;;
100563323ee5Smrg	we32k-unknown)
100663323ee5Smrg		vendor=att
1007c7484f1fSmrg		;;
100863323ee5Smrg	cydra-unknown)
100963323ee5Smrg		vendor=cydrome
1010c7484f1fSmrg		;;
101163323ee5Smrg	i370-ibm*)
101263323ee5Smrg		vendor=ibm
1013c7484f1fSmrg		;;
101463323ee5Smrg	orion-unknown)
101563323ee5Smrg		vendor=highlevel
1016c7484f1fSmrg		;;
101763323ee5Smrg	xps-unknown | xps100-unknown)
101863323ee5Smrg		cpu=xps100
101963323ee5Smrg		vendor=honeywell
1020c7484f1fSmrg		;;
102163323ee5Smrg
102263323ee5Smrg	# Here we normalize CPU types with a missing or matching vendor
1023d5e55f73Smrg	armh-unknown | armh-alt)
1024d5e55f73Smrg		cpu=armv7l
1025d5e55f73Smrg		vendor=alt
1026d5e55f73Smrg		basic_os=${basic_os:-linux-gnueabihf}
1027d5e55f73Smrg		;;
102863323ee5Smrg	dpx20-unknown | dpx20-bull)
102963323ee5Smrg		cpu=rs6000
103063323ee5Smrg		vendor=bull
103163323ee5Smrg		basic_os=${basic_os:-bosx}
1032c7484f1fSmrg		;;
103363323ee5Smrg
103463323ee5Smrg	# Here we normalize CPU types irrespective of the vendor
103563323ee5Smrg	amd64-*)
103663323ee5Smrg		cpu=x86_64
1037c7484f1fSmrg		;;
103863323ee5Smrg	blackfin-*)
103963323ee5Smrg		cpu=bfin
104063323ee5Smrg		basic_os=linux
1041c7484f1fSmrg		;;
104263323ee5Smrg	c54x-*)
104363323ee5Smrg		cpu=tic54x
1044c7484f1fSmrg		;;
104563323ee5Smrg	c55x-*)
104663323ee5Smrg		cpu=tic55x
1047c7484f1fSmrg		;;
104863323ee5Smrg	c6x-*)
104963323ee5Smrg		cpu=tic6x
1050c7484f1fSmrg		;;
105163323ee5Smrg	e500v[12]-*)
105263323ee5Smrg		cpu=powerpc
105363323ee5Smrg		basic_os=${basic_os}"spe"
1054c7484f1fSmrg		;;
105563323ee5Smrg	mips3*-*)
105663323ee5Smrg		cpu=mips64
1057c7484f1fSmrg		;;
105863323ee5Smrg	ms1-*)
105963323ee5Smrg		cpu=mt
1060c7484f1fSmrg		;;
106163323ee5Smrg	m68knommu-*)
106263323ee5Smrg		cpu=m68k
106363323ee5Smrg		basic_os=linux
1064c7484f1fSmrg		;;
106563323ee5Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106663323ee5Smrg		cpu=s12z
1067c7484f1fSmrg		;;
106863323ee5Smrg	openrisc-*)
106963323ee5Smrg		cpu=or32
1070c7484f1fSmrg		;;
107163323ee5Smrg	parisc-*)
107263323ee5Smrg		cpu=hppa
107363323ee5Smrg		basic_os=linux
1074c7484f1fSmrg		;;
107563323ee5Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107663323ee5Smrg		cpu=i586
1077c7484f1fSmrg		;;
1078d5e55f73Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
107963323ee5Smrg		cpu=i686
1080c7484f1fSmrg		;;
108163323ee5Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108263323ee5Smrg		cpu=i686
1083c7484f1fSmrg		;;
108463323ee5Smrg	pentium4-*)
108563323ee5Smrg		cpu=i786
1086c7484f1fSmrg		;;
108763323ee5Smrg	pc98-*)
108863323ee5Smrg		cpu=i386
1089c7484f1fSmrg		;;
109063323ee5Smrg	ppc-* | ppcbe-*)
109163323ee5Smrg		cpu=powerpc
1092c7484f1fSmrg		;;
109363323ee5Smrg	ppcle-* | powerpclittle-*)
109463323ee5Smrg		cpu=powerpcle
1095c7484f1fSmrg		;;
109663323ee5Smrg	ppc64-*)
109763323ee5Smrg		cpu=powerpc64
1098e6ecbdaeSmrg		;;
109963323ee5Smrg	ppc64le-* | powerpc64little-*)
110063323ee5Smrg		cpu=powerpc64le
1101c7484f1fSmrg		;;
110263323ee5Smrg	sb1-*)
110363323ee5Smrg		cpu=mipsisa64sb1
1104c7484f1fSmrg		;;
110563323ee5Smrg	sb1el-*)
110663323ee5Smrg		cpu=mipsisa64sb1el
1107baed689fSmrg		;;
110863323ee5Smrg	sh5e[lb]-*)
110963323ee5Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110c7484f1fSmrg		;;
111163323ee5Smrg	spur-*)
111263323ee5Smrg		cpu=spur
1113c7484f1fSmrg		;;
111463323ee5Smrg	strongarm-* | thumb-*)
111563323ee5Smrg		cpu=arm
1116c7484f1fSmrg		;;
111763323ee5Smrg	tx39-*)
111863323ee5Smrg		cpu=mipstx39
1119c7484f1fSmrg		;;
112063323ee5Smrg	tx39el-*)
112163323ee5Smrg		cpu=mipstx39el
1122c7484f1fSmrg		;;
112363323ee5Smrg	x64-*)
112463323ee5Smrg		cpu=x86_64
1125c7484f1fSmrg		;;
112663323ee5Smrg	xscale-* | xscalee[bl]-*)
112763323ee5Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128c7484f1fSmrg		;;
1129d5e55f73Smrg	arm64-* | aarch64le-*)
113063323ee5Smrg		cpu=aarch64
1131c7484f1fSmrg		;;
113263323ee5Smrg
113363323ee5Smrg	# Recognize the canonical CPU Types that limit and/or modify the
113463323ee5Smrg	# company names they are paired with.
113563323ee5Smrg	cr16-*)
113663323ee5Smrg		basic_os=${basic_os:-elf}
1137c7484f1fSmrg		;;
113863323ee5Smrg	crisv32-* | etraxfs*-*)
113963323ee5Smrg		cpu=crisv32
114063323ee5Smrg		vendor=axis
1141c7484f1fSmrg		;;
114263323ee5Smrg	cris-* | etrax*-*)
114363323ee5Smrg		cpu=cris
114463323ee5Smrg		vendor=axis
1145c7484f1fSmrg		;;
114663323ee5Smrg	crx-*)
114763323ee5Smrg		basic_os=${basic_os:-elf}
1148c7484f1fSmrg		;;
114963323ee5Smrg	neo-tandem)
115063323ee5Smrg		cpu=neo
115163323ee5Smrg		vendor=tandem
1152c7484f1fSmrg		;;
115363323ee5Smrg	nse-tandem)
115463323ee5Smrg		cpu=nse
115563323ee5Smrg		vendor=tandem
1156c7484f1fSmrg		;;
115763323ee5Smrg	nsr-tandem)
115863323ee5Smrg		cpu=nsr
115963323ee5Smrg		vendor=tandem
1160c7484f1fSmrg		;;
116163323ee5Smrg	nsv-tandem)
116263323ee5Smrg		cpu=nsv
116363323ee5Smrg		vendor=tandem
1164c7484f1fSmrg		;;
116563323ee5Smrg	nsx-tandem)
116663323ee5Smrg		cpu=nsx
116763323ee5Smrg		vendor=tandem
1168c7484f1fSmrg		;;
116963323ee5Smrg	mipsallegrexel-sony)
117063323ee5Smrg		cpu=mipsallegrexel
117163323ee5Smrg		vendor=sony
1172c7484f1fSmrg		;;
117363323ee5Smrg	tile*-*)
117463323ee5Smrg		basic_os=${basic_os:-linux-gnu}
1175c7484f1fSmrg		;;
117663323ee5Smrg
1177c7484f1fSmrg	*)
117863323ee5Smrg		# Recognize the canonical CPU types that are allowed with any
117963323ee5Smrg		# company name.
118063323ee5Smrg		case $cpu in
118163323ee5Smrg			1750a | 580 \
118263323ee5Smrg			| a29k \
118363323ee5Smrg			| aarch64 | aarch64_be \
118463323ee5Smrg			| abacus \
118563323ee5Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118663323ee5Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118763323ee5Smrg			| alphapca5[67] | alpha64pca5[67] \
118863323ee5Smrg			| am33_2.0 \
118963323ee5Smrg			| amdgcn \
119063323ee5Smrg			| arc | arceb | arc32 | arc64 \
119163323ee5Smrg			| arm | arm[lb]e | arme[lb] | armv* \
119263323ee5Smrg			| avr | avr32 \
119363323ee5Smrg			| asmjs \
119463323ee5Smrg			| ba \
119563323ee5Smrg			| be32 | be64 \
119663323ee5Smrg			| bfin | bpf | bs2000 \
119763323ee5Smrg			| c[123]* | c30 | [cjt]90 | c4x \
119863323ee5Smrg			| c8051 | clipper | craynv | csky | cydra \
119963323ee5Smrg			| d10v | d30v | dlx | dsp16xx \
120063323ee5Smrg			| e2k | elxsi | epiphany \
120163323ee5Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120263323ee5Smrg			| h8300 | h8500 \
120363323ee5Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
120463323ee5Smrg			| hexagon \
120563323ee5Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120663323ee5Smrg			| ip2k | iq2000 \
120763323ee5Smrg			| k1om \
120863323ee5Smrg			| le32 | le64 \
120963323ee5Smrg			| lm32 \
1210d5e55f73Smrg			| loongarch32 | loongarch64 \
121163323ee5Smrg			| m32c | m32r | m32rle \
121263323ee5Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121363323ee5Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121463323ee5Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121563323ee5Smrg			| microblaze | microblazeel \
121663323ee5Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121763323ee5Smrg			| mips16 \
121863323ee5Smrg			| mips64 | mips64eb | mips64el \
121963323ee5Smrg			| mips64octeon | mips64octeonel \
122063323ee5Smrg			| mips64orion | mips64orionel \
122163323ee5Smrg			| mips64r5900 | mips64r5900el \
122263323ee5Smrg			| mips64vr | mips64vrel \
122363323ee5Smrg			| mips64vr4100 | mips64vr4100el \
122463323ee5Smrg			| mips64vr4300 | mips64vr4300el \
122563323ee5Smrg			| mips64vr5000 | mips64vr5000el \
122663323ee5Smrg			| mips64vr5900 | mips64vr5900el \
122763323ee5Smrg			| mipsisa32 | mipsisa32el \
122863323ee5Smrg			| mipsisa32r2 | mipsisa32r2el \
122963323ee5Smrg			| mipsisa32r3 | mipsisa32r3el \
123063323ee5Smrg			| mipsisa32r5 | mipsisa32r5el \
123163323ee5Smrg			| mipsisa32r6 | mipsisa32r6el \
123263323ee5Smrg			| mipsisa64 | mipsisa64el \
123363323ee5Smrg			| mipsisa64r2 | mipsisa64r2el \
123463323ee5Smrg			| mipsisa64r3 | mipsisa64r3el \
123563323ee5Smrg			| mipsisa64r5 | mipsisa64r5el \
123663323ee5Smrg			| mipsisa64r6 | mipsisa64r6el \
123763323ee5Smrg			| mipsisa64sb1 | mipsisa64sb1el \
123863323ee5Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
123963323ee5Smrg			| mipsr5900 | mipsr5900el \
124063323ee5Smrg			| mipstx39 | mipstx39el \
124163323ee5Smrg			| mmix \
124263323ee5Smrg			| mn10200 | mn10300 \
124363323ee5Smrg			| moxie \
124463323ee5Smrg			| mt \
124563323ee5Smrg			| msp430 \
124663323ee5Smrg			| nds32 | nds32le | nds32be \
124763323ee5Smrg			| nfp \
124863323ee5Smrg			| nios | nios2 | nios2eb | nios2el \
124963323ee5Smrg			| none | np1 | ns16k | ns32k | nvptx \
125063323ee5Smrg			| open8 \
125163323ee5Smrg			| or1k* \
125263323ee5Smrg			| or32 \
125363323ee5Smrg			| orion \
125463323ee5Smrg			| picochip \
125563323ee5Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125663323ee5Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125763323ee5Smrg			| pru \
125863323ee5Smrg			| pyramid \
125963323ee5Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
126063323ee5Smrg			| rl78 | romp | rs6000 | rx \
126163323ee5Smrg			| s390 | s390x \
126263323ee5Smrg			| score \
126363323ee5Smrg			| sh | shl \
126463323ee5Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126563323ee5Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126663323ee5Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126763323ee5Smrg			| sparclite \
126863323ee5Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126963323ee5Smrg			| spu \
127063323ee5Smrg			| tahoe \
127163323ee5Smrg			| thumbv7* \
127263323ee5Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
127363323ee5Smrg			| tron \
127463323ee5Smrg			| ubicom32 \
127563323ee5Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127663323ee5Smrg			| vax \
127763323ee5Smrg			| visium \
127863323ee5Smrg			| w65 \
127963323ee5Smrg			| wasm32 | wasm64 \
128063323ee5Smrg			| we32k \
128163323ee5Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
128263323ee5Smrg			| xstormy16 | xtensa* \
128363323ee5Smrg			| ymp \
128463323ee5Smrg			| z8k | z80)
128563323ee5Smrg				;;
128663323ee5Smrg
128763323ee5Smrg			*)
128863323ee5Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128963323ee5Smrg				exit 1
129063323ee5Smrg				;;
129163323ee5Smrg		esac
1292c7484f1fSmrg		;;
1293c7484f1fSmrgesac
1294c7484f1fSmrg
1295c7484f1fSmrg# Here we canonicalize certain aliases for manufacturers.
129663323ee5Smrgcase $vendor in
129763323ee5Smrg	digital*)
129863323ee5Smrg		vendor=dec
1299c7484f1fSmrg		;;
130063323ee5Smrg	commodore*)
130163323ee5Smrg		vendor=cbm
1302c7484f1fSmrg		;;
1303c7484f1fSmrg	*)
1304c7484f1fSmrg		;;
1305c7484f1fSmrgesac
1306c7484f1fSmrg
1307c7484f1fSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308c7484f1fSmrg
130963323ee5Smrgif test x$basic_os != x
1310c7484f1fSmrgthen
131163323ee5Smrg
1312d5e55f73Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
131363323ee5Smrg# set os.
131463323ee5Smrgcase $basic_os in
131563323ee5Smrg	gnu/linux*)
131663323ee5Smrg		kernel=linux
131763323ee5Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131863323ee5Smrg		;;
131963323ee5Smrg	os2-emx)
132063323ee5Smrg		kernel=os2
132163323ee5Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
132263323ee5Smrg		;;
132363323ee5Smrg	nto-qnx*)
132463323ee5Smrg		kernel=nto
132563323ee5Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132663323ee5Smrg		;;
132763323ee5Smrg	*-*)
132863323ee5Smrg		# shellcheck disable=SC2162
132963323ee5Smrg		saved_IFS=$IFS
133063323ee5Smrg		IFS="-" read kernel os <<EOF
133163323ee5Smrg$basic_os
133263323ee5SmrgEOF
133363323ee5Smrg		IFS=$saved_IFS
133463323ee5Smrg		;;
133563323ee5Smrg	# Default OS when just kernel was specified
133663323ee5Smrg	nto*)
133763323ee5Smrg		kernel=nto
133863323ee5Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133963323ee5Smrg		;;
134063323ee5Smrg	linux*)
134163323ee5Smrg		kernel=linux
134263323ee5Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1343baed689fSmrg		;;
1344d5e55f73Smrg	managarm*)
1345d5e55f73Smrg		kernel=managarm
1346d5e55f73Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1347d5e55f73Smrg		;;
134863323ee5Smrg	*)
134963323ee5Smrg		kernel=
135063323ee5Smrg		os=$basic_os
1351c7484f1fSmrg		;;
135263323ee5Smrgesac
135363323ee5Smrg
135463323ee5Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
135563323ee5Smrg# etc.)
135663323ee5Smrgcase $os in
135763323ee5Smrg	# First match some system type aliases that might get confused
135863323ee5Smrg	# with valid system types.
135963323ee5Smrg	# solaris* is a basic system type, with this one exception.
136063323ee5Smrg	auroraux)
136163323ee5Smrg		os=auroraux
1362c7484f1fSmrg		;;
136363323ee5Smrg	bluegene*)
136463323ee5Smrg		os=cnk
1365c7484f1fSmrg		;;
136663323ee5Smrg	solaris1 | solaris1.*)
136763323ee5Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368c7484f1fSmrg		;;
136963323ee5Smrg	solaris)
137063323ee5Smrg		os=solaris2
1371c7484f1fSmrg		;;
137263323ee5Smrg	unixware*)
137363323ee5Smrg		os=sysv4.2uw
1374c7484f1fSmrg		;;
137563323ee5Smrg	# es1800 is here to avoid being matched by es* (a different OS)
137663323ee5Smrg	es1800*)
137763323ee5Smrg		os=ose
1378c7484f1fSmrg		;;
137963323ee5Smrg	# Some version numbers need modification
138063323ee5Smrg	chorusos*)
138163323ee5Smrg		os=chorusos
1382c7484f1fSmrg		;;
138363323ee5Smrg	isc)
138463323ee5Smrg		os=isc2.2
1385c7484f1fSmrg		;;
138663323ee5Smrg	sco6)
138763323ee5Smrg		os=sco5v6
1388c7484f1fSmrg		;;
138963323ee5Smrg	sco5)
139063323ee5Smrg		os=sco3.2v5
1391c7484f1fSmrg		;;
139263323ee5Smrg	sco4)
139363323ee5Smrg		os=sco3.2v4
1394c7484f1fSmrg		;;
139563323ee5Smrg	sco3.2.[4-9]*)
139663323ee5Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397c7484f1fSmrg		;;
139863323ee5Smrg	sco*v* | scout)
139963323ee5Smrg		# Don't match below
1400c7484f1fSmrg		;;
140163323ee5Smrg	sco*)
140263323ee5Smrg		os=sco3.2v2
1403c7484f1fSmrg		;;
140463323ee5Smrg	psos*)
140563323ee5Smrg		os=psos
1406c7484f1fSmrg		;;
140763323ee5Smrg	qnx*)
140863323ee5Smrg		os=qnx
1409c7484f1fSmrg		;;
141063323ee5Smrg	hiux*)
141163323ee5Smrg		os=hiuxwe2
1412c7484f1fSmrg		;;
141363323ee5Smrg	lynx*178)
141463323ee5Smrg		os=lynxos178
1415c7484f1fSmrg		;;
141663323ee5Smrg	lynx*5)
141763323ee5Smrg		os=lynxos5
1418c7484f1fSmrg		;;
141963323ee5Smrg	lynxos*)
142063323ee5Smrg		# don't get caught up in next wildcard
1421c7484f1fSmrg		;;
142263323ee5Smrg	lynx*)
142363323ee5Smrg		os=lynxos
1424c7484f1fSmrg		;;
142563323ee5Smrg	mac[0-9]*)
142663323ee5Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427c7484f1fSmrg		;;
142863323ee5Smrg	opened*)
142963323ee5Smrg		os=openedition
1430c7484f1fSmrg		;;
143163323ee5Smrg	os400*)
143263323ee5Smrg		os=os400
1433c7484f1fSmrg		;;
143463323ee5Smrg	sunos5*)
143563323ee5Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436c7484f1fSmrg		;;
143763323ee5Smrg	sunos6*)
143863323ee5Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439c7484f1fSmrg		;;
144063323ee5Smrg	wince*)
144163323ee5Smrg		os=wince
1442c7484f1fSmrg		;;
144363323ee5Smrg	utek*)
144463323ee5Smrg		os=bsd
1445c7484f1fSmrg		;;
144663323ee5Smrg	dynix*)
144763323ee5Smrg		os=bsd
144863323ee5Smrg		;;
144963323ee5Smrg	acis*)
145063323ee5Smrg		os=aos
1451c7484f1fSmrg		;;
145263323ee5Smrg	atheos*)
145363323ee5Smrg		os=atheos
1454c7484f1fSmrg		;;
145563323ee5Smrg	syllable*)
145663323ee5Smrg		os=syllable
1457c7484f1fSmrg		;;
145863323ee5Smrg	386bsd)
145963323ee5Smrg		os=bsd
1460c7484f1fSmrg		;;
146163323ee5Smrg	ctix* | uts*)
146263323ee5Smrg		os=sysv
1463c7484f1fSmrg		;;
146463323ee5Smrg	nova*)
146563323ee5Smrg		os=rtmk-nova
1466c7484f1fSmrg		;;
146763323ee5Smrg	ns2)
146863323ee5Smrg		os=nextstep2
1469c7484f1fSmrg		;;
147063323ee5Smrg	# Preserve the version number of sinix5.
147163323ee5Smrg	sinix5.*)
147263323ee5Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473c7484f1fSmrg		;;
147463323ee5Smrg	sinix*)
147563323ee5Smrg		os=sysv4
1476c7484f1fSmrg		;;
147763323ee5Smrg	tpf*)
147863323ee5Smrg		os=tpf
1479c7484f1fSmrg		;;
148063323ee5Smrg	triton*)
148163323ee5Smrg		os=sysv3
1482c7484f1fSmrg		;;
148363323ee5Smrg	oss*)
148463323ee5Smrg		os=sysv3
1485c7484f1fSmrg		;;
148663323ee5Smrg	svr4*)
148763323ee5Smrg		os=sysv4
1488c7484f1fSmrg		;;
148963323ee5Smrg	svr3)
149063323ee5Smrg		os=sysv3
1491c7484f1fSmrg		;;
149263323ee5Smrg	sysvr4)
149363323ee5Smrg		os=sysv4
1494c7484f1fSmrg		;;
149563323ee5Smrg	ose*)
149663323ee5Smrg		os=ose
1497baed689fSmrg		;;
149863323ee5Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149963323ee5Smrg		os=mint
1500e6ecbdaeSmrg		;;
150163323ee5Smrg	dicos*)
150263323ee5Smrg		os=dicos
1503ebb1c56dSmrg		;;
150463323ee5Smrg	pikeos*)
150563323ee5Smrg		# Until real need of OS specific support for
150663323ee5Smrg		# particular features comes up, bare metal
150763323ee5Smrg		# configurations are quite functional.
150863323ee5Smrg		case $cpu in
150963323ee5Smrg		    arm*)
151063323ee5Smrg			os=eabi
151163323ee5Smrg			;;
151263323ee5Smrg		    *)
151363323ee5Smrg			os=elf
151463323ee5Smrg			;;
151563323ee5Smrg		esac
1516c7484f1fSmrg		;;
1517c7484f1fSmrg	*)
151863323ee5Smrg		# No normalization, but not necessarily accepted, that comes below.
1519c7484f1fSmrg		;;
1520c7484f1fSmrgesac
152163323ee5Smrg
1522c7484f1fSmrgelse
1523c7484f1fSmrg
1524c7484f1fSmrg# Here we handle the default operating systems that come with various machines.
1525c7484f1fSmrg# The value should be what the vendor currently ships out the door with their
1526c7484f1fSmrg# machine or put another way, the most popular os provided with the machine.
1527c7484f1fSmrg
1528c7484f1fSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529c7484f1fSmrg# "-sun"), then you have to tell the case statement up towards the top
1530c7484f1fSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531c7484f1fSmrg# will signal an error saying that MANUFACTURER isn't an operating
1532c7484f1fSmrg# system, and we'll never get to this point.
1533c7484f1fSmrg
153463323ee5Smrgkernel=
153563323ee5Smrgcase $cpu-$vendor in
1536e6ecbdaeSmrg	score-*)
153763323ee5Smrg		os=elf
1538c7484f1fSmrg		;;
1539e6ecbdaeSmrg	spu-*)
154063323ee5Smrg		os=elf
1541c7484f1fSmrg		;;
1542c7484f1fSmrg	*-acorn)
154363323ee5Smrg		os=riscix1.2
1544c7484f1fSmrg		;;
1545c7484f1fSmrg	arm*-rebel)
154663323ee5Smrg		kernel=linux
154763323ee5Smrg		os=gnu
1548c7484f1fSmrg		;;
1549c7484f1fSmrg	arm*-semi)
155063323ee5Smrg		os=aout
1551c7484f1fSmrg		;;
1552e6ecbdaeSmrg	c4x-* | tic4x-*)
155363323ee5Smrg		os=coff
1554e6ecbdaeSmrg		;;
1555ebb1c56dSmrg	c8051-*)
155663323ee5Smrg		os=elf
155763323ee5Smrg		;;
155863323ee5Smrg	clipper-intergraph)
155963323ee5Smrg		os=clix
1560ebb1c56dSmrg		;;
1561e6ecbdaeSmrg	hexagon-*)
156263323ee5Smrg		os=elf
1563c7484f1fSmrg		;;
1564baed689fSmrg	tic54x-*)
156563323ee5Smrg		os=coff
1566baed689fSmrg		;;
1567baed689fSmrg	tic55x-*)
156863323ee5Smrg		os=coff
1569baed689fSmrg		;;
1570baed689fSmrg	tic6x-*)
157163323ee5Smrg		os=coff
1572baed689fSmrg		;;
1573c7484f1fSmrg	# This must come before the *-dec entry.
1574c7484f1fSmrg	pdp10-*)
157563323ee5Smrg		os=tops20
1576c7484f1fSmrg		;;
1577c7484f1fSmrg	pdp11-*)
157863323ee5Smrg		os=none
1579c7484f1fSmrg		;;
1580c7484f1fSmrg	*-dec | vax-*)
158163323ee5Smrg		os=ultrix4.2
1582c7484f1fSmrg		;;
1583c7484f1fSmrg	m68*-apollo)
158463323ee5Smrg		os=domain
1585c7484f1fSmrg		;;
1586c7484f1fSmrg	i386-sun)
158763323ee5Smrg		os=sunos4.0.2
1588c7484f1fSmrg		;;
1589c7484f1fSmrg	m68000-sun)
159063323ee5Smrg		os=sunos3
1591c7484f1fSmrg		;;
1592c7484f1fSmrg	m68*-cisco)
159363323ee5Smrg		os=aout
1594c7484f1fSmrg		;;
1595e6ecbdaeSmrg	mep-*)
159663323ee5Smrg		os=elf
1597baed689fSmrg		;;
1598c7484f1fSmrg	mips*-cisco)
159963323ee5Smrg		os=elf
1600c7484f1fSmrg		;;
1601c7484f1fSmrg	mips*-*)
160263323ee5Smrg		os=elf
1603c7484f1fSmrg		;;
1604c7484f1fSmrg	or32-*)
160563323ee5Smrg		os=coff
1606c7484f1fSmrg		;;
1607c7484f1fSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
160863323ee5Smrg		os=sysv3
1609c7484f1fSmrg		;;
1610c7484f1fSmrg	sparc-* | *-sun)
161163323ee5Smrg		os=sunos4.1.1
1612c7484f1fSmrg		;;
161363323ee5Smrg	pru-*)
161463323ee5Smrg		os=elf
1615c7484f1fSmrg		;;
161663323ee5Smrg	*-be)
161763323ee5Smrg		os=beos
1618c7484f1fSmrg		;;
1619c7484f1fSmrg	*-ibm)
162063323ee5Smrg		os=aix
1621c7484f1fSmrg		;;
1622e6ecbdaeSmrg	*-knuth)
162363323ee5Smrg		os=mmixware
1624c7484f1fSmrg		;;
1625c7484f1fSmrg	*-wec)
162663323ee5Smrg		os=proelf
1627c7484f1fSmrg		;;
1628c7484f1fSmrg	*-winbond)
162963323ee5Smrg		os=proelf
1630c7484f1fSmrg		;;
1631c7484f1fSmrg	*-oki)
163263323ee5Smrg		os=proelf
1633c7484f1fSmrg		;;
1634c7484f1fSmrg	*-hp)
163563323ee5Smrg		os=hpux
1636c7484f1fSmrg		;;
1637c7484f1fSmrg	*-hitachi)
163863323ee5Smrg		os=hiux
1639c7484f1fSmrg		;;
1640c7484f1fSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
164163323ee5Smrg		os=sysv
1642c7484f1fSmrg		;;
1643c7484f1fSmrg	*-cbm)
164463323ee5Smrg		os=amigaos
1645c7484f1fSmrg		;;
1646c7484f1fSmrg	*-dg)
164763323ee5Smrg		os=dgux
1648c7484f1fSmrg		;;
1649c7484f1fSmrg	*-dolphin)
165063323ee5Smrg		os=sysv3
1651c7484f1fSmrg		;;
1652c7484f1fSmrg	m68k-ccur)
165363323ee5Smrg		os=rtu
1654c7484f1fSmrg		;;
1655c7484f1fSmrg	m88k-omron*)
165663323ee5Smrg		os=luna
1657c7484f1fSmrg		;;
165863323ee5Smrg	*-next)
165963323ee5Smrg		os=nextstep
1660c7484f1fSmrg		;;
1661c7484f1fSmrg	*-sequent)
166263323ee5Smrg		os=ptx
1663c7484f1fSmrg		;;
1664c7484f1fSmrg	*-crds)
166563323ee5Smrg		os=unos
1666c7484f1fSmrg		;;
1667c7484f1fSmrg	*-ns)
166863323ee5Smrg		os=genix
1669c7484f1fSmrg		;;
1670c7484f1fSmrg	i370-*)
167163323ee5Smrg		os=mvs
1672c7484f1fSmrg		;;
1673c7484f1fSmrg	*-gould)
167463323ee5Smrg		os=sysv
1675c7484f1fSmrg		;;
1676c7484f1fSmrg	*-highlevel)
167763323ee5Smrg		os=bsd
1678c7484f1fSmrg		;;
1679c7484f1fSmrg	*-encore)
168063323ee5Smrg		os=bsd
1681c7484f1fSmrg		;;
1682c7484f1fSmrg	*-sgi)
168363323ee5Smrg		os=irix
1684c7484f1fSmrg		;;
1685c7484f1fSmrg	*-siemens)
168663323ee5Smrg		os=sysv4
1687c7484f1fSmrg		;;
1688c7484f1fSmrg	*-masscomp)
168963323ee5Smrg		os=rtu
1690c7484f1fSmrg		;;
1691c7484f1fSmrg	f30[01]-fujitsu | f700-fujitsu)
169263323ee5Smrg		os=uxpv
1693c7484f1fSmrg		;;
1694c7484f1fSmrg	*-rom68k)
169563323ee5Smrg		os=coff
1696c7484f1fSmrg		;;
1697c7484f1fSmrg	*-*bug)
169863323ee5Smrg		os=coff
1699c7484f1fSmrg		;;
1700c7484f1fSmrg	*-apple)
170163323ee5Smrg		os=macos
1702c7484f1fSmrg		;;
1703c7484f1fSmrg	*-atari*)
170463323ee5Smrg		os=mint
170563323ee5Smrg		;;
170663323ee5Smrg	*-wrs)
170763323ee5Smrg		os=vxworks
1708c7484f1fSmrg		;;
1709c7484f1fSmrg	*)
171063323ee5Smrg		os=none
1711c7484f1fSmrg		;;
1712c7484f1fSmrgesac
171363323ee5Smrg
1714c7484f1fSmrgfi
1715c7484f1fSmrg
171663323ee5Smrg# Now, validate our (potentially fixed-up) OS.
171763323ee5Smrgcase $os in
171863323ee5Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
171963323ee5Smrg	musl* | newlib* | relibc* | uclibc*)
172063323ee5Smrg		;;
172163323ee5Smrg	# Likewise for "kernel-abi"
172263323ee5Smrg	eabi* | gnueabi*)
172363323ee5Smrg		;;
172463323ee5Smrg	# VxWorks passes extra cpu info in the 4th filed.
172563323ee5Smrg	simlinux | simwindows | spe)
172663323ee5Smrg		;;
172763323ee5Smrg	# Now accept the basic system types.
172863323ee5Smrg	# The portable systems comes first.
172963323ee5Smrg	# Each alternative MUST end in a * to match a version number.
173063323ee5Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
173163323ee5Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
173263323ee5Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
173363323ee5Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
173463323ee5Smrg	     | hiux* | abug | nacl* | netware* | windows* \
173563323ee5Smrg	     | os9* | macos* | osx* | ios* \
173663323ee5Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
173763323ee5Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
173863323ee5Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173963323ee5Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
174063323ee5Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
174163323ee5Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
174263323ee5Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
174363323ee5Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
174463323ee5Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
174563323ee5Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
174663323ee5Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
174763323ee5Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
174863323ee5Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174963323ee5Smrg	     | midipix* | mingw32* | mingw64* | mint* \
175063323ee5Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
175163323ee5Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
175263323ee5Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
175363323ee5Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
175463323ee5Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
175563323ee5Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
175663323ee5Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
175763323ee5Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
175863323ee5Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175963323ee5Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1760d5e55f73Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761d5e55f73Smrg	     | fiwix* | mlibc* )
176263323ee5Smrg		;;
176363323ee5Smrg	# This one is extra strict with allowed versions
176463323ee5Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
176563323ee5Smrg		# Don't forget version if it is 3.2v4 or newer.
176663323ee5Smrg		;;
176763323ee5Smrg	none)
176863323ee5Smrg		;;
1769d5e55f73Smrg	kernel* )
1770d5e55f73Smrg		# Restricted further below
1771d5e55f73Smrg		;;
177263323ee5Smrg	*)
177363323ee5Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
177463323ee5Smrg		exit 1
177563323ee5Smrg		;;
177663323ee5Smrgesac
177763323ee5Smrg
177863323ee5Smrg# As a final step for OS-related things, validate the OS-kernel combination
177963323ee5Smrg# (given a valid OS), if there is a kernel.
178063323ee5Smrgcase $kernel-$os in
178163323ee5Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782d5e55f73Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
178363323ee5Smrg		;;
178463323ee5Smrg	uclinux-uclibc* )
178563323ee5Smrg		;;
1786d5e55f73Smrg	managarm-mlibc* | managarm-kernel* )
1787d5e55f73Smrg		;;
1788d5e55f73Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
178963323ee5Smrg		# These are just libc implementations, not actual OSes, and thus
179063323ee5Smrg		# require a kernel.
179163323ee5Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
179263323ee5Smrg		exit 1
179363323ee5Smrg		;;
1794d5e55f73Smrg	-kernel* )
1795d5e55f73Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
1796d5e55f73Smrg		exit 1
1797d5e55f73Smrg		;;
1798d5e55f73Smrg	*-kernel* )
1799d5e55f73Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
1800d5e55f73Smrg		exit 1
1801d5e55f73Smrg		;;
180263323ee5Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
180363323ee5Smrg		;;
180463323ee5Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
180563323ee5Smrg		;;
180663323ee5Smrg	nto-qnx*)
180763323ee5Smrg		;;
180863323ee5Smrg	os2-emx)
180963323ee5Smrg		;;
181063323ee5Smrg	*-eabi* | *-gnueabi*)
181163323ee5Smrg		;;
181263323ee5Smrg	-*)
181363323ee5Smrg		# Blank kernel with real OS is always fine.
181463323ee5Smrg		;;
181563323ee5Smrg	*-*)
181663323ee5Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
181763323ee5Smrg		exit 1
181863323ee5Smrg		;;
181963323ee5Smrgesac
182063323ee5Smrg
1821c7484f1fSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1822c7484f1fSmrg# manufacturer.  We pick the logical manufacturer.
182363323ee5Smrgcase $vendor in
182463323ee5Smrg	unknown)
182563323ee5Smrg		case $cpu-$os in
182663323ee5Smrg			*-riscix*)
1827c7484f1fSmrg				vendor=acorn
1828c7484f1fSmrg				;;
182963323ee5Smrg			*-sunos*)
1830c7484f1fSmrg				vendor=sun
1831c7484f1fSmrg				;;
183263323ee5Smrg			*-cnk* | *-aix*)
1833c7484f1fSmrg				vendor=ibm
1834c7484f1fSmrg				;;
183563323ee5Smrg			*-beos*)
1836c7484f1fSmrg				vendor=be
1837c7484f1fSmrg				;;
183863323ee5Smrg			*-hpux*)
1839c7484f1fSmrg				vendor=hp
1840c7484f1fSmrg				;;
184163323ee5Smrg			*-mpeix*)
1842c7484f1fSmrg				vendor=hp
1843c7484f1fSmrg				;;
184463323ee5Smrg			*-hiux*)
1845c7484f1fSmrg				vendor=hitachi
1846c7484f1fSmrg				;;
184763323ee5Smrg			*-unos*)
1848c7484f1fSmrg				vendor=crds
1849c7484f1fSmrg				;;
185063323ee5Smrg			*-dgux*)
1851c7484f1fSmrg				vendor=dg
1852c7484f1fSmrg				;;
185363323ee5Smrg			*-luna*)
1854c7484f1fSmrg				vendor=omron
1855c7484f1fSmrg				;;
185663323ee5Smrg			*-genix*)
1857c7484f1fSmrg				vendor=ns
1858c7484f1fSmrg				;;
185963323ee5Smrg			*-clix*)
186063323ee5Smrg				vendor=intergraph
186163323ee5Smrg				;;
186263323ee5Smrg			*-mvs* | *-opened*)
186363323ee5Smrg				vendor=ibm
186463323ee5Smrg				;;
186563323ee5Smrg			*-os400*)
1866c7484f1fSmrg				vendor=ibm
1867c7484f1fSmrg				;;
186863323ee5Smrg			s390-* | s390x-*)
1869c7484f1fSmrg				vendor=ibm
1870c7484f1fSmrg				;;
187163323ee5Smrg			*-ptx*)
1872c7484f1fSmrg				vendor=sequent
1873c7484f1fSmrg				;;
187463323ee5Smrg			*-tpf*)
1875c7484f1fSmrg				vendor=ibm
1876c7484f1fSmrg				;;
187763323ee5Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1878c7484f1fSmrg				vendor=wrs
1879c7484f1fSmrg				;;
188063323ee5Smrg			*-aux*)
1881c7484f1fSmrg				vendor=apple
1882c7484f1fSmrg				;;
188363323ee5Smrg			*-hms*)
1884c7484f1fSmrg				vendor=hitachi
1885c7484f1fSmrg				;;
188663323ee5Smrg			*-mpw* | *-macos*)
1887c7484f1fSmrg				vendor=apple
1888c7484f1fSmrg				;;
188963323ee5Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890c7484f1fSmrg				vendor=atari
1891c7484f1fSmrg				;;
189263323ee5Smrg			*-vos*)
1893c7484f1fSmrg				vendor=stratus
1894c7484f1fSmrg				;;
1895c7484f1fSmrg		esac
1896c7484f1fSmrg		;;
1897c7484f1fSmrgesac
1898c7484f1fSmrg
189963323ee5Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900c7484f1fSmrgexit
1901c7484f1fSmrg
1902c7484f1fSmrg# Local variables:
190363323ee5Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904c7484f1fSmrg# time-stamp-start: "timestamp='"
1905c7484f1fSmrg# time-stamp-format: "%:y-%02m-%02d"
1906c7484f1fSmrg# time-stamp-end: "'"
1907c7484f1fSmrg# End:
1908