1caade7ccSmrg#! /bin/sh
2caade7ccSmrg# Configuration validation subroutine script.
305789e77Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4caade7ccSmrg
50760f5d2Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
60760f5d2Smrg
705789e77Smrgtimestamp='2023-01-21'
8caade7ccSmrg
9af9a7ee5Smrg# This file is free software; you can redistribute it and/or modify it
10af9a7ee5Smrg# under the terms of the GNU General Public License as published by
1105789e77Smrg# the Free Software Foundation, either version 3 of the License, or
12caade7ccSmrg# (at your option) any later version.
13caade7ccSmrg#
14af9a7ee5Smrg# This program is distributed in the hope that it will be useful, but
15af9a7ee5Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16af9a7ee5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17af9a7ee5Smrg# General Public License for more details.
18caade7ccSmrg#
19caade7ccSmrg# You should have received a copy of the GNU General Public License
20cc4920e5Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21caade7ccSmrg#
22caade7ccSmrg# As a special exception to the GNU General Public License, if you
23caade7ccSmrg# distribute this file as part of a program that contains a
24caade7ccSmrg# configuration script generated by Autoconf, you may include it under
25af9a7ee5Smrg# the same distribution terms that you use for the rest of that
26af9a7ee5Smrg# program.  This Exception is an additional permission under section 7
27af9a7ee5Smrg# of the GNU General Public License, version 3 ("GPLv3").
28caade7ccSmrg
29caade7ccSmrg
30cc4920e5Smrg# Please send patches to <config-patches@gnu.org>.
31caade7ccSmrg#
32caade7ccSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33caade7ccSmrg# Supply the specified configuration type as an argument.
34caade7ccSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35caade7ccSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36caade7ccSmrg
37b9b4fd27Smrg# You can get the latest version of this script from:
380760f5d2Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39b9b4fd27Smrg
40caade7ccSmrg# This file is supposed to be the same for all GNU packages
41caade7ccSmrg# and recognize all the CPU types, system types and aliases
42caade7ccSmrg# that are meaningful with *any* GNU software.
43caade7ccSmrg# Each package is responsible for reporting which valid configurations
44caade7ccSmrg# it does not support.  The user should be able to distinguish
45caade7ccSmrg# a failure to support a valid configuration from a meaningless
46caade7ccSmrg# configuration.
47caade7ccSmrg
48caade7ccSmrg# The goal of this file is to map all the various variations of a given
49caade7ccSmrg# machine specification into a single specification in the form:
50caade7ccSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51caade7ccSmrg# or in some cases, the newer four-part form:
52caade7ccSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53caade7ccSmrg# It is wrong to echo any other type of specification.
54caade7ccSmrg
550760f5d2Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
560760f5d2Smrg# about features and limitations of the classic Bourne shell that were
570760f5d2Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
580760f5d2Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
590760f5d2Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
600760f5d2Smrg# have a pre-POSIX /bin/sh.
610760f5d2Smrg
62caade7ccSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63caade7ccSmrg
64caade7ccSmrgusage="\
65cc4920e5SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66caade7ccSmrg
67caade7ccSmrgCanonicalize a configuration name.
68caade7ccSmrg
69cc4920e5SmrgOptions:
70caade7ccSmrg  -h, --help         print this help, then exit
71caade7ccSmrg  -t, --time-stamp   print date of last modification, then exit
72caade7ccSmrg  -v, --version      print version number, then exit
73caade7ccSmrg
74caade7ccSmrgReport bugs and patches to <config-patches@gnu.org>."
75caade7ccSmrg
76caade7ccSmrgversion="\
77caade7ccSmrgGNU config.sub ($timestamp)
78caade7ccSmrg
7905789e77SmrgCopyright 1992-2023 Free Software Foundation, Inc.
80caade7ccSmrg
81caade7ccSmrgThis is free software; see the source for copying conditions.  There is NO
82caade7ccSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83caade7ccSmrg
84caade7ccSmrghelp="
85caade7ccSmrgTry \`$me --help' for more information."
86caade7ccSmrg
87caade7ccSmrg# Parse command line
88caade7ccSmrgwhile test $# -gt 0 ; do
89caade7ccSmrg  case $1 in
90caade7ccSmrg    --time-stamp | --time* | -t )
91caade7ccSmrg       echo "$timestamp" ; exit ;;
92caade7ccSmrg    --version | -v )
93caade7ccSmrg       echo "$version" ; exit ;;
94caade7ccSmrg    --help | --h* | -h )
95caade7ccSmrg       echo "$usage"; exit ;;
96caade7ccSmrg    -- )     # Stop option processing
97caade7ccSmrg       shift; break ;;
98caade7ccSmrg    - )	# Use stdin as input.
99caade7ccSmrg       break ;;
100caade7ccSmrg    -* )
1010760f5d2Smrg       echo "$me: invalid option $1$help" >&2
102caade7ccSmrg       exit 1 ;;
103caade7ccSmrg
104caade7ccSmrg    *local*)
105caade7ccSmrg       # First pass through any local machine types.
106cc4920e5Smrg       echo "$1"
107caade7ccSmrg       exit ;;
108caade7ccSmrg
109caade7ccSmrg    * )
110caade7ccSmrg       break ;;
111caade7ccSmrg  esac
112caade7ccSmrgdone
113caade7ccSmrg
114caade7ccSmrgcase $# in
115caade7ccSmrg 0) echo "$me: missing argument$help" >&2
116caade7ccSmrg    exit 1;;
117caade7ccSmrg 1) ;;
118caade7ccSmrg *) echo "$me: too many arguments$help" >&2
119caade7ccSmrg    exit 1;;
120caade7ccSmrgesac
121caade7ccSmrg
1220760f5d2Smrg# Split fields of configuration type
1230760f5d2Smrg# shellcheck disable=SC2162
1240760f5d2Smrgsaved_IFS=$IFS
1250760f5d2SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1260760f5d2Smrg$1
1270760f5d2SmrgEOF
1280760f5d2SmrgIFS=$saved_IFS
129caade7ccSmrg
1300760f5d2Smrg# Separate into logical components for further validation
1310760f5d2Smrgcase $1 in
1320760f5d2Smrg	*-*-*-*-*)
1330760f5d2Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
1340760f5d2Smrg		exit 1
135af9a7ee5Smrg		;;
1360760f5d2Smrg	*-*-*-*)
1370760f5d2Smrg		basic_machine=$field1-$field2
1380760f5d2Smrg		basic_os=$field3-$field4
139caade7ccSmrg		;;
1400760f5d2Smrg	*-*-*)
1410760f5d2Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1420760f5d2Smrg		# parts
1430760f5d2Smrg		maybe_os=$field2-$field3
1440760f5d2Smrg		case $maybe_os in
1450760f5d2Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1460760f5d2Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1470760f5d2Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14805789e77Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
1490760f5d2Smrg				basic_machine=$field1
1500760f5d2Smrg				basic_os=$maybe_os
1510760f5d2Smrg				;;
1520760f5d2Smrg			android-linux)
1530760f5d2Smrg				basic_machine=$field1-unknown
1540760f5d2Smrg				basic_os=linux-android
1550760f5d2Smrg				;;
1560760f5d2Smrg			*)
1570760f5d2Smrg				basic_machine=$field1-$field2
1580760f5d2Smrg				basic_os=$field3
1590760f5d2Smrg				;;
1600760f5d2Smrg		esac
161caade7ccSmrg		;;
1620760f5d2Smrg	*-*)
1630760f5d2Smrg		# A lone config we happen to match not fitting any pattern
1640760f5d2Smrg		case $field1-$field2 in
1650760f5d2Smrg			decstation-3100)
1660760f5d2Smrg				basic_machine=mips-dec
1670760f5d2Smrg				basic_os=
1680760f5d2Smrg				;;
1690760f5d2Smrg			*-*)
1700760f5d2Smrg				# Second component is usually, but not always the OS
1710760f5d2Smrg				case $field2 in
1720760f5d2Smrg					# Prevent following clause from handling this valid os
1730760f5d2Smrg					sun*os*)
1740760f5d2Smrg						basic_machine=$field1
1750760f5d2Smrg						basic_os=$field2
1760760f5d2Smrg						;;
1770760f5d2Smrg					zephyr*)
1780760f5d2Smrg						basic_machine=$field1-unknown
1790760f5d2Smrg						basic_os=$field2
1800760f5d2Smrg						;;
1810760f5d2Smrg					# Manufacturers
1820760f5d2Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1830760f5d2Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1840760f5d2Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1850760f5d2Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1860760f5d2Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1870760f5d2Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1880760f5d2Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1890760f5d2Smrg					| microblaze* | sim | cisco \
1900760f5d2Smrg					| oki | wec | wrs | winbond)
1910760f5d2Smrg						basic_machine=$field1-$field2
1920760f5d2Smrg						basic_os=
1930760f5d2Smrg						;;
1940760f5d2Smrg					*)
1950760f5d2Smrg						basic_machine=$field1
1960760f5d2Smrg						basic_os=$field2
1970760f5d2Smrg						;;
1980760f5d2Smrg				esac
1990760f5d2Smrg			;;
2000760f5d2Smrg		esac
201caade7ccSmrg		;;
2020760f5d2Smrg	*)
2030760f5d2Smrg		# Convert single-component short-hands not valid as part of
2040760f5d2Smrg		# multi-component configurations.
2050760f5d2Smrg		case $field1 in
2060760f5d2Smrg			386bsd)
2070760f5d2Smrg				basic_machine=i386-pc
2080760f5d2Smrg				basic_os=bsd
2090760f5d2Smrg				;;
2100760f5d2Smrg			a29khif)
2110760f5d2Smrg				basic_machine=a29k-amd
2120760f5d2Smrg				basic_os=udi
2130760f5d2Smrg				;;
2140760f5d2Smrg			adobe68k)
2150760f5d2Smrg				basic_machine=m68010-adobe
2160760f5d2Smrg				basic_os=scout
2170760f5d2Smrg				;;
2180760f5d2Smrg			alliant)
2190760f5d2Smrg				basic_machine=fx80-alliant
2200760f5d2Smrg				basic_os=
2210760f5d2Smrg				;;
2220760f5d2Smrg			altos | altos3068)
2230760f5d2Smrg				basic_machine=m68k-altos
2240760f5d2Smrg				basic_os=
2250760f5d2Smrg				;;
2260760f5d2Smrg			am29k)
2270760f5d2Smrg				basic_machine=a29k-none
2280760f5d2Smrg				basic_os=bsd
2290760f5d2Smrg				;;
2300760f5d2Smrg			amdahl)
2310760f5d2Smrg				basic_machine=580-amdahl
2320760f5d2Smrg				basic_os=sysv
2330760f5d2Smrg				;;
2340760f5d2Smrg			amiga)
2350760f5d2Smrg				basic_machine=m68k-unknown
2360760f5d2Smrg				basic_os=
2370760f5d2Smrg				;;
2380760f5d2Smrg			amigaos | amigados)
2390760f5d2Smrg				basic_machine=m68k-unknown
2400760f5d2Smrg				basic_os=amigaos
2410760f5d2Smrg				;;
2420760f5d2Smrg			amigaunix | amix)
2430760f5d2Smrg				basic_machine=m68k-unknown
2440760f5d2Smrg				basic_os=sysv4
2450760f5d2Smrg				;;
2460760f5d2Smrg			apollo68)
2470760f5d2Smrg				basic_machine=m68k-apollo
2480760f5d2Smrg				basic_os=sysv
2490760f5d2Smrg				;;
2500760f5d2Smrg			apollo68bsd)
2510760f5d2Smrg				basic_machine=m68k-apollo
2520760f5d2Smrg				basic_os=bsd
2530760f5d2Smrg				;;
2540760f5d2Smrg			aros)
2550760f5d2Smrg				basic_machine=i386-pc
2560760f5d2Smrg				basic_os=aros
2570760f5d2Smrg				;;
2580760f5d2Smrg			aux)
2590760f5d2Smrg				basic_machine=m68k-apple
2600760f5d2Smrg				basic_os=aux
2610760f5d2Smrg				;;
2620760f5d2Smrg			balance)
2630760f5d2Smrg				basic_machine=ns32k-sequent
2640760f5d2Smrg				basic_os=dynix
2650760f5d2Smrg				;;
2660760f5d2Smrg			blackfin)
2670760f5d2Smrg				basic_machine=bfin-unknown
2680760f5d2Smrg				basic_os=linux
2690760f5d2Smrg				;;
2700760f5d2Smrg			cegcc)
2710760f5d2Smrg				basic_machine=arm-unknown
2720760f5d2Smrg				basic_os=cegcc
2730760f5d2Smrg				;;
2740760f5d2Smrg			convex-c1)
2750760f5d2Smrg				basic_machine=c1-convex
2760760f5d2Smrg				basic_os=bsd
2770760f5d2Smrg				;;
2780760f5d2Smrg			convex-c2)
2790760f5d2Smrg				basic_machine=c2-convex
2800760f5d2Smrg				basic_os=bsd
2810760f5d2Smrg				;;
2820760f5d2Smrg			convex-c32)
2830760f5d2Smrg				basic_machine=c32-convex
2840760f5d2Smrg				basic_os=bsd
2850760f5d2Smrg				;;
2860760f5d2Smrg			convex-c34)
2870760f5d2Smrg				basic_machine=c34-convex
2880760f5d2Smrg				basic_os=bsd
2890760f5d2Smrg				;;
2900760f5d2Smrg			convex-c38)
2910760f5d2Smrg				basic_machine=c38-convex
2920760f5d2Smrg				basic_os=bsd
2930760f5d2Smrg				;;
2940760f5d2Smrg			cray)
2950760f5d2Smrg				basic_machine=j90-cray
2960760f5d2Smrg				basic_os=unicos
2970760f5d2Smrg				;;
2980760f5d2Smrg			crds | unos)
2990760f5d2Smrg				basic_machine=m68k-crds
3000760f5d2Smrg				basic_os=
3010760f5d2Smrg				;;
3020760f5d2Smrg			da30)
3030760f5d2Smrg				basic_machine=m68k-da30
3040760f5d2Smrg				basic_os=
3050760f5d2Smrg				;;
3060760f5d2Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3070760f5d2Smrg				basic_machine=mips-dec
3080760f5d2Smrg				basic_os=
3090760f5d2Smrg				;;
3100760f5d2Smrg			delta88)
3110760f5d2Smrg				basic_machine=m88k-motorola
3120760f5d2Smrg				basic_os=sysv3
3130760f5d2Smrg				;;
3140760f5d2Smrg			dicos)
3150760f5d2Smrg				basic_machine=i686-pc
3160760f5d2Smrg				basic_os=dicos
3170760f5d2Smrg				;;
3180760f5d2Smrg			djgpp)
3190760f5d2Smrg				basic_machine=i586-pc
3200760f5d2Smrg				basic_os=msdosdjgpp
3210760f5d2Smrg				;;
3220760f5d2Smrg			ebmon29k)
3230760f5d2Smrg				basic_machine=a29k-amd
3240760f5d2Smrg				basic_os=ebmon
3250760f5d2Smrg				;;
3260760f5d2Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3270760f5d2Smrg				basic_machine=m68k-ericsson
3280760f5d2Smrg				basic_os=ose
3290760f5d2Smrg				;;
3300760f5d2Smrg			gmicro)
3310760f5d2Smrg				basic_machine=tron-gmicro
3320760f5d2Smrg				basic_os=sysv
3330760f5d2Smrg				;;
3340760f5d2Smrg			go32)
3350760f5d2Smrg				basic_machine=i386-pc
3360760f5d2Smrg				basic_os=go32
3370760f5d2Smrg				;;
3380760f5d2Smrg			h8300hms)
3390760f5d2Smrg				basic_machine=h8300-hitachi
3400760f5d2Smrg				basic_os=hms
3410760f5d2Smrg				;;
3420760f5d2Smrg			h8300xray)
3430760f5d2Smrg				basic_machine=h8300-hitachi
3440760f5d2Smrg				basic_os=xray
3450760f5d2Smrg				;;
3460760f5d2Smrg			h8500hms)
3470760f5d2Smrg				basic_machine=h8500-hitachi
3480760f5d2Smrg				basic_os=hms
3490760f5d2Smrg				;;
3500760f5d2Smrg			harris)
3510760f5d2Smrg				basic_machine=m88k-harris
3520760f5d2Smrg				basic_os=sysv3
3530760f5d2Smrg				;;
3540760f5d2Smrg			hp300 | hp300hpux)
3550760f5d2Smrg				basic_machine=m68k-hp
3560760f5d2Smrg				basic_os=hpux
3570760f5d2Smrg				;;
3580760f5d2Smrg			hp300bsd)
3590760f5d2Smrg				basic_machine=m68k-hp
3600760f5d2Smrg				basic_os=bsd
3610760f5d2Smrg				;;
3620760f5d2Smrg			hppaosf)
3630760f5d2Smrg				basic_machine=hppa1.1-hp
3640760f5d2Smrg				basic_os=osf
3650760f5d2Smrg				;;
3660760f5d2Smrg			hppro)
3670760f5d2Smrg				basic_machine=hppa1.1-hp
3680760f5d2Smrg				basic_os=proelf
3690760f5d2Smrg				;;
3700760f5d2Smrg			i386mach)
3710760f5d2Smrg				basic_machine=i386-mach
3720760f5d2Smrg				basic_os=mach
3730760f5d2Smrg				;;
3740760f5d2Smrg			isi68 | isi)
3750760f5d2Smrg				basic_machine=m68k-isi
3760760f5d2Smrg				basic_os=sysv
3770760f5d2Smrg				;;
3780760f5d2Smrg			m68knommu)
3790760f5d2Smrg				basic_machine=m68k-unknown
3800760f5d2Smrg				basic_os=linux
3810760f5d2Smrg				;;
3820760f5d2Smrg			magnum | m3230)
3830760f5d2Smrg				basic_machine=mips-mips
3840760f5d2Smrg				basic_os=sysv
3850760f5d2Smrg				;;
3860760f5d2Smrg			merlin)
3870760f5d2Smrg				basic_machine=ns32k-utek
3880760f5d2Smrg				basic_os=sysv
3890760f5d2Smrg				;;
3900760f5d2Smrg			mingw64)
3910760f5d2Smrg				basic_machine=x86_64-pc
3920760f5d2Smrg				basic_os=mingw64
3930760f5d2Smrg				;;
3940760f5d2Smrg			mingw32)
3950760f5d2Smrg				basic_machine=i686-pc
3960760f5d2Smrg				basic_os=mingw32
3970760f5d2Smrg				;;
3980760f5d2Smrg			mingw32ce)
3990760f5d2Smrg				basic_machine=arm-unknown
4000760f5d2Smrg				basic_os=mingw32ce
4010760f5d2Smrg				;;
4020760f5d2Smrg			monitor)
4030760f5d2Smrg				basic_machine=m68k-rom68k
4040760f5d2Smrg				basic_os=coff
4050760f5d2Smrg				;;
4060760f5d2Smrg			morphos)
4070760f5d2Smrg				basic_machine=powerpc-unknown
4080760f5d2Smrg				basic_os=morphos
4090760f5d2Smrg				;;
4100760f5d2Smrg			moxiebox)
4110760f5d2Smrg				basic_machine=moxie-unknown
4120760f5d2Smrg				basic_os=moxiebox
4130760f5d2Smrg				;;
4140760f5d2Smrg			msdos)
4150760f5d2Smrg				basic_machine=i386-pc
4160760f5d2Smrg				basic_os=msdos
4170760f5d2Smrg				;;
4180760f5d2Smrg			msys)
4190760f5d2Smrg				basic_machine=i686-pc
4200760f5d2Smrg				basic_os=msys
4210760f5d2Smrg				;;
4220760f5d2Smrg			mvs)
4230760f5d2Smrg				basic_machine=i370-ibm
4240760f5d2Smrg				basic_os=mvs
4250760f5d2Smrg				;;
4260760f5d2Smrg			nacl)
4270760f5d2Smrg				basic_machine=le32-unknown
4280760f5d2Smrg				basic_os=nacl
4290760f5d2Smrg				;;
4300760f5d2Smrg			ncr3000)
4310760f5d2Smrg				basic_machine=i486-ncr
4320760f5d2Smrg				basic_os=sysv4
4330760f5d2Smrg				;;
4340760f5d2Smrg			netbsd386)
4350760f5d2Smrg				basic_machine=i386-pc
4360760f5d2Smrg				basic_os=netbsd
4370760f5d2Smrg				;;
4380760f5d2Smrg			netwinder)
4390760f5d2Smrg				basic_machine=armv4l-rebel
4400760f5d2Smrg				basic_os=linux
4410760f5d2Smrg				;;
4420760f5d2Smrg			news | news700 | news800 | news900)
4430760f5d2Smrg				basic_machine=m68k-sony
4440760f5d2Smrg				basic_os=newsos
4450760f5d2Smrg				;;
4460760f5d2Smrg			news1000)
4470760f5d2Smrg				basic_machine=m68030-sony
4480760f5d2Smrg				basic_os=newsos
4490760f5d2Smrg				;;
4500760f5d2Smrg			necv70)
4510760f5d2Smrg				basic_machine=v70-nec
4520760f5d2Smrg				basic_os=sysv
4530760f5d2Smrg				;;
4540760f5d2Smrg			nh3000)
4550760f5d2Smrg				basic_machine=m68k-harris
4560760f5d2Smrg				basic_os=cxux
4570760f5d2Smrg				;;
4580760f5d2Smrg			nh[45]000)
4590760f5d2Smrg				basic_machine=m88k-harris
4600760f5d2Smrg				basic_os=cxux
4610760f5d2Smrg				;;
4620760f5d2Smrg			nindy960)
4630760f5d2Smrg				basic_machine=i960-intel
4640760f5d2Smrg				basic_os=nindy
4650760f5d2Smrg				;;
4660760f5d2Smrg			mon960)
4670760f5d2Smrg				basic_machine=i960-intel
4680760f5d2Smrg				basic_os=mon960
4690760f5d2Smrg				;;
4700760f5d2Smrg			nonstopux)
4710760f5d2Smrg				basic_machine=mips-compaq
4720760f5d2Smrg				basic_os=nonstopux
4730760f5d2Smrg				;;
4740760f5d2Smrg			os400)
4750760f5d2Smrg				basic_machine=powerpc-ibm
4760760f5d2Smrg				basic_os=os400
4770760f5d2Smrg				;;
4780760f5d2Smrg			OSE68000 | ose68000)
4790760f5d2Smrg				basic_machine=m68000-ericsson
4800760f5d2Smrg				basic_os=ose
4810760f5d2Smrg				;;
4820760f5d2Smrg			os68k)
4830760f5d2Smrg				basic_machine=m68k-none
4840760f5d2Smrg				basic_os=os68k
4850760f5d2Smrg				;;
4860760f5d2Smrg			paragon)
4870760f5d2Smrg				basic_machine=i860-intel
4880760f5d2Smrg				basic_os=osf
4890760f5d2Smrg				;;
4900760f5d2Smrg			parisc)
4910760f5d2Smrg				basic_machine=hppa-unknown
4920760f5d2Smrg				basic_os=linux
4930760f5d2Smrg				;;
4940760f5d2Smrg			psp)
4950760f5d2Smrg				basic_machine=mipsallegrexel-sony
4960760f5d2Smrg				basic_os=psp
4970760f5d2Smrg				;;
4980760f5d2Smrg			pw32)
4990760f5d2Smrg				basic_machine=i586-unknown
5000760f5d2Smrg				basic_os=pw32
5010760f5d2Smrg				;;
5020760f5d2Smrg			rdos | rdos64)
5030760f5d2Smrg				basic_machine=x86_64-pc
5040760f5d2Smrg				basic_os=rdos
5050760f5d2Smrg				;;
5060760f5d2Smrg			rdos32)
5070760f5d2Smrg				basic_machine=i386-pc
5080760f5d2Smrg				basic_os=rdos
5090760f5d2Smrg				;;
5100760f5d2Smrg			rom68k)
5110760f5d2Smrg				basic_machine=m68k-rom68k
5120760f5d2Smrg				basic_os=coff
5130760f5d2Smrg				;;
5140760f5d2Smrg			sa29200)
5150760f5d2Smrg				basic_machine=a29k-amd
5160760f5d2Smrg				basic_os=udi
5170760f5d2Smrg				;;
5180760f5d2Smrg			sei)
5190760f5d2Smrg				basic_machine=mips-sei
5200760f5d2Smrg				basic_os=seiux
5210760f5d2Smrg				;;
5220760f5d2Smrg			sequent)
5230760f5d2Smrg				basic_machine=i386-sequent
5240760f5d2Smrg				basic_os=
5250760f5d2Smrg				;;
5260760f5d2Smrg			sps7)
5270760f5d2Smrg				basic_machine=m68k-bull
5280760f5d2Smrg				basic_os=sysv2
5290760f5d2Smrg				;;
5300760f5d2Smrg			st2000)
5310760f5d2Smrg				basic_machine=m68k-tandem
5320760f5d2Smrg				basic_os=
5330760f5d2Smrg				;;
5340760f5d2Smrg			stratus)
5350760f5d2Smrg				basic_machine=i860-stratus
5360760f5d2Smrg				basic_os=sysv4
5370760f5d2Smrg				;;
5380760f5d2Smrg			sun2)
5390760f5d2Smrg				basic_machine=m68000-sun
5400760f5d2Smrg				basic_os=
5410760f5d2Smrg				;;
5420760f5d2Smrg			sun2os3)
5430760f5d2Smrg				basic_machine=m68000-sun
5440760f5d2Smrg				basic_os=sunos3
5450760f5d2Smrg				;;
5460760f5d2Smrg			sun2os4)
5470760f5d2Smrg				basic_machine=m68000-sun
5480760f5d2Smrg				basic_os=sunos4
5490760f5d2Smrg				;;
5500760f5d2Smrg			sun3)
5510760f5d2Smrg				basic_machine=m68k-sun
5520760f5d2Smrg				basic_os=
5530760f5d2Smrg				;;
5540760f5d2Smrg			sun3os3)
5550760f5d2Smrg				basic_machine=m68k-sun
5560760f5d2Smrg				basic_os=sunos3
5570760f5d2Smrg				;;
5580760f5d2Smrg			sun3os4)
5590760f5d2Smrg				basic_machine=m68k-sun
5600760f5d2Smrg				basic_os=sunos4
5610760f5d2Smrg				;;
5620760f5d2Smrg			sun4)
5630760f5d2Smrg				basic_machine=sparc-sun
5640760f5d2Smrg				basic_os=
5650760f5d2Smrg				;;
5660760f5d2Smrg			sun4os3)
5670760f5d2Smrg				basic_machine=sparc-sun
5680760f5d2Smrg				basic_os=sunos3
5690760f5d2Smrg				;;
5700760f5d2Smrg			sun4os4)
5710760f5d2Smrg				basic_machine=sparc-sun
5720760f5d2Smrg				basic_os=sunos4
5730760f5d2Smrg				;;
5740760f5d2Smrg			sun4sol2)
5750760f5d2Smrg				basic_machine=sparc-sun
5760760f5d2Smrg				basic_os=solaris2
5770760f5d2Smrg				;;
5780760f5d2Smrg			sun386 | sun386i | roadrunner)
5790760f5d2Smrg				basic_machine=i386-sun
5800760f5d2Smrg				basic_os=
5810760f5d2Smrg				;;
5820760f5d2Smrg			sv1)
5830760f5d2Smrg				basic_machine=sv1-cray
5840760f5d2Smrg				basic_os=unicos
5850760f5d2Smrg				;;
5860760f5d2Smrg			symmetry)
5870760f5d2Smrg				basic_machine=i386-sequent
5880760f5d2Smrg				basic_os=dynix
5890760f5d2Smrg				;;
5900760f5d2Smrg			t3e)
5910760f5d2Smrg				basic_machine=alphaev5-cray
5920760f5d2Smrg				basic_os=unicos
5930760f5d2Smrg				;;
5940760f5d2Smrg			t90)
5950760f5d2Smrg				basic_machine=t90-cray
5960760f5d2Smrg				basic_os=unicos
5970760f5d2Smrg				;;
5980760f5d2Smrg			toad1)
5990760f5d2Smrg				basic_machine=pdp10-xkl
6000760f5d2Smrg				basic_os=tops20
6010760f5d2Smrg				;;
6020760f5d2Smrg			tpf)
6030760f5d2Smrg				basic_machine=s390x-ibm
6040760f5d2Smrg				basic_os=tpf
6050760f5d2Smrg				;;
6060760f5d2Smrg			udi29k)
6070760f5d2Smrg				basic_machine=a29k-amd
6080760f5d2Smrg				basic_os=udi
6090760f5d2Smrg				;;
6100760f5d2Smrg			ultra3)
6110760f5d2Smrg				basic_machine=a29k-nyu
6120760f5d2Smrg				basic_os=sym1
6130760f5d2Smrg				;;
6140760f5d2Smrg			v810 | necv810)
6150760f5d2Smrg				basic_machine=v810-nec
6160760f5d2Smrg				basic_os=none
6170760f5d2Smrg				;;
6180760f5d2Smrg			vaxv)
6190760f5d2Smrg				basic_machine=vax-dec
6200760f5d2Smrg				basic_os=sysv
6210760f5d2Smrg				;;
6220760f5d2Smrg			vms)
6230760f5d2Smrg				basic_machine=vax-dec
6240760f5d2Smrg				basic_os=vms
6250760f5d2Smrg				;;
6260760f5d2Smrg			vsta)
6270760f5d2Smrg				basic_machine=i386-pc
6280760f5d2Smrg				basic_os=vsta
6290760f5d2Smrg				;;
6300760f5d2Smrg			vxworks960)
6310760f5d2Smrg				basic_machine=i960-wrs
6320760f5d2Smrg				basic_os=vxworks
6330760f5d2Smrg				;;
6340760f5d2Smrg			vxworks68)
6350760f5d2Smrg				basic_machine=m68k-wrs
6360760f5d2Smrg				basic_os=vxworks
6370760f5d2Smrg				;;
6380760f5d2Smrg			vxworks29k)
6390760f5d2Smrg				basic_machine=a29k-wrs
6400760f5d2Smrg				basic_os=vxworks
6410760f5d2Smrg				;;
6420760f5d2Smrg			xbox)
6430760f5d2Smrg				basic_machine=i686-pc
6440760f5d2Smrg				basic_os=mingw32
6450760f5d2Smrg				;;
6460760f5d2Smrg			ymp)
6470760f5d2Smrg				basic_machine=ymp-cray
6480760f5d2Smrg				basic_os=unicos
6490760f5d2Smrg				;;
6500760f5d2Smrg			*)
6510760f5d2Smrg				basic_machine=$1
6520760f5d2Smrg				basic_os=
6530760f5d2Smrg				;;
6540760f5d2Smrg		esac
655caade7ccSmrg		;;
656caade7ccSmrgesac
657caade7ccSmrg
6580760f5d2Smrg# Decode 1-component or ad-hoc basic machines
659caade7ccSmrgcase $basic_machine in
6600760f5d2Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6610760f5d2Smrg	# some cases the only manufacturer, in others, it is the most popular.
6620760f5d2Smrg	w89k)
6630760f5d2Smrg		cpu=hppa1.1
6640760f5d2Smrg		vendor=winbond
665cc4920e5Smrg		;;
6660760f5d2Smrg	op50n)
6670760f5d2Smrg		cpu=hppa1.1
6680760f5d2Smrg		vendor=oki
669caade7ccSmrg		;;
6700760f5d2Smrg	op60c)
6710760f5d2Smrg		cpu=hppa1.1
6720760f5d2Smrg		vendor=oki
673caade7ccSmrg		;;
6740760f5d2Smrg	ibm*)
6750760f5d2Smrg		cpu=i370
6760760f5d2Smrg		vendor=ibm
677caade7ccSmrg		;;
6780760f5d2Smrg	orion105)
6790760f5d2Smrg		cpu=clipper
6800760f5d2Smrg		vendor=highlevel
681af9a7ee5Smrg		;;
6820760f5d2Smrg	mac | mpw | mac-mpw)
6830760f5d2Smrg		cpu=m68k
6840760f5d2Smrg		vendor=apple
685af9a7ee5Smrg		;;
6860760f5d2Smrg	pmac | pmac-mpw)
6870760f5d2Smrg		cpu=powerpc
6880760f5d2Smrg		vendor=apple
689af9a7ee5Smrg		;;
690af9a7ee5Smrg
691caade7ccSmrg	# Recognize the various machine names and aliases which stand
692caade7ccSmrg	# for a CPU type and a company and sometimes even an OS.
693caade7ccSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6940760f5d2Smrg		cpu=m68000
6950760f5d2Smrg		vendor=att
696caade7ccSmrg		;;
697caade7ccSmrg	3b*)
6980760f5d2Smrg		cpu=we32k
6990760f5d2Smrg		vendor=att
700485f0483Smrg		;;
701b9b4fd27Smrg	bluegene*)
7020760f5d2Smrg		cpu=powerpc
7030760f5d2Smrg		vendor=ibm
7040760f5d2Smrg		basic_os=cnk
705caade7ccSmrg		;;
706caade7ccSmrg	decsystem10* | dec10*)
7070760f5d2Smrg		cpu=pdp10
7080760f5d2Smrg		vendor=dec
7090760f5d2Smrg		basic_os=tops10
710caade7ccSmrg		;;
711caade7ccSmrg	decsystem20* | dec20*)
7120760f5d2Smrg		cpu=pdp10
7130760f5d2Smrg		vendor=dec
7140760f5d2Smrg		basic_os=tops20
715caade7ccSmrg		;;
716caade7ccSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717caade7ccSmrg	      | 3300-motorola | delta-motorola)
7180760f5d2Smrg		cpu=m68k
7190760f5d2Smrg		vendor=motorola
720caade7ccSmrg		;;
721cc4920e5Smrg	dpx2*)
7220760f5d2Smrg		cpu=m68k
7230760f5d2Smrg		vendor=bull
7240760f5d2Smrg		basic_os=sysv3
725caade7ccSmrg		;;
726caade7ccSmrg	encore | umax | mmax)
7270760f5d2Smrg		cpu=ns32k
7280760f5d2Smrg		vendor=encore
729caade7ccSmrg		;;
7300760f5d2Smrg	elxsi)
7310760f5d2Smrg		cpu=elxsi
7320760f5d2Smrg		vendor=elxsi
7330760f5d2Smrg		basic_os=${basic_os:-bsd}
734caade7ccSmrg		;;
735caade7ccSmrg	fx2800)
7360760f5d2Smrg		cpu=i860
7370760f5d2Smrg		vendor=alliant
738caade7ccSmrg		;;
739caade7ccSmrg	genix)
7400760f5d2Smrg		cpu=ns32k
7410760f5d2Smrg		vendor=ns
742caade7ccSmrg		;;
743caade7ccSmrg	h3050r* | hiux*)
7440760f5d2Smrg		cpu=hppa1.1
7450760f5d2Smrg		vendor=hitachi
7460760f5d2Smrg		basic_os=hiuxwe2
747caade7ccSmrg		;;
748caade7ccSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7490760f5d2Smrg		cpu=hppa1.0
7500760f5d2Smrg		vendor=hp
751caade7ccSmrg		;;
752caade7ccSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7530760f5d2Smrg		cpu=m68000
7540760f5d2Smrg		vendor=hp
755caade7ccSmrg		;;
756caade7ccSmrg	hp9k3[2-9][0-9])
7570760f5d2Smrg		cpu=m68k
7580760f5d2Smrg		vendor=hp
759caade7ccSmrg		;;
760caade7ccSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7610760f5d2Smrg		cpu=hppa1.0
7620760f5d2Smrg		vendor=hp
763caade7ccSmrg		;;
764caade7ccSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7650760f5d2Smrg		cpu=hppa1.1
7660760f5d2Smrg		vendor=hp
767caade7ccSmrg		;;
768caade7ccSmrg	hp9k78[0-9] | hp78[0-9])
769caade7ccSmrg		# FIXME: really hppa2.0-hp
7700760f5d2Smrg		cpu=hppa1.1
7710760f5d2Smrg		vendor=hp
772caade7ccSmrg		;;
773caade7ccSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774caade7ccSmrg		# FIXME: really hppa2.0-hp
7750760f5d2Smrg		cpu=hppa1.1
7760760f5d2Smrg		vendor=hp
777caade7ccSmrg		;;
778caade7ccSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7790760f5d2Smrg		cpu=hppa1.1
7800760f5d2Smrg		vendor=hp
781caade7ccSmrg		;;
782caade7ccSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7830760f5d2Smrg		cpu=hppa1.0
7840760f5d2Smrg		vendor=hp
785caade7ccSmrg		;;
786caade7ccSmrg	i*86v32)
7870760f5d2Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7880760f5d2Smrg		vendor=pc
7890760f5d2Smrg		basic_os=sysv32
790caade7ccSmrg		;;
791caade7ccSmrg	i*86v4*)
7920760f5d2Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7930760f5d2Smrg		vendor=pc
7940760f5d2Smrg		basic_os=sysv4
795caade7ccSmrg		;;
796caade7ccSmrg	i*86v)
7970760f5d2Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7980760f5d2Smrg		vendor=pc
7990760f5d2Smrg		basic_os=sysv
800caade7ccSmrg		;;
801caade7ccSmrg	i*86sol2)
8020760f5d2Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8030760f5d2Smrg		vendor=pc
8040760f5d2Smrg		basic_os=solaris2
805caade7ccSmrg		;;
8060760f5d2Smrg	j90 | j90-cray)
8070760f5d2Smrg		cpu=j90
8080760f5d2Smrg		vendor=cray
8090760f5d2Smrg		basic_os=${basic_os:-unicos}
810caade7ccSmrg		;;
811caade7ccSmrg	iris | iris4d)
8120760f5d2Smrg		cpu=mips
8130760f5d2Smrg		vendor=sgi
8140760f5d2Smrg		case $basic_os in
8150760f5d2Smrg		    irix*)
816caade7ccSmrg			;;
817caade7ccSmrg		    *)
8180760f5d2Smrg			basic_os=irix4
819caade7ccSmrg			;;
820caade7ccSmrg		esac
821caade7ccSmrg		;;
822caade7ccSmrg	miniframe)
8230760f5d2Smrg		cpu=m68000
8240760f5d2Smrg		vendor=convergent
825caade7ccSmrg		;;
8260760f5d2Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8270760f5d2Smrg		cpu=m68k
8280760f5d2Smrg		vendor=atari
8290760f5d2Smrg		basic_os=mint
830caade7ccSmrg		;;
831caade7ccSmrg	news-3600 | risc-news)
8320760f5d2Smrg		cpu=mips
8330760f5d2Smrg		vendor=sony
8340760f5d2Smrg		basic_os=newsos
835caade7ccSmrg		;;
836cc4920e5Smrg	next | m*-next)
8370760f5d2Smrg		cpu=m68k
8380760f5d2Smrg		vendor=next
8390760f5d2Smrg		case $basic_os in
8400760f5d2Smrg		    openstep*)
8410760f5d2Smrg		        ;;
8420760f5d2Smrg		    nextstep*)
843caade7ccSmrg			;;
8440760f5d2Smrg		    ns2*)
8450760f5d2Smrg		      basic_os=nextstep2
846caade7ccSmrg			;;
847caade7ccSmrg		    *)
8480760f5d2Smrg		      basic_os=nextstep3
849caade7ccSmrg			;;
850caade7ccSmrg		esac
851caade7ccSmrg		;;
852caade7ccSmrg	np1)
8530760f5d2Smrg		cpu=np1
8540760f5d2Smrg		vendor=gould
855cc4920e5Smrg		;;
856caade7ccSmrg	op50n-* | op60c-*)
8570760f5d2Smrg		cpu=hppa1.1
8580760f5d2Smrg		vendor=oki
8590760f5d2Smrg		basic_os=proelf
860caade7ccSmrg		;;
861caade7ccSmrg	pa-hitachi)
8620760f5d2Smrg		cpu=hppa1.1
8630760f5d2Smrg		vendor=hitachi
8640760f5d2Smrg		basic_os=hiuxwe2
865485f0483Smrg		;;
866caade7ccSmrg	pbd)
8670760f5d2Smrg		cpu=sparc
8680760f5d2Smrg		vendor=tti
869caade7ccSmrg		;;
870caade7ccSmrg	pbb)
8710760f5d2Smrg		cpu=m68k
8720760f5d2Smrg		vendor=tti
873caade7ccSmrg		;;
8740760f5d2Smrg	pc532)
8750760f5d2Smrg		cpu=ns32k
8760760f5d2Smrg		vendor=pc532
877caade7ccSmrg		;;
878caade7ccSmrg	pn)
8790760f5d2Smrg		cpu=pn
8800760f5d2Smrg		vendor=gould
881caade7ccSmrg		;;
8820760f5d2Smrg	power)
8830760f5d2Smrg		cpu=power
8840760f5d2Smrg		vendor=ibm
885caade7ccSmrg		;;
8860760f5d2Smrg	ps2)
8870760f5d2Smrg		cpu=i386
8880760f5d2Smrg		vendor=ibm
889caade7ccSmrg		;;
8900760f5d2Smrg	rm[46]00)
8910760f5d2Smrg		cpu=mips
8920760f5d2Smrg		vendor=siemens
893caade7ccSmrg		;;
8940760f5d2Smrg	rtpc | rtpc-*)
8950760f5d2Smrg		cpu=romp
8960760f5d2Smrg		vendor=ibm
897caade7ccSmrg		;;
8980760f5d2Smrg	sde)
8990760f5d2Smrg		cpu=mipsisa32
9000760f5d2Smrg		vendor=sde
9010760f5d2Smrg		basic_os=${basic_os:-elf}
902caade7ccSmrg		;;
9030760f5d2Smrg	simso-wrs)
9040760f5d2Smrg		cpu=sparclite
9050760f5d2Smrg		vendor=wrs
9060760f5d2Smrg		basic_os=vxworks
907caade7ccSmrg		;;
9080760f5d2Smrg	tower | tower-32)
9090760f5d2Smrg		cpu=m68k
9100760f5d2Smrg		vendor=ncr
911caade7ccSmrg		;;
9120760f5d2Smrg	vpp*|vx|vx-*)
9130760f5d2Smrg		cpu=f301
9140760f5d2Smrg		vendor=fujitsu
915af9a7ee5Smrg		;;
9160760f5d2Smrg	w65)
9170760f5d2Smrg		cpu=w65
9180760f5d2Smrg		vendor=wdc
919caade7ccSmrg		;;
9200760f5d2Smrg	w89k-*)
9210760f5d2Smrg		cpu=hppa1.1
9220760f5d2Smrg		vendor=winbond
9230760f5d2Smrg		basic_os=proelf
924caade7ccSmrg		;;
9250760f5d2Smrg	none)
9260760f5d2Smrg		cpu=none
9270760f5d2Smrg		vendor=none
928caade7ccSmrg		;;
9290760f5d2Smrg	leon|leon[3-9])
9300760f5d2Smrg		cpu=sparc
9310760f5d2Smrg		vendor=$basic_machine
932caade7ccSmrg		;;
9330760f5d2Smrg	leon-*|leon[3-9]-*)
9340760f5d2Smrg		cpu=sparc
9350760f5d2Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936caade7ccSmrg		;;
9370760f5d2Smrg
9380760f5d2Smrg	*-*)
9390760f5d2Smrg		# shellcheck disable=SC2162
9400760f5d2Smrg		saved_IFS=$IFS
9410760f5d2Smrg		IFS="-" read cpu vendor <<EOF
9420760f5d2Smrg$basic_machine
9430760f5d2SmrgEOF
9440760f5d2Smrg		IFS=$saved_IFS
945caade7ccSmrg		;;
9460760f5d2Smrg	# We use `pc' rather than `unknown'
9470760f5d2Smrg	# because (1) that's what they normally are, and
9480760f5d2Smrg	# (2) the word "unknown" tends to confuse beginning users.
9490760f5d2Smrg	i*86 | x86_64)
9500760f5d2Smrg		cpu=$basic_machine
9510760f5d2Smrg		vendor=pc
952caade7ccSmrg		;;
9530760f5d2Smrg	# These rules are duplicated from below for sake of the special case above;
9540760f5d2Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9550760f5d2Smrg	pc98)
9560760f5d2Smrg		cpu=i386
9570760f5d2Smrg		vendor=pc
958caade7ccSmrg		;;
9590760f5d2Smrg	x64 | amd64)
9600760f5d2Smrg		cpu=x86_64
9610760f5d2Smrg		vendor=pc
962caade7ccSmrg		;;
9630760f5d2Smrg	# Recognize the basic CPU types without company name.
9640760f5d2Smrg	*)
9650760f5d2Smrg		cpu=$basic_machine
9660760f5d2Smrg		vendor=unknown
967485f0483Smrg		;;
9680760f5d2Smrgesac
9690760f5d2Smrg
9700760f5d2Smrgunset -v basic_machine
9710760f5d2Smrg
9720760f5d2Smrg# Decode basic machines in the full and proper CPU-Company form.
9730760f5d2Smrgcase $cpu-$vendor in
9740760f5d2Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9750760f5d2Smrg	# some cases the only manufacturer, in others, it is the most popular.
9760760f5d2Smrg	craynv-unknown)
9770760f5d2Smrg		vendor=cray
9780760f5d2Smrg		basic_os=${basic_os:-unicosmp}
979caade7ccSmrg		;;
9800760f5d2Smrg	c90-unknown | c90-cray)
9810760f5d2Smrg		vendor=cray
9820760f5d2Smrg		basic_os=${Basic_os:-unicos}
983caade7ccSmrg		;;
9840760f5d2Smrg	fx80-unknown)
9850760f5d2Smrg		vendor=alliant
986485f0483Smrg		;;
9870760f5d2Smrg	romp-unknown)
9880760f5d2Smrg		vendor=ibm
989caade7ccSmrg		;;
9900760f5d2Smrg	mmix-unknown)
9910760f5d2Smrg		vendor=knuth
992caade7ccSmrg		;;
9930760f5d2Smrg	microblaze-unknown | microblazeel-unknown)
9940760f5d2Smrg		vendor=xilinx
995caade7ccSmrg		;;
9960760f5d2Smrg	rs6000-unknown)
9970760f5d2Smrg		vendor=ibm
998caade7ccSmrg		;;
9990760f5d2Smrg	vax-unknown)
10000760f5d2Smrg		vendor=dec
1001caade7ccSmrg		;;
10020760f5d2Smrg	pdp11-unknown)
10030760f5d2Smrg		vendor=dec
1004af9a7ee5Smrg		;;
10050760f5d2Smrg	we32k-unknown)
10060760f5d2Smrg		vendor=att
1007caade7ccSmrg		;;
10080760f5d2Smrg	cydra-unknown)
10090760f5d2Smrg		vendor=cydrome
1010caade7ccSmrg		;;
10110760f5d2Smrg	i370-ibm*)
10120760f5d2Smrg		vendor=ibm
1013caade7ccSmrg		;;
10140760f5d2Smrg	orion-unknown)
10150760f5d2Smrg		vendor=highlevel
1016caade7ccSmrg		;;
10170760f5d2Smrg	xps-unknown | xps100-unknown)
10180760f5d2Smrg		cpu=xps100
10190760f5d2Smrg		vendor=honeywell
1020caade7ccSmrg		;;
10210760f5d2Smrg
10220760f5d2Smrg	# Here we normalize CPU types with a missing or matching vendor
102305789e77Smrg	armh-unknown | armh-alt)
102405789e77Smrg		cpu=armv7l
102505789e77Smrg		vendor=alt
102605789e77Smrg		basic_os=${basic_os:-linux-gnueabihf}
102705789e77Smrg		;;
10280760f5d2Smrg	dpx20-unknown | dpx20-bull)
10290760f5d2Smrg		cpu=rs6000
10300760f5d2Smrg		vendor=bull
10310760f5d2Smrg		basic_os=${basic_os:-bosx}
1032caade7ccSmrg		;;
10330760f5d2Smrg
10340760f5d2Smrg	# Here we normalize CPU types irrespective of the vendor
10350760f5d2Smrg	amd64-*)
10360760f5d2Smrg		cpu=x86_64
1037caade7ccSmrg		;;
10380760f5d2Smrg	blackfin-*)
10390760f5d2Smrg		cpu=bfin
10400760f5d2Smrg		basic_os=linux
1041caade7ccSmrg		;;
10420760f5d2Smrg	c54x-*)
10430760f5d2Smrg		cpu=tic54x
1044caade7ccSmrg		;;
10450760f5d2Smrg	c55x-*)
10460760f5d2Smrg		cpu=tic55x
1047caade7ccSmrg		;;
10480760f5d2Smrg	c6x-*)
10490760f5d2Smrg		cpu=tic6x
1050caade7ccSmrg		;;
10510760f5d2Smrg	e500v[12]-*)
10520760f5d2Smrg		cpu=powerpc
10530760f5d2Smrg		basic_os=${basic_os}"spe"
1054caade7ccSmrg		;;
10550760f5d2Smrg	mips3*-*)
10560760f5d2Smrg		cpu=mips64
1057caade7ccSmrg		;;
10580760f5d2Smrg	ms1-*)
10590760f5d2Smrg		cpu=mt
1060caade7ccSmrg		;;
10610760f5d2Smrg	m68knommu-*)
10620760f5d2Smrg		cpu=m68k
10630760f5d2Smrg		basic_os=linux
1064caade7ccSmrg		;;
10650760f5d2Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10660760f5d2Smrg		cpu=s12z
1067485f0483Smrg		;;
10680760f5d2Smrg	openrisc-*)
10690760f5d2Smrg		cpu=or32
1070caade7ccSmrg		;;
10710760f5d2Smrg	parisc-*)
10720760f5d2Smrg		cpu=hppa
10730760f5d2Smrg		basic_os=linux
1074caade7ccSmrg		;;
10750760f5d2Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10760760f5d2Smrg		cpu=i586
1077caade7ccSmrg		;;
107805789e77Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10790760f5d2Smrg		cpu=i686
1080caade7ccSmrg		;;
10810760f5d2Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10820760f5d2Smrg		cpu=i686
1083caade7ccSmrg		;;
10840760f5d2Smrg	pentium4-*)
10850760f5d2Smrg		cpu=i786
1086caade7ccSmrg		;;
10870760f5d2Smrg	pc98-*)
10880760f5d2Smrg		cpu=i386
1089caade7ccSmrg		;;
10900760f5d2Smrg	ppc-* | ppcbe-*)
10910760f5d2Smrg		cpu=powerpc
1092caade7ccSmrg		;;
10930760f5d2Smrg	ppcle-* | powerpclittle-*)
10940760f5d2Smrg		cpu=powerpcle
1095caade7ccSmrg		;;
10960760f5d2Smrg	ppc64-*)
10970760f5d2Smrg		cpu=powerpc64
1098caade7ccSmrg		;;
10990760f5d2Smrg	ppc64le-* | powerpc64little-*)
11000760f5d2Smrg		cpu=powerpc64le
1101caade7ccSmrg		;;
11020760f5d2Smrg	sb1-*)
11030760f5d2Smrg		cpu=mipsisa64sb1
1104caade7ccSmrg		;;
11050760f5d2Smrg	sb1el-*)
11060760f5d2Smrg		cpu=mipsisa64sb1el
1107caade7ccSmrg		;;
11080760f5d2Smrg	sh5e[lb]-*)
11090760f5d2Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110caade7ccSmrg		;;
11110760f5d2Smrg	spur-*)
11120760f5d2Smrg		cpu=spur
1113caade7ccSmrg		;;
11140760f5d2Smrg	strongarm-* | thumb-*)
11150760f5d2Smrg		cpu=arm
1116caade7ccSmrg		;;
11170760f5d2Smrg	tx39-*)
11180760f5d2Smrg		cpu=mipstx39
1119cc4920e5Smrg		;;
11200760f5d2Smrg	tx39el-*)
11210760f5d2Smrg		cpu=mipstx39el
1122caade7ccSmrg		;;
11230760f5d2Smrg	x64-*)
11240760f5d2Smrg		cpu=x86_64
1125caade7ccSmrg		;;
1126af9a7ee5Smrg	xscale-* | xscalee[bl]-*)
11270760f5d2Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128caade7ccSmrg		;;
112905789e77Smrg	arm64-* | aarch64le-*)
11300760f5d2Smrg		cpu=aarch64
1131caade7ccSmrg		;;
1132caade7ccSmrg
11330760f5d2Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11340760f5d2Smrg	# company names they are paired with.
11350760f5d2Smrg	cr16-*)
11360760f5d2Smrg		basic_os=${basic_os:-elf}
1137caade7ccSmrg		;;
11380760f5d2Smrg	crisv32-* | etraxfs*-*)
11390760f5d2Smrg		cpu=crisv32
11400760f5d2Smrg		vendor=axis
1141caade7ccSmrg		;;
11420760f5d2Smrg	cris-* | etrax*-*)
11430760f5d2Smrg		cpu=cris
11440760f5d2Smrg		vendor=axis
1145caade7ccSmrg		;;
11460760f5d2Smrg	crx-*)
11470760f5d2Smrg		basic_os=${basic_os:-elf}
1148caade7ccSmrg		;;
11490760f5d2Smrg	neo-tandem)
11500760f5d2Smrg		cpu=neo
11510760f5d2Smrg		vendor=tandem
1152caade7ccSmrg		;;
11530760f5d2Smrg	nse-tandem)
11540760f5d2Smrg		cpu=nse
11550760f5d2Smrg		vendor=tandem
1156caade7ccSmrg		;;
11570760f5d2Smrg	nsr-tandem)
11580760f5d2Smrg		cpu=nsr
11590760f5d2Smrg		vendor=tandem
1160caade7ccSmrg		;;
11610760f5d2Smrg	nsv-tandem)
11620760f5d2Smrg		cpu=nsv
11630760f5d2Smrg		vendor=tandem
1164caade7ccSmrg		;;
11650760f5d2Smrg	nsx-tandem)
11660760f5d2Smrg		cpu=nsx
11670760f5d2Smrg		vendor=tandem
1168caade7ccSmrg		;;
11690760f5d2Smrg	mipsallegrexel-sony)
11700760f5d2Smrg		cpu=mipsallegrexel
11710760f5d2Smrg		vendor=sony
1172caade7ccSmrg		;;
11730760f5d2Smrg	tile*-*)
11740760f5d2Smrg		basic_os=${basic_os:-linux-gnu}
1175caade7ccSmrg		;;
11760760f5d2Smrg
1177caade7ccSmrg	*)
11780760f5d2Smrg		# Recognize the canonical CPU types that are allowed with any
11790760f5d2Smrg		# company name.
11800760f5d2Smrg		case $cpu in
11810760f5d2Smrg			1750a | 580 \
11820760f5d2Smrg			| a29k \
11830760f5d2Smrg			| aarch64 | aarch64_be \
11840760f5d2Smrg			| abacus \
11850760f5d2Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11860760f5d2Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11870760f5d2Smrg			| alphapca5[67] | alpha64pca5[67] \
11880760f5d2Smrg			| am33_2.0 \
11890760f5d2Smrg			| amdgcn \
11900760f5d2Smrg			| arc | arceb | arc32 | arc64 \
11910760f5d2Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11920760f5d2Smrg			| avr | avr32 \
11930760f5d2Smrg			| asmjs \
11940760f5d2Smrg			| ba \
11950760f5d2Smrg			| be32 | be64 \
11960760f5d2Smrg			| bfin | bpf | bs2000 \
11970760f5d2Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11980760f5d2Smrg			| c8051 | clipper | craynv | csky | cydra \
11990760f5d2Smrg			| d10v | d30v | dlx | dsp16xx \
12000760f5d2Smrg			| e2k | elxsi | epiphany \
12010760f5d2Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12020760f5d2Smrg			| h8300 | h8500 \
12030760f5d2Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12040760f5d2Smrg			| hexagon \
12050760f5d2Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12060760f5d2Smrg			| ip2k | iq2000 \
12070760f5d2Smrg			| k1om \
12080760f5d2Smrg			| le32 | le64 \
12090760f5d2Smrg			| lm32 \
121005789e77Smrg			| loongarch32 | loongarch64 \
12110760f5d2Smrg			| m32c | m32r | m32rle \
12120760f5d2Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12130760f5d2Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12140760f5d2Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12150760f5d2Smrg			| microblaze | microblazeel \
12160760f5d2Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12170760f5d2Smrg			| mips16 \
12180760f5d2Smrg			| mips64 | mips64eb | mips64el \
12190760f5d2Smrg			| mips64octeon | mips64octeonel \
12200760f5d2Smrg			| mips64orion | mips64orionel \
12210760f5d2Smrg			| mips64r5900 | mips64r5900el \
12220760f5d2Smrg			| mips64vr | mips64vrel \
12230760f5d2Smrg			| mips64vr4100 | mips64vr4100el \
12240760f5d2Smrg			| mips64vr4300 | mips64vr4300el \
12250760f5d2Smrg			| mips64vr5000 | mips64vr5000el \
12260760f5d2Smrg			| mips64vr5900 | mips64vr5900el \
12270760f5d2Smrg			| mipsisa32 | mipsisa32el \
12280760f5d2Smrg			| mipsisa32r2 | mipsisa32r2el \
12290760f5d2Smrg			| mipsisa32r3 | mipsisa32r3el \
12300760f5d2Smrg			| mipsisa32r5 | mipsisa32r5el \
12310760f5d2Smrg			| mipsisa32r6 | mipsisa32r6el \
12320760f5d2Smrg			| mipsisa64 | mipsisa64el \
12330760f5d2Smrg			| mipsisa64r2 | mipsisa64r2el \
12340760f5d2Smrg			| mipsisa64r3 | mipsisa64r3el \
12350760f5d2Smrg			| mipsisa64r5 | mipsisa64r5el \
12360760f5d2Smrg			| mipsisa64r6 | mipsisa64r6el \
12370760f5d2Smrg			| mipsisa64sb1 | mipsisa64sb1el \
12380760f5d2Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
12390760f5d2Smrg			| mipsr5900 | mipsr5900el \
12400760f5d2Smrg			| mipstx39 | mipstx39el \
12410760f5d2Smrg			| mmix \
12420760f5d2Smrg			| mn10200 | mn10300 \
12430760f5d2Smrg			| moxie \
12440760f5d2Smrg			| mt \
12450760f5d2Smrg			| msp430 \
12460760f5d2Smrg			| nds32 | nds32le | nds32be \
12470760f5d2Smrg			| nfp \
12480760f5d2Smrg			| nios | nios2 | nios2eb | nios2el \
12490760f5d2Smrg			| none | np1 | ns16k | ns32k | nvptx \
12500760f5d2Smrg			| open8 \
12510760f5d2Smrg			| or1k* \
12520760f5d2Smrg			| or32 \
12530760f5d2Smrg			| orion \
12540760f5d2Smrg			| picochip \
12550760f5d2Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12560760f5d2Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12570760f5d2Smrg			| pru \
12580760f5d2Smrg			| pyramid \
12590760f5d2Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12600760f5d2Smrg			| rl78 | romp | rs6000 | rx \
12610760f5d2Smrg			| s390 | s390x \
12620760f5d2Smrg			| score \
12630760f5d2Smrg			| sh | shl \
12640760f5d2Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12650760f5d2Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12660760f5d2Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12670760f5d2Smrg			| sparclite \
12680760f5d2Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12690760f5d2Smrg			| spu \
12700760f5d2Smrg			| tahoe \
12710760f5d2Smrg			| thumbv7* \
12720760f5d2Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12730760f5d2Smrg			| tron \
12740760f5d2Smrg			| ubicom32 \
12750760f5d2Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12760760f5d2Smrg			| vax \
12770760f5d2Smrg			| visium \
12780760f5d2Smrg			| w65 \
12790760f5d2Smrg			| wasm32 | wasm64 \
12800760f5d2Smrg			| we32k \
12810760f5d2Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12820760f5d2Smrg			| xstormy16 | xtensa* \
12830760f5d2Smrg			| ymp \
12840760f5d2Smrg			| z8k | z80)
12850760f5d2Smrg				;;
12860760f5d2Smrg
12870760f5d2Smrg			*)
12880760f5d2Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12890760f5d2Smrg				exit 1
12900760f5d2Smrg				;;
12910760f5d2Smrg		esac
1292caade7ccSmrg		;;
1293caade7ccSmrgesac
1294caade7ccSmrg
1295caade7ccSmrg# Here we canonicalize certain aliases for manufacturers.
12960760f5d2Smrgcase $vendor in
12970760f5d2Smrg	digital*)
12980760f5d2Smrg		vendor=dec
1299caade7ccSmrg		;;
13000760f5d2Smrg	commodore*)
13010760f5d2Smrg		vendor=cbm
1302caade7ccSmrg		;;
1303caade7ccSmrg	*)
1304caade7ccSmrg		;;
1305caade7ccSmrgesac
1306caade7ccSmrg
1307caade7ccSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308caade7ccSmrg
13090760f5d2Smrgif test x$basic_os != x
1310caade7ccSmrgthen
13110760f5d2Smrg
131205789e77Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13130760f5d2Smrg# set os.
13140760f5d2Smrgcase $basic_os in
13150760f5d2Smrg	gnu/linux*)
13160760f5d2Smrg		kernel=linux
13170760f5d2Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13180760f5d2Smrg		;;
13190760f5d2Smrg	os2-emx)
13200760f5d2Smrg		kernel=os2
13210760f5d2Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13220760f5d2Smrg		;;
13230760f5d2Smrg	nto-qnx*)
13240760f5d2Smrg		kernel=nto
13250760f5d2Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13260760f5d2Smrg		;;
13270760f5d2Smrg	*-*)
13280760f5d2Smrg		# shellcheck disable=SC2162
13290760f5d2Smrg		saved_IFS=$IFS
13300760f5d2Smrg		IFS="-" read kernel os <<EOF
13310760f5d2Smrg$basic_os
13320760f5d2SmrgEOF
13330760f5d2Smrg		IFS=$saved_IFS
13340760f5d2Smrg		;;
13350760f5d2Smrg	# Default OS when just kernel was specified
13360760f5d2Smrg	nto*)
13370760f5d2Smrg		kernel=nto
13380760f5d2Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13390760f5d2Smrg		;;
13400760f5d2Smrg	linux*)
13410760f5d2Smrg		kernel=linux
13420760f5d2Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13430760f5d2Smrg		;;
134405789e77Smrg	managarm*)
134505789e77Smrg		kernel=managarm
134605789e77Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
134705789e77Smrg		;;
13480760f5d2Smrg	*)
13490760f5d2Smrg		kernel=
13500760f5d2Smrg		os=$basic_os
13510760f5d2Smrg		;;
13520760f5d2Smrgesac
13530760f5d2Smrg
13540760f5d2Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13550760f5d2Smrg# etc.)
1356caade7ccSmrgcase $os in
1357cc4920e5Smrg	# First match some system type aliases that might get confused
1358cc4920e5Smrg	# with valid system types.
13590760f5d2Smrg	# solaris* is a basic system type, with this one exception.
13600760f5d2Smrg	auroraux)
13610760f5d2Smrg		os=auroraux
1362b9b4fd27Smrg		;;
13630760f5d2Smrg	bluegene*)
13640760f5d2Smrg		os=cnk
1365caade7ccSmrg		;;
13660760f5d2Smrg	solaris1 | solaris1.*)
13670760f5d2Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368caade7ccSmrg		;;
13690760f5d2Smrg	solaris)
13700760f5d2Smrg		os=solaris2
1371caade7ccSmrg		;;
13720760f5d2Smrg	unixware*)
13730760f5d2Smrg		os=sysv4.2uw
1374caade7ccSmrg		;;
1375cc4920e5Smrg	# es1800 is here to avoid being matched by es* (a different OS)
13760760f5d2Smrg	es1800*)
13770760f5d2Smrg		os=ose
1378cc4920e5Smrg		;;
13790760f5d2Smrg	# Some version numbers need modification
13800760f5d2Smrg	chorusos*)
13810760f5d2Smrg		os=chorusos
1382caade7ccSmrg		;;
13830760f5d2Smrg	isc)
13840760f5d2Smrg		os=isc2.2
1385caade7ccSmrg		;;
13860760f5d2Smrg	sco6)
13870760f5d2Smrg		os=sco5v6
1388caade7ccSmrg		;;
13890760f5d2Smrg	sco5)
13900760f5d2Smrg		os=sco3.2v5
1391caade7ccSmrg		;;
13920760f5d2Smrg	sco4)
13930760f5d2Smrg		os=sco3.2v4
1394caade7ccSmrg		;;
13950760f5d2Smrg	sco3.2.[4-9]*)
13960760f5d2Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397caade7ccSmrg		;;
13980760f5d2Smrg	sco*v* | scout)
13990760f5d2Smrg		# Don't match below
1400caade7ccSmrg		;;
14010760f5d2Smrg	sco*)
14020760f5d2Smrg		os=sco3.2v2
1403caade7ccSmrg		;;
14040760f5d2Smrg	psos*)
14050760f5d2Smrg		os=psos
1406caade7ccSmrg		;;
14070760f5d2Smrg	qnx*)
14080760f5d2Smrg		os=qnx
1409caade7ccSmrg		;;
14100760f5d2Smrg	hiux*)
14110760f5d2Smrg		os=hiuxwe2
1412caade7ccSmrg		;;
14130760f5d2Smrg	lynx*178)
14140760f5d2Smrg		os=lynxos178
1415caade7ccSmrg		;;
14160760f5d2Smrg	lynx*5)
14170760f5d2Smrg		os=lynxos5
1418caade7ccSmrg		;;
14190760f5d2Smrg	lynxos*)
14200760f5d2Smrg		# don't get caught up in next wildcard
1421caade7ccSmrg		;;
14220760f5d2Smrg	lynx*)
14230760f5d2Smrg		os=lynxos
1424caade7ccSmrg		;;
14250760f5d2Smrg	mac[0-9]*)
14260760f5d2Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427caade7ccSmrg		;;
14280760f5d2Smrg	opened*)
14290760f5d2Smrg		os=openedition
1430caade7ccSmrg		;;
14310760f5d2Smrg	os400*)
14320760f5d2Smrg		os=os400
1433caade7ccSmrg		;;
14340760f5d2Smrg	sunos5*)
14350760f5d2Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436caade7ccSmrg		;;
14370760f5d2Smrg	sunos6*)
14380760f5d2Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439caade7ccSmrg		;;
14400760f5d2Smrg	wince*)
14410760f5d2Smrg		os=wince
1442caade7ccSmrg		;;
14430760f5d2Smrg	utek*)
14440760f5d2Smrg		os=bsd
1445caade7ccSmrg		;;
14460760f5d2Smrg	dynix*)
14470760f5d2Smrg		os=bsd
1448caade7ccSmrg		;;
14490760f5d2Smrg	acis*)
14500760f5d2Smrg		os=aos
1451caade7ccSmrg		;;
14520760f5d2Smrg	atheos*)
14530760f5d2Smrg		os=atheos
1454caade7ccSmrg		;;
14550760f5d2Smrg	syllable*)
14560760f5d2Smrg		os=syllable
14570760f5d2Smrg		;;
14580760f5d2Smrg	386bsd)
14590760f5d2Smrg		os=bsd
14600760f5d2Smrg		;;
14610760f5d2Smrg	ctix* | uts*)
14620760f5d2Smrg		os=sysv
14630760f5d2Smrg		;;
14640760f5d2Smrg	nova*)
14650760f5d2Smrg		os=rtmk-nova
14660760f5d2Smrg		;;
14670760f5d2Smrg	ns2)
14680760f5d2Smrg		os=nextstep2
14690760f5d2Smrg		;;
14700760f5d2Smrg	# Preserve the version number of sinix5.
14710760f5d2Smrg	sinix5.*)
14720760f5d2Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473caade7ccSmrg		;;
14740760f5d2Smrg	sinix*)
14750760f5d2Smrg		os=sysv4
1476caade7ccSmrg		;;
14770760f5d2Smrg	tpf*)
14780760f5d2Smrg		os=tpf
1479caade7ccSmrg		;;
14800760f5d2Smrg	triton*)
14810760f5d2Smrg		os=sysv3
1482caade7ccSmrg		;;
14830760f5d2Smrg	oss*)
14840760f5d2Smrg		os=sysv3
1485caade7ccSmrg		;;
14860760f5d2Smrg	svr4*)
14870760f5d2Smrg		os=sysv4
1488caade7ccSmrg		;;
14890760f5d2Smrg	svr3)
14900760f5d2Smrg		os=sysv3
1491caade7ccSmrg		;;
14920760f5d2Smrg	sysvr4)
14930760f5d2Smrg		os=sysv4
1494caade7ccSmrg		;;
14950760f5d2Smrg	ose*)
14960760f5d2Smrg		os=ose
1497caade7ccSmrg		;;
14980760f5d2Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14990760f5d2Smrg		os=mint
1500b9b4fd27Smrg		;;
15010760f5d2Smrg	dicos*)
15020760f5d2Smrg		os=dicos
15030760f5d2Smrg		;;
15040760f5d2Smrg	pikeos*)
1505cc4920e5Smrg		# Until real need of OS specific support for
1506cc4920e5Smrg		# particular features comes up, bare metal
1507cc4920e5Smrg		# configurations are quite functional.
15080760f5d2Smrg		case $cpu in
1509cc4920e5Smrg		    arm*)
15100760f5d2Smrg			os=eabi
1511cc4920e5Smrg			;;
1512cc4920e5Smrg		    *)
15130760f5d2Smrg			os=elf
1514cc4920e5Smrg			;;
1515cc4920e5Smrg		esac
1516cc4920e5Smrg		;;
1517caade7ccSmrg	*)
15180760f5d2Smrg		# No normalization, but not necessarily accepted, that comes below.
1519caade7ccSmrg		;;
1520caade7ccSmrgesac
15210760f5d2Smrg
1522caade7ccSmrgelse
1523caade7ccSmrg
1524caade7ccSmrg# Here we handle the default operating systems that come with various machines.
1525caade7ccSmrg# The value should be what the vendor currently ships out the door with their
1526caade7ccSmrg# machine or put another way, the most popular os provided with the machine.
1527caade7ccSmrg
1528caade7ccSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529caade7ccSmrg# "-sun"), then you have to tell the case statement up towards the top
1530caade7ccSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531caade7ccSmrg# will signal an error saying that MANUFACTURER isn't an operating
1532caade7ccSmrg# system, and we'll never get to this point.
1533caade7ccSmrg
15340760f5d2Smrgkernel=
15350760f5d2Smrgcase $cpu-$vendor in
1536af9a7ee5Smrg	score-*)
15370760f5d2Smrg		os=elf
1538485f0483Smrg		;;
1539af9a7ee5Smrg	spu-*)
15400760f5d2Smrg		os=elf
1541485f0483Smrg		;;
1542caade7ccSmrg	*-acorn)
15430760f5d2Smrg		os=riscix1.2
1544caade7ccSmrg		;;
1545caade7ccSmrg	arm*-rebel)
15460760f5d2Smrg		kernel=linux
15470760f5d2Smrg		os=gnu
1548caade7ccSmrg		;;
1549caade7ccSmrg	arm*-semi)
15500760f5d2Smrg		os=aout
1551caade7ccSmrg		;;
1552af9a7ee5Smrg	c4x-* | tic4x-*)
15530760f5d2Smrg		os=coff
1554af9a7ee5Smrg		;;
1555cc4920e5Smrg	c8051-*)
15560760f5d2Smrg		os=elf
15570760f5d2Smrg		;;
15580760f5d2Smrg	clipper-intergraph)
15590760f5d2Smrg		os=clix
1560cc4920e5Smrg		;;
1561af9a7ee5Smrg	hexagon-*)
15620760f5d2Smrg		os=elf
1563485f0483Smrg		;;
1564e8a5466aSmrg	tic54x-*)
15650760f5d2Smrg		os=coff
1566e8a5466aSmrg		;;
1567e8a5466aSmrg	tic55x-*)
15680760f5d2Smrg		os=coff
1569e8a5466aSmrg		;;
1570e8a5466aSmrg	tic6x-*)
15710760f5d2Smrg		os=coff
1572e8a5466aSmrg		;;
1573caade7ccSmrg	# This must come before the *-dec entry.
1574caade7ccSmrg	pdp10-*)
15750760f5d2Smrg		os=tops20
1576caade7ccSmrg		;;
1577caade7ccSmrg	pdp11-*)
15780760f5d2Smrg		os=none
1579caade7ccSmrg		;;
1580caade7ccSmrg	*-dec | vax-*)
15810760f5d2Smrg		os=ultrix4.2
1582caade7ccSmrg		;;
1583caade7ccSmrg	m68*-apollo)
15840760f5d2Smrg		os=domain
1585caade7ccSmrg		;;
1586caade7ccSmrg	i386-sun)
15870760f5d2Smrg		os=sunos4.0.2
1588caade7ccSmrg		;;
1589caade7ccSmrg	m68000-sun)
15900760f5d2Smrg		os=sunos3
1591caade7ccSmrg		;;
1592caade7ccSmrg	m68*-cisco)
15930760f5d2Smrg		os=aout
1594caade7ccSmrg		;;
1595af9a7ee5Smrg	mep-*)
15960760f5d2Smrg		os=elf
1597485f0483Smrg		;;
1598caade7ccSmrg	mips*-cisco)
15990760f5d2Smrg		os=elf
1600caade7ccSmrg		;;
1601caade7ccSmrg	mips*-*)
16020760f5d2Smrg		os=elf
1603caade7ccSmrg		;;
1604caade7ccSmrg	or32-*)
16050760f5d2Smrg		os=coff
1606caade7ccSmrg		;;
1607caade7ccSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
16080760f5d2Smrg		os=sysv3
1609caade7ccSmrg		;;
1610caade7ccSmrg	sparc-* | *-sun)
16110760f5d2Smrg		os=sunos4.1.1
1612caade7ccSmrg		;;
1613cc4920e5Smrg	pru-*)
16140760f5d2Smrg		os=elf
1615cc4920e5Smrg		;;
1616caade7ccSmrg	*-be)
16170760f5d2Smrg		os=beos
1618caade7ccSmrg		;;
1619caade7ccSmrg	*-ibm)
16200760f5d2Smrg		os=aix
1621caade7ccSmrg		;;
1622af9a7ee5Smrg	*-knuth)
16230760f5d2Smrg		os=mmixware
1624caade7ccSmrg		;;
1625caade7ccSmrg	*-wec)
16260760f5d2Smrg		os=proelf
1627caade7ccSmrg		;;
1628caade7ccSmrg	*-winbond)
16290760f5d2Smrg		os=proelf
1630caade7ccSmrg		;;
1631caade7ccSmrg	*-oki)
16320760f5d2Smrg		os=proelf
1633caade7ccSmrg		;;
1634caade7ccSmrg	*-hp)
16350760f5d2Smrg		os=hpux
1636caade7ccSmrg		;;
1637caade7ccSmrg	*-hitachi)
16380760f5d2Smrg		os=hiux
1639caade7ccSmrg		;;
1640caade7ccSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16410760f5d2Smrg		os=sysv
1642caade7ccSmrg		;;
1643caade7ccSmrg	*-cbm)
16440760f5d2Smrg		os=amigaos
1645caade7ccSmrg		;;
1646caade7ccSmrg	*-dg)
16470760f5d2Smrg		os=dgux
1648caade7ccSmrg		;;
1649caade7ccSmrg	*-dolphin)
16500760f5d2Smrg		os=sysv3
1651caade7ccSmrg		;;
1652caade7ccSmrg	m68k-ccur)
16530760f5d2Smrg		os=rtu
1654caade7ccSmrg		;;
1655caade7ccSmrg	m88k-omron*)
16560760f5d2Smrg		os=luna
1657caade7ccSmrg		;;
1658cc4920e5Smrg	*-next)
16590760f5d2Smrg		os=nextstep
1660caade7ccSmrg		;;
1661caade7ccSmrg	*-sequent)
16620760f5d2Smrg		os=ptx
1663caade7ccSmrg		;;
1664caade7ccSmrg	*-crds)
16650760f5d2Smrg		os=unos
1666caade7ccSmrg		;;
1667caade7ccSmrg	*-ns)
16680760f5d2Smrg		os=genix
1669caade7ccSmrg		;;
1670caade7ccSmrg	i370-*)
16710760f5d2Smrg		os=mvs
1672caade7ccSmrg		;;
1673caade7ccSmrg	*-gould)
16740760f5d2Smrg		os=sysv
1675caade7ccSmrg		;;
1676caade7ccSmrg	*-highlevel)
16770760f5d2Smrg		os=bsd
1678caade7ccSmrg		;;
1679caade7ccSmrg	*-encore)
16800760f5d2Smrg		os=bsd
1681caade7ccSmrg		;;
1682caade7ccSmrg	*-sgi)
16830760f5d2Smrg		os=irix
1684caade7ccSmrg		;;
1685caade7ccSmrg	*-siemens)
16860760f5d2Smrg		os=sysv4
1687caade7ccSmrg		;;
1688caade7ccSmrg	*-masscomp)
16890760f5d2Smrg		os=rtu
1690caade7ccSmrg		;;
1691caade7ccSmrg	f30[01]-fujitsu | f700-fujitsu)
16920760f5d2Smrg		os=uxpv
1693caade7ccSmrg		;;
1694caade7ccSmrg	*-rom68k)
16950760f5d2Smrg		os=coff
1696caade7ccSmrg		;;
1697caade7ccSmrg	*-*bug)
16980760f5d2Smrg		os=coff
1699caade7ccSmrg		;;
1700caade7ccSmrg	*-apple)
17010760f5d2Smrg		os=macos
1702caade7ccSmrg		;;
1703caade7ccSmrg	*-atari*)
17040760f5d2Smrg		os=mint
17050760f5d2Smrg		;;
17060760f5d2Smrg	*-wrs)
17070760f5d2Smrg		os=vxworks
1708caade7ccSmrg		;;
1709caade7ccSmrg	*)
17100760f5d2Smrg		os=none
1711caade7ccSmrg		;;
1712caade7ccSmrgesac
17130760f5d2Smrg
1714caade7ccSmrgfi
1715caade7ccSmrg
17160760f5d2Smrg# Now, validate our (potentially fixed-up) OS.
17170760f5d2Smrgcase $os in
17180760f5d2Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17190760f5d2Smrg	musl* | newlib* | relibc* | uclibc*)
17200760f5d2Smrg		;;
17210760f5d2Smrg	# Likewise for "kernel-abi"
17220760f5d2Smrg	eabi* | gnueabi*)
17230760f5d2Smrg		;;
17240760f5d2Smrg	# VxWorks passes extra cpu info in the 4th filed.
17250760f5d2Smrg	simlinux | simwindows | spe)
17260760f5d2Smrg		;;
17270760f5d2Smrg	# Now accept the basic system types.
17280760f5d2Smrg	# The portable systems comes first.
17290760f5d2Smrg	# Each alternative MUST end in a * to match a version number.
17300760f5d2Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17310760f5d2Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17320760f5d2Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17330760f5d2Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17340760f5d2Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17350760f5d2Smrg	     | os9* | macos* | osx* | ios* \
17360760f5d2Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17370760f5d2Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17380760f5d2Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17390760f5d2Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17400760f5d2Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17410760f5d2Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17420760f5d2Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17430760f5d2Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17440760f5d2Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17450760f5d2Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17460760f5d2Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17470760f5d2Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17480760f5d2Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17490760f5d2Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17500760f5d2Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17510760f5d2Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17520760f5d2Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17530760f5d2Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17540760f5d2Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17550760f5d2Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17560760f5d2Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17570760f5d2Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17580760f5d2Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17590760f5d2Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
176005789e77Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
176105789e77Smrg	     | fiwix* | mlibc* )
17620760f5d2Smrg		;;
17630760f5d2Smrg	# This one is extra strict with allowed versions
17640760f5d2Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17650760f5d2Smrg		# Don't forget version if it is 3.2v4 or newer.
17660760f5d2Smrg		;;
17670760f5d2Smrg	none)
17680760f5d2Smrg		;;
176905789e77Smrg	kernel* )
177005789e77Smrg		# Restricted further below
177105789e77Smrg		;;
17720760f5d2Smrg	*)
17730760f5d2Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17740760f5d2Smrg		exit 1
17750760f5d2Smrg		;;
17760760f5d2Smrgesac
17770760f5d2Smrg
17780760f5d2Smrg# As a final step for OS-related things, validate the OS-kernel combination
17790760f5d2Smrg# (given a valid OS), if there is a kernel.
17800760f5d2Smrgcase $kernel-$os in
17810760f5d2Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
178205789e77Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17830760f5d2Smrg		;;
17840760f5d2Smrg	uclinux-uclibc* )
17850760f5d2Smrg		;;
178605789e77Smrg	managarm-mlibc* | managarm-kernel* )
178705789e77Smrg		;;
178805789e77Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17890760f5d2Smrg		# These are just libc implementations, not actual OSes, and thus
17900760f5d2Smrg		# require a kernel.
17910760f5d2Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17920760f5d2Smrg		exit 1
17930760f5d2Smrg		;;
179405789e77Smrg	-kernel* )
179505789e77Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
179605789e77Smrg		exit 1
179705789e77Smrg		;;
179805789e77Smrg	*-kernel* )
179905789e77Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
180005789e77Smrg		exit 1
180105789e77Smrg		;;
18020760f5d2Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
18030760f5d2Smrg		;;
18040760f5d2Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
18050760f5d2Smrg		;;
18060760f5d2Smrg	nto-qnx*)
18070760f5d2Smrg		;;
18080760f5d2Smrg	os2-emx)
18090760f5d2Smrg		;;
18100760f5d2Smrg	*-eabi* | *-gnueabi*)
18110760f5d2Smrg		;;
18120760f5d2Smrg	-*)
18130760f5d2Smrg		# Blank kernel with real OS is always fine.
18140760f5d2Smrg		;;
18150760f5d2Smrg	*-*)
18160760f5d2Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18170760f5d2Smrg		exit 1
18180760f5d2Smrg		;;
18190760f5d2Smrgesac
18200760f5d2Smrg
1821caade7ccSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1822caade7ccSmrg# manufacturer.  We pick the logical manufacturer.
18230760f5d2Smrgcase $vendor in
18240760f5d2Smrg	unknown)
18250760f5d2Smrg		case $cpu-$os in
18260760f5d2Smrg			*-riscix*)
1827caade7ccSmrg				vendor=acorn
1828caade7ccSmrg				;;
18290760f5d2Smrg			*-sunos*)
1830caade7ccSmrg				vendor=sun
1831caade7ccSmrg				;;
18320760f5d2Smrg			*-cnk* | *-aix*)
1833caade7ccSmrg				vendor=ibm
1834caade7ccSmrg				;;
18350760f5d2Smrg			*-beos*)
1836caade7ccSmrg				vendor=be
1837caade7ccSmrg				;;
18380760f5d2Smrg			*-hpux*)
1839caade7ccSmrg				vendor=hp
1840caade7ccSmrg				;;
18410760f5d2Smrg			*-mpeix*)
1842caade7ccSmrg				vendor=hp
1843caade7ccSmrg				;;
18440760f5d2Smrg			*-hiux*)
1845caade7ccSmrg				vendor=hitachi
1846caade7ccSmrg				;;
18470760f5d2Smrg			*-unos*)
1848caade7ccSmrg				vendor=crds
1849caade7ccSmrg				;;
18500760f5d2Smrg			*-dgux*)
1851caade7ccSmrg				vendor=dg
1852caade7ccSmrg				;;
18530760f5d2Smrg			*-luna*)
1854caade7ccSmrg				vendor=omron
1855caade7ccSmrg				;;
18560760f5d2Smrg			*-genix*)
1857caade7ccSmrg				vendor=ns
1858caade7ccSmrg				;;
18590760f5d2Smrg			*-clix*)
18600760f5d2Smrg				vendor=intergraph
18610760f5d2Smrg				;;
18620760f5d2Smrg			*-mvs* | *-opened*)
18630760f5d2Smrg				vendor=ibm
18640760f5d2Smrg				;;
18650760f5d2Smrg			*-os400*)
1866caade7ccSmrg				vendor=ibm
1867caade7ccSmrg				;;
18680760f5d2Smrg			s390-* | s390x-*)
1869caade7ccSmrg				vendor=ibm
1870caade7ccSmrg				;;
18710760f5d2Smrg			*-ptx*)
1872caade7ccSmrg				vendor=sequent
1873caade7ccSmrg				;;
18740760f5d2Smrg			*-tpf*)
1875caade7ccSmrg				vendor=ibm
1876caade7ccSmrg				;;
18770760f5d2Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1878caade7ccSmrg				vendor=wrs
1879caade7ccSmrg				;;
18800760f5d2Smrg			*-aux*)
1881caade7ccSmrg				vendor=apple
1882caade7ccSmrg				;;
18830760f5d2Smrg			*-hms*)
1884caade7ccSmrg				vendor=hitachi
1885caade7ccSmrg				;;
18860760f5d2Smrg			*-mpw* | *-macos*)
1887caade7ccSmrg				vendor=apple
1888caade7ccSmrg				;;
18890760f5d2Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890caade7ccSmrg				vendor=atari
1891caade7ccSmrg				;;
18920760f5d2Smrg			*-vos*)
1893caade7ccSmrg				vendor=stratus
1894caade7ccSmrg				;;
1895caade7ccSmrg		esac
1896caade7ccSmrg		;;
1897caade7ccSmrgesac
1898caade7ccSmrg
18990760f5d2Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900caade7ccSmrgexit
1901caade7ccSmrg
1902caade7ccSmrg# Local variables:
19030760f5d2Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904caade7ccSmrg# time-stamp-start: "timestamp='"
1905caade7ccSmrg# time-stamp-format: "%:y-%02m-%02d"
1906caade7ccSmrg# time-stamp-end: "'"
1907caade7ccSmrg# End:
1908