1972599cfSmrg#! /bin/sh
2972599cfSmrg# Configuration validation subroutine script.
39dd7914aSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4972599cfSmrg
59dd7914aSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
69dd7914aSmrg
79dd7914aSmrgtimestamp='2023-01-21'
8972599cfSmrg
95eeb4e8fSmrg# This file is free software; you can redistribute it and/or modify it
105eeb4e8fSmrg# under the terms of the GNU General Public License as published by
119dd7914aSmrg# the Free Software Foundation, either version 3 of the License, or
12972599cfSmrg# (at your option) any later version.
13972599cfSmrg#
145eeb4e8fSmrg# This program is distributed in the hope that it will be useful, but
155eeb4e8fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
165eeb4e8fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
175eeb4e8fSmrg# General Public License for more details.
18972599cfSmrg#
19972599cfSmrg# You should have received a copy of the GNU General Public License
209dd7914aSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21972599cfSmrg#
22972599cfSmrg# As a special exception to the GNU General Public License, if you
23972599cfSmrg# distribute this file as part of a program that contains a
24972599cfSmrg# configuration script generated by Autoconf, you may include it under
255eeb4e8fSmrg# the same distribution terms that you use for the rest of that
265eeb4e8fSmrg# program.  This Exception is an additional permission under section 7
275eeb4e8fSmrg# of the GNU General Public License, version 3 ("GPLv3").
28972599cfSmrg
29972599cfSmrg
305eeb4e8fSmrg# Please send patches to <config-patches@gnu.org>.
31972599cfSmrg#
32972599cfSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33972599cfSmrg# Supply the specified configuration type as an argument.
34972599cfSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35972599cfSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36972599cfSmrg
37972599cfSmrg# You can get the latest version of this script from:
389dd7914aSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39972599cfSmrg
40972599cfSmrg# This file is supposed to be the same for all GNU packages
41972599cfSmrg# and recognize all the CPU types, system types and aliases
42972599cfSmrg# that are meaningful with *any* GNU software.
43972599cfSmrg# Each package is responsible for reporting which valid configurations
44972599cfSmrg# it does not support.  The user should be able to distinguish
45972599cfSmrg# a failure to support a valid configuration from a meaningless
46972599cfSmrg# configuration.
47972599cfSmrg
48972599cfSmrg# The goal of this file is to map all the various variations of a given
49972599cfSmrg# machine specification into a single specification in the form:
50972599cfSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51972599cfSmrg# or in some cases, the newer four-part form:
52972599cfSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53972599cfSmrg# It is wrong to echo any other type of specification.
54972599cfSmrg
559dd7914aSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
569dd7914aSmrg# about features and limitations of the classic Bourne shell that were
579dd7914aSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
589dd7914aSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
599dd7914aSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
609dd7914aSmrg# have a pre-POSIX /bin/sh.
619dd7914aSmrg
62972599cfSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63972599cfSmrg
64972599cfSmrgusage="\
659dd7914aSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66972599cfSmrg
67972599cfSmrgCanonicalize a configuration name.
68972599cfSmrg
699dd7914aSmrgOptions:
70972599cfSmrg  -h, --help         print this help, then exit
71972599cfSmrg  -t, --time-stamp   print date of last modification, then exit
72972599cfSmrg  -v, --version      print version number, then exit
73972599cfSmrg
74972599cfSmrgReport bugs and patches to <config-patches@gnu.org>."
75972599cfSmrg
76972599cfSmrgversion="\
77972599cfSmrgGNU config.sub ($timestamp)
78972599cfSmrg
799dd7914aSmrgCopyright 1992-2023 Free Software Foundation, Inc.
80972599cfSmrg
81972599cfSmrgThis is free software; see the source for copying conditions.  There is NO
82972599cfSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83972599cfSmrg
84972599cfSmrghelp="
85972599cfSmrgTry \`$me --help' for more information."
86972599cfSmrg
87972599cfSmrg# Parse command line
88972599cfSmrgwhile test $# -gt 0 ; do
89972599cfSmrg  case $1 in
90972599cfSmrg    --time-stamp | --time* | -t )
91972599cfSmrg       echo "$timestamp" ; exit ;;
92972599cfSmrg    --version | -v )
93972599cfSmrg       echo "$version" ; exit ;;
94972599cfSmrg    --help | --h* | -h )
95972599cfSmrg       echo "$usage"; exit ;;
96972599cfSmrg    -- )     # Stop option processing
97972599cfSmrg       shift; break ;;
98972599cfSmrg    - )	# Use stdin as input.
99972599cfSmrg       break ;;
100972599cfSmrg    -* )
1019dd7914aSmrg       echo "$me: invalid option $1$help" >&2
102972599cfSmrg       exit 1 ;;
103972599cfSmrg
104972599cfSmrg    *local*)
105972599cfSmrg       # First pass through any local machine types.
1069dd7914aSmrg       echo "$1"
107972599cfSmrg       exit ;;
108972599cfSmrg
109972599cfSmrg    * )
110972599cfSmrg       break ;;
111972599cfSmrg  esac
112972599cfSmrgdone
113972599cfSmrg
114972599cfSmrgcase $# in
115972599cfSmrg 0) echo "$me: missing argument$help" >&2
116972599cfSmrg    exit 1;;
117972599cfSmrg 1) ;;
118972599cfSmrg *) echo "$me: too many arguments$help" >&2
119972599cfSmrg    exit 1;;
120972599cfSmrgesac
121972599cfSmrg
1229dd7914aSmrg# Split fields of configuration type
1239dd7914aSmrg# shellcheck disable=SC2162
1249dd7914aSmrgsaved_IFS=$IFS
1259dd7914aSmrgIFS="-" read field1 field2 field3 field4 <<EOF
1269dd7914aSmrg$1
1279dd7914aSmrgEOF
1289dd7914aSmrgIFS=$saved_IFS
129972599cfSmrg
1309dd7914aSmrg# Separate into logical components for further validation
1319dd7914aSmrgcase $1 in
1329dd7914aSmrg	*-*-*-*-*)
1339dd7914aSmrg		echo Invalid configuration \`"$1"\': more than four components >&2
1349dd7914aSmrg		exit 1
135972599cfSmrg		;;
1369dd7914aSmrg	*-*-*-*)
1379dd7914aSmrg		basic_machine=$field1-$field2
1389dd7914aSmrg		basic_os=$field3-$field4
139972599cfSmrg		;;
1409dd7914aSmrg	*-*-*)
1419dd7914aSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1429dd7914aSmrg		# parts
1439dd7914aSmrg		maybe_os=$field2-$field3
1449dd7914aSmrg		case $maybe_os in
1459dd7914aSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
1469dd7914aSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1479dd7914aSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1489dd7914aSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
1499dd7914aSmrg				basic_machine=$field1
1509dd7914aSmrg				basic_os=$maybe_os
1519dd7914aSmrg				;;
1529dd7914aSmrg			android-linux)
1539dd7914aSmrg				basic_machine=$field1-unknown
1549dd7914aSmrg				basic_os=linux-android
1559dd7914aSmrg				;;
1569dd7914aSmrg			*)
1579dd7914aSmrg				basic_machine=$field1-$field2
1589dd7914aSmrg				basic_os=$field3
1599dd7914aSmrg				;;
1609dd7914aSmrg		esac
161972599cfSmrg		;;
1629dd7914aSmrg	*-*)
1639dd7914aSmrg		# A lone config we happen to match not fitting any pattern
1649dd7914aSmrg		case $field1-$field2 in
1659dd7914aSmrg			decstation-3100)
1669dd7914aSmrg				basic_machine=mips-dec
1679dd7914aSmrg				basic_os=
1689dd7914aSmrg				;;
1699dd7914aSmrg			*-*)
1709dd7914aSmrg				# Second component is usually, but not always the OS
1719dd7914aSmrg				case $field2 in
1729dd7914aSmrg					# Prevent following clause from handling this valid os
1739dd7914aSmrg					sun*os*)
1749dd7914aSmrg						basic_machine=$field1
1759dd7914aSmrg						basic_os=$field2
1769dd7914aSmrg						;;
1779dd7914aSmrg					zephyr*)
1789dd7914aSmrg						basic_machine=$field1-unknown
1799dd7914aSmrg						basic_os=$field2
1809dd7914aSmrg						;;
1819dd7914aSmrg					# Manufacturers
1829dd7914aSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1839dd7914aSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1849dd7914aSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1859dd7914aSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1869dd7914aSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1879dd7914aSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1889dd7914aSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1899dd7914aSmrg					| microblaze* | sim | cisco \
1909dd7914aSmrg					| oki | wec | wrs | winbond)
1919dd7914aSmrg						basic_machine=$field1-$field2
1929dd7914aSmrg						basic_os=
1939dd7914aSmrg						;;
1949dd7914aSmrg					*)
1959dd7914aSmrg						basic_machine=$field1
1969dd7914aSmrg						basic_os=$field2
1979dd7914aSmrg						;;
1989dd7914aSmrg				esac
1999dd7914aSmrg			;;
2009dd7914aSmrg		esac
201972599cfSmrg		;;
2029dd7914aSmrg	*)
2039dd7914aSmrg		# Convert single-component short-hands not valid as part of
2049dd7914aSmrg		# multi-component configurations.
2059dd7914aSmrg		case $field1 in
2069dd7914aSmrg			386bsd)
2079dd7914aSmrg				basic_machine=i386-pc
2089dd7914aSmrg				basic_os=bsd
2099dd7914aSmrg				;;
2109dd7914aSmrg			a29khif)
2119dd7914aSmrg				basic_machine=a29k-amd
2129dd7914aSmrg				basic_os=udi
2139dd7914aSmrg				;;
2149dd7914aSmrg			adobe68k)
2159dd7914aSmrg				basic_machine=m68010-adobe
2169dd7914aSmrg				basic_os=scout
2179dd7914aSmrg				;;
2189dd7914aSmrg			alliant)
2199dd7914aSmrg				basic_machine=fx80-alliant
2209dd7914aSmrg				basic_os=
2219dd7914aSmrg				;;
2229dd7914aSmrg			altos | altos3068)
2239dd7914aSmrg				basic_machine=m68k-altos
2249dd7914aSmrg				basic_os=
2259dd7914aSmrg				;;
2269dd7914aSmrg			am29k)
2279dd7914aSmrg				basic_machine=a29k-none
2289dd7914aSmrg				basic_os=bsd
2299dd7914aSmrg				;;
2309dd7914aSmrg			amdahl)
2319dd7914aSmrg				basic_machine=580-amdahl
2329dd7914aSmrg				basic_os=sysv
2339dd7914aSmrg				;;
2349dd7914aSmrg			amiga)
2359dd7914aSmrg				basic_machine=m68k-unknown
2369dd7914aSmrg				basic_os=
2379dd7914aSmrg				;;
2389dd7914aSmrg			amigaos | amigados)
2399dd7914aSmrg				basic_machine=m68k-unknown
2409dd7914aSmrg				basic_os=amigaos
2419dd7914aSmrg				;;
2429dd7914aSmrg			amigaunix | amix)
2439dd7914aSmrg				basic_machine=m68k-unknown
2449dd7914aSmrg				basic_os=sysv4
2459dd7914aSmrg				;;
2469dd7914aSmrg			apollo68)
2479dd7914aSmrg				basic_machine=m68k-apollo
2489dd7914aSmrg				basic_os=sysv
2499dd7914aSmrg				;;
2509dd7914aSmrg			apollo68bsd)
2519dd7914aSmrg				basic_machine=m68k-apollo
2529dd7914aSmrg				basic_os=bsd
2539dd7914aSmrg				;;
2549dd7914aSmrg			aros)
2559dd7914aSmrg				basic_machine=i386-pc
2569dd7914aSmrg				basic_os=aros
2579dd7914aSmrg				;;
2589dd7914aSmrg			aux)
2599dd7914aSmrg				basic_machine=m68k-apple
2609dd7914aSmrg				basic_os=aux
2619dd7914aSmrg				;;
2629dd7914aSmrg			balance)
2639dd7914aSmrg				basic_machine=ns32k-sequent
2649dd7914aSmrg				basic_os=dynix
2659dd7914aSmrg				;;
2669dd7914aSmrg			blackfin)
2679dd7914aSmrg				basic_machine=bfin-unknown
2689dd7914aSmrg				basic_os=linux
2699dd7914aSmrg				;;
2709dd7914aSmrg			cegcc)
2719dd7914aSmrg				basic_machine=arm-unknown
2729dd7914aSmrg				basic_os=cegcc
2739dd7914aSmrg				;;
2749dd7914aSmrg			convex-c1)
2759dd7914aSmrg				basic_machine=c1-convex
2769dd7914aSmrg				basic_os=bsd
2779dd7914aSmrg				;;
2789dd7914aSmrg			convex-c2)
2799dd7914aSmrg				basic_machine=c2-convex
2809dd7914aSmrg				basic_os=bsd
2819dd7914aSmrg				;;
2829dd7914aSmrg			convex-c32)
2839dd7914aSmrg				basic_machine=c32-convex
2849dd7914aSmrg				basic_os=bsd
2859dd7914aSmrg				;;
2869dd7914aSmrg			convex-c34)
2879dd7914aSmrg				basic_machine=c34-convex
2889dd7914aSmrg				basic_os=bsd
2899dd7914aSmrg				;;
2909dd7914aSmrg			convex-c38)
2919dd7914aSmrg				basic_machine=c38-convex
2929dd7914aSmrg				basic_os=bsd
2939dd7914aSmrg				;;
2949dd7914aSmrg			cray)
2959dd7914aSmrg				basic_machine=j90-cray
2969dd7914aSmrg				basic_os=unicos
2979dd7914aSmrg				;;
2989dd7914aSmrg			crds | unos)
2999dd7914aSmrg				basic_machine=m68k-crds
3009dd7914aSmrg				basic_os=
3019dd7914aSmrg				;;
3029dd7914aSmrg			da30)
3039dd7914aSmrg				basic_machine=m68k-da30
3049dd7914aSmrg				basic_os=
3059dd7914aSmrg				;;
3069dd7914aSmrg			decstation | pmax | pmin | dec3100 | decstatn)
3079dd7914aSmrg				basic_machine=mips-dec
3089dd7914aSmrg				basic_os=
3099dd7914aSmrg				;;
3109dd7914aSmrg			delta88)
3119dd7914aSmrg				basic_machine=m88k-motorola
3129dd7914aSmrg				basic_os=sysv3
3139dd7914aSmrg				;;
3149dd7914aSmrg			dicos)
3159dd7914aSmrg				basic_machine=i686-pc
3169dd7914aSmrg				basic_os=dicos
3179dd7914aSmrg				;;
3189dd7914aSmrg			djgpp)
3199dd7914aSmrg				basic_machine=i586-pc
3209dd7914aSmrg				basic_os=msdosdjgpp
3219dd7914aSmrg				;;
3229dd7914aSmrg			ebmon29k)
3239dd7914aSmrg				basic_machine=a29k-amd
3249dd7914aSmrg				basic_os=ebmon
3259dd7914aSmrg				;;
3269dd7914aSmrg			es1800 | OSE68k | ose68k | ose | OSE)
3279dd7914aSmrg				basic_machine=m68k-ericsson
3289dd7914aSmrg				basic_os=ose
3299dd7914aSmrg				;;
3309dd7914aSmrg			gmicro)
3319dd7914aSmrg				basic_machine=tron-gmicro
3329dd7914aSmrg				basic_os=sysv
3339dd7914aSmrg				;;
3349dd7914aSmrg			go32)
3359dd7914aSmrg				basic_machine=i386-pc
3369dd7914aSmrg				basic_os=go32
3379dd7914aSmrg				;;
3389dd7914aSmrg			h8300hms)
3399dd7914aSmrg				basic_machine=h8300-hitachi
3409dd7914aSmrg				basic_os=hms
3419dd7914aSmrg				;;
3429dd7914aSmrg			h8300xray)
3439dd7914aSmrg				basic_machine=h8300-hitachi
3449dd7914aSmrg				basic_os=xray
3459dd7914aSmrg				;;
3469dd7914aSmrg			h8500hms)
3479dd7914aSmrg				basic_machine=h8500-hitachi
3489dd7914aSmrg				basic_os=hms
3499dd7914aSmrg				;;
3509dd7914aSmrg			harris)
3519dd7914aSmrg				basic_machine=m88k-harris
3529dd7914aSmrg				basic_os=sysv3
3539dd7914aSmrg				;;
3549dd7914aSmrg			hp300 | hp300hpux)
3559dd7914aSmrg				basic_machine=m68k-hp
3569dd7914aSmrg				basic_os=hpux
3579dd7914aSmrg				;;
3589dd7914aSmrg			hp300bsd)
3599dd7914aSmrg				basic_machine=m68k-hp
3609dd7914aSmrg				basic_os=bsd
3619dd7914aSmrg				;;
3629dd7914aSmrg			hppaosf)
3639dd7914aSmrg				basic_machine=hppa1.1-hp
3649dd7914aSmrg				basic_os=osf
3659dd7914aSmrg				;;
3669dd7914aSmrg			hppro)
3679dd7914aSmrg				basic_machine=hppa1.1-hp
3689dd7914aSmrg				basic_os=proelf
3699dd7914aSmrg				;;
3709dd7914aSmrg			i386mach)
3719dd7914aSmrg				basic_machine=i386-mach
3729dd7914aSmrg				basic_os=mach
3739dd7914aSmrg				;;
3749dd7914aSmrg			isi68 | isi)
3759dd7914aSmrg				basic_machine=m68k-isi
3769dd7914aSmrg				basic_os=sysv
3779dd7914aSmrg				;;
3789dd7914aSmrg			m68knommu)
3799dd7914aSmrg				basic_machine=m68k-unknown
3809dd7914aSmrg				basic_os=linux
3819dd7914aSmrg				;;
3829dd7914aSmrg			magnum | m3230)
3839dd7914aSmrg				basic_machine=mips-mips
3849dd7914aSmrg				basic_os=sysv
3859dd7914aSmrg				;;
3869dd7914aSmrg			merlin)
3879dd7914aSmrg				basic_machine=ns32k-utek
3889dd7914aSmrg				basic_os=sysv
3899dd7914aSmrg				;;
3909dd7914aSmrg			mingw64)
3919dd7914aSmrg				basic_machine=x86_64-pc
3929dd7914aSmrg				basic_os=mingw64
3939dd7914aSmrg				;;
3949dd7914aSmrg			mingw32)
3959dd7914aSmrg				basic_machine=i686-pc
3969dd7914aSmrg				basic_os=mingw32
3979dd7914aSmrg				;;
3989dd7914aSmrg			mingw32ce)
3999dd7914aSmrg				basic_machine=arm-unknown
4009dd7914aSmrg				basic_os=mingw32ce
4019dd7914aSmrg				;;
4029dd7914aSmrg			monitor)
4039dd7914aSmrg				basic_machine=m68k-rom68k
4049dd7914aSmrg				basic_os=coff
4059dd7914aSmrg				;;
4069dd7914aSmrg			morphos)
4079dd7914aSmrg				basic_machine=powerpc-unknown
4089dd7914aSmrg				basic_os=morphos
4099dd7914aSmrg				;;
4109dd7914aSmrg			moxiebox)
4119dd7914aSmrg				basic_machine=moxie-unknown
4129dd7914aSmrg				basic_os=moxiebox
4139dd7914aSmrg				;;
4149dd7914aSmrg			msdos)
4159dd7914aSmrg				basic_machine=i386-pc
4169dd7914aSmrg				basic_os=msdos
4179dd7914aSmrg				;;
4189dd7914aSmrg			msys)
4199dd7914aSmrg				basic_machine=i686-pc
4209dd7914aSmrg				basic_os=msys
4219dd7914aSmrg				;;
4229dd7914aSmrg			mvs)
4239dd7914aSmrg				basic_machine=i370-ibm
4249dd7914aSmrg				basic_os=mvs
4259dd7914aSmrg				;;
4269dd7914aSmrg			nacl)
4279dd7914aSmrg				basic_machine=le32-unknown
4289dd7914aSmrg				basic_os=nacl
4299dd7914aSmrg				;;
4309dd7914aSmrg			ncr3000)
4319dd7914aSmrg				basic_machine=i486-ncr
4329dd7914aSmrg				basic_os=sysv4
4339dd7914aSmrg				;;
4349dd7914aSmrg			netbsd386)
4359dd7914aSmrg				basic_machine=i386-pc
4369dd7914aSmrg				basic_os=netbsd
4379dd7914aSmrg				;;
4389dd7914aSmrg			netwinder)
4399dd7914aSmrg				basic_machine=armv4l-rebel
4409dd7914aSmrg				basic_os=linux
4419dd7914aSmrg				;;
4429dd7914aSmrg			news | news700 | news800 | news900)
4439dd7914aSmrg				basic_machine=m68k-sony
4449dd7914aSmrg				basic_os=newsos
4459dd7914aSmrg				;;
4469dd7914aSmrg			news1000)
4479dd7914aSmrg				basic_machine=m68030-sony
4489dd7914aSmrg				basic_os=newsos
4499dd7914aSmrg				;;
4509dd7914aSmrg			necv70)
4519dd7914aSmrg				basic_machine=v70-nec
4529dd7914aSmrg				basic_os=sysv
4539dd7914aSmrg				;;
4549dd7914aSmrg			nh3000)
4559dd7914aSmrg				basic_machine=m68k-harris
4569dd7914aSmrg				basic_os=cxux
4579dd7914aSmrg				;;
4589dd7914aSmrg			nh[45]000)
4599dd7914aSmrg				basic_machine=m88k-harris
4609dd7914aSmrg				basic_os=cxux
4619dd7914aSmrg				;;
4629dd7914aSmrg			nindy960)
4639dd7914aSmrg				basic_machine=i960-intel
4649dd7914aSmrg				basic_os=nindy
4659dd7914aSmrg				;;
4669dd7914aSmrg			mon960)
4679dd7914aSmrg				basic_machine=i960-intel
4689dd7914aSmrg				basic_os=mon960
4699dd7914aSmrg				;;
4709dd7914aSmrg			nonstopux)
4719dd7914aSmrg				basic_machine=mips-compaq
4729dd7914aSmrg				basic_os=nonstopux
4739dd7914aSmrg				;;
4749dd7914aSmrg			os400)
4759dd7914aSmrg				basic_machine=powerpc-ibm
4769dd7914aSmrg				basic_os=os400
4779dd7914aSmrg				;;
4789dd7914aSmrg			OSE68000 | ose68000)
4799dd7914aSmrg				basic_machine=m68000-ericsson
4809dd7914aSmrg				basic_os=ose
4819dd7914aSmrg				;;
4829dd7914aSmrg			os68k)
4839dd7914aSmrg				basic_machine=m68k-none
4849dd7914aSmrg				basic_os=os68k
4859dd7914aSmrg				;;
4869dd7914aSmrg			paragon)
4879dd7914aSmrg				basic_machine=i860-intel
4889dd7914aSmrg				basic_os=osf
4899dd7914aSmrg				;;
4909dd7914aSmrg			parisc)
4919dd7914aSmrg				basic_machine=hppa-unknown
4929dd7914aSmrg				basic_os=linux
4939dd7914aSmrg				;;
4949dd7914aSmrg			psp)
4959dd7914aSmrg				basic_machine=mipsallegrexel-sony
4969dd7914aSmrg				basic_os=psp
4979dd7914aSmrg				;;
4989dd7914aSmrg			pw32)
4999dd7914aSmrg				basic_machine=i586-unknown
5009dd7914aSmrg				basic_os=pw32
5019dd7914aSmrg				;;
5029dd7914aSmrg			rdos | rdos64)
5039dd7914aSmrg				basic_machine=x86_64-pc
5049dd7914aSmrg				basic_os=rdos
5059dd7914aSmrg				;;
5069dd7914aSmrg			rdos32)
5079dd7914aSmrg				basic_machine=i386-pc
5089dd7914aSmrg				basic_os=rdos
5099dd7914aSmrg				;;
5109dd7914aSmrg			rom68k)
5119dd7914aSmrg				basic_machine=m68k-rom68k
5129dd7914aSmrg				basic_os=coff
5139dd7914aSmrg				;;
5149dd7914aSmrg			sa29200)
5159dd7914aSmrg				basic_machine=a29k-amd
5169dd7914aSmrg				basic_os=udi
5179dd7914aSmrg				;;
5189dd7914aSmrg			sei)
5199dd7914aSmrg				basic_machine=mips-sei
5209dd7914aSmrg				basic_os=seiux
5219dd7914aSmrg				;;
5229dd7914aSmrg			sequent)
5239dd7914aSmrg				basic_machine=i386-sequent
5249dd7914aSmrg				basic_os=
5259dd7914aSmrg				;;
5269dd7914aSmrg			sps7)
5279dd7914aSmrg				basic_machine=m68k-bull
5289dd7914aSmrg				basic_os=sysv2
5299dd7914aSmrg				;;
5309dd7914aSmrg			st2000)
5319dd7914aSmrg				basic_machine=m68k-tandem
5329dd7914aSmrg				basic_os=
5339dd7914aSmrg				;;
5349dd7914aSmrg			stratus)
5359dd7914aSmrg				basic_machine=i860-stratus
5369dd7914aSmrg				basic_os=sysv4
5379dd7914aSmrg				;;
5389dd7914aSmrg			sun2)
5399dd7914aSmrg				basic_machine=m68000-sun
5409dd7914aSmrg				basic_os=
5419dd7914aSmrg				;;
5429dd7914aSmrg			sun2os3)
5439dd7914aSmrg				basic_machine=m68000-sun
5449dd7914aSmrg				basic_os=sunos3
5459dd7914aSmrg				;;
5469dd7914aSmrg			sun2os4)
5479dd7914aSmrg				basic_machine=m68000-sun
5489dd7914aSmrg				basic_os=sunos4
5499dd7914aSmrg				;;
5509dd7914aSmrg			sun3)
5519dd7914aSmrg				basic_machine=m68k-sun
5529dd7914aSmrg				basic_os=
5539dd7914aSmrg				;;
5549dd7914aSmrg			sun3os3)
5559dd7914aSmrg				basic_machine=m68k-sun
5569dd7914aSmrg				basic_os=sunos3
5579dd7914aSmrg				;;
5589dd7914aSmrg			sun3os4)
5599dd7914aSmrg				basic_machine=m68k-sun
5609dd7914aSmrg				basic_os=sunos4
5619dd7914aSmrg				;;
5629dd7914aSmrg			sun4)
5639dd7914aSmrg				basic_machine=sparc-sun
5649dd7914aSmrg				basic_os=
5659dd7914aSmrg				;;
5669dd7914aSmrg			sun4os3)
5679dd7914aSmrg				basic_machine=sparc-sun
5689dd7914aSmrg				basic_os=sunos3
5699dd7914aSmrg				;;
5709dd7914aSmrg			sun4os4)
5719dd7914aSmrg				basic_machine=sparc-sun
5729dd7914aSmrg				basic_os=sunos4
5739dd7914aSmrg				;;
5749dd7914aSmrg			sun4sol2)
5759dd7914aSmrg				basic_machine=sparc-sun
5769dd7914aSmrg				basic_os=solaris2
5779dd7914aSmrg				;;
5789dd7914aSmrg			sun386 | sun386i | roadrunner)
5799dd7914aSmrg				basic_machine=i386-sun
5809dd7914aSmrg				basic_os=
5819dd7914aSmrg				;;
5829dd7914aSmrg			sv1)
5839dd7914aSmrg				basic_machine=sv1-cray
5849dd7914aSmrg				basic_os=unicos
5859dd7914aSmrg				;;
5869dd7914aSmrg			symmetry)
5879dd7914aSmrg				basic_machine=i386-sequent
5889dd7914aSmrg				basic_os=dynix
5899dd7914aSmrg				;;
5909dd7914aSmrg			t3e)
5919dd7914aSmrg				basic_machine=alphaev5-cray
5929dd7914aSmrg				basic_os=unicos
5939dd7914aSmrg				;;
5949dd7914aSmrg			t90)
5959dd7914aSmrg				basic_machine=t90-cray
5969dd7914aSmrg				basic_os=unicos
5979dd7914aSmrg				;;
5989dd7914aSmrg			toad1)
5999dd7914aSmrg				basic_machine=pdp10-xkl
6009dd7914aSmrg				basic_os=tops20
6019dd7914aSmrg				;;
6029dd7914aSmrg			tpf)
6039dd7914aSmrg				basic_machine=s390x-ibm
6049dd7914aSmrg				basic_os=tpf
6059dd7914aSmrg				;;
6069dd7914aSmrg			udi29k)
6079dd7914aSmrg				basic_machine=a29k-amd
6089dd7914aSmrg				basic_os=udi
6099dd7914aSmrg				;;
6109dd7914aSmrg			ultra3)
6119dd7914aSmrg				basic_machine=a29k-nyu
6129dd7914aSmrg				basic_os=sym1
6139dd7914aSmrg				;;
6149dd7914aSmrg			v810 | necv810)
6159dd7914aSmrg				basic_machine=v810-nec
6169dd7914aSmrg				basic_os=none
6179dd7914aSmrg				;;
6189dd7914aSmrg			vaxv)
6199dd7914aSmrg				basic_machine=vax-dec
6209dd7914aSmrg				basic_os=sysv
6219dd7914aSmrg				;;
6229dd7914aSmrg			vms)
6239dd7914aSmrg				basic_machine=vax-dec
6249dd7914aSmrg				basic_os=vms
6259dd7914aSmrg				;;
6269dd7914aSmrg			vsta)
6279dd7914aSmrg				basic_machine=i386-pc
6289dd7914aSmrg				basic_os=vsta
6299dd7914aSmrg				;;
6309dd7914aSmrg			vxworks960)
6319dd7914aSmrg				basic_machine=i960-wrs
6329dd7914aSmrg				basic_os=vxworks
6339dd7914aSmrg				;;
6349dd7914aSmrg			vxworks68)
6359dd7914aSmrg				basic_machine=m68k-wrs
6369dd7914aSmrg				basic_os=vxworks
6379dd7914aSmrg				;;
6389dd7914aSmrg			vxworks29k)
6399dd7914aSmrg				basic_machine=a29k-wrs
6409dd7914aSmrg				basic_os=vxworks
6419dd7914aSmrg				;;
6429dd7914aSmrg			xbox)
6439dd7914aSmrg				basic_machine=i686-pc
6449dd7914aSmrg				basic_os=mingw32
6459dd7914aSmrg				;;
6469dd7914aSmrg			ymp)
6479dd7914aSmrg				basic_machine=ymp-cray
6489dd7914aSmrg				basic_os=unicos
6499dd7914aSmrg				;;
6509dd7914aSmrg			*)
6519dd7914aSmrg				basic_machine=$1
6529dd7914aSmrg				basic_os=
6539dd7914aSmrg				;;
6549dd7914aSmrg		esac
655972599cfSmrg		;;
656972599cfSmrgesac
657972599cfSmrg
6589dd7914aSmrg# Decode 1-component or ad-hoc basic machines
659972599cfSmrgcase $basic_machine in
6609dd7914aSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6619dd7914aSmrg	# some cases the only manufacturer, in others, it is the most popular.
6629dd7914aSmrg	w89k)
6639dd7914aSmrg		cpu=hppa1.1
6649dd7914aSmrg		vendor=winbond
665972599cfSmrg		;;
6669dd7914aSmrg	op50n)
6679dd7914aSmrg		cpu=hppa1.1
6689dd7914aSmrg		vendor=oki
669972599cfSmrg		;;
6709dd7914aSmrg	op60c)
6719dd7914aSmrg		cpu=hppa1.1
6729dd7914aSmrg		vendor=oki
673972599cfSmrg		;;
6749dd7914aSmrg	ibm*)
6759dd7914aSmrg		cpu=i370
6769dd7914aSmrg		vendor=ibm
677972599cfSmrg		;;
6789dd7914aSmrg	orion105)
6799dd7914aSmrg		cpu=clipper
6809dd7914aSmrg		vendor=highlevel
6815eeb4e8fSmrg		;;
6829dd7914aSmrg	mac | mpw | mac-mpw)
6839dd7914aSmrg		cpu=m68k
6849dd7914aSmrg		vendor=apple
685972599cfSmrg		;;
6869dd7914aSmrg	pmac | pmac-mpw)
6879dd7914aSmrg		cpu=powerpc
6889dd7914aSmrg		vendor=apple
689972599cfSmrg		;;
690972599cfSmrg
691972599cfSmrg	# Recognize the various machine names and aliases which stand
692972599cfSmrg	# for a CPU type and a company and sometimes even an OS.
693972599cfSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6949dd7914aSmrg		cpu=m68000
6959dd7914aSmrg		vendor=att
696972599cfSmrg		;;
697972599cfSmrg	3b*)
6989dd7914aSmrg		cpu=we32k
6999dd7914aSmrg		vendor=att
700972599cfSmrg		;;
701972599cfSmrg	bluegene*)
7029dd7914aSmrg		cpu=powerpc
7039dd7914aSmrg		vendor=ibm
7049dd7914aSmrg		basic_os=cnk
705972599cfSmrg		;;
706972599cfSmrg	decsystem10* | dec10*)
7079dd7914aSmrg		cpu=pdp10
7089dd7914aSmrg		vendor=dec
7099dd7914aSmrg		basic_os=tops10
710972599cfSmrg		;;
711972599cfSmrg	decsystem20* | dec20*)
7129dd7914aSmrg		cpu=pdp10
7139dd7914aSmrg		vendor=dec
7149dd7914aSmrg		basic_os=tops20
715972599cfSmrg		;;
716972599cfSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717972599cfSmrg	      | 3300-motorola | delta-motorola)
7189dd7914aSmrg		cpu=m68k
7199dd7914aSmrg		vendor=motorola
720972599cfSmrg		;;
7219dd7914aSmrg	dpx2*)
7229dd7914aSmrg		cpu=m68k
7239dd7914aSmrg		vendor=bull
7249dd7914aSmrg		basic_os=sysv3
725972599cfSmrg		;;
726972599cfSmrg	encore | umax | mmax)
7279dd7914aSmrg		cpu=ns32k
7289dd7914aSmrg		vendor=encore
729972599cfSmrg		;;
7309dd7914aSmrg	elxsi)
7319dd7914aSmrg		cpu=elxsi
7329dd7914aSmrg		vendor=elxsi
7339dd7914aSmrg		basic_os=${basic_os:-bsd}
734972599cfSmrg		;;
735972599cfSmrg	fx2800)
7369dd7914aSmrg		cpu=i860
7379dd7914aSmrg		vendor=alliant
738972599cfSmrg		;;
739972599cfSmrg	genix)
7409dd7914aSmrg		cpu=ns32k
7419dd7914aSmrg		vendor=ns
742972599cfSmrg		;;
743972599cfSmrg	h3050r* | hiux*)
7449dd7914aSmrg		cpu=hppa1.1
7459dd7914aSmrg		vendor=hitachi
7469dd7914aSmrg		basic_os=hiuxwe2
747972599cfSmrg		;;
748972599cfSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7499dd7914aSmrg		cpu=hppa1.0
7509dd7914aSmrg		vendor=hp
751972599cfSmrg		;;
752972599cfSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7539dd7914aSmrg		cpu=m68000
7549dd7914aSmrg		vendor=hp
755972599cfSmrg		;;
756972599cfSmrg	hp9k3[2-9][0-9])
7579dd7914aSmrg		cpu=m68k
7589dd7914aSmrg		vendor=hp
759972599cfSmrg		;;
760972599cfSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7619dd7914aSmrg		cpu=hppa1.0
7629dd7914aSmrg		vendor=hp
763972599cfSmrg		;;
764972599cfSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7659dd7914aSmrg		cpu=hppa1.1
7669dd7914aSmrg		vendor=hp
767972599cfSmrg		;;
768972599cfSmrg	hp9k78[0-9] | hp78[0-9])
769972599cfSmrg		# FIXME: really hppa2.0-hp
7709dd7914aSmrg		cpu=hppa1.1
7719dd7914aSmrg		vendor=hp
772972599cfSmrg		;;
773972599cfSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774972599cfSmrg		# FIXME: really hppa2.0-hp
7759dd7914aSmrg		cpu=hppa1.1
7769dd7914aSmrg		vendor=hp
777972599cfSmrg		;;
778972599cfSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7799dd7914aSmrg		cpu=hppa1.1
7809dd7914aSmrg		vendor=hp
781972599cfSmrg		;;
782972599cfSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7839dd7914aSmrg		cpu=hppa1.0
7849dd7914aSmrg		vendor=hp
785972599cfSmrg		;;
786972599cfSmrg	i*86v32)
7879dd7914aSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7889dd7914aSmrg		vendor=pc
7899dd7914aSmrg		basic_os=sysv32
790972599cfSmrg		;;
791972599cfSmrg	i*86v4*)
7929dd7914aSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7939dd7914aSmrg		vendor=pc
7949dd7914aSmrg		basic_os=sysv4
795972599cfSmrg		;;
796972599cfSmrg	i*86v)
7979dd7914aSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7989dd7914aSmrg		vendor=pc
7999dd7914aSmrg		basic_os=sysv
800972599cfSmrg		;;
801972599cfSmrg	i*86sol2)
8029dd7914aSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8039dd7914aSmrg		vendor=pc
8049dd7914aSmrg		basic_os=solaris2
805972599cfSmrg		;;
8069dd7914aSmrg	j90 | j90-cray)
8079dd7914aSmrg		cpu=j90
8089dd7914aSmrg		vendor=cray
8099dd7914aSmrg		basic_os=${basic_os:-unicos}
810972599cfSmrg		;;
811972599cfSmrg	iris | iris4d)
8129dd7914aSmrg		cpu=mips
8139dd7914aSmrg		vendor=sgi
8149dd7914aSmrg		case $basic_os in
8159dd7914aSmrg		    irix*)
816972599cfSmrg			;;
817972599cfSmrg		    *)
8189dd7914aSmrg			basic_os=irix4
819972599cfSmrg			;;
820972599cfSmrg		esac
821972599cfSmrg		;;
822972599cfSmrg	miniframe)
8239dd7914aSmrg		cpu=m68000
8249dd7914aSmrg		vendor=convergent
825972599cfSmrg		;;
8269dd7914aSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8279dd7914aSmrg		cpu=m68k
8289dd7914aSmrg		vendor=atari
8299dd7914aSmrg		basic_os=mint
830972599cfSmrg		;;
831972599cfSmrg	news-3600 | risc-news)
8329dd7914aSmrg		cpu=mips
8339dd7914aSmrg		vendor=sony
8349dd7914aSmrg		basic_os=newsos
8359dd7914aSmrg		;;
8369dd7914aSmrg	next | m*-next)
8379dd7914aSmrg		cpu=m68k
8389dd7914aSmrg		vendor=next
8399dd7914aSmrg		case $basic_os in
8409dd7914aSmrg		    openstep*)
8419dd7914aSmrg		        ;;
8429dd7914aSmrg		    nextstep*)
843972599cfSmrg			;;
8449dd7914aSmrg		    ns2*)
8459dd7914aSmrg		      basic_os=nextstep2
846972599cfSmrg			;;
847972599cfSmrg		    *)
8489dd7914aSmrg		      basic_os=nextstep3
849972599cfSmrg			;;
850972599cfSmrg		esac
851972599cfSmrg		;;
852972599cfSmrg	np1)
8539dd7914aSmrg		cpu=np1
8549dd7914aSmrg		vendor=gould
855972599cfSmrg		;;
856972599cfSmrg	op50n-* | op60c-*)
8579dd7914aSmrg		cpu=hppa1.1
8589dd7914aSmrg		vendor=oki
8599dd7914aSmrg		basic_os=proelf
860972599cfSmrg		;;
861972599cfSmrg	pa-hitachi)
8629dd7914aSmrg		cpu=hppa1.1
8639dd7914aSmrg		vendor=hitachi
8649dd7914aSmrg		basic_os=hiuxwe2
865972599cfSmrg		;;
866972599cfSmrg	pbd)
8679dd7914aSmrg		cpu=sparc
8689dd7914aSmrg		vendor=tti
869972599cfSmrg		;;
870972599cfSmrg	pbb)
8719dd7914aSmrg		cpu=m68k
8729dd7914aSmrg		vendor=tti
873972599cfSmrg		;;
8749dd7914aSmrg	pc532)
8759dd7914aSmrg		cpu=ns32k
8769dd7914aSmrg		vendor=pc532
877972599cfSmrg		;;
878972599cfSmrg	pn)
8799dd7914aSmrg		cpu=pn
8809dd7914aSmrg		vendor=gould
881972599cfSmrg		;;
8829dd7914aSmrg	power)
8839dd7914aSmrg		cpu=power
8849dd7914aSmrg		vendor=ibm
885972599cfSmrg		;;
886972599cfSmrg	ps2)
8879dd7914aSmrg		cpu=i386
8889dd7914aSmrg		vendor=ibm
889972599cfSmrg		;;
890972599cfSmrg	rm[46]00)
8919dd7914aSmrg		cpu=mips
8929dd7914aSmrg		vendor=siemens
893972599cfSmrg		;;
894972599cfSmrg	rtpc | rtpc-*)
8959dd7914aSmrg		cpu=romp
8969dd7914aSmrg		vendor=ibm
897972599cfSmrg		;;
8989dd7914aSmrg	sde)
8999dd7914aSmrg		cpu=mipsisa32
9009dd7914aSmrg		vendor=sde
9019dd7914aSmrg		basic_os=${basic_os:-elf}
902972599cfSmrg		;;
9039dd7914aSmrg	simso-wrs)
9049dd7914aSmrg		cpu=sparclite
9059dd7914aSmrg		vendor=wrs
9069dd7914aSmrg		basic_os=vxworks
907972599cfSmrg		;;
9089dd7914aSmrg	tower | tower-32)
9099dd7914aSmrg		cpu=m68k
9109dd7914aSmrg		vendor=ncr
911972599cfSmrg		;;
9129dd7914aSmrg	vpp*|vx|vx-*)
9139dd7914aSmrg		cpu=f301
9149dd7914aSmrg		vendor=fujitsu
915972599cfSmrg		;;
9169dd7914aSmrg	w65)
9179dd7914aSmrg		cpu=w65
9189dd7914aSmrg		vendor=wdc
919972599cfSmrg		;;
9209dd7914aSmrg	w89k-*)
9219dd7914aSmrg		cpu=hppa1.1
9229dd7914aSmrg		vendor=winbond
9239dd7914aSmrg		basic_os=proelf
924972599cfSmrg		;;
9259dd7914aSmrg	none)
9269dd7914aSmrg		cpu=none
9279dd7914aSmrg		vendor=none
928972599cfSmrg		;;
9299dd7914aSmrg	leon|leon[3-9])
9309dd7914aSmrg		cpu=sparc
9319dd7914aSmrg		vendor=$basic_machine
932972599cfSmrg		;;
9339dd7914aSmrg	leon-*|leon[3-9]-*)
9349dd7914aSmrg		cpu=sparc
9359dd7914aSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936972599cfSmrg		;;
9379dd7914aSmrg
9389dd7914aSmrg	*-*)
9399dd7914aSmrg		# shellcheck disable=SC2162
9409dd7914aSmrg		saved_IFS=$IFS
9419dd7914aSmrg		IFS="-" read cpu vendor <<EOF
9429dd7914aSmrg$basic_machine
9439dd7914aSmrgEOF
9449dd7914aSmrg		IFS=$saved_IFS
945972599cfSmrg		;;
9469dd7914aSmrg	# We use `pc' rather than `unknown'
9479dd7914aSmrg	# because (1) that's what they normally are, and
9489dd7914aSmrg	# (2) the word "unknown" tends to confuse beginning users.
9499dd7914aSmrg	i*86 | x86_64)
9509dd7914aSmrg		cpu=$basic_machine
9519dd7914aSmrg		vendor=pc
952972599cfSmrg		;;
9539dd7914aSmrg	# These rules are duplicated from below for sake of the special case above;
9549dd7914aSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
9559dd7914aSmrg	pc98)
9569dd7914aSmrg		cpu=i386
9579dd7914aSmrg		vendor=pc
958972599cfSmrg		;;
9599dd7914aSmrg	x64 | amd64)
9609dd7914aSmrg		cpu=x86_64
9619dd7914aSmrg		vendor=pc
962972599cfSmrg		;;
9639dd7914aSmrg	# Recognize the basic CPU types without company name.
9649dd7914aSmrg	*)
9659dd7914aSmrg		cpu=$basic_machine
9669dd7914aSmrg		vendor=unknown
967972599cfSmrg		;;
9689dd7914aSmrgesac
9699dd7914aSmrg
9709dd7914aSmrgunset -v basic_machine
9719dd7914aSmrg
9729dd7914aSmrg# Decode basic machines in the full and proper CPU-Company form.
9739dd7914aSmrgcase $cpu-$vendor in
9749dd7914aSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9759dd7914aSmrg	# some cases the only manufacturer, in others, it is the most popular.
9769dd7914aSmrg	craynv-unknown)
9779dd7914aSmrg		vendor=cray
9789dd7914aSmrg		basic_os=${basic_os:-unicosmp}
979972599cfSmrg		;;
9809dd7914aSmrg	c90-unknown | c90-cray)
9819dd7914aSmrg		vendor=cray
9829dd7914aSmrg		basic_os=${Basic_os:-unicos}
983972599cfSmrg		;;
9849dd7914aSmrg	fx80-unknown)
9859dd7914aSmrg		vendor=alliant
986972599cfSmrg		;;
9879dd7914aSmrg	romp-unknown)
9889dd7914aSmrg		vendor=ibm
989972599cfSmrg		;;
9909dd7914aSmrg	mmix-unknown)
9919dd7914aSmrg		vendor=knuth
992972599cfSmrg		;;
9939dd7914aSmrg	microblaze-unknown | microblazeel-unknown)
9949dd7914aSmrg		vendor=xilinx
995972599cfSmrg		;;
9969dd7914aSmrg	rs6000-unknown)
9979dd7914aSmrg		vendor=ibm
998972599cfSmrg		;;
9999dd7914aSmrg	vax-unknown)
10009dd7914aSmrg		vendor=dec
1001972599cfSmrg		;;
10029dd7914aSmrg	pdp11-unknown)
10039dd7914aSmrg		vendor=dec
1004972599cfSmrg		;;
10059dd7914aSmrg	we32k-unknown)
10069dd7914aSmrg		vendor=att
1007972599cfSmrg		;;
10089dd7914aSmrg	cydra-unknown)
10099dd7914aSmrg		vendor=cydrome
1010972599cfSmrg		;;
10119dd7914aSmrg	i370-ibm*)
10129dd7914aSmrg		vendor=ibm
1013972599cfSmrg		;;
10149dd7914aSmrg	orion-unknown)
10159dd7914aSmrg		vendor=highlevel
1016972599cfSmrg		;;
10179dd7914aSmrg	xps-unknown | xps100-unknown)
10189dd7914aSmrg		cpu=xps100
10199dd7914aSmrg		vendor=honeywell
1020972599cfSmrg		;;
10219dd7914aSmrg
10229dd7914aSmrg	# Here we normalize CPU types with a missing or matching vendor
10239dd7914aSmrg	armh-unknown | armh-alt)
10249dd7914aSmrg		cpu=armv7l
10259dd7914aSmrg		vendor=alt
10269dd7914aSmrg		basic_os=${basic_os:-linux-gnueabihf}
1027972599cfSmrg		;;
10289dd7914aSmrg	dpx20-unknown | dpx20-bull)
10299dd7914aSmrg		cpu=rs6000
10309dd7914aSmrg		vendor=bull
10319dd7914aSmrg		basic_os=${basic_os:-bosx}
1032972599cfSmrg		;;
10339dd7914aSmrg
10349dd7914aSmrg	# Here we normalize CPU types irrespective of the vendor
10359dd7914aSmrg	amd64-*)
10369dd7914aSmrg		cpu=x86_64
1037972599cfSmrg		;;
10389dd7914aSmrg	blackfin-*)
10399dd7914aSmrg		cpu=bfin
10409dd7914aSmrg		basic_os=linux
1041972599cfSmrg		;;
10429dd7914aSmrg	c54x-*)
10439dd7914aSmrg		cpu=tic54x
1044972599cfSmrg		;;
10459dd7914aSmrg	c55x-*)
10469dd7914aSmrg		cpu=tic55x
1047972599cfSmrg		;;
10489dd7914aSmrg	c6x-*)
10499dd7914aSmrg		cpu=tic6x
1050972599cfSmrg		;;
10519dd7914aSmrg	e500v[12]-*)
10529dd7914aSmrg		cpu=powerpc
10539dd7914aSmrg		basic_os=${basic_os}"spe"
1054972599cfSmrg		;;
10559dd7914aSmrg	mips3*-*)
10569dd7914aSmrg		cpu=mips64
1057972599cfSmrg		;;
10589dd7914aSmrg	ms1-*)
10599dd7914aSmrg		cpu=mt
1060972599cfSmrg		;;
10619dd7914aSmrg	m68knommu-*)
10629dd7914aSmrg		cpu=m68k
10639dd7914aSmrg		basic_os=linux
1064972599cfSmrg		;;
10659dd7914aSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10669dd7914aSmrg		cpu=s12z
1067972599cfSmrg		;;
10689dd7914aSmrg	openrisc-*)
10699dd7914aSmrg		cpu=or32
1070972599cfSmrg		;;
10719dd7914aSmrg	parisc-*)
10729dd7914aSmrg		cpu=hppa
10739dd7914aSmrg		basic_os=linux
1074972599cfSmrg		;;
10759dd7914aSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10769dd7914aSmrg		cpu=i586
1077972599cfSmrg		;;
10789dd7914aSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10799dd7914aSmrg		cpu=i686
1080972599cfSmrg		;;
10819dd7914aSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10829dd7914aSmrg		cpu=i686
1083972599cfSmrg		;;
10849dd7914aSmrg	pentium4-*)
10859dd7914aSmrg		cpu=i786
1086972599cfSmrg		;;
10879dd7914aSmrg	pc98-*)
10889dd7914aSmrg		cpu=i386
1089972599cfSmrg		;;
10909dd7914aSmrg	ppc-* | ppcbe-*)
10919dd7914aSmrg		cpu=powerpc
1092972599cfSmrg		;;
10939dd7914aSmrg	ppcle-* | powerpclittle-*)
10949dd7914aSmrg		cpu=powerpcle
1095972599cfSmrg		;;
10969dd7914aSmrg	ppc64-*)
10979dd7914aSmrg		cpu=powerpc64
1098972599cfSmrg		;;
10999dd7914aSmrg	ppc64le-* | powerpc64little-*)
11009dd7914aSmrg		cpu=powerpc64le
1101972599cfSmrg		;;
11029dd7914aSmrg	sb1-*)
11039dd7914aSmrg		cpu=mipsisa64sb1
1104972599cfSmrg		;;
11059dd7914aSmrg	sb1el-*)
11069dd7914aSmrg		cpu=mipsisa64sb1el
1107972599cfSmrg		;;
11089dd7914aSmrg	sh5e[lb]-*)
11099dd7914aSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110972599cfSmrg		;;
11119dd7914aSmrg	spur-*)
11129dd7914aSmrg		cpu=spur
1113972599cfSmrg		;;
11149dd7914aSmrg	strongarm-* | thumb-*)
11159dd7914aSmrg		cpu=arm
1116972599cfSmrg		;;
11179dd7914aSmrg	tx39-*)
11189dd7914aSmrg		cpu=mipstx39
1119972599cfSmrg		;;
11209dd7914aSmrg	tx39el-*)
11219dd7914aSmrg		cpu=mipstx39el
1122972599cfSmrg		;;
11239dd7914aSmrg	x64-*)
11249dd7914aSmrg		cpu=x86_64
1125972599cfSmrg		;;
11269dd7914aSmrg	xscale-* | xscalee[bl]-*)
11279dd7914aSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128972599cfSmrg		;;
11299dd7914aSmrg	arm64-* | aarch64le-*)
11309dd7914aSmrg		cpu=aarch64
1131972599cfSmrg		;;
11329dd7914aSmrg
11339dd7914aSmrg	# Recognize the canonical CPU Types that limit and/or modify the
11349dd7914aSmrg	# company names they are paired with.
11359dd7914aSmrg	cr16-*)
11369dd7914aSmrg		basic_os=${basic_os:-elf}
1137972599cfSmrg		;;
11389dd7914aSmrg	crisv32-* | etraxfs*-*)
11399dd7914aSmrg		cpu=crisv32
11409dd7914aSmrg		vendor=axis
1141972599cfSmrg		;;
11429dd7914aSmrg	cris-* | etrax*-*)
11439dd7914aSmrg		cpu=cris
11449dd7914aSmrg		vendor=axis
1145972599cfSmrg		;;
11469dd7914aSmrg	crx-*)
11479dd7914aSmrg		basic_os=${basic_os:-elf}
1148972599cfSmrg		;;
11499dd7914aSmrg	neo-tandem)
11509dd7914aSmrg		cpu=neo
11519dd7914aSmrg		vendor=tandem
1152972599cfSmrg		;;
11539dd7914aSmrg	nse-tandem)
11549dd7914aSmrg		cpu=nse
11559dd7914aSmrg		vendor=tandem
1156972599cfSmrg		;;
11579dd7914aSmrg	nsr-tandem)
11589dd7914aSmrg		cpu=nsr
11599dd7914aSmrg		vendor=tandem
1160972599cfSmrg		;;
11619dd7914aSmrg	nsv-tandem)
11629dd7914aSmrg		cpu=nsv
11639dd7914aSmrg		vendor=tandem
1164972599cfSmrg		;;
11659dd7914aSmrg	nsx-tandem)
11669dd7914aSmrg		cpu=nsx
11679dd7914aSmrg		vendor=tandem
1168972599cfSmrg		;;
11699dd7914aSmrg	mipsallegrexel-sony)
11709dd7914aSmrg		cpu=mipsallegrexel
11719dd7914aSmrg		vendor=sony
1172972599cfSmrg		;;
11739dd7914aSmrg	tile*-*)
11749dd7914aSmrg		basic_os=${basic_os:-linux-gnu}
1175972599cfSmrg		;;
11769dd7914aSmrg
1177972599cfSmrg	*)
11789dd7914aSmrg		# Recognize the canonical CPU types that are allowed with any
11799dd7914aSmrg		# company name.
11809dd7914aSmrg		case $cpu in
11819dd7914aSmrg			1750a | 580 \
11829dd7914aSmrg			| a29k \
11839dd7914aSmrg			| aarch64 | aarch64_be \
11849dd7914aSmrg			| abacus \
11859dd7914aSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11869dd7914aSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11879dd7914aSmrg			| alphapca5[67] | alpha64pca5[67] \
11889dd7914aSmrg			| am33_2.0 \
11899dd7914aSmrg			| amdgcn \
11909dd7914aSmrg			| arc | arceb | arc32 | arc64 \
11919dd7914aSmrg			| arm | arm[lb]e | arme[lb] | armv* \
11929dd7914aSmrg			| avr | avr32 \
11939dd7914aSmrg			| asmjs \
11949dd7914aSmrg			| ba \
11959dd7914aSmrg			| be32 | be64 \
11969dd7914aSmrg			| bfin | bpf | bs2000 \
11979dd7914aSmrg			| c[123]* | c30 | [cjt]90 | c4x \
11989dd7914aSmrg			| c8051 | clipper | craynv | csky | cydra \
11999dd7914aSmrg			| d10v | d30v | dlx | dsp16xx \
12009dd7914aSmrg			| e2k | elxsi | epiphany \
12019dd7914aSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12029dd7914aSmrg			| h8300 | h8500 \
12039dd7914aSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12049dd7914aSmrg			| hexagon \
12059dd7914aSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12069dd7914aSmrg			| ip2k | iq2000 \
12079dd7914aSmrg			| k1om \
12089dd7914aSmrg			| le32 | le64 \
12099dd7914aSmrg			| lm32 \
12109dd7914aSmrg			| loongarch32 | loongarch64 \
12119dd7914aSmrg			| m32c | m32r | m32rle \
12129dd7914aSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12139dd7914aSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12149dd7914aSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12159dd7914aSmrg			| microblaze | microblazeel \
12169dd7914aSmrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12179dd7914aSmrg			| mips16 \
12189dd7914aSmrg			| mips64 | mips64eb | mips64el \
12199dd7914aSmrg			| mips64octeon | mips64octeonel \
12209dd7914aSmrg			| mips64orion | mips64orionel \
12219dd7914aSmrg			| mips64r5900 | mips64r5900el \
12229dd7914aSmrg			| mips64vr | mips64vrel \
12239dd7914aSmrg			| mips64vr4100 | mips64vr4100el \
12249dd7914aSmrg			| mips64vr4300 | mips64vr4300el \
12259dd7914aSmrg			| mips64vr5000 | mips64vr5000el \
12269dd7914aSmrg			| mips64vr5900 | mips64vr5900el \
12279dd7914aSmrg			| mipsisa32 | mipsisa32el \
12289dd7914aSmrg			| mipsisa32r2 | mipsisa32r2el \
12299dd7914aSmrg			| mipsisa32r3 | mipsisa32r3el \
12309dd7914aSmrg			| mipsisa32r5 | mipsisa32r5el \
12319dd7914aSmrg			| mipsisa32r6 | mipsisa32r6el \
12329dd7914aSmrg			| mipsisa64 | mipsisa64el \
12339dd7914aSmrg			| mipsisa64r2 | mipsisa64r2el \
12349dd7914aSmrg			| mipsisa64r3 | mipsisa64r3el \
12359dd7914aSmrg			| mipsisa64r5 | mipsisa64r5el \
12369dd7914aSmrg			| mipsisa64r6 | mipsisa64r6el \
12379dd7914aSmrg			| mipsisa64sb1 | mipsisa64sb1el \
12389dd7914aSmrg			| mipsisa64sr71k | mipsisa64sr71kel \
12399dd7914aSmrg			| mipsr5900 | mipsr5900el \
12409dd7914aSmrg			| mipstx39 | mipstx39el \
12419dd7914aSmrg			| mmix \
12429dd7914aSmrg			| mn10200 | mn10300 \
12439dd7914aSmrg			| moxie \
12449dd7914aSmrg			| mt \
12459dd7914aSmrg			| msp430 \
12469dd7914aSmrg			| nds32 | nds32le | nds32be \
12479dd7914aSmrg			| nfp \
12489dd7914aSmrg			| nios | nios2 | nios2eb | nios2el \
12499dd7914aSmrg			| none | np1 | ns16k | ns32k | nvptx \
12509dd7914aSmrg			| open8 \
12519dd7914aSmrg			| or1k* \
12529dd7914aSmrg			| or32 \
12539dd7914aSmrg			| orion \
12549dd7914aSmrg			| picochip \
12559dd7914aSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12569dd7914aSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12579dd7914aSmrg			| pru \
12589dd7914aSmrg			| pyramid \
12599dd7914aSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12609dd7914aSmrg			| rl78 | romp | rs6000 | rx \
12619dd7914aSmrg			| s390 | s390x \
12629dd7914aSmrg			| score \
12639dd7914aSmrg			| sh | shl \
12649dd7914aSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12659dd7914aSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12669dd7914aSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12679dd7914aSmrg			| sparclite \
12689dd7914aSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12699dd7914aSmrg			| spu \
12709dd7914aSmrg			| tahoe \
12719dd7914aSmrg			| thumbv7* \
12729dd7914aSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12739dd7914aSmrg			| tron \
12749dd7914aSmrg			| ubicom32 \
12759dd7914aSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12769dd7914aSmrg			| vax \
12779dd7914aSmrg			| visium \
12789dd7914aSmrg			| w65 \
12799dd7914aSmrg			| wasm32 | wasm64 \
12809dd7914aSmrg			| we32k \
12819dd7914aSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12829dd7914aSmrg			| xstormy16 | xtensa* \
12839dd7914aSmrg			| ymp \
12849dd7914aSmrg			| z8k | z80)
12859dd7914aSmrg				;;
12869dd7914aSmrg
12879dd7914aSmrg			*)
12889dd7914aSmrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12899dd7914aSmrg				exit 1
12909dd7914aSmrg				;;
12919dd7914aSmrg		esac
1292972599cfSmrg		;;
1293972599cfSmrgesac
1294972599cfSmrg
1295972599cfSmrg# Here we canonicalize certain aliases for manufacturers.
12969dd7914aSmrgcase $vendor in
12979dd7914aSmrg	digital*)
12989dd7914aSmrg		vendor=dec
1299972599cfSmrg		;;
13009dd7914aSmrg	commodore*)
13019dd7914aSmrg		vendor=cbm
1302972599cfSmrg		;;
1303972599cfSmrg	*)
1304972599cfSmrg		;;
1305972599cfSmrgesac
1306972599cfSmrg
1307972599cfSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308972599cfSmrg
13099dd7914aSmrgif test x$basic_os != x
1310972599cfSmrgthen
13119dd7914aSmrg
13129dd7914aSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13139dd7914aSmrg# set os.
13149dd7914aSmrgcase $basic_os in
13159dd7914aSmrg	gnu/linux*)
13169dd7914aSmrg		kernel=linux
13179dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13189dd7914aSmrg		;;
13199dd7914aSmrg	os2-emx)
13209dd7914aSmrg		kernel=os2
13219dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13229dd7914aSmrg		;;
13239dd7914aSmrg	nto-qnx*)
13249dd7914aSmrg		kernel=nto
13259dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13269dd7914aSmrg		;;
13279dd7914aSmrg	*-*)
13289dd7914aSmrg		# shellcheck disable=SC2162
13299dd7914aSmrg		saved_IFS=$IFS
13309dd7914aSmrg		IFS="-" read kernel os <<EOF
13319dd7914aSmrg$basic_os
13329dd7914aSmrgEOF
13339dd7914aSmrg		IFS=$saved_IFS
13349dd7914aSmrg		;;
13359dd7914aSmrg	# Default OS when just kernel was specified
13369dd7914aSmrg	nto*)
13379dd7914aSmrg		kernel=nto
13389dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13399dd7914aSmrg		;;
13409dd7914aSmrg	linux*)
13419dd7914aSmrg		kernel=linux
13429dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13439dd7914aSmrg		;;
13449dd7914aSmrg	managarm*)
13459dd7914aSmrg		kernel=managarm
13469dd7914aSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13479dd7914aSmrg		;;
13489dd7914aSmrg	*)
13499dd7914aSmrg		kernel=
13509dd7914aSmrg		os=$basic_os
13519dd7914aSmrg		;;
13529dd7914aSmrgesac
13539dd7914aSmrg
13549dd7914aSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13559dd7914aSmrg# etc.)
1356972599cfSmrgcase $os in
13579dd7914aSmrg	# First match some system type aliases that might get confused
13589dd7914aSmrg	# with valid system types.
13599dd7914aSmrg	# solaris* is a basic system type, with this one exception.
13609dd7914aSmrg	auroraux)
13619dd7914aSmrg		os=auroraux
1362972599cfSmrg		;;
13639dd7914aSmrg	bluegene*)
13649dd7914aSmrg		os=cnk
1365972599cfSmrg		;;
13669dd7914aSmrg	solaris1 | solaris1.*)
13679dd7914aSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368972599cfSmrg		;;
13699dd7914aSmrg	solaris)
13709dd7914aSmrg		os=solaris2
1371972599cfSmrg		;;
13729dd7914aSmrg	unixware*)
13739dd7914aSmrg		os=sysv4.2uw
1374972599cfSmrg		;;
13759dd7914aSmrg	# es1800 is here to avoid being matched by es* (a different OS)
13769dd7914aSmrg	es1800*)
13779dd7914aSmrg		os=ose
1378972599cfSmrg		;;
13799dd7914aSmrg	# Some version numbers need modification
13809dd7914aSmrg	chorusos*)
13819dd7914aSmrg		os=chorusos
1382972599cfSmrg		;;
13839dd7914aSmrg	isc)
13849dd7914aSmrg		os=isc2.2
1385972599cfSmrg		;;
13869dd7914aSmrg	sco6)
13879dd7914aSmrg		os=sco5v6
1388972599cfSmrg		;;
13899dd7914aSmrg	sco5)
13909dd7914aSmrg		os=sco3.2v5
1391972599cfSmrg		;;
13929dd7914aSmrg	sco4)
13939dd7914aSmrg		os=sco3.2v4
1394972599cfSmrg		;;
13959dd7914aSmrg	sco3.2.[4-9]*)
13969dd7914aSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397972599cfSmrg		;;
13989dd7914aSmrg	sco*v* | scout)
13999dd7914aSmrg		# Don't match below
1400972599cfSmrg		;;
14019dd7914aSmrg	sco*)
14029dd7914aSmrg		os=sco3.2v2
1403972599cfSmrg		;;
14049dd7914aSmrg	psos*)
14059dd7914aSmrg		os=psos
1406972599cfSmrg		;;
14079dd7914aSmrg	qnx*)
14089dd7914aSmrg		os=qnx
1409972599cfSmrg		;;
14109dd7914aSmrg	hiux*)
14119dd7914aSmrg		os=hiuxwe2
1412972599cfSmrg		;;
14139dd7914aSmrg	lynx*178)
14149dd7914aSmrg		os=lynxos178
1415972599cfSmrg		;;
14169dd7914aSmrg	lynx*5)
14179dd7914aSmrg		os=lynxos5
1418972599cfSmrg		;;
14199dd7914aSmrg	lynxos*)
14209dd7914aSmrg		# don't get caught up in next wildcard
1421972599cfSmrg		;;
14229dd7914aSmrg	lynx*)
14239dd7914aSmrg		os=lynxos
1424972599cfSmrg		;;
14259dd7914aSmrg	mac[0-9]*)
14269dd7914aSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427972599cfSmrg		;;
14289dd7914aSmrg	opened*)
14299dd7914aSmrg		os=openedition
1430972599cfSmrg		;;
14319dd7914aSmrg	os400*)
14329dd7914aSmrg		os=os400
1433972599cfSmrg		;;
14349dd7914aSmrg	sunos5*)
14359dd7914aSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436972599cfSmrg		;;
14379dd7914aSmrg	sunos6*)
14389dd7914aSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439972599cfSmrg		;;
14409dd7914aSmrg	wince*)
14419dd7914aSmrg		os=wince
1442972599cfSmrg		;;
14439dd7914aSmrg	utek*)
14449dd7914aSmrg		os=bsd
1445972599cfSmrg		;;
14469dd7914aSmrg	dynix*)
14479dd7914aSmrg		os=bsd
1448972599cfSmrg		;;
14499dd7914aSmrg	acis*)
14509dd7914aSmrg		os=aos
1451972599cfSmrg		;;
14529dd7914aSmrg	atheos*)
14539dd7914aSmrg		os=atheos
1454972599cfSmrg		;;
14559dd7914aSmrg	syllable*)
14569dd7914aSmrg		os=syllable
1457972599cfSmrg		;;
14589dd7914aSmrg	386bsd)
14599dd7914aSmrg		os=bsd
1460972599cfSmrg		;;
14619dd7914aSmrg	ctix* | uts*)
14629dd7914aSmrg		os=sysv
1463972599cfSmrg		;;
14649dd7914aSmrg	nova*)
14659dd7914aSmrg		os=rtmk-nova
1466972599cfSmrg		;;
14679dd7914aSmrg	ns2)
14689dd7914aSmrg		os=nextstep2
1469972599cfSmrg		;;
14709dd7914aSmrg	# Preserve the version number of sinix5.
14719dd7914aSmrg	sinix5.*)
14729dd7914aSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473972599cfSmrg		;;
14749dd7914aSmrg	sinix*)
14759dd7914aSmrg		os=sysv4
1476972599cfSmrg		;;
14779dd7914aSmrg	tpf*)
14789dd7914aSmrg		os=tpf
1479972599cfSmrg		;;
14809dd7914aSmrg	triton*)
14819dd7914aSmrg		os=sysv3
1482972599cfSmrg		;;
14839dd7914aSmrg	oss*)
14849dd7914aSmrg		os=sysv3
1485972599cfSmrg		;;
14869dd7914aSmrg	svr4*)
14879dd7914aSmrg		os=sysv4
1488972599cfSmrg		;;
14899dd7914aSmrg	svr3)
14909dd7914aSmrg		os=sysv3
1491972599cfSmrg		;;
14929dd7914aSmrg	sysvr4)
14939dd7914aSmrg		os=sysv4
1494972599cfSmrg		;;
14959dd7914aSmrg	ose*)
14969dd7914aSmrg		os=ose
1497972599cfSmrg		;;
14989dd7914aSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14999dd7914aSmrg		os=mint
1500972599cfSmrg		;;
15019dd7914aSmrg	dicos*)
15029dd7914aSmrg		os=dicos
1503972599cfSmrg		;;
15049dd7914aSmrg	pikeos*)
15059dd7914aSmrg		# Until real need of OS specific support for
15069dd7914aSmrg		# particular features comes up, bare metal
15079dd7914aSmrg		# configurations are quite functional.
15089dd7914aSmrg		case $cpu in
15099dd7914aSmrg		    arm*)
15109dd7914aSmrg			os=eabi
15119dd7914aSmrg			;;
15129dd7914aSmrg		    *)
15139dd7914aSmrg			os=elf
15149dd7914aSmrg			;;
15159dd7914aSmrg		esac
1516972599cfSmrg		;;
1517972599cfSmrg	*)
15189dd7914aSmrg		# No normalization, but not necessarily accepted, that comes below.
1519972599cfSmrg		;;
1520972599cfSmrgesac
15219dd7914aSmrg
1522972599cfSmrgelse
1523972599cfSmrg
1524972599cfSmrg# Here we handle the default operating systems that come with various machines.
1525972599cfSmrg# The value should be what the vendor currently ships out the door with their
1526972599cfSmrg# machine or put another way, the most popular os provided with the machine.
1527972599cfSmrg
1528972599cfSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529972599cfSmrg# "-sun"), then you have to tell the case statement up towards the top
1530972599cfSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531972599cfSmrg# will signal an error saying that MANUFACTURER isn't an operating
1532972599cfSmrg# system, and we'll never get to this point.
1533972599cfSmrg
15349dd7914aSmrgkernel=
15359dd7914aSmrgcase $cpu-$vendor in
1536972599cfSmrg	score-*)
15379dd7914aSmrg		os=elf
1538972599cfSmrg		;;
1539972599cfSmrg	spu-*)
15409dd7914aSmrg		os=elf
1541972599cfSmrg		;;
1542972599cfSmrg	*-acorn)
15439dd7914aSmrg		os=riscix1.2
1544972599cfSmrg		;;
1545972599cfSmrg	arm*-rebel)
15469dd7914aSmrg		kernel=linux
15479dd7914aSmrg		os=gnu
1548972599cfSmrg		;;
1549972599cfSmrg	arm*-semi)
15509dd7914aSmrg		os=aout
1551972599cfSmrg		;;
1552972599cfSmrg	c4x-* | tic4x-*)
15539dd7914aSmrg		os=coff
1554972599cfSmrg		;;
15555eeb4e8fSmrg	c8051-*)
15569dd7914aSmrg		os=elf
15579dd7914aSmrg		;;
15589dd7914aSmrg	clipper-intergraph)
15599dd7914aSmrg		os=clix
15605eeb4e8fSmrg		;;
15615eeb4e8fSmrg	hexagon-*)
15629dd7914aSmrg		os=elf
15635eeb4e8fSmrg		;;
1564972599cfSmrg	tic54x-*)
15659dd7914aSmrg		os=coff
1566972599cfSmrg		;;
1567972599cfSmrg	tic55x-*)
15689dd7914aSmrg		os=coff
1569972599cfSmrg		;;
1570972599cfSmrg	tic6x-*)
15719dd7914aSmrg		os=coff
1572972599cfSmrg		;;
1573972599cfSmrg	# This must come before the *-dec entry.
1574972599cfSmrg	pdp10-*)
15759dd7914aSmrg		os=tops20
1576972599cfSmrg		;;
1577972599cfSmrg	pdp11-*)
15789dd7914aSmrg		os=none
1579972599cfSmrg		;;
1580972599cfSmrg	*-dec | vax-*)
15819dd7914aSmrg		os=ultrix4.2
1582972599cfSmrg		;;
1583972599cfSmrg	m68*-apollo)
15849dd7914aSmrg		os=domain
1585972599cfSmrg		;;
1586972599cfSmrg	i386-sun)
15879dd7914aSmrg		os=sunos4.0.2
1588972599cfSmrg		;;
1589972599cfSmrg	m68000-sun)
15909dd7914aSmrg		os=sunos3
1591972599cfSmrg		;;
1592972599cfSmrg	m68*-cisco)
15939dd7914aSmrg		os=aout
1594972599cfSmrg		;;
1595972599cfSmrg	mep-*)
15969dd7914aSmrg		os=elf
1597972599cfSmrg		;;
1598972599cfSmrg	mips*-cisco)
15999dd7914aSmrg		os=elf
1600972599cfSmrg		;;
1601972599cfSmrg	mips*-*)
16029dd7914aSmrg		os=elf
1603972599cfSmrg		;;
1604972599cfSmrg	or32-*)
16059dd7914aSmrg		os=coff
1606972599cfSmrg		;;
1607972599cfSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
16089dd7914aSmrg		os=sysv3
1609972599cfSmrg		;;
1610972599cfSmrg	sparc-* | *-sun)
16119dd7914aSmrg		os=sunos4.1.1
1612972599cfSmrg		;;
16139dd7914aSmrg	pru-*)
16149dd7914aSmrg		os=elf
1615972599cfSmrg		;;
16169dd7914aSmrg	*-be)
16179dd7914aSmrg		os=beos
1618972599cfSmrg		;;
1619972599cfSmrg	*-ibm)
16209dd7914aSmrg		os=aix
1621972599cfSmrg		;;
1622972599cfSmrg	*-knuth)
16239dd7914aSmrg		os=mmixware
1624972599cfSmrg		;;
1625972599cfSmrg	*-wec)
16269dd7914aSmrg		os=proelf
1627972599cfSmrg		;;
1628972599cfSmrg	*-winbond)
16299dd7914aSmrg		os=proelf
1630972599cfSmrg		;;
1631972599cfSmrg	*-oki)
16329dd7914aSmrg		os=proelf
1633972599cfSmrg		;;
1634972599cfSmrg	*-hp)
16359dd7914aSmrg		os=hpux
1636972599cfSmrg		;;
1637972599cfSmrg	*-hitachi)
16389dd7914aSmrg		os=hiux
1639972599cfSmrg		;;
1640972599cfSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16419dd7914aSmrg		os=sysv
1642972599cfSmrg		;;
1643972599cfSmrg	*-cbm)
16449dd7914aSmrg		os=amigaos
1645972599cfSmrg		;;
1646972599cfSmrg	*-dg)
16479dd7914aSmrg		os=dgux
1648972599cfSmrg		;;
1649972599cfSmrg	*-dolphin)
16509dd7914aSmrg		os=sysv3
1651972599cfSmrg		;;
1652972599cfSmrg	m68k-ccur)
16539dd7914aSmrg		os=rtu
1654972599cfSmrg		;;
1655972599cfSmrg	m88k-omron*)
16569dd7914aSmrg		os=luna
1657972599cfSmrg		;;
16589dd7914aSmrg	*-next)
16599dd7914aSmrg		os=nextstep
1660972599cfSmrg		;;
1661972599cfSmrg	*-sequent)
16629dd7914aSmrg		os=ptx
1663972599cfSmrg		;;
1664972599cfSmrg	*-crds)
16659dd7914aSmrg		os=unos
1666972599cfSmrg		;;
1667972599cfSmrg	*-ns)
16689dd7914aSmrg		os=genix
1669972599cfSmrg		;;
1670972599cfSmrg	i370-*)
16719dd7914aSmrg		os=mvs
1672972599cfSmrg		;;
1673972599cfSmrg	*-gould)
16749dd7914aSmrg		os=sysv
1675972599cfSmrg		;;
1676972599cfSmrg	*-highlevel)
16779dd7914aSmrg		os=bsd
1678972599cfSmrg		;;
1679972599cfSmrg	*-encore)
16809dd7914aSmrg		os=bsd
1681972599cfSmrg		;;
1682972599cfSmrg	*-sgi)
16839dd7914aSmrg		os=irix
1684972599cfSmrg		;;
1685972599cfSmrg	*-siemens)
16869dd7914aSmrg		os=sysv4
1687972599cfSmrg		;;
1688972599cfSmrg	*-masscomp)
16899dd7914aSmrg		os=rtu
1690972599cfSmrg		;;
1691972599cfSmrg	f30[01]-fujitsu | f700-fujitsu)
16929dd7914aSmrg		os=uxpv
1693972599cfSmrg		;;
1694972599cfSmrg	*-rom68k)
16959dd7914aSmrg		os=coff
1696972599cfSmrg		;;
1697972599cfSmrg	*-*bug)
16989dd7914aSmrg		os=coff
1699972599cfSmrg		;;
1700972599cfSmrg	*-apple)
17019dd7914aSmrg		os=macos
1702972599cfSmrg		;;
1703972599cfSmrg	*-atari*)
17049dd7914aSmrg		os=mint
17059dd7914aSmrg		;;
17069dd7914aSmrg	*-wrs)
17079dd7914aSmrg		os=vxworks
1708972599cfSmrg		;;
1709972599cfSmrg	*)
17109dd7914aSmrg		os=none
1711972599cfSmrg		;;
1712972599cfSmrgesac
17139dd7914aSmrg
1714972599cfSmrgfi
1715972599cfSmrg
17169dd7914aSmrg# Now, validate our (potentially fixed-up) OS.
17179dd7914aSmrgcase $os in
17189dd7914aSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17199dd7914aSmrg	musl* | newlib* | relibc* | uclibc*)
17209dd7914aSmrg		;;
17219dd7914aSmrg	# Likewise for "kernel-abi"
17229dd7914aSmrg	eabi* | gnueabi*)
17239dd7914aSmrg		;;
17249dd7914aSmrg	# VxWorks passes extra cpu info in the 4th filed.
17259dd7914aSmrg	simlinux | simwindows | spe)
17269dd7914aSmrg		;;
17279dd7914aSmrg	# Now accept the basic system types.
17289dd7914aSmrg	# The portable systems comes first.
17299dd7914aSmrg	# Each alternative MUST end in a * to match a version number.
17309dd7914aSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17319dd7914aSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17329dd7914aSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17339dd7914aSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17349dd7914aSmrg	     | hiux* | abug | nacl* | netware* | windows* \
17359dd7914aSmrg	     | os9* | macos* | osx* | ios* \
17369dd7914aSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17379dd7914aSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17389dd7914aSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17399dd7914aSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17409dd7914aSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17419dd7914aSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17429dd7914aSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17439dd7914aSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17449dd7914aSmrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17459dd7914aSmrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17469dd7914aSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17479dd7914aSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17489dd7914aSmrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17499dd7914aSmrg	     | midipix* | mingw32* | mingw64* | mint* \
17509dd7914aSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17519dd7914aSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17529dd7914aSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17539dd7914aSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17549dd7914aSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17559dd7914aSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17569dd7914aSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17579dd7914aSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17589dd7914aSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17599dd7914aSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17609dd7914aSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17619dd7914aSmrg	     | fiwix* | mlibc* )
17629dd7914aSmrg		;;
17639dd7914aSmrg	# This one is extra strict with allowed versions
17649dd7914aSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17659dd7914aSmrg		# Don't forget version if it is 3.2v4 or newer.
17669dd7914aSmrg		;;
17679dd7914aSmrg	none)
17689dd7914aSmrg		;;
17699dd7914aSmrg	kernel* )
17709dd7914aSmrg		# Restricted further below
17719dd7914aSmrg		;;
17729dd7914aSmrg	*)
17739dd7914aSmrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17749dd7914aSmrg		exit 1
17759dd7914aSmrg		;;
17769dd7914aSmrgesac
17779dd7914aSmrg
17789dd7914aSmrg# As a final step for OS-related things, validate the OS-kernel combination
17799dd7914aSmrg# (given a valid OS), if there is a kernel.
17809dd7914aSmrgcase $kernel-$os in
17819dd7914aSmrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
17829dd7914aSmrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17839dd7914aSmrg		;;
17849dd7914aSmrg	uclinux-uclibc* )
17859dd7914aSmrg		;;
17869dd7914aSmrg	managarm-mlibc* | managarm-kernel* )
17879dd7914aSmrg		;;
17889dd7914aSmrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17899dd7914aSmrg		# These are just libc implementations, not actual OSes, and thus
17909dd7914aSmrg		# require a kernel.
17919dd7914aSmrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17929dd7914aSmrg		exit 1
17939dd7914aSmrg		;;
17949dd7914aSmrg	-kernel* )
17959dd7914aSmrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
17969dd7914aSmrg		exit 1
17979dd7914aSmrg		;;
17989dd7914aSmrg	*-kernel* )
17999dd7914aSmrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
18009dd7914aSmrg		exit 1
18019dd7914aSmrg		;;
18029dd7914aSmrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
18039dd7914aSmrg		;;
18049dd7914aSmrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
18059dd7914aSmrg		;;
18069dd7914aSmrg	nto-qnx*)
18079dd7914aSmrg		;;
18089dd7914aSmrg	os2-emx)
18099dd7914aSmrg		;;
18109dd7914aSmrg	*-eabi* | *-gnueabi*)
18119dd7914aSmrg		;;
18129dd7914aSmrg	-*)
18139dd7914aSmrg		# Blank kernel with real OS is always fine.
18149dd7914aSmrg		;;
18159dd7914aSmrg	*-*)
18169dd7914aSmrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18179dd7914aSmrg		exit 1
18189dd7914aSmrg		;;
18199dd7914aSmrgesac
18209dd7914aSmrg
1821972599cfSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1822972599cfSmrg# manufacturer.  We pick the logical manufacturer.
18239dd7914aSmrgcase $vendor in
18249dd7914aSmrg	unknown)
18259dd7914aSmrg		case $cpu-$os in
18269dd7914aSmrg			*-riscix*)
1827972599cfSmrg				vendor=acorn
1828972599cfSmrg				;;
18299dd7914aSmrg			*-sunos*)
1830972599cfSmrg				vendor=sun
1831972599cfSmrg				;;
18329dd7914aSmrg			*-cnk* | *-aix*)
1833972599cfSmrg				vendor=ibm
1834972599cfSmrg				;;
18359dd7914aSmrg			*-beos*)
1836972599cfSmrg				vendor=be
1837972599cfSmrg				;;
18389dd7914aSmrg			*-hpux*)
1839972599cfSmrg				vendor=hp
1840972599cfSmrg				;;
18419dd7914aSmrg			*-mpeix*)
1842972599cfSmrg				vendor=hp
1843972599cfSmrg				;;
18449dd7914aSmrg			*-hiux*)
1845972599cfSmrg				vendor=hitachi
1846972599cfSmrg				;;
18479dd7914aSmrg			*-unos*)
1848972599cfSmrg				vendor=crds
1849972599cfSmrg				;;
18509dd7914aSmrg			*-dgux*)
1851972599cfSmrg				vendor=dg
1852972599cfSmrg				;;
18539dd7914aSmrg			*-luna*)
1854972599cfSmrg				vendor=omron
1855972599cfSmrg				;;
18569dd7914aSmrg			*-genix*)
1857972599cfSmrg				vendor=ns
1858972599cfSmrg				;;
18599dd7914aSmrg			*-clix*)
18609dd7914aSmrg				vendor=intergraph
18619dd7914aSmrg				;;
18629dd7914aSmrg			*-mvs* | *-opened*)
18639dd7914aSmrg				vendor=ibm
18649dd7914aSmrg				;;
18659dd7914aSmrg			*-os400*)
1866972599cfSmrg				vendor=ibm
1867972599cfSmrg				;;
18689dd7914aSmrg			s390-* | s390x-*)
1869972599cfSmrg				vendor=ibm
1870972599cfSmrg				;;
18719dd7914aSmrg			*-ptx*)
1872972599cfSmrg				vendor=sequent
1873972599cfSmrg				;;
18749dd7914aSmrg			*-tpf*)
1875972599cfSmrg				vendor=ibm
1876972599cfSmrg				;;
18779dd7914aSmrg			*-vxsim* | *-vxworks* | *-windiss*)
1878972599cfSmrg				vendor=wrs
1879972599cfSmrg				;;
18809dd7914aSmrg			*-aux*)
1881972599cfSmrg				vendor=apple
1882972599cfSmrg				;;
18839dd7914aSmrg			*-hms*)
1884972599cfSmrg				vendor=hitachi
1885972599cfSmrg				;;
18869dd7914aSmrg			*-mpw* | *-macos*)
1887972599cfSmrg				vendor=apple
1888972599cfSmrg				;;
18899dd7914aSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890972599cfSmrg				vendor=atari
1891972599cfSmrg				;;
18929dd7914aSmrg			*-vos*)
1893972599cfSmrg				vendor=stratus
1894972599cfSmrg				;;
1895972599cfSmrg		esac
1896972599cfSmrg		;;
1897972599cfSmrgesac
1898972599cfSmrg
18999dd7914aSmrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900972599cfSmrgexit
1901972599cfSmrg
1902972599cfSmrg# Local variables:
19039dd7914aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904972599cfSmrg# time-stamp-start: "timestamp='"
1905972599cfSmrg# time-stamp-format: "%:y-%02m-%02d"
1906972599cfSmrg# time-stamp-end: "'"
1907972599cfSmrg# End:
1908