15dfecf96Smrg#! /bin/sh
25dfecf96Smrg# Configuration validation subroutine script.
3c2cbb186Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
45dfecf96Smrg
596d43ffdSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
696d43ffdSmrg
7c2cbb186Smrgtimestamp='2023-01-21'
85dfecf96Smrg
9f765521fSmrg# This file is free software; you can redistribute it and/or modify it
10f765521fSmrg# under the terms of the GNU General Public License as published by
11c2cbb186Smrg# the Free Software Foundation, either version 3 of the License, or
125dfecf96Smrg# (at your option) any later version.
135dfecf96Smrg#
14f765521fSmrg# This program is distributed in the hope that it will be useful, but
15f765521fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16f765521fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17f765521fSmrg# General Public License for more details.
185dfecf96Smrg#
195dfecf96Smrg# You should have received a copy of the GNU General Public License
2096d43ffdSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
215dfecf96Smrg#
225dfecf96Smrg# As a special exception to the GNU General Public License, if you
235dfecf96Smrg# distribute this file as part of a program that contains a
245dfecf96Smrg# configuration script generated by Autoconf, you may include it under
25f765521fSmrg# the same distribution terms that you use for the rest of that
26f765521fSmrg# program.  This Exception is an additional permission under section 7
27f765521fSmrg# of the GNU General Public License, version 3 ("GPLv3").
285dfecf96Smrg
295dfecf96Smrg
3096d43ffdSmrg# Please send patches to <config-patches@gnu.org>.
315dfecf96Smrg#
325dfecf96Smrg# Configuration subroutine to validate and canonicalize a configuration type.
335dfecf96Smrg# Supply the specified configuration type as an argument.
345dfecf96Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
355dfecf96Smrg# Otherwise, we print the canonical config type on stdout and succeed.
365dfecf96Smrg
37c05e22d7Smrg# You can get the latest version of this script from:
3896d43ffdSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39c05e22d7Smrg
405dfecf96Smrg# This file is supposed to be the same for all GNU packages
415dfecf96Smrg# and recognize all the CPU types, system types and aliases
425dfecf96Smrg# that are meaningful with *any* GNU software.
435dfecf96Smrg# Each package is responsible for reporting which valid configurations
445dfecf96Smrg# it does not support.  The user should be able to distinguish
455dfecf96Smrg# a failure to support a valid configuration from a meaningless
465dfecf96Smrg# configuration.
475dfecf96Smrg
485dfecf96Smrg# The goal of this file is to map all the various variations of a given
495dfecf96Smrg# machine specification into a single specification in the form:
505dfecf96Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
515dfecf96Smrg# or in some cases, the newer four-part form:
525dfecf96Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
535dfecf96Smrg# It is wrong to echo any other type of specification.
545dfecf96Smrg
5596d43ffdSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
5696d43ffdSmrg# about features and limitations of the classic Bourne shell that were
5796d43ffdSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
5896d43ffdSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
5996d43ffdSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
6096d43ffdSmrg# have a pre-POSIX /bin/sh.
6196d43ffdSmrg
625dfecf96Smrgme=`echo "$0" | sed -e 's,.*/,,'`
635dfecf96Smrg
645dfecf96Smrgusage="\
6596d43ffdSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
665dfecf96Smrg
675dfecf96SmrgCanonicalize a configuration name.
685dfecf96Smrg
6996d43ffdSmrgOptions:
705dfecf96Smrg  -h, --help         print this help, then exit
715dfecf96Smrg  -t, --time-stamp   print date of last modification, then exit
725dfecf96Smrg  -v, --version      print version number, then exit
735dfecf96Smrg
745dfecf96SmrgReport bugs and patches to <config-patches@gnu.org>."
755dfecf96Smrg
765dfecf96Smrgversion="\
775dfecf96SmrgGNU config.sub ($timestamp)
785dfecf96Smrg
79c2cbb186SmrgCopyright 1992-2023 Free Software Foundation, Inc.
805dfecf96Smrg
815dfecf96SmrgThis is free software; see the source for copying conditions.  There is NO
825dfecf96Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
835dfecf96Smrg
845dfecf96Smrghelp="
855dfecf96SmrgTry \`$me --help' for more information."
865dfecf96Smrg
875dfecf96Smrg# Parse command line
885dfecf96Smrgwhile test $# -gt 0 ; do
895dfecf96Smrg  case $1 in
905dfecf96Smrg    --time-stamp | --time* | -t )
915dfecf96Smrg       echo "$timestamp" ; exit ;;
925dfecf96Smrg    --version | -v )
935dfecf96Smrg       echo "$version" ; exit ;;
945dfecf96Smrg    --help | --h* | -h )
955dfecf96Smrg       echo "$usage"; exit ;;
965dfecf96Smrg    -- )     # Stop option processing
975dfecf96Smrg       shift; break ;;
985dfecf96Smrg    - )	# Use stdin as input.
995dfecf96Smrg       break ;;
1005dfecf96Smrg    -* )
10196d43ffdSmrg       echo "$me: invalid option $1$help" >&2
1025dfecf96Smrg       exit 1 ;;
1035dfecf96Smrg
1045dfecf96Smrg    *local*)
1055dfecf96Smrg       # First pass through any local machine types.
10696d43ffdSmrg       echo "$1"
1075dfecf96Smrg       exit ;;
1085dfecf96Smrg
1095dfecf96Smrg    * )
1105dfecf96Smrg       break ;;
1115dfecf96Smrg  esac
1125dfecf96Smrgdone
1135dfecf96Smrg
1145dfecf96Smrgcase $# in
1155dfecf96Smrg 0) echo "$me: missing argument$help" >&2
1165dfecf96Smrg    exit 1;;
1175dfecf96Smrg 1) ;;
1185dfecf96Smrg *) echo "$me: too many arguments$help" >&2
1195dfecf96Smrg    exit 1;;
1205dfecf96Smrgesac
1215dfecf96Smrg
12296d43ffdSmrg# Split fields of configuration type
12396d43ffdSmrg# shellcheck disable=SC2162
12496d43ffdSmrgsaved_IFS=$IFS
12596d43ffdSmrgIFS="-" read field1 field2 field3 field4 <<EOF
12696d43ffdSmrg$1
12796d43ffdSmrgEOF
12896d43ffdSmrgIFS=$saved_IFS
1295dfecf96Smrg
13096d43ffdSmrg# Separate into logical components for further validation
13196d43ffdSmrgcase $1 in
13296d43ffdSmrg	*-*-*-*-*)
13396d43ffdSmrg		echo Invalid configuration \`"$1"\': more than four components >&2
13496d43ffdSmrg		exit 1
1355dfecf96Smrg		;;
13696d43ffdSmrg	*-*-*-*)
13796d43ffdSmrg		basic_machine=$field1-$field2
13896d43ffdSmrg		basic_os=$field3-$field4
1395dfecf96Smrg		;;
14096d43ffdSmrg	*-*-*)
14196d43ffdSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14296d43ffdSmrg		# parts
14396d43ffdSmrg		maybe_os=$field2-$field3
14496d43ffdSmrg		case $maybe_os in
14596d43ffdSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
14696d43ffdSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14796d43ffdSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148c2cbb186Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
14996d43ffdSmrg				basic_machine=$field1
15096d43ffdSmrg				basic_os=$maybe_os
15196d43ffdSmrg				;;
15296d43ffdSmrg			android-linux)
15396d43ffdSmrg				basic_machine=$field1-unknown
15496d43ffdSmrg				basic_os=linux-android
15596d43ffdSmrg				;;
15696d43ffdSmrg			*)
15796d43ffdSmrg				basic_machine=$field1-$field2
15896d43ffdSmrg				basic_os=$field3
15996d43ffdSmrg				;;
16096d43ffdSmrg		esac
1615dfecf96Smrg		;;
16296d43ffdSmrg	*-*)
16396d43ffdSmrg		# A lone config we happen to match not fitting any pattern
16496d43ffdSmrg		case $field1-$field2 in
16596d43ffdSmrg			decstation-3100)
16696d43ffdSmrg				basic_machine=mips-dec
16796d43ffdSmrg				basic_os=
16896d43ffdSmrg				;;
16996d43ffdSmrg			*-*)
17096d43ffdSmrg				# Second component is usually, but not always the OS
17196d43ffdSmrg				case $field2 in
17296d43ffdSmrg					# Prevent following clause from handling this valid os
17396d43ffdSmrg					sun*os*)
17496d43ffdSmrg						basic_machine=$field1
17596d43ffdSmrg						basic_os=$field2
17696d43ffdSmrg						;;
17796d43ffdSmrg					zephyr*)
17896d43ffdSmrg						basic_machine=$field1-unknown
17996d43ffdSmrg						basic_os=$field2
18096d43ffdSmrg						;;
18196d43ffdSmrg					# Manufacturers
18296d43ffdSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18396d43ffdSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18496d43ffdSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18596d43ffdSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18696d43ffdSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18796d43ffdSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
18896d43ffdSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
18996d43ffdSmrg					| microblaze* | sim | cisco \
19096d43ffdSmrg					| oki | wec | wrs | winbond)
19196d43ffdSmrg						basic_machine=$field1-$field2
19296d43ffdSmrg						basic_os=
19396d43ffdSmrg						;;
19496d43ffdSmrg					*)
19596d43ffdSmrg						basic_machine=$field1
19696d43ffdSmrg						basic_os=$field2
19796d43ffdSmrg						;;
19896d43ffdSmrg				esac
19996d43ffdSmrg			;;
20096d43ffdSmrg		esac
2015dfecf96Smrg		;;
20296d43ffdSmrg	*)
20396d43ffdSmrg		# Convert single-component short-hands not valid as part of
20496d43ffdSmrg		# multi-component configurations.
20596d43ffdSmrg		case $field1 in
20696d43ffdSmrg			386bsd)
20796d43ffdSmrg				basic_machine=i386-pc
20896d43ffdSmrg				basic_os=bsd
20996d43ffdSmrg				;;
21096d43ffdSmrg			a29khif)
21196d43ffdSmrg				basic_machine=a29k-amd
21296d43ffdSmrg				basic_os=udi
21396d43ffdSmrg				;;
21496d43ffdSmrg			adobe68k)
21596d43ffdSmrg				basic_machine=m68010-adobe
21696d43ffdSmrg				basic_os=scout
21796d43ffdSmrg				;;
21896d43ffdSmrg			alliant)
21996d43ffdSmrg				basic_machine=fx80-alliant
22096d43ffdSmrg				basic_os=
22196d43ffdSmrg				;;
22296d43ffdSmrg			altos | altos3068)
22396d43ffdSmrg				basic_machine=m68k-altos
22496d43ffdSmrg				basic_os=
22596d43ffdSmrg				;;
22696d43ffdSmrg			am29k)
22796d43ffdSmrg				basic_machine=a29k-none
22896d43ffdSmrg				basic_os=bsd
22996d43ffdSmrg				;;
23096d43ffdSmrg			amdahl)
23196d43ffdSmrg				basic_machine=580-amdahl
23296d43ffdSmrg				basic_os=sysv
23396d43ffdSmrg				;;
23496d43ffdSmrg			amiga)
23596d43ffdSmrg				basic_machine=m68k-unknown
23696d43ffdSmrg				basic_os=
23796d43ffdSmrg				;;
23896d43ffdSmrg			amigaos | amigados)
23996d43ffdSmrg				basic_machine=m68k-unknown
24096d43ffdSmrg				basic_os=amigaos
24196d43ffdSmrg				;;
24296d43ffdSmrg			amigaunix | amix)
24396d43ffdSmrg				basic_machine=m68k-unknown
24496d43ffdSmrg				basic_os=sysv4
24596d43ffdSmrg				;;
24696d43ffdSmrg			apollo68)
24796d43ffdSmrg				basic_machine=m68k-apollo
24896d43ffdSmrg				basic_os=sysv
24996d43ffdSmrg				;;
25096d43ffdSmrg			apollo68bsd)
25196d43ffdSmrg				basic_machine=m68k-apollo
25296d43ffdSmrg				basic_os=bsd
25396d43ffdSmrg				;;
25496d43ffdSmrg			aros)
25596d43ffdSmrg				basic_machine=i386-pc
25696d43ffdSmrg				basic_os=aros
25796d43ffdSmrg				;;
25896d43ffdSmrg			aux)
25996d43ffdSmrg				basic_machine=m68k-apple
26096d43ffdSmrg				basic_os=aux
26196d43ffdSmrg				;;
26296d43ffdSmrg			balance)
26396d43ffdSmrg				basic_machine=ns32k-sequent
26496d43ffdSmrg				basic_os=dynix
26596d43ffdSmrg				;;
26696d43ffdSmrg			blackfin)
26796d43ffdSmrg				basic_machine=bfin-unknown
26896d43ffdSmrg				basic_os=linux
26996d43ffdSmrg				;;
27096d43ffdSmrg			cegcc)
27196d43ffdSmrg				basic_machine=arm-unknown
27296d43ffdSmrg				basic_os=cegcc
27396d43ffdSmrg				;;
27496d43ffdSmrg			convex-c1)
27596d43ffdSmrg				basic_machine=c1-convex
27696d43ffdSmrg				basic_os=bsd
27796d43ffdSmrg				;;
27896d43ffdSmrg			convex-c2)
27996d43ffdSmrg				basic_machine=c2-convex
28096d43ffdSmrg				basic_os=bsd
28196d43ffdSmrg				;;
28296d43ffdSmrg			convex-c32)
28396d43ffdSmrg				basic_machine=c32-convex
28496d43ffdSmrg				basic_os=bsd
28596d43ffdSmrg				;;
28696d43ffdSmrg			convex-c34)
28796d43ffdSmrg				basic_machine=c34-convex
28896d43ffdSmrg				basic_os=bsd
28996d43ffdSmrg				;;
29096d43ffdSmrg			convex-c38)
29196d43ffdSmrg				basic_machine=c38-convex
29296d43ffdSmrg				basic_os=bsd
29396d43ffdSmrg				;;
29496d43ffdSmrg			cray)
29596d43ffdSmrg				basic_machine=j90-cray
29696d43ffdSmrg				basic_os=unicos
29796d43ffdSmrg				;;
29896d43ffdSmrg			crds | unos)
29996d43ffdSmrg				basic_machine=m68k-crds
30096d43ffdSmrg				basic_os=
30196d43ffdSmrg				;;
30296d43ffdSmrg			da30)
30396d43ffdSmrg				basic_machine=m68k-da30
30496d43ffdSmrg				basic_os=
30596d43ffdSmrg				;;
30696d43ffdSmrg			decstation | pmax | pmin | dec3100 | decstatn)
30796d43ffdSmrg				basic_machine=mips-dec
30896d43ffdSmrg				basic_os=
30996d43ffdSmrg				;;
31096d43ffdSmrg			delta88)
31196d43ffdSmrg				basic_machine=m88k-motorola
31296d43ffdSmrg				basic_os=sysv3
31396d43ffdSmrg				;;
31496d43ffdSmrg			dicos)
31596d43ffdSmrg				basic_machine=i686-pc
31696d43ffdSmrg				basic_os=dicos
31796d43ffdSmrg				;;
31896d43ffdSmrg			djgpp)
31996d43ffdSmrg				basic_machine=i586-pc
32096d43ffdSmrg				basic_os=msdosdjgpp
32196d43ffdSmrg				;;
32296d43ffdSmrg			ebmon29k)
32396d43ffdSmrg				basic_machine=a29k-amd
32496d43ffdSmrg				basic_os=ebmon
32596d43ffdSmrg				;;
32696d43ffdSmrg			es1800 | OSE68k | ose68k | ose | OSE)
32796d43ffdSmrg				basic_machine=m68k-ericsson
32896d43ffdSmrg				basic_os=ose
32996d43ffdSmrg				;;
33096d43ffdSmrg			gmicro)
33196d43ffdSmrg				basic_machine=tron-gmicro
33296d43ffdSmrg				basic_os=sysv
33396d43ffdSmrg				;;
33496d43ffdSmrg			go32)
33596d43ffdSmrg				basic_machine=i386-pc
33696d43ffdSmrg				basic_os=go32
33796d43ffdSmrg				;;
33896d43ffdSmrg			h8300hms)
33996d43ffdSmrg				basic_machine=h8300-hitachi
34096d43ffdSmrg				basic_os=hms
34196d43ffdSmrg				;;
34296d43ffdSmrg			h8300xray)
34396d43ffdSmrg				basic_machine=h8300-hitachi
34496d43ffdSmrg				basic_os=xray
34596d43ffdSmrg				;;
34696d43ffdSmrg			h8500hms)
34796d43ffdSmrg				basic_machine=h8500-hitachi
34896d43ffdSmrg				basic_os=hms
34996d43ffdSmrg				;;
35096d43ffdSmrg			harris)
35196d43ffdSmrg				basic_machine=m88k-harris
35296d43ffdSmrg				basic_os=sysv3
35396d43ffdSmrg				;;
35496d43ffdSmrg			hp300 | hp300hpux)
35596d43ffdSmrg				basic_machine=m68k-hp
35696d43ffdSmrg				basic_os=hpux
35796d43ffdSmrg				;;
35896d43ffdSmrg			hp300bsd)
35996d43ffdSmrg				basic_machine=m68k-hp
36096d43ffdSmrg				basic_os=bsd
36196d43ffdSmrg				;;
36296d43ffdSmrg			hppaosf)
36396d43ffdSmrg				basic_machine=hppa1.1-hp
36496d43ffdSmrg				basic_os=osf
36596d43ffdSmrg				;;
36696d43ffdSmrg			hppro)
36796d43ffdSmrg				basic_machine=hppa1.1-hp
36896d43ffdSmrg				basic_os=proelf
36996d43ffdSmrg				;;
37096d43ffdSmrg			i386mach)
37196d43ffdSmrg				basic_machine=i386-mach
37296d43ffdSmrg				basic_os=mach
37396d43ffdSmrg				;;
37496d43ffdSmrg			isi68 | isi)
37596d43ffdSmrg				basic_machine=m68k-isi
37696d43ffdSmrg				basic_os=sysv
37796d43ffdSmrg				;;
37896d43ffdSmrg			m68knommu)
37996d43ffdSmrg				basic_machine=m68k-unknown
38096d43ffdSmrg				basic_os=linux
38196d43ffdSmrg				;;
38296d43ffdSmrg			magnum | m3230)
38396d43ffdSmrg				basic_machine=mips-mips
38496d43ffdSmrg				basic_os=sysv
38596d43ffdSmrg				;;
38696d43ffdSmrg			merlin)
38796d43ffdSmrg				basic_machine=ns32k-utek
38896d43ffdSmrg				basic_os=sysv
38996d43ffdSmrg				;;
39096d43ffdSmrg			mingw64)
39196d43ffdSmrg				basic_machine=x86_64-pc
39296d43ffdSmrg				basic_os=mingw64
39396d43ffdSmrg				;;
39496d43ffdSmrg			mingw32)
39596d43ffdSmrg				basic_machine=i686-pc
39696d43ffdSmrg				basic_os=mingw32
39796d43ffdSmrg				;;
39896d43ffdSmrg			mingw32ce)
39996d43ffdSmrg				basic_machine=arm-unknown
40096d43ffdSmrg				basic_os=mingw32ce
40196d43ffdSmrg				;;
40296d43ffdSmrg			monitor)
40396d43ffdSmrg				basic_machine=m68k-rom68k
40496d43ffdSmrg				basic_os=coff
40596d43ffdSmrg				;;
40696d43ffdSmrg			morphos)
40796d43ffdSmrg				basic_machine=powerpc-unknown
40896d43ffdSmrg				basic_os=morphos
40996d43ffdSmrg				;;
41096d43ffdSmrg			moxiebox)
41196d43ffdSmrg				basic_machine=moxie-unknown
41296d43ffdSmrg				basic_os=moxiebox
41396d43ffdSmrg				;;
41496d43ffdSmrg			msdos)
41596d43ffdSmrg				basic_machine=i386-pc
41696d43ffdSmrg				basic_os=msdos
41796d43ffdSmrg				;;
41896d43ffdSmrg			msys)
41996d43ffdSmrg				basic_machine=i686-pc
42096d43ffdSmrg				basic_os=msys
42196d43ffdSmrg				;;
42296d43ffdSmrg			mvs)
42396d43ffdSmrg				basic_machine=i370-ibm
42496d43ffdSmrg				basic_os=mvs
42596d43ffdSmrg				;;
42696d43ffdSmrg			nacl)
42796d43ffdSmrg				basic_machine=le32-unknown
42896d43ffdSmrg				basic_os=nacl
42996d43ffdSmrg				;;
43096d43ffdSmrg			ncr3000)
43196d43ffdSmrg				basic_machine=i486-ncr
43296d43ffdSmrg				basic_os=sysv4
43396d43ffdSmrg				;;
43496d43ffdSmrg			netbsd386)
43596d43ffdSmrg				basic_machine=i386-pc
43696d43ffdSmrg				basic_os=netbsd
43796d43ffdSmrg				;;
43896d43ffdSmrg			netwinder)
43996d43ffdSmrg				basic_machine=armv4l-rebel
44096d43ffdSmrg				basic_os=linux
44196d43ffdSmrg				;;
44296d43ffdSmrg			news | news700 | news800 | news900)
44396d43ffdSmrg				basic_machine=m68k-sony
44496d43ffdSmrg				basic_os=newsos
44596d43ffdSmrg				;;
44696d43ffdSmrg			news1000)
44796d43ffdSmrg				basic_machine=m68030-sony
44896d43ffdSmrg				basic_os=newsos
44996d43ffdSmrg				;;
45096d43ffdSmrg			necv70)
45196d43ffdSmrg				basic_machine=v70-nec
45296d43ffdSmrg				basic_os=sysv
45396d43ffdSmrg				;;
45496d43ffdSmrg			nh3000)
45596d43ffdSmrg				basic_machine=m68k-harris
45696d43ffdSmrg				basic_os=cxux
45796d43ffdSmrg				;;
45896d43ffdSmrg			nh[45]000)
45996d43ffdSmrg				basic_machine=m88k-harris
46096d43ffdSmrg				basic_os=cxux
46196d43ffdSmrg				;;
46296d43ffdSmrg			nindy960)
46396d43ffdSmrg				basic_machine=i960-intel
46496d43ffdSmrg				basic_os=nindy
46596d43ffdSmrg				;;
46696d43ffdSmrg			mon960)
46796d43ffdSmrg				basic_machine=i960-intel
46896d43ffdSmrg				basic_os=mon960
46996d43ffdSmrg				;;
47096d43ffdSmrg			nonstopux)
47196d43ffdSmrg				basic_machine=mips-compaq
47296d43ffdSmrg				basic_os=nonstopux
47396d43ffdSmrg				;;
47496d43ffdSmrg			os400)
47596d43ffdSmrg				basic_machine=powerpc-ibm
47696d43ffdSmrg				basic_os=os400
47796d43ffdSmrg				;;
47896d43ffdSmrg			OSE68000 | ose68000)
47996d43ffdSmrg				basic_machine=m68000-ericsson
48096d43ffdSmrg				basic_os=ose
48196d43ffdSmrg				;;
48296d43ffdSmrg			os68k)
48396d43ffdSmrg				basic_machine=m68k-none
48496d43ffdSmrg				basic_os=os68k
48596d43ffdSmrg				;;
48696d43ffdSmrg			paragon)
48796d43ffdSmrg				basic_machine=i860-intel
48896d43ffdSmrg				basic_os=osf
48996d43ffdSmrg				;;
49096d43ffdSmrg			parisc)
49196d43ffdSmrg				basic_machine=hppa-unknown
49296d43ffdSmrg				basic_os=linux
49396d43ffdSmrg				;;
49496d43ffdSmrg			psp)
49596d43ffdSmrg				basic_machine=mipsallegrexel-sony
49696d43ffdSmrg				basic_os=psp
49796d43ffdSmrg				;;
49896d43ffdSmrg			pw32)
49996d43ffdSmrg				basic_machine=i586-unknown
50096d43ffdSmrg				basic_os=pw32
50196d43ffdSmrg				;;
50296d43ffdSmrg			rdos | rdos64)
50396d43ffdSmrg				basic_machine=x86_64-pc
50496d43ffdSmrg				basic_os=rdos
50596d43ffdSmrg				;;
50696d43ffdSmrg			rdos32)
50796d43ffdSmrg				basic_machine=i386-pc
50896d43ffdSmrg				basic_os=rdos
50996d43ffdSmrg				;;
51096d43ffdSmrg			rom68k)
51196d43ffdSmrg				basic_machine=m68k-rom68k
51296d43ffdSmrg				basic_os=coff
51396d43ffdSmrg				;;
51496d43ffdSmrg			sa29200)
51596d43ffdSmrg				basic_machine=a29k-amd
51696d43ffdSmrg				basic_os=udi
51796d43ffdSmrg				;;
51896d43ffdSmrg			sei)
51996d43ffdSmrg				basic_machine=mips-sei
52096d43ffdSmrg				basic_os=seiux
52196d43ffdSmrg				;;
52296d43ffdSmrg			sequent)
52396d43ffdSmrg				basic_machine=i386-sequent
52496d43ffdSmrg				basic_os=
52596d43ffdSmrg				;;
52696d43ffdSmrg			sps7)
52796d43ffdSmrg				basic_machine=m68k-bull
52896d43ffdSmrg				basic_os=sysv2
52996d43ffdSmrg				;;
53096d43ffdSmrg			st2000)
53196d43ffdSmrg				basic_machine=m68k-tandem
53296d43ffdSmrg				basic_os=
53396d43ffdSmrg				;;
53496d43ffdSmrg			stratus)
53596d43ffdSmrg				basic_machine=i860-stratus
53696d43ffdSmrg				basic_os=sysv4
53796d43ffdSmrg				;;
53896d43ffdSmrg			sun2)
53996d43ffdSmrg				basic_machine=m68000-sun
54096d43ffdSmrg				basic_os=
54196d43ffdSmrg				;;
54296d43ffdSmrg			sun2os3)
54396d43ffdSmrg				basic_machine=m68000-sun
54496d43ffdSmrg				basic_os=sunos3
54596d43ffdSmrg				;;
54696d43ffdSmrg			sun2os4)
54796d43ffdSmrg				basic_machine=m68000-sun
54896d43ffdSmrg				basic_os=sunos4
54996d43ffdSmrg				;;
55096d43ffdSmrg			sun3)
55196d43ffdSmrg				basic_machine=m68k-sun
55296d43ffdSmrg				basic_os=
55396d43ffdSmrg				;;
55496d43ffdSmrg			sun3os3)
55596d43ffdSmrg				basic_machine=m68k-sun
55696d43ffdSmrg				basic_os=sunos3
55796d43ffdSmrg				;;
55896d43ffdSmrg			sun3os4)
55996d43ffdSmrg				basic_machine=m68k-sun
56096d43ffdSmrg				basic_os=sunos4
56196d43ffdSmrg				;;
56296d43ffdSmrg			sun4)
56396d43ffdSmrg				basic_machine=sparc-sun
56496d43ffdSmrg				basic_os=
56596d43ffdSmrg				;;
56696d43ffdSmrg			sun4os3)
56796d43ffdSmrg				basic_machine=sparc-sun
56896d43ffdSmrg				basic_os=sunos3
56996d43ffdSmrg				;;
57096d43ffdSmrg			sun4os4)
57196d43ffdSmrg				basic_machine=sparc-sun
57296d43ffdSmrg				basic_os=sunos4
57396d43ffdSmrg				;;
57496d43ffdSmrg			sun4sol2)
57596d43ffdSmrg				basic_machine=sparc-sun
57696d43ffdSmrg				basic_os=solaris2
57796d43ffdSmrg				;;
57896d43ffdSmrg			sun386 | sun386i | roadrunner)
57996d43ffdSmrg				basic_machine=i386-sun
58096d43ffdSmrg				basic_os=
58196d43ffdSmrg				;;
58296d43ffdSmrg			sv1)
58396d43ffdSmrg				basic_machine=sv1-cray
58496d43ffdSmrg				basic_os=unicos
58596d43ffdSmrg				;;
58696d43ffdSmrg			symmetry)
58796d43ffdSmrg				basic_machine=i386-sequent
58896d43ffdSmrg				basic_os=dynix
58996d43ffdSmrg				;;
59096d43ffdSmrg			t3e)
59196d43ffdSmrg				basic_machine=alphaev5-cray
59296d43ffdSmrg				basic_os=unicos
59396d43ffdSmrg				;;
59496d43ffdSmrg			t90)
59596d43ffdSmrg				basic_machine=t90-cray
59696d43ffdSmrg				basic_os=unicos
59796d43ffdSmrg				;;
59896d43ffdSmrg			toad1)
59996d43ffdSmrg				basic_machine=pdp10-xkl
60096d43ffdSmrg				basic_os=tops20
60196d43ffdSmrg				;;
60296d43ffdSmrg			tpf)
60396d43ffdSmrg				basic_machine=s390x-ibm
60496d43ffdSmrg				basic_os=tpf
60596d43ffdSmrg				;;
60696d43ffdSmrg			udi29k)
60796d43ffdSmrg				basic_machine=a29k-amd
60896d43ffdSmrg				basic_os=udi
60996d43ffdSmrg				;;
61096d43ffdSmrg			ultra3)
61196d43ffdSmrg				basic_machine=a29k-nyu
61296d43ffdSmrg				basic_os=sym1
61396d43ffdSmrg				;;
61496d43ffdSmrg			v810 | necv810)
61596d43ffdSmrg				basic_machine=v810-nec
61696d43ffdSmrg				basic_os=none
61796d43ffdSmrg				;;
61896d43ffdSmrg			vaxv)
61996d43ffdSmrg				basic_machine=vax-dec
62096d43ffdSmrg				basic_os=sysv
62196d43ffdSmrg				;;
62296d43ffdSmrg			vms)
62396d43ffdSmrg				basic_machine=vax-dec
62496d43ffdSmrg				basic_os=vms
62596d43ffdSmrg				;;
62696d43ffdSmrg			vsta)
62796d43ffdSmrg				basic_machine=i386-pc
62896d43ffdSmrg				basic_os=vsta
62996d43ffdSmrg				;;
63096d43ffdSmrg			vxworks960)
63196d43ffdSmrg				basic_machine=i960-wrs
63296d43ffdSmrg				basic_os=vxworks
63396d43ffdSmrg				;;
63496d43ffdSmrg			vxworks68)
63596d43ffdSmrg				basic_machine=m68k-wrs
63696d43ffdSmrg				basic_os=vxworks
63796d43ffdSmrg				;;
63896d43ffdSmrg			vxworks29k)
63996d43ffdSmrg				basic_machine=a29k-wrs
64096d43ffdSmrg				basic_os=vxworks
64196d43ffdSmrg				;;
64296d43ffdSmrg			xbox)
64396d43ffdSmrg				basic_machine=i686-pc
64496d43ffdSmrg				basic_os=mingw32
64596d43ffdSmrg				;;
64696d43ffdSmrg			ymp)
64796d43ffdSmrg				basic_machine=ymp-cray
64896d43ffdSmrg				basic_os=unicos
64996d43ffdSmrg				;;
65096d43ffdSmrg			*)
65196d43ffdSmrg				basic_machine=$1
65296d43ffdSmrg				basic_os=
65396d43ffdSmrg				;;
65496d43ffdSmrg		esac
6555dfecf96Smrg		;;
6565dfecf96Smrgesac
6575dfecf96Smrg
65896d43ffdSmrg# Decode 1-component or ad-hoc basic machines
6595dfecf96Smrgcase $basic_machine in
66096d43ffdSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
66196d43ffdSmrg	# some cases the only manufacturer, in others, it is the most popular.
66296d43ffdSmrg	w89k)
66396d43ffdSmrg		cpu=hppa1.1
66496d43ffdSmrg		vendor=winbond
665f14f4646Smrg		;;
66696d43ffdSmrg	op50n)
66796d43ffdSmrg		cpu=hppa1.1
66896d43ffdSmrg		vendor=oki
66931de2854Smrg		;;
67096d43ffdSmrg	op60c)
67196d43ffdSmrg		cpu=hppa1.1
67296d43ffdSmrg		vendor=oki
673f765521fSmrg		;;
67496d43ffdSmrg	ibm*)
67596d43ffdSmrg		cpu=i370
67696d43ffdSmrg		vendor=ibm
67731de2854Smrg		;;
67896d43ffdSmrg	orion105)
67996d43ffdSmrg		cpu=clipper
68096d43ffdSmrg		vendor=highlevel
68131de2854Smrg		;;
68296d43ffdSmrg	mac | mpw | mac-mpw)
68396d43ffdSmrg		cpu=m68k
68496d43ffdSmrg		vendor=apple
6855dfecf96Smrg		;;
68696d43ffdSmrg	pmac | pmac-mpw)
68796d43ffdSmrg		cpu=powerpc
68896d43ffdSmrg		vendor=apple
6895dfecf96Smrg		;;
69096d43ffdSmrg
6915dfecf96Smrg	# Recognize the various machine names and aliases which stand
6925dfecf96Smrg	# for a CPU type and a company and sometimes even an OS.
6935dfecf96Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69496d43ffdSmrg		cpu=m68000
69596d43ffdSmrg		vendor=att
6965dfecf96Smrg		;;
6975dfecf96Smrg	3b*)
69896d43ffdSmrg		cpu=we32k
69996d43ffdSmrg		vendor=att
700f14f4646Smrg		;;
701c05e22d7Smrg	bluegene*)
70296d43ffdSmrg		cpu=powerpc
70396d43ffdSmrg		vendor=ibm
70496d43ffdSmrg		basic_os=cnk
7055dfecf96Smrg		;;
7065dfecf96Smrg	decsystem10* | dec10*)
70796d43ffdSmrg		cpu=pdp10
70896d43ffdSmrg		vendor=dec
70996d43ffdSmrg		basic_os=tops10
7105dfecf96Smrg		;;
7115dfecf96Smrg	decsystem20* | dec20*)
71296d43ffdSmrg		cpu=pdp10
71396d43ffdSmrg		vendor=dec
71496d43ffdSmrg		basic_os=tops20
7155dfecf96Smrg		;;
7165dfecf96Smrg	delta | 3300 | motorola-3300 | motorola-delta \
7175dfecf96Smrg	      | 3300-motorola | delta-motorola)
71896d43ffdSmrg		cpu=m68k
71996d43ffdSmrg		vendor=motorola
7205dfecf96Smrg		;;
72196d43ffdSmrg	dpx2*)
72296d43ffdSmrg		cpu=m68k
72396d43ffdSmrg		vendor=bull
72496d43ffdSmrg		basic_os=sysv3
7255dfecf96Smrg		;;
7265dfecf96Smrg	encore | umax | mmax)
72796d43ffdSmrg		cpu=ns32k
72896d43ffdSmrg		vendor=encore
7295dfecf96Smrg		;;
73096d43ffdSmrg	elxsi)
73196d43ffdSmrg		cpu=elxsi
73296d43ffdSmrg		vendor=elxsi
73396d43ffdSmrg		basic_os=${basic_os:-bsd}
7345dfecf96Smrg		;;
7355dfecf96Smrg	fx2800)
73696d43ffdSmrg		cpu=i860
73796d43ffdSmrg		vendor=alliant
7385dfecf96Smrg		;;
7395dfecf96Smrg	genix)
74096d43ffdSmrg		cpu=ns32k
74196d43ffdSmrg		vendor=ns
7425dfecf96Smrg		;;
7435dfecf96Smrg	h3050r* | hiux*)
74496d43ffdSmrg		cpu=hppa1.1
74596d43ffdSmrg		vendor=hitachi
74696d43ffdSmrg		basic_os=hiuxwe2
7475dfecf96Smrg		;;
7485dfecf96Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
74996d43ffdSmrg		cpu=hppa1.0
75096d43ffdSmrg		vendor=hp
7515dfecf96Smrg		;;
7525dfecf96Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
75396d43ffdSmrg		cpu=m68000
75496d43ffdSmrg		vendor=hp
7555dfecf96Smrg		;;
7565dfecf96Smrg	hp9k3[2-9][0-9])
75796d43ffdSmrg		cpu=m68k
75896d43ffdSmrg		vendor=hp
7595dfecf96Smrg		;;
7605dfecf96Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76196d43ffdSmrg		cpu=hppa1.0
76296d43ffdSmrg		vendor=hp
7635dfecf96Smrg		;;
7645dfecf96Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76596d43ffdSmrg		cpu=hppa1.1
76696d43ffdSmrg		vendor=hp
7675dfecf96Smrg		;;
7685dfecf96Smrg	hp9k78[0-9] | hp78[0-9])
7695dfecf96Smrg		# FIXME: really hppa2.0-hp
77096d43ffdSmrg		cpu=hppa1.1
77196d43ffdSmrg		vendor=hp
7725dfecf96Smrg		;;
7735dfecf96Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7745dfecf96Smrg		# FIXME: really hppa2.0-hp
77596d43ffdSmrg		cpu=hppa1.1
77696d43ffdSmrg		vendor=hp
7775dfecf96Smrg		;;
7785dfecf96Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
77996d43ffdSmrg		cpu=hppa1.1
78096d43ffdSmrg		vendor=hp
7815dfecf96Smrg		;;
7825dfecf96Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78396d43ffdSmrg		cpu=hppa1.0
78496d43ffdSmrg		vendor=hp
7855dfecf96Smrg		;;
7865dfecf96Smrg	i*86v32)
78796d43ffdSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78896d43ffdSmrg		vendor=pc
78996d43ffdSmrg		basic_os=sysv32
7905dfecf96Smrg		;;
7915dfecf96Smrg	i*86v4*)
79296d43ffdSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79396d43ffdSmrg		vendor=pc
79496d43ffdSmrg		basic_os=sysv4
7955dfecf96Smrg		;;
7965dfecf96Smrg	i*86v)
79796d43ffdSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79896d43ffdSmrg		vendor=pc
79996d43ffdSmrg		basic_os=sysv
8005dfecf96Smrg		;;
8015dfecf96Smrg	i*86sol2)
80296d43ffdSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80396d43ffdSmrg		vendor=pc
80496d43ffdSmrg		basic_os=solaris2
8055dfecf96Smrg		;;
80696d43ffdSmrg	j90 | j90-cray)
80796d43ffdSmrg		cpu=j90
80896d43ffdSmrg		vendor=cray
80996d43ffdSmrg		basic_os=${basic_os:-unicos}
8105dfecf96Smrg		;;
8115dfecf96Smrg	iris | iris4d)
81296d43ffdSmrg		cpu=mips
81396d43ffdSmrg		vendor=sgi
81496d43ffdSmrg		case $basic_os in
81596d43ffdSmrg		    irix*)
8165dfecf96Smrg			;;
8175dfecf96Smrg		    *)
81896d43ffdSmrg			basic_os=irix4
8195dfecf96Smrg			;;
8205dfecf96Smrg		esac
8215dfecf96Smrg		;;
8225dfecf96Smrg	miniframe)
82396d43ffdSmrg		cpu=m68000
82496d43ffdSmrg		vendor=convergent
8255dfecf96Smrg		;;
82696d43ffdSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82796d43ffdSmrg		cpu=m68k
82896d43ffdSmrg		vendor=atari
82996d43ffdSmrg		basic_os=mint
8305dfecf96Smrg		;;
8315dfecf96Smrg	news-3600 | risc-news)
83296d43ffdSmrg		cpu=mips
83396d43ffdSmrg		vendor=sony
83496d43ffdSmrg		basic_os=newsos
83596d43ffdSmrg		;;
83696d43ffdSmrg	next | m*-next)
83796d43ffdSmrg		cpu=m68k
83896d43ffdSmrg		vendor=next
83996d43ffdSmrg		case $basic_os in
84096d43ffdSmrg		    openstep*)
84196d43ffdSmrg		        ;;
84296d43ffdSmrg		    nextstep*)
8435dfecf96Smrg			;;
84496d43ffdSmrg		    ns2*)
84596d43ffdSmrg		      basic_os=nextstep2
8465dfecf96Smrg			;;
8475dfecf96Smrg		    *)
84896d43ffdSmrg		      basic_os=nextstep3
8495dfecf96Smrg			;;
8505dfecf96Smrg		esac
8515dfecf96Smrg		;;
8525dfecf96Smrg	np1)
85396d43ffdSmrg		cpu=np1
85496d43ffdSmrg		vendor=gould
8555dfecf96Smrg		;;
8565dfecf96Smrg	op50n-* | op60c-*)
85796d43ffdSmrg		cpu=hppa1.1
85896d43ffdSmrg		vendor=oki
85996d43ffdSmrg		basic_os=proelf
8605dfecf96Smrg		;;
8615dfecf96Smrg	pa-hitachi)
86296d43ffdSmrg		cpu=hppa1.1
86396d43ffdSmrg		vendor=hitachi
86496d43ffdSmrg		basic_os=hiuxwe2
865f14f4646Smrg		;;
8665dfecf96Smrg	pbd)
86796d43ffdSmrg		cpu=sparc
86896d43ffdSmrg		vendor=tti
8695dfecf96Smrg		;;
8705dfecf96Smrg	pbb)
87196d43ffdSmrg		cpu=m68k
87296d43ffdSmrg		vendor=tti
8735dfecf96Smrg		;;
87496d43ffdSmrg	pc532)
87596d43ffdSmrg		cpu=ns32k
87696d43ffdSmrg		vendor=pc532
8775dfecf96Smrg		;;
8785dfecf96Smrg	pn)
87996d43ffdSmrg		cpu=pn
88096d43ffdSmrg		vendor=gould
8815dfecf96Smrg		;;
88296d43ffdSmrg	power)
88396d43ffdSmrg		cpu=power
88496d43ffdSmrg		vendor=ibm
8855dfecf96Smrg		;;
8865dfecf96Smrg	ps2)
88796d43ffdSmrg		cpu=i386
88896d43ffdSmrg		vendor=ibm
8895dfecf96Smrg		;;
8905dfecf96Smrg	rm[46]00)
89196d43ffdSmrg		cpu=mips
89296d43ffdSmrg		vendor=siemens
8935dfecf96Smrg		;;
8945dfecf96Smrg	rtpc | rtpc-*)
89596d43ffdSmrg		cpu=romp
89696d43ffdSmrg		vendor=ibm
8975dfecf96Smrg		;;
89896d43ffdSmrg	sde)
89996d43ffdSmrg		cpu=mipsisa32
90096d43ffdSmrg		vendor=sde
90196d43ffdSmrg		basic_os=${basic_os:-elf}
9025dfecf96Smrg		;;
90396d43ffdSmrg	simso-wrs)
90496d43ffdSmrg		cpu=sparclite
90596d43ffdSmrg		vendor=wrs
90696d43ffdSmrg		basic_os=vxworks
9075dfecf96Smrg		;;
90896d43ffdSmrg	tower | tower-32)
90996d43ffdSmrg		cpu=m68k
91096d43ffdSmrg		vendor=ncr
911f14f4646Smrg		;;
91296d43ffdSmrg	vpp*|vx|vx-*)
91396d43ffdSmrg		cpu=f301
91496d43ffdSmrg		vendor=fujitsu
9155dfecf96Smrg		;;
91696d43ffdSmrg	w65)
91796d43ffdSmrg		cpu=w65
91896d43ffdSmrg		vendor=wdc
9195dfecf96Smrg		;;
92096d43ffdSmrg	w89k-*)
92196d43ffdSmrg		cpu=hppa1.1
92296d43ffdSmrg		vendor=winbond
92396d43ffdSmrg		basic_os=proelf
9245dfecf96Smrg		;;
92596d43ffdSmrg	none)
92696d43ffdSmrg		cpu=none
92796d43ffdSmrg		vendor=none
928f14f4646Smrg		;;
92996d43ffdSmrg	leon|leon[3-9])
93096d43ffdSmrg		cpu=sparc
93196d43ffdSmrg		vendor=$basic_machine
9325dfecf96Smrg		;;
93396d43ffdSmrg	leon-*|leon[3-9]-*)
93496d43ffdSmrg		cpu=sparc
93596d43ffdSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9365dfecf96Smrg		;;
93796d43ffdSmrg
93896d43ffdSmrg	*-*)
93996d43ffdSmrg		# shellcheck disable=SC2162
94096d43ffdSmrg		saved_IFS=$IFS
94196d43ffdSmrg		IFS="-" read cpu vendor <<EOF
94296d43ffdSmrg$basic_machine
94396d43ffdSmrgEOF
94496d43ffdSmrg		IFS=$saved_IFS
9455dfecf96Smrg		;;
94696d43ffdSmrg	# We use `pc' rather than `unknown'
94796d43ffdSmrg	# because (1) that's what they normally are, and
94896d43ffdSmrg	# (2) the word "unknown" tends to confuse beginning users.
94996d43ffdSmrg	i*86 | x86_64)
95096d43ffdSmrg		cpu=$basic_machine
95196d43ffdSmrg		vendor=pc
9525dfecf96Smrg		;;
95396d43ffdSmrg	# These rules are duplicated from below for sake of the special case above;
95496d43ffdSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
95596d43ffdSmrg	pc98)
95696d43ffdSmrg		cpu=i386
95796d43ffdSmrg		vendor=pc
9585dfecf96Smrg		;;
95996d43ffdSmrg	x64 | amd64)
96096d43ffdSmrg		cpu=x86_64
96196d43ffdSmrg		vendor=pc
9625dfecf96Smrg		;;
96396d43ffdSmrg	# Recognize the basic CPU types without company name.
96496d43ffdSmrg	*)
96596d43ffdSmrg		cpu=$basic_machine
96696d43ffdSmrg		vendor=unknown
96731de2854Smrg		;;
96896d43ffdSmrgesac
96996d43ffdSmrg
97096d43ffdSmrgunset -v basic_machine
97196d43ffdSmrg
97296d43ffdSmrg# Decode basic machines in the full and proper CPU-Company form.
97396d43ffdSmrgcase $cpu-$vendor in
97496d43ffdSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97596d43ffdSmrg	# some cases the only manufacturer, in others, it is the most popular.
97696d43ffdSmrg	craynv-unknown)
97796d43ffdSmrg		vendor=cray
97896d43ffdSmrg		basic_os=${basic_os:-unicosmp}
9795dfecf96Smrg		;;
98096d43ffdSmrg	c90-unknown | c90-cray)
98196d43ffdSmrg		vendor=cray
98296d43ffdSmrg		basic_os=${Basic_os:-unicos}
9835dfecf96Smrg		;;
98496d43ffdSmrg	fx80-unknown)
98596d43ffdSmrg		vendor=alliant
9865dfecf96Smrg		;;
98796d43ffdSmrg	romp-unknown)
98896d43ffdSmrg		vendor=ibm
9895dfecf96Smrg		;;
99096d43ffdSmrg	mmix-unknown)
99196d43ffdSmrg		vendor=knuth
9925dfecf96Smrg		;;
99396d43ffdSmrg	microblaze-unknown | microblazeel-unknown)
99496d43ffdSmrg		vendor=xilinx
9955dfecf96Smrg		;;
99696d43ffdSmrg	rs6000-unknown)
99796d43ffdSmrg		vendor=ibm
9985dfecf96Smrg		;;
99996d43ffdSmrg	vax-unknown)
100096d43ffdSmrg		vendor=dec
10015dfecf96Smrg		;;
100296d43ffdSmrg	pdp11-unknown)
100396d43ffdSmrg		vendor=dec
10045dfecf96Smrg		;;
100596d43ffdSmrg	we32k-unknown)
100696d43ffdSmrg		vendor=att
10075dfecf96Smrg		;;
100896d43ffdSmrg	cydra-unknown)
100996d43ffdSmrg		vendor=cydrome
10105dfecf96Smrg		;;
101196d43ffdSmrg	i370-ibm*)
101296d43ffdSmrg		vendor=ibm
10135dfecf96Smrg		;;
101496d43ffdSmrg	orion-unknown)
101596d43ffdSmrg		vendor=highlevel
10165dfecf96Smrg		;;
101796d43ffdSmrg	xps-unknown | xps100-unknown)
101896d43ffdSmrg		cpu=xps100
101996d43ffdSmrg		vendor=honeywell
10205dfecf96Smrg		;;
102196d43ffdSmrg
102296d43ffdSmrg	# Here we normalize CPU types with a missing or matching vendor
1023c2cbb186Smrg	armh-unknown | armh-alt)
1024c2cbb186Smrg		cpu=armv7l
1025c2cbb186Smrg		vendor=alt
1026c2cbb186Smrg		basic_os=${basic_os:-linux-gnueabihf}
1027c2cbb186Smrg		;;
102896d43ffdSmrg	dpx20-unknown | dpx20-bull)
102996d43ffdSmrg		cpu=rs6000
103096d43ffdSmrg		vendor=bull
103196d43ffdSmrg		basic_os=${basic_os:-bosx}
10325dfecf96Smrg		;;
103396d43ffdSmrg
103496d43ffdSmrg	# Here we normalize CPU types irrespective of the vendor
103596d43ffdSmrg	amd64-*)
103696d43ffdSmrg		cpu=x86_64
1037f14f4646Smrg		;;
103896d43ffdSmrg	blackfin-*)
103996d43ffdSmrg		cpu=bfin
104096d43ffdSmrg		basic_os=linux
10415dfecf96Smrg		;;
104296d43ffdSmrg	c54x-*)
104396d43ffdSmrg		cpu=tic54x
10445dfecf96Smrg		;;
104596d43ffdSmrg	c55x-*)
104696d43ffdSmrg		cpu=tic55x
10475dfecf96Smrg		;;
104896d43ffdSmrg	c6x-*)
104996d43ffdSmrg		cpu=tic6x
10505dfecf96Smrg		;;
105196d43ffdSmrg	e500v[12]-*)
105296d43ffdSmrg		cpu=powerpc
105396d43ffdSmrg		basic_os=${basic_os}"spe"
10545dfecf96Smrg		;;
105596d43ffdSmrg	mips3*-*)
105696d43ffdSmrg		cpu=mips64
10575dfecf96Smrg		;;
105896d43ffdSmrg	ms1-*)
105996d43ffdSmrg		cpu=mt
10605dfecf96Smrg		;;
106196d43ffdSmrg	m68knommu-*)
106296d43ffdSmrg		cpu=m68k
106396d43ffdSmrg		basic_os=linux
10645dfecf96Smrg		;;
106596d43ffdSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106696d43ffdSmrg		cpu=s12z
10675dfecf96Smrg		;;
106896d43ffdSmrg	openrisc-*)
106996d43ffdSmrg		cpu=or32
10705dfecf96Smrg		;;
107196d43ffdSmrg	parisc-*)
107296d43ffdSmrg		cpu=hppa
107396d43ffdSmrg		basic_os=linux
10745dfecf96Smrg		;;
107596d43ffdSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107696d43ffdSmrg		cpu=i586
10775dfecf96Smrg		;;
1078c2cbb186Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
107996d43ffdSmrg		cpu=i686
10805dfecf96Smrg		;;
108196d43ffdSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108296d43ffdSmrg		cpu=i686
10835dfecf96Smrg		;;
108496d43ffdSmrg	pentium4-*)
108596d43ffdSmrg		cpu=i786
10865dfecf96Smrg		;;
108796d43ffdSmrg	pc98-*)
108896d43ffdSmrg		cpu=i386
10895dfecf96Smrg		;;
109096d43ffdSmrg	ppc-* | ppcbe-*)
109196d43ffdSmrg		cpu=powerpc
10925dfecf96Smrg		;;
109396d43ffdSmrg	ppcle-* | powerpclittle-*)
109496d43ffdSmrg		cpu=powerpcle
10955dfecf96Smrg		;;
109696d43ffdSmrg	ppc64-*)
109796d43ffdSmrg		cpu=powerpc64
109831de2854Smrg		;;
109996d43ffdSmrg	ppc64le-* | powerpc64little-*)
110096d43ffdSmrg		cpu=powerpc64le
11015dfecf96Smrg		;;
110296d43ffdSmrg	sb1-*)
110396d43ffdSmrg		cpu=mipsisa64sb1
11045dfecf96Smrg		;;
110596d43ffdSmrg	sb1el-*)
110696d43ffdSmrg		cpu=mipsisa64sb1el
1107c05e22d7Smrg		;;
110896d43ffdSmrg	sh5e[lb]-*)
110996d43ffdSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11105dfecf96Smrg		;;
111196d43ffdSmrg	spur-*)
111296d43ffdSmrg		cpu=spur
11135dfecf96Smrg		;;
111496d43ffdSmrg	strongarm-* | thumb-*)
111596d43ffdSmrg		cpu=arm
11165dfecf96Smrg		;;
111796d43ffdSmrg	tx39-*)
111896d43ffdSmrg		cpu=mipstx39
11195dfecf96Smrg		;;
112096d43ffdSmrg	tx39el-*)
112196d43ffdSmrg		cpu=mipstx39el
11225dfecf96Smrg		;;
112396d43ffdSmrg	x64-*)
112496d43ffdSmrg		cpu=x86_64
11255dfecf96Smrg		;;
112696d43ffdSmrg	xscale-* | xscalee[bl]-*)
112796d43ffdSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11285dfecf96Smrg		;;
1129c2cbb186Smrg	arm64-* | aarch64le-*)
113096d43ffdSmrg		cpu=aarch64
11315dfecf96Smrg		;;
113296d43ffdSmrg
113396d43ffdSmrg	# Recognize the canonical CPU Types that limit and/or modify the
113496d43ffdSmrg	# company names they are paired with.
113596d43ffdSmrg	cr16-*)
113696d43ffdSmrg		basic_os=${basic_os:-elf}
11375dfecf96Smrg		;;
113896d43ffdSmrg	crisv32-* | etraxfs*-*)
113996d43ffdSmrg		cpu=crisv32
114096d43ffdSmrg		vendor=axis
11415dfecf96Smrg		;;
114296d43ffdSmrg	cris-* | etrax*-*)
114396d43ffdSmrg		cpu=cris
114496d43ffdSmrg		vendor=axis
11455dfecf96Smrg		;;
114696d43ffdSmrg	crx-*)
114796d43ffdSmrg		basic_os=${basic_os:-elf}
11485dfecf96Smrg		;;
114996d43ffdSmrg	neo-tandem)
115096d43ffdSmrg		cpu=neo
115196d43ffdSmrg		vendor=tandem
11525dfecf96Smrg		;;
115396d43ffdSmrg	nse-tandem)
115496d43ffdSmrg		cpu=nse
115596d43ffdSmrg		vendor=tandem
11565dfecf96Smrg		;;
115796d43ffdSmrg	nsr-tandem)
115896d43ffdSmrg		cpu=nsr
115996d43ffdSmrg		vendor=tandem
11605dfecf96Smrg		;;
116196d43ffdSmrg	nsv-tandem)
116296d43ffdSmrg		cpu=nsv
116396d43ffdSmrg		vendor=tandem
11645dfecf96Smrg		;;
116596d43ffdSmrg	nsx-tandem)
116696d43ffdSmrg		cpu=nsx
116796d43ffdSmrg		vendor=tandem
11685dfecf96Smrg		;;
116996d43ffdSmrg	mipsallegrexel-sony)
117096d43ffdSmrg		cpu=mipsallegrexel
117196d43ffdSmrg		vendor=sony
11725dfecf96Smrg		;;
117396d43ffdSmrg	tile*-*)
117496d43ffdSmrg		basic_os=${basic_os:-linux-gnu}
11755dfecf96Smrg		;;
117696d43ffdSmrg
11775dfecf96Smrg	*)
117896d43ffdSmrg		# Recognize the canonical CPU types that are allowed with any
117996d43ffdSmrg		# company name.
118096d43ffdSmrg		case $cpu in
118196d43ffdSmrg			1750a | 580 \
118296d43ffdSmrg			| a29k \
118396d43ffdSmrg			| aarch64 | aarch64_be \
118496d43ffdSmrg			| abacus \
118596d43ffdSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118696d43ffdSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118796d43ffdSmrg			| alphapca5[67] | alpha64pca5[67] \
118896d43ffdSmrg			| am33_2.0 \
118996d43ffdSmrg			| amdgcn \
119096d43ffdSmrg			| arc | arceb | arc32 | arc64 \
119196d43ffdSmrg			| arm | arm[lb]e | arme[lb] | armv* \
119296d43ffdSmrg			| avr | avr32 \
119396d43ffdSmrg			| asmjs \
119496d43ffdSmrg			| ba \
119596d43ffdSmrg			| be32 | be64 \
119696d43ffdSmrg			| bfin | bpf | bs2000 \
119796d43ffdSmrg			| c[123]* | c30 | [cjt]90 | c4x \
119896d43ffdSmrg			| c8051 | clipper | craynv | csky | cydra \
119996d43ffdSmrg			| d10v | d30v | dlx | dsp16xx \
120096d43ffdSmrg			| e2k | elxsi | epiphany \
120196d43ffdSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120296d43ffdSmrg			| h8300 | h8500 \
120396d43ffdSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
120496d43ffdSmrg			| hexagon \
120596d43ffdSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
120696d43ffdSmrg			| ip2k | iq2000 \
120796d43ffdSmrg			| k1om \
120896d43ffdSmrg			| le32 | le64 \
120996d43ffdSmrg			| lm32 \
1210c2cbb186Smrg			| loongarch32 | loongarch64 \
121196d43ffdSmrg			| m32c | m32r | m32rle \
121296d43ffdSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121396d43ffdSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121496d43ffdSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121596d43ffdSmrg			| microblaze | microblazeel \
121696d43ffdSmrg			| mips | mipsbe | mipseb | mipsel | mipsle \
121796d43ffdSmrg			| mips16 \
121896d43ffdSmrg			| mips64 | mips64eb | mips64el \
121996d43ffdSmrg			| mips64octeon | mips64octeonel \
122096d43ffdSmrg			| mips64orion | mips64orionel \
122196d43ffdSmrg			| mips64r5900 | mips64r5900el \
122296d43ffdSmrg			| mips64vr | mips64vrel \
122396d43ffdSmrg			| mips64vr4100 | mips64vr4100el \
122496d43ffdSmrg			| mips64vr4300 | mips64vr4300el \
122596d43ffdSmrg			| mips64vr5000 | mips64vr5000el \
122696d43ffdSmrg			| mips64vr5900 | mips64vr5900el \
122796d43ffdSmrg			| mipsisa32 | mipsisa32el \
122896d43ffdSmrg			| mipsisa32r2 | mipsisa32r2el \
122996d43ffdSmrg			| mipsisa32r3 | mipsisa32r3el \
123096d43ffdSmrg			| mipsisa32r5 | mipsisa32r5el \
123196d43ffdSmrg			| mipsisa32r6 | mipsisa32r6el \
123296d43ffdSmrg			| mipsisa64 | mipsisa64el \
123396d43ffdSmrg			| mipsisa64r2 | mipsisa64r2el \
123496d43ffdSmrg			| mipsisa64r3 | mipsisa64r3el \
123596d43ffdSmrg			| mipsisa64r5 | mipsisa64r5el \
123696d43ffdSmrg			| mipsisa64r6 | mipsisa64r6el \
123796d43ffdSmrg			| mipsisa64sb1 | mipsisa64sb1el \
123896d43ffdSmrg			| mipsisa64sr71k | mipsisa64sr71kel \
123996d43ffdSmrg			| mipsr5900 | mipsr5900el \
124096d43ffdSmrg			| mipstx39 | mipstx39el \
124196d43ffdSmrg			| mmix \
124296d43ffdSmrg			| mn10200 | mn10300 \
124396d43ffdSmrg			| moxie \
124496d43ffdSmrg			| mt \
124596d43ffdSmrg			| msp430 \
124696d43ffdSmrg			| nds32 | nds32le | nds32be \
124796d43ffdSmrg			| nfp \
124896d43ffdSmrg			| nios | nios2 | nios2eb | nios2el \
124996d43ffdSmrg			| none | np1 | ns16k | ns32k | nvptx \
125096d43ffdSmrg			| open8 \
125196d43ffdSmrg			| or1k* \
125296d43ffdSmrg			| or32 \
125396d43ffdSmrg			| orion \
125496d43ffdSmrg			| picochip \
125596d43ffdSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
125696d43ffdSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
125796d43ffdSmrg			| pru \
125896d43ffdSmrg			| pyramid \
125996d43ffdSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
126096d43ffdSmrg			| rl78 | romp | rs6000 | rx \
126196d43ffdSmrg			| s390 | s390x \
126296d43ffdSmrg			| score \
126396d43ffdSmrg			| sh | shl \
126496d43ffdSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
126596d43ffdSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
126696d43ffdSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
126796d43ffdSmrg			| sparclite \
126896d43ffdSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
126996d43ffdSmrg			| spu \
127096d43ffdSmrg			| tahoe \
127196d43ffdSmrg			| thumbv7* \
127296d43ffdSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
127396d43ffdSmrg			| tron \
127496d43ffdSmrg			| ubicom32 \
127596d43ffdSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
127696d43ffdSmrg			| vax \
127796d43ffdSmrg			| visium \
127896d43ffdSmrg			| w65 \
127996d43ffdSmrg			| wasm32 | wasm64 \
128096d43ffdSmrg			| we32k \
128196d43ffdSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
128296d43ffdSmrg			| xstormy16 | xtensa* \
128396d43ffdSmrg			| ymp \
128496d43ffdSmrg			| z8k | z80)
128596d43ffdSmrg				;;
128696d43ffdSmrg
128796d43ffdSmrg			*)
128896d43ffdSmrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
128996d43ffdSmrg				exit 1
129096d43ffdSmrg				;;
129196d43ffdSmrg		esac
12925dfecf96Smrg		;;
12935dfecf96Smrgesac
12945dfecf96Smrg
12955dfecf96Smrg# Here we canonicalize certain aliases for manufacturers.
129696d43ffdSmrgcase $vendor in
129796d43ffdSmrg	digital*)
129896d43ffdSmrg		vendor=dec
12995dfecf96Smrg		;;
130096d43ffdSmrg	commodore*)
130196d43ffdSmrg		vendor=cbm
13025dfecf96Smrg		;;
13035dfecf96Smrg	*)
13045dfecf96Smrg		;;
13055dfecf96Smrgesac
13065dfecf96Smrg
13075dfecf96Smrg# Decode manufacturer-specific aliases for certain operating systems.
13085dfecf96Smrg
130996d43ffdSmrgif test x$basic_os != x
13105dfecf96Smrgthen
131196d43ffdSmrg
1312c2cbb186Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
131396d43ffdSmrg# set os.
131496d43ffdSmrgcase $basic_os in
131596d43ffdSmrg	gnu/linux*)
131696d43ffdSmrg		kernel=linux
131796d43ffdSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
131896d43ffdSmrg		;;
131996d43ffdSmrg	os2-emx)
132096d43ffdSmrg		kernel=os2
132196d43ffdSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
132296d43ffdSmrg		;;
132396d43ffdSmrg	nto-qnx*)
132496d43ffdSmrg		kernel=nto
132596d43ffdSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
132696d43ffdSmrg		;;
132796d43ffdSmrg	*-*)
132896d43ffdSmrg		# shellcheck disable=SC2162
132996d43ffdSmrg		saved_IFS=$IFS
133096d43ffdSmrg		IFS="-" read kernel os <<EOF
133196d43ffdSmrg$basic_os
133296d43ffdSmrgEOF
133396d43ffdSmrg		IFS=$saved_IFS
133496d43ffdSmrg		;;
133596d43ffdSmrg	# Default OS when just kernel was specified
133696d43ffdSmrg	nto*)
133796d43ffdSmrg		kernel=nto
133896d43ffdSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
133996d43ffdSmrg		;;
134096d43ffdSmrg	linux*)
134196d43ffdSmrg		kernel=linux
134296d43ffdSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
134396d43ffdSmrg		;;
1344c2cbb186Smrg	managarm*)
1345c2cbb186Smrg		kernel=managarm
1346c2cbb186Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1347c2cbb186Smrg		;;
134896d43ffdSmrg	*)
134996d43ffdSmrg		kernel=
135096d43ffdSmrg		os=$basic_os
135196d43ffdSmrg		;;
135296d43ffdSmrgesac
135396d43ffdSmrg
135496d43ffdSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
135596d43ffdSmrg# etc.)
13565dfecf96Smrgcase $os in
135796d43ffdSmrg	# First match some system type aliases that might get confused
135896d43ffdSmrg	# with valid system types.
135996d43ffdSmrg	# solaris* is a basic system type, with this one exception.
136096d43ffdSmrg	auroraux)
136196d43ffdSmrg		os=auroraux
1362c05e22d7Smrg		;;
136396d43ffdSmrg	bluegene*)
136496d43ffdSmrg		os=cnk
13655dfecf96Smrg		;;
136696d43ffdSmrg	solaris1 | solaris1.*)
136796d43ffdSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13685dfecf96Smrg		;;
136996d43ffdSmrg	solaris)
137096d43ffdSmrg		os=solaris2
13715dfecf96Smrg		;;
137296d43ffdSmrg	unixware*)
137396d43ffdSmrg		os=sysv4.2uw
13745dfecf96Smrg		;;
137596d43ffdSmrg	# es1800 is here to avoid being matched by es* (a different OS)
137696d43ffdSmrg	es1800*)
137796d43ffdSmrg		os=ose
13785dfecf96Smrg		;;
137996d43ffdSmrg	# Some version numbers need modification
138096d43ffdSmrg	chorusos*)
138196d43ffdSmrg		os=chorusos
13825dfecf96Smrg		;;
138396d43ffdSmrg	isc)
138496d43ffdSmrg		os=isc2.2
13855dfecf96Smrg		;;
138696d43ffdSmrg	sco6)
138796d43ffdSmrg		os=sco5v6
13885dfecf96Smrg		;;
138996d43ffdSmrg	sco5)
139096d43ffdSmrg		os=sco3.2v5
13915dfecf96Smrg		;;
139296d43ffdSmrg	sco4)
139396d43ffdSmrg		os=sco3.2v4
13945dfecf96Smrg		;;
139596d43ffdSmrg	sco3.2.[4-9]*)
139696d43ffdSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13975dfecf96Smrg		;;
139896d43ffdSmrg	sco*v* | scout)
139996d43ffdSmrg		# Don't match below
14005dfecf96Smrg		;;
140196d43ffdSmrg	sco*)
140296d43ffdSmrg		os=sco3.2v2
14035dfecf96Smrg		;;
140496d43ffdSmrg	psos*)
140596d43ffdSmrg		os=psos
14065dfecf96Smrg		;;
140796d43ffdSmrg	qnx*)
140896d43ffdSmrg		os=qnx
14095dfecf96Smrg		;;
141096d43ffdSmrg	hiux*)
141196d43ffdSmrg		os=hiuxwe2
14125dfecf96Smrg		;;
141396d43ffdSmrg	lynx*178)
141496d43ffdSmrg		os=lynxos178
14155dfecf96Smrg		;;
141696d43ffdSmrg	lynx*5)
141796d43ffdSmrg		os=lynxos5
14185dfecf96Smrg		;;
141996d43ffdSmrg	lynxos*)
142096d43ffdSmrg		# don't get caught up in next wildcard
14215dfecf96Smrg		;;
142296d43ffdSmrg	lynx*)
142396d43ffdSmrg		os=lynxos
14245dfecf96Smrg		;;
142596d43ffdSmrg	mac[0-9]*)
142696d43ffdSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14275dfecf96Smrg		;;
142896d43ffdSmrg	opened*)
142996d43ffdSmrg		os=openedition
14305dfecf96Smrg		;;
143196d43ffdSmrg	os400*)
143296d43ffdSmrg		os=os400
14335dfecf96Smrg		;;
143496d43ffdSmrg	sunos5*)
143596d43ffdSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
14365dfecf96Smrg		;;
143796d43ffdSmrg	sunos6*)
143896d43ffdSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14395dfecf96Smrg		;;
144096d43ffdSmrg	wince*)
144196d43ffdSmrg		os=wince
14425dfecf96Smrg		;;
144396d43ffdSmrg	utek*)
144496d43ffdSmrg		os=bsd
14455dfecf96Smrg		;;
144696d43ffdSmrg	dynix*)
144796d43ffdSmrg		os=bsd
14485dfecf96Smrg		;;
144996d43ffdSmrg	acis*)
145096d43ffdSmrg		os=aos
14515dfecf96Smrg		;;
145296d43ffdSmrg	atheos*)
145396d43ffdSmrg		os=atheos
14545dfecf96Smrg		;;
145596d43ffdSmrg	syllable*)
145696d43ffdSmrg		os=syllable
14575dfecf96Smrg		;;
145896d43ffdSmrg	386bsd)
145996d43ffdSmrg		os=bsd
14605dfecf96Smrg		;;
146196d43ffdSmrg	ctix* | uts*)
146296d43ffdSmrg		os=sysv
14635dfecf96Smrg		;;
146496d43ffdSmrg	nova*)
146596d43ffdSmrg		os=rtmk-nova
14665dfecf96Smrg		;;
146796d43ffdSmrg	ns2)
146896d43ffdSmrg		os=nextstep2
14695dfecf96Smrg		;;
147096d43ffdSmrg	# Preserve the version number of sinix5.
147196d43ffdSmrg	sinix5.*)
147296d43ffdSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14735dfecf96Smrg		;;
147496d43ffdSmrg	sinix*)
147596d43ffdSmrg		os=sysv4
14765dfecf96Smrg		;;
147796d43ffdSmrg	tpf*)
147896d43ffdSmrg		os=tpf
14795dfecf96Smrg		;;
148096d43ffdSmrg	triton*)
148196d43ffdSmrg		os=sysv3
14825dfecf96Smrg		;;
148396d43ffdSmrg	oss*)
148496d43ffdSmrg		os=sysv3
14855dfecf96Smrg		;;
148696d43ffdSmrg	svr4*)
148796d43ffdSmrg		os=sysv4
14885dfecf96Smrg		;;
148996d43ffdSmrg	svr3)
149096d43ffdSmrg		os=sysv3
14915dfecf96Smrg		;;
149296d43ffdSmrg	sysvr4)
149396d43ffdSmrg		os=sysv4
14945dfecf96Smrg		;;
149596d43ffdSmrg	ose*)
149696d43ffdSmrg		os=ose
14975dfecf96Smrg		;;
149896d43ffdSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
149996d43ffdSmrg		os=mint
1500c05e22d7Smrg		;;
150196d43ffdSmrg	dicos*)
150296d43ffdSmrg		os=dicos
150331de2854Smrg		;;
150496d43ffdSmrg	pikeos*)
150596d43ffdSmrg		# Until real need of OS specific support for
150696d43ffdSmrg		# particular features comes up, bare metal
150796d43ffdSmrg		# configurations are quite functional.
150896d43ffdSmrg		case $cpu in
150996d43ffdSmrg		    arm*)
151096d43ffdSmrg			os=eabi
151196d43ffdSmrg			;;
151296d43ffdSmrg		    *)
151396d43ffdSmrg			os=elf
151496d43ffdSmrg			;;
151596d43ffdSmrg		esac
15165dfecf96Smrg		;;
15175dfecf96Smrg	*)
151896d43ffdSmrg		# No normalization, but not necessarily accepted, that comes below.
15195dfecf96Smrg		;;
15205dfecf96Smrgesac
152196d43ffdSmrg
15225dfecf96Smrgelse
15235dfecf96Smrg
15245dfecf96Smrg# Here we handle the default operating systems that come with various machines.
15255dfecf96Smrg# The value should be what the vendor currently ships out the door with their
15265dfecf96Smrg# machine or put another way, the most popular os provided with the machine.
15275dfecf96Smrg
15285dfecf96Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15295dfecf96Smrg# "-sun"), then you have to tell the case statement up towards the top
15305dfecf96Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15315dfecf96Smrg# will signal an error saying that MANUFACTURER isn't an operating
15325dfecf96Smrg# system, and we'll never get to this point.
15335dfecf96Smrg
153496d43ffdSmrgkernel=
153596d43ffdSmrgcase $cpu-$vendor in
153631de2854Smrg	score-*)
153796d43ffdSmrg		os=elf
1538f14f4646Smrg		;;
153931de2854Smrg	spu-*)
154096d43ffdSmrg		os=elf
1541f14f4646Smrg		;;
15425dfecf96Smrg	*-acorn)
154396d43ffdSmrg		os=riscix1.2
15445dfecf96Smrg		;;
15455dfecf96Smrg	arm*-rebel)
154696d43ffdSmrg		kernel=linux
154796d43ffdSmrg		os=gnu
15485dfecf96Smrg		;;
15495dfecf96Smrg	arm*-semi)
155096d43ffdSmrg		os=aout
15515dfecf96Smrg		;;
155231de2854Smrg	c4x-* | tic4x-*)
155396d43ffdSmrg		os=coff
1554f14f4646Smrg		;;
1555f765521fSmrg	c8051-*)
155696d43ffdSmrg		os=elf
155796d43ffdSmrg		;;
155896d43ffdSmrg	clipper-intergraph)
155996d43ffdSmrg		os=clix
1560f765521fSmrg		;;
1561f765521fSmrg	hexagon-*)
156296d43ffdSmrg		os=elf
1563f765521fSmrg		;;
1564c05e22d7Smrg	tic54x-*)
156596d43ffdSmrg		os=coff
1566c05e22d7Smrg		;;
1567c05e22d7Smrg	tic55x-*)
156896d43ffdSmrg		os=coff
1569c05e22d7Smrg		;;
1570c05e22d7Smrg	tic6x-*)
157196d43ffdSmrg		os=coff
1572c05e22d7Smrg		;;
15735dfecf96Smrg	# This must come before the *-dec entry.
15745dfecf96Smrg	pdp10-*)
157596d43ffdSmrg		os=tops20
15765dfecf96Smrg		;;
15775dfecf96Smrg	pdp11-*)
157896d43ffdSmrg		os=none
15795dfecf96Smrg		;;
15805dfecf96Smrg	*-dec | vax-*)
158196d43ffdSmrg		os=ultrix4.2
15825dfecf96Smrg		;;
15835dfecf96Smrg	m68*-apollo)
158496d43ffdSmrg		os=domain
15855dfecf96Smrg		;;
15865dfecf96Smrg	i386-sun)
158796d43ffdSmrg		os=sunos4.0.2
15885dfecf96Smrg		;;
15895dfecf96Smrg	m68000-sun)
159096d43ffdSmrg		os=sunos3
15915dfecf96Smrg		;;
15925dfecf96Smrg	m68*-cisco)
159396d43ffdSmrg		os=aout
15945dfecf96Smrg		;;
159531de2854Smrg	mep-*)
159696d43ffdSmrg		os=elf
1597f14f4646Smrg		;;
15985dfecf96Smrg	mips*-cisco)
159996d43ffdSmrg		os=elf
16005dfecf96Smrg		;;
16015dfecf96Smrg	mips*-*)
160296d43ffdSmrg		os=elf
1603f765521fSmrg		;;
16045dfecf96Smrg	or32-*)
160596d43ffdSmrg		os=coff
16065dfecf96Smrg		;;
16075dfecf96Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
160896d43ffdSmrg		os=sysv3
16095dfecf96Smrg		;;
16105dfecf96Smrg	sparc-* | *-sun)
161196d43ffdSmrg		os=sunos4.1.1
16125dfecf96Smrg		;;
161396d43ffdSmrg	pru-*)
161496d43ffdSmrg		os=elf
16155dfecf96Smrg		;;
161696d43ffdSmrg	*-be)
161796d43ffdSmrg		os=beos
16185dfecf96Smrg		;;
16195dfecf96Smrg	*-ibm)
162096d43ffdSmrg		os=aix
16215dfecf96Smrg		;;
162231de2854Smrg	*-knuth)
162396d43ffdSmrg		os=mmixware
16245dfecf96Smrg		;;
16255dfecf96Smrg	*-wec)
162696d43ffdSmrg		os=proelf
16275dfecf96Smrg		;;
16285dfecf96Smrg	*-winbond)
162996d43ffdSmrg		os=proelf
16305dfecf96Smrg		;;
16315dfecf96Smrg	*-oki)
163296d43ffdSmrg		os=proelf
16335dfecf96Smrg		;;
16345dfecf96Smrg	*-hp)
163596d43ffdSmrg		os=hpux
16365dfecf96Smrg		;;
16375dfecf96Smrg	*-hitachi)
163896d43ffdSmrg		os=hiux
16395dfecf96Smrg		;;
16405dfecf96Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
164196d43ffdSmrg		os=sysv
16425dfecf96Smrg		;;
16435dfecf96Smrg	*-cbm)
164496d43ffdSmrg		os=amigaos
16455dfecf96Smrg		;;
16465dfecf96Smrg	*-dg)
164796d43ffdSmrg		os=dgux
16485dfecf96Smrg		;;
16495dfecf96Smrg	*-dolphin)
165096d43ffdSmrg		os=sysv3
16515dfecf96Smrg		;;
16525dfecf96Smrg	m68k-ccur)
165396d43ffdSmrg		os=rtu
16545dfecf96Smrg		;;
16555dfecf96Smrg	m88k-omron*)
165696d43ffdSmrg		os=luna
16575dfecf96Smrg		;;
165896d43ffdSmrg	*-next)
165996d43ffdSmrg		os=nextstep
16605dfecf96Smrg		;;
16615dfecf96Smrg	*-sequent)
166296d43ffdSmrg		os=ptx
16635dfecf96Smrg		;;
16645dfecf96Smrg	*-crds)
166596d43ffdSmrg		os=unos
16665dfecf96Smrg		;;
16675dfecf96Smrg	*-ns)
166896d43ffdSmrg		os=genix
16695dfecf96Smrg		;;
16705dfecf96Smrg	i370-*)
167196d43ffdSmrg		os=mvs
16725dfecf96Smrg		;;
16735dfecf96Smrg	*-gould)
167496d43ffdSmrg		os=sysv
16755dfecf96Smrg		;;
16765dfecf96Smrg	*-highlevel)
167796d43ffdSmrg		os=bsd
16785dfecf96Smrg		;;
16795dfecf96Smrg	*-encore)
168096d43ffdSmrg		os=bsd
16815dfecf96Smrg		;;
16825dfecf96Smrg	*-sgi)
168396d43ffdSmrg		os=irix
16845dfecf96Smrg		;;
16855dfecf96Smrg	*-siemens)
168696d43ffdSmrg		os=sysv4
16875dfecf96Smrg		;;
16885dfecf96Smrg	*-masscomp)
168996d43ffdSmrg		os=rtu
16905dfecf96Smrg		;;
16915dfecf96Smrg	f30[01]-fujitsu | f700-fujitsu)
169296d43ffdSmrg		os=uxpv
16935dfecf96Smrg		;;
16945dfecf96Smrg	*-rom68k)
169596d43ffdSmrg		os=coff
16965dfecf96Smrg		;;
16975dfecf96Smrg	*-*bug)
169896d43ffdSmrg		os=coff
16995dfecf96Smrg		;;
17005dfecf96Smrg	*-apple)
170196d43ffdSmrg		os=macos
17025dfecf96Smrg		;;
17035dfecf96Smrg	*-atari*)
170496d43ffdSmrg		os=mint
170596d43ffdSmrg		;;
170696d43ffdSmrg	*-wrs)
170796d43ffdSmrg		os=vxworks
17085dfecf96Smrg		;;
17095dfecf96Smrg	*)
171096d43ffdSmrg		os=none
17115dfecf96Smrg		;;
17125dfecf96Smrgesac
171396d43ffdSmrg
17145dfecf96Smrgfi
17155dfecf96Smrg
171696d43ffdSmrg# Now, validate our (potentially fixed-up) OS.
171796d43ffdSmrgcase $os in
171896d43ffdSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
171996d43ffdSmrg	musl* | newlib* | relibc* | uclibc*)
172096d43ffdSmrg		;;
172196d43ffdSmrg	# Likewise for "kernel-abi"
172296d43ffdSmrg	eabi* | gnueabi*)
172396d43ffdSmrg		;;
172496d43ffdSmrg	# VxWorks passes extra cpu info in the 4th filed.
172596d43ffdSmrg	simlinux | simwindows | spe)
172696d43ffdSmrg		;;
172796d43ffdSmrg	# Now accept the basic system types.
172896d43ffdSmrg	# The portable systems comes first.
172996d43ffdSmrg	# Each alternative MUST end in a * to match a version number.
173096d43ffdSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
173196d43ffdSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
173296d43ffdSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
173396d43ffdSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
173496d43ffdSmrg	     | hiux* | abug | nacl* | netware* | windows* \
173596d43ffdSmrg	     | os9* | macos* | osx* | ios* \
173696d43ffdSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
173796d43ffdSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
173896d43ffdSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
173996d43ffdSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
174096d43ffdSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
174196d43ffdSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
174296d43ffdSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
174396d43ffdSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
174496d43ffdSmrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
174596d43ffdSmrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
174696d43ffdSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
174796d43ffdSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
174896d43ffdSmrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
174996d43ffdSmrg	     | midipix* | mingw32* | mingw64* | mint* \
175096d43ffdSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
175196d43ffdSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
175296d43ffdSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
175396d43ffdSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
175496d43ffdSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
175596d43ffdSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
175696d43ffdSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
175796d43ffdSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
175896d43ffdSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
175996d43ffdSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1760c2cbb186Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761c2cbb186Smrg	     | fiwix* | mlibc* )
176296d43ffdSmrg		;;
176396d43ffdSmrg	# This one is extra strict with allowed versions
176496d43ffdSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
176596d43ffdSmrg		# Don't forget version if it is 3.2v4 or newer.
176696d43ffdSmrg		;;
176796d43ffdSmrg	none)
176896d43ffdSmrg		;;
1769c2cbb186Smrg	kernel* )
1770c2cbb186Smrg		# Restricted further below
1771c2cbb186Smrg		;;
177296d43ffdSmrg	*)
177396d43ffdSmrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
177496d43ffdSmrg		exit 1
177596d43ffdSmrg		;;
177696d43ffdSmrgesac
177796d43ffdSmrg
177896d43ffdSmrg# As a final step for OS-related things, validate the OS-kernel combination
177996d43ffdSmrg# (given a valid OS), if there is a kernel.
178096d43ffdSmrgcase $kernel-$os in
178196d43ffdSmrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782c2cbb186Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
178396d43ffdSmrg		;;
178496d43ffdSmrg	uclinux-uclibc* )
178596d43ffdSmrg		;;
1786c2cbb186Smrg	managarm-mlibc* | managarm-kernel* )
1787c2cbb186Smrg		;;
1788c2cbb186Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
178996d43ffdSmrg		# These are just libc implementations, not actual OSes, and thus
179096d43ffdSmrg		# require a kernel.
179196d43ffdSmrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
179296d43ffdSmrg		exit 1
179396d43ffdSmrg		;;
1794c2cbb186Smrg	-kernel* )
1795c2cbb186Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
1796c2cbb186Smrg		exit 1
1797c2cbb186Smrg		;;
1798c2cbb186Smrg	*-kernel* )
1799c2cbb186Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
1800c2cbb186Smrg		exit 1
1801c2cbb186Smrg		;;
180296d43ffdSmrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
180396d43ffdSmrg		;;
180496d43ffdSmrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
180596d43ffdSmrg		;;
180696d43ffdSmrg	nto-qnx*)
180796d43ffdSmrg		;;
180896d43ffdSmrg	os2-emx)
180996d43ffdSmrg		;;
181096d43ffdSmrg	*-eabi* | *-gnueabi*)
181196d43ffdSmrg		;;
181296d43ffdSmrg	-*)
181396d43ffdSmrg		# Blank kernel with real OS is always fine.
181496d43ffdSmrg		;;
181596d43ffdSmrg	*-*)
181696d43ffdSmrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
181796d43ffdSmrg		exit 1
181896d43ffdSmrg		;;
181996d43ffdSmrgesac
182096d43ffdSmrg
18215dfecf96Smrg# Here we handle the case where we know the os, and the CPU type, but not the
18225dfecf96Smrg# manufacturer.  We pick the logical manufacturer.
182396d43ffdSmrgcase $vendor in
182496d43ffdSmrg	unknown)
182596d43ffdSmrg		case $cpu-$os in
182696d43ffdSmrg			*-riscix*)
18275dfecf96Smrg				vendor=acorn
18285dfecf96Smrg				;;
182996d43ffdSmrg			*-sunos*)
18305dfecf96Smrg				vendor=sun
18315dfecf96Smrg				;;
183296d43ffdSmrg			*-cnk* | *-aix*)
18335dfecf96Smrg				vendor=ibm
18345dfecf96Smrg				;;
183596d43ffdSmrg			*-beos*)
18365dfecf96Smrg				vendor=be
18375dfecf96Smrg				;;
183896d43ffdSmrg			*-hpux*)
18395dfecf96Smrg				vendor=hp
18405dfecf96Smrg				;;
184196d43ffdSmrg			*-mpeix*)
18425dfecf96Smrg				vendor=hp
18435dfecf96Smrg				;;
184496d43ffdSmrg			*-hiux*)
18455dfecf96Smrg				vendor=hitachi
18465dfecf96Smrg				;;
184796d43ffdSmrg			*-unos*)
18485dfecf96Smrg				vendor=crds
18495dfecf96Smrg				;;
185096d43ffdSmrg			*-dgux*)
18515dfecf96Smrg				vendor=dg
18525dfecf96Smrg				;;
185396d43ffdSmrg			*-luna*)
18545dfecf96Smrg				vendor=omron
18555dfecf96Smrg				;;
185696d43ffdSmrg			*-genix*)
18575dfecf96Smrg				vendor=ns
18585dfecf96Smrg				;;
185996d43ffdSmrg			*-clix*)
186096d43ffdSmrg				vendor=intergraph
186196d43ffdSmrg				;;
186296d43ffdSmrg			*-mvs* | *-opened*)
186396d43ffdSmrg				vendor=ibm
186496d43ffdSmrg				;;
186596d43ffdSmrg			*-os400*)
18665dfecf96Smrg				vendor=ibm
18675dfecf96Smrg				;;
186896d43ffdSmrg			s390-* | s390x-*)
18695dfecf96Smrg				vendor=ibm
18705dfecf96Smrg				;;
187196d43ffdSmrg			*-ptx*)
18725dfecf96Smrg				vendor=sequent
18735dfecf96Smrg				;;
187496d43ffdSmrg			*-tpf*)
18755dfecf96Smrg				vendor=ibm
18765dfecf96Smrg				;;
187796d43ffdSmrg			*-vxsim* | *-vxworks* | *-windiss*)
18785dfecf96Smrg				vendor=wrs
18795dfecf96Smrg				;;
188096d43ffdSmrg			*-aux*)
18815dfecf96Smrg				vendor=apple
18825dfecf96Smrg				;;
188396d43ffdSmrg			*-hms*)
18845dfecf96Smrg				vendor=hitachi
18855dfecf96Smrg				;;
188696d43ffdSmrg			*-mpw* | *-macos*)
18875dfecf96Smrg				vendor=apple
18885dfecf96Smrg				;;
188996d43ffdSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
18905dfecf96Smrg				vendor=atari
18915dfecf96Smrg				;;
189296d43ffdSmrg			*-vos*)
18935dfecf96Smrg				vendor=stratus
18945dfecf96Smrg				;;
18955dfecf96Smrg		esac
18965dfecf96Smrg		;;
18975dfecf96Smrgesac
18985dfecf96Smrg
189996d43ffdSmrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
19005dfecf96Smrgexit
19015dfecf96Smrg
19025dfecf96Smrg# Local variables:
190396d43ffdSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
19045dfecf96Smrg# time-stamp-start: "timestamp='"
19055dfecf96Smrg# time-stamp-format: "%:y-%02m-%02d"
19065dfecf96Smrg# time-stamp-end: "'"
19075dfecf96Smrg# End:
1908