config.sub revision 95b7a5c8
127702724Smrg#! /bin/sh
227702724Smrg# Configuration validation subroutine script.
395b7a5c8Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
427702724Smrg
595b7a5c8Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
695b7a5c8Smrg
795b7a5c8Smrgtimestamp='2021-08-14'
827702724Smrg
9313a12fdSmrg# This file is free software; you can redistribute it and/or modify it
10313a12fdSmrg# under the terms of the GNU General Public License as published by
11313a12fdSmrg# the Free Software Foundation; either version 3 of the License, or
1227702724Smrg# (at your option) any later version.
1327702724Smrg#
14313a12fdSmrg# This program is distributed in the hope that it will be useful, but
15313a12fdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16313a12fdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17313a12fdSmrg# General Public License for more details.
1827702724Smrg#
1927702724Smrg# You should have received a copy of the GNU General Public License
207cea3689Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2127702724Smrg#
2227702724Smrg# As a special exception to the GNU General Public License, if you
2327702724Smrg# distribute this file as part of a program that contains a
2427702724Smrg# configuration script generated by Autoconf, you may include it under
25313a12fdSmrg# the same distribution terms that you use for the rest of that
26313a12fdSmrg# program.  This Exception is an additional permission under section 7
27313a12fdSmrg# of the GNU General Public License, version 3 ("GPLv3").
2827702724Smrg
2927702724Smrg
307cea3689Smrg# Please send patches to <config-patches@gnu.org>.
3127702724Smrg#
3227702724Smrg# Configuration subroutine to validate and canonicalize a configuration type.
3327702724Smrg# Supply the specified configuration type as an argument.
3427702724Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
3527702724Smrg# Otherwise, we print the canonical config type on stdout and succeed.
3627702724Smrg
3700084f2cSmrg# You can get the latest version of this script from:
3895b7a5c8Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3900084f2cSmrg
4027702724Smrg# This file is supposed to be the same for all GNU packages
4127702724Smrg# and recognize all the CPU types, system types and aliases
4227702724Smrg# that are meaningful with *any* GNU software.
4327702724Smrg# Each package is responsible for reporting which valid configurations
4427702724Smrg# it does not support.  The user should be able to distinguish
4527702724Smrg# a failure to support a valid configuration from a meaningless
4627702724Smrg# configuration.
4727702724Smrg
4827702724Smrg# The goal of this file is to map all the various variations of a given
4927702724Smrg# machine specification into a single specification in the form:
5027702724Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
5127702724Smrg# or in some cases, the newer four-part form:
5227702724Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
5327702724Smrg# It is wrong to echo any other type of specification.
5427702724Smrg
5595b7a5c8Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
5695b7a5c8Smrg# about features and limitations of the classic Bourne shell that were
5795b7a5c8Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
5895b7a5c8Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5995b7a5c8Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6095b7a5c8Smrg# have a pre-POSIX /bin/sh.
6195b7a5c8Smrg
6227702724Smrgme=`echo "$0" | sed -e 's,.*/,,'`
6327702724Smrg
6427702724Smrgusage="\
657cea3689SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
6627702724Smrg
6727702724SmrgCanonicalize a configuration name.
6827702724Smrg
697cea3689SmrgOptions:
7027702724Smrg  -h, --help         print this help, then exit
7127702724Smrg  -t, --time-stamp   print date of last modification, then exit
7227702724Smrg  -v, --version      print version number, then exit
7327702724Smrg
7427702724SmrgReport bugs and patches to <config-patches@gnu.org>."
7527702724Smrg
7627702724Smrgversion="\
7727702724SmrgGNU config.sub ($timestamp)
7827702724Smrg
7995b7a5c8SmrgCopyright 1992-2021 Free Software Foundation, Inc.
8027702724Smrg
8127702724SmrgThis is free software; see the source for copying conditions.  There is NO
8227702724Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
8327702724Smrg
8427702724Smrghelp="
8527702724SmrgTry \`$me --help' for more information."
8627702724Smrg
8727702724Smrg# Parse command line
8827702724Smrgwhile test $# -gt 0 ; do
8927702724Smrg  case $1 in
9027702724Smrg    --time-stamp | --time* | -t )
9127702724Smrg       echo "$timestamp" ; exit ;;
9227702724Smrg    --version | -v )
9327702724Smrg       echo "$version" ; exit ;;
9427702724Smrg    --help | --h* | -h )
9527702724Smrg       echo "$usage"; exit ;;
9627702724Smrg    -- )     # Stop option processing
9727702724Smrg       shift; break ;;
9827702724Smrg    - )	# Use stdin as input.
9927702724Smrg       break ;;
10027702724Smrg    -* )
10195b7a5c8Smrg       echo "$me: invalid option $1$help" >&2
10227702724Smrg       exit 1 ;;
10327702724Smrg
10427702724Smrg    *local*)
10527702724Smrg       # First pass through any local machine types.
1067cea3689Smrg       echo "$1"
10727702724Smrg       exit ;;
10827702724Smrg
10927702724Smrg    * )
11027702724Smrg       break ;;
11127702724Smrg  esac
11227702724Smrgdone
11327702724Smrg
11427702724Smrgcase $# in
11527702724Smrg 0) echo "$me: missing argument$help" >&2
11627702724Smrg    exit 1;;
11727702724Smrg 1) ;;
11827702724Smrg *) echo "$me: too many arguments$help" >&2
11927702724Smrg    exit 1;;
12027702724Smrgesac
12127702724Smrg
12295b7a5c8Smrg# Split fields of configuration type
12395b7a5c8Smrg# shellcheck disable=SC2162
12495b7a5c8Smrgsaved_IFS=$IFS
12595b7a5c8SmrgIFS="-" read field1 field2 field3 field4 <<EOF
12695b7a5c8Smrg$1
12795b7a5c8SmrgEOF
12895b7a5c8SmrgIFS=$saved_IFS
12927702724Smrg
13095b7a5c8Smrg# Separate into logical components for further validation
13195b7a5c8Smrgcase $1 in
13295b7a5c8Smrg	*-*-*-*-*)
13395b7a5c8Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
13495b7a5c8Smrg		exit 1
135313a12fdSmrg		;;
13695b7a5c8Smrg	*-*-*-*)
13795b7a5c8Smrg		basic_machine=$field1-$field2
13895b7a5c8Smrg		basic_os=$field3-$field4
13927702724Smrg		;;
14095b7a5c8Smrg	*-*-*)
14195b7a5c8Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14295b7a5c8Smrg		# parts
14395b7a5c8Smrg		maybe_os=$field2-$field3
14495b7a5c8Smrg		case $maybe_os in
14595b7a5c8Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
14695b7a5c8Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14795b7a5c8Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14895b7a5c8Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
14995b7a5c8Smrg				basic_machine=$field1
15095b7a5c8Smrg				basic_os=$maybe_os
15195b7a5c8Smrg				;;
15295b7a5c8Smrg			android-linux)
15395b7a5c8Smrg				basic_machine=$field1-unknown
15495b7a5c8Smrg				basic_os=linux-android
15595b7a5c8Smrg				;;
15695b7a5c8Smrg			*)
15795b7a5c8Smrg				basic_machine=$field1-$field2
15895b7a5c8Smrg				basic_os=$field3
15995b7a5c8Smrg				;;
16095b7a5c8Smrg		esac
16127702724Smrg		;;
16295b7a5c8Smrg	*-*)
16395b7a5c8Smrg		# A lone config we happen to match not fitting any pattern
16495b7a5c8Smrg		case $field1-$field2 in
16595b7a5c8Smrg			decstation-3100)
16695b7a5c8Smrg				basic_machine=mips-dec
16795b7a5c8Smrg				basic_os=
16895b7a5c8Smrg				;;
16995b7a5c8Smrg			*-*)
17095b7a5c8Smrg				# Second component is usually, but not always the OS
17195b7a5c8Smrg				case $field2 in
17295b7a5c8Smrg					# Prevent following clause from handling this valid os
17395b7a5c8Smrg					sun*os*)
17495b7a5c8Smrg						basic_machine=$field1
17595b7a5c8Smrg						basic_os=$field2
17695b7a5c8Smrg						;;
17795b7a5c8Smrg					zephyr*)
17895b7a5c8Smrg						basic_machine=$field1-unknown
17995b7a5c8Smrg						basic_os=$field2
18095b7a5c8Smrg						;;
18195b7a5c8Smrg					# Manufacturers
18295b7a5c8Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18395b7a5c8Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18495b7a5c8Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18595b7a5c8Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18695b7a5c8Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18795b7a5c8Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18895b7a5c8Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18995b7a5c8Smrg					| microblaze* | sim | cisco \
19095b7a5c8Smrg					| oki | wec | wrs | winbond)
19195b7a5c8Smrg						basic_machine=$field1-$field2
19295b7a5c8Smrg						basic_os=
19395b7a5c8Smrg						;;
19495b7a5c8Smrg					*)
19595b7a5c8Smrg						basic_machine=$field1
19695b7a5c8Smrg						basic_os=$field2
19795b7a5c8Smrg						;;
19895b7a5c8Smrg				esac
19995b7a5c8Smrg			;;
20095b7a5c8Smrg		esac
20127702724Smrg		;;
20295b7a5c8Smrg	*)
20395b7a5c8Smrg		# Convert single-component short-hands not valid as part of
20495b7a5c8Smrg		# multi-component configurations.
20595b7a5c8Smrg		case $field1 in
20695b7a5c8Smrg			386bsd)
20795b7a5c8Smrg				basic_machine=i386-pc
20895b7a5c8Smrg				basic_os=bsd
20995b7a5c8Smrg				;;
21095b7a5c8Smrg			a29khif)
21195b7a5c8Smrg				basic_machine=a29k-amd
21295b7a5c8Smrg				basic_os=udi
21395b7a5c8Smrg				;;
21495b7a5c8Smrg			adobe68k)
21595b7a5c8Smrg				basic_machine=m68010-adobe
21695b7a5c8Smrg				basic_os=scout
21795b7a5c8Smrg				;;
21895b7a5c8Smrg			alliant)
21995b7a5c8Smrg				basic_machine=fx80-alliant
22095b7a5c8Smrg				basic_os=
22195b7a5c8Smrg				;;
22295b7a5c8Smrg			altos | altos3068)
22395b7a5c8Smrg				basic_machine=m68k-altos
22495b7a5c8Smrg				basic_os=
22595b7a5c8Smrg				;;
22695b7a5c8Smrg			am29k)
22795b7a5c8Smrg				basic_machine=a29k-none
22895b7a5c8Smrg				basic_os=bsd
22995b7a5c8Smrg				;;
23095b7a5c8Smrg			amdahl)
23195b7a5c8Smrg				basic_machine=580-amdahl
23295b7a5c8Smrg				basic_os=sysv
23395b7a5c8Smrg				;;
23495b7a5c8Smrg			amiga)
23595b7a5c8Smrg				basic_machine=m68k-unknown
23695b7a5c8Smrg				basic_os=
23795b7a5c8Smrg				;;
23895b7a5c8Smrg			amigaos | amigados)
23995b7a5c8Smrg				basic_machine=m68k-unknown
24095b7a5c8Smrg				basic_os=amigaos
24195b7a5c8Smrg				;;
24295b7a5c8Smrg			amigaunix | amix)
24395b7a5c8Smrg				basic_machine=m68k-unknown
24495b7a5c8Smrg				basic_os=sysv4
24595b7a5c8Smrg				;;
24695b7a5c8Smrg			apollo68)
24795b7a5c8Smrg				basic_machine=m68k-apollo
24895b7a5c8Smrg				basic_os=sysv
24995b7a5c8Smrg				;;
25095b7a5c8Smrg			apollo68bsd)
25195b7a5c8Smrg				basic_machine=m68k-apollo
25295b7a5c8Smrg				basic_os=bsd
25395b7a5c8Smrg				;;
25495b7a5c8Smrg			aros)
25595b7a5c8Smrg				basic_machine=i386-pc
25695b7a5c8Smrg				basic_os=aros
25795b7a5c8Smrg				;;
25895b7a5c8Smrg			aux)
25995b7a5c8Smrg				basic_machine=m68k-apple
26095b7a5c8Smrg				basic_os=aux
26195b7a5c8Smrg				;;
26295b7a5c8Smrg			balance)
26395b7a5c8Smrg				basic_machine=ns32k-sequent
26495b7a5c8Smrg				basic_os=dynix
26595b7a5c8Smrg				;;
26695b7a5c8Smrg			blackfin)
26795b7a5c8Smrg				basic_machine=bfin-unknown
26895b7a5c8Smrg				basic_os=linux
26995b7a5c8Smrg				;;
27095b7a5c8Smrg			cegcc)
27195b7a5c8Smrg				basic_machine=arm-unknown
27295b7a5c8Smrg				basic_os=cegcc
27395b7a5c8Smrg				;;
27495b7a5c8Smrg			convex-c1)
27595b7a5c8Smrg				basic_machine=c1-convex
27695b7a5c8Smrg				basic_os=bsd
27795b7a5c8Smrg				;;
27895b7a5c8Smrg			convex-c2)
27995b7a5c8Smrg				basic_machine=c2-convex
28095b7a5c8Smrg				basic_os=bsd
28195b7a5c8Smrg				;;
28295b7a5c8Smrg			convex-c32)
28395b7a5c8Smrg				basic_machine=c32-convex
28495b7a5c8Smrg				basic_os=bsd
28595b7a5c8Smrg				;;
28695b7a5c8Smrg			convex-c34)
28795b7a5c8Smrg				basic_machine=c34-convex
28895b7a5c8Smrg				basic_os=bsd
28995b7a5c8Smrg				;;
29095b7a5c8Smrg			convex-c38)
29195b7a5c8Smrg				basic_machine=c38-convex
29295b7a5c8Smrg				basic_os=bsd
29395b7a5c8Smrg				;;
29495b7a5c8Smrg			cray)
29595b7a5c8Smrg				basic_machine=j90-cray
29695b7a5c8Smrg				basic_os=unicos
29795b7a5c8Smrg				;;
29895b7a5c8Smrg			crds | unos)
29995b7a5c8Smrg				basic_machine=m68k-crds
30095b7a5c8Smrg				basic_os=
30195b7a5c8Smrg				;;
30295b7a5c8Smrg			da30)
30395b7a5c8Smrg				basic_machine=m68k-da30
30495b7a5c8Smrg				basic_os=
30595b7a5c8Smrg				;;
30695b7a5c8Smrg			decstation | pmax | pmin | dec3100 | decstatn)
30795b7a5c8Smrg				basic_machine=mips-dec
30895b7a5c8Smrg				basic_os=
30995b7a5c8Smrg				;;
31095b7a5c8Smrg			delta88)
31195b7a5c8Smrg				basic_machine=m88k-motorola
31295b7a5c8Smrg				basic_os=sysv3
31395b7a5c8Smrg				;;
31495b7a5c8Smrg			dicos)
31595b7a5c8Smrg				basic_machine=i686-pc
31695b7a5c8Smrg				basic_os=dicos
31795b7a5c8Smrg				;;
31895b7a5c8Smrg			djgpp)
31995b7a5c8Smrg				basic_machine=i586-pc
32095b7a5c8Smrg				basic_os=msdosdjgpp
32195b7a5c8Smrg				;;
32295b7a5c8Smrg			ebmon29k)
32395b7a5c8Smrg				basic_machine=a29k-amd
32495b7a5c8Smrg				basic_os=ebmon
32595b7a5c8Smrg				;;
32695b7a5c8Smrg			es1800 | OSE68k | ose68k | ose | OSE)
32795b7a5c8Smrg				basic_machine=m68k-ericsson
32895b7a5c8Smrg				basic_os=ose
32995b7a5c8Smrg				;;
33095b7a5c8Smrg			gmicro)
33195b7a5c8Smrg				basic_machine=tron-gmicro
33295b7a5c8Smrg				basic_os=sysv
33395b7a5c8Smrg				;;
33495b7a5c8Smrg			go32)
33595b7a5c8Smrg				basic_machine=i386-pc
33695b7a5c8Smrg				basic_os=go32
33795b7a5c8Smrg				;;
33895b7a5c8Smrg			h8300hms)
33995b7a5c8Smrg				basic_machine=h8300-hitachi
34095b7a5c8Smrg				basic_os=hms
34195b7a5c8Smrg				;;
34295b7a5c8Smrg			h8300xray)
34395b7a5c8Smrg				basic_machine=h8300-hitachi
34495b7a5c8Smrg				basic_os=xray
34595b7a5c8Smrg				;;
34695b7a5c8Smrg			h8500hms)
34795b7a5c8Smrg				basic_machine=h8500-hitachi
34895b7a5c8Smrg				basic_os=hms
34995b7a5c8Smrg				;;
35095b7a5c8Smrg			harris)
35195b7a5c8Smrg				basic_machine=m88k-harris
35295b7a5c8Smrg				basic_os=sysv3
35395b7a5c8Smrg				;;
35495b7a5c8Smrg			hp300 | hp300hpux)
35595b7a5c8Smrg				basic_machine=m68k-hp
35695b7a5c8Smrg				basic_os=hpux
35795b7a5c8Smrg				;;
35895b7a5c8Smrg			hp300bsd)
35995b7a5c8Smrg				basic_machine=m68k-hp
36095b7a5c8Smrg				basic_os=bsd
36195b7a5c8Smrg				;;
36295b7a5c8Smrg			hppaosf)
36395b7a5c8Smrg				basic_machine=hppa1.1-hp
36495b7a5c8Smrg				basic_os=osf
36595b7a5c8Smrg				;;
36695b7a5c8Smrg			hppro)
36795b7a5c8Smrg				basic_machine=hppa1.1-hp
36895b7a5c8Smrg				basic_os=proelf
36995b7a5c8Smrg				;;
37095b7a5c8Smrg			i386mach)
37195b7a5c8Smrg				basic_machine=i386-mach
37295b7a5c8Smrg				basic_os=mach
37395b7a5c8Smrg				;;
37495b7a5c8Smrg			isi68 | isi)
37595b7a5c8Smrg				basic_machine=m68k-isi
37695b7a5c8Smrg				basic_os=sysv
37795b7a5c8Smrg				;;
37895b7a5c8Smrg			m68knommu)
37995b7a5c8Smrg				basic_machine=m68k-unknown
38095b7a5c8Smrg				basic_os=linux
38195b7a5c8Smrg				;;
38295b7a5c8Smrg			magnum | m3230)
38395b7a5c8Smrg				basic_machine=mips-mips
38495b7a5c8Smrg				basic_os=sysv
38595b7a5c8Smrg				;;
38695b7a5c8Smrg			merlin)
38795b7a5c8Smrg				basic_machine=ns32k-utek
38895b7a5c8Smrg				basic_os=sysv
38995b7a5c8Smrg				;;
39095b7a5c8Smrg			mingw64)
39195b7a5c8Smrg				basic_machine=x86_64-pc
39295b7a5c8Smrg				basic_os=mingw64
39395b7a5c8Smrg				;;
39495b7a5c8Smrg			mingw32)
39595b7a5c8Smrg				basic_machine=i686-pc
39695b7a5c8Smrg				basic_os=mingw32
39795b7a5c8Smrg				;;
39895b7a5c8Smrg			mingw32ce)
39995b7a5c8Smrg				basic_machine=arm-unknown
40095b7a5c8Smrg				basic_os=mingw32ce
40195b7a5c8Smrg				;;
40295b7a5c8Smrg			monitor)
40395b7a5c8Smrg				basic_machine=m68k-rom68k
40495b7a5c8Smrg				basic_os=coff
40595b7a5c8Smrg				;;
40695b7a5c8Smrg			morphos)
40795b7a5c8Smrg				basic_machine=powerpc-unknown
40895b7a5c8Smrg				basic_os=morphos
40995b7a5c8Smrg				;;
41095b7a5c8Smrg			moxiebox)
41195b7a5c8Smrg				basic_machine=moxie-unknown
41295b7a5c8Smrg				basic_os=moxiebox
41395b7a5c8Smrg				;;
41495b7a5c8Smrg			msdos)
41595b7a5c8Smrg				basic_machine=i386-pc
41695b7a5c8Smrg				basic_os=msdos
41795b7a5c8Smrg				;;
41895b7a5c8Smrg			msys)
41995b7a5c8Smrg				basic_machine=i686-pc
42095b7a5c8Smrg				basic_os=msys
42195b7a5c8Smrg				;;
42295b7a5c8Smrg			mvs)
42395b7a5c8Smrg				basic_machine=i370-ibm
42495b7a5c8Smrg				basic_os=mvs
42595b7a5c8Smrg				;;
42695b7a5c8Smrg			nacl)
42795b7a5c8Smrg				basic_machine=le32-unknown
42895b7a5c8Smrg				basic_os=nacl
42995b7a5c8Smrg				;;
43095b7a5c8Smrg			ncr3000)
43195b7a5c8Smrg				basic_machine=i486-ncr
43295b7a5c8Smrg				basic_os=sysv4
43395b7a5c8Smrg				;;
43495b7a5c8Smrg			netbsd386)
43595b7a5c8Smrg				basic_machine=i386-pc
43695b7a5c8Smrg				basic_os=netbsd
43795b7a5c8Smrg				;;
43895b7a5c8Smrg			netwinder)
43995b7a5c8Smrg				basic_machine=armv4l-rebel
44095b7a5c8Smrg				basic_os=linux
44195b7a5c8Smrg				;;
44295b7a5c8Smrg			news | news700 | news800 | news900)
44395b7a5c8Smrg				basic_machine=m68k-sony
44495b7a5c8Smrg				basic_os=newsos
44595b7a5c8Smrg				;;
44695b7a5c8Smrg			news1000)
44795b7a5c8Smrg				basic_machine=m68030-sony
44895b7a5c8Smrg				basic_os=newsos
44995b7a5c8Smrg				;;
45095b7a5c8Smrg			necv70)
45195b7a5c8Smrg				basic_machine=v70-nec
45295b7a5c8Smrg				basic_os=sysv
45395b7a5c8Smrg				;;
45495b7a5c8Smrg			nh3000)
45595b7a5c8Smrg				basic_machine=m68k-harris
45695b7a5c8Smrg				basic_os=cxux
45795b7a5c8Smrg				;;
45895b7a5c8Smrg			nh[45]000)
45995b7a5c8Smrg				basic_machine=m88k-harris
46095b7a5c8Smrg				basic_os=cxux
46195b7a5c8Smrg				;;
46295b7a5c8Smrg			nindy960)
46395b7a5c8Smrg				basic_machine=i960-intel
46495b7a5c8Smrg				basic_os=nindy
46595b7a5c8Smrg				;;
46695b7a5c8Smrg			mon960)
46795b7a5c8Smrg				basic_machine=i960-intel
46895b7a5c8Smrg				basic_os=mon960
46995b7a5c8Smrg				;;
47095b7a5c8Smrg			nonstopux)
47195b7a5c8Smrg				basic_machine=mips-compaq
47295b7a5c8Smrg				basic_os=nonstopux
47395b7a5c8Smrg				;;
47495b7a5c8Smrg			os400)
47595b7a5c8Smrg				basic_machine=powerpc-ibm
47695b7a5c8Smrg				basic_os=os400
47795b7a5c8Smrg				;;
47895b7a5c8Smrg			OSE68000 | ose68000)
47995b7a5c8Smrg				basic_machine=m68000-ericsson
48095b7a5c8Smrg				basic_os=ose
48195b7a5c8Smrg				;;
48295b7a5c8Smrg			os68k)
48395b7a5c8Smrg				basic_machine=m68k-none
48495b7a5c8Smrg				basic_os=os68k
48595b7a5c8Smrg				;;
48695b7a5c8Smrg			paragon)
48795b7a5c8Smrg				basic_machine=i860-intel
48895b7a5c8Smrg				basic_os=osf
48995b7a5c8Smrg				;;
49095b7a5c8Smrg			parisc)
49195b7a5c8Smrg				basic_machine=hppa-unknown
49295b7a5c8Smrg				basic_os=linux
49395b7a5c8Smrg				;;
49495b7a5c8Smrg			psp)
49595b7a5c8Smrg				basic_machine=mipsallegrexel-sony
49695b7a5c8Smrg				basic_os=psp
49795b7a5c8Smrg				;;
49895b7a5c8Smrg			pw32)
49995b7a5c8Smrg				basic_machine=i586-unknown
50095b7a5c8Smrg				basic_os=pw32
50195b7a5c8Smrg				;;
50295b7a5c8Smrg			rdos | rdos64)
50395b7a5c8Smrg				basic_machine=x86_64-pc
50495b7a5c8Smrg				basic_os=rdos
50595b7a5c8Smrg				;;
50695b7a5c8Smrg			rdos32)
50795b7a5c8Smrg				basic_machine=i386-pc
50895b7a5c8Smrg				basic_os=rdos
50995b7a5c8Smrg				;;
51095b7a5c8Smrg			rom68k)
51195b7a5c8Smrg				basic_machine=m68k-rom68k
51295b7a5c8Smrg				basic_os=coff
51395b7a5c8Smrg				;;
51495b7a5c8Smrg			sa29200)
51595b7a5c8Smrg				basic_machine=a29k-amd
51695b7a5c8Smrg				basic_os=udi
51795b7a5c8Smrg				;;
51895b7a5c8Smrg			sei)
51995b7a5c8Smrg				basic_machine=mips-sei
52095b7a5c8Smrg				basic_os=seiux
52195b7a5c8Smrg				;;
52295b7a5c8Smrg			sequent)
52395b7a5c8Smrg				basic_machine=i386-sequent
52495b7a5c8Smrg				basic_os=
52595b7a5c8Smrg				;;
52695b7a5c8Smrg			sps7)
52795b7a5c8Smrg				basic_machine=m68k-bull
52895b7a5c8Smrg				basic_os=sysv2
52995b7a5c8Smrg				;;
53095b7a5c8Smrg			st2000)
53195b7a5c8Smrg				basic_machine=m68k-tandem
53295b7a5c8Smrg				basic_os=
53395b7a5c8Smrg				;;
53495b7a5c8Smrg			stratus)
53595b7a5c8Smrg				basic_machine=i860-stratus
53695b7a5c8Smrg				basic_os=sysv4
53795b7a5c8Smrg				;;
53895b7a5c8Smrg			sun2)
53995b7a5c8Smrg				basic_machine=m68000-sun
54095b7a5c8Smrg				basic_os=
54195b7a5c8Smrg				;;
54295b7a5c8Smrg			sun2os3)
54395b7a5c8Smrg				basic_machine=m68000-sun
54495b7a5c8Smrg				basic_os=sunos3
54595b7a5c8Smrg				;;
54695b7a5c8Smrg			sun2os4)
54795b7a5c8Smrg				basic_machine=m68000-sun
54895b7a5c8Smrg				basic_os=sunos4
54995b7a5c8Smrg				;;
55095b7a5c8Smrg			sun3)
55195b7a5c8Smrg				basic_machine=m68k-sun
55295b7a5c8Smrg				basic_os=
55395b7a5c8Smrg				;;
55495b7a5c8Smrg			sun3os3)
55595b7a5c8Smrg				basic_machine=m68k-sun
55695b7a5c8Smrg				basic_os=sunos3
55795b7a5c8Smrg				;;
55895b7a5c8Smrg			sun3os4)
55995b7a5c8Smrg				basic_machine=m68k-sun
56095b7a5c8Smrg				basic_os=sunos4
56195b7a5c8Smrg				;;
56295b7a5c8Smrg			sun4)
56395b7a5c8Smrg				basic_machine=sparc-sun
56495b7a5c8Smrg				basic_os=
56595b7a5c8Smrg				;;
56695b7a5c8Smrg			sun4os3)
56795b7a5c8Smrg				basic_machine=sparc-sun
56895b7a5c8Smrg				basic_os=sunos3
56995b7a5c8Smrg				;;
57095b7a5c8Smrg			sun4os4)
57195b7a5c8Smrg				basic_machine=sparc-sun
57295b7a5c8Smrg				basic_os=sunos4
57395b7a5c8Smrg				;;
57495b7a5c8Smrg			sun4sol2)
57595b7a5c8Smrg				basic_machine=sparc-sun
57695b7a5c8Smrg				basic_os=solaris2
57795b7a5c8Smrg				;;
57895b7a5c8Smrg			sun386 | sun386i | roadrunner)
57995b7a5c8Smrg				basic_machine=i386-sun
58095b7a5c8Smrg				basic_os=
58195b7a5c8Smrg				;;
58295b7a5c8Smrg			sv1)
58395b7a5c8Smrg				basic_machine=sv1-cray
58495b7a5c8Smrg				basic_os=unicos
58595b7a5c8Smrg				;;
58695b7a5c8Smrg			symmetry)
58795b7a5c8Smrg				basic_machine=i386-sequent
58895b7a5c8Smrg				basic_os=dynix
58995b7a5c8Smrg				;;
59095b7a5c8Smrg			t3e)
59195b7a5c8Smrg				basic_machine=alphaev5-cray
59295b7a5c8Smrg				basic_os=unicos
59395b7a5c8Smrg				;;
59495b7a5c8Smrg			t90)
59595b7a5c8Smrg				basic_machine=t90-cray
59695b7a5c8Smrg				basic_os=unicos
59795b7a5c8Smrg				;;
59895b7a5c8Smrg			toad1)
59995b7a5c8Smrg				basic_machine=pdp10-xkl
60095b7a5c8Smrg				basic_os=tops20
60195b7a5c8Smrg				;;
60295b7a5c8Smrg			tpf)
60395b7a5c8Smrg				basic_machine=s390x-ibm
60495b7a5c8Smrg				basic_os=tpf
60595b7a5c8Smrg				;;
60695b7a5c8Smrg			udi29k)
60795b7a5c8Smrg				basic_machine=a29k-amd
60895b7a5c8Smrg				basic_os=udi
60995b7a5c8Smrg				;;
61095b7a5c8Smrg			ultra3)
61195b7a5c8Smrg				basic_machine=a29k-nyu
61295b7a5c8Smrg				basic_os=sym1
61395b7a5c8Smrg				;;
61495b7a5c8Smrg			v810 | necv810)
61595b7a5c8Smrg				basic_machine=v810-nec
61695b7a5c8Smrg				basic_os=none
61795b7a5c8Smrg				;;
61895b7a5c8Smrg			vaxv)
61995b7a5c8Smrg				basic_machine=vax-dec
62095b7a5c8Smrg				basic_os=sysv
62195b7a5c8Smrg				;;
62295b7a5c8Smrg			vms)
62395b7a5c8Smrg				basic_machine=vax-dec
62495b7a5c8Smrg				basic_os=vms
62595b7a5c8Smrg				;;
62695b7a5c8Smrg			vsta)
62795b7a5c8Smrg				basic_machine=i386-pc
62895b7a5c8Smrg				basic_os=vsta
62995b7a5c8Smrg				;;
63095b7a5c8Smrg			vxworks960)
63195b7a5c8Smrg				basic_machine=i960-wrs
63295b7a5c8Smrg				basic_os=vxworks
63395b7a5c8Smrg				;;
63495b7a5c8Smrg			vxworks68)
63595b7a5c8Smrg				basic_machine=m68k-wrs
63695b7a5c8Smrg				basic_os=vxworks
63795b7a5c8Smrg				;;
63895b7a5c8Smrg			vxworks29k)
63995b7a5c8Smrg				basic_machine=a29k-wrs
64095b7a5c8Smrg				basic_os=vxworks
64195b7a5c8Smrg				;;
64295b7a5c8Smrg			xbox)
64395b7a5c8Smrg				basic_machine=i686-pc
64495b7a5c8Smrg				basic_os=mingw32
64595b7a5c8Smrg				;;
64695b7a5c8Smrg			ymp)
64795b7a5c8Smrg				basic_machine=ymp-cray
64895b7a5c8Smrg				basic_os=unicos
64995b7a5c8Smrg				;;
65095b7a5c8Smrg			*)
65195b7a5c8Smrg				basic_machine=$1
65295b7a5c8Smrg				basic_os=
65395b7a5c8Smrg				;;
65495b7a5c8Smrg		esac
65527702724Smrg		;;
65627702724Smrgesac
65727702724Smrg
65895b7a5c8Smrg# Decode 1-component or ad-hoc basic machines
65927702724Smrgcase $basic_machine in
66095b7a5c8Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66195b7a5c8Smrg	# some cases the only manufacturer, in others, it is the most popular.
66295b7a5c8Smrg	w89k)
66395b7a5c8Smrg		cpu=hppa1.1
66495b7a5c8Smrg		vendor=winbond
6657cea3689Smrg		;;
66695b7a5c8Smrg	op50n)
66795b7a5c8Smrg		cpu=hppa1.1
66895b7a5c8Smrg		vendor=oki
66927702724Smrg		;;
67095b7a5c8Smrg	op60c)
67195b7a5c8Smrg		cpu=hppa1.1
67295b7a5c8Smrg		vendor=oki
67327702724Smrg		;;
67495b7a5c8Smrg	ibm*)
67595b7a5c8Smrg		cpu=i370
67695b7a5c8Smrg		vendor=ibm
67727702724Smrg		;;
67895b7a5c8Smrg	orion105)
67995b7a5c8Smrg		cpu=clipper
68095b7a5c8Smrg		vendor=highlevel
681313a12fdSmrg		;;
68295b7a5c8Smrg	mac | mpw | mac-mpw)
68395b7a5c8Smrg		cpu=m68k
68495b7a5c8Smrg		vendor=apple
685313a12fdSmrg		;;
68695b7a5c8Smrg	pmac | pmac-mpw)
68795b7a5c8Smrg		cpu=powerpc
68895b7a5c8Smrg		vendor=apple
689313a12fdSmrg		;;
690313a12fdSmrg
69127702724Smrg	# Recognize the various machine names and aliases which stand
69227702724Smrg	# for a CPU type and a company and sometimes even an OS.
69327702724Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69495b7a5c8Smrg		cpu=m68000
69595b7a5c8Smrg		vendor=att
69627702724Smrg		;;
69727702724Smrg	3b*)
69895b7a5c8Smrg		cpu=we32k
69995b7a5c8Smrg		vendor=att
700e19dfac4Smrg		;;
70100084f2cSmrg	bluegene*)
70295b7a5c8Smrg		cpu=powerpc
70395b7a5c8Smrg		vendor=ibm
70495b7a5c8Smrg		basic_os=cnk
70527702724Smrg		;;
70627702724Smrg	decsystem10* | dec10*)
70795b7a5c8Smrg		cpu=pdp10
70895b7a5c8Smrg		vendor=dec
70995b7a5c8Smrg		basic_os=tops10
71027702724Smrg		;;
71127702724Smrg	decsystem20* | dec20*)
71295b7a5c8Smrg		cpu=pdp10
71395b7a5c8Smrg		vendor=dec
71495b7a5c8Smrg		basic_os=tops20
71527702724Smrg		;;
71627702724Smrg	delta | 3300 | motorola-3300 | motorola-delta \
71727702724Smrg	      | 3300-motorola | delta-motorola)
71895b7a5c8Smrg		cpu=m68k
71995b7a5c8Smrg		vendor=motorola
72027702724Smrg		;;
7217cea3689Smrg	dpx2*)
72295b7a5c8Smrg		cpu=m68k
72395b7a5c8Smrg		vendor=bull
72495b7a5c8Smrg		basic_os=sysv3
72527702724Smrg		;;
72627702724Smrg	encore | umax | mmax)
72795b7a5c8Smrg		cpu=ns32k
72895b7a5c8Smrg		vendor=encore
72927702724Smrg		;;
73095b7a5c8Smrg	elxsi)
73195b7a5c8Smrg		cpu=elxsi
73295b7a5c8Smrg		vendor=elxsi
73395b7a5c8Smrg		basic_os=${basic_os:-bsd}
73427702724Smrg		;;
73527702724Smrg	fx2800)
73695b7a5c8Smrg		cpu=i860
73795b7a5c8Smrg		vendor=alliant
73827702724Smrg		;;
73927702724Smrg	genix)
74095b7a5c8Smrg		cpu=ns32k
74195b7a5c8Smrg		vendor=ns
74227702724Smrg		;;
74327702724Smrg	h3050r* | hiux*)
74495b7a5c8Smrg		cpu=hppa1.1
74595b7a5c8Smrg		vendor=hitachi
74695b7a5c8Smrg		basic_os=hiuxwe2
74727702724Smrg		;;
74827702724Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74995b7a5c8Smrg		cpu=hppa1.0
75095b7a5c8Smrg		vendor=hp
75127702724Smrg		;;
75227702724Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75395b7a5c8Smrg		cpu=m68000
75495b7a5c8Smrg		vendor=hp
75527702724Smrg		;;
75627702724Smrg	hp9k3[2-9][0-9])
75795b7a5c8Smrg		cpu=m68k
75895b7a5c8Smrg		vendor=hp
75927702724Smrg		;;
76027702724Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76195b7a5c8Smrg		cpu=hppa1.0
76295b7a5c8Smrg		vendor=hp
76327702724Smrg		;;
76427702724Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76595b7a5c8Smrg		cpu=hppa1.1
76695b7a5c8Smrg		vendor=hp
76727702724Smrg		;;
76827702724Smrg	hp9k78[0-9] | hp78[0-9])
76927702724Smrg		# FIXME: really hppa2.0-hp
77095b7a5c8Smrg		cpu=hppa1.1
77195b7a5c8Smrg		vendor=hp
77227702724Smrg		;;
77327702724Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
77427702724Smrg		# FIXME: really hppa2.0-hp
77595b7a5c8Smrg		cpu=hppa1.1
77695b7a5c8Smrg		vendor=hp
77727702724Smrg		;;
77827702724Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77995b7a5c8Smrg		cpu=hppa1.1
78095b7a5c8Smrg		vendor=hp
78127702724Smrg		;;
78227702724Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78395b7a5c8Smrg		cpu=hppa1.0
78495b7a5c8Smrg		vendor=hp
78527702724Smrg		;;
78627702724Smrg	i*86v32)
78795b7a5c8Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78895b7a5c8Smrg		vendor=pc
78995b7a5c8Smrg		basic_os=sysv32
79027702724Smrg		;;
79127702724Smrg	i*86v4*)
79295b7a5c8Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79395b7a5c8Smrg		vendor=pc
79495b7a5c8Smrg		basic_os=sysv4
79527702724Smrg		;;
79627702724Smrg	i*86v)
79795b7a5c8Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79895b7a5c8Smrg		vendor=pc
79995b7a5c8Smrg		basic_os=sysv
80027702724Smrg		;;
80127702724Smrg	i*86sol2)
80295b7a5c8Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80395b7a5c8Smrg		vendor=pc
80495b7a5c8Smrg		basic_os=solaris2
80527702724Smrg		;;
80695b7a5c8Smrg	j90 | j90-cray)
80795b7a5c8Smrg		cpu=j90
80895b7a5c8Smrg		vendor=cray
80995b7a5c8Smrg		basic_os=${basic_os:-unicos}
81027702724Smrg		;;
81127702724Smrg	iris | iris4d)
81295b7a5c8Smrg		cpu=mips
81395b7a5c8Smrg		vendor=sgi
81495b7a5c8Smrg		case $basic_os in
81595b7a5c8Smrg		    irix*)
81627702724Smrg			;;
81727702724Smrg		    *)
81895b7a5c8Smrg			basic_os=irix4
81927702724Smrg			;;
82027702724Smrg		esac
82127702724Smrg		;;
82227702724Smrg	miniframe)
82395b7a5c8Smrg		cpu=m68000
82495b7a5c8Smrg		vendor=convergent
82527702724Smrg		;;
82695b7a5c8Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82795b7a5c8Smrg		cpu=m68k
82895b7a5c8Smrg		vendor=atari
82995b7a5c8Smrg		basic_os=mint
83027702724Smrg		;;
83127702724Smrg	news-3600 | risc-news)
83295b7a5c8Smrg		cpu=mips
83395b7a5c8Smrg		vendor=sony
83495b7a5c8Smrg		basic_os=newsos
83527702724Smrg		;;
8367cea3689Smrg	next | m*-next)
83795b7a5c8Smrg		cpu=m68k
83895b7a5c8Smrg		vendor=next
83995b7a5c8Smrg		case $basic_os in
84095b7a5c8Smrg		    openstep*)
84195b7a5c8Smrg		        ;;
84295b7a5c8Smrg		    nextstep*)
84327702724Smrg			;;
84495b7a5c8Smrg		    ns2*)
84595b7a5c8Smrg		      basic_os=nextstep2
84627702724Smrg			;;
84727702724Smrg		    *)
84895b7a5c8Smrg		      basic_os=nextstep3
84927702724Smrg			;;
85027702724Smrg		esac
85127702724Smrg		;;
85227702724Smrg	np1)
85395b7a5c8Smrg		cpu=np1
85495b7a5c8Smrg		vendor=gould
8557cea3689Smrg		;;
85627702724Smrg	op50n-* | op60c-*)
85795b7a5c8Smrg		cpu=hppa1.1
85895b7a5c8Smrg		vendor=oki
85995b7a5c8Smrg		basic_os=proelf
86027702724Smrg		;;
86127702724Smrg	pa-hitachi)
86295b7a5c8Smrg		cpu=hppa1.1
86395b7a5c8Smrg		vendor=hitachi
86495b7a5c8Smrg		basic_os=hiuxwe2
865e19dfac4Smrg		;;
86627702724Smrg	pbd)
86795b7a5c8Smrg		cpu=sparc
86895b7a5c8Smrg		vendor=tti
86927702724Smrg		;;
87027702724Smrg	pbb)
87195b7a5c8Smrg		cpu=m68k
87295b7a5c8Smrg		vendor=tti
87327702724Smrg		;;
87495b7a5c8Smrg	pc532)
87595b7a5c8Smrg		cpu=ns32k
87695b7a5c8Smrg		vendor=pc532
87727702724Smrg		;;
87827702724Smrg	pn)
87995b7a5c8Smrg		cpu=pn
88095b7a5c8Smrg		vendor=gould
88127702724Smrg		;;
88295b7a5c8Smrg	power)
88395b7a5c8Smrg		cpu=power
88495b7a5c8Smrg		vendor=ibm
88527702724Smrg		;;
88695b7a5c8Smrg	ps2)
88795b7a5c8Smrg		cpu=i386
88895b7a5c8Smrg		vendor=ibm
88927702724Smrg		;;
89095b7a5c8Smrg	rm[46]00)
89195b7a5c8Smrg		cpu=mips
89295b7a5c8Smrg		vendor=siemens
89327702724Smrg		;;
89495b7a5c8Smrg	rtpc | rtpc-*)
89595b7a5c8Smrg		cpu=romp
89695b7a5c8Smrg		vendor=ibm
89727702724Smrg		;;
89895b7a5c8Smrg	sde)
89995b7a5c8Smrg		cpu=mipsisa32
90095b7a5c8Smrg		vendor=sde
90195b7a5c8Smrg		basic_os=${basic_os:-elf}
90227702724Smrg		;;
90395b7a5c8Smrg	simso-wrs)
90495b7a5c8Smrg		cpu=sparclite
90595b7a5c8Smrg		vendor=wrs
90695b7a5c8Smrg		basic_os=vxworks
90727702724Smrg		;;
90895b7a5c8Smrg	tower | tower-32)
90995b7a5c8Smrg		cpu=m68k
91095b7a5c8Smrg		vendor=ncr
91127702724Smrg		;;
91295b7a5c8Smrg	vpp*|vx|vx-*)
91395b7a5c8Smrg		cpu=f301
91495b7a5c8Smrg		vendor=fujitsu
915313a12fdSmrg		;;
91695b7a5c8Smrg	w65)
91795b7a5c8Smrg		cpu=w65
91895b7a5c8Smrg		vendor=wdc
91927702724Smrg		;;
92095b7a5c8Smrg	w89k-*)
92195b7a5c8Smrg		cpu=hppa1.1
92295b7a5c8Smrg		vendor=winbond
92395b7a5c8Smrg		basic_os=proelf
92427702724Smrg		;;
92595b7a5c8Smrg	none)
92695b7a5c8Smrg		cpu=none
92795b7a5c8Smrg		vendor=none
92827702724Smrg		;;
92995b7a5c8Smrg	leon|leon[3-9])
93095b7a5c8Smrg		cpu=sparc
93195b7a5c8Smrg		vendor=$basic_machine
93227702724Smrg		;;
93395b7a5c8Smrg	leon-*|leon[3-9]-*)
93495b7a5c8Smrg		cpu=sparc
93595b7a5c8Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93627702724Smrg		;;
93795b7a5c8Smrg
93895b7a5c8Smrg	*-*)
93995b7a5c8Smrg		# shellcheck disable=SC2162
94095b7a5c8Smrg		saved_IFS=$IFS
94195b7a5c8Smrg		IFS="-" read cpu vendor <<EOF
94295b7a5c8Smrg$basic_machine
94395b7a5c8SmrgEOF
94495b7a5c8Smrg		IFS=$saved_IFS
94527702724Smrg		;;
94695b7a5c8Smrg	# We use `pc' rather than `unknown'
94795b7a5c8Smrg	# because (1) that's what they normally are, and
94895b7a5c8Smrg	# (2) the word "unknown" tends to confuse beginning users.
94995b7a5c8Smrg	i*86 | x86_64)
95095b7a5c8Smrg		cpu=$basic_machine
95195b7a5c8Smrg		vendor=pc
95227702724Smrg		;;
95395b7a5c8Smrg	# These rules are duplicated from below for sake of the special case above;
95495b7a5c8Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
95595b7a5c8Smrg	pc98)
95695b7a5c8Smrg		cpu=i386
95795b7a5c8Smrg		vendor=pc
95827702724Smrg		;;
95995b7a5c8Smrg	x64 | amd64)
96095b7a5c8Smrg		cpu=x86_64
96195b7a5c8Smrg		vendor=pc
96227702724Smrg		;;
96395b7a5c8Smrg	# Recognize the basic CPU types without company name.
96495b7a5c8Smrg	*)
96595b7a5c8Smrg		cpu=$basic_machine
96695b7a5c8Smrg		vendor=unknown
967e19dfac4Smrg		;;
96895b7a5c8Smrgesac
96995b7a5c8Smrg
97095b7a5c8Smrgunset -v basic_machine
97195b7a5c8Smrg
97295b7a5c8Smrg# Decode basic machines in the full and proper CPU-Company form.
97395b7a5c8Smrgcase $cpu-$vendor in
97495b7a5c8Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97595b7a5c8Smrg	# some cases the only manufacturer, in others, it is the most popular.
97695b7a5c8Smrg	craynv-unknown)
97795b7a5c8Smrg		vendor=cray
97895b7a5c8Smrg		basic_os=${basic_os:-unicosmp}
97927702724Smrg		;;
98095b7a5c8Smrg	c90-unknown | c90-cray)
98195b7a5c8Smrg		vendor=cray
98295b7a5c8Smrg		basic_os=${Basic_os:-unicos}
98327702724Smrg		;;
98495b7a5c8Smrg	fx80-unknown)
98595b7a5c8Smrg		vendor=alliant
986e19dfac4Smrg		;;
98795b7a5c8Smrg	romp-unknown)
98895b7a5c8Smrg		vendor=ibm
98927702724Smrg		;;
99095b7a5c8Smrg	mmix-unknown)
99195b7a5c8Smrg		vendor=knuth
99227702724Smrg		;;
99395b7a5c8Smrg	microblaze-unknown | microblazeel-unknown)
99495b7a5c8Smrg		vendor=xilinx
99527702724Smrg		;;
99695b7a5c8Smrg	rs6000-unknown)
99795b7a5c8Smrg		vendor=ibm
99827702724Smrg		;;
99995b7a5c8Smrg	vax-unknown)
100095b7a5c8Smrg		vendor=dec
100127702724Smrg		;;
100295b7a5c8Smrg	pdp11-unknown)
100395b7a5c8Smrg		vendor=dec
1004313a12fdSmrg		;;
100595b7a5c8Smrg	we32k-unknown)
100695b7a5c8Smrg		vendor=att
100727702724Smrg		;;
100895b7a5c8Smrg	cydra-unknown)
100995b7a5c8Smrg		vendor=cydrome
101027702724Smrg		;;
101195b7a5c8Smrg	i370-ibm*)
101295b7a5c8Smrg		vendor=ibm
101327702724Smrg		;;
101495b7a5c8Smrg	orion-unknown)
101595b7a5c8Smrg		vendor=highlevel
101627702724Smrg		;;
101795b7a5c8Smrg	xps-unknown | xps100-unknown)
101895b7a5c8Smrg		cpu=xps100
101995b7a5c8Smrg		vendor=honeywell
102027702724Smrg		;;
102195b7a5c8Smrg
102295b7a5c8Smrg	# Here we normalize CPU types with a missing or matching vendor
102395b7a5c8Smrg	dpx20-unknown | dpx20-bull)
102495b7a5c8Smrg		cpu=rs6000
102595b7a5c8Smrg		vendor=bull
102695b7a5c8Smrg		basic_os=${basic_os:-bosx}
102727702724Smrg		;;
102895b7a5c8Smrg
102995b7a5c8Smrg	# Here we normalize CPU types irrespective of the vendor
103095b7a5c8Smrg	amd64-*)
103195b7a5c8Smrg		cpu=x86_64
103227702724Smrg		;;
103395b7a5c8Smrg	blackfin-*)
103495b7a5c8Smrg		cpu=bfin
103595b7a5c8Smrg		basic_os=linux
103627702724Smrg		;;
103795b7a5c8Smrg	c54x-*)
103895b7a5c8Smrg		cpu=tic54x
103927702724Smrg		;;
104095b7a5c8Smrg	c55x-*)
104195b7a5c8Smrg		cpu=tic55x
104227702724Smrg		;;
104395b7a5c8Smrg	c6x-*)
104495b7a5c8Smrg		cpu=tic6x
104527702724Smrg		;;
104695b7a5c8Smrg	e500v[12]-*)
104795b7a5c8Smrg		cpu=powerpc
104895b7a5c8Smrg		basic_os=${basic_os}"spe"
104927702724Smrg		;;
105095b7a5c8Smrg	mips3*-*)
105195b7a5c8Smrg		cpu=mips64
105227702724Smrg		;;
105395b7a5c8Smrg	ms1-*)
105495b7a5c8Smrg		cpu=mt
105527702724Smrg		;;
105695b7a5c8Smrg	m68knommu-*)
105795b7a5c8Smrg		cpu=m68k
105895b7a5c8Smrg		basic_os=linux
105927702724Smrg		;;
106095b7a5c8Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106195b7a5c8Smrg		cpu=s12z
1062e19dfac4Smrg		;;
106395b7a5c8Smrg	openrisc-*)
106495b7a5c8Smrg		cpu=or32
106527702724Smrg		;;
106695b7a5c8Smrg	parisc-*)
106795b7a5c8Smrg		cpu=hppa
106895b7a5c8Smrg		basic_os=linux
106927702724Smrg		;;
107095b7a5c8Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107195b7a5c8Smrg		cpu=i586
107227702724Smrg		;;
107395b7a5c8Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
107495b7a5c8Smrg		cpu=i686
107527702724Smrg		;;
107695b7a5c8Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
107795b7a5c8Smrg		cpu=i686
107827702724Smrg		;;
107995b7a5c8Smrg	pentium4-*)
108095b7a5c8Smrg		cpu=i786
108127702724Smrg		;;
108295b7a5c8Smrg	pc98-*)
108395b7a5c8Smrg		cpu=i386
108427702724Smrg		;;
108595b7a5c8Smrg	ppc-* | ppcbe-*)
108695b7a5c8Smrg		cpu=powerpc
108727702724Smrg		;;
108895b7a5c8Smrg	ppcle-* | powerpclittle-*)
108995b7a5c8Smrg		cpu=powerpcle
109027702724Smrg		;;
109195b7a5c8Smrg	ppc64-*)
109295b7a5c8Smrg		cpu=powerpc64
109327702724Smrg		;;
109495b7a5c8Smrg	ppc64le-* | powerpc64little-*)
109595b7a5c8Smrg		cpu=powerpc64le
109627702724Smrg		;;
109795b7a5c8Smrg	sb1-*)
109895b7a5c8Smrg		cpu=mipsisa64sb1
109927702724Smrg		;;
110095b7a5c8Smrg	sb1el-*)
110195b7a5c8Smrg		cpu=mipsisa64sb1el
110227702724Smrg		;;
110395b7a5c8Smrg	sh5e[lb]-*)
110495b7a5c8Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
110527702724Smrg		;;
110695b7a5c8Smrg	spur-*)
110795b7a5c8Smrg		cpu=spur
110827702724Smrg		;;
110995b7a5c8Smrg	strongarm-* | thumb-*)
111095b7a5c8Smrg		cpu=arm
111127702724Smrg		;;
111295b7a5c8Smrg	tx39-*)
111395b7a5c8Smrg		cpu=mipstx39
11147cea3689Smrg		;;
111595b7a5c8Smrg	tx39el-*)
111695b7a5c8Smrg		cpu=mipstx39el
111727702724Smrg		;;
111895b7a5c8Smrg	x64-*)
111995b7a5c8Smrg		cpu=x86_64
112027702724Smrg		;;
1121313a12fdSmrg	xscale-* | xscalee[bl]-*)
112295b7a5c8Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112327702724Smrg		;;
112495b7a5c8Smrg	arm64-*)
112595b7a5c8Smrg		cpu=aarch64
112627702724Smrg		;;
112727702724Smrg
112895b7a5c8Smrg	# Recognize the canonical CPU Types that limit and/or modify the
112995b7a5c8Smrg	# company names they are paired with.
113095b7a5c8Smrg	cr16-*)
113195b7a5c8Smrg		basic_os=${basic_os:-elf}
113227702724Smrg		;;
113395b7a5c8Smrg	crisv32-* | etraxfs*-*)
113495b7a5c8Smrg		cpu=crisv32
113595b7a5c8Smrg		vendor=axis
113627702724Smrg		;;
113795b7a5c8Smrg	cris-* | etrax*-*)
113895b7a5c8Smrg		cpu=cris
113995b7a5c8Smrg		vendor=axis
114027702724Smrg		;;
114195b7a5c8Smrg	crx-*)
114295b7a5c8Smrg		basic_os=${basic_os:-elf}
114327702724Smrg		;;
114495b7a5c8Smrg	neo-tandem)
114595b7a5c8Smrg		cpu=neo
114695b7a5c8Smrg		vendor=tandem
114727702724Smrg		;;
114895b7a5c8Smrg	nse-tandem)
114995b7a5c8Smrg		cpu=nse
115095b7a5c8Smrg		vendor=tandem
115127702724Smrg		;;
115295b7a5c8Smrg	nsr-tandem)
115395b7a5c8Smrg		cpu=nsr
115495b7a5c8Smrg		vendor=tandem
115527702724Smrg		;;
115695b7a5c8Smrg	nsv-tandem)
115795b7a5c8Smrg		cpu=nsv
115895b7a5c8Smrg		vendor=tandem
115927702724Smrg		;;
116095b7a5c8Smrg	nsx-tandem)
116195b7a5c8Smrg		cpu=nsx
116295b7a5c8Smrg		vendor=tandem
116327702724Smrg		;;
116495b7a5c8Smrg	mipsallegrexel-sony)
116595b7a5c8Smrg		cpu=mipsallegrexel
116695b7a5c8Smrg		vendor=sony
116727702724Smrg		;;
116895b7a5c8Smrg	tile*-*)
116995b7a5c8Smrg		basic_os=${basic_os:-linux-gnu}
117027702724Smrg		;;
117195b7a5c8Smrg
117227702724Smrg	*)
117395b7a5c8Smrg		# Recognize the canonical CPU types that are allowed with any
117495b7a5c8Smrg		# company name.
117595b7a5c8Smrg		case $cpu in
117695b7a5c8Smrg			1750a | 580 \
117795b7a5c8Smrg			| a29k \
117895b7a5c8Smrg			| aarch64 | aarch64_be \
117995b7a5c8Smrg			| abacus \
118095b7a5c8Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118195b7a5c8Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118295b7a5c8Smrg			| alphapca5[67] | alpha64pca5[67] \
118395b7a5c8Smrg			| am33_2.0 \
118495b7a5c8Smrg			| amdgcn \
118595b7a5c8Smrg			| arc | arceb | arc32 | arc64 \
118695b7a5c8Smrg			| arm | arm[lb]e | arme[lb] | armv* \
118795b7a5c8Smrg			| avr | avr32 \
118895b7a5c8Smrg			| asmjs \
118995b7a5c8Smrg			| ba \
119095b7a5c8Smrg			| be32 | be64 \
119195b7a5c8Smrg			| bfin | bpf | bs2000 \
119295b7a5c8Smrg			| c[123]* | c30 | [cjt]90 | c4x \
119395b7a5c8Smrg			| c8051 | clipper | craynv | csky | cydra \
119495b7a5c8Smrg			| d10v | d30v | dlx | dsp16xx \
119595b7a5c8Smrg			| e2k | elxsi | epiphany \
119695b7a5c8Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
119795b7a5c8Smrg			| h8300 | h8500 \
119895b7a5c8Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
119995b7a5c8Smrg			| hexagon \
120095b7a5c8Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120195b7a5c8Smrg			| ip2k | iq2000 \
120295b7a5c8Smrg			| k1om \
120395b7a5c8Smrg			| le32 | le64 \
120495b7a5c8Smrg			| lm32 \
120595b7a5c8Smrg			| loongarch32 | loongarch64 | loongarchx32 \
120695b7a5c8Smrg			| m32c | m32r | m32rle \
120795b7a5c8Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
120895b7a5c8Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
120995b7a5c8Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121095b7a5c8Smrg			| microblaze | microblazeel \
121195b7a5c8Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121295b7a5c8Smrg			| mips16 \
121395b7a5c8Smrg			| mips64 | mips64eb | mips64el \
121495b7a5c8Smrg			| mips64octeon | mips64octeonel \
121595b7a5c8Smrg			| mips64orion | mips64orionel \
121695b7a5c8Smrg			| mips64r5900 | mips64r5900el \
121795b7a5c8Smrg			| mips64vr | mips64vrel \
121895b7a5c8Smrg			| mips64vr4100 | mips64vr4100el \
121995b7a5c8Smrg			| mips64vr4300 | mips64vr4300el \
122095b7a5c8Smrg			| mips64vr5000 | mips64vr5000el \
122195b7a5c8Smrg			| mips64vr5900 | mips64vr5900el \
122295b7a5c8Smrg			| mipsisa32 | mipsisa32el \
122395b7a5c8Smrg			| mipsisa32r2 | mipsisa32r2el \
122495b7a5c8Smrg			| mipsisa32r3 | mipsisa32r3el \
122595b7a5c8Smrg			| mipsisa32r5 | mipsisa32r5el \
122695b7a5c8Smrg			| mipsisa32r6 | mipsisa32r6el \
122795b7a5c8Smrg			| mipsisa64 | mipsisa64el \
122895b7a5c8Smrg			| mipsisa64r2 | mipsisa64r2el \
122995b7a5c8Smrg			| mipsisa64r3 | mipsisa64r3el \
123095b7a5c8Smrg			| mipsisa64r5 | mipsisa64r5el \
123195b7a5c8Smrg			| mipsisa64r6 | mipsisa64r6el \
123295b7a5c8Smrg			| mipsisa64sb1 | mipsisa64sb1el \
123395b7a5c8Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
123495b7a5c8Smrg			| mipsr5900 | mipsr5900el \
123595b7a5c8Smrg			| mipstx39 | mipstx39el \
123695b7a5c8Smrg			| mmix \
123795b7a5c8Smrg			| mn10200 | mn10300 \
123895b7a5c8Smrg			| moxie \
123995b7a5c8Smrg			| mt \
124095b7a5c8Smrg			| msp430 \
124195b7a5c8Smrg			| nds32 | nds32le | nds32be \
124295b7a5c8Smrg			| nfp \
124395b7a5c8Smrg			| nios | nios2 | nios2eb | nios2el \
124495b7a5c8Smrg			| none | np1 | ns16k | ns32k | nvptx \
124595b7a5c8Smrg			| open8 \
124695b7a5c8Smrg			| or1k* \
124795b7a5c8Smrg			| or32 \
124895b7a5c8Smrg			| orion \
124995b7a5c8Smrg			| picochip \
125095b7a5c8Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125195b7a5c8Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125295b7a5c8Smrg			| pru \
125395b7a5c8Smrg			| pyramid \
125495b7a5c8Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
125595b7a5c8Smrg			| rl78 | romp | rs6000 | rx \
125695b7a5c8Smrg			| s390 | s390x \
125795b7a5c8Smrg			| score \
125895b7a5c8Smrg			| sh | shl \
125995b7a5c8Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126095b7a5c8Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126195b7a5c8Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126295b7a5c8Smrg			| sparclite \
126395b7a5c8Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126495b7a5c8Smrg			| spu \
126595b7a5c8Smrg			| tahoe \
126695b7a5c8Smrg			| thumbv7* \
126795b7a5c8Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
126895b7a5c8Smrg			| tron \
126995b7a5c8Smrg			| ubicom32 \
127095b7a5c8Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127195b7a5c8Smrg			| vax \
127295b7a5c8Smrg			| visium \
127395b7a5c8Smrg			| w65 \
127495b7a5c8Smrg			| wasm32 | wasm64 \
127595b7a5c8Smrg			| we32k \
127695b7a5c8Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
127795b7a5c8Smrg			| xstormy16 | xtensa* \
127895b7a5c8Smrg			| ymp \
127995b7a5c8Smrg			| z8k | z80)
128095b7a5c8Smrg				;;
128195b7a5c8Smrg
128295b7a5c8Smrg			*)
128395b7a5c8Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128495b7a5c8Smrg				exit 1
128595b7a5c8Smrg				;;
128695b7a5c8Smrg		esac
128727702724Smrg		;;
128827702724Smrgesac
128927702724Smrg
129027702724Smrg# Here we canonicalize certain aliases for manufacturers.
129195b7a5c8Smrgcase $vendor in
129295b7a5c8Smrg	digital*)
129395b7a5c8Smrg		vendor=dec
129427702724Smrg		;;
129595b7a5c8Smrg	commodore*)
129695b7a5c8Smrg		vendor=cbm
129727702724Smrg		;;
129827702724Smrg	*)
129927702724Smrg		;;
130027702724Smrgesac
130127702724Smrg
130227702724Smrg# Decode manufacturer-specific aliases for certain operating systems.
130327702724Smrg
130495b7a5c8Smrgif test x$basic_os != x
130527702724Smrgthen
130695b7a5c8Smrg
130795b7a5c8Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
130895b7a5c8Smrg# set os.
130995b7a5c8Smrgcase $basic_os in
131095b7a5c8Smrg	gnu/linux*)
131195b7a5c8Smrg		kernel=linux
131295b7a5c8Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131395b7a5c8Smrg		;;
131495b7a5c8Smrg	os2-emx)
131595b7a5c8Smrg		kernel=os2
131695b7a5c8Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
131795b7a5c8Smrg		;;
131895b7a5c8Smrg	nto-qnx*)
131995b7a5c8Smrg		kernel=nto
132095b7a5c8Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132195b7a5c8Smrg		;;
132295b7a5c8Smrg	*-*)
132395b7a5c8Smrg		# shellcheck disable=SC2162
132495b7a5c8Smrg		saved_IFS=$IFS
132595b7a5c8Smrg		IFS="-" read kernel os <<EOF
132695b7a5c8Smrg$basic_os
132795b7a5c8SmrgEOF
132895b7a5c8Smrg		IFS=$saved_IFS
132995b7a5c8Smrg		;;
133095b7a5c8Smrg	# Default OS when just kernel was specified
133195b7a5c8Smrg	nto*)
133295b7a5c8Smrg		kernel=nto
133395b7a5c8Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133495b7a5c8Smrg		;;
133595b7a5c8Smrg	linux*)
133695b7a5c8Smrg		kernel=linux
133795b7a5c8Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
133895b7a5c8Smrg		;;
133995b7a5c8Smrg	*)
134095b7a5c8Smrg		kernel=
134195b7a5c8Smrg		os=$basic_os
134295b7a5c8Smrg		;;
134395b7a5c8Smrgesac
134495b7a5c8Smrg
134595b7a5c8Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
134695b7a5c8Smrg# etc.)
134727702724Smrgcase $os in
13487cea3689Smrg	# First match some system type aliases that might get confused
13497cea3689Smrg	# with valid system types.
135095b7a5c8Smrg	# solaris* is a basic system type, with this one exception.
135195b7a5c8Smrg	auroraux)
135295b7a5c8Smrg		os=auroraux
135300084f2cSmrg		;;
135495b7a5c8Smrg	bluegene*)
135595b7a5c8Smrg		os=cnk
135627702724Smrg		;;
135795b7a5c8Smrg	solaris1 | solaris1.*)
135895b7a5c8Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
135927702724Smrg		;;
136095b7a5c8Smrg	solaris)
136195b7a5c8Smrg		os=solaris2
136227702724Smrg		;;
136395b7a5c8Smrg	unixware*)
136495b7a5c8Smrg		os=sysv4.2uw
136527702724Smrg		;;
13667cea3689Smrg	# es1800 is here to avoid being matched by es* (a different OS)
136795b7a5c8Smrg	es1800*)
136895b7a5c8Smrg		os=ose
13697cea3689Smrg		;;
137095b7a5c8Smrg	# Some version numbers need modification
137195b7a5c8Smrg	chorusos*)
137295b7a5c8Smrg		os=chorusos
137327702724Smrg		;;
137495b7a5c8Smrg	isc)
137595b7a5c8Smrg		os=isc2.2
137627702724Smrg		;;
137795b7a5c8Smrg	sco6)
137895b7a5c8Smrg		os=sco5v6
137927702724Smrg		;;
138095b7a5c8Smrg	sco5)
138195b7a5c8Smrg		os=sco3.2v5
138227702724Smrg		;;
138395b7a5c8Smrg	sco4)
138495b7a5c8Smrg		os=sco3.2v4
138527702724Smrg		;;
138695b7a5c8Smrg	sco3.2.[4-9]*)
138795b7a5c8Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
138827702724Smrg		;;
138995b7a5c8Smrg	sco*v* | scout)
139095b7a5c8Smrg		# Don't match below
139127702724Smrg		;;
139295b7a5c8Smrg	sco*)
139395b7a5c8Smrg		os=sco3.2v2
139427702724Smrg		;;
139595b7a5c8Smrg	psos*)
139695b7a5c8Smrg		os=psos
139727702724Smrg		;;
139895b7a5c8Smrg	qnx*)
139995b7a5c8Smrg		os=qnx
140027702724Smrg		;;
140195b7a5c8Smrg	hiux*)
140295b7a5c8Smrg		os=hiuxwe2
140327702724Smrg		;;
140495b7a5c8Smrg	lynx*178)
140595b7a5c8Smrg		os=lynxos178
140627702724Smrg		;;
140795b7a5c8Smrg	lynx*5)
140895b7a5c8Smrg		os=lynxos5
140927702724Smrg		;;
141095b7a5c8Smrg	lynxos*)
141195b7a5c8Smrg		# don't get caught up in next wildcard
141227702724Smrg		;;
141395b7a5c8Smrg	lynx*)
141495b7a5c8Smrg		os=lynxos
141527702724Smrg		;;
141695b7a5c8Smrg	mac[0-9]*)
141795b7a5c8Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
141827702724Smrg		;;
141995b7a5c8Smrg	opened*)
142095b7a5c8Smrg		os=openedition
142127702724Smrg		;;
142295b7a5c8Smrg	os400*)
142395b7a5c8Smrg		os=os400
142427702724Smrg		;;
142595b7a5c8Smrg	sunos5*)
142695b7a5c8Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
142727702724Smrg		;;
142895b7a5c8Smrg	sunos6*)
142995b7a5c8Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
143027702724Smrg		;;
143195b7a5c8Smrg	wince*)
143295b7a5c8Smrg		os=wince
143327702724Smrg		;;
143495b7a5c8Smrg	utek*)
143595b7a5c8Smrg		os=bsd
143627702724Smrg		;;
143795b7a5c8Smrg	dynix*)
143895b7a5c8Smrg		os=bsd
143927702724Smrg		;;
144095b7a5c8Smrg	acis*)
144195b7a5c8Smrg		os=aos
144227702724Smrg		;;
144395b7a5c8Smrg	atheos*)
144495b7a5c8Smrg		os=atheos
144527702724Smrg		;;
144695b7a5c8Smrg	syllable*)
144795b7a5c8Smrg		os=syllable
144895b7a5c8Smrg		;;
144995b7a5c8Smrg	386bsd)
145095b7a5c8Smrg		os=bsd
145195b7a5c8Smrg		;;
145295b7a5c8Smrg	ctix* | uts*)
145395b7a5c8Smrg		os=sysv
145495b7a5c8Smrg		;;
145595b7a5c8Smrg	nova*)
145695b7a5c8Smrg		os=rtmk-nova
145795b7a5c8Smrg		;;
145895b7a5c8Smrg	ns2)
145995b7a5c8Smrg		os=nextstep2
146095b7a5c8Smrg		;;
146195b7a5c8Smrg	# Preserve the version number of sinix5.
146295b7a5c8Smrg	sinix5.*)
146395b7a5c8Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
146427702724Smrg		;;
146595b7a5c8Smrg	sinix*)
146695b7a5c8Smrg		os=sysv4
146727702724Smrg		;;
146895b7a5c8Smrg	tpf*)
146995b7a5c8Smrg		os=tpf
147027702724Smrg		;;
147195b7a5c8Smrg	triton*)
147295b7a5c8Smrg		os=sysv3
147327702724Smrg		;;
147495b7a5c8Smrg	oss*)
147595b7a5c8Smrg		os=sysv3
147627702724Smrg		;;
147795b7a5c8Smrg	svr4*)
147895b7a5c8Smrg		os=sysv4
147927702724Smrg		;;
148095b7a5c8Smrg	svr3)
148195b7a5c8Smrg		os=sysv3
148227702724Smrg		;;
148395b7a5c8Smrg	sysvr4)
148495b7a5c8Smrg		os=sysv4
148527702724Smrg		;;
148695b7a5c8Smrg	ose*)
148795b7a5c8Smrg		os=ose
148827702724Smrg		;;
148995b7a5c8Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149095b7a5c8Smrg		os=mint
149100084f2cSmrg		;;
149295b7a5c8Smrg	dicos*)
149395b7a5c8Smrg		os=dicos
149495b7a5c8Smrg		;;
149595b7a5c8Smrg	pikeos*)
14967cea3689Smrg		# Until real need of OS specific support for
14977cea3689Smrg		# particular features comes up, bare metal
14987cea3689Smrg		# configurations are quite functional.
149995b7a5c8Smrg		case $cpu in
15007cea3689Smrg		    arm*)
150195b7a5c8Smrg			os=eabi
15027cea3689Smrg			;;
15037cea3689Smrg		    *)
150495b7a5c8Smrg			os=elf
15057cea3689Smrg			;;
15067cea3689Smrg		esac
15077cea3689Smrg		;;
150827702724Smrg	*)
150995b7a5c8Smrg		# No normalization, but not necessarily accepted, that comes below.
151027702724Smrg		;;
151127702724Smrgesac
151295b7a5c8Smrg
151327702724Smrgelse
151427702724Smrg
151527702724Smrg# Here we handle the default operating systems that come with various machines.
151627702724Smrg# The value should be what the vendor currently ships out the door with their
151727702724Smrg# machine or put another way, the most popular os provided with the machine.
151827702724Smrg
151927702724Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
152027702724Smrg# "-sun"), then you have to tell the case statement up towards the top
152127702724Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
152227702724Smrg# will signal an error saying that MANUFACTURER isn't an operating
152327702724Smrg# system, and we'll never get to this point.
152427702724Smrg
152595b7a5c8Smrgkernel=
152695b7a5c8Smrgcase $cpu-$vendor in
1527313a12fdSmrg	score-*)
152895b7a5c8Smrg		os=elf
1529e19dfac4Smrg		;;
1530313a12fdSmrg	spu-*)
153195b7a5c8Smrg		os=elf
1532e19dfac4Smrg		;;
153327702724Smrg	*-acorn)
153495b7a5c8Smrg		os=riscix1.2
153527702724Smrg		;;
153627702724Smrg	arm*-rebel)
153795b7a5c8Smrg		kernel=linux
153895b7a5c8Smrg		os=gnu
153927702724Smrg		;;
154027702724Smrg	arm*-semi)
154195b7a5c8Smrg		os=aout
154227702724Smrg		;;
1543313a12fdSmrg	c4x-* | tic4x-*)
154495b7a5c8Smrg		os=coff
1545313a12fdSmrg		;;
15467cea3689Smrg	c8051-*)
154795b7a5c8Smrg		os=elf
154895b7a5c8Smrg		;;
154995b7a5c8Smrg	clipper-intergraph)
155095b7a5c8Smrg		os=clix
15517cea3689Smrg		;;
1552313a12fdSmrg	hexagon-*)
155395b7a5c8Smrg		os=elf
1554313a12fdSmrg		;;
1555313a12fdSmrg	tic54x-*)
155695b7a5c8Smrg		os=coff
1557313a12fdSmrg		;;
1558313a12fdSmrg	tic55x-*)
155995b7a5c8Smrg		os=coff
1560313a12fdSmrg		;;
1561313a12fdSmrg	tic6x-*)
156295b7a5c8Smrg		os=coff
1563e19dfac4Smrg		;;
156427702724Smrg	# This must come before the *-dec entry.
156527702724Smrg	pdp10-*)
156695b7a5c8Smrg		os=tops20
156727702724Smrg		;;
156827702724Smrg	pdp11-*)
156995b7a5c8Smrg		os=none
157027702724Smrg		;;
157127702724Smrg	*-dec | vax-*)
157295b7a5c8Smrg		os=ultrix4.2
157327702724Smrg		;;
157427702724Smrg	m68*-apollo)
157595b7a5c8Smrg		os=domain
157627702724Smrg		;;
157727702724Smrg	i386-sun)
157895b7a5c8Smrg		os=sunos4.0.2
157927702724Smrg		;;
158027702724Smrg	m68000-sun)
158195b7a5c8Smrg		os=sunos3
158227702724Smrg		;;
158327702724Smrg	m68*-cisco)
158495b7a5c8Smrg		os=aout
158527702724Smrg		;;
1586313a12fdSmrg	mep-*)
158795b7a5c8Smrg		os=elf
1588e19dfac4Smrg		;;
158927702724Smrg	mips*-cisco)
159095b7a5c8Smrg		os=elf
159127702724Smrg		;;
159227702724Smrg	mips*-*)
159395b7a5c8Smrg		os=elf
159427702724Smrg		;;
159527702724Smrg	or32-*)
159695b7a5c8Smrg		os=coff
159727702724Smrg		;;
159827702724Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
159995b7a5c8Smrg		os=sysv3
160027702724Smrg		;;
160127702724Smrg	sparc-* | *-sun)
160295b7a5c8Smrg		os=sunos4.1.1
160327702724Smrg		;;
16047cea3689Smrg	pru-*)
160595b7a5c8Smrg		os=elf
16067cea3689Smrg		;;
160727702724Smrg	*-be)
160895b7a5c8Smrg		os=beos
160927702724Smrg		;;
161027702724Smrg	*-ibm)
161195b7a5c8Smrg		os=aix
161227702724Smrg		;;
1613313a12fdSmrg	*-knuth)
161495b7a5c8Smrg		os=mmixware
161527702724Smrg		;;
161627702724Smrg	*-wec)
161795b7a5c8Smrg		os=proelf
161827702724Smrg		;;
161927702724Smrg	*-winbond)
162095b7a5c8Smrg		os=proelf
162127702724Smrg		;;
162227702724Smrg	*-oki)
162395b7a5c8Smrg		os=proelf
162427702724Smrg		;;
162527702724Smrg	*-hp)
162695b7a5c8Smrg		os=hpux
162727702724Smrg		;;
162827702724Smrg	*-hitachi)
162995b7a5c8Smrg		os=hiux
163027702724Smrg		;;
163127702724Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
163295b7a5c8Smrg		os=sysv
163327702724Smrg		;;
163427702724Smrg	*-cbm)
163595b7a5c8Smrg		os=amigaos
163627702724Smrg		;;
163727702724Smrg	*-dg)
163895b7a5c8Smrg		os=dgux
163927702724Smrg		;;
164027702724Smrg	*-dolphin)
164195b7a5c8Smrg		os=sysv3
164227702724Smrg		;;
164327702724Smrg	m68k-ccur)
164495b7a5c8Smrg		os=rtu
164527702724Smrg		;;
164627702724Smrg	m88k-omron*)
164795b7a5c8Smrg		os=luna
164827702724Smrg		;;
16497cea3689Smrg	*-next)
165095b7a5c8Smrg		os=nextstep
165127702724Smrg		;;
165227702724Smrg	*-sequent)
165395b7a5c8Smrg		os=ptx
165427702724Smrg		;;
165527702724Smrg	*-crds)
165695b7a5c8Smrg		os=unos
165727702724Smrg		;;
165827702724Smrg	*-ns)
165995b7a5c8Smrg		os=genix
166027702724Smrg		;;
166127702724Smrg	i370-*)
166295b7a5c8Smrg		os=mvs
166327702724Smrg		;;
166427702724Smrg	*-gould)
166595b7a5c8Smrg		os=sysv
166627702724Smrg		;;
166727702724Smrg	*-highlevel)
166895b7a5c8Smrg		os=bsd
166927702724Smrg		;;
167027702724Smrg	*-encore)
167195b7a5c8Smrg		os=bsd
167227702724Smrg		;;
167327702724Smrg	*-sgi)
167495b7a5c8Smrg		os=irix
167527702724Smrg		;;
167627702724Smrg	*-siemens)
167795b7a5c8Smrg		os=sysv4
167827702724Smrg		;;
167927702724Smrg	*-masscomp)
168095b7a5c8Smrg		os=rtu
168127702724Smrg		;;
168227702724Smrg	f30[01]-fujitsu | f700-fujitsu)
168395b7a5c8Smrg		os=uxpv
168427702724Smrg		;;
168527702724Smrg	*-rom68k)
168695b7a5c8Smrg		os=coff
168727702724Smrg		;;
168827702724Smrg	*-*bug)
168995b7a5c8Smrg		os=coff
169027702724Smrg		;;
169127702724Smrg	*-apple)
169295b7a5c8Smrg		os=macos
169327702724Smrg		;;
169427702724Smrg	*-atari*)
169595b7a5c8Smrg		os=mint
169695b7a5c8Smrg		;;
169795b7a5c8Smrg	*-wrs)
169895b7a5c8Smrg		os=vxworks
169927702724Smrg		;;
170027702724Smrg	*)
170195b7a5c8Smrg		os=none
170227702724Smrg		;;
170327702724Smrgesac
170495b7a5c8Smrg
170527702724Smrgfi
170627702724Smrg
170795b7a5c8Smrg# Now, validate our (potentially fixed-up) OS.
170895b7a5c8Smrgcase $os in
170995b7a5c8Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
171095b7a5c8Smrg	musl* | newlib* | relibc* | uclibc*)
171195b7a5c8Smrg		;;
171295b7a5c8Smrg	# Likewise for "kernel-abi"
171395b7a5c8Smrg	eabi* | gnueabi*)
171495b7a5c8Smrg		;;
171595b7a5c8Smrg	# VxWorks passes extra cpu info in the 4th filed.
171695b7a5c8Smrg	simlinux | simwindows | spe)
171795b7a5c8Smrg		;;
171895b7a5c8Smrg	# Now accept the basic system types.
171995b7a5c8Smrg	# The portable systems comes first.
172095b7a5c8Smrg	# Each alternative MUST end in a * to match a version number.
172195b7a5c8Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
172295b7a5c8Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
172395b7a5c8Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
172495b7a5c8Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
172595b7a5c8Smrg	     | hiux* | abug | nacl* | netware* | windows* \
172695b7a5c8Smrg	     | os9* | macos* | osx* | ios* \
172795b7a5c8Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
172895b7a5c8Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
172995b7a5c8Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173095b7a5c8Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
173195b7a5c8Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
173295b7a5c8Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
173395b7a5c8Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
173495b7a5c8Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
173595b7a5c8Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
173695b7a5c8Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
173795b7a5c8Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
173895b7a5c8Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
173995b7a5c8Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174095b7a5c8Smrg	     | midipix* | mingw32* | mingw64* | mint* \
174195b7a5c8Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
174295b7a5c8Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
174395b7a5c8Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
174495b7a5c8Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
174595b7a5c8Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
174695b7a5c8Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
174795b7a5c8Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
174895b7a5c8Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
174995b7a5c8Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175095b7a5c8Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
175195b7a5c8Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
175295b7a5c8Smrg		;;
175395b7a5c8Smrg	# This one is extra strict with allowed versions
175495b7a5c8Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
175595b7a5c8Smrg		# Don't forget version if it is 3.2v4 or newer.
175695b7a5c8Smrg		;;
175795b7a5c8Smrg	none)
175895b7a5c8Smrg		;;
175995b7a5c8Smrg	*)
176095b7a5c8Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
176195b7a5c8Smrg		exit 1
176295b7a5c8Smrg		;;
176395b7a5c8Smrgesac
176495b7a5c8Smrg
176595b7a5c8Smrg# As a final step for OS-related things, validate the OS-kernel combination
176695b7a5c8Smrg# (given a valid OS), if there is a kernel.
176795b7a5c8Smrgcase $kernel-$os in
176895b7a5c8Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
176995b7a5c8Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
177095b7a5c8Smrg		;;
177195b7a5c8Smrg	uclinux-uclibc* )
177295b7a5c8Smrg		;;
177395b7a5c8Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
177495b7a5c8Smrg		# These are just libc implementations, not actual OSes, and thus
177595b7a5c8Smrg		# require a kernel.
177695b7a5c8Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
177795b7a5c8Smrg		exit 1
177895b7a5c8Smrg		;;
177995b7a5c8Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
178095b7a5c8Smrg		;;
178195b7a5c8Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
178295b7a5c8Smrg		;;
178395b7a5c8Smrg	nto-qnx*)
178495b7a5c8Smrg		;;
178595b7a5c8Smrg	os2-emx)
178695b7a5c8Smrg		;;
178795b7a5c8Smrg	*-eabi* | *-gnueabi*)
178895b7a5c8Smrg		;;
178995b7a5c8Smrg	-*)
179095b7a5c8Smrg		# Blank kernel with real OS is always fine.
179195b7a5c8Smrg		;;
179295b7a5c8Smrg	*-*)
179395b7a5c8Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
179495b7a5c8Smrg		exit 1
179595b7a5c8Smrg		;;
179695b7a5c8Smrgesac
179795b7a5c8Smrg
179827702724Smrg# Here we handle the case where we know the os, and the CPU type, but not the
179927702724Smrg# manufacturer.  We pick the logical manufacturer.
180095b7a5c8Smrgcase $vendor in
180195b7a5c8Smrg	unknown)
180295b7a5c8Smrg		case $cpu-$os in
180395b7a5c8Smrg			*-riscix*)
180427702724Smrg				vendor=acorn
180527702724Smrg				;;
180695b7a5c8Smrg			*-sunos*)
180727702724Smrg				vendor=sun
180827702724Smrg				;;
180995b7a5c8Smrg			*-cnk* | *-aix*)
181027702724Smrg				vendor=ibm
181127702724Smrg				;;
181295b7a5c8Smrg			*-beos*)
181327702724Smrg				vendor=be
181427702724Smrg				;;
181595b7a5c8Smrg			*-hpux*)
181627702724Smrg				vendor=hp
181727702724Smrg				;;
181895b7a5c8Smrg			*-mpeix*)
181927702724Smrg				vendor=hp
182027702724Smrg				;;
182195b7a5c8Smrg			*-hiux*)
182227702724Smrg				vendor=hitachi
182327702724Smrg				;;
182495b7a5c8Smrg			*-unos*)
182527702724Smrg				vendor=crds
182627702724Smrg				;;
182795b7a5c8Smrg			*-dgux*)
182827702724Smrg				vendor=dg
182927702724Smrg				;;
183095b7a5c8Smrg			*-luna*)
183127702724Smrg				vendor=omron
183227702724Smrg				;;
183395b7a5c8Smrg			*-genix*)
183427702724Smrg				vendor=ns
183527702724Smrg				;;
183695b7a5c8Smrg			*-clix*)
183795b7a5c8Smrg				vendor=intergraph
183895b7a5c8Smrg				;;
183995b7a5c8Smrg			*-mvs* | *-opened*)
184095b7a5c8Smrg				vendor=ibm
184195b7a5c8Smrg				;;
184295b7a5c8Smrg			*-os400*)
184327702724Smrg				vendor=ibm
184427702724Smrg				;;
184595b7a5c8Smrg			s390-* | s390x-*)
184627702724Smrg				vendor=ibm
184727702724Smrg				;;
184895b7a5c8Smrg			*-ptx*)
184927702724Smrg				vendor=sequent
185027702724Smrg				;;
185195b7a5c8Smrg			*-tpf*)
185227702724Smrg				vendor=ibm
185327702724Smrg				;;
185495b7a5c8Smrg			*-vxsim* | *-vxworks* | *-windiss*)
185527702724Smrg				vendor=wrs
185627702724Smrg				;;
185795b7a5c8Smrg			*-aux*)
185827702724Smrg				vendor=apple
185927702724Smrg				;;
186095b7a5c8Smrg			*-hms*)
186127702724Smrg				vendor=hitachi
186227702724Smrg				;;
186395b7a5c8Smrg			*-mpw* | *-macos*)
186427702724Smrg				vendor=apple
186527702724Smrg				;;
186695b7a5c8Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
186727702724Smrg				vendor=atari
186827702724Smrg				;;
186995b7a5c8Smrg			*-vos*)
187027702724Smrg				vendor=stratus
187127702724Smrg				;;
187227702724Smrg		esac
187327702724Smrg		;;
187427702724Smrgesac
187527702724Smrg
187695b7a5c8Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
187727702724Smrgexit
187827702724Smrg
187927702724Smrg# Local variables:
188095b7a5c8Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
188127702724Smrg# time-stamp-start: "timestamp='"
188227702724Smrg# time-stamp-format: "%:y-%02m-%02d"
188327702724Smrg# time-stamp-end: "'"
188427702724Smrg# End:
1885