17914d74bSmrg#! /bin/sh
27914d74bSmrg# Configuration validation subroutine script.
36b7436aeSmrg#   Copyright 1992-2022 Free Software Foundation, Inc.
47914d74bSmrg
50ea508b1Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
60ea508b1Smrg
76b7436aeSmrgtimestamp='2022-01-03'
87914d74bSmrg
9e6d5e4e0Smrg# This file is free software; you can redistribute it and/or modify it
10e6d5e4e0Smrg# under the terms of the GNU General Public License as published by
110ea508b1Smrg# the Free Software Foundation, either version 3 of the License, or
127914d74bSmrg# (at your option) any later version.
137914d74bSmrg#
14e6d5e4e0Smrg# This program is distributed in the hope that it will be useful, but
15e6d5e4e0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16e6d5e4e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17e6d5e4e0Smrg# General Public License for more details.
187914d74bSmrg#
197914d74bSmrg# You should have received a copy of the GNU General Public License
20cdce750aSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
217914d74bSmrg#
227914d74bSmrg# As a special exception to the GNU General Public License, if you
237914d74bSmrg# distribute this file as part of a program that contains a
247914d74bSmrg# configuration script generated by Autoconf, you may include it under
25e6d5e4e0Smrg# the same distribution terms that you use for the rest of that
26e6d5e4e0Smrg# program.  This Exception is an additional permission under section 7
27e6d5e4e0Smrg# of the GNU General Public License, version 3 ("GPLv3").
287914d74bSmrg
297914d74bSmrg
309d0ccd10Smrg# Please send patches to <config-patches@gnu.org>.
317914d74bSmrg#
327914d74bSmrg# Configuration subroutine to validate and canonicalize a configuration type.
337914d74bSmrg# Supply the specified configuration type as an argument.
347914d74bSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
357914d74bSmrg# Otherwise, we print the canonical config type on stdout and succeed.
367914d74bSmrg
37e8ead290Smrg# You can get the latest version of this script from:
380ea508b1Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39e8ead290Smrg
407914d74bSmrg# This file is supposed to be the same for all GNU packages
417914d74bSmrg# and recognize all the CPU types, system types and aliases
427914d74bSmrg# that are meaningful with *any* GNU software.
437914d74bSmrg# Each package is responsible for reporting which valid configurations
447914d74bSmrg# it does not support.  The user should be able to distinguish
457914d74bSmrg# a failure to support a valid configuration from a meaningless
467914d74bSmrg# configuration.
477914d74bSmrg
487914d74bSmrg# The goal of this file is to map all the various variations of a given
497914d74bSmrg# machine specification into a single specification in the form:
507914d74bSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
517914d74bSmrg# or in some cases, the newer four-part form:
527914d74bSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
537914d74bSmrg# It is wrong to echo any other type of specification.
547914d74bSmrg
550ea508b1Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
560ea508b1Smrg# about features and limitations of the classic Bourne shell that were
570ea508b1Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
580ea508b1Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
590ea508b1Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
600ea508b1Smrg# have a pre-POSIX /bin/sh.
610ea508b1Smrg
627914d74bSmrgme=`echo "$0" | sed -e 's,.*/,,'`
637914d74bSmrg
647914d74bSmrgusage="\
65cdce750aSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
667914d74bSmrg
677914d74bSmrgCanonicalize a configuration name.
687914d74bSmrg
69cdce750aSmrgOptions:
707914d74bSmrg  -h, --help         print this help, then exit
717914d74bSmrg  -t, --time-stamp   print date of last modification, then exit
727914d74bSmrg  -v, --version      print version number, then exit
737914d74bSmrg
747914d74bSmrgReport bugs and patches to <config-patches@gnu.org>."
757914d74bSmrg
767914d74bSmrgversion="\
777914d74bSmrgGNU config.sub ($timestamp)
787914d74bSmrg
796b7436aeSmrgCopyright 1992-2022 Free Software Foundation, Inc.
807914d74bSmrg
817914d74bSmrgThis is free software; see the source for copying conditions.  There is NO
827914d74bSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
837914d74bSmrg
847914d74bSmrghelp="
857914d74bSmrgTry \`$me --help' for more information."
867914d74bSmrg
877914d74bSmrg# Parse command line
887914d74bSmrgwhile test $# -gt 0 ; do
897914d74bSmrg  case $1 in
907914d74bSmrg    --time-stamp | --time* | -t )
917914d74bSmrg       echo "$timestamp" ; exit ;;
927914d74bSmrg    --version | -v )
937914d74bSmrg       echo "$version" ; exit ;;
947914d74bSmrg    --help | --h* | -h )
957914d74bSmrg       echo "$usage"; exit ;;
967914d74bSmrg    -- )     # Stop option processing
977914d74bSmrg       shift; break ;;
987914d74bSmrg    - )	# Use stdin as input.
997914d74bSmrg       break ;;
1007914d74bSmrg    -* )
1010ea508b1Smrg       echo "$me: invalid option $1$help" >&2
1027914d74bSmrg       exit 1 ;;
1037914d74bSmrg
1047914d74bSmrg    *local*)
1057914d74bSmrg       # First pass through any local machine types.
106cdce750aSmrg       echo "$1"
1077914d74bSmrg       exit ;;
1087914d74bSmrg
1097914d74bSmrg    * )
1107914d74bSmrg       break ;;
1117914d74bSmrg  esac
1127914d74bSmrgdone
1137914d74bSmrg
1147914d74bSmrgcase $# in
1157914d74bSmrg 0) echo "$me: missing argument$help" >&2
1167914d74bSmrg    exit 1;;
1177914d74bSmrg 1) ;;
1187914d74bSmrg *) echo "$me: too many arguments$help" >&2
1197914d74bSmrg    exit 1;;
1207914d74bSmrgesac
1217914d74bSmrg
1220ea508b1Smrg# Split fields of configuration type
1230ea508b1Smrg# shellcheck disable=SC2162
1240ea508b1Smrgsaved_IFS=$IFS
1250ea508b1SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1260ea508b1Smrg$1
1270ea508b1SmrgEOF
1280ea508b1SmrgIFS=$saved_IFS
1297914d74bSmrg
1300ea508b1Smrg# Separate into logical components for further validation
1310ea508b1Smrgcase $1 in
1320ea508b1Smrg	*-*-*-*-*)
1330ea508b1Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
1340ea508b1Smrg		exit 1
135e6d5e4e0Smrg		;;
1360ea508b1Smrg	*-*-*-*)
1370ea508b1Smrg		basic_machine=$field1-$field2
1380ea508b1Smrg		basic_os=$field3-$field4
1397914d74bSmrg		;;
1400ea508b1Smrg	*-*-*)
1410ea508b1Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1420ea508b1Smrg		# parts
1430ea508b1Smrg		maybe_os=$field2-$field3
1440ea508b1Smrg		case $maybe_os in
1450ea508b1Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1460ea508b1Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1470ea508b1Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1486b7436aeSmrg			| storm-chaos* | os2-emx* | rtmk-nova*)
1490ea508b1Smrg				basic_machine=$field1
1500ea508b1Smrg				basic_os=$maybe_os
1510ea508b1Smrg				;;
1520ea508b1Smrg			android-linux)
1530ea508b1Smrg				basic_machine=$field1-unknown
1540ea508b1Smrg				basic_os=linux-android
1550ea508b1Smrg				;;
1560ea508b1Smrg			*)
1570ea508b1Smrg				basic_machine=$field1-$field2
1580ea508b1Smrg				basic_os=$field3
1590ea508b1Smrg				;;
1600ea508b1Smrg		esac
1617914d74bSmrg		;;
1620ea508b1Smrg	*-*)
1630ea508b1Smrg		# A lone config we happen to match not fitting any pattern
1640ea508b1Smrg		case $field1-$field2 in
1650ea508b1Smrg			decstation-3100)
1660ea508b1Smrg				basic_machine=mips-dec
1670ea508b1Smrg				basic_os=
1680ea508b1Smrg				;;
1690ea508b1Smrg			*-*)
1700ea508b1Smrg				# Second component is usually, but not always the OS
1710ea508b1Smrg				case $field2 in
1720ea508b1Smrg					# Prevent following clause from handling this valid os
1730ea508b1Smrg					sun*os*)
1740ea508b1Smrg						basic_machine=$field1
1750ea508b1Smrg						basic_os=$field2
1760ea508b1Smrg						;;
1770ea508b1Smrg					zephyr*)
1780ea508b1Smrg						basic_machine=$field1-unknown
1790ea508b1Smrg						basic_os=$field2
1800ea508b1Smrg						;;
1810ea508b1Smrg					# Manufacturers
1820ea508b1Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1830ea508b1Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1840ea508b1Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1850ea508b1Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1860ea508b1Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1870ea508b1Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1880ea508b1Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1890ea508b1Smrg					| microblaze* | sim | cisco \
1900ea508b1Smrg					| oki | wec | wrs | winbond)
1910ea508b1Smrg						basic_machine=$field1-$field2
1920ea508b1Smrg						basic_os=
1930ea508b1Smrg						;;
1940ea508b1Smrg					*)
1950ea508b1Smrg						basic_machine=$field1
1960ea508b1Smrg						basic_os=$field2
1970ea508b1Smrg						;;
1980ea508b1Smrg				esac
1990ea508b1Smrg			;;
2000ea508b1Smrg		esac
2017914d74bSmrg		;;
2020ea508b1Smrg	*)
2030ea508b1Smrg		# Convert single-component short-hands not valid as part of
2040ea508b1Smrg		# multi-component configurations.
2050ea508b1Smrg		case $field1 in
2060ea508b1Smrg			386bsd)
2070ea508b1Smrg				basic_machine=i386-pc
2080ea508b1Smrg				basic_os=bsd
2090ea508b1Smrg				;;
2100ea508b1Smrg			a29khif)
2110ea508b1Smrg				basic_machine=a29k-amd
2120ea508b1Smrg				basic_os=udi
2130ea508b1Smrg				;;
2140ea508b1Smrg			adobe68k)
2150ea508b1Smrg				basic_machine=m68010-adobe
2160ea508b1Smrg				basic_os=scout
2170ea508b1Smrg				;;
2180ea508b1Smrg			alliant)
2190ea508b1Smrg				basic_machine=fx80-alliant
2200ea508b1Smrg				basic_os=
2210ea508b1Smrg				;;
2220ea508b1Smrg			altos | altos3068)
2230ea508b1Smrg				basic_machine=m68k-altos
2240ea508b1Smrg				basic_os=
2250ea508b1Smrg				;;
2260ea508b1Smrg			am29k)
2270ea508b1Smrg				basic_machine=a29k-none
2280ea508b1Smrg				basic_os=bsd
2290ea508b1Smrg				;;
2300ea508b1Smrg			amdahl)
2310ea508b1Smrg				basic_machine=580-amdahl
2320ea508b1Smrg				basic_os=sysv
2330ea508b1Smrg				;;
2340ea508b1Smrg			amiga)
2350ea508b1Smrg				basic_machine=m68k-unknown
2360ea508b1Smrg				basic_os=
2370ea508b1Smrg				;;
2380ea508b1Smrg			amigaos | amigados)
2390ea508b1Smrg				basic_machine=m68k-unknown
2400ea508b1Smrg				basic_os=amigaos
2410ea508b1Smrg				;;
2420ea508b1Smrg			amigaunix | amix)
2430ea508b1Smrg				basic_machine=m68k-unknown
2440ea508b1Smrg				basic_os=sysv4
2450ea508b1Smrg				;;
2460ea508b1Smrg			apollo68)
2470ea508b1Smrg				basic_machine=m68k-apollo
2480ea508b1Smrg				basic_os=sysv
2490ea508b1Smrg				;;
2500ea508b1Smrg			apollo68bsd)
2510ea508b1Smrg				basic_machine=m68k-apollo
2520ea508b1Smrg				basic_os=bsd
2530ea508b1Smrg				;;
2540ea508b1Smrg			aros)
2550ea508b1Smrg				basic_machine=i386-pc
2560ea508b1Smrg				basic_os=aros
2570ea508b1Smrg				;;
2580ea508b1Smrg			aux)
2590ea508b1Smrg				basic_machine=m68k-apple
2600ea508b1Smrg				basic_os=aux
2610ea508b1Smrg				;;
2620ea508b1Smrg			balance)
2630ea508b1Smrg				basic_machine=ns32k-sequent
2640ea508b1Smrg				basic_os=dynix
2650ea508b1Smrg				;;
2660ea508b1Smrg			blackfin)
2670ea508b1Smrg				basic_machine=bfin-unknown
2680ea508b1Smrg				basic_os=linux
2690ea508b1Smrg				;;
2700ea508b1Smrg			cegcc)
2710ea508b1Smrg				basic_machine=arm-unknown
2720ea508b1Smrg				basic_os=cegcc
2730ea508b1Smrg				;;
2740ea508b1Smrg			convex-c1)
2750ea508b1Smrg				basic_machine=c1-convex
2760ea508b1Smrg				basic_os=bsd
2770ea508b1Smrg				;;
2780ea508b1Smrg			convex-c2)
2790ea508b1Smrg				basic_machine=c2-convex
2800ea508b1Smrg				basic_os=bsd
2810ea508b1Smrg				;;
2820ea508b1Smrg			convex-c32)
2830ea508b1Smrg				basic_machine=c32-convex
2840ea508b1Smrg				basic_os=bsd
2850ea508b1Smrg				;;
2860ea508b1Smrg			convex-c34)
2870ea508b1Smrg				basic_machine=c34-convex
2880ea508b1Smrg				basic_os=bsd
2890ea508b1Smrg				;;
2900ea508b1Smrg			convex-c38)
2910ea508b1Smrg				basic_machine=c38-convex
2920ea508b1Smrg				basic_os=bsd
2930ea508b1Smrg				;;
2940ea508b1Smrg			cray)
2950ea508b1Smrg				basic_machine=j90-cray
2960ea508b1Smrg				basic_os=unicos
2970ea508b1Smrg				;;
2980ea508b1Smrg			crds | unos)
2990ea508b1Smrg				basic_machine=m68k-crds
3000ea508b1Smrg				basic_os=
3010ea508b1Smrg				;;
3020ea508b1Smrg			da30)
3030ea508b1Smrg				basic_machine=m68k-da30
3040ea508b1Smrg				basic_os=
3050ea508b1Smrg				;;
3060ea508b1Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3070ea508b1Smrg				basic_machine=mips-dec
3080ea508b1Smrg				basic_os=
3090ea508b1Smrg				;;
3100ea508b1Smrg			delta88)
3110ea508b1Smrg				basic_machine=m88k-motorola
3120ea508b1Smrg				basic_os=sysv3
3130ea508b1Smrg				;;
3140ea508b1Smrg			dicos)
3150ea508b1Smrg				basic_machine=i686-pc
3160ea508b1Smrg				basic_os=dicos
3170ea508b1Smrg				;;
3180ea508b1Smrg			djgpp)
3190ea508b1Smrg				basic_machine=i586-pc
3200ea508b1Smrg				basic_os=msdosdjgpp
3210ea508b1Smrg				;;
3220ea508b1Smrg			ebmon29k)
3230ea508b1Smrg				basic_machine=a29k-amd
3240ea508b1Smrg				basic_os=ebmon
3250ea508b1Smrg				;;
3260ea508b1Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3270ea508b1Smrg				basic_machine=m68k-ericsson
3280ea508b1Smrg				basic_os=ose
3290ea508b1Smrg				;;
3300ea508b1Smrg			gmicro)
3310ea508b1Smrg				basic_machine=tron-gmicro
3320ea508b1Smrg				basic_os=sysv
3330ea508b1Smrg				;;
3340ea508b1Smrg			go32)
3350ea508b1Smrg				basic_machine=i386-pc
3360ea508b1Smrg				basic_os=go32
3370ea508b1Smrg				;;
3380ea508b1Smrg			h8300hms)
3390ea508b1Smrg				basic_machine=h8300-hitachi
3400ea508b1Smrg				basic_os=hms
3410ea508b1Smrg				;;
3420ea508b1Smrg			h8300xray)
3430ea508b1Smrg				basic_machine=h8300-hitachi
3440ea508b1Smrg				basic_os=xray
3450ea508b1Smrg				;;
3460ea508b1Smrg			h8500hms)
3470ea508b1Smrg				basic_machine=h8500-hitachi
3480ea508b1Smrg				basic_os=hms
3490ea508b1Smrg				;;
3500ea508b1Smrg			harris)
3510ea508b1Smrg				basic_machine=m88k-harris
3520ea508b1Smrg				basic_os=sysv3
3530ea508b1Smrg				;;
3540ea508b1Smrg			hp300 | hp300hpux)
3550ea508b1Smrg				basic_machine=m68k-hp
3560ea508b1Smrg				basic_os=hpux
3570ea508b1Smrg				;;
3580ea508b1Smrg			hp300bsd)
3590ea508b1Smrg				basic_machine=m68k-hp
3600ea508b1Smrg				basic_os=bsd
3610ea508b1Smrg				;;
3620ea508b1Smrg			hppaosf)
3630ea508b1Smrg				basic_machine=hppa1.1-hp
3640ea508b1Smrg				basic_os=osf
3650ea508b1Smrg				;;
3660ea508b1Smrg			hppro)
3670ea508b1Smrg				basic_machine=hppa1.1-hp
3680ea508b1Smrg				basic_os=proelf
3690ea508b1Smrg				;;
3700ea508b1Smrg			i386mach)
3710ea508b1Smrg				basic_machine=i386-mach
3720ea508b1Smrg				basic_os=mach
3730ea508b1Smrg				;;
3740ea508b1Smrg			isi68 | isi)
3750ea508b1Smrg				basic_machine=m68k-isi
3760ea508b1Smrg				basic_os=sysv
3770ea508b1Smrg				;;
3780ea508b1Smrg			m68knommu)
3790ea508b1Smrg				basic_machine=m68k-unknown
3800ea508b1Smrg				basic_os=linux
3810ea508b1Smrg				;;
3820ea508b1Smrg			magnum | m3230)
3830ea508b1Smrg				basic_machine=mips-mips
3840ea508b1Smrg				basic_os=sysv
3850ea508b1Smrg				;;
3860ea508b1Smrg			merlin)
3870ea508b1Smrg				basic_machine=ns32k-utek
3880ea508b1Smrg				basic_os=sysv
3890ea508b1Smrg				;;
3900ea508b1Smrg			mingw64)
3910ea508b1Smrg				basic_machine=x86_64-pc
3920ea508b1Smrg				basic_os=mingw64
3930ea508b1Smrg				;;
3940ea508b1Smrg			mingw32)
3950ea508b1Smrg				basic_machine=i686-pc
3960ea508b1Smrg				basic_os=mingw32
3970ea508b1Smrg				;;
3980ea508b1Smrg			mingw32ce)
3990ea508b1Smrg				basic_machine=arm-unknown
4000ea508b1Smrg				basic_os=mingw32ce
4010ea508b1Smrg				;;
4020ea508b1Smrg			monitor)
4030ea508b1Smrg				basic_machine=m68k-rom68k
4040ea508b1Smrg				basic_os=coff
4050ea508b1Smrg				;;
4060ea508b1Smrg			morphos)
4070ea508b1Smrg				basic_machine=powerpc-unknown
4080ea508b1Smrg				basic_os=morphos
4090ea508b1Smrg				;;
4100ea508b1Smrg			moxiebox)
4110ea508b1Smrg				basic_machine=moxie-unknown
4120ea508b1Smrg				basic_os=moxiebox
4130ea508b1Smrg				;;
4140ea508b1Smrg			msdos)
4150ea508b1Smrg				basic_machine=i386-pc
4160ea508b1Smrg				basic_os=msdos
4170ea508b1Smrg				;;
4180ea508b1Smrg			msys)
4190ea508b1Smrg				basic_machine=i686-pc
4200ea508b1Smrg				basic_os=msys
4210ea508b1Smrg				;;
4220ea508b1Smrg			mvs)
4230ea508b1Smrg				basic_machine=i370-ibm
4240ea508b1Smrg				basic_os=mvs
4250ea508b1Smrg				;;
4260ea508b1Smrg			nacl)
4270ea508b1Smrg				basic_machine=le32-unknown
4280ea508b1Smrg				basic_os=nacl
4290ea508b1Smrg				;;
4300ea508b1Smrg			ncr3000)
4310ea508b1Smrg				basic_machine=i486-ncr
4320ea508b1Smrg				basic_os=sysv4
4330ea508b1Smrg				;;
4340ea508b1Smrg			netbsd386)
4350ea508b1Smrg				basic_machine=i386-pc
4360ea508b1Smrg				basic_os=netbsd
4370ea508b1Smrg				;;
4380ea508b1Smrg			netwinder)
4390ea508b1Smrg				basic_machine=armv4l-rebel
4400ea508b1Smrg				basic_os=linux
4410ea508b1Smrg				;;
4420ea508b1Smrg			news | news700 | news800 | news900)
4430ea508b1Smrg				basic_machine=m68k-sony
4440ea508b1Smrg				basic_os=newsos
4450ea508b1Smrg				;;
4460ea508b1Smrg			news1000)
4470ea508b1Smrg				basic_machine=m68030-sony
4480ea508b1Smrg				basic_os=newsos
4490ea508b1Smrg				;;
4500ea508b1Smrg			necv70)
4510ea508b1Smrg				basic_machine=v70-nec
4520ea508b1Smrg				basic_os=sysv
4530ea508b1Smrg				;;
4540ea508b1Smrg			nh3000)
4550ea508b1Smrg				basic_machine=m68k-harris
4560ea508b1Smrg				basic_os=cxux
4570ea508b1Smrg				;;
4580ea508b1Smrg			nh[45]000)
4590ea508b1Smrg				basic_machine=m88k-harris
4600ea508b1Smrg				basic_os=cxux
4610ea508b1Smrg				;;
4620ea508b1Smrg			nindy960)
4630ea508b1Smrg				basic_machine=i960-intel
4640ea508b1Smrg				basic_os=nindy
4650ea508b1Smrg				;;
4660ea508b1Smrg			mon960)
4670ea508b1Smrg				basic_machine=i960-intel
4680ea508b1Smrg				basic_os=mon960
4690ea508b1Smrg				;;
4700ea508b1Smrg			nonstopux)
4710ea508b1Smrg				basic_machine=mips-compaq
4720ea508b1Smrg				basic_os=nonstopux
4730ea508b1Smrg				;;
4740ea508b1Smrg			os400)
4750ea508b1Smrg				basic_machine=powerpc-ibm
4760ea508b1Smrg				basic_os=os400
4770ea508b1Smrg				;;
4780ea508b1Smrg			OSE68000 | ose68000)
4790ea508b1Smrg				basic_machine=m68000-ericsson
4800ea508b1Smrg				basic_os=ose
4810ea508b1Smrg				;;
4820ea508b1Smrg			os68k)
4830ea508b1Smrg				basic_machine=m68k-none
4840ea508b1Smrg				basic_os=os68k
4850ea508b1Smrg				;;
4860ea508b1Smrg			paragon)
4870ea508b1Smrg				basic_machine=i860-intel
4880ea508b1Smrg				basic_os=osf
4890ea508b1Smrg				;;
4900ea508b1Smrg			parisc)
4910ea508b1Smrg				basic_machine=hppa-unknown
4920ea508b1Smrg				basic_os=linux
4930ea508b1Smrg				;;
4940ea508b1Smrg			psp)
4950ea508b1Smrg				basic_machine=mipsallegrexel-sony
4960ea508b1Smrg				basic_os=psp
4970ea508b1Smrg				;;
4980ea508b1Smrg			pw32)
4990ea508b1Smrg				basic_machine=i586-unknown
5000ea508b1Smrg				basic_os=pw32
5010ea508b1Smrg				;;
5020ea508b1Smrg			rdos | rdos64)
5030ea508b1Smrg				basic_machine=x86_64-pc
5040ea508b1Smrg				basic_os=rdos
5050ea508b1Smrg				;;
5060ea508b1Smrg			rdos32)
5070ea508b1Smrg				basic_machine=i386-pc
5080ea508b1Smrg				basic_os=rdos
5090ea508b1Smrg				;;
5100ea508b1Smrg			rom68k)
5110ea508b1Smrg				basic_machine=m68k-rom68k
5120ea508b1Smrg				basic_os=coff
5130ea508b1Smrg				;;
5140ea508b1Smrg			sa29200)
5150ea508b1Smrg				basic_machine=a29k-amd
5160ea508b1Smrg				basic_os=udi
5170ea508b1Smrg				;;
5180ea508b1Smrg			sei)
5190ea508b1Smrg				basic_machine=mips-sei
5200ea508b1Smrg				basic_os=seiux
5210ea508b1Smrg				;;
5220ea508b1Smrg			sequent)
5230ea508b1Smrg				basic_machine=i386-sequent
5240ea508b1Smrg				basic_os=
5250ea508b1Smrg				;;
5260ea508b1Smrg			sps7)
5270ea508b1Smrg				basic_machine=m68k-bull
5280ea508b1Smrg				basic_os=sysv2
5290ea508b1Smrg				;;
5300ea508b1Smrg			st2000)
5310ea508b1Smrg				basic_machine=m68k-tandem
5320ea508b1Smrg				basic_os=
5330ea508b1Smrg				;;
5340ea508b1Smrg			stratus)
5350ea508b1Smrg				basic_machine=i860-stratus
5360ea508b1Smrg				basic_os=sysv4
5370ea508b1Smrg				;;
5380ea508b1Smrg			sun2)
5390ea508b1Smrg				basic_machine=m68000-sun
5400ea508b1Smrg				basic_os=
5410ea508b1Smrg				;;
5420ea508b1Smrg			sun2os3)
5430ea508b1Smrg				basic_machine=m68000-sun
5440ea508b1Smrg				basic_os=sunos3
5450ea508b1Smrg				;;
5460ea508b1Smrg			sun2os4)
5470ea508b1Smrg				basic_machine=m68000-sun
5480ea508b1Smrg				basic_os=sunos4
5490ea508b1Smrg				;;
5500ea508b1Smrg			sun3)
5510ea508b1Smrg				basic_machine=m68k-sun
5520ea508b1Smrg				basic_os=
5530ea508b1Smrg				;;
5540ea508b1Smrg			sun3os3)
5550ea508b1Smrg				basic_machine=m68k-sun
5560ea508b1Smrg				basic_os=sunos3
5570ea508b1Smrg				;;
5580ea508b1Smrg			sun3os4)
5590ea508b1Smrg				basic_machine=m68k-sun
5600ea508b1Smrg				basic_os=sunos4
5610ea508b1Smrg				;;
5620ea508b1Smrg			sun4)
5630ea508b1Smrg				basic_machine=sparc-sun
5640ea508b1Smrg				basic_os=
5650ea508b1Smrg				;;
5660ea508b1Smrg			sun4os3)
5670ea508b1Smrg				basic_machine=sparc-sun
5680ea508b1Smrg				basic_os=sunos3
5690ea508b1Smrg				;;
5700ea508b1Smrg			sun4os4)
5710ea508b1Smrg				basic_machine=sparc-sun
5720ea508b1Smrg				basic_os=sunos4
5730ea508b1Smrg				;;
5740ea508b1Smrg			sun4sol2)
5750ea508b1Smrg				basic_machine=sparc-sun
5760ea508b1Smrg				basic_os=solaris2
5770ea508b1Smrg				;;
5780ea508b1Smrg			sun386 | sun386i | roadrunner)
5790ea508b1Smrg				basic_machine=i386-sun
5800ea508b1Smrg				basic_os=
5810ea508b1Smrg				;;
5820ea508b1Smrg			sv1)
5830ea508b1Smrg				basic_machine=sv1-cray
5840ea508b1Smrg				basic_os=unicos
5850ea508b1Smrg				;;
5860ea508b1Smrg			symmetry)
5870ea508b1Smrg				basic_machine=i386-sequent
5880ea508b1Smrg				basic_os=dynix
5890ea508b1Smrg				;;
5900ea508b1Smrg			t3e)
5910ea508b1Smrg				basic_machine=alphaev5-cray
5920ea508b1Smrg				basic_os=unicos
5930ea508b1Smrg				;;
5940ea508b1Smrg			t90)
5950ea508b1Smrg				basic_machine=t90-cray
5960ea508b1Smrg				basic_os=unicos
5970ea508b1Smrg				;;
5980ea508b1Smrg			toad1)
5990ea508b1Smrg				basic_machine=pdp10-xkl
6000ea508b1Smrg				basic_os=tops20
6010ea508b1Smrg				;;
6020ea508b1Smrg			tpf)
6030ea508b1Smrg				basic_machine=s390x-ibm
6040ea508b1Smrg				basic_os=tpf
6050ea508b1Smrg				;;
6060ea508b1Smrg			udi29k)
6070ea508b1Smrg				basic_machine=a29k-amd
6080ea508b1Smrg				basic_os=udi
6090ea508b1Smrg				;;
6100ea508b1Smrg			ultra3)
6110ea508b1Smrg				basic_machine=a29k-nyu
6120ea508b1Smrg				basic_os=sym1
6130ea508b1Smrg				;;
6140ea508b1Smrg			v810 | necv810)
6150ea508b1Smrg				basic_machine=v810-nec
6160ea508b1Smrg				basic_os=none
6170ea508b1Smrg				;;
6180ea508b1Smrg			vaxv)
6190ea508b1Smrg				basic_machine=vax-dec
6200ea508b1Smrg				basic_os=sysv
6210ea508b1Smrg				;;
6220ea508b1Smrg			vms)
6230ea508b1Smrg				basic_machine=vax-dec
6240ea508b1Smrg				basic_os=vms
6250ea508b1Smrg				;;
6260ea508b1Smrg			vsta)
6270ea508b1Smrg				basic_machine=i386-pc
6280ea508b1Smrg				basic_os=vsta
6290ea508b1Smrg				;;
6300ea508b1Smrg			vxworks960)
6310ea508b1Smrg				basic_machine=i960-wrs
6320ea508b1Smrg				basic_os=vxworks
6330ea508b1Smrg				;;
6340ea508b1Smrg			vxworks68)
6350ea508b1Smrg				basic_machine=m68k-wrs
6360ea508b1Smrg				basic_os=vxworks
6370ea508b1Smrg				;;
6380ea508b1Smrg			vxworks29k)
6390ea508b1Smrg				basic_machine=a29k-wrs
6400ea508b1Smrg				basic_os=vxworks
6410ea508b1Smrg				;;
6420ea508b1Smrg			xbox)
6430ea508b1Smrg				basic_machine=i686-pc
6440ea508b1Smrg				basic_os=mingw32
6450ea508b1Smrg				;;
6460ea508b1Smrg			ymp)
6470ea508b1Smrg				basic_machine=ymp-cray
6480ea508b1Smrg				basic_os=unicos
6490ea508b1Smrg				;;
6500ea508b1Smrg			*)
6510ea508b1Smrg				basic_machine=$1
6520ea508b1Smrg				basic_os=
6530ea508b1Smrg				;;
6540ea508b1Smrg		esac
6557914d74bSmrg		;;
6567914d74bSmrgesac
6577914d74bSmrg
6580ea508b1Smrg# Decode 1-component or ad-hoc basic machines
6597914d74bSmrgcase $basic_machine in
6600ea508b1Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6610ea508b1Smrg	# some cases the only manufacturer, in others, it is the most popular.
6620ea508b1Smrg	w89k)
6630ea508b1Smrg		cpu=hppa1.1
6640ea508b1Smrg		vendor=winbond
6657914d74bSmrg		;;
6660ea508b1Smrg	op50n)
6670ea508b1Smrg		cpu=hppa1.1
6680ea508b1Smrg		vendor=oki
6697914d74bSmrg		;;
6700ea508b1Smrg	op60c)
6710ea508b1Smrg		cpu=hppa1.1
6720ea508b1Smrg		vendor=oki
6737914d74bSmrg		;;
6740ea508b1Smrg	ibm*)
6750ea508b1Smrg		cpu=i370
6760ea508b1Smrg		vendor=ibm
677e6d5e4e0Smrg		;;
6780ea508b1Smrg	orion105)
6790ea508b1Smrg		cpu=clipper
6800ea508b1Smrg		vendor=highlevel
681e6d5e4e0Smrg		;;
6820ea508b1Smrg	mac | mpw | mac-mpw)
6830ea508b1Smrg		cpu=m68k
6840ea508b1Smrg		vendor=apple
685e6d5e4e0Smrg		;;
6860ea508b1Smrg	pmac | pmac-mpw)
6870ea508b1Smrg		cpu=powerpc
6880ea508b1Smrg		vendor=apple
689e6d5e4e0Smrg		;;
690e6d5e4e0Smrg
6917914d74bSmrg	# Recognize the various machine names and aliases which stand
6927914d74bSmrg	# for a CPU type and a company and sometimes even an OS.
6937914d74bSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6940ea508b1Smrg		cpu=m68000
6950ea508b1Smrg		vendor=att
6967914d74bSmrg		;;
6977914d74bSmrg	3b*)
6980ea508b1Smrg		cpu=we32k
6990ea508b1Smrg		vendor=att
700e169010aSmrg		;;
701e8ead290Smrg	bluegene*)
7020ea508b1Smrg		cpu=powerpc
7030ea508b1Smrg		vendor=ibm
7040ea508b1Smrg		basic_os=cnk
7057914d74bSmrg		;;
7067914d74bSmrg	decsystem10* | dec10*)
7070ea508b1Smrg		cpu=pdp10
7080ea508b1Smrg		vendor=dec
7090ea508b1Smrg		basic_os=tops10
7107914d74bSmrg		;;
7117914d74bSmrg	decsystem20* | dec20*)
7120ea508b1Smrg		cpu=pdp10
7130ea508b1Smrg		vendor=dec
7140ea508b1Smrg		basic_os=tops20
7157914d74bSmrg		;;
7167914d74bSmrg	delta | 3300 | motorola-3300 | motorola-delta \
7177914d74bSmrg	      | 3300-motorola | delta-motorola)
7180ea508b1Smrg		cpu=m68k
7190ea508b1Smrg		vendor=motorola
7207914d74bSmrg		;;
721cdce750aSmrg	dpx2*)
7220ea508b1Smrg		cpu=m68k
7230ea508b1Smrg		vendor=bull
7240ea508b1Smrg		basic_os=sysv3
7257914d74bSmrg		;;
7267914d74bSmrg	encore | umax | mmax)
7270ea508b1Smrg		cpu=ns32k
7280ea508b1Smrg		vendor=encore
7297914d74bSmrg		;;
7300ea508b1Smrg	elxsi)
7310ea508b1Smrg		cpu=elxsi
7320ea508b1Smrg		vendor=elxsi
7330ea508b1Smrg		basic_os=${basic_os:-bsd}
7347914d74bSmrg		;;
7357914d74bSmrg	fx2800)
7360ea508b1Smrg		cpu=i860
7370ea508b1Smrg		vendor=alliant
7387914d74bSmrg		;;
7397914d74bSmrg	genix)
7400ea508b1Smrg		cpu=ns32k
7410ea508b1Smrg		vendor=ns
7427914d74bSmrg		;;
7437914d74bSmrg	h3050r* | hiux*)
7440ea508b1Smrg		cpu=hppa1.1
7450ea508b1Smrg		vendor=hitachi
7460ea508b1Smrg		basic_os=hiuxwe2
7477914d74bSmrg		;;
7487914d74bSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7490ea508b1Smrg		cpu=hppa1.0
7500ea508b1Smrg		vendor=hp
7517914d74bSmrg		;;
7527914d74bSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7530ea508b1Smrg		cpu=m68000
7540ea508b1Smrg		vendor=hp
7557914d74bSmrg		;;
7567914d74bSmrg	hp9k3[2-9][0-9])
7570ea508b1Smrg		cpu=m68k
7580ea508b1Smrg		vendor=hp
7597914d74bSmrg		;;
7607914d74bSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7610ea508b1Smrg		cpu=hppa1.0
7620ea508b1Smrg		vendor=hp
7637914d74bSmrg		;;
7647914d74bSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7650ea508b1Smrg		cpu=hppa1.1
7660ea508b1Smrg		vendor=hp
7677914d74bSmrg		;;
7687914d74bSmrg	hp9k78[0-9] | hp78[0-9])
7697914d74bSmrg		# FIXME: really hppa2.0-hp
7700ea508b1Smrg		cpu=hppa1.1
7710ea508b1Smrg		vendor=hp
7727914d74bSmrg		;;
7737914d74bSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7747914d74bSmrg		# FIXME: really hppa2.0-hp
7750ea508b1Smrg		cpu=hppa1.1
7760ea508b1Smrg		vendor=hp
7777914d74bSmrg		;;
7787914d74bSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7790ea508b1Smrg		cpu=hppa1.1
7800ea508b1Smrg		vendor=hp
7817914d74bSmrg		;;
7827914d74bSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7830ea508b1Smrg		cpu=hppa1.0
7840ea508b1Smrg		vendor=hp
7857914d74bSmrg		;;
7867914d74bSmrg	i*86v32)
7870ea508b1Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7880ea508b1Smrg		vendor=pc
7890ea508b1Smrg		basic_os=sysv32
7907914d74bSmrg		;;
7917914d74bSmrg	i*86v4*)
7920ea508b1Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7930ea508b1Smrg		vendor=pc
7940ea508b1Smrg		basic_os=sysv4
7957914d74bSmrg		;;
7967914d74bSmrg	i*86v)
7970ea508b1Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7980ea508b1Smrg		vendor=pc
7990ea508b1Smrg		basic_os=sysv
8007914d74bSmrg		;;
8017914d74bSmrg	i*86sol2)
8020ea508b1Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8030ea508b1Smrg		vendor=pc
8040ea508b1Smrg		basic_os=solaris2
8057914d74bSmrg		;;
8060ea508b1Smrg	j90 | j90-cray)
8070ea508b1Smrg		cpu=j90
8080ea508b1Smrg		vendor=cray
8090ea508b1Smrg		basic_os=${basic_os:-unicos}
8107914d74bSmrg		;;
8117914d74bSmrg	iris | iris4d)
8120ea508b1Smrg		cpu=mips
8130ea508b1Smrg		vendor=sgi
8140ea508b1Smrg		case $basic_os in
8150ea508b1Smrg		    irix*)
8167914d74bSmrg			;;
8177914d74bSmrg		    *)
8180ea508b1Smrg			basic_os=irix4
8197914d74bSmrg			;;
8207914d74bSmrg		esac
8217914d74bSmrg		;;
8227914d74bSmrg	miniframe)
8230ea508b1Smrg		cpu=m68000
8240ea508b1Smrg		vendor=convergent
8257914d74bSmrg		;;
8260ea508b1Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8270ea508b1Smrg		cpu=m68k
8280ea508b1Smrg		vendor=atari
8290ea508b1Smrg		basic_os=mint
8307914d74bSmrg		;;
8317914d74bSmrg	news-3600 | risc-news)
8320ea508b1Smrg		cpu=mips
8330ea508b1Smrg		vendor=sony
8340ea508b1Smrg		basic_os=newsos
8357914d74bSmrg		;;
836cdce750aSmrg	next | m*-next)
8370ea508b1Smrg		cpu=m68k
8380ea508b1Smrg		vendor=next
8390ea508b1Smrg		case $basic_os in
8400ea508b1Smrg		    openstep*)
8410ea508b1Smrg		        ;;
8420ea508b1Smrg		    nextstep*)
8437914d74bSmrg			;;
8440ea508b1Smrg		    ns2*)
8450ea508b1Smrg		      basic_os=nextstep2
8467914d74bSmrg			;;
8477914d74bSmrg		    *)
8480ea508b1Smrg		      basic_os=nextstep3
8497914d74bSmrg			;;
8507914d74bSmrg		esac
8517914d74bSmrg		;;
8527914d74bSmrg	np1)
8530ea508b1Smrg		cpu=np1
8540ea508b1Smrg		vendor=gould
855cdce750aSmrg		;;
8567914d74bSmrg	op50n-* | op60c-*)
8570ea508b1Smrg		cpu=hppa1.1
8580ea508b1Smrg		vendor=oki
8590ea508b1Smrg		basic_os=proelf
8607914d74bSmrg		;;
8617914d74bSmrg	pa-hitachi)
8620ea508b1Smrg		cpu=hppa1.1
8630ea508b1Smrg		vendor=hitachi
8640ea508b1Smrg		basic_os=hiuxwe2
865e169010aSmrg		;;
8667914d74bSmrg	pbd)
8670ea508b1Smrg		cpu=sparc
8680ea508b1Smrg		vendor=tti
8697914d74bSmrg		;;
8707914d74bSmrg	pbb)
8710ea508b1Smrg		cpu=m68k
8720ea508b1Smrg		vendor=tti
8737914d74bSmrg		;;
8740ea508b1Smrg	pc532)
8750ea508b1Smrg		cpu=ns32k
8760ea508b1Smrg		vendor=pc532
8777914d74bSmrg		;;
8787914d74bSmrg	pn)
8790ea508b1Smrg		cpu=pn
8800ea508b1Smrg		vendor=gould
8817914d74bSmrg		;;
8820ea508b1Smrg	power)
8830ea508b1Smrg		cpu=power
8840ea508b1Smrg		vendor=ibm
8857914d74bSmrg		;;
8860ea508b1Smrg	ps2)
8870ea508b1Smrg		cpu=i386
8880ea508b1Smrg		vendor=ibm
8897914d74bSmrg		;;
8900ea508b1Smrg	rm[46]00)
8910ea508b1Smrg		cpu=mips
8920ea508b1Smrg		vendor=siemens
8937914d74bSmrg		;;
8940ea508b1Smrg	rtpc | rtpc-*)
8950ea508b1Smrg		cpu=romp
8960ea508b1Smrg		vendor=ibm
8977914d74bSmrg		;;
8980ea508b1Smrg	sde)
8990ea508b1Smrg		cpu=mipsisa32
9000ea508b1Smrg		vendor=sde
9010ea508b1Smrg		basic_os=${basic_os:-elf}
9027914d74bSmrg		;;
9030ea508b1Smrg	simso-wrs)
9040ea508b1Smrg		cpu=sparclite
9050ea508b1Smrg		vendor=wrs
9060ea508b1Smrg		basic_os=vxworks
9077914d74bSmrg		;;
9080ea508b1Smrg	tower | tower-32)
9090ea508b1Smrg		cpu=m68k
9100ea508b1Smrg		vendor=ncr
9117914d74bSmrg		;;
9120ea508b1Smrg	vpp*|vx|vx-*)
9130ea508b1Smrg		cpu=f301
9140ea508b1Smrg		vendor=fujitsu
9157914d74bSmrg		;;
9160ea508b1Smrg	w65)
9170ea508b1Smrg		cpu=w65
9180ea508b1Smrg		vendor=wdc
919e6d5e4e0Smrg		;;
9200ea508b1Smrg	w89k-*)
9210ea508b1Smrg		cpu=hppa1.1
9220ea508b1Smrg		vendor=winbond
9230ea508b1Smrg		basic_os=proelf
9247914d74bSmrg		;;
9250ea508b1Smrg	none)
9260ea508b1Smrg		cpu=none
9270ea508b1Smrg		vendor=none
9287914d74bSmrg		;;
9290ea508b1Smrg	leon|leon[3-9])
9300ea508b1Smrg		cpu=sparc
9310ea508b1Smrg		vendor=$basic_machine
9327914d74bSmrg		;;
9330ea508b1Smrg	leon-*|leon[3-9]-*)
9340ea508b1Smrg		cpu=sparc
9350ea508b1Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9367914d74bSmrg		;;
9370ea508b1Smrg
9380ea508b1Smrg	*-*)
9390ea508b1Smrg		# shellcheck disable=SC2162
9400ea508b1Smrg		saved_IFS=$IFS
9410ea508b1Smrg		IFS="-" read cpu vendor <<EOF
9420ea508b1Smrg$basic_machine
9430ea508b1SmrgEOF
9440ea508b1Smrg		IFS=$saved_IFS
9457914d74bSmrg		;;
9460ea508b1Smrg	# We use `pc' rather than `unknown'
9470ea508b1Smrg	# because (1) that's what they normally are, and
9480ea508b1Smrg	# (2) the word "unknown" tends to confuse beginning users.
9490ea508b1Smrg	i*86 | x86_64)
9500ea508b1Smrg		cpu=$basic_machine
9510ea508b1Smrg		vendor=pc
9527914d74bSmrg		;;
9530ea508b1Smrg	# These rules are duplicated from below for sake of the special case above;
9540ea508b1Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9550ea508b1Smrg	pc98)
9560ea508b1Smrg		cpu=i386
9570ea508b1Smrg		vendor=pc
9587914d74bSmrg		;;
9590ea508b1Smrg	x64 | amd64)
9600ea508b1Smrg		cpu=x86_64
9610ea508b1Smrg		vendor=pc
9627914d74bSmrg		;;
9630ea508b1Smrg	# Recognize the basic CPU types without company name.
9640ea508b1Smrg	*)
9650ea508b1Smrg		cpu=$basic_machine
9660ea508b1Smrg		vendor=unknown
9677914d74bSmrg		;;
9680ea508b1Smrgesac
9690ea508b1Smrg
9700ea508b1Smrgunset -v basic_machine
9710ea508b1Smrg
9720ea508b1Smrg# Decode basic machines in the full and proper CPU-Company form.
9730ea508b1Smrgcase $cpu-$vendor in
9740ea508b1Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9750ea508b1Smrg	# some cases the only manufacturer, in others, it is the most popular.
9760ea508b1Smrg	craynv-unknown)
9770ea508b1Smrg		vendor=cray
9780ea508b1Smrg		basic_os=${basic_os:-unicosmp}
9797914d74bSmrg		;;
9800ea508b1Smrg	c90-unknown | c90-cray)
9810ea508b1Smrg		vendor=cray
9820ea508b1Smrg		basic_os=${Basic_os:-unicos}
9837914d74bSmrg		;;
9840ea508b1Smrg	fx80-unknown)
9850ea508b1Smrg		vendor=alliant
9867914d74bSmrg		;;
9870ea508b1Smrg	romp-unknown)
9880ea508b1Smrg		vendor=ibm
9897914d74bSmrg		;;
9900ea508b1Smrg	mmix-unknown)
9910ea508b1Smrg		vendor=knuth
9927914d74bSmrg		;;
9930ea508b1Smrg	microblaze-unknown | microblazeel-unknown)
9940ea508b1Smrg		vendor=xilinx
9957914d74bSmrg		;;
9960ea508b1Smrg	rs6000-unknown)
9970ea508b1Smrg		vendor=ibm
9987914d74bSmrg		;;
9990ea508b1Smrg	vax-unknown)
10000ea508b1Smrg		vendor=dec
10017914d74bSmrg		;;
10020ea508b1Smrg	pdp11-unknown)
10030ea508b1Smrg		vendor=dec
10047914d74bSmrg		;;
10050ea508b1Smrg	we32k-unknown)
10060ea508b1Smrg		vendor=att
1007e6d5e4e0Smrg		;;
10080ea508b1Smrg	cydra-unknown)
10090ea508b1Smrg		vendor=cydrome
10107914d74bSmrg		;;
10110ea508b1Smrg	i370-ibm*)
10120ea508b1Smrg		vendor=ibm
10137914d74bSmrg		;;
10140ea508b1Smrg	orion-unknown)
10150ea508b1Smrg		vendor=highlevel
10167914d74bSmrg		;;
10170ea508b1Smrg	xps-unknown | xps100-unknown)
10180ea508b1Smrg		cpu=xps100
10190ea508b1Smrg		vendor=honeywell
10207914d74bSmrg		;;
10210ea508b1Smrg
10220ea508b1Smrg	# Here we normalize CPU types with a missing or matching vendor
10230ea508b1Smrg	armh-unknown | armh-alt)
10240ea508b1Smrg		cpu=armv7l
10250ea508b1Smrg		vendor=alt
10260ea508b1Smrg		basic_os=${basic_os:-linux-gnueabihf}
10277914d74bSmrg		;;
10280ea508b1Smrg	dpx20-unknown | dpx20-bull)
10290ea508b1Smrg		cpu=rs6000
10300ea508b1Smrg		vendor=bull
10310ea508b1Smrg		basic_os=${basic_os:-bosx}
10327914d74bSmrg		;;
10330ea508b1Smrg
10340ea508b1Smrg	# Here we normalize CPU types irrespective of the vendor
10350ea508b1Smrg	amd64-*)
10360ea508b1Smrg		cpu=x86_64
10377914d74bSmrg		;;
10380ea508b1Smrg	blackfin-*)
10390ea508b1Smrg		cpu=bfin
10400ea508b1Smrg		basic_os=linux
10417914d74bSmrg		;;
10420ea508b1Smrg	c54x-*)
10430ea508b1Smrg		cpu=tic54x
10447914d74bSmrg		;;
10450ea508b1Smrg	c55x-*)
10460ea508b1Smrg		cpu=tic55x
10477914d74bSmrg		;;
10480ea508b1Smrg	c6x-*)
10490ea508b1Smrg		cpu=tic6x
10507914d74bSmrg		;;
10510ea508b1Smrg	e500v[12]-*)
10520ea508b1Smrg		cpu=powerpc
10530ea508b1Smrg		basic_os=${basic_os}"spe"
10547914d74bSmrg		;;
10550ea508b1Smrg	mips3*-*)
10560ea508b1Smrg		cpu=mips64
10577914d74bSmrg		;;
10580ea508b1Smrg	ms1-*)
10590ea508b1Smrg		cpu=mt
10607914d74bSmrg		;;
10610ea508b1Smrg	m68knommu-*)
10620ea508b1Smrg		cpu=m68k
10630ea508b1Smrg		basic_os=linux
10647914d74bSmrg		;;
10650ea508b1Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10660ea508b1Smrg		cpu=s12z
1067e169010aSmrg		;;
10680ea508b1Smrg	openrisc-*)
10690ea508b1Smrg		cpu=or32
10707914d74bSmrg		;;
10710ea508b1Smrg	parisc-*)
10720ea508b1Smrg		cpu=hppa
10730ea508b1Smrg		basic_os=linux
10747914d74bSmrg		;;
10750ea508b1Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10760ea508b1Smrg		cpu=i586
10777914d74bSmrg		;;
10786b7436aeSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
10790ea508b1Smrg		cpu=i686
10807914d74bSmrg		;;
10810ea508b1Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10820ea508b1Smrg		cpu=i686
10837914d74bSmrg		;;
10840ea508b1Smrg	pentium4-*)
10850ea508b1Smrg		cpu=i786
10867914d74bSmrg		;;
10870ea508b1Smrg	pc98-*)
10880ea508b1Smrg		cpu=i386
10897914d74bSmrg		;;
10900ea508b1Smrg	ppc-* | ppcbe-*)
10910ea508b1Smrg		cpu=powerpc
10927914d74bSmrg		;;
10930ea508b1Smrg	ppcle-* | powerpclittle-*)
10940ea508b1Smrg		cpu=powerpcle
10957914d74bSmrg		;;
10960ea508b1Smrg	ppc64-*)
10970ea508b1Smrg		cpu=powerpc64
10987914d74bSmrg		;;
10990ea508b1Smrg	ppc64le-* | powerpc64little-*)
11000ea508b1Smrg		cpu=powerpc64le
11017914d74bSmrg		;;
11020ea508b1Smrg	sb1-*)
11030ea508b1Smrg		cpu=mipsisa64sb1
11047914d74bSmrg		;;
11050ea508b1Smrg	sb1el-*)
11060ea508b1Smrg		cpu=mipsisa64sb1el
11077914d74bSmrg		;;
11080ea508b1Smrg	sh5e[lb]-*)
11090ea508b1Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11107914d74bSmrg		;;
11110ea508b1Smrg	spur-*)
11120ea508b1Smrg		cpu=spur
11137914d74bSmrg		;;
11140ea508b1Smrg	strongarm-* | thumb-*)
11150ea508b1Smrg		cpu=arm
11167914d74bSmrg		;;
11170ea508b1Smrg	tx39-*)
11180ea508b1Smrg		cpu=mipstx39
1119cdce750aSmrg		;;
11200ea508b1Smrg	tx39el-*)
11210ea508b1Smrg		cpu=mipstx39el
11227914d74bSmrg		;;
11230ea508b1Smrg	x64-*)
11240ea508b1Smrg		cpu=x86_64
11257914d74bSmrg		;;
1126e6d5e4e0Smrg	xscale-* | xscalee[bl]-*)
11270ea508b1Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11287914d74bSmrg		;;
11290ea508b1Smrg	arm64-* | aarch64le-*)
11300ea508b1Smrg		cpu=aarch64
11317914d74bSmrg		;;
11327914d74bSmrg
11330ea508b1Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11340ea508b1Smrg	# company names they are paired with.
11350ea508b1Smrg	cr16-*)
11360ea508b1Smrg		basic_os=${basic_os:-elf}
11377914d74bSmrg		;;
11380ea508b1Smrg	crisv32-* | etraxfs*-*)
11390ea508b1Smrg		cpu=crisv32
11400ea508b1Smrg		vendor=axis
11417914d74bSmrg		;;
11420ea508b1Smrg	cris-* | etrax*-*)
11430ea508b1Smrg		cpu=cris
11440ea508b1Smrg		vendor=axis
11457914d74bSmrg		;;
11460ea508b1Smrg	crx-*)
11470ea508b1Smrg		basic_os=${basic_os:-elf}
11487914d74bSmrg		;;
11490ea508b1Smrg	neo-tandem)
11500ea508b1Smrg		cpu=neo
11510ea508b1Smrg		vendor=tandem
11527914d74bSmrg		;;
11530ea508b1Smrg	nse-tandem)
11540ea508b1Smrg		cpu=nse
11550ea508b1Smrg		vendor=tandem
11567914d74bSmrg		;;
11570ea508b1Smrg	nsr-tandem)
11580ea508b1Smrg		cpu=nsr
11590ea508b1Smrg		vendor=tandem
11607914d74bSmrg		;;
11610ea508b1Smrg	nsv-tandem)
11620ea508b1Smrg		cpu=nsv
11630ea508b1Smrg		vendor=tandem
11647914d74bSmrg		;;
11650ea508b1Smrg	nsx-tandem)
11660ea508b1Smrg		cpu=nsx
11670ea508b1Smrg		vendor=tandem
11687914d74bSmrg		;;
11690ea508b1Smrg	mipsallegrexel-sony)
11700ea508b1Smrg		cpu=mipsallegrexel
11710ea508b1Smrg		vendor=sony
11727914d74bSmrg		;;
11730ea508b1Smrg	tile*-*)
11740ea508b1Smrg		basic_os=${basic_os:-linux-gnu}
11757914d74bSmrg		;;
11760ea508b1Smrg
11777914d74bSmrg	*)
11780ea508b1Smrg		# Recognize the canonical CPU types that are allowed with any
11790ea508b1Smrg		# company name.
11800ea508b1Smrg		case $cpu in
11810ea508b1Smrg			1750a | 580 \
11820ea508b1Smrg			| a29k \
11830ea508b1Smrg			| aarch64 | aarch64_be \
11840ea508b1Smrg			| abacus \
11850ea508b1Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11860ea508b1Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11870ea508b1Smrg			| alphapca5[67] | alpha64pca5[67] \
11880ea508b1Smrg			| am33_2.0 \
11890ea508b1Smrg			| amdgcn \
11900ea508b1Smrg			| arc | arceb | arc32 | arc64 \
11910ea508b1Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11920ea508b1Smrg			| avr | avr32 \
11930ea508b1Smrg			| asmjs \
11940ea508b1Smrg			| ba \
11950ea508b1Smrg			| be32 | be64 \
11960ea508b1Smrg			| bfin | bpf | bs2000 \
11970ea508b1Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11980ea508b1Smrg			| c8051 | clipper | craynv | csky | cydra \
11990ea508b1Smrg			| d10v | d30v | dlx | dsp16xx \
12000ea508b1Smrg			| e2k | elxsi | epiphany \
12010ea508b1Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12020ea508b1Smrg			| h8300 | h8500 \
12030ea508b1Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12040ea508b1Smrg			| hexagon \
12050ea508b1Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12060ea508b1Smrg			| ip2k | iq2000 \
12070ea508b1Smrg			| k1om \
12080ea508b1Smrg			| le32 | le64 \
12090ea508b1Smrg			| lm32 \
12106b7436aeSmrg			| loongarch32 | loongarch64 | loongarchx32 \
12110ea508b1Smrg			| m32c | m32r | m32rle \
12120ea508b1Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12130ea508b1Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12140ea508b1Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12150ea508b1Smrg			| microblaze | microblazeel \
12160ea508b1Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12170ea508b1Smrg			| mips16 \
12180ea508b1Smrg			| mips64 | mips64eb | mips64el \
12190ea508b1Smrg			| mips64octeon | mips64octeonel \
12200ea508b1Smrg			| mips64orion | mips64orionel \
12210ea508b1Smrg			| mips64r5900 | mips64r5900el \
12220ea508b1Smrg			| mips64vr | mips64vrel \
12230ea508b1Smrg			| mips64vr4100 | mips64vr4100el \
12240ea508b1Smrg			| mips64vr4300 | mips64vr4300el \
12250ea508b1Smrg			| mips64vr5000 | mips64vr5000el \
12260ea508b1Smrg			| mips64vr5900 | mips64vr5900el \
12270ea508b1Smrg			| mipsisa32 | mipsisa32el \
12280ea508b1Smrg			| mipsisa32r2 | mipsisa32r2el \
12290ea508b1Smrg			| mipsisa32r3 | mipsisa32r3el \
12300ea508b1Smrg			| mipsisa32r5 | mipsisa32r5el \
12310ea508b1Smrg			| mipsisa32r6 | mipsisa32r6el \
12320ea508b1Smrg			| mipsisa64 | mipsisa64el \
12330ea508b1Smrg			| mipsisa64r2 | mipsisa64r2el \
12340ea508b1Smrg			| mipsisa64r3 | mipsisa64r3el \
12350ea508b1Smrg			| mipsisa64r5 | mipsisa64r5el \
12360ea508b1Smrg			| mipsisa64r6 | mipsisa64r6el \
12370ea508b1Smrg			| mipsisa64sb1 | mipsisa64sb1el \
12380ea508b1Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
12390ea508b1Smrg			| mipsr5900 | mipsr5900el \
12400ea508b1Smrg			| mipstx39 | mipstx39el \
12410ea508b1Smrg			| mmix \
12420ea508b1Smrg			| mn10200 | mn10300 \
12430ea508b1Smrg			| moxie \
12440ea508b1Smrg			| mt \
12450ea508b1Smrg			| msp430 \
12460ea508b1Smrg			| nds32 | nds32le | nds32be \
12470ea508b1Smrg			| nfp \
12480ea508b1Smrg			| nios | nios2 | nios2eb | nios2el \
12490ea508b1Smrg			| none | np1 | ns16k | ns32k | nvptx \
12500ea508b1Smrg			| open8 \
12510ea508b1Smrg			| or1k* \
12520ea508b1Smrg			| or32 \
12530ea508b1Smrg			| orion \
12540ea508b1Smrg			| picochip \
12550ea508b1Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12560ea508b1Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12570ea508b1Smrg			| pru \
12580ea508b1Smrg			| pyramid \
12590ea508b1Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12600ea508b1Smrg			| rl78 | romp | rs6000 | rx \
12610ea508b1Smrg			| s390 | s390x \
12620ea508b1Smrg			| score \
12630ea508b1Smrg			| sh | shl \
12640ea508b1Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12650ea508b1Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12660ea508b1Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12670ea508b1Smrg			| sparclite \
12680ea508b1Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12690ea508b1Smrg			| spu \
12700ea508b1Smrg			| tahoe \
12710ea508b1Smrg			| thumbv7* \
12720ea508b1Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12730ea508b1Smrg			| tron \
12740ea508b1Smrg			| ubicom32 \
12750ea508b1Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12760ea508b1Smrg			| vax \
12770ea508b1Smrg			| visium \
12780ea508b1Smrg			| w65 \
12790ea508b1Smrg			| wasm32 | wasm64 \
12800ea508b1Smrg			| we32k \
12810ea508b1Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12820ea508b1Smrg			| xstormy16 | xtensa* \
12830ea508b1Smrg			| ymp \
12840ea508b1Smrg			| z8k | z80)
12850ea508b1Smrg				;;
12860ea508b1Smrg
12870ea508b1Smrg			*)
12880ea508b1Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12890ea508b1Smrg				exit 1
12900ea508b1Smrg				;;
12910ea508b1Smrg		esac
12927914d74bSmrg		;;
12937914d74bSmrgesac
12947914d74bSmrg
12957914d74bSmrg# Here we canonicalize certain aliases for manufacturers.
12960ea508b1Smrgcase $vendor in
12970ea508b1Smrg	digital*)
12980ea508b1Smrg		vendor=dec
12997914d74bSmrg		;;
13000ea508b1Smrg	commodore*)
13010ea508b1Smrg		vendor=cbm
13027914d74bSmrg		;;
13037914d74bSmrg	*)
13047914d74bSmrg		;;
13057914d74bSmrgesac
13067914d74bSmrg
13077914d74bSmrg# Decode manufacturer-specific aliases for certain operating systems.
13087914d74bSmrg
13090ea508b1Smrgif test x$basic_os != x
13107914d74bSmrgthen
13110ea508b1Smrg
13120ea508b1Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13130ea508b1Smrg# set os.
13140ea508b1Smrgcase $basic_os in
13150ea508b1Smrg	gnu/linux*)
13160ea508b1Smrg		kernel=linux
13170ea508b1Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13180ea508b1Smrg		;;
13190ea508b1Smrg	os2-emx)
13200ea508b1Smrg		kernel=os2
13210ea508b1Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13220ea508b1Smrg		;;
13230ea508b1Smrg	nto-qnx*)
13240ea508b1Smrg		kernel=nto
13250ea508b1Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13260ea508b1Smrg		;;
13270ea508b1Smrg	*-*)
13280ea508b1Smrg		# shellcheck disable=SC2162
13290ea508b1Smrg		saved_IFS=$IFS
13300ea508b1Smrg		IFS="-" read kernel os <<EOF
13310ea508b1Smrg$basic_os
13320ea508b1SmrgEOF
13330ea508b1Smrg		IFS=$saved_IFS
13340ea508b1Smrg		;;
13350ea508b1Smrg	# Default OS when just kernel was specified
13360ea508b1Smrg	nto*)
13370ea508b1Smrg		kernel=nto
13380ea508b1Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13390ea508b1Smrg		;;
13400ea508b1Smrg	linux*)
13410ea508b1Smrg		kernel=linux
13420ea508b1Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13430ea508b1Smrg		;;
13440ea508b1Smrg	*)
13450ea508b1Smrg		kernel=
13460ea508b1Smrg		os=$basic_os
13470ea508b1Smrg		;;
13480ea508b1Smrgesac
13490ea508b1Smrg
13500ea508b1Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13510ea508b1Smrg# etc.)
13527914d74bSmrgcase $os in
1353cdce750aSmrg	# First match some system type aliases that might get confused
1354cdce750aSmrg	# with valid system types.
13550ea508b1Smrg	# solaris* is a basic system type, with this one exception.
13560ea508b1Smrg	auroraux)
13570ea508b1Smrg		os=auroraux
1358e8ead290Smrg		;;
13590ea508b1Smrg	bluegene*)
13600ea508b1Smrg		os=cnk
13617914d74bSmrg		;;
13620ea508b1Smrg	solaris1 | solaris1.*)
13630ea508b1Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13647914d74bSmrg		;;
13650ea508b1Smrg	solaris)
13660ea508b1Smrg		os=solaris2
13677914d74bSmrg		;;
13680ea508b1Smrg	unixware*)
13690ea508b1Smrg		os=sysv4.2uw
13707914d74bSmrg		;;
1371cdce750aSmrg	# es1800 is here to avoid being matched by es* (a different OS)
13720ea508b1Smrg	es1800*)
13730ea508b1Smrg		os=ose
1374cdce750aSmrg		;;
13750ea508b1Smrg	# Some version numbers need modification
13760ea508b1Smrg	chorusos*)
13770ea508b1Smrg		os=chorusos
13787914d74bSmrg		;;
13790ea508b1Smrg	isc)
13800ea508b1Smrg		os=isc2.2
13817914d74bSmrg		;;
13820ea508b1Smrg	sco6)
13830ea508b1Smrg		os=sco5v6
13847914d74bSmrg		;;
13850ea508b1Smrg	sco5)
13860ea508b1Smrg		os=sco3.2v5
13877914d74bSmrg		;;
13880ea508b1Smrg	sco4)
13890ea508b1Smrg		os=sco3.2v4
13907914d74bSmrg		;;
13910ea508b1Smrg	sco3.2.[4-9]*)
13920ea508b1Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13937914d74bSmrg		;;
13940ea508b1Smrg	sco*v* | scout)
13950ea508b1Smrg		# Don't match below
13967914d74bSmrg		;;
13970ea508b1Smrg	sco*)
13980ea508b1Smrg		os=sco3.2v2
13997914d74bSmrg		;;
14000ea508b1Smrg	psos*)
14010ea508b1Smrg		os=psos
14027914d74bSmrg		;;
14030ea508b1Smrg	qnx*)
14040ea508b1Smrg		os=qnx
14057914d74bSmrg		;;
14060ea508b1Smrg	hiux*)
14070ea508b1Smrg		os=hiuxwe2
14087914d74bSmrg		;;
14090ea508b1Smrg	lynx*178)
14100ea508b1Smrg		os=lynxos178
14117914d74bSmrg		;;
14120ea508b1Smrg	lynx*5)
14130ea508b1Smrg		os=lynxos5
14147914d74bSmrg		;;
14150ea508b1Smrg	lynxos*)
14160ea508b1Smrg		# don't get caught up in next wildcard
14177914d74bSmrg		;;
14180ea508b1Smrg	lynx*)
14190ea508b1Smrg		os=lynxos
14207914d74bSmrg		;;
14210ea508b1Smrg	mac[0-9]*)
14220ea508b1Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14237914d74bSmrg		;;
14240ea508b1Smrg	opened*)
14250ea508b1Smrg		os=openedition
14267914d74bSmrg		;;
14270ea508b1Smrg	os400*)
14280ea508b1Smrg		os=os400
14297914d74bSmrg		;;
14300ea508b1Smrg	sunos5*)
14310ea508b1Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
14327914d74bSmrg		;;
14330ea508b1Smrg	sunos6*)
14340ea508b1Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14357914d74bSmrg		;;
14360ea508b1Smrg	wince*)
14370ea508b1Smrg		os=wince
14387914d74bSmrg		;;
14390ea508b1Smrg	utek*)
14400ea508b1Smrg		os=bsd
14417914d74bSmrg		;;
14420ea508b1Smrg	dynix*)
14430ea508b1Smrg		os=bsd
14440ea508b1Smrg		;;
14450ea508b1Smrg	acis*)
14460ea508b1Smrg		os=aos
14470ea508b1Smrg		;;
14480ea508b1Smrg	atheos*)
14490ea508b1Smrg		os=atheos
14500ea508b1Smrg		;;
14510ea508b1Smrg	syllable*)
14520ea508b1Smrg		os=syllable
14537914d74bSmrg		;;
14540ea508b1Smrg	386bsd)
14550ea508b1Smrg		os=bsd
14560ea508b1Smrg		;;
14570ea508b1Smrg	ctix* | uts*)
14580ea508b1Smrg		os=sysv
14597914d74bSmrg		;;
14600ea508b1Smrg	nova*)
14610ea508b1Smrg		os=rtmk-nova
14627914d74bSmrg		;;
14630ea508b1Smrg	ns2)
14640ea508b1Smrg		os=nextstep2
14650ea508b1Smrg		;;
14660ea508b1Smrg	# Preserve the version number of sinix5.
14670ea508b1Smrg	sinix5.*)
14680ea508b1Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14697914d74bSmrg		;;
14700ea508b1Smrg	sinix*)
14710ea508b1Smrg		os=sysv4
14727914d74bSmrg		;;
14730ea508b1Smrg	tpf*)
14740ea508b1Smrg		os=tpf
14757914d74bSmrg		;;
14760ea508b1Smrg	triton*)
14770ea508b1Smrg		os=sysv3
14787914d74bSmrg		;;
14790ea508b1Smrg	oss*)
14800ea508b1Smrg		os=sysv3
14817914d74bSmrg		;;
14820ea508b1Smrg	svr4*)
14830ea508b1Smrg		os=sysv4
14847914d74bSmrg		;;
14850ea508b1Smrg	svr3)
14860ea508b1Smrg		os=sysv3
14877914d74bSmrg		;;
14880ea508b1Smrg	sysvr4)
14890ea508b1Smrg		os=sysv4
14907914d74bSmrg		;;
14910ea508b1Smrg	ose*)
14920ea508b1Smrg		os=ose
14937914d74bSmrg		;;
14940ea508b1Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14950ea508b1Smrg		os=mint
1496e8ead290Smrg		;;
14970ea508b1Smrg	dicos*)
14980ea508b1Smrg		os=dicos
14990ea508b1Smrg		;;
15000ea508b1Smrg	pikeos*)
1501cdce750aSmrg		# Until real need of OS specific support for
1502cdce750aSmrg		# particular features comes up, bare metal
1503cdce750aSmrg		# configurations are quite functional.
15040ea508b1Smrg		case $cpu in
1505cdce750aSmrg		    arm*)
15060ea508b1Smrg			os=eabi
1507cdce750aSmrg			;;
1508cdce750aSmrg		    *)
15090ea508b1Smrg			os=elf
1510cdce750aSmrg			;;
1511cdce750aSmrg		esac
1512cdce750aSmrg		;;
15137914d74bSmrg	*)
15140ea508b1Smrg		# No normalization, but not necessarily accepted, that comes below.
15157914d74bSmrg		;;
15167914d74bSmrgesac
15170ea508b1Smrg
15187914d74bSmrgelse
15197914d74bSmrg
15207914d74bSmrg# Here we handle the default operating systems that come with various machines.
15217914d74bSmrg# The value should be what the vendor currently ships out the door with their
15227914d74bSmrg# machine or put another way, the most popular os provided with the machine.
15237914d74bSmrg
15247914d74bSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15257914d74bSmrg# "-sun"), then you have to tell the case statement up towards the top
15267914d74bSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15277914d74bSmrg# will signal an error saying that MANUFACTURER isn't an operating
15287914d74bSmrg# system, and we'll never get to this point.
15297914d74bSmrg
15300ea508b1Smrgkernel=
15310ea508b1Smrgcase $cpu-$vendor in
1532e6d5e4e0Smrg	score-*)
15330ea508b1Smrg		os=elf
15347914d74bSmrg		;;
1535e6d5e4e0Smrg	spu-*)
15360ea508b1Smrg		os=elf
15377914d74bSmrg		;;
15387914d74bSmrg	*-acorn)
15390ea508b1Smrg		os=riscix1.2
15407914d74bSmrg		;;
15417914d74bSmrg	arm*-rebel)
15420ea508b1Smrg		kernel=linux
15430ea508b1Smrg		os=gnu
15447914d74bSmrg		;;
15457914d74bSmrg	arm*-semi)
15460ea508b1Smrg		os=aout
15477914d74bSmrg		;;
1548e6d5e4e0Smrg	c4x-* | tic4x-*)
15490ea508b1Smrg		os=coff
1550e6d5e4e0Smrg		;;
15519d0ccd10Smrg	c8051-*)
15520ea508b1Smrg		os=elf
15530ea508b1Smrg		;;
15540ea508b1Smrg	clipper-intergraph)
15550ea508b1Smrg		os=clix
15569d0ccd10Smrg		;;
1557e6d5e4e0Smrg	hexagon-*)
15580ea508b1Smrg		os=elf
15597914d74bSmrg		;;
1560e8ead290Smrg	tic54x-*)
15610ea508b1Smrg		os=coff
1562e8ead290Smrg		;;
1563e8ead290Smrg	tic55x-*)
15640ea508b1Smrg		os=coff
1565e8ead290Smrg		;;
1566e8ead290Smrg	tic6x-*)
15670ea508b1Smrg		os=coff
1568e8ead290Smrg		;;
15697914d74bSmrg	# This must come before the *-dec entry.
15707914d74bSmrg	pdp10-*)
15710ea508b1Smrg		os=tops20
15727914d74bSmrg		;;
15737914d74bSmrg	pdp11-*)
15740ea508b1Smrg		os=none
15757914d74bSmrg		;;
15767914d74bSmrg	*-dec | vax-*)
15770ea508b1Smrg		os=ultrix4.2
15787914d74bSmrg		;;
15797914d74bSmrg	m68*-apollo)
15800ea508b1Smrg		os=domain
15817914d74bSmrg		;;
15827914d74bSmrg	i386-sun)
15830ea508b1Smrg		os=sunos4.0.2
15847914d74bSmrg		;;
15857914d74bSmrg	m68000-sun)
15860ea508b1Smrg		os=sunos3
15877914d74bSmrg		;;
15887914d74bSmrg	m68*-cisco)
15890ea508b1Smrg		os=aout
15907914d74bSmrg		;;
1591e6d5e4e0Smrg	mep-*)
15920ea508b1Smrg		os=elf
15937914d74bSmrg		;;
15947914d74bSmrg	mips*-cisco)
15950ea508b1Smrg		os=elf
15967914d74bSmrg		;;
15977914d74bSmrg	mips*-*)
15980ea508b1Smrg		os=elf
15997914d74bSmrg		;;
16007914d74bSmrg	or32-*)
16010ea508b1Smrg		os=coff
16027914d74bSmrg		;;
16037914d74bSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
16040ea508b1Smrg		os=sysv3
16057914d74bSmrg		;;
16067914d74bSmrg	sparc-* | *-sun)
16070ea508b1Smrg		os=sunos4.1.1
16087914d74bSmrg		;;
1609cdce750aSmrg	pru-*)
16100ea508b1Smrg		os=elf
1611cdce750aSmrg		;;
16127914d74bSmrg	*-be)
16130ea508b1Smrg		os=beos
16147914d74bSmrg		;;
16157914d74bSmrg	*-ibm)
16160ea508b1Smrg		os=aix
16177914d74bSmrg		;;
1618e6d5e4e0Smrg	*-knuth)
16190ea508b1Smrg		os=mmixware
16207914d74bSmrg		;;
16217914d74bSmrg	*-wec)
16220ea508b1Smrg		os=proelf
16237914d74bSmrg		;;
16247914d74bSmrg	*-winbond)
16250ea508b1Smrg		os=proelf
16267914d74bSmrg		;;
16277914d74bSmrg	*-oki)
16280ea508b1Smrg		os=proelf
16297914d74bSmrg		;;
16307914d74bSmrg	*-hp)
16310ea508b1Smrg		os=hpux
16327914d74bSmrg		;;
16337914d74bSmrg	*-hitachi)
16340ea508b1Smrg		os=hiux
16357914d74bSmrg		;;
16367914d74bSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16370ea508b1Smrg		os=sysv
16387914d74bSmrg		;;
16397914d74bSmrg	*-cbm)
16400ea508b1Smrg		os=amigaos
16417914d74bSmrg		;;
16427914d74bSmrg	*-dg)
16430ea508b1Smrg		os=dgux
16447914d74bSmrg		;;
16457914d74bSmrg	*-dolphin)
16460ea508b1Smrg		os=sysv3
16477914d74bSmrg		;;
16487914d74bSmrg	m68k-ccur)
16490ea508b1Smrg		os=rtu
16507914d74bSmrg		;;
16517914d74bSmrg	m88k-omron*)
16520ea508b1Smrg		os=luna
16537914d74bSmrg		;;
1654cdce750aSmrg	*-next)
16550ea508b1Smrg		os=nextstep
16567914d74bSmrg		;;
16577914d74bSmrg	*-sequent)
16580ea508b1Smrg		os=ptx
16597914d74bSmrg		;;
16607914d74bSmrg	*-crds)
16610ea508b1Smrg		os=unos
16627914d74bSmrg		;;
16637914d74bSmrg	*-ns)
16640ea508b1Smrg		os=genix
16657914d74bSmrg		;;
16667914d74bSmrg	i370-*)
16670ea508b1Smrg		os=mvs
16687914d74bSmrg		;;
16697914d74bSmrg	*-gould)
16700ea508b1Smrg		os=sysv
16717914d74bSmrg		;;
16727914d74bSmrg	*-highlevel)
16730ea508b1Smrg		os=bsd
16747914d74bSmrg		;;
16757914d74bSmrg	*-encore)
16760ea508b1Smrg		os=bsd
16777914d74bSmrg		;;
16787914d74bSmrg	*-sgi)
16790ea508b1Smrg		os=irix
16807914d74bSmrg		;;
16817914d74bSmrg	*-siemens)
16820ea508b1Smrg		os=sysv4
16837914d74bSmrg		;;
16847914d74bSmrg	*-masscomp)
16850ea508b1Smrg		os=rtu
16867914d74bSmrg		;;
16877914d74bSmrg	f30[01]-fujitsu | f700-fujitsu)
16880ea508b1Smrg		os=uxpv
16897914d74bSmrg		;;
16907914d74bSmrg	*-rom68k)
16910ea508b1Smrg		os=coff
16927914d74bSmrg		;;
16937914d74bSmrg	*-*bug)
16940ea508b1Smrg		os=coff
16957914d74bSmrg		;;
16967914d74bSmrg	*-apple)
16970ea508b1Smrg		os=macos
16987914d74bSmrg		;;
16997914d74bSmrg	*-atari*)
17000ea508b1Smrg		os=mint
17010ea508b1Smrg		;;
17020ea508b1Smrg	*-wrs)
17030ea508b1Smrg		os=vxworks
17047914d74bSmrg		;;
17057914d74bSmrg	*)
17060ea508b1Smrg		os=none
17077914d74bSmrg		;;
17087914d74bSmrgesac
17090ea508b1Smrg
17107914d74bSmrgfi
17117914d74bSmrg
17120ea508b1Smrg# Now, validate our (potentially fixed-up) OS.
17130ea508b1Smrgcase $os in
17140ea508b1Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17150ea508b1Smrg	musl* | newlib* | relibc* | uclibc*)
17160ea508b1Smrg		;;
17170ea508b1Smrg	# Likewise for "kernel-abi"
17180ea508b1Smrg	eabi* | gnueabi*)
17190ea508b1Smrg		;;
17200ea508b1Smrg	# VxWorks passes extra cpu info in the 4th filed.
17210ea508b1Smrg	simlinux | simwindows | spe)
17220ea508b1Smrg		;;
17230ea508b1Smrg	# Now accept the basic system types.
17240ea508b1Smrg	# The portable systems comes first.
17250ea508b1Smrg	# Each alternative MUST end in a * to match a version number.
17260ea508b1Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17270ea508b1Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17280ea508b1Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17290ea508b1Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17300ea508b1Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17310ea508b1Smrg	     | os9* | macos* | osx* | ios* \
17320ea508b1Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17330ea508b1Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17340ea508b1Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17350ea508b1Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17360ea508b1Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17370ea508b1Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17380ea508b1Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17390ea508b1Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17400ea508b1Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17410ea508b1Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17420ea508b1Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17430ea508b1Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17440ea508b1Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17450ea508b1Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17460ea508b1Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17470ea508b1Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17480ea508b1Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17490ea508b1Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17500ea508b1Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17510ea508b1Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17520ea508b1Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17530ea508b1Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17540ea508b1Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17550ea508b1Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17560ea508b1Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17576b7436aeSmrg	     | fiwix* )
17580ea508b1Smrg		;;
17590ea508b1Smrg	# This one is extra strict with allowed versions
17600ea508b1Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17610ea508b1Smrg		# Don't forget version if it is 3.2v4 or newer.
17620ea508b1Smrg		;;
17630ea508b1Smrg	none)
17640ea508b1Smrg		;;
17650ea508b1Smrg	*)
17660ea508b1Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17670ea508b1Smrg		exit 1
17680ea508b1Smrg		;;
17690ea508b1Smrgesac
17700ea508b1Smrg
17710ea508b1Smrg# As a final step for OS-related things, validate the OS-kernel combination
17720ea508b1Smrg# (given a valid OS), if there is a kernel.
17730ea508b1Smrgcase $kernel-$os in
17740ea508b1Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
17756b7436aeSmrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
17760ea508b1Smrg		;;
17770ea508b1Smrg	uclinux-uclibc* )
17780ea508b1Smrg		;;
17796b7436aeSmrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
17800ea508b1Smrg		# These are just libc implementations, not actual OSes, and thus
17810ea508b1Smrg		# require a kernel.
17820ea508b1Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17830ea508b1Smrg		exit 1
17840ea508b1Smrg		;;
17850ea508b1Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
17860ea508b1Smrg		;;
17870ea508b1Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
17880ea508b1Smrg		;;
17890ea508b1Smrg	nto-qnx*)
17900ea508b1Smrg		;;
17910ea508b1Smrg	os2-emx)
17920ea508b1Smrg		;;
17930ea508b1Smrg	*-eabi* | *-gnueabi*)
17940ea508b1Smrg		;;
17950ea508b1Smrg	-*)
17960ea508b1Smrg		# Blank kernel with real OS is always fine.
17970ea508b1Smrg		;;
17980ea508b1Smrg	*-*)
17990ea508b1Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18000ea508b1Smrg		exit 1
18010ea508b1Smrg		;;
18020ea508b1Smrgesac
18030ea508b1Smrg
18047914d74bSmrg# Here we handle the case where we know the os, and the CPU type, but not the
18057914d74bSmrg# manufacturer.  We pick the logical manufacturer.
18060ea508b1Smrgcase $vendor in
18070ea508b1Smrg	unknown)
18080ea508b1Smrg		case $cpu-$os in
18090ea508b1Smrg			*-riscix*)
18107914d74bSmrg				vendor=acorn
18117914d74bSmrg				;;
18120ea508b1Smrg			*-sunos*)
18137914d74bSmrg				vendor=sun
18147914d74bSmrg				;;
18150ea508b1Smrg			*-cnk* | *-aix*)
18167914d74bSmrg				vendor=ibm
18177914d74bSmrg				;;
18180ea508b1Smrg			*-beos*)
18197914d74bSmrg				vendor=be
18207914d74bSmrg				;;
18210ea508b1Smrg			*-hpux*)
18227914d74bSmrg				vendor=hp
18237914d74bSmrg				;;
18240ea508b1Smrg			*-mpeix*)
18257914d74bSmrg				vendor=hp
18267914d74bSmrg				;;
18270ea508b1Smrg			*-hiux*)
18287914d74bSmrg				vendor=hitachi
18297914d74bSmrg				;;
18300ea508b1Smrg			*-unos*)
18317914d74bSmrg				vendor=crds
18327914d74bSmrg				;;
18330ea508b1Smrg			*-dgux*)
18347914d74bSmrg				vendor=dg
18357914d74bSmrg				;;
18360ea508b1Smrg			*-luna*)
18377914d74bSmrg				vendor=omron
18387914d74bSmrg				;;
18390ea508b1Smrg			*-genix*)
18407914d74bSmrg				vendor=ns
18417914d74bSmrg				;;
18420ea508b1Smrg			*-clix*)
18430ea508b1Smrg				vendor=intergraph
18440ea508b1Smrg				;;
18450ea508b1Smrg			*-mvs* | *-opened*)
18460ea508b1Smrg				vendor=ibm
18470ea508b1Smrg				;;
18480ea508b1Smrg			*-os400*)
18497914d74bSmrg				vendor=ibm
18507914d74bSmrg				;;
18510ea508b1Smrg			s390-* | s390x-*)
18527914d74bSmrg				vendor=ibm
18537914d74bSmrg				;;
18540ea508b1Smrg			*-ptx*)
18557914d74bSmrg				vendor=sequent
18567914d74bSmrg				;;
18570ea508b1Smrg			*-tpf*)
18587914d74bSmrg				vendor=ibm
18597914d74bSmrg				;;
18600ea508b1Smrg			*-vxsim* | *-vxworks* | *-windiss*)
18617914d74bSmrg				vendor=wrs
18627914d74bSmrg				;;
18630ea508b1Smrg			*-aux*)
18647914d74bSmrg				vendor=apple
18657914d74bSmrg				;;
18660ea508b1Smrg			*-hms*)
18677914d74bSmrg				vendor=hitachi
18687914d74bSmrg				;;
18690ea508b1Smrg			*-mpw* | *-macos*)
18707914d74bSmrg				vendor=apple
18717914d74bSmrg				;;
18720ea508b1Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
18737914d74bSmrg				vendor=atari
18747914d74bSmrg				;;
18750ea508b1Smrg			*-vos*)
18767914d74bSmrg				vendor=stratus
18777914d74bSmrg				;;
18787914d74bSmrg		esac
18797914d74bSmrg		;;
18807914d74bSmrgesac
18817914d74bSmrg
18820ea508b1Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
18837914d74bSmrgexit
18847914d74bSmrg
18857914d74bSmrg# Local variables:
18860ea508b1Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
18877914d74bSmrg# time-stamp-start: "timestamp='"
18887914d74bSmrg# time-stamp-format: "%:y-%02m-%02d"
18897914d74bSmrg# time-stamp-end: "'"
18907914d74bSmrg# End:
1891