1100ae103Smrg#! /bin/sh
2100ae103Smrg# Configuration validation subroutine script.
314a67432Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4100ae103Smrg
50103645bSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
60103645bSmrg
714a67432Smrgtimestamp='2023-01-21'
8100ae103Smrg
995cf0c00Smrg# This file is free software; you can redistribute it and/or modify it
1095cf0c00Smrg# under the terms of the GNU General Public License as published by
1114a67432Smrg# the Free Software Foundation, either version 3 of the License, or
12100ae103Smrg# (at your option) any later version.
13100ae103Smrg#
1495cf0c00Smrg# This program is distributed in the hope that it will be useful, but
1595cf0c00Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1695cf0c00Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1795cf0c00Smrg# General Public License for more details.
18100ae103Smrg#
19100ae103Smrg# You should have received a copy of the GNU General Public License
2095cf0c00Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21100ae103Smrg#
22100ae103Smrg# As a special exception to the GNU General Public License, if you
23100ae103Smrg# distribute this file as part of a program that contains a
24100ae103Smrg# configuration script generated by Autoconf, you may include it under
2595cf0c00Smrg# the same distribution terms that you use for the rest of that
2695cf0c00Smrg# program.  This Exception is an additional permission under section 7
2795cf0c00Smrg# of the GNU General Public License, version 3 ("GPLv3").
28100ae103Smrg
29100ae103Smrg
3095cf0c00Smrg# Please send patches to <config-patches@gnu.org>.
31100ae103Smrg#
32100ae103Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33100ae103Smrg# Supply the specified configuration type as an argument.
34100ae103Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35100ae103Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36100ae103Smrg
37165cb819Smrg# You can get the latest version of this script from:
380103645bSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39165cb819Smrg
40100ae103Smrg# This file is supposed to be the same for all GNU packages
41100ae103Smrg# and recognize all the CPU types, system types and aliases
42100ae103Smrg# that are meaningful with *any* GNU software.
43100ae103Smrg# Each package is responsible for reporting which valid configurations
44100ae103Smrg# it does not support.  The user should be able to distinguish
45100ae103Smrg# a failure to support a valid configuration from a meaningless
46100ae103Smrg# configuration.
47100ae103Smrg
48100ae103Smrg# The goal of this file is to map all the various variations of a given
49100ae103Smrg# machine specification into a single specification in the form:
50100ae103Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51100ae103Smrg# or in some cases, the newer four-part form:
52100ae103Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53100ae103Smrg# It is wrong to echo any other type of specification.
54100ae103Smrg
550103645bSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
560103645bSmrg# about features and limitations of the classic Bourne shell that were
570103645bSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
580103645bSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
590103645bSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
600103645bSmrg# have a pre-POSIX /bin/sh.
610103645bSmrg
62100ae103Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63100ae103Smrg
64100ae103Smrgusage="\
6595cf0c00SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66100ae103Smrg
67100ae103SmrgCanonicalize a configuration name.
68100ae103Smrg
6995cf0c00SmrgOptions:
70100ae103Smrg  -h, --help         print this help, then exit
71100ae103Smrg  -t, --time-stamp   print date of last modification, then exit
72100ae103Smrg  -v, --version      print version number, then exit
73100ae103Smrg
74100ae103SmrgReport bugs and patches to <config-patches@gnu.org>."
75100ae103Smrg
76100ae103Smrgversion="\
77100ae103SmrgGNU config.sub ($timestamp)
78100ae103Smrg
7914a67432SmrgCopyright 1992-2023 Free Software Foundation, Inc.
80100ae103Smrg
81100ae103SmrgThis is free software; see the source for copying conditions.  There is NO
82100ae103Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83100ae103Smrg
84100ae103Smrghelp="
85100ae103SmrgTry \`$me --help' for more information."
86100ae103Smrg
87100ae103Smrg# Parse command line
88100ae103Smrgwhile test $# -gt 0 ; do
89100ae103Smrg  case $1 in
90100ae103Smrg    --time-stamp | --time* | -t )
91100ae103Smrg       echo "$timestamp" ; exit ;;
92100ae103Smrg    --version | -v )
93100ae103Smrg       echo "$version" ; exit ;;
94100ae103Smrg    --help | --h* | -h )
95100ae103Smrg       echo "$usage"; exit ;;
96100ae103Smrg    -- )     # Stop option processing
97100ae103Smrg       shift; break ;;
98100ae103Smrg    - )	# Use stdin as input.
99100ae103Smrg       break ;;
100100ae103Smrg    -* )
1010103645bSmrg       echo "$me: invalid option $1$help" >&2
102100ae103Smrg       exit 1 ;;
103100ae103Smrg
104100ae103Smrg    *local*)
105100ae103Smrg       # First pass through any local machine types.
10695cf0c00Smrg       echo "$1"
107100ae103Smrg       exit ;;
108100ae103Smrg
109100ae103Smrg    * )
110100ae103Smrg       break ;;
111100ae103Smrg  esac
112100ae103Smrgdone
113100ae103Smrg
114100ae103Smrgcase $# in
115100ae103Smrg 0) echo "$me: missing argument$help" >&2
116100ae103Smrg    exit 1;;
117100ae103Smrg 1) ;;
118100ae103Smrg *) echo "$me: too many arguments$help" >&2
119100ae103Smrg    exit 1;;
120100ae103Smrgesac
121100ae103Smrg
1220103645bSmrg# Split fields of configuration type
1230103645bSmrg# shellcheck disable=SC2162
1240103645bSmrgsaved_IFS=$IFS
1250103645bSmrgIFS="-" read field1 field2 field3 field4 <<EOF
1260103645bSmrg$1
1270103645bSmrgEOF
1280103645bSmrgIFS=$saved_IFS
129100ae103Smrg
1300103645bSmrg# Separate into logical components for further validation
1310103645bSmrgcase $1 in
1320103645bSmrg	*-*-*-*-*)
1330103645bSmrg		echo Invalid configuration \`"$1"\': more than four components >&2
1340103645bSmrg		exit 1
135100ae103Smrg		;;
1360103645bSmrg	*-*-*-*)
1370103645bSmrg		basic_machine=$field1-$field2
1380103645bSmrg		basic_os=$field3-$field4
139100ae103Smrg		;;
1400103645bSmrg	*-*-*)
1410103645bSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1420103645bSmrg		# parts
1430103645bSmrg		maybe_os=$field2-$field3
1440103645bSmrg		case $maybe_os in
1450103645bSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
1460103645bSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1470103645bSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14814a67432Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
1490103645bSmrg				basic_machine=$field1
1500103645bSmrg				basic_os=$maybe_os
1510103645bSmrg				;;
1520103645bSmrg			android-linux)
1530103645bSmrg				basic_machine=$field1-unknown
1540103645bSmrg				basic_os=linux-android
1550103645bSmrg				;;
1560103645bSmrg			*)
1570103645bSmrg				basic_machine=$field1-$field2
1580103645bSmrg				basic_os=$field3
1590103645bSmrg				;;
1600103645bSmrg		esac
161100ae103Smrg		;;
1620103645bSmrg	*-*)
1630103645bSmrg		# A lone config we happen to match not fitting any pattern
1640103645bSmrg		case $field1-$field2 in
1650103645bSmrg			decstation-3100)
1660103645bSmrg				basic_machine=mips-dec
1670103645bSmrg				basic_os=
1680103645bSmrg				;;
1690103645bSmrg			*-*)
1700103645bSmrg				# Second component is usually, but not always the OS
1710103645bSmrg				case $field2 in
1720103645bSmrg					# Prevent following clause from handling this valid os
1730103645bSmrg					sun*os*)
1740103645bSmrg						basic_machine=$field1
1750103645bSmrg						basic_os=$field2
1760103645bSmrg						;;
1770103645bSmrg					zephyr*)
1780103645bSmrg						basic_machine=$field1-unknown
1790103645bSmrg						basic_os=$field2
1800103645bSmrg						;;
1810103645bSmrg					# Manufacturers
1820103645bSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1830103645bSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1840103645bSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1850103645bSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1860103645bSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1870103645bSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1880103645bSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1890103645bSmrg					| microblaze* | sim | cisco \
1900103645bSmrg					| oki | wec | wrs | winbond)
1910103645bSmrg						basic_machine=$field1-$field2
1920103645bSmrg						basic_os=
1930103645bSmrg						;;
1940103645bSmrg					*)
1950103645bSmrg						basic_machine=$field1
1960103645bSmrg						basic_os=$field2
1970103645bSmrg						;;
1980103645bSmrg				esac
1990103645bSmrg			;;
2000103645bSmrg		esac
201100ae103Smrg		;;
2020103645bSmrg	*)
2030103645bSmrg		# Convert single-component short-hands not valid as part of
2040103645bSmrg		# multi-component configurations.
2050103645bSmrg		case $field1 in
2060103645bSmrg			386bsd)
2070103645bSmrg				basic_machine=i386-pc
2080103645bSmrg				basic_os=bsd
2090103645bSmrg				;;
2100103645bSmrg			a29khif)
2110103645bSmrg				basic_machine=a29k-amd
2120103645bSmrg				basic_os=udi
2130103645bSmrg				;;
2140103645bSmrg			adobe68k)
2150103645bSmrg				basic_machine=m68010-adobe
2160103645bSmrg				basic_os=scout
2170103645bSmrg				;;
2180103645bSmrg			alliant)
2190103645bSmrg				basic_machine=fx80-alliant
2200103645bSmrg				basic_os=
2210103645bSmrg				;;
2220103645bSmrg			altos | altos3068)
2230103645bSmrg				basic_machine=m68k-altos
2240103645bSmrg				basic_os=
2250103645bSmrg				;;
2260103645bSmrg			am29k)
2270103645bSmrg				basic_machine=a29k-none
2280103645bSmrg				basic_os=bsd
2290103645bSmrg				;;
2300103645bSmrg			amdahl)
2310103645bSmrg				basic_machine=580-amdahl
2320103645bSmrg				basic_os=sysv
2330103645bSmrg				;;
2340103645bSmrg			amiga)
2350103645bSmrg				basic_machine=m68k-unknown
2360103645bSmrg				basic_os=
2370103645bSmrg				;;
2380103645bSmrg			amigaos | amigados)
2390103645bSmrg				basic_machine=m68k-unknown
2400103645bSmrg				basic_os=amigaos
2410103645bSmrg				;;
2420103645bSmrg			amigaunix | amix)
2430103645bSmrg				basic_machine=m68k-unknown
2440103645bSmrg				basic_os=sysv4
2450103645bSmrg				;;
2460103645bSmrg			apollo68)
2470103645bSmrg				basic_machine=m68k-apollo
2480103645bSmrg				basic_os=sysv
2490103645bSmrg				;;
2500103645bSmrg			apollo68bsd)
2510103645bSmrg				basic_machine=m68k-apollo
2520103645bSmrg				basic_os=bsd
2530103645bSmrg				;;
2540103645bSmrg			aros)
2550103645bSmrg				basic_machine=i386-pc
2560103645bSmrg				basic_os=aros
2570103645bSmrg				;;
2580103645bSmrg			aux)
2590103645bSmrg				basic_machine=m68k-apple
2600103645bSmrg				basic_os=aux
2610103645bSmrg				;;
2620103645bSmrg			balance)
2630103645bSmrg				basic_machine=ns32k-sequent
2640103645bSmrg				basic_os=dynix
2650103645bSmrg				;;
2660103645bSmrg			blackfin)
2670103645bSmrg				basic_machine=bfin-unknown
2680103645bSmrg				basic_os=linux
2690103645bSmrg				;;
2700103645bSmrg			cegcc)
2710103645bSmrg				basic_machine=arm-unknown
2720103645bSmrg				basic_os=cegcc
2730103645bSmrg				;;
2740103645bSmrg			convex-c1)
2750103645bSmrg				basic_machine=c1-convex
2760103645bSmrg				basic_os=bsd
2770103645bSmrg				;;
2780103645bSmrg			convex-c2)
2790103645bSmrg				basic_machine=c2-convex
2800103645bSmrg				basic_os=bsd
2810103645bSmrg				;;
2820103645bSmrg			convex-c32)
2830103645bSmrg				basic_machine=c32-convex
2840103645bSmrg				basic_os=bsd
2850103645bSmrg				;;
2860103645bSmrg			convex-c34)
2870103645bSmrg				basic_machine=c34-convex
2880103645bSmrg				basic_os=bsd
2890103645bSmrg				;;
2900103645bSmrg			convex-c38)
2910103645bSmrg				basic_machine=c38-convex
2920103645bSmrg				basic_os=bsd
2930103645bSmrg				;;
2940103645bSmrg			cray)
2950103645bSmrg				basic_machine=j90-cray
2960103645bSmrg				basic_os=unicos
2970103645bSmrg				;;
2980103645bSmrg			crds | unos)
2990103645bSmrg				basic_machine=m68k-crds
3000103645bSmrg				basic_os=
3010103645bSmrg				;;
3020103645bSmrg			da30)
3030103645bSmrg				basic_machine=m68k-da30
3040103645bSmrg				basic_os=
3050103645bSmrg				;;
3060103645bSmrg			decstation | pmax | pmin | dec3100 | decstatn)
3070103645bSmrg				basic_machine=mips-dec
3080103645bSmrg				basic_os=
3090103645bSmrg				;;
3100103645bSmrg			delta88)
3110103645bSmrg				basic_machine=m88k-motorola
3120103645bSmrg				basic_os=sysv3
3130103645bSmrg				;;
3140103645bSmrg			dicos)
3150103645bSmrg				basic_machine=i686-pc
3160103645bSmrg				basic_os=dicos
3170103645bSmrg				;;
3180103645bSmrg			djgpp)
3190103645bSmrg				basic_machine=i586-pc
3200103645bSmrg				basic_os=msdosdjgpp
3210103645bSmrg				;;
3220103645bSmrg			ebmon29k)
3230103645bSmrg				basic_machine=a29k-amd
3240103645bSmrg				basic_os=ebmon
3250103645bSmrg				;;
3260103645bSmrg			es1800 | OSE68k | ose68k | ose | OSE)
3270103645bSmrg				basic_machine=m68k-ericsson
3280103645bSmrg				basic_os=ose
3290103645bSmrg				;;
3300103645bSmrg			gmicro)
3310103645bSmrg				basic_machine=tron-gmicro
3320103645bSmrg				basic_os=sysv
3330103645bSmrg				;;
3340103645bSmrg			go32)
3350103645bSmrg				basic_machine=i386-pc
3360103645bSmrg				basic_os=go32
3370103645bSmrg				;;
3380103645bSmrg			h8300hms)
3390103645bSmrg				basic_machine=h8300-hitachi
3400103645bSmrg				basic_os=hms
3410103645bSmrg				;;
3420103645bSmrg			h8300xray)
3430103645bSmrg				basic_machine=h8300-hitachi
3440103645bSmrg				basic_os=xray
3450103645bSmrg				;;
3460103645bSmrg			h8500hms)
3470103645bSmrg				basic_machine=h8500-hitachi
3480103645bSmrg				basic_os=hms
3490103645bSmrg				;;
3500103645bSmrg			harris)
3510103645bSmrg				basic_machine=m88k-harris
3520103645bSmrg				basic_os=sysv3
3530103645bSmrg				;;
3540103645bSmrg			hp300 | hp300hpux)
3550103645bSmrg				basic_machine=m68k-hp
3560103645bSmrg				basic_os=hpux
3570103645bSmrg				;;
3580103645bSmrg			hp300bsd)
3590103645bSmrg				basic_machine=m68k-hp
3600103645bSmrg				basic_os=bsd
3610103645bSmrg				;;
3620103645bSmrg			hppaosf)
3630103645bSmrg				basic_machine=hppa1.1-hp
3640103645bSmrg				basic_os=osf
3650103645bSmrg				;;
3660103645bSmrg			hppro)
3670103645bSmrg				basic_machine=hppa1.1-hp
3680103645bSmrg				basic_os=proelf
3690103645bSmrg				;;
3700103645bSmrg			i386mach)
3710103645bSmrg				basic_machine=i386-mach
3720103645bSmrg				basic_os=mach
3730103645bSmrg				;;
3740103645bSmrg			isi68 | isi)
3750103645bSmrg				basic_machine=m68k-isi
3760103645bSmrg				basic_os=sysv
3770103645bSmrg				;;
3780103645bSmrg			m68knommu)
3790103645bSmrg				basic_machine=m68k-unknown
3800103645bSmrg				basic_os=linux
3810103645bSmrg				;;
3820103645bSmrg			magnum | m3230)
3830103645bSmrg				basic_machine=mips-mips
3840103645bSmrg				basic_os=sysv
3850103645bSmrg				;;
3860103645bSmrg			merlin)
3870103645bSmrg				basic_machine=ns32k-utek
3880103645bSmrg				basic_os=sysv
3890103645bSmrg				;;
3900103645bSmrg			mingw64)
3910103645bSmrg				basic_machine=x86_64-pc
3920103645bSmrg				basic_os=mingw64
3930103645bSmrg				;;
3940103645bSmrg			mingw32)
3950103645bSmrg				basic_machine=i686-pc
3960103645bSmrg				basic_os=mingw32
3970103645bSmrg				;;
3980103645bSmrg			mingw32ce)
3990103645bSmrg				basic_machine=arm-unknown
4000103645bSmrg				basic_os=mingw32ce
4010103645bSmrg				;;
4020103645bSmrg			monitor)
4030103645bSmrg				basic_machine=m68k-rom68k
4040103645bSmrg				basic_os=coff
4050103645bSmrg				;;
4060103645bSmrg			morphos)
4070103645bSmrg				basic_machine=powerpc-unknown
4080103645bSmrg				basic_os=morphos
4090103645bSmrg				;;
4100103645bSmrg			moxiebox)
4110103645bSmrg				basic_machine=moxie-unknown
4120103645bSmrg				basic_os=moxiebox
4130103645bSmrg				;;
4140103645bSmrg			msdos)
4150103645bSmrg				basic_machine=i386-pc
4160103645bSmrg				basic_os=msdos
4170103645bSmrg				;;
4180103645bSmrg			msys)
4190103645bSmrg				basic_machine=i686-pc
4200103645bSmrg				basic_os=msys
4210103645bSmrg				;;
4220103645bSmrg			mvs)
4230103645bSmrg				basic_machine=i370-ibm
4240103645bSmrg				basic_os=mvs
4250103645bSmrg				;;
4260103645bSmrg			nacl)
4270103645bSmrg				basic_machine=le32-unknown
4280103645bSmrg				basic_os=nacl
4290103645bSmrg				;;
4300103645bSmrg			ncr3000)
4310103645bSmrg				basic_machine=i486-ncr
4320103645bSmrg				basic_os=sysv4
4330103645bSmrg				;;
4340103645bSmrg			netbsd386)
4350103645bSmrg				basic_machine=i386-pc
4360103645bSmrg				basic_os=netbsd
4370103645bSmrg				;;
4380103645bSmrg			netwinder)
4390103645bSmrg				basic_machine=armv4l-rebel
4400103645bSmrg				basic_os=linux
4410103645bSmrg				;;
4420103645bSmrg			news | news700 | news800 | news900)
4430103645bSmrg				basic_machine=m68k-sony
4440103645bSmrg				basic_os=newsos
4450103645bSmrg				;;
4460103645bSmrg			news1000)
4470103645bSmrg				basic_machine=m68030-sony
4480103645bSmrg				basic_os=newsos
4490103645bSmrg				;;
4500103645bSmrg			necv70)
4510103645bSmrg				basic_machine=v70-nec
4520103645bSmrg				basic_os=sysv
4530103645bSmrg				;;
4540103645bSmrg			nh3000)
4550103645bSmrg				basic_machine=m68k-harris
4560103645bSmrg				basic_os=cxux
4570103645bSmrg				;;
4580103645bSmrg			nh[45]000)
4590103645bSmrg				basic_machine=m88k-harris
4600103645bSmrg				basic_os=cxux
4610103645bSmrg				;;
4620103645bSmrg			nindy960)
4630103645bSmrg				basic_machine=i960-intel
4640103645bSmrg				basic_os=nindy
4650103645bSmrg				;;
4660103645bSmrg			mon960)
4670103645bSmrg				basic_machine=i960-intel
4680103645bSmrg				basic_os=mon960
4690103645bSmrg				;;
4700103645bSmrg			nonstopux)
4710103645bSmrg				basic_machine=mips-compaq
4720103645bSmrg				basic_os=nonstopux
4730103645bSmrg				;;
4740103645bSmrg			os400)
4750103645bSmrg				basic_machine=powerpc-ibm
4760103645bSmrg				basic_os=os400
4770103645bSmrg				;;
4780103645bSmrg			OSE68000 | ose68000)
4790103645bSmrg				basic_machine=m68000-ericsson
4800103645bSmrg				basic_os=ose
4810103645bSmrg				;;
4820103645bSmrg			os68k)
4830103645bSmrg				basic_machine=m68k-none
4840103645bSmrg				basic_os=os68k
4850103645bSmrg				;;
4860103645bSmrg			paragon)
4870103645bSmrg				basic_machine=i860-intel
4880103645bSmrg				basic_os=osf
4890103645bSmrg				;;
4900103645bSmrg			parisc)
4910103645bSmrg				basic_machine=hppa-unknown
4920103645bSmrg				basic_os=linux
4930103645bSmrg				;;
4940103645bSmrg			psp)
4950103645bSmrg				basic_machine=mipsallegrexel-sony
4960103645bSmrg				basic_os=psp
4970103645bSmrg				;;
4980103645bSmrg			pw32)
4990103645bSmrg				basic_machine=i586-unknown
5000103645bSmrg				basic_os=pw32
5010103645bSmrg				;;
5020103645bSmrg			rdos | rdos64)
5030103645bSmrg				basic_machine=x86_64-pc
5040103645bSmrg				basic_os=rdos
5050103645bSmrg				;;
5060103645bSmrg			rdos32)
5070103645bSmrg				basic_machine=i386-pc
5080103645bSmrg				basic_os=rdos
5090103645bSmrg				;;
5100103645bSmrg			rom68k)
5110103645bSmrg				basic_machine=m68k-rom68k
5120103645bSmrg				basic_os=coff
5130103645bSmrg				;;
5140103645bSmrg			sa29200)
5150103645bSmrg				basic_machine=a29k-amd
5160103645bSmrg				basic_os=udi
5170103645bSmrg				;;
5180103645bSmrg			sei)
5190103645bSmrg				basic_machine=mips-sei
5200103645bSmrg				basic_os=seiux
5210103645bSmrg				;;
5220103645bSmrg			sequent)
5230103645bSmrg				basic_machine=i386-sequent
5240103645bSmrg				basic_os=
5250103645bSmrg				;;
5260103645bSmrg			sps7)
5270103645bSmrg				basic_machine=m68k-bull
5280103645bSmrg				basic_os=sysv2
5290103645bSmrg				;;
5300103645bSmrg			st2000)
5310103645bSmrg				basic_machine=m68k-tandem
5320103645bSmrg				basic_os=
5330103645bSmrg				;;
5340103645bSmrg			stratus)
5350103645bSmrg				basic_machine=i860-stratus
5360103645bSmrg				basic_os=sysv4
5370103645bSmrg				;;
5380103645bSmrg			sun2)
5390103645bSmrg				basic_machine=m68000-sun
5400103645bSmrg				basic_os=
5410103645bSmrg				;;
5420103645bSmrg			sun2os3)
5430103645bSmrg				basic_machine=m68000-sun
5440103645bSmrg				basic_os=sunos3
5450103645bSmrg				;;
5460103645bSmrg			sun2os4)
5470103645bSmrg				basic_machine=m68000-sun
5480103645bSmrg				basic_os=sunos4
5490103645bSmrg				;;
5500103645bSmrg			sun3)
5510103645bSmrg				basic_machine=m68k-sun
5520103645bSmrg				basic_os=
5530103645bSmrg				;;
5540103645bSmrg			sun3os3)
5550103645bSmrg				basic_machine=m68k-sun
5560103645bSmrg				basic_os=sunos3
5570103645bSmrg				;;
5580103645bSmrg			sun3os4)
5590103645bSmrg				basic_machine=m68k-sun
5600103645bSmrg				basic_os=sunos4
5610103645bSmrg				;;
5620103645bSmrg			sun4)
5630103645bSmrg				basic_machine=sparc-sun
5640103645bSmrg				basic_os=
5650103645bSmrg				;;
5660103645bSmrg			sun4os3)
5670103645bSmrg				basic_machine=sparc-sun
5680103645bSmrg				basic_os=sunos3
5690103645bSmrg				;;
5700103645bSmrg			sun4os4)
5710103645bSmrg				basic_machine=sparc-sun
5720103645bSmrg				basic_os=sunos4
5730103645bSmrg				;;
5740103645bSmrg			sun4sol2)
5750103645bSmrg				basic_machine=sparc-sun
5760103645bSmrg				basic_os=solaris2
5770103645bSmrg				;;
5780103645bSmrg			sun386 | sun386i | roadrunner)
5790103645bSmrg				basic_machine=i386-sun
5800103645bSmrg				basic_os=
5810103645bSmrg				;;
5820103645bSmrg			sv1)
5830103645bSmrg				basic_machine=sv1-cray
5840103645bSmrg				basic_os=unicos
5850103645bSmrg				;;
5860103645bSmrg			symmetry)
5870103645bSmrg				basic_machine=i386-sequent
5880103645bSmrg				basic_os=dynix
5890103645bSmrg				;;
5900103645bSmrg			t3e)
5910103645bSmrg				basic_machine=alphaev5-cray
5920103645bSmrg				basic_os=unicos
5930103645bSmrg				;;
5940103645bSmrg			t90)
5950103645bSmrg				basic_machine=t90-cray
5960103645bSmrg				basic_os=unicos
5970103645bSmrg				;;
5980103645bSmrg			toad1)
5990103645bSmrg				basic_machine=pdp10-xkl
6000103645bSmrg				basic_os=tops20
6010103645bSmrg				;;
6020103645bSmrg			tpf)
6030103645bSmrg				basic_machine=s390x-ibm
6040103645bSmrg				basic_os=tpf
6050103645bSmrg				;;
6060103645bSmrg			udi29k)
6070103645bSmrg				basic_machine=a29k-amd
6080103645bSmrg				basic_os=udi
6090103645bSmrg				;;
6100103645bSmrg			ultra3)
6110103645bSmrg				basic_machine=a29k-nyu
6120103645bSmrg				basic_os=sym1
6130103645bSmrg				;;
6140103645bSmrg			v810 | necv810)
6150103645bSmrg				basic_machine=v810-nec
6160103645bSmrg				basic_os=none
6170103645bSmrg				;;
6180103645bSmrg			vaxv)
6190103645bSmrg				basic_machine=vax-dec
6200103645bSmrg				basic_os=sysv
6210103645bSmrg				;;
6220103645bSmrg			vms)
6230103645bSmrg				basic_machine=vax-dec
6240103645bSmrg				basic_os=vms
6250103645bSmrg				;;
6260103645bSmrg			vsta)
6270103645bSmrg				basic_machine=i386-pc
6280103645bSmrg				basic_os=vsta
6290103645bSmrg				;;
6300103645bSmrg			vxworks960)
6310103645bSmrg				basic_machine=i960-wrs
6320103645bSmrg				basic_os=vxworks
6330103645bSmrg				;;
6340103645bSmrg			vxworks68)
6350103645bSmrg				basic_machine=m68k-wrs
6360103645bSmrg				basic_os=vxworks
6370103645bSmrg				;;
6380103645bSmrg			vxworks29k)
6390103645bSmrg				basic_machine=a29k-wrs
6400103645bSmrg				basic_os=vxworks
6410103645bSmrg				;;
6420103645bSmrg			xbox)
6430103645bSmrg				basic_machine=i686-pc
6440103645bSmrg				basic_os=mingw32
6450103645bSmrg				;;
6460103645bSmrg			ymp)
6470103645bSmrg				basic_machine=ymp-cray
6480103645bSmrg				basic_os=unicos
6490103645bSmrg				;;
6500103645bSmrg			*)
6510103645bSmrg				basic_machine=$1
6520103645bSmrg				basic_os=
6530103645bSmrg				;;
6540103645bSmrg		esac
655100ae103Smrg		;;
656100ae103Smrgesac
657100ae103Smrg
6580103645bSmrg# Decode 1-component or ad-hoc basic machines
659100ae103Smrgcase $basic_machine in
6600103645bSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6610103645bSmrg	# some cases the only manufacturer, in others, it is the most popular.
6620103645bSmrg	w89k)
6630103645bSmrg		cpu=hppa1.1
6640103645bSmrg		vendor=winbond
66595cf0c00Smrg		;;
6660103645bSmrg	op50n)
6670103645bSmrg		cpu=hppa1.1
6680103645bSmrg		vendor=oki
669100ae103Smrg		;;
6700103645bSmrg	op60c)
6710103645bSmrg		cpu=hppa1.1
6720103645bSmrg		vendor=oki
673100ae103Smrg		;;
6740103645bSmrg	ibm*)
6750103645bSmrg		cpu=i370
6760103645bSmrg		vendor=ibm
677165cb819Smrg		;;
6780103645bSmrg	orion105)
6790103645bSmrg		cpu=clipper
6800103645bSmrg		vendor=highlevel
68195cf0c00Smrg		;;
6820103645bSmrg	mac | mpw | mac-mpw)
6830103645bSmrg		cpu=m68k
6840103645bSmrg		vendor=apple
6858831d3fbSmrg		;;
6860103645bSmrg	pmac | pmac-mpw)
6870103645bSmrg		cpu=powerpc
6880103645bSmrg		vendor=apple
6898831d3fbSmrg		;;
6908831d3fbSmrg
691100ae103Smrg	# Recognize the various machine names and aliases which stand
692100ae103Smrg	# for a CPU type and a company and sometimes even an OS.
693100ae103Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6940103645bSmrg		cpu=m68000
6950103645bSmrg		vendor=att
696100ae103Smrg		;;
697100ae103Smrg	3b*)
6980103645bSmrg		cpu=we32k
6990103645bSmrg		vendor=att
700165cb819Smrg		;;
701165cb819Smrg	bluegene*)
7020103645bSmrg		cpu=powerpc
7030103645bSmrg		vendor=ibm
7040103645bSmrg		basic_os=cnk
705100ae103Smrg		;;
706100ae103Smrg	decsystem10* | dec10*)
7070103645bSmrg		cpu=pdp10
7080103645bSmrg		vendor=dec
7090103645bSmrg		basic_os=tops10
710100ae103Smrg		;;
711100ae103Smrg	decsystem20* | dec20*)
7120103645bSmrg		cpu=pdp10
7130103645bSmrg		vendor=dec
7140103645bSmrg		basic_os=tops20
715100ae103Smrg		;;
716100ae103Smrg	delta | 3300 | motorola-3300 | motorola-delta \
717100ae103Smrg	      | 3300-motorola | delta-motorola)
7180103645bSmrg		cpu=m68k
7190103645bSmrg		vendor=motorola
720100ae103Smrg		;;
72195cf0c00Smrg	dpx2*)
7220103645bSmrg		cpu=m68k
7230103645bSmrg		vendor=bull
7240103645bSmrg		basic_os=sysv3
725100ae103Smrg		;;
726100ae103Smrg	encore | umax | mmax)
7270103645bSmrg		cpu=ns32k
7280103645bSmrg		vendor=encore
729100ae103Smrg		;;
7300103645bSmrg	elxsi)
7310103645bSmrg		cpu=elxsi
7320103645bSmrg		vendor=elxsi
7330103645bSmrg		basic_os=${basic_os:-bsd}
734100ae103Smrg		;;
735100ae103Smrg	fx2800)
7360103645bSmrg		cpu=i860
7370103645bSmrg		vendor=alliant
738100ae103Smrg		;;
739100ae103Smrg	genix)
7400103645bSmrg		cpu=ns32k
7410103645bSmrg		vendor=ns
742100ae103Smrg		;;
743100ae103Smrg	h3050r* | hiux*)
7440103645bSmrg		cpu=hppa1.1
7450103645bSmrg		vendor=hitachi
7460103645bSmrg		basic_os=hiuxwe2
747100ae103Smrg		;;
748100ae103Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7490103645bSmrg		cpu=hppa1.0
7500103645bSmrg		vendor=hp
751100ae103Smrg		;;
752100ae103Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7530103645bSmrg		cpu=m68000
7540103645bSmrg		vendor=hp
755100ae103Smrg		;;
756100ae103Smrg	hp9k3[2-9][0-9])
7570103645bSmrg		cpu=m68k
7580103645bSmrg		vendor=hp
759100ae103Smrg		;;
760100ae103Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7610103645bSmrg		cpu=hppa1.0
7620103645bSmrg		vendor=hp
763100ae103Smrg		;;
764100ae103Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7650103645bSmrg		cpu=hppa1.1
7660103645bSmrg		vendor=hp
767100ae103Smrg		;;
768100ae103Smrg	hp9k78[0-9] | hp78[0-9])
769100ae103Smrg		# FIXME: really hppa2.0-hp
7700103645bSmrg		cpu=hppa1.1
7710103645bSmrg		vendor=hp
772100ae103Smrg		;;
773100ae103Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774100ae103Smrg		# FIXME: really hppa2.0-hp
7750103645bSmrg		cpu=hppa1.1
7760103645bSmrg		vendor=hp
777100ae103Smrg		;;
778100ae103Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7790103645bSmrg		cpu=hppa1.1
7800103645bSmrg		vendor=hp
781100ae103Smrg		;;
782100ae103Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7830103645bSmrg		cpu=hppa1.0
7840103645bSmrg		vendor=hp
785100ae103Smrg		;;
786100ae103Smrg	i*86v32)
7870103645bSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7880103645bSmrg		vendor=pc
7890103645bSmrg		basic_os=sysv32
790100ae103Smrg		;;
791100ae103Smrg	i*86v4*)
7920103645bSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7930103645bSmrg		vendor=pc
7940103645bSmrg		basic_os=sysv4
795100ae103Smrg		;;
796100ae103Smrg	i*86v)
7970103645bSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7980103645bSmrg		vendor=pc
7990103645bSmrg		basic_os=sysv
800100ae103Smrg		;;
801100ae103Smrg	i*86sol2)
8020103645bSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8030103645bSmrg		vendor=pc
8040103645bSmrg		basic_os=solaris2
805100ae103Smrg		;;
8060103645bSmrg	j90 | j90-cray)
8070103645bSmrg		cpu=j90
8080103645bSmrg		vendor=cray
8090103645bSmrg		basic_os=${basic_os:-unicos}
810100ae103Smrg		;;
811100ae103Smrg	iris | iris4d)
8120103645bSmrg		cpu=mips
8130103645bSmrg		vendor=sgi
8140103645bSmrg		case $basic_os in
8150103645bSmrg		    irix*)
816100ae103Smrg			;;
817100ae103Smrg		    *)
8180103645bSmrg			basic_os=irix4
819100ae103Smrg			;;
820100ae103Smrg		esac
821100ae103Smrg		;;
822100ae103Smrg	miniframe)
8230103645bSmrg		cpu=m68000
8240103645bSmrg		vendor=convergent
825100ae103Smrg		;;
8260103645bSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8270103645bSmrg		cpu=m68k
8280103645bSmrg		vendor=atari
8290103645bSmrg		basic_os=mint
830100ae103Smrg		;;
831100ae103Smrg	news-3600 | risc-news)
8320103645bSmrg		cpu=mips
8330103645bSmrg		vendor=sony
8340103645bSmrg		basic_os=newsos
835100ae103Smrg		;;
83695cf0c00Smrg	next | m*-next)
8370103645bSmrg		cpu=m68k
8380103645bSmrg		vendor=next
8390103645bSmrg		case $basic_os in
8400103645bSmrg		    openstep*)
8410103645bSmrg		        ;;
8420103645bSmrg		    nextstep*)
843100ae103Smrg			;;
8440103645bSmrg		    ns2*)
8450103645bSmrg		      basic_os=nextstep2
846100ae103Smrg			;;
847100ae103Smrg		    *)
8480103645bSmrg		      basic_os=nextstep3
849100ae103Smrg			;;
850100ae103Smrg		esac
851100ae103Smrg		;;
852100ae103Smrg	np1)
8530103645bSmrg		cpu=np1
8540103645bSmrg		vendor=gould
85595cf0c00Smrg		;;
856100ae103Smrg	op50n-* | op60c-*)
8570103645bSmrg		cpu=hppa1.1
8580103645bSmrg		vendor=oki
8590103645bSmrg		basic_os=proelf
860100ae103Smrg		;;
861100ae103Smrg	pa-hitachi)
8620103645bSmrg		cpu=hppa1.1
8630103645bSmrg		vendor=hitachi
8640103645bSmrg		basic_os=hiuxwe2
865165cb819Smrg		;;
866100ae103Smrg	pbd)
8670103645bSmrg		cpu=sparc
8680103645bSmrg		vendor=tti
869100ae103Smrg		;;
870100ae103Smrg	pbb)
8710103645bSmrg		cpu=m68k
8720103645bSmrg		vendor=tti
873100ae103Smrg		;;
8740103645bSmrg	pc532)
8750103645bSmrg		cpu=ns32k
8760103645bSmrg		vendor=pc532
877100ae103Smrg		;;
878100ae103Smrg	pn)
8790103645bSmrg		cpu=pn
8800103645bSmrg		vendor=gould
881100ae103Smrg		;;
8820103645bSmrg	power)
8830103645bSmrg		cpu=power
8840103645bSmrg		vendor=ibm
885100ae103Smrg		;;
8860103645bSmrg	ps2)
8870103645bSmrg		cpu=i386
8880103645bSmrg		vendor=ibm
889100ae103Smrg		;;
8900103645bSmrg	rm[46]00)
8910103645bSmrg		cpu=mips
8920103645bSmrg		vendor=siemens
893100ae103Smrg		;;
8940103645bSmrg	rtpc | rtpc-*)
8950103645bSmrg		cpu=romp
8960103645bSmrg		vendor=ibm
897100ae103Smrg		;;
8980103645bSmrg	sde)
8990103645bSmrg		cpu=mipsisa32
9000103645bSmrg		vendor=sde
9010103645bSmrg		basic_os=${basic_os:-elf}
902100ae103Smrg		;;
9030103645bSmrg	simso-wrs)
9040103645bSmrg		cpu=sparclite
9050103645bSmrg		vendor=wrs
9060103645bSmrg		basic_os=vxworks
907100ae103Smrg		;;
9080103645bSmrg	tower | tower-32)
9090103645bSmrg		cpu=m68k
9100103645bSmrg		vendor=ncr
911100ae103Smrg		;;
9120103645bSmrg	vpp*|vx|vx-*)
9130103645bSmrg		cpu=f301
9140103645bSmrg		vendor=fujitsu
91595cf0c00Smrg		;;
9160103645bSmrg	w65)
9170103645bSmrg		cpu=w65
9180103645bSmrg		vendor=wdc
919165cb819Smrg		;;
9200103645bSmrg	w89k-*)
9210103645bSmrg		cpu=hppa1.1
9220103645bSmrg		vendor=winbond
9230103645bSmrg		basic_os=proelf
924100ae103Smrg		;;
9250103645bSmrg	none)
9260103645bSmrg		cpu=none
9270103645bSmrg		vendor=none
928100ae103Smrg		;;
9290103645bSmrg	leon|leon[3-9])
9300103645bSmrg		cpu=sparc
9310103645bSmrg		vendor=$basic_machine
932100ae103Smrg		;;
9330103645bSmrg	leon-*|leon[3-9]-*)
9340103645bSmrg		cpu=sparc
9350103645bSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936100ae103Smrg		;;
9370103645bSmrg
9380103645bSmrg	*-*)
9390103645bSmrg		# shellcheck disable=SC2162
9400103645bSmrg		saved_IFS=$IFS
9410103645bSmrg		IFS="-" read cpu vendor <<EOF
9420103645bSmrg$basic_machine
9430103645bSmrgEOF
9440103645bSmrg		IFS=$saved_IFS
945100ae103Smrg		;;
9460103645bSmrg	# We use `pc' rather than `unknown'
9470103645bSmrg	# because (1) that's what they normally are, and
9480103645bSmrg	# (2) the word "unknown" tends to confuse beginning users.
9490103645bSmrg	i*86 | x86_64)
9500103645bSmrg		cpu=$basic_machine
9510103645bSmrg		vendor=pc
952100ae103Smrg		;;
9530103645bSmrg	# These rules are duplicated from below for sake of the special case above;
9540103645bSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
9550103645bSmrg	pc98)
9560103645bSmrg		cpu=i386
9570103645bSmrg		vendor=pc
958100ae103Smrg		;;
9590103645bSmrg	x64 | amd64)
9600103645bSmrg		cpu=x86_64
9610103645bSmrg		vendor=pc
962100ae103Smrg		;;
9630103645bSmrg	# Recognize the basic CPU types without company name.
9640103645bSmrg	*)
9650103645bSmrg		cpu=$basic_machine
9660103645bSmrg		vendor=unknown
967165cb819Smrg		;;
9680103645bSmrgesac
9690103645bSmrg
9700103645bSmrgunset -v basic_machine
9710103645bSmrg
9720103645bSmrg# Decode basic machines in the full and proper CPU-Company form.
9730103645bSmrgcase $cpu-$vendor in
9740103645bSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9750103645bSmrg	# some cases the only manufacturer, in others, it is the most popular.
9760103645bSmrg	craynv-unknown)
9770103645bSmrg		vendor=cray
9780103645bSmrg		basic_os=${basic_os:-unicosmp}
979100ae103Smrg		;;
9800103645bSmrg	c90-unknown | c90-cray)
9810103645bSmrg		vendor=cray
9820103645bSmrg		basic_os=${Basic_os:-unicos}
983100ae103Smrg		;;
9840103645bSmrg	fx80-unknown)
9850103645bSmrg		vendor=alliant
986165cb819Smrg		;;
9870103645bSmrg	romp-unknown)
9880103645bSmrg		vendor=ibm
989100ae103Smrg		;;
9900103645bSmrg	mmix-unknown)
9910103645bSmrg		vendor=knuth
992100ae103Smrg		;;
9930103645bSmrg	microblaze-unknown | microblazeel-unknown)
9940103645bSmrg		vendor=xilinx
995100ae103Smrg		;;
9960103645bSmrg	rs6000-unknown)
9970103645bSmrg		vendor=ibm
998100ae103Smrg		;;
9990103645bSmrg	vax-unknown)
10000103645bSmrg		vendor=dec
1001100ae103Smrg		;;
10020103645bSmrg	pdp11-unknown)
10030103645bSmrg		vendor=dec
10048831d3fbSmrg		;;
10050103645bSmrg	we32k-unknown)
10060103645bSmrg		vendor=att
1007100ae103Smrg		;;
10080103645bSmrg	cydra-unknown)
10090103645bSmrg		vendor=cydrome
1010100ae103Smrg		;;
10110103645bSmrg	i370-ibm*)
10120103645bSmrg		vendor=ibm
1013100ae103Smrg		;;
10140103645bSmrg	orion-unknown)
10150103645bSmrg		vendor=highlevel
1016100ae103Smrg		;;
10170103645bSmrg	xps-unknown | xps100-unknown)
10180103645bSmrg		cpu=xps100
10190103645bSmrg		vendor=honeywell
1020100ae103Smrg		;;
10210103645bSmrg
10220103645bSmrg	# Here we normalize CPU types with a missing or matching vendor
102314a67432Smrg	armh-unknown | armh-alt)
102414a67432Smrg		cpu=armv7l
102514a67432Smrg		vendor=alt
102614a67432Smrg		basic_os=${basic_os:-linux-gnueabihf}
102714a67432Smrg		;;
10280103645bSmrg	dpx20-unknown | dpx20-bull)
10290103645bSmrg		cpu=rs6000
10300103645bSmrg		vendor=bull
10310103645bSmrg		basic_os=${basic_os:-bosx}
1032100ae103Smrg		;;
10330103645bSmrg
10340103645bSmrg	# Here we normalize CPU types irrespective of the vendor
10350103645bSmrg	amd64-*)
10360103645bSmrg		cpu=x86_64
1037100ae103Smrg		;;
10380103645bSmrg	blackfin-*)
10390103645bSmrg		cpu=bfin
10400103645bSmrg		basic_os=linux
1041100ae103Smrg		;;
10420103645bSmrg	c54x-*)
10430103645bSmrg		cpu=tic54x
1044100ae103Smrg		;;
10450103645bSmrg	c55x-*)
10460103645bSmrg		cpu=tic55x
1047100ae103Smrg		;;
10480103645bSmrg	c6x-*)
10490103645bSmrg		cpu=tic6x
1050100ae103Smrg		;;
10510103645bSmrg	e500v[12]-*)
10520103645bSmrg		cpu=powerpc
10530103645bSmrg		basic_os=${basic_os}"spe"
1054100ae103Smrg		;;
10550103645bSmrg	mips3*-*)
10560103645bSmrg		cpu=mips64
1057100ae103Smrg		;;
10580103645bSmrg	ms1-*)
10590103645bSmrg		cpu=mt
1060100ae103Smrg		;;
10610103645bSmrg	m68knommu-*)
10620103645bSmrg		cpu=m68k
10630103645bSmrg		basic_os=linux
1064100ae103Smrg		;;
10650103645bSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10660103645bSmrg		cpu=s12z
1067165cb819Smrg		;;
10680103645bSmrg	openrisc-*)
10690103645bSmrg		cpu=or32
1070100ae103Smrg		;;
10710103645bSmrg	parisc-*)
10720103645bSmrg		cpu=hppa
10730103645bSmrg		basic_os=linux
1074100ae103Smrg		;;
10750103645bSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10760103645bSmrg		cpu=i586
1077100ae103Smrg		;;
107814a67432Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10790103645bSmrg		cpu=i686
1080100ae103Smrg		;;
10810103645bSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10820103645bSmrg		cpu=i686
1083100ae103Smrg		;;
10840103645bSmrg	pentium4-*)
10850103645bSmrg		cpu=i786
1086100ae103Smrg		;;
10870103645bSmrg	pc98-*)
10880103645bSmrg		cpu=i386
1089100ae103Smrg		;;
10900103645bSmrg	ppc-* | ppcbe-*)
10910103645bSmrg		cpu=powerpc
1092100ae103Smrg		;;
10930103645bSmrg	ppcle-* | powerpclittle-*)
10940103645bSmrg		cpu=powerpcle
1095100ae103Smrg		;;
10960103645bSmrg	ppc64-*)
10970103645bSmrg		cpu=powerpc64
1098100ae103Smrg		;;
10990103645bSmrg	ppc64le-* | powerpc64little-*)
11000103645bSmrg		cpu=powerpc64le
1101100ae103Smrg		;;
11020103645bSmrg	sb1-*)
11030103645bSmrg		cpu=mipsisa64sb1
1104100ae103Smrg		;;
11050103645bSmrg	sb1el-*)
11060103645bSmrg		cpu=mipsisa64sb1el
1107100ae103Smrg		;;
11080103645bSmrg	sh5e[lb]-*)
11090103645bSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110100ae103Smrg		;;
11110103645bSmrg	spur-*)
11120103645bSmrg		cpu=spur
1113100ae103Smrg		;;
11140103645bSmrg	strongarm-* | thumb-*)
11150103645bSmrg		cpu=arm
1116100ae103Smrg		;;
11170103645bSmrg	tx39-*)
11180103645bSmrg		cpu=mipstx39
111995cf0c00Smrg		;;
11200103645bSmrg	tx39el-*)
11210103645bSmrg		cpu=mipstx39el
1122100ae103Smrg		;;
11230103645bSmrg	x64-*)
11240103645bSmrg		cpu=x86_64
1125100ae103Smrg		;;
11268831d3fbSmrg	xscale-* | xscalee[bl]-*)
11270103645bSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128100ae103Smrg		;;
112914a67432Smrg	arm64-* | aarch64le-*)
11300103645bSmrg		cpu=aarch64
1131100ae103Smrg		;;
1132100ae103Smrg
11330103645bSmrg	# Recognize the canonical CPU Types that limit and/or modify the
11340103645bSmrg	# company names they are paired with.
11350103645bSmrg	cr16-*)
11360103645bSmrg		basic_os=${basic_os:-elf}
1137100ae103Smrg		;;
11380103645bSmrg	crisv32-* | etraxfs*-*)
11390103645bSmrg		cpu=crisv32
11400103645bSmrg		vendor=axis
1141100ae103Smrg		;;
11420103645bSmrg	cris-* | etrax*-*)
11430103645bSmrg		cpu=cris
11440103645bSmrg		vendor=axis
1145100ae103Smrg		;;
11460103645bSmrg	crx-*)
11470103645bSmrg		basic_os=${basic_os:-elf}
1148100ae103Smrg		;;
11490103645bSmrg	neo-tandem)
11500103645bSmrg		cpu=neo
11510103645bSmrg		vendor=tandem
1152100ae103Smrg		;;
11530103645bSmrg	nse-tandem)
11540103645bSmrg		cpu=nse
11550103645bSmrg		vendor=tandem
1156100ae103Smrg		;;
11570103645bSmrg	nsr-tandem)
11580103645bSmrg		cpu=nsr
11590103645bSmrg		vendor=tandem
1160100ae103Smrg		;;
11610103645bSmrg	nsv-tandem)
11620103645bSmrg		cpu=nsv
11630103645bSmrg		vendor=tandem
1164100ae103Smrg		;;
11650103645bSmrg	nsx-tandem)
11660103645bSmrg		cpu=nsx
11670103645bSmrg		vendor=tandem
1168100ae103Smrg		;;
11690103645bSmrg	mipsallegrexel-sony)
11700103645bSmrg		cpu=mipsallegrexel
11710103645bSmrg		vendor=sony
1172100ae103Smrg		;;
11730103645bSmrg	tile*-*)
11740103645bSmrg		basic_os=${basic_os:-linux-gnu}
1175100ae103Smrg		;;
11760103645bSmrg
1177100ae103Smrg	*)
11780103645bSmrg		# Recognize the canonical CPU types that are allowed with any
11790103645bSmrg		# company name.
11800103645bSmrg		case $cpu in
11810103645bSmrg			1750a | 580 \
11820103645bSmrg			| a29k \
11830103645bSmrg			| aarch64 | aarch64_be \
11840103645bSmrg			| abacus \
11850103645bSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11860103645bSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11870103645bSmrg			| alphapca5[67] | alpha64pca5[67] \
11880103645bSmrg			| am33_2.0 \
11890103645bSmrg			| amdgcn \
11900103645bSmrg			| arc | arceb | arc32 | arc64 \
11910103645bSmrg			| arm | arm[lb]e | arme[lb] | armv* \
11920103645bSmrg			| avr | avr32 \
11930103645bSmrg			| asmjs \
11940103645bSmrg			| ba \
11950103645bSmrg			| be32 | be64 \
11960103645bSmrg			| bfin | bpf | bs2000 \
11970103645bSmrg			| c[123]* | c30 | [cjt]90 | c4x \
11980103645bSmrg			| c8051 | clipper | craynv | csky | cydra \
11990103645bSmrg			| d10v | d30v | dlx | dsp16xx \
12000103645bSmrg			| e2k | elxsi | epiphany \
12010103645bSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12020103645bSmrg			| h8300 | h8500 \
12030103645bSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12040103645bSmrg			| hexagon \
12050103645bSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12060103645bSmrg			| ip2k | iq2000 \
12070103645bSmrg			| k1om \
12080103645bSmrg			| le32 | le64 \
12090103645bSmrg			| lm32 \
121014a67432Smrg			| loongarch32 | loongarch64 \
12110103645bSmrg			| m32c | m32r | m32rle \
12120103645bSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12130103645bSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12140103645bSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12150103645bSmrg			| microblaze | microblazeel \
12160103645bSmrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12170103645bSmrg			| mips16 \
12180103645bSmrg			| mips64 | mips64eb | mips64el \
12190103645bSmrg			| mips64octeon | mips64octeonel \
12200103645bSmrg			| mips64orion | mips64orionel \
12210103645bSmrg			| mips64r5900 | mips64r5900el \
12220103645bSmrg			| mips64vr | mips64vrel \
12230103645bSmrg			| mips64vr4100 | mips64vr4100el \
12240103645bSmrg			| mips64vr4300 | mips64vr4300el \
12250103645bSmrg			| mips64vr5000 | mips64vr5000el \
12260103645bSmrg			| mips64vr5900 | mips64vr5900el \
12270103645bSmrg			| mipsisa32 | mipsisa32el \
12280103645bSmrg			| mipsisa32r2 | mipsisa32r2el \
12290103645bSmrg			| mipsisa32r3 | mipsisa32r3el \
12300103645bSmrg			| mipsisa32r5 | mipsisa32r5el \
12310103645bSmrg			| mipsisa32r6 | mipsisa32r6el \
12320103645bSmrg			| mipsisa64 | mipsisa64el \
12330103645bSmrg			| mipsisa64r2 | mipsisa64r2el \
12340103645bSmrg			| mipsisa64r3 | mipsisa64r3el \
12350103645bSmrg			| mipsisa64r5 | mipsisa64r5el \
12360103645bSmrg			| mipsisa64r6 | mipsisa64r6el \
12370103645bSmrg			| mipsisa64sb1 | mipsisa64sb1el \
12380103645bSmrg			| mipsisa64sr71k | mipsisa64sr71kel \
12390103645bSmrg			| mipsr5900 | mipsr5900el \
12400103645bSmrg			| mipstx39 | mipstx39el \
12410103645bSmrg			| mmix \
12420103645bSmrg			| mn10200 | mn10300 \
12430103645bSmrg			| moxie \
12440103645bSmrg			| mt \
12450103645bSmrg			| msp430 \
12460103645bSmrg			| nds32 | nds32le | nds32be \
12470103645bSmrg			| nfp \
12480103645bSmrg			| nios | nios2 | nios2eb | nios2el \
12490103645bSmrg			| none | np1 | ns16k | ns32k | nvptx \
12500103645bSmrg			| open8 \
12510103645bSmrg			| or1k* \
12520103645bSmrg			| or32 \
12530103645bSmrg			| orion \
12540103645bSmrg			| picochip \
12550103645bSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12560103645bSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12570103645bSmrg			| pru \
12580103645bSmrg			| pyramid \
12590103645bSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12600103645bSmrg			| rl78 | romp | rs6000 | rx \
12610103645bSmrg			| s390 | s390x \
12620103645bSmrg			| score \
12630103645bSmrg			| sh | shl \
12640103645bSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12650103645bSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12660103645bSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12670103645bSmrg			| sparclite \
12680103645bSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12690103645bSmrg			| spu \
12700103645bSmrg			| tahoe \
12710103645bSmrg			| thumbv7* \
12720103645bSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12730103645bSmrg			| tron \
12740103645bSmrg			| ubicom32 \
12750103645bSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12760103645bSmrg			| vax \
12770103645bSmrg			| visium \
12780103645bSmrg			| w65 \
12790103645bSmrg			| wasm32 | wasm64 \
12800103645bSmrg			| we32k \
12810103645bSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12820103645bSmrg			| xstormy16 | xtensa* \
12830103645bSmrg			| ymp \
12840103645bSmrg			| z8k | z80)
12850103645bSmrg				;;
12860103645bSmrg
12870103645bSmrg			*)
12880103645bSmrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12890103645bSmrg				exit 1
12900103645bSmrg				;;
12910103645bSmrg		esac
1292100ae103Smrg		;;
1293100ae103Smrgesac
1294100ae103Smrg
1295100ae103Smrg# Here we canonicalize certain aliases for manufacturers.
12960103645bSmrgcase $vendor in
12970103645bSmrg	digital*)
12980103645bSmrg		vendor=dec
1299100ae103Smrg		;;
13000103645bSmrg	commodore*)
13010103645bSmrg		vendor=cbm
1302100ae103Smrg		;;
1303100ae103Smrg	*)
1304100ae103Smrg		;;
1305100ae103Smrgesac
1306100ae103Smrg
1307100ae103Smrg# Decode manufacturer-specific aliases for certain operating systems.
1308100ae103Smrg
13090103645bSmrgif test x$basic_os != x
1310100ae103Smrgthen
13110103645bSmrg
131214a67432Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13130103645bSmrg# set os.
13140103645bSmrgcase $basic_os in
13150103645bSmrg	gnu/linux*)
13160103645bSmrg		kernel=linux
13170103645bSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13180103645bSmrg		;;
13190103645bSmrg	os2-emx)
13200103645bSmrg		kernel=os2
13210103645bSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13220103645bSmrg		;;
13230103645bSmrg	nto-qnx*)
13240103645bSmrg		kernel=nto
13250103645bSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13260103645bSmrg		;;
13270103645bSmrg	*-*)
13280103645bSmrg		# shellcheck disable=SC2162
13290103645bSmrg		saved_IFS=$IFS
13300103645bSmrg		IFS="-" read kernel os <<EOF
13310103645bSmrg$basic_os
13320103645bSmrgEOF
13330103645bSmrg		IFS=$saved_IFS
13340103645bSmrg		;;
13350103645bSmrg	# Default OS when just kernel was specified
13360103645bSmrg	nto*)
13370103645bSmrg		kernel=nto
13380103645bSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13390103645bSmrg		;;
13400103645bSmrg	linux*)
13410103645bSmrg		kernel=linux
13420103645bSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13430103645bSmrg		;;
134414a67432Smrg	managarm*)
134514a67432Smrg		kernel=managarm
134614a67432Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
134714a67432Smrg		;;
13480103645bSmrg	*)
13490103645bSmrg		kernel=
13500103645bSmrg		os=$basic_os
13510103645bSmrg		;;
13520103645bSmrgesac
13530103645bSmrg
13540103645bSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13550103645bSmrg# etc.)
1356100ae103Smrgcase $os in
135795cf0c00Smrg	# First match some system type aliases that might get confused
135895cf0c00Smrg	# with valid system types.
13590103645bSmrg	# solaris* is a basic system type, with this one exception.
13600103645bSmrg	auroraux)
13610103645bSmrg		os=auroraux
1362165cb819Smrg		;;
13630103645bSmrg	bluegene*)
13640103645bSmrg		os=cnk
1365100ae103Smrg		;;
13660103645bSmrg	solaris1 | solaris1.*)
13670103645bSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368100ae103Smrg		;;
13690103645bSmrg	solaris)
13700103645bSmrg		os=solaris2
1371100ae103Smrg		;;
13720103645bSmrg	unixware*)
13730103645bSmrg		os=sysv4.2uw
1374100ae103Smrg		;;
137595cf0c00Smrg	# es1800 is here to avoid being matched by es* (a different OS)
13760103645bSmrg	es1800*)
13770103645bSmrg		os=ose
137895cf0c00Smrg		;;
13790103645bSmrg	# Some version numbers need modification
13800103645bSmrg	chorusos*)
13810103645bSmrg		os=chorusos
1382100ae103Smrg		;;
13830103645bSmrg	isc)
13840103645bSmrg		os=isc2.2
1385100ae103Smrg		;;
13860103645bSmrg	sco6)
13870103645bSmrg		os=sco5v6
1388100ae103Smrg		;;
13890103645bSmrg	sco5)
13900103645bSmrg		os=sco3.2v5
1391100ae103Smrg		;;
13920103645bSmrg	sco4)
13930103645bSmrg		os=sco3.2v4
1394100ae103Smrg		;;
13950103645bSmrg	sco3.2.[4-9]*)
13960103645bSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397100ae103Smrg		;;
13980103645bSmrg	sco*v* | scout)
13990103645bSmrg		# Don't match below
1400100ae103Smrg		;;
14010103645bSmrg	sco*)
14020103645bSmrg		os=sco3.2v2
1403100ae103Smrg		;;
14040103645bSmrg	psos*)
14050103645bSmrg		os=psos
1406100ae103Smrg		;;
14070103645bSmrg	qnx*)
14080103645bSmrg		os=qnx
1409100ae103Smrg		;;
14100103645bSmrg	hiux*)
14110103645bSmrg		os=hiuxwe2
1412100ae103Smrg		;;
14130103645bSmrg	lynx*178)
14140103645bSmrg		os=lynxos178
1415100ae103Smrg		;;
14160103645bSmrg	lynx*5)
14170103645bSmrg		os=lynxos5
1418100ae103Smrg		;;
14190103645bSmrg	lynxos*)
14200103645bSmrg		# don't get caught up in next wildcard
1421100ae103Smrg		;;
14220103645bSmrg	lynx*)
14230103645bSmrg		os=lynxos
1424100ae103Smrg		;;
14250103645bSmrg	mac[0-9]*)
14260103645bSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427100ae103Smrg		;;
14280103645bSmrg	opened*)
14290103645bSmrg		os=openedition
1430100ae103Smrg		;;
14310103645bSmrg	os400*)
14320103645bSmrg		os=os400
1433100ae103Smrg		;;
14340103645bSmrg	sunos5*)
14350103645bSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436100ae103Smrg		;;
14370103645bSmrg	sunos6*)
14380103645bSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439100ae103Smrg		;;
14400103645bSmrg	wince*)
14410103645bSmrg		os=wince
1442100ae103Smrg		;;
14430103645bSmrg	utek*)
14440103645bSmrg		os=bsd
1445100ae103Smrg		;;
14460103645bSmrg	dynix*)
14470103645bSmrg		os=bsd
1448100ae103Smrg		;;
14490103645bSmrg	acis*)
14500103645bSmrg		os=aos
1451100ae103Smrg		;;
14520103645bSmrg	atheos*)
14530103645bSmrg		os=atheos
1454100ae103Smrg		;;
14550103645bSmrg	syllable*)
14560103645bSmrg		os=syllable
14570103645bSmrg		;;
14580103645bSmrg	386bsd)
14590103645bSmrg		os=bsd
14600103645bSmrg		;;
14610103645bSmrg	ctix* | uts*)
14620103645bSmrg		os=sysv
14630103645bSmrg		;;
14640103645bSmrg	nova*)
14650103645bSmrg		os=rtmk-nova
14660103645bSmrg		;;
14670103645bSmrg	ns2)
14680103645bSmrg		os=nextstep2
14690103645bSmrg		;;
14700103645bSmrg	# Preserve the version number of sinix5.
14710103645bSmrg	sinix5.*)
14720103645bSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473100ae103Smrg		;;
14740103645bSmrg	sinix*)
14750103645bSmrg		os=sysv4
1476100ae103Smrg		;;
14770103645bSmrg	tpf*)
14780103645bSmrg		os=tpf
1479100ae103Smrg		;;
14800103645bSmrg	triton*)
14810103645bSmrg		os=sysv3
1482100ae103Smrg		;;
14830103645bSmrg	oss*)
14840103645bSmrg		os=sysv3
1485100ae103Smrg		;;
14860103645bSmrg	svr4*)
14870103645bSmrg		os=sysv4
1488100ae103Smrg		;;
14890103645bSmrg	svr3)
14900103645bSmrg		os=sysv3
1491100ae103Smrg		;;
14920103645bSmrg	sysvr4)
14930103645bSmrg		os=sysv4
1494100ae103Smrg		;;
14950103645bSmrg	ose*)
14960103645bSmrg		os=ose
1497100ae103Smrg		;;
14980103645bSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14990103645bSmrg		os=mint
1500165cb819Smrg		;;
15010103645bSmrg	dicos*)
15020103645bSmrg		os=dicos
15030103645bSmrg		;;
15040103645bSmrg	pikeos*)
150595cf0c00Smrg		# Until real need of OS specific support for
150695cf0c00Smrg		# particular features comes up, bare metal
150795cf0c00Smrg		# configurations are quite functional.
15080103645bSmrg		case $cpu in
150995cf0c00Smrg		    arm*)
15100103645bSmrg			os=eabi
151195cf0c00Smrg			;;
151295cf0c00Smrg		    *)
15130103645bSmrg			os=elf
151495cf0c00Smrg			;;
151595cf0c00Smrg		esac
151695cf0c00Smrg		;;
1517100ae103Smrg	*)
15180103645bSmrg		# No normalization, but not necessarily accepted, that comes below.
1519100ae103Smrg		;;
1520100ae103Smrgesac
15210103645bSmrg
1522100ae103Smrgelse
1523100ae103Smrg
1524100ae103Smrg# Here we handle the default operating systems that come with various machines.
1525100ae103Smrg# The value should be what the vendor currently ships out the door with their
1526100ae103Smrg# machine or put another way, the most popular os provided with the machine.
1527100ae103Smrg
1528100ae103Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529100ae103Smrg# "-sun"), then you have to tell the case statement up towards the top
1530100ae103Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531100ae103Smrg# will signal an error saying that MANUFACTURER isn't an operating
1532100ae103Smrg# system, and we'll never get to this point.
1533100ae103Smrg
15340103645bSmrgkernel=
15350103645bSmrgcase $cpu-$vendor in
15368831d3fbSmrg	score-*)
15370103645bSmrg		os=elf
1538165cb819Smrg		;;
15398831d3fbSmrg	spu-*)
15400103645bSmrg		os=elf
1541165cb819Smrg		;;
1542100ae103Smrg	*-acorn)
15430103645bSmrg		os=riscix1.2
1544100ae103Smrg		;;
1545100ae103Smrg	arm*-rebel)
15460103645bSmrg		kernel=linux
15470103645bSmrg		os=gnu
1548100ae103Smrg		;;
1549100ae103Smrg	arm*-semi)
15500103645bSmrg		os=aout
1551100ae103Smrg		;;
15528831d3fbSmrg	c4x-* | tic4x-*)
15530103645bSmrg		os=coff
15548831d3fbSmrg		;;
155595cf0c00Smrg	c8051-*)
15560103645bSmrg		os=elf
15570103645bSmrg		;;
15580103645bSmrg	clipper-intergraph)
15590103645bSmrg		os=clix
156095cf0c00Smrg		;;
156195cf0c00Smrg	hexagon-*)
15620103645bSmrg		os=elf
156395cf0c00Smrg		;;
15648831d3fbSmrg	tic54x-*)
15650103645bSmrg		os=coff
15668831d3fbSmrg		;;
15678831d3fbSmrg	tic55x-*)
15680103645bSmrg		os=coff
15698831d3fbSmrg		;;
15708831d3fbSmrg	tic6x-*)
15710103645bSmrg		os=coff
1572165cb819Smrg		;;
1573100ae103Smrg	# This must come before the *-dec entry.
1574100ae103Smrg	pdp10-*)
15750103645bSmrg		os=tops20
1576100ae103Smrg		;;
1577100ae103Smrg	pdp11-*)
15780103645bSmrg		os=none
1579100ae103Smrg		;;
1580100ae103Smrg	*-dec | vax-*)
15810103645bSmrg		os=ultrix4.2
1582100ae103Smrg		;;
1583100ae103Smrg	m68*-apollo)
15840103645bSmrg		os=domain
1585100ae103Smrg		;;
1586100ae103Smrg	i386-sun)
15870103645bSmrg		os=sunos4.0.2
1588100ae103Smrg		;;
1589100ae103Smrg	m68000-sun)
15900103645bSmrg		os=sunos3
1591100ae103Smrg		;;
1592100ae103Smrg	m68*-cisco)
15930103645bSmrg		os=aout
1594100ae103Smrg		;;
15958831d3fbSmrg	mep-*)
15960103645bSmrg		os=elf
1597165cb819Smrg		;;
1598100ae103Smrg	mips*-cisco)
15990103645bSmrg		os=elf
1600100ae103Smrg		;;
1601100ae103Smrg	mips*-*)
16020103645bSmrg		os=elf
1603100ae103Smrg		;;
1604100ae103Smrg	or32-*)
16050103645bSmrg		os=coff
1606100ae103Smrg		;;
1607100ae103Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
16080103645bSmrg		os=sysv3
1609100ae103Smrg		;;
1610100ae103Smrg	sparc-* | *-sun)
16110103645bSmrg		os=sunos4.1.1
1612100ae103Smrg		;;
161395cf0c00Smrg	pru-*)
16140103645bSmrg		os=elf
161595cf0c00Smrg		;;
1616100ae103Smrg	*-be)
16170103645bSmrg		os=beos
1618100ae103Smrg		;;
1619100ae103Smrg	*-ibm)
16200103645bSmrg		os=aix
1621100ae103Smrg		;;
16228831d3fbSmrg	*-knuth)
16230103645bSmrg		os=mmixware
1624100ae103Smrg		;;
1625100ae103Smrg	*-wec)
16260103645bSmrg		os=proelf
1627100ae103Smrg		;;
1628100ae103Smrg	*-winbond)
16290103645bSmrg		os=proelf
1630100ae103Smrg		;;
1631100ae103Smrg	*-oki)
16320103645bSmrg		os=proelf
1633100ae103Smrg		;;
1634100ae103Smrg	*-hp)
16350103645bSmrg		os=hpux
1636100ae103Smrg		;;
1637100ae103Smrg	*-hitachi)
16380103645bSmrg		os=hiux
1639100ae103Smrg		;;
1640100ae103Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16410103645bSmrg		os=sysv
1642100ae103Smrg		;;
1643100ae103Smrg	*-cbm)
16440103645bSmrg		os=amigaos
1645100ae103Smrg		;;
1646100ae103Smrg	*-dg)
16470103645bSmrg		os=dgux
1648100ae103Smrg		;;
1649100ae103Smrg	*-dolphin)
16500103645bSmrg		os=sysv3
1651100ae103Smrg		;;
1652100ae103Smrg	m68k-ccur)
16530103645bSmrg		os=rtu
1654100ae103Smrg		;;
1655100ae103Smrg	m88k-omron*)
16560103645bSmrg		os=luna
1657100ae103Smrg		;;
165895cf0c00Smrg	*-next)
16590103645bSmrg		os=nextstep
1660100ae103Smrg		;;
1661100ae103Smrg	*-sequent)
16620103645bSmrg		os=ptx
1663100ae103Smrg		;;
1664100ae103Smrg	*-crds)
16650103645bSmrg		os=unos
1666100ae103Smrg		;;
1667100ae103Smrg	*-ns)
16680103645bSmrg		os=genix
1669100ae103Smrg		;;
1670100ae103Smrg	i370-*)
16710103645bSmrg		os=mvs
1672100ae103Smrg		;;
1673100ae103Smrg	*-gould)
16740103645bSmrg		os=sysv
1675100ae103Smrg		;;
1676100ae103Smrg	*-highlevel)
16770103645bSmrg		os=bsd
1678100ae103Smrg		;;
1679100ae103Smrg	*-encore)
16800103645bSmrg		os=bsd
1681100ae103Smrg		;;
1682100ae103Smrg	*-sgi)
16830103645bSmrg		os=irix
1684100ae103Smrg		;;
1685100ae103Smrg	*-siemens)
16860103645bSmrg		os=sysv4
1687100ae103Smrg		;;
1688100ae103Smrg	*-masscomp)
16890103645bSmrg		os=rtu
1690100ae103Smrg		;;
1691100ae103Smrg	f30[01]-fujitsu | f700-fujitsu)
16920103645bSmrg		os=uxpv
1693100ae103Smrg		;;
1694100ae103Smrg	*-rom68k)
16950103645bSmrg		os=coff
1696100ae103Smrg		;;
1697100ae103Smrg	*-*bug)
16980103645bSmrg		os=coff
1699100ae103Smrg		;;
1700100ae103Smrg	*-apple)
17010103645bSmrg		os=macos
1702100ae103Smrg		;;
1703100ae103Smrg	*-atari*)
17040103645bSmrg		os=mint
17050103645bSmrg		;;
17060103645bSmrg	*-wrs)
17070103645bSmrg		os=vxworks
1708100ae103Smrg		;;
1709100ae103Smrg	*)
17100103645bSmrg		os=none
1711100ae103Smrg		;;
1712100ae103Smrgesac
17130103645bSmrg
1714100ae103Smrgfi
1715100ae103Smrg
17160103645bSmrg# Now, validate our (potentially fixed-up) OS.
17170103645bSmrgcase $os in
17180103645bSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17190103645bSmrg	musl* | newlib* | relibc* | uclibc*)
17200103645bSmrg		;;
17210103645bSmrg	# Likewise for "kernel-abi"
17220103645bSmrg	eabi* | gnueabi*)
17230103645bSmrg		;;
17240103645bSmrg	# VxWorks passes extra cpu info in the 4th filed.
17250103645bSmrg	simlinux | simwindows | spe)
17260103645bSmrg		;;
17270103645bSmrg	# Now accept the basic system types.
17280103645bSmrg	# The portable systems comes first.
17290103645bSmrg	# Each alternative MUST end in a * to match a version number.
17300103645bSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17310103645bSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17320103645bSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17330103645bSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17340103645bSmrg	     | hiux* | abug | nacl* | netware* | windows* \
17350103645bSmrg	     | os9* | macos* | osx* | ios* \
17360103645bSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17370103645bSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17380103645bSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17390103645bSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17400103645bSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17410103645bSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17420103645bSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17430103645bSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17440103645bSmrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17450103645bSmrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17460103645bSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17470103645bSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17480103645bSmrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17490103645bSmrg	     | midipix* | mingw32* | mingw64* | mint* \
17500103645bSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17510103645bSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17520103645bSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17530103645bSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17540103645bSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17550103645bSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17560103645bSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17570103645bSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17580103645bSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17590103645bSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
176014a67432Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
176114a67432Smrg	     | fiwix* | mlibc* )
17620103645bSmrg		;;
17630103645bSmrg	# This one is extra strict with allowed versions
17640103645bSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17650103645bSmrg		# Don't forget version if it is 3.2v4 or newer.
17660103645bSmrg		;;
17670103645bSmrg	none)
17680103645bSmrg		;;
176914a67432Smrg	kernel* )
177014a67432Smrg		# Restricted further below
177114a67432Smrg		;;
17720103645bSmrg	*)
17730103645bSmrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17740103645bSmrg		exit 1
17750103645bSmrg		;;
17760103645bSmrgesac
17770103645bSmrg
17780103645bSmrg# As a final step for OS-related things, validate the OS-kernel combination
17790103645bSmrg# (given a valid OS), if there is a kernel.
17800103645bSmrgcase $kernel-$os in
17810103645bSmrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
178214a67432Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17830103645bSmrg		;;
17840103645bSmrg	uclinux-uclibc* )
17850103645bSmrg		;;
178614a67432Smrg	managarm-mlibc* | managarm-kernel* )
178714a67432Smrg		;;
178814a67432Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17890103645bSmrg		# These are just libc implementations, not actual OSes, and thus
17900103645bSmrg		# require a kernel.
17910103645bSmrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17920103645bSmrg		exit 1
17930103645bSmrg		;;
179414a67432Smrg	-kernel* )
179514a67432Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
179614a67432Smrg		exit 1
179714a67432Smrg		;;
179814a67432Smrg	*-kernel* )
179914a67432Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
180014a67432Smrg		exit 1
180114a67432Smrg		;;
18020103645bSmrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
18030103645bSmrg		;;
18040103645bSmrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
18050103645bSmrg		;;
18060103645bSmrg	nto-qnx*)
18070103645bSmrg		;;
18080103645bSmrg	os2-emx)
18090103645bSmrg		;;
18100103645bSmrg	*-eabi* | *-gnueabi*)
18110103645bSmrg		;;
18120103645bSmrg	-*)
18130103645bSmrg		# Blank kernel with real OS is always fine.
18140103645bSmrg		;;
18150103645bSmrg	*-*)
18160103645bSmrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18170103645bSmrg		exit 1
18180103645bSmrg		;;
18190103645bSmrgesac
18200103645bSmrg
1821100ae103Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1822100ae103Smrg# manufacturer.  We pick the logical manufacturer.
18230103645bSmrgcase $vendor in
18240103645bSmrg	unknown)
18250103645bSmrg		case $cpu-$os in
18260103645bSmrg			*-riscix*)
1827100ae103Smrg				vendor=acorn
1828100ae103Smrg				;;
18290103645bSmrg			*-sunos*)
1830100ae103Smrg				vendor=sun
1831100ae103Smrg				;;
18320103645bSmrg			*-cnk* | *-aix*)
1833100ae103Smrg				vendor=ibm
1834100ae103Smrg				;;
18350103645bSmrg			*-beos*)
1836100ae103Smrg				vendor=be
1837100ae103Smrg				;;
18380103645bSmrg			*-hpux*)
1839100ae103Smrg				vendor=hp
1840100ae103Smrg				;;
18410103645bSmrg			*-mpeix*)
1842100ae103Smrg				vendor=hp
1843100ae103Smrg				;;
18440103645bSmrg			*-hiux*)
1845100ae103Smrg				vendor=hitachi
1846100ae103Smrg				;;
18470103645bSmrg			*-unos*)
1848100ae103Smrg				vendor=crds
1849100ae103Smrg				;;
18500103645bSmrg			*-dgux*)
1851100ae103Smrg				vendor=dg
1852100ae103Smrg				;;
18530103645bSmrg			*-luna*)
1854100ae103Smrg				vendor=omron
1855100ae103Smrg				;;
18560103645bSmrg			*-genix*)
1857100ae103Smrg				vendor=ns
1858100ae103Smrg				;;
18590103645bSmrg			*-clix*)
18600103645bSmrg				vendor=intergraph
18610103645bSmrg				;;
18620103645bSmrg			*-mvs* | *-opened*)
18630103645bSmrg				vendor=ibm
18640103645bSmrg				;;
18650103645bSmrg			*-os400*)
1866100ae103Smrg				vendor=ibm
1867100ae103Smrg				;;
18680103645bSmrg			s390-* | s390x-*)
1869100ae103Smrg				vendor=ibm
1870100ae103Smrg				;;
18710103645bSmrg			*-ptx*)
1872100ae103Smrg				vendor=sequent
1873100ae103Smrg				;;
18740103645bSmrg			*-tpf*)
1875100ae103Smrg				vendor=ibm
1876100ae103Smrg				;;
18770103645bSmrg			*-vxsim* | *-vxworks* | *-windiss*)
1878100ae103Smrg				vendor=wrs
1879100ae103Smrg				;;
18800103645bSmrg			*-aux*)
1881100ae103Smrg				vendor=apple
1882100ae103Smrg				;;
18830103645bSmrg			*-hms*)
1884100ae103Smrg				vendor=hitachi
1885100ae103Smrg				;;
18860103645bSmrg			*-mpw* | *-macos*)
1887100ae103Smrg				vendor=apple
1888100ae103Smrg				;;
18890103645bSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890100ae103Smrg				vendor=atari
1891100ae103Smrg				;;
18920103645bSmrg			*-vos*)
1893100ae103Smrg				vendor=stratus
1894100ae103Smrg				;;
1895100ae103Smrg		esac
1896100ae103Smrg		;;
1897100ae103Smrgesac
1898100ae103Smrg
18990103645bSmrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900100ae103Smrgexit
1901100ae103Smrg
1902100ae103Smrg# Local variables:
19030103645bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904100ae103Smrg# time-stamp-start: "timestamp='"
1905100ae103Smrg# time-stamp-format: "%:y-%02m-%02d"
1906100ae103Smrg# time-stamp-end: "'"
1907100ae103Smrg# End:
1908