1126a8a12Smrg#! /bin/sh
2126a8a12Smrg# Configuration validation subroutine script.
36bea0e4fSmrg#   Copyright 1992-2024 Free Software Foundation, Inc.
4126a8a12Smrg
53fb97780Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
63fb97780Smrg
76bea0e4fSmrgtimestamp='2024-01-01'
8126a8a12Smrg
90a6b08f8Smrg# This file is free software; you can redistribute it and/or modify it
100a6b08f8Smrg# under the terms of the GNU General Public License as published by
116bea0e4fSmrg# the Free Software Foundation, either version 3 of the License, or
12126a8a12Smrg# (at your option) any later version.
13126a8a12Smrg#
140a6b08f8Smrg# This program is distributed in the hope that it will be useful, but
150a6b08f8Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
160a6b08f8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
170a6b08f8Smrg# General Public License for more details.
18126a8a12Smrg#
19126a8a12Smrg# You should have received a copy of the GNU General Public License
20300346aeSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21126a8a12Smrg#
22126a8a12Smrg# As a special exception to the GNU General Public License, if you
23126a8a12Smrg# distribute this file as part of a program that contains a
24126a8a12Smrg# configuration script generated by Autoconf, you may include it under
250a6b08f8Smrg# the same distribution terms that you use for the rest of that
260a6b08f8Smrg# program.  This Exception is an additional permission under section 7
270a6b08f8Smrg# of the GNU General Public License, version 3 ("GPLv3").
28126a8a12Smrg
29126a8a12Smrg
30300346aeSmrg# Please send patches to <config-patches@gnu.org>.
31126a8a12Smrg#
32126a8a12Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33126a8a12Smrg# Supply the specified configuration type as an argument.
34126a8a12Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35126a8a12Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36126a8a12Smrg
37555991fdSmrg# You can get the latest version of this script from:
383fb97780Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39555991fdSmrg
40126a8a12Smrg# This file is supposed to be the same for all GNU packages
41126a8a12Smrg# and recognize all the CPU types, system types and aliases
42126a8a12Smrg# that are meaningful with *any* GNU software.
43126a8a12Smrg# Each package is responsible for reporting which valid configurations
44126a8a12Smrg# it does not support.  The user should be able to distinguish
45126a8a12Smrg# a failure to support a valid configuration from a meaningless
46126a8a12Smrg# configuration.
47126a8a12Smrg
48126a8a12Smrg# The goal of this file is to map all the various variations of a given
49126a8a12Smrg# machine specification into a single specification in the form:
50126a8a12Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51126a8a12Smrg# or in some cases, the newer four-part form:
52126a8a12Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53126a8a12Smrg# It is wrong to echo any other type of specification.
54126a8a12Smrg
553fb97780Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
563fb97780Smrg# about features and limitations of the classic Bourne shell that were
573fb97780Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
583fb97780Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
593fb97780Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
603fb97780Smrg# have a pre-POSIX /bin/sh.
613fb97780Smrg
62126a8a12Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63126a8a12Smrg
64126a8a12Smrgusage="\
65300346aeSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66126a8a12Smrg
67126a8a12SmrgCanonicalize a configuration name.
68126a8a12Smrg
69300346aeSmrgOptions:
70126a8a12Smrg  -h, --help         print this help, then exit
71126a8a12Smrg  -t, --time-stamp   print date of last modification, then exit
72126a8a12Smrg  -v, --version      print version number, then exit
73126a8a12Smrg
74126a8a12SmrgReport bugs and patches to <config-patches@gnu.org>."
75126a8a12Smrg
76126a8a12Smrgversion="\
77126a8a12SmrgGNU config.sub ($timestamp)
78126a8a12Smrg
796bea0e4fSmrgCopyright 1992-2024 Free Software Foundation, Inc.
80126a8a12Smrg
81126a8a12SmrgThis is free software; see the source for copying conditions.  There is NO
82126a8a12Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83126a8a12Smrg
84126a8a12Smrghelp="
856bea0e4fSmrgTry '$me --help' for more information."
86126a8a12Smrg
87126a8a12Smrg# Parse command line
88126a8a12Smrgwhile test $# -gt 0 ; do
89126a8a12Smrg  case $1 in
90126a8a12Smrg    --time-stamp | --time* | -t )
91126a8a12Smrg       echo "$timestamp" ; exit ;;
92126a8a12Smrg    --version | -v )
93126a8a12Smrg       echo "$version" ; exit ;;
94126a8a12Smrg    --help | --h* | -h )
95126a8a12Smrg       echo "$usage"; exit ;;
96126a8a12Smrg    -- )     # Stop option processing
97126a8a12Smrg       shift; break ;;
98126a8a12Smrg    - )	# Use stdin as input.
99126a8a12Smrg       break ;;
100126a8a12Smrg    -* )
1013fb97780Smrg       echo "$me: invalid option $1$help" >&2
102126a8a12Smrg       exit 1 ;;
103126a8a12Smrg
104126a8a12Smrg    *local*)
105126a8a12Smrg       # First pass through any local machine types.
106300346aeSmrg       echo "$1"
107126a8a12Smrg       exit ;;
108126a8a12Smrg
109126a8a12Smrg    * )
110126a8a12Smrg       break ;;
111126a8a12Smrg  esac
112126a8a12Smrgdone
113126a8a12Smrg
114126a8a12Smrgcase $# in
115126a8a12Smrg 0) echo "$me: missing argument$help" >&2
116126a8a12Smrg    exit 1;;
117126a8a12Smrg 1) ;;
118126a8a12Smrg *) echo "$me: too many arguments$help" >&2
119126a8a12Smrg    exit 1;;
120126a8a12Smrgesac
121126a8a12Smrg
1223fb97780Smrg# Split fields of configuration type
1233fb97780Smrg# shellcheck disable=SC2162
1243fb97780Smrgsaved_IFS=$IFS
1253fb97780SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1263fb97780Smrg$1
1273fb97780SmrgEOF
1283fb97780SmrgIFS=$saved_IFS
129126a8a12Smrg
1303fb97780Smrg# Separate into logical components for further validation
1313fb97780Smrgcase $1 in
1323fb97780Smrg	*-*-*-*-*)
1336bea0e4fSmrg		echo "Invalid configuration '$1': more than four components" >&2
1343fb97780Smrg		exit 1
1350a6b08f8Smrg		;;
1363fb97780Smrg	*-*-*-*)
1373fb97780Smrg		basic_machine=$field1-$field2
1383fb97780Smrg		basic_os=$field3-$field4
139126a8a12Smrg		;;
1403fb97780Smrg	*-*-*)
1413fb97780Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1423fb97780Smrg		# parts
1433fb97780Smrg		maybe_os=$field2-$field3
1443fb97780Smrg		case $maybe_os in
1453fb97780Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1463fb97780Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1473fb97780Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1486bea0e4fSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
1496bea0e4fSmrg			| windows-* )
1503fb97780Smrg				basic_machine=$field1
1513fb97780Smrg				basic_os=$maybe_os
1523fb97780Smrg				;;
1533fb97780Smrg			android-linux)
1543fb97780Smrg				basic_machine=$field1-unknown
1553fb97780Smrg				basic_os=linux-android
1563fb97780Smrg				;;
1573fb97780Smrg			*)
1583fb97780Smrg				basic_machine=$field1-$field2
1593fb97780Smrg				basic_os=$field3
1603fb97780Smrg				;;
1613fb97780Smrg		esac
162126a8a12Smrg		;;
1633fb97780Smrg	*-*)
1643fb97780Smrg		# A lone config we happen to match not fitting any pattern
1653fb97780Smrg		case $field1-$field2 in
1663fb97780Smrg			decstation-3100)
1673fb97780Smrg				basic_machine=mips-dec
1683fb97780Smrg				basic_os=
1693fb97780Smrg				;;
1703fb97780Smrg			*-*)
1713fb97780Smrg				# Second component is usually, but not always the OS
1723fb97780Smrg				case $field2 in
1733fb97780Smrg					# Prevent following clause from handling this valid os
1743fb97780Smrg					sun*os*)
1753fb97780Smrg						basic_machine=$field1
1763fb97780Smrg						basic_os=$field2
1773fb97780Smrg						;;
1783fb97780Smrg					zephyr*)
1793fb97780Smrg						basic_machine=$field1-unknown
1803fb97780Smrg						basic_os=$field2
1813fb97780Smrg						;;
1823fb97780Smrg					# Manufacturers
1833fb97780Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1843fb97780Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1853fb97780Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1863fb97780Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1873fb97780Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1883fb97780Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1893fb97780Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1903fb97780Smrg					| microblaze* | sim | cisco \
1913fb97780Smrg					| oki | wec | wrs | winbond)
1923fb97780Smrg						basic_machine=$field1-$field2
1933fb97780Smrg						basic_os=
1943fb97780Smrg						;;
1953fb97780Smrg					*)
1963fb97780Smrg						basic_machine=$field1
1973fb97780Smrg						basic_os=$field2
1983fb97780Smrg						;;
1993fb97780Smrg				esac
2003fb97780Smrg			;;
2013fb97780Smrg		esac
202126a8a12Smrg		;;
2033fb97780Smrg	*)
2043fb97780Smrg		# Convert single-component short-hands not valid as part of
2053fb97780Smrg		# multi-component configurations.
2063fb97780Smrg		case $field1 in
2073fb97780Smrg			386bsd)
2083fb97780Smrg				basic_machine=i386-pc
2093fb97780Smrg				basic_os=bsd
2103fb97780Smrg				;;
2113fb97780Smrg			a29khif)
2123fb97780Smrg				basic_machine=a29k-amd
2133fb97780Smrg				basic_os=udi
2143fb97780Smrg				;;
2153fb97780Smrg			adobe68k)
2163fb97780Smrg				basic_machine=m68010-adobe
2173fb97780Smrg				basic_os=scout
2183fb97780Smrg				;;
2193fb97780Smrg			alliant)
2203fb97780Smrg				basic_machine=fx80-alliant
2213fb97780Smrg				basic_os=
2223fb97780Smrg				;;
2233fb97780Smrg			altos | altos3068)
2243fb97780Smrg				basic_machine=m68k-altos
2253fb97780Smrg				basic_os=
2263fb97780Smrg				;;
2273fb97780Smrg			am29k)
2283fb97780Smrg				basic_machine=a29k-none
2293fb97780Smrg				basic_os=bsd
2303fb97780Smrg				;;
2313fb97780Smrg			amdahl)
2323fb97780Smrg				basic_machine=580-amdahl
2333fb97780Smrg				basic_os=sysv
2343fb97780Smrg				;;
2353fb97780Smrg			amiga)
2363fb97780Smrg				basic_machine=m68k-unknown
2373fb97780Smrg				basic_os=
2383fb97780Smrg				;;
2393fb97780Smrg			amigaos | amigados)
2403fb97780Smrg				basic_machine=m68k-unknown
2413fb97780Smrg				basic_os=amigaos
2423fb97780Smrg				;;
2433fb97780Smrg			amigaunix | amix)
2443fb97780Smrg				basic_machine=m68k-unknown
2453fb97780Smrg				basic_os=sysv4
2463fb97780Smrg				;;
2473fb97780Smrg			apollo68)
2483fb97780Smrg				basic_machine=m68k-apollo
2493fb97780Smrg				basic_os=sysv
2503fb97780Smrg				;;
2513fb97780Smrg			apollo68bsd)
2523fb97780Smrg				basic_machine=m68k-apollo
2533fb97780Smrg				basic_os=bsd
2543fb97780Smrg				;;
2553fb97780Smrg			aros)
2563fb97780Smrg				basic_machine=i386-pc
2573fb97780Smrg				basic_os=aros
2583fb97780Smrg				;;
2593fb97780Smrg			aux)
2603fb97780Smrg				basic_machine=m68k-apple
2613fb97780Smrg				basic_os=aux
2623fb97780Smrg				;;
2633fb97780Smrg			balance)
2643fb97780Smrg				basic_machine=ns32k-sequent
2653fb97780Smrg				basic_os=dynix
2663fb97780Smrg				;;
2673fb97780Smrg			blackfin)
2683fb97780Smrg				basic_machine=bfin-unknown
2693fb97780Smrg				basic_os=linux
2703fb97780Smrg				;;
2713fb97780Smrg			cegcc)
2723fb97780Smrg				basic_machine=arm-unknown
2733fb97780Smrg				basic_os=cegcc
2743fb97780Smrg				;;
2753fb97780Smrg			convex-c1)
2763fb97780Smrg				basic_machine=c1-convex
2773fb97780Smrg				basic_os=bsd
2783fb97780Smrg				;;
2793fb97780Smrg			convex-c2)
2803fb97780Smrg				basic_machine=c2-convex
2813fb97780Smrg				basic_os=bsd
2823fb97780Smrg				;;
2833fb97780Smrg			convex-c32)
2843fb97780Smrg				basic_machine=c32-convex
2853fb97780Smrg				basic_os=bsd
2863fb97780Smrg				;;
2873fb97780Smrg			convex-c34)
2883fb97780Smrg				basic_machine=c34-convex
2893fb97780Smrg				basic_os=bsd
2903fb97780Smrg				;;
2913fb97780Smrg			convex-c38)
2923fb97780Smrg				basic_machine=c38-convex
2933fb97780Smrg				basic_os=bsd
2943fb97780Smrg				;;
2953fb97780Smrg			cray)
2963fb97780Smrg				basic_machine=j90-cray
2973fb97780Smrg				basic_os=unicos
2983fb97780Smrg				;;
2993fb97780Smrg			crds | unos)
3003fb97780Smrg				basic_machine=m68k-crds
3013fb97780Smrg				basic_os=
3023fb97780Smrg				;;
3033fb97780Smrg			da30)
3043fb97780Smrg				basic_machine=m68k-da30
3053fb97780Smrg				basic_os=
3063fb97780Smrg				;;
3073fb97780Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3083fb97780Smrg				basic_machine=mips-dec
3093fb97780Smrg				basic_os=
3103fb97780Smrg				;;
3113fb97780Smrg			delta88)
3123fb97780Smrg				basic_machine=m88k-motorola
3133fb97780Smrg				basic_os=sysv3
3143fb97780Smrg				;;
3153fb97780Smrg			dicos)
3163fb97780Smrg				basic_machine=i686-pc
3173fb97780Smrg				basic_os=dicos
3183fb97780Smrg				;;
3193fb97780Smrg			djgpp)
3203fb97780Smrg				basic_machine=i586-pc
3213fb97780Smrg				basic_os=msdosdjgpp
3223fb97780Smrg				;;
3233fb97780Smrg			ebmon29k)
3243fb97780Smrg				basic_machine=a29k-amd
3253fb97780Smrg				basic_os=ebmon
3263fb97780Smrg				;;
3273fb97780Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3283fb97780Smrg				basic_machine=m68k-ericsson
3293fb97780Smrg				basic_os=ose
3303fb97780Smrg				;;
3313fb97780Smrg			gmicro)
3323fb97780Smrg				basic_machine=tron-gmicro
3333fb97780Smrg				basic_os=sysv
3343fb97780Smrg				;;
3353fb97780Smrg			go32)
3363fb97780Smrg				basic_machine=i386-pc
3373fb97780Smrg				basic_os=go32
3383fb97780Smrg				;;
3393fb97780Smrg			h8300hms)
3403fb97780Smrg				basic_machine=h8300-hitachi
3413fb97780Smrg				basic_os=hms
3423fb97780Smrg				;;
3433fb97780Smrg			h8300xray)
3443fb97780Smrg				basic_machine=h8300-hitachi
3453fb97780Smrg				basic_os=xray
3463fb97780Smrg				;;
3473fb97780Smrg			h8500hms)
3483fb97780Smrg				basic_machine=h8500-hitachi
3493fb97780Smrg				basic_os=hms
3503fb97780Smrg				;;
3513fb97780Smrg			harris)
3523fb97780Smrg				basic_machine=m88k-harris
3533fb97780Smrg				basic_os=sysv3
3543fb97780Smrg				;;
3553fb97780Smrg			hp300 | hp300hpux)
3563fb97780Smrg				basic_machine=m68k-hp
3573fb97780Smrg				basic_os=hpux
3583fb97780Smrg				;;
3593fb97780Smrg			hp300bsd)
3603fb97780Smrg				basic_machine=m68k-hp
3613fb97780Smrg				basic_os=bsd
3623fb97780Smrg				;;
3633fb97780Smrg			hppaosf)
3643fb97780Smrg				basic_machine=hppa1.1-hp
3653fb97780Smrg				basic_os=osf
3663fb97780Smrg				;;
3673fb97780Smrg			hppro)
3683fb97780Smrg				basic_machine=hppa1.1-hp
3693fb97780Smrg				basic_os=proelf
3703fb97780Smrg				;;
3713fb97780Smrg			i386mach)
3723fb97780Smrg				basic_machine=i386-mach
3733fb97780Smrg				basic_os=mach
3743fb97780Smrg				;;
3753fb97780Smrg			isi68 | isi)
3763fb97780Smrg				basic_machine=m68k-isi
3773fb97780Smrg				basic_os=sysv
3783fb97780Smrg				;;
3793fb97780Smrg			m68knommu)
3803fb97780Smrg				basic_machine=m68k-unknown
3813fb97780Smrg				basic_os=linux
3823fb97780Smrg				;;
3833fb97780Smrg			magnum | m3230)
3843fb97780Smrg				basic_machine=mips-mips
3853fb97780Smrg				basic_os=sysv
3863fb97780Smrg				;;
3873fb97780Smrg			merlin)
3883fb97780Smrg				basic_machine=ns32k-utek
3893fb97780Smrg				basic_os=sysv
3903fb97780Smrg				;;
3913fb97780Smrg			mingw64)
3923fb97780Smrg				basic_machine=x86_64-pc
3933fb97780Smrg				basic_os=mingw64
3943fb97780Smrg				;;
3953fb97780Smrg			mingw32)
3963fb97780Smrg				basic_machine=i686-pc
3973fb97780Smrg				basic_os=mingw32
3983fb97780Smrg				;;
3993fb97780Smrg			mingw32ce)
4003fb97780Smrg				basic_machine=arm-unknown
4013fb97780Smrg				basic_os=mingw32ce
4023fb97780Smrg				;;
4033fb97780Smrg			monitor)
4043fb97780Smrg				basic_machine=m68k-rom68k
4053fb97780Smrg				basic_os=coff
4063fb97780Smrg				;;
4073fb97780Smrg			morphos)
4083fb97780Smrg				basic_machine=powerpc-unknown
4093fb97780Smrg				basic_os=morphos
4103fb97780Smrg				;;
4113fb97780Smrg			moxiebox)
4123fb97780Smrg				basic_machine=moxie-unknown
4133fb97780Smrg				basic_os=moxiebox
4143fb97780Smrg				;;
4153fb97780Smrg			msdos)
4163fb97780Smrg				basic_machine=i386-pc
4173fb97780Smrg				basic_os=msdos
4183fb97780Smrg				;;
4193fb97780Smrg			msys)
4203fb97780Smrg				basic_machine=i686-pc
4213fb97780Smrg				basic_os=msys
4223fb97780Smrg				;;
4233fb97780Smrg			mvs)
4243fb97780Smrg				basic_machine=i370-ibm
4253fb97780Smrg				basic_os=mvs
4263fb97780Smrg				;;
4273fb97780Smrg			nacl)
4283fb97780Smrg				basic_machine=le32-unknown
4293fb97780Smrg				basic_os=nacl
4303fb97780Smrg				;;
4313fb97780Smrg			ncr3000)
4323fb97780Smrg				basic_machine=i486-ncr
4333fb97780Smrg				basic_os=sysv4
4343fb97780Smrg				;;
4353fb97780Smrg			netbsd386)
4363fb97780Smrg				basic_machine=i386-pc
4373fb97780Smrg				basic_os=netbsd
4383fb97780Smrg				;;
4393fb97780Smrg			netwinder)
4403fb97780Smrg				basic_machine=armv4l-rebel
4413fb97780Smrg				basic_os=linux
4423fb97780Smrg				;;
4433fb97780Smrg			news | news700 | news800 | news900)
4443fb97780Smrg				basic_machine=m68k-sony
4453fb97780Smrg				basic_os=newsos
4463fb97780Smrg				;;
4473fb97780Smrg			news1000)
4483fb97780Smrg				basic_machine=m68030-sony
4493fb97780Smrg				basic_os=newsos
4503fb97780Smrg				;;
4513fb97780Smrg			necv70)
4523fb97780Smrg				basic_machine=v70-nec
4533fb97780Smrg				basic_os=sysv
4543fb97780Smrg				;;
4553fb97780Smrg			nh3000)
4563fb97780Smrg				basic_machine=m68k-harris
4573fb97780Smrg				basic_os=cxux
4583fb97780Smrg				;;
4593fb97780Smrg			nh[45]000)
4603fb97780Smrg				basic_machine=m88k-harris
4613fb97780Smrg				basic_os=cxux
4623fb97780Smrg				;;
4633fb97780Smrg			nindy960)
4643fb97780Smrg				basic_machine=i960-intel
4653fb97780Smrg				basic_os=nindy
4663fb97780Smrg				;;
4673fb97780Smrg			mon960)
4683fb97780Smrg				basic_machine=i960-intel
4693fb97780Smrg				basic_os=mon960
4703fb97780Smrg				;;
4713fb97780Smrg			nonstopux)
4723fb97780Smrg				basic_machine=mips-compaq
4733fb97780Smrg				basic_os=nonstopux
4743fb97780Smrg				;;
4753fb97780Smrg			os400)
4763fb97780Smrg				basic_machine=powerpc-ibm
4773fb97780Smrg				basic_os=os400
4783fb97780Smrg				;;
4793fb97780Smrg			OSE68000 | ose68000)
4803fb97780Smrg				basic_machine=m68000-ericsson
4813fb97780Smrg				basic_os=ose
4823fb97780Smrg				;;
4833fb97780Smrg			os68k)
4843fb97780Smrg				basic_machine=m68k-none
4853fb97780Smrg				basic_os=os68k
4863fb97780Smrg				;;
4873fb97780Smrg			paragon)
4883fb97780Smrg				basic_machine=i860-intel
4893fb97780Smrg				basic_os=osf
4903fb97780Smrg				;;
4913fb97780Smrg			parisc)
4923fb97780Smrg				basic_machine=hppa-unknown
4933fb97780Smrg				basic_os=linux
4943fb97780Smrg				;;
4953fb97780Smrg			psp)
4963fb97780Smrg				basic_machine=mipsallegrexel-sony
4973fb97780Smrg				basic_os=psp
4983fb97780Smrg				;;
4993fb97780Smrg			pw32)
5003fb97780Smrg				basic_machine=i586-unknown
5013fb97780Smrg				basic_os=pw32
5023fb97780Smrg				;;
5033fb97780Smrg			rdos | rdos64)
5043fb97780Smrg				basic_machine=x86_64-pc
5053fb97780Smrg				basic_os=rdos
5063fb97780Smrg				;;
5073fb97780Smrg			rdos32)
5083fb97780Smrg				basic_machine=i386-pc
5093fb97780Smrg				basic_os=rdos
5103fb97780Smrg				;;
5113fb97780Smrg			rom68k)
5123fb97780Smrg				basic_machine=m68k-rom68k
5133fb97780Smrg				basic_os=coff
5143fb97780Smrg				;;
5153fb97780Smrg			sa29200)
5163fb97780Smrg				basic_machine=a29k-amd
5173fb97780Smrg				basic_os=udi
5183fb97780Smrg				;;
5193fb97780Smrg			sei)
5203fb97780Smrg				basic_machine=mips-sei
5213fb97780Smrg				basic_os=seiux
5223fb97780Smrg				;;
5233fb97780Smrg			sequent)
5243fb97780Smrg				basic_machine=i386-sequent
5253fb97780Smrg				basic_os=
5263fb97780Smrg				;;
5273fb97780Smrg			sps7)
5283fb97780Smrg				basic_machine=m68k-bull
5293fb97780Smrg				basic_os=sysv2
5303fb97780Smrg				;;
5313fb97780Smrg			st2000)
5323fb97780Smrg				basic_machine=m68k-tandem
5333fb97780Smrg				basic_os=
5343fb97780Smrg				;;
5353fb97780Smrg			stratus)
5363fb97780Smrg				basic_machine=i860-stratus
5373fb97780Smrg				basic_os=sysv4
5383fb97780Smrg				;;
5393fb97780Smrg			sun2)
5403fb97780Smrg				basic_machine=m68000-sun
5413fb97780Smrg				basic_os=
5423fb97780Smrg				;;
5433fb97780Smrg			sun2os3)
5443fb97780Smrg				basic_machine=m68000-sun
5453fb97780Smrg				basic_os=sunos3
5463fb97780Smrg				;;
5473fb97780Smrg			sun2os4)
5483fb97780Smrg				basic_machine=m68000-sun
5493fb97780Smrg				basic_os=sunos4
5503fb97780Smrg				;;
5513fb97780Smrg			sun3)
5523fb97780Smrg				basic_machine=m68k-sun
5533fb97780Smrg				basic_os=
5543fb97780Smrg				;;
5553fb97780Smrg			sun3os3)
5563fb97780Smrg				basic_machine=m68k-sun
5573fb97780Smrg				basic_os=sunos3
5583fb97780Smrg				;;
5593fb97780Smrg			sun3os4)
5603fb97780Smrg				basic_machine=m68k-sun
5613fb97780Smrg				basic_os=sunos4
5623fb97780Smrg				;;
5633fb97780Smrg			sun4)
5643fb97780Smrg				basic_machine=sparc-sun
5653fb97780Smrg				basic_os=
5663fb97780Smrg				;;
5673fb97780Smrg			sun4os3)
5683fb97780Smrg				basic_machine=sparc-sun
5693fb97780Smrg				basic_os=sunos3
5703fb97780Smrg				;;
5713fb97780Smrg			sun4os4)
5723fb97780Smrg				basic_machine=sparc-sun
5733fb97780Smrg				basic_os=sunos4
5743fb97780Smrg				;;
5753fb97780Smrg			sun4sol2)
5763fb97780Smrg				basic_machine=sparc-sun
5773fb97780Smrg				basic_os=solaris2
5783fb97780Smrg				;;
5793fb97780Smrg			sun386 | sun386i | roadrunner)
5803fb97780Smrg				basic_machine=i386-sun
5813fb97780Smrg				basic_os=
5823fb97780Smrg				;;
5833fb97780Smrg			sv1)
5843fb97780Smrg				basic_machine=sv1-cray
5853fb97780Smrg				basic_os=unicos
5863fb97780Smrg				;;
5873fb97780Smrg			symmetry)
5883fb97780Smrg				basic_machine=i386-sequent
5893fb97780Smrg				basic_os=dynix
5903fb97780Smrg				;;
5913fb97780Smrg			t3e)
5923fb97780Smrg				basic_machine=alphaev5-cray
5933fb97780Smrg				basic_os=unicos
5943fb97780Smrg				;;
5953fb97780Smrg			t90)
5963fb97780Smrg				basic_machine=t90-cray
5973fb97780Smrg				basic_os=unicos
5983fb97780Smrg				;;
5993fb97780Smrg			toad1)
6003fb97780Smrg				basic_machine=pdp10-xkl
6013fb97780Smrg				basic_os=tops20
6023fb97780Smrg				;;
6033fb97780Smrg			tpf)
6043fb97780Smrg				basic_machine=s390x-ibm
6053fb97780Smrg				basic_os=tpf
6063fb97780Smrg				;;
6073fb97780Smrg			udi29k)
6083fb97780Smrg				basic_machine=a29k-amd
6093fb97780Smrg				basic_os=udi
6103fb97780Smrg				;;
6113fb97780Smrg			ultra3)
6123fb97780Smrg				basic_machine=a29k-nyu
6133fb97780Smrg				basic_os=sym1
6143fb97780Smrg				;;
6153fb97780Smrg			v810 | necv810)
6163fb97780Smrg				basic_machine=v810-nec
6173fb97780Smrg				basic_os=none
6183fb97780Smrg				;;
6193fb97780Smrg			vaxv)
6203fb97780Smrg				basic_machine=vax-dec
6213fb97780Smrg				basic_os=sysv
6223fb97780Smrg				;;
6233fb97780Smrg			vms)
6243fb97780Smrg				basic_machine=vax-dec
6253fb97780Smrg				basic_os=vms
6263fb97780Smrg				;;
6273fb97780Smrg			vsta)
6283fb97780Smrg				basic_machine=i386-pc
6293fb97780Smrg				basic_os=vsta
6303fb97780Smrg				;;
6313fb97780Smrg			vxworks960)
6323fb97780Smrg				basic_machine=i960-wrs
6333fb97780Smrg				basic_os=vxworks
6343fb97780Smrg				;;
6353fb97780Smrg			vxworks68)
6363fb97780Smrg				basic_machine=m68k-wrs
6373fb97780Smrg				basic_os=vxworks
6383fb97780Smrg				;;
6393fb97780Smrg			vxworks29k)
6403fb97780Smrg				basic_machine=a29k-wrs
6413fb97780Smrg				basic_os=vxworks
6423fb97780Smrg				;;
6433fb97780Smrg			xbox)
6443fb97780Smrg				basic_machine=i686-pc
6453fb97780Smrg				basic_os=mingw32
6463fb97780Smrg				;;
6473fb97780Smrg			ymp)
6483fb97780Smrg				basic_machine=ymp-cray
6493fb97780Smrg				basic_os=unicos
6503fb97780Smrg				;;
6513fb97780Smrg			*)
6523fb97780Smrg				basic_machine=$1
6533fb97780Smrg				basic_os=
6543fb97780Smrg				;;
6553fb97780Smrg		esac
656126a8a12Smrg		;;
657126a8a12Smrgesac
658126a8a12Smrg
6593fb97780Smrg# Decode 1-component or ad-hoc basic machines
660126a8a12Smrgcase $basic_machine in
6613fb97780Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6623fb97780Smrg	# some cases the only manufacturer, in others, it is the most popular.
6633fb97780Smrg	w89k)
6643fb97780Smrg		cpu=hppa1.1
6653fb97780Smrg		vendor=winbond
666300346aeSmrg		;;
6673fb97780Smrg	op50n)
6683fb97780Smrg		cpu=hppa1.1
6693fb97780Smrg		vendor=oki
670126a8a12Smrg		;;
6713fb97780Smrg	op60c)
6723fb97780Smrg		cpu=hppa1.1
6733fb97780Smrg		vendor=oki
674126a8a12Smrg		;;
6753fb97780Smrg	ibm*)
6763fb97780Smrg		cpu=i370
6773fb97780Smrg		vendor=ibm
678126a8a12Smrg		;;
6793fb97780Smrg	orion105)
6803fb97780Smrg		cpu=clipper
6813fb97780Smrg		vendor=highlevel
6820a6b08f8Smrg		;;
6833fb97780Smrg	mac | mpw | mac-mpw)
6843fb97780Smrg		cpu=m68k
6853fb97780Smrg		vendor=apple
6860a6b08f8Smrg		;;
6873fb97780Smrg	pmac | pmac-mpw)
6883fb97780Smrg		cpu=powerpc
6893fb97780Smrg		vendor=apple
6900a6b08f8Smrg		;;
6910a6b08f8Smrg
692126a8a12Smrg	# Recognize the various machine names and aliases which stand
693126a8a12Smrg	# for a CPU type and a company and sometimes even an OS.
694126a8a12Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6953fb97780Smrg		cpu=m68000
6963fb97780Smrg		vendor=att
697126a8a12Smrg		;;
698126a8a12Smrg	3b*)
6993fb97780Smrg		cpu=we32k
7003fb97780Smrg		vendor=att
701d656433aSmrg		;;
702555991fdSmrg	bluegene*)
7033fb97780Smrg		cpu=powerpc
7043fb97780Smrg		vendor=ibm
7053fb97780Smrg		basic_os=cnk
706126a8a12Smrg		;;
707126a8a12Smrg	decsystem10* | dec10*)
7083fb97780Smrg		cpu=pdp10
7093fb97780Smrg		vendor=dec
7103fb97780Smrg		basic_os=tops10
711126a8a12Smrg		;;
712126a8a12Smrg	decsystem20* | dec20*)
7133fb97780Smrg		cpu=pdp10
7143fb97780Smrg		vendor=dec
7153fb97780Smrg		basic_os=tops20
716126a8a12Smrg		;;
717126a8a12Smrg	delta | 3300 | motorola-3300 | motorola-delta \
718126a8a12Smrg	      | 3300-motorola | delta-motorola)
7193fb97780Smrg		cpu=m68k
7203fb97780Smrg		vendor=motorola
721126a8a12Smrg		;;
722300346aeSmrg	dpx2*)
7233fb97780Smrg		cpu=m68k
7243fb97780Smrg		vendor=bull
7253fb97780Smrg		basic_os=sysv3
726126a8a12Smrg		;;
727126a8a12Smrg	encore | umax | mmax)
7283fb97780Smrg		cpu=ns32k
7293fb97780Smrg		vendor=encore
730126a8a12Smrg		;;
7313fb97780Smrg	elxsi)
7323fb97780Smrg		cpu=elxsi
7333fb97780Smrg		vendor=elxsi
7343fb97780Smrg		basic_os=${basic_os:-bsd}
735126a8a12Smrg		;;
736126a8a12Smrg	fx2800)
7373fb97780Smrg		cpu=i860
7383fb97780Smrg		vendor=alliant
739126a8a12Smrg		;;
740126a8a12Smrg	genix)
7413fb97780Smrg		cpu=ns32k
7423fb97780Smrg		vendor=ns
743126a8a12Smrg		;;
744126a8a12Smrg	h3050r* | hiux*)
7453fb97780Smrg		cpu=hppa1.1
7463fb97780Smrg		vendor=hitachi
7473fb97780Smrg		basic_os=hiuxwe2
748126a8a12Smrg		;;
749126a8a12Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7503fb97780Smrg		cpu=hppa1.0
7513fb97780Smrg		vendor=hp
752126a8a12Smrg		;;
753126a8a12Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7543fb97780Smrg		cpu=m68000
7553fb97780Smrg		vendor=hp
756126a8a12Smrg		;;
757126a8a12Smrg	hp9k3[2-9][0-9])
7583fb97780Smrg		cpu=m68k
7593fb97780Smrg		vendor=hp
760126a8a12Smrg		;;
761126a8a12Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7623fb97780Smrg		cpu=hppa1.0
7633fb97780Smrg		vendor=hp
764126a8a12Smrg		;;
765126a8a12Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7663fb97780Smrg		cpu=hppa1.1
7673fb97780Smrg		vendor=hp
768126a8a12Smrg		;;
769126a8a12Smrg	hp9k78[0-9] | hp78[0-9])
770126a8a12Smrg		# FIXME: really hppa2.0-hp
7713fb97780Smrg		cpu=hppa1.1
7723fb97780Smrg		vendor=hp
773126a8a12Smrg		;;
774126a8a12Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
775126a8a12Smrg		# FIXME: really hppa2.0-hp
7763fb97780Smrg		cpu=hppa1.1
7773fb97780Smrg		vendor=hp
778126a8a12Smrg		;;
779126a8a12Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7803fb97780Smrg		cpu=hppa1.1
7813fb97780Smrg		vendor=hp
782126a8a12Smrg		;;
783126a8a12Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7843fb97780Smrg		cpu=hppa1.0
7853fb97780Smrg		vendor=hp
786126a8a12Smrg		;;
787126a8a12Smrg	i*86v32)
7883fb97780Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7893fb97780Smrg		vendor=pc
7903fb97780Smrg		basic_os=sysv32
791126a8a12Smrg		;;
792126a8a12Smrg	i*86v4*)
7933fb97780Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7943fb97780Smrg		vendor=pc
7953fb97780Smrg		basic_os=sysv4
796126a8a12Smrg		;;
797126a8a12Smrg	i*86v)
7983fb97780Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7993fb97780Smrg		vendor=pc
8003fb97780Smrg		basic_os=sysv
801126a8a12Smrg		;;
802126a8a12Smrg	i*86sol2)
8033fb97780Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8043fb97780Smrg		vendor=pc
8053fb97780Smrg		basic_os=solaris2
806126a8a12Smrg		;;
8073fb97780Smrg	j90 | j90-cray)
8083fb97780Smrg		cpu=j90
8093fb97780Smrg		vendor=cray
8103fb97780Smrg		basic_os=${basic_os:-unicos}
811126a8a12Smrg		;;
812126a8a12Smrg	iris | iris4d)
8133fb97780Smrg		cpu=mips
8143fb97780Smrg		vendor=sgi
8153fb97780Smrg		case $basic_os in
8163fb97780Smrg		    irix*)
817126a8a12Smrg			;;
818126a8a12Smrg		    *)
8193fb97780Smrg			basic_os=irix4
820126a8a12Smrg			;;
821126a8a12Smrg		esac
822126a8a12Smrg		;;
823126a8a12Smrg	miniframe)
8243fb97780Smrg		cpu=m68000
8253fb97780Smrg		vendor=convergent
826126a8a12Smrg		;;
8273fb97780Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8283fb97780Smrg		cpu=m68k
8293fb97780Smrg		vendor=atari
8303fb97780Smrg		basic_os=mint
831126a8a12Smrg		;;
832126a8a12Smrg	news-3600 | risc-news)
8333fb97780Smrg		cpu=mips
8343fb97780Smrg		vendor=sony
8353fb97780Smrg		basic_os=newsos
836126a8a12Smrg		;;
837300346aeSmrg	next | m*-next)
8383fb97780Smrg		cpu=m68k
8393fb97780Smrg		vendor=next
8403fb97780Smrg		case $basic_os in
8413fb97780Smrg		    openstep*)
8423fb97780Smrg		        ;;
8433fb97780Smrg		    nextstep*)
844126a8a12Smrg			;;
8453fb97780Smrg		    ns2*)
8463fb97780Smrg		      basic_os=nextstep2
847126a8a12Smrg			;;
848126a8a12Smrg		    *)
8493fb97780Smrg		      basic_os=nextstep3
850126a8a12Smrg			;;
851126a8a12Smrg		esac
852126a8a12Smrg		;;
853126a8a12Smrg	np1)
8543fb97780Smrg		cpu=np1
8553fb97780Smrg		vendor=gould
856300346aeSmrg		;;
857126a8a12Smrg	op50n-* | op60c-*)
8583fb97780Smrg		cpu=hppa1.1
8593fb97780Smrg		vendor=oki
8603fb97780Smrg		basic_os=proelf
861126a8a12Smrg		;;
862126a8a12Smrg	pa-hitachi)
8633fb97780Smrg		cpu=hppa1.1
8643fb97780Smrg		vendor=hitachi
8653fb97780Smrg		basic_os=hiuxwe2
866d656433aSmrg		;;
867126a8a12Smrg	pbd)
8683fb97780Smrg		cpu=sparc
8693fb97780Smrg		vendor=tti
870126a8a12Smrg		;;
871126a8a12Smrg	pbb)
8723fb97780Smrg		cpu=m68k
8733fb97780Smrg		vendor=tti
874126a8a12Smrg		;;
8753fb97780Smrg	pc532)
8763fb97780Smrg		cpu=ns32k
8773fb97780Smrg		vendor=pc532
878126a8a12Smrg		;;
879126a8a12Smrg	pn)
8803fb97780Smrg		cpu=pn
8813fb97780Smrg		vendor=gould
882126a8a12Smrg		;;
8833fb97780Smrg	power)
8843fb97780Smrg		cpu=power
8853fb97780Smrg		vendor=ibm
886126a8a12Smrg		;;
8873fb97780Smrg	ps2)
8883fb97780Smrg		cpu=i386
8893fb97780Smrg		vendor=ibm
890126a8a12Smrg		;;
8913fb97780Smrg	rm[46]00)
8923fb97780Smrg		cpu=mips
8933fb97780Smrg		vendor=siemens
894126a8a12Smrg		;;
8953fb97780Smrg	rtpc | rtpc-*)
8963fb97780Smrg		cpu=romp
8973fb97780Smrg		vendor=ibm
898126a8a12Smrg		;;
8993fb97780Smrg	sde)
9003fb97780Smrg		cpu=mipsisa32
9013fb97780Smrg		vendor=sde
9023fb97780Smrg		basic_os=${basic_os:-elf}
903126a8a12Smrg		;;
9043fb97780Smrg	simso-wrs)
9053fb97780Smrg		cpu=sparclite
9063fb97780Smrg		vendor=wrs
9073fb97780Smrg		basic_os=vxworks
908126a8a12Smrg		;;
9093fb97780Smrg	tower | tower-32)
9103fb97780Smrg		cpu=m68k
9113fb97780Smrg		vendor=ncr
912126a8a12Smrg		;;
9133fb97780Smrg	vpp*|vx|vx-*)
9143fb97780Smrg		cpu=f301
9153fb97780Smrg		vendor=fujitsu
9160a6b08f8Smrg		;;
9173fb97780Smrg	w65)
9183fb97780Smrg		cpu=w65
9193fb97780Smrg		vendor=wdc
920126a8a12Smrg		;;
9213fb97780Smrg	w89k-*)
9223fb97780Smrg		cpu=hppa1.1
9233fb97780Smrg		vendor=winbond
9243fb97780Smrg		basic_os=proelf
925126a8a12Smrg		;;
9263fb97780Smrg	none)
9273fb97780Smrg		cpu=none
9283fb97780Smrg		vendor=none
929126a8a12Smrg		;;
9303fb97780Smrg	leon|leon[3-9])
9313fb97780Smrg		cpu=sparc
9323fb97780Smrg		vendor=$basic_machine
933126a8a12Smrg		;;
9343fb97780Smrg	leon-*|leon[3-9]-*)
9353fb97780Smrg		cpu=sparc
9363fb97780Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
937126a8a12Smrg		;;
9383fb97780Smrg
9393fb97780Smrg	*-*)
9403fb97780Smrg		# shellcheck disable=SC2162
9413fb97780Smrg		saved_IFS=$IFS
9423fb97780Smrg		IFS="-" read cpu vendor <<EOF
9433fb97780Smrg$basic_machine
9443fb97780SmrgEOF
9453fb97780Smrg		IFS=$saved_IFS
946126a8a12Smrg		;;
9476bea0e4fSmrg	# We use 'pc' rather than 'unknown'
9483fb97780Smrg	# because (1) that's what they normally are, and
9493fb97780Smrg	# (2) the word "unknown" tends to confuse beginning users.
9503fb97780Smrg	i*86 | x86_64)
9513fb97780Smrg		cpu=$basic_machine
9523fb97780Smrg		vendor=pc
953126a8a12Smrg		;;
9543fb97780Smrg	# These rules are duplicated from below for sake of the special case above;
9553fb97780Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9563fb97780Smrg	pc98)
9573fb97780Smrg		cpu=i386
9583fb97780Smrg		vendor=pc
959126a8a12Smrg		;;
9603fb97780Smrg	x64 | amd64)
9613fb97780Smrg		cpu=x86_64
9623fb97780Smrg		vendor=pc
963126a8a12Smrg		;;
9643fb97780Smrg	# Recognize the basic CPU types without company name.
9653fb97780Smrg	*)
9663fb97780Smrg		cpu=$basic_machine
9673fb97780Smrg		vendor=unknown
968d656433aSmrg		;;
9693fb97780Smrgesac
9703fb97780Smrg
9713fb97780Smrgunset -v basic_machine
9723fb97780Smrg
9733fb97780Smrg# Decode basic machines in the full and proper CPU-Company form.
9743fb97780Smrgcase $cpu-$vendor in
9753fb97780Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9763fb97780Smrg	# some cases the only manufacturer, in others, it is the most popular.
9773fb97780Smrg	craynv-unknown)
9783fb97780Smrg		vendor=cray
9793fb97780Smrg		basic_os=${basic_os:-unicosmp}
980126a8a12Smrg		;;
9813fb97780Smrg	c90-unknown | c90-cray)
9823fb97780Smrg		vendor=cray
9833fb97780Smrg		basic_os=${Basic_os:-unicos}
984126a8a12Smrg		;;
9853fb97780Smrg	fx80-unknown)
9863fb97780Smrg		vendor=alliant
987d656433aSmrg		;;
9883fb97780Smrg	romp-unknown)
9893fb97780Smrg		vendor=ibm
990126a8a12Smrg		;;
9913fb97780Smrg	mmix-unknown)
9923fb97780Smrg		vendor=knuth
993126a8a12Smrg		;;
9943fb97780Smrg	microblaze-unknown | microblazeel-unknown)
9953fb97780Smrg		vendor=xilinx
996126a8a12Smrg		;;
9973fb97780Smrg	rs6000-unknown)
9983fb97780Smrg		vendor=ibm
999126a8a12Smrg		;;
10003fb97780Smrg	vax-unknown)
10013fb97780Smrg		vendor=dec
1002126a8a12Smrg		;;
10033fb97780Smrg	pdp11-unknown)
10043fb97780Smrg		vendor=dec
10050a6b08f8Smrg		;;
10063fb97780Smrg	we32k-unknown)
10073fb97780Smrg		vendor=att
1008126a8a12Smrg		;;
10093fb97780Smrg	cydra-unknown)
10103fb97780Smrg		vendor=cydrome
1011126a8a12Smrg		;;
10123fb97780Smrg	i370-ibm*)
10133fb97780Smrg		vendor=ibm
1014126a8a12Smrg		;;
10153fb97780Smrg	orion-unknown)
10163fb97780Smrg		vendor=highlevel
1017126a8a12Smrg		;;
10183fb97780Smrg	xps-unknown | xps100-unknown)
10193fb97780Smrg		cpu=xps100
10203fb97780Smrg		vendor=honeywell
1021126a8a12Smrg		;;
10223fb97780Smrg
10233fb97780Smrg	# Here we normalize CPU types with a missing or matching vendor
10246bea0e4fSmrg	armh-unknown | armh-alt)
10256bea0e4fSmrg		cpu=armv7l
10266bea0e4fSmrg		vendor=alt
10276bea0e4fSmrg		basic_os=${basic_os:-linux-gnueabihf}
10286bea0e4fSmrg		;;
10293fb97780Smrg	dpx20-unknown | dpx20-bull)
10303fb97780Smrg		cpu=rs6000
10313fb97780Smrg		vendor=bull
10323fb97780Smrg		basic_os=${basic_os:-bosx}
1033126a8a12Smrg		;;
10343fb97780Smrg
10353fb97780Smrg	# Here we normalize CPU types irrespective of the vendor
10363fb97780Smrg	amd64-*)
10373fb97780Smrg		cpu=x86_64
1038126a8a12Smrg		;;
10393fb97780Smrg	blackfin-*)
10403fb97780Smrg		cpu=bfin
10413fb97780Smrg		basic_os=linux
1042126a8a12Smrg		;;
10433fb97780Smrg	c54x-*)
10443fb97780Smrg		cpu=tic54x
1045126a8a12Smrg		;;
10463fb97780Smrg	c55x-*)
10473fb97780Smrg		cpu=tic55x
1048126a8a12Smrg		;;
10493fb97780Smrg	c6x-*)
10503fb97780Smrg		cpu=tic6x
1051126a8a12Smrg		;;
10523fb97780Smrg	e500v[12]-*)
10533fb97780Smrg		cpu=powerpc
10543fb97780Smrg		basic_os=${basic_os}"spe"
1055126a8a12Smrg		;;
10563fb97780Smrg	mips3*-*)
10573fb97780Smrg		cpu=mips64
1058126a8a12Smrg		;;
10593fb97780Smrg	ms1-*)
10603fb97780Smrg		cpu=mt
1061126a8a12Smrg		;;
10623fb97780Smrg	m68knommu-*)
10633fb97780Smrg		cpu=m68k
10643fb97780Smrg		basic_os=linux
1065126a8a12Smrg		;;
10663fb97780Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10673fb97780Smrg		cpu=s12z
1068d656433aSmrg		;;
10693fb97780Smrg	openrisc-*)
10703fb97780Smrg		cpu=or32
1071126a8a12Smrg		;;
10723fb97780Smrg	parisc-*)
10733fb97780Smrg		cpu=hppa
10743fb97780Smrg		basic_os=linux
1075126a8a12Smrg		;;
10763fb97780Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10773fb97780Smrg		cpu=i586
1078126a8a12Smrg		;;
10796bea0e4fSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10803fb97780Smrg		cpu=i686
1081126a8a12Smrg		;;
10823fb97780Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10833fb97780Smrg		cpu=i686
1084126a8a12Smrg		;;
10853fb97780Smrg	pentium4-*)
10863fb97780Smrg		cpu=i786
1087126a8a12Smrg		;;
10883fb97780Smrg	pc98-*)
10893fb97780Smrg		cpu=i386
1090126a8a12Smrg		;;
10913fb97780Smrg	ppc-* | ppcbe-*)
10923fb97780Smrg		cpu=powerpc
1093126a8a12Smrg		;;
10943fb97780Smrg	ppcle-* | powerpclittle-*)
10953fb97780Smrg		cpu=powerpcle
1096126a8a12Smrg		;;
10973fb97780Smrg	ppc64-*)
10983fb97780Smrg		cpu=powerpc64
1099126a8a12Smrg		;;
11003fb97780Smrg	ppc64le-* | powerpc64little-*)
11013fb97780Smrg		cpu=powerpc64le
1102126a8a12Smrg		;;
11033fb97780Smrg	sb1-*)
11043fb97780Smrg		cpu=mipsisa64sb1
1105126a8a12Smrg		;;
11063fb97780Smrg	sb1el-*)
11073fb97780Smrg		cpu=mipsisa64sb1el
1108126a8a12Smrg		;;
11093fb97780Smrg	sh5e[lb]-*)
11103fb97780Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1111126a8a12Smrg		;;
11123fb97780Smrg	spur-*)
11133fb97780Smrg		cpu=spur
1114126a8a12Smrg		;;
11153fb97780Smrg	strongarm-* | thumb-*)
11163fb97780Smrg		cpu=arm
1117126a8a12Smrg		;;
11183fb97780Smrg	tx39-*)
11193fb97780Smrg		cpu=mipstx39
1120300346aeSmrg		;;
11213fb97780Smrg	tx39el-*)
11223fb97780Smrg		cpu=mipstx39el
1123126a8a12Smrg		;;
11243fb97780Smrg	x64-*)
11253fb97780Smrg		cpu=x86_64
1126126a8a12Smrg		;;
11270a6b08f8Smrg	xscale-* | xscalee[bl]-*)
11283fb97780Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1129126a8a12Smrg		;;
11306bea0e4fSmrg	arm64-* | aarch64le-*)
11313fb97780Smrg		cpu=aarch64
1132126a8a12Smrg		;;
1133126a8a12Smrg
11343fb97780Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11353fb97780Smrg	# company names they are paired with.
11363fb97780Smrg	cr16-*)
11373fb97780Smrg		basic_os=${basic_os:-elf}
1138126a8a12Smrg		;;
11393fb97780Smrg	crisv32-* | etraxfs*-*)
11403fb97780Smrg		cpu=crisv32
11413fb97780Smrg		vendor=axis
1142126a8a12Smrg		;;
11433fb97780Smrg	cris-* | etrax*-*)
11443fb97780Smrg		cpu=cris
11453fb97780Smrg		vendor=axis
1146126a8a12Smrg		;;
11473fb97780Smrg	crx-*)
11483fb97780Smrg		basic_os=${basic_os:-elf}
1149126a8a12Smrg		;;
11503fb97780Smrg	neo-tandem)
11513fb97780Smrg		cpu=neo
11523fb97780Smrg		vendor=tandem
1153126a8a12Smrg		;;
11543fb97780Smrg	nse-tandem)
11553fb97780Smrg		cpu=nse
11563fb97780Smrg		vendor=tandem
1157126a8a12Smrg		;;
11583fb97780Smrg	nsr-tandem)
11593fb97780Smrg		cpu=nsr
11603fb97780Smrg		vendor=tandem
1161126a8a12Smrg		;;
11623fb97780Smrg	nsv-tandem)
11633fb97780Smrg		cpu=nsv
11643fb97780Smrg		vendor=tandem
1165126a8a12Smrg		;;
11663fb97780Smrg	nsx-tandem)
11673fb97780Smrg		cpu=nsx
11683fb97780Smrg		vendor=tandem
1169126a8a12Smrg		;;
11703fb97780Smrg	mipsallegrexel-sony)
11713fb97780Smrg		cpu=mipsallegrexel
11723fb97780Smrg		vendor=sony
1173126a8a12Smrg		;;
11743fb97780Smrg	tile*-*)
11753fb97780Smrg		basic_os=${basic_os:-linux-gnu}
1176126a8a12Smrg		;;
11773fb97780Smrg
1178126a8a12Smrg	*)
11793fb97780Smrg		# Recognize the canonical CPU types that are allowed with any
11803fb97780Smrg		# company name.
11813fb97780Smrg		case $cpu in
11823fb97780Smrg			1750a | 580 \
11833fb97780Smrg			| a29k \
11846bea0e4fSmrg			| aarch64 | aarch64_be | aarch64c | arm64ec \
11853fb97780Smrg			| abacus \
11863fb97780Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11873fb97780Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11883fb97780Smrg			| alphapca5[67] | alpha64pca5[67] \
11893fb97780Smrg			| am33_2.0 \
11903fb97780Smrg			| amdgcn \
11913fb97780Smrg			| arc | arceb | arc32 | arc64 \
11923fb97780Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11933fb97780Smrg			| avr | avr32 \
11943fb97780Smrg			| asmjs \
11953fb97780Smrg			| ba \
11963fb97780Smrg			| be32 | be64 \
11973fb97780Smrg			| bfin | bpf | bs2000 \
11983fb97780Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11993fb97780Smrg			| c8051 | clipper | craynv | csky | cydra \
12003fb97780Smrg			| d10v | d30v | dlx | dsp16xx \
12013fb97780Smrg			| e2k | elxsi | epiphany \
12023fb97780Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12036bea0e4fSmrg			| javascript \
12043fb97780Smrg			| h8300 | h8500 \
12053fb97780Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12063fb97780Smrg			| hexagon \
12073fb97780Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12083fb97780Smrg			| ip2k | iq2000 \
12093fb97780Smrg			| k1om \
12106bea0e4fSmrg			| kvx \
12113fb97780Smrg			| le32 | le64 \
12123fb97780Smrg			| lm32 \
12136bea0e4fSmrg			| loongarch32 | loongarch64 \
12143fb97780Smrg			| m32c | m32r | m32rle \
12153fb97780Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12163fb97780Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12173fb97780Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12183fb97780Smrg			| microblaze | microblazeel \
12196bea0e4fSmrg			| mips* \
12203fb97780Smrg			| mmix \
12213fb97780Smrg			| mn10200 | mn10300 \
12223fb97780Smrg			| moxie \
12233fb97780Smrg			| mt \
12243fb97780Smrg			| msp430 \
12256bea0e4fSmrg			| nanomips* \
12263fb97780Smrg			| nds32 | nds32le | nds32be \
12273fb97780Smrg			| nfp \
12283fb97780Smrg			| nios | nios2 | nios2eb | nios2el \
12293fb97780Smrg			| none | np1 | ns16k | ns32k | nvptx \
12303fb97780Smrg			| open8 \
12313fb97780Smrg			| or1k* \
12323fb97780Smrg			| or32 \
12333fb97780Smrg			| orion \
12343fb97780Smrg			| picochip \
12353fb97780Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12363fb97780Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12373fb97780Smrg			| pru \
12383fb97780Smrg			| pyramid \
12393fb97780Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12403fb97780Smrg			| rl78 | romp | rs6000 | rx \
12413fb97780Smrg			| s390 | s390x \
12423fb97780Smrg			| score \
12433fb97780Smrg			| sh | shl \
12443fb97780Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12453fb97780Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12463fb97780Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12473fb97780Smrg			| sparclite \
12483fb97780Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12493fb97780Smrg			| spu \
12503fb97780Smrg			| tahoe \
12513fb97780Smrg			| thumbv7* \
12523fb97780Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12533fb97780Smrg			| tron \
12543fb97780Smrg			| ubicom32 \
12553fb97780Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12563fb97780Smrg			| vax \
12576bea0e4fSmrg			| vc4 \
12583fb97780Smrg			| visium \
12593fb97780Smrg			| w65 \
12603fb97780Smrg			| wasm32 | wasm64 \
12613fb97780Smrg			| we32k \
12623fb97780Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12633fb97780Smrg			| xstormy16 | xtensa* \
12643fb97780Smrg			| ymp \
12653fb97780Smrg			| z8k | z80)
12663fb97780Smrg				;;
12673fb97780Smrg
12683fb97780Smrg			*)
12696bea0e4fSmrg				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
12703fb97780Smrg				exit 1
12713fb97780Smrg				;;
12723fb97780Smrg		esac
1273126a8a12Smrg		;;
1274126a8a12Smrgesac
1275126a8a12Smrg
1276126a8a12Smrg# Here we canonicalize certain aliases for manufacturers.
12773fb97780Smrgcase $vendor in
12783fb97780Smrg	digital*)
12793fb97780Smrg		vendor=dec
1280126a8a12Smrg		;;
12813fb97780Smrg	commodore*)
12823fb97780Smrg		vendor=cbm
1283126a8a12Smrg		;;
1284126a8a12Smrg	*)
1285126a8a12Smrg		;;
1286126a8a12Smrgesac
1287126a8a12Smrg
1288126a8a12Smrg# Decode manufacturer-specific aliases for certain operating systems.
1289126a8a12Smrg
12906bea0e4fSmrgif test x"$basic_os" != x
1291126a8a12Smrgthen
12923fb97780Smrg
12936bea0e4fSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
12943fb97780Smrg# set os.
12956bea0e4fSmrgobj=
12963fb97780Smrgcase $basic_os in
12973fb97780Smrg	gnu/linux*)
12983fb97780Smrg		kernel=linux
12993fb97780Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13003fb97780Smrg		;;
13013fb97780Smrg	os2-emx)
13023fb97780Smrg		kernel=os2
13033fb97780Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13043fb97780Smrg		;;
13053fb97780Smrg	nto-qnx*)
13063fb97780Smrg		kernel=nto
13073fb97780Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13083fb97780Smrg		;;
13093fb97780Smrg	*-*)
13103fb97780Smrg		# shellcheck disable=SC2162
13113fb97780Smrg		saved_IFS=$IFS
13123fb97780Smrg		IFS="-" read kernel os <<EOF
13133fb97780Smrg$basic_os
13143fb97780SmrgEOF
13153fb97780Smrg		IFS=$saved_IFS
13163fb97780Smrg		;;
13173fb97780Smrg	# Default OS when just kernel was specified
13183fb97780Smrg	nto*)
13193fb97780Smrg		kernel=nto
13203fb97780Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13213fb97780Smrg		;;
13223fb97780Smrg	linux*)
13233fb97780Smrg		kernel=linux
13243fb97780Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13253fb97780Smrg		;;
13266bea0e4fSmrg	managarm*)
13276bea0e4fSmrg		kernel=managarm
13286bea0e4fSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13296bea0e4fSmrg		;;
13303fb97780Smrg	*)
13313fb97780Smrg		kernel=
13323fb97780Smrg		os=$basic_os
13333fb97780Smrg		;;
13343fb97780Smrgesac
13353fb97780Smrg
13363fb97780Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13373fb97780Smrg# etc.)
1338126a8a12Smrgcase $os in
1339300346aeSmrg	# First match some system type aliases that might get confused
1340300346aeSmrg	# with valid system types.
13413fb97780Smrg	# solaris* is a basic system type, with this one exception.
13423fb97780Smrg	auroraux)
13433fb97780Smrg		os=auroraux
1344555991fdSmrg		;;
13453fb97780Smrg	bluegene*)
13463fb97780Smrg		os=cnk
1347126a8a12Smrg		;;
13483fb97780Smrg	solaris1 | solaris1.*)
13493fb97780Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1350126a8a12Smrg		;;
13513fb97780Smrg	solaris)
13523fb97780Smrg		os=solaris2
1353126a8a12Smrg		;;
13543fb97780Smrg	unixware*)
13553fb97780Smrg		os=sysv4.2uw
1356126a8a12Smrg		;;
1357300346aeSmrg	# es1800 is here to avoid being matched by es* (a different OS)
13583fb97780Smrg	es1800*)
13593fb97780Smrg		os=ose
1360300346aeSmrg		;;
13613fb97780Smrg	# Some version numbers need modification
13623fb97780Smrg	chorusos*)
13633fb97780Smrg		os=chorusos
1364126a8a12Smrg		;;
13653fb97780Smrg	isc)
13663fb97780Smrg		os=isc2.2
1367126a8a12Smrg		;;
13683fb97780Smrg	sco6)
13693fb97780Smrg		os=sco5v6
1370126a8a12Smrg		;;
13713fb97780Smrg	sco5)
13723fb97780Smrg		os=sco3.2v5
1373126a8a12Smrg		;;
13743fb97780Smrg	sco4)
13753fb97780Smrg		os=sco3.2v4
1376126a8a12Smrg		;;
13773fb97780Smrg	sco3.2.[4-9]*)
13783fb97780Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1379126a8a12Smrg		;;
13803fb97780Smrg	sco*v* | scout)
13813fb97780Smrg		# Don't match below
1382126a8a12Smrg		;;
13833fb97780Smrg	sco*)
13843fb97780Smrg		os=sco3.2v2
1385126a8a12Smrg		;;
13863fb97780Smrg	psos*)
13873fb97780Smrg		os=psos
1388126a8a12Smrg		;;
13893fb97780Smrg	qnx*)
13903fb97780Smrg		os=qnx
1391126a8a12Smrg		;;
13923fb97780Smrg	hiux*)
13933fb97780Smrg		os=hiuxwe2
1394126a8a12Smrg		;;
13953fb97780Smrg	lynx*178)
13963fb97780Smrg		os=lynxos178
1397126a8a12Smrg		;;
13983fb97780Smrg	lynx*5)
13993fb97780Smrg		os=lynxos5
1400126a8a12Smrg		;;
14013fb97780Smrg	lynxos*)
14023fb97780Smrg		# don't get caught up in next wildcard
1403126a8a12Smrg		;;
14043fb97780Smrg	lynx*)
14053fb97780Smrg		os=lynxos
1406126a8a12Smrg		;;
14073fb97780Smrg	mac[0-9]*)
14083fb97780Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1409126a8a12Smrg		;;
14103fb97780Smrg	opened*)
14113fb97780Smrg		os=openedition
1412126a8a12Smrg		;;
14133fb97780Smrg	os400*)
14143fb97780Smrg		os=os400
1415126a8a12Smrg		;;
14163fb97780Smrg	sunos5*)
14173fb97780Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1418126a8a12Smrg		;;
14193fb97780Smrg	sunos6*)
14203fb97780Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1421126a8a12Smrg		;;
14223fb97780Smrg	wince*)
14233fb97780Smrg		os=wince
1424126a8a12Smrg		;;
14253fb97780Smrg	utek*)
14263fb97780Smrg		os=bsd
1427126a8a12Smrg		;;
14283fb97780Smrg	dynix*)
14293fb97780Smrg		os=bsd
1430126a8a12Smrg		;;
14313fb97780Smrg	acis*)
14323fb97780Smrg		os=aos
1433126a8a12Smrg		;;
14343fb97780Smrg	atheos*)
14353fb97780Smrg		os=atheos
1436126a8a12Smrg		;;
14373fb97780Smrg	syllable*)
14383fb97780Smrg		os=syllable
14393fb97780Smrg		;;
14403fb97780Smrg	386bsd)
14413fb97780Smrg		os=bsd
14423fb97780Smrg		;;
14433fb97780Smrg	ctix* | uts*)
14443fb97780Smrg		os=sysv
14453fb97780Smrg		;;
14463fb97780Smrg	nova*)
14473fb97780Smrg		os=rtmk-nova
14483fb97780Smrg		;;
14493fb97780Smrg	ns2)
14503fb97780Smrg		os=nextstep2
14513fb97780Smrg		;;
14523fb97780Smrg	# Preserve the version number of sinix5.
14533fb97780Smrg	sinix5.*)
14543fb97780Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1455126a8a12Smrg		;;
14563fb97780Smrg	sinix*)
14573fb97780Smrg		os=sysv4
1458126a8a12Smrg		;;
14593fb97780Smrg	tpf*)
14603fb97780Smrg		os=tpf
1461126a8a12Smrg		;;
14623fb97780Smrg	triton*)
14633fb97780Smrg		os=sysv3
1464126a8a12Smrg		;;
14653fb97780Smrg	oss*)
14663fb97780Smrg		os=sysv3
1467126a8a12Smrg		;;
14683fb97780Smrg	svr4*)
14693fb97780Smrg		os=sysv4
1470126a8a12Smrg		;;
14713fb97780Smrg	svr3)
14723fb97780Smrg		os=sysv3
1473126a8a12Smrg		;;
14743fb97780Smrg	sysvr4)
14753fb97780Smrg		os=sysv4
1476126a8a12Smrg		;;
14773fb97780Smrg	ose*)
14783fb97780Smrg		os=ose
1479126a8a12Smrg		;;
14803fb97780Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14813fb97780Smrg		os=mint
1482d656433aSmrg		;;
14833fb97780Smrg	dicos*)
14843fb97780Smrg		os=dicos
14853fb97780Smrg		;;
14863fb97780Smrg	pikeos*)
1487300346aeSmrg		# Until real need of OS specific support for
1488300346aeSmrg		# particular features comes up, bare metal
1489300346aeSmrg		# configurations are quite functional.
14903fb97780Smrg		case $cpu in
1491300346aeSmrg		    arm*)
14923fb97780Smrg			os=eabi
1493300346aeSmrg			;;
1494300346aeSmrg		    *)
14956bea0e4fSmrg			os=
14966bea0e4fSmrg			obj=elf
1497300346aeSmrg			;;
1498300346aeSmrg		esac
1499300346aeSmrg		;;
15006bea0e4fSmrg	aout* | coff* | elf* | pe*)
15016bea0e4fSmrg		# These are machine code file formats, not OSes
15026bea0e4fSmrg		obj=$os
15036bea0e4fSmrg		os=
15046bea0e4fSmrg		;;
1505126a8a12Smrg	*)
15063fb97780Smrg		# No normalization, but not necessarily accepted, that comes below.
1507126a8a12Smrg		;;
1508126a8a12Smrgesac
15093fb97780Smrg
1510126a8a12Smrgelse
1511126a8a12Smrg
1512126a8a12Smrg# Here we handle the default operating systems that come with various machines.
1513126a8a12Smrg# The value should be what the vendor currently ships out the door with their
1514126a8a12Smrg# machine or put another way, the most popular os provided with the machine.
1515126a8a12Smrg
1516126a8a12Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1517126a8a12Smrg# "-sun"), then you have to tell the case statement up towards the top
1518126a8a12Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1519126a8a12Smrg# will signal an error saying that MANUFACTURER isn't an operating
1520126a8a12Smrg# system, and we'll never get to this point.
1521126a8a12Smrg
15223fb97780Smrgkernel=
15236bea0e4fSmrgobj=
15243fb97780Smrgcase $cpu-$vendor in
15250a6b08f8Smrg	score-*)
15266bea0e4fSmrg		os=
15276bea0e4fSmrg		obj=elf
1528d656433aSmrg		;;
15290a6b08f8Smrg	spu-*)
15306bea0e4fSmrg		os=
15316bea0e4fSmrg		obj=elf
1532d656433aSmrg		;;
1533126a8a12Smrg	*-acorn)
15343fb97780Smrg		os=riscix1.2
1535126a8a12Smrg		;;
1536126a8a12Smrg	arm*-rebel)
15373fb97780Smrg		kernel=linux
15383fb97780Smrg		os=gnu
1539126a8a12Smrg		;;
1540126a8a12Smrg	arm*-semi)
15416bea0e4fSmrg		os=
15426bea0e4fSmrg		obj=aout
1543126a8a12Smrg		;;
15440a6b08f8Smrg	c4x-* | tic4x-*)
15456bea0e4fSmrg		os=
15466bea0e4fSmrg		obj=coff
15470a6b08f8Smrg		;;
1548300346aeSmrg	c8051-*)
15496bea0e4fSmrg		os=
15506bea0e4fSmrg		obj=elf
15513fb97780Smrg		;;
15523fb97780Smrg	clipper-intergraph)
15533fb97780Smrg		os=clix
1554300346aeSmrg		;;
15550a6b08f8Smrg	hexagon-*)
15566bea0e4fSmrg		os=
15576bea0e4fSmrg		obj=elf
1558d656433aSmrg		;;
1559555991fdSmrg	tic54x-*)
15606bea0e4fSmrg		os=
15616bea0e4fSmrg		obj=coff
1562555991fdSmrg		;;
1563555991fdSmrg	tic55x-*)
15646bea0e4fSmrg		os=
15656bea0e4fSmrg		obj=coff
1566555991fdSmrg		;;
1567555991fdSmrg	tic6x-*)
15686bea0e4fSmrg		os=
15696bea0e4fSmrg		obj=coff
1570555991fdSmrg		;;
1571126a8a12Smrg	# This must come before the *-dec entry.
1572126a8a12Smrg	pdp10-*)
15733fb97780Smrg		os=tops20
1574126a8a12Smrg		;;
1575126a8a12Smrg	pdp11-*)
15763fb97780Smrg		os=none
1577126a8a12Smrg		;;
1578126a8a12Smrg	*-dec | vax-*)
15793fb97780Smrg		os=ultrix4.2
1580126a8a12Smrg		;;
1581126a8a12Smrg	m68*-apollo)
15823fb97780Smrg		os=domain
1583126a8a12Smrg		;;
1584126a8a12Smrg	i386-sun)
15853fb97780Smrg		os=sunos4.0.2
1586126a8a12Smrg		;;
1587126a8a12Smrg	m68000-sun)
15883fb97780Smrg		os=sunos3
1589126a8a12Smrg		;;
1590126a8a12Smrg	m68*-cisco)
15916bea0e4fSmrg		os=
15926bea0e4fSmrg		obj=aout
1593126a8a12Smrg		;;
15940a6b08f8Smrg	mep-*)
15956bea0e4fSmrg		os=
15966bea0e4fSmrg		obj=elf
1597d656433aSmrg		;;
1598126a8a12Smrg	mips*-cisco)
15996bea0e4fSmrg		os=
16006bea0e4fSmrg		obj=elf
1601126a8a12Smrg		;;
16026bea0e4fSmrg	mips*-*|nanomips*-*)
16036bea0e4fSmrg		os=
16046bea0e4fSmrg		obj=elf
1605126a8a12Smrg		;;
1606126a8a12Smrg	or32-*)
16076bea0e4fSmrg		os=
16086bea0e4fSmrg		obj=coff
1609126a8a12Smrg		;;
1610126a8a12Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
16113fb97780Smrg		os=sysv3
1612126a8a12Smrg		;;
1613126a8a12Smrg	sparc-* | *-sun)
16143fb97780Smrg		os=sunos4.1.1
1615126a8a12Smrg		;;
1616300346aeSmrg	pru-*)
16176bea0e4fSmrg		os=
16186bea0e4fSmrg		obj=elf
1619300346aeSmrg		;;
1620126a8a12Smrg	*-be)
16213fb97780Smrg		os=beos
1622126a8a12Smrg		;;
1623126a8a12Smrg	*-ibm)
16243fb97780Smrg		os=aix
1625126a8a12Smrg		;;
16260a6b08f8Smrg	*-knuth)
16273fb97780Smrg		os=mmixware
1628126a8a12Smrg		;;
1629126a8a12Smrg	*-wec)
16303fb97780Smrg		os=proelf
1631126a8a12Smrg		;;
1632126a8a12Smrg	*-winbond)
16333fb97780Smrg		os=proelf
1634126a8a12Smrg		;;
1635126a8a12Smrg	*-oki)
16363fb97780Smrg		os=proelf
1637126a8a12Smrg		;;
1638126a8a12Smrg	*-hp)
16393fb97780Smrg		os=hpux
1640126a8a12Smrg		;;
1641126a8a12Smrg	*-hitachi)
16423fb97780Smrg		os=hiux
1643126a8a12Smrg		;;
1644126a8a12Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16453fb97780Smrg		os=sysv
1646126a8a12Smrg		;;
1647126a8a12Smrg	*-cbm)
16483fb97780Smrg		os=amigaos
1649126a8a12Smrg		;;
1650126a8a12Smrg	*-dg)
16513fb97780Smrg		os=dgux
1652126a8a12Smrg		;;
1653126a8a12Smrg	*-dolphin)
16543fb97780Smrg		os=sysv3
1655126a8a12Smrg		;;
1656126a8a12Smrg	m68k-ccur)
16573fb97780Smrg		os=rtu
1658126a8a12Smrg		;;
1659126a8a12Smrg	m88k-omron*)
16603fb97780Smrg		os=luna
1661126a8a12Smrg		;;
1662300346aeSmrg	*-next)
16633fb97780Smrg		os=nextstep
1664126a8a12Smrg		;;
1665126a8a12Smrg	*-sequent)
16663fb97780Smrg		os=ptx
1667126a8a12Smrg		;;
1668126a8a12Smrg	*-crds)
16693fb97780Smrg		os=unos
1670126a8a12Smrg		;;
1671126a8a12Smrg	*-ns)
16723fb97780Smrg		os=genix
1673126a8a12Smrg		;;
1674126a8a12Smrg	i370-*)
16753fb97780Smrg		os=mvs
1676126a8a12Smrg		;;
1677126a8a12Smrg	*-gould)
16783fb97780Smrg		os=sysv
1679126a8a12Smrg		;;
1680126a8a12Smrg	*-highlevel)
16813fb97780Smrg		os=bsd
1682126a8a12Smrg		;;
1683126a8a12Smrg	*-encore)
16843fb97780Smrg		os=bsd
1685126a8a12Smrg		;;
1686126a8a12Smrg	*-sgi)
16873fb97780Smrg		os=irix
1688126a8a12Smrg		;;
1689126a8a12Smrg	*-siemens)
16903fb97780Smrg		os=sysv4
1691126a8a12Smrg		;;
1692126a8a12Smrg	*-masscomp)
16933fb97780Smrg		os=rtu
1694126a8a12Smrg		;;
1695126a8a12Smrg	f30[01]-fujitsu | f700-fujitsu)
16963fb97780Smrg		os=uxpv
1697126a8a12Smrg		;;
1698126a8a12Smrg	*-rom68k)
16996bea0e4fSmrg		os=
17006bea0e4fSmrg		obj=coff
1701126a8a12Smrg		;;
1702126a8a12Smrg	*-*bug)
17036bea0e4fSmrg		os=
17046bea0e4fSmrg		obj=coff
1705126a8a12Smrg		;;
1706126a8a12Smrg	*-apple)
17073fb97780Smrg		os=macos
1708126a8a12Smrg		;;
1709126a8a12Smrg	*-atari*)
17103fb97780Smrg		os=mint
17113fb97780Smrg		;;
17123fb97780Smrg	*-wrs)
17133fb97780Smrg		os=vxworks
1714126a8a12Smrg		;;
1715126a8a12Smrg	*)
17163fb97780Smrg		os=none
1717126a8a12Smrg		;;
1718126a8a12Smrgesac
17193fb97780Smrg
1720126a8a12Smrgfi
1721126a8a12Smrg
17226bea0e4fSmrg# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
17236bea0e4fSmrg
17243fb97780Smrgcase $os in
17253fb97780Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17266bea0e4fSmrg	llvm* | musl* | newlib* | relibc* | uclibc*)
17273fb97780Smrg		;;
17283fb97780Smrg	# Likewise for "kernel-abi"
17293fb97780Smrg	eabi* | gnueabi*)
17303fb97780Smrg		;;
17313fb97780Smrg	# VxWorks passes extra cpu info in the 4th filed.
17323fb97780Smrg	simlinux | simwindows | spe)
17333fb97780Smrg		;;
17346bea0e4fSmrg	# See `case $cpu-$os` validation below
17356bea0e4fSmrg	ghcjs)
17366bea0e4fSmrg		;;
17373fb97780Smrg	# Now accept the basic system types.
17383fb97780Smrg	# The portable systems comes first.
17393fb97780Smrg	# Each alternative MUST end in a * to match a version number.
17403fb97780Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17413fb97780Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17423fb97780Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17433fb97780Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17443fb97780Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17456bea0e4fSmrg	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
17463fb97780Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17473fb97780Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17483fb97780Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17493fb97780Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17503fb97780Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17513fb97780Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17523fb97780Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17533fb97780Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17546bea0e4fSmrg	     | bosx* | nextstep* | cxux* | oabi* \
17556bea0e4fSmrg	     | ptx* | ecoff* | winnt* | domain* | vsta* \
17563fb97780Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17573fb97780Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17586bea0e4fSmrg	     | cygwin* | msys* | moss* | proelf* | rtems* \
17593fb97780Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17603fb97780Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17613fb97780Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17623fb97780Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17633fb97780Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17643fb97780Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17653fb97780Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17663fb97780Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17673fb97780Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17683fb97780Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17693fb97780Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17706bea0e4fSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17716bea0e4fSmrg	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
17723fb97780Smrg		;;
17733fb97780Smrg	# This one is extra strict with allowed versions
17743fb97780Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17753fb97780Smrg		# Don't forget version if it is 3.2v4 or newer.
17763fb97780Smrg		;;
17776bea0e4fSmrg	# This refers to builds using the UEFI calling convention
17786bea0e4fSmrg	# (which depends on the architecture) and PE file format.
17796bea0e4fSmrg	# Note that this is both a different calling convention and
17806bea0e4fSmrg	# different file format than that of GNU-EFI
17816bea0e4fSmrg	# (x86_64-w64-mingw32).
17826bea0e4fSmrg	uefi)
17836bea0e4fSmrg		;;
17843fb97780Smrg	none)
17853fb97780Smrg		;;
17866bea0e4fSmrg	kernel* | msvc* )
17876bea0e4fSmrg		# Restricted further below
17886bea0e4fSmrg		;;
17896bea0e4fSmrg	'')
17906bea0e4fSmrg		if test x"$obj" = x
17916bea0e4fSmrg		then
17926bea0e4fSmrg			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
17936bea0e4fSmrg		fi
17946bea0e4fSmrg		;;
17953fb97780Smrg	*)
17966bea0e4fSmrg		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
17976bea0e4fSmrg		exit 1
17986bea0e4fSmrg		;;
17996bea0e4fSmrgesac
18006bea0e4fSmrg
18016bea0e4fSmrgcase $obj in
18026bea0e4fSmrg	aout* | coff* | elf* | pe*)
18036bea0e4fSmrg		;;
18046bea0e4fSmrg	'')
18056bea0e4fSmrg		# empty is fine
18066bea0e4fSmrg		;;
18076bea0e4fSmrg	*)
18086bea0e4fSmrg		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
18096bea0e4fSmrg		exit 1
18106bea0e4fSmrg		;;
18116bea0e4fSmrgesac
18126bea0e4fSmrg
18136bea0e4fSmrg# Here we handle the constraint that a (synthetic) cpu and os are
18146bea0e4fSmrg# valid only in combination with each other and nowhere else.
18156bea0e4fSmrgcase $cpu-$os in
18166bea0e4fSmrg	# The "javascript-unknown-ghcjs" triple is used by GHC; we
18176bea0e4fSmrg	# accept it here in order to tolerate that, but reject any
18186bea0e4fSmrg	# variations.
18196bea0e4fSmrg	javascript-ghcjs)
18206bea0e4fSmrg		;;
18216bea0e4fSmrg	javascript-* | *-ghcjs)
18226bea0e4fSmrg		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
18233fb97780Smrg		exit 1
18243fb97780Smrg		;;
18253fb97780Smrgesac
18263fb97780Smrg
18273fb97780Smrg# As a final step for OS-related things, validate the OS-kernel combination
18283fb97780Smrg# (given a valid OS), if there is a kernel.
18296bea0e4fSmrgcase $kernel-$os-$obj in
18306bea0e4fSmrg	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
18316bea0e4fSmrg		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
18326bea0e4fSmrg		    | linux-relibc*- | linux-uclibc*- )
18336bea0e4fSmrg		;;
18346bea0e4fSmrg	uclinux-uclibc*- )
18356bea0e4fSmrg		;;
18366bea0e4fSmrg	managarm-mlibc*- | managarm-kernel*- )
18373fb97780Smrg		;;
18386bea0e4fSmrg	windows*-msvc*-)
18393fb97780Smrg		;;
18406bea0e4fSmrg	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
18416bea0e4fSmrg		    | -uclibc*- )
18423fb97780Smrg		# These are just libc implementations, not actual OSes, and thus
18433fb97780Smrg		# require a kernel.
18446bea0e4fSmrg		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
18453fb97780Smrg		exit 1
18463fb97780Smrg		;;
18476bea0e4fSmrg	-kernel*- )
18486bea0e4fSmrg		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
18496bea0e4fSmrg		exit 1
18503fb97780Smrg		;;
18516bea0e4fSmrg	*-kernel*- )
18526bea0e4fSmrg		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
18536bea0e4fSmrg		exit 1
18543fb97780Smrg		;;
18556bea0e4fSmrg	*-msvc*- )
18566bea0e4fSmrg		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
18576bea0e4fSmrg		exit 1
18583fb97780Smrg		;;
18596bea0e4fSmrg	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
18606bea0e4fSmrg		;;
18616bea0e4fSmrg	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
18626bea0e4fSmrg		;;
18636bea0e4fSmrg	nto-qnx*-)
18646bea0e4fSmrg		;;
18656bea0e4fSmrg	os2-emx-)
18663fb97780Smrg		;;
18676bea0e4fSmrg	*-eabi*- | *-gnueabi*-)
18683fb97780Smrg		;;
18696bea0e4fSmrg	none--*)
18706bea0e4fSmrg		# None (no kernel, i.e. freestanding / bare metal),
18716bea0e4fSmrg		# can be paired with an machine code file format
18726bea0e4fSmrg		;;
18736bea0e4fSmrg	-*-)
18743fb97780Smrg		# Blank kernel with real OS is always fine.
18753fb97780Smrg		;;
18766bea0e4fSmrg	--*)
18776bea0e4fSmrg		# Blank kernel and OS with real machine code file format is always fine.
18786bea0e4fSmrg		;;
18796bea0e4fSmrg	*-*-*)
18806bea0e4fSmrg		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
18813fb97780Smrg		exit 1
18823fb97780Smrg		;;
18833fb97780Smrgesac
18843fb97780Smrg
1885126a8a12Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1886126a8a12Smrg# manufacturer.  We pick the logical manufacturer.
18873fb97780Smrgcase $vendor in
18883fb97780Smrg	unknown)
18893fb97780Smrg		case $cpu-$os in
18903fb97780Smrg			*-riscix*)
1891126a8a12Smrg				vendor=acorn
1892126a8a12Smrg				;;
18933fb97780Smrg			*-sunos*)
1894126a8a12Smrg				vendor=sun
1895126a8a12Smrg				;;
18963fb97780Smrg			*-cnk* | *-aix*)
1897126a8a12Smrg				vendor=ibm
1898126a8a12Smrg				;;
18993fb97780Smrg			*-beos*)
1900126a8a12Smrg				vendor=be
1901126a8a12Smrg				;;
19023fb97780Smrg			*-hpux*)
1903126a8a12Smrg				vendor=hp
1904126a8a12Smrg				;;
19053fb97780Smrg			*-mpeix*)
1906126a8a12Smrg				vendor=hp
1907126a8a12Smrg				;;
19083fb97780Smrg			*-hiux*)
1909126a8a12Smrg				vendor=hitachi
1910126a8a12Smrg				;;
19113fb97780Smrg			*-unos*)
1912126a8a12Smrg				vendor=crds
1913126a8a12Smrg				;;
19143fb97780Smrg			*-dgux*)
1915126a8a12Smrg				vendor=dg
1916126a8a12Smrg				;;
19173fb97780Smrg			*-luna*)
1918126a8a12Smrg				vendor=omron
1919126a8a12Smrg				;;
19203fb97780Smrg			*-genix*)
1921126a8a12Smrg				vendor=ns
1922126a8a12Smrg				;;
19233fb97780Smrg			*-clix*)
19243fb97780Smrg				vendor=intergraph
19253fb97780Smrg				;;
19263fb97780Smrg			*-mvs* | *-opened*)
19273fb97780Smrg				vendor=ibm
19283fb97780Smrg				;;
19293fb97780Smrg			*-os400*)
1930126a8a12Smrg				vendor=ibm
1931126a8a12Smrg				;;
19323fb97780Smrg			s390-* | s390x-*)
1933126a8a12Smrg				vendor=ibm
1934126a8a12Smrg				;;
19353fb97780Smrg			*-ptx*)
1936126a8a12Smrg				vendor=sequent
1937126a8a12Smrg				;;
19383fb97780Smrg			*-tpf*)
1939126a8a12Smrg				vendor=ibm
1940126a8a12Smrg				;;
19413fb97780Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1942126a8a12Smrg				vendor=wrs
1943126a8a12Smrg				;;
19443fb97780Smrg			*-aux*)
1945126a8a12Smrg				vendor=apple
1946126a8a12Smrg				;;
19473fb97780Smrg			*-hms*)
1948126a8a12Smrg				vendor=hitachi
1949126a8a12Smrg				;;
19503fb97780Smrg			*-mpw* | *-macos*)
1951126a8a12Smrg				vendor=apple
1952126a8a12Smrg				;;
19533fb97780Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1954126a8a12Smrg				vendor=atari
1955126a8a12Smrg				;;
19563fb97780Smrg			*-vos*)
1957126a8a12Smrg				vendor=stratus
1958126a8a12Smrg				;;
1959126a8a12Smrg		esac
1960126a8a12Smrg		;;
1961126a8a12Smrgesac
1962126a8a12Smrg
19636bea0e4fSmrgecho "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
1964126a8a12Smrgexit
1965126a8a12Smrg
1966126a8a12Smrg# Local variables:
19673fb97780Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1968126a8a12Smrg# time-stamp-start: "timestamp='"
1969126a8a12Smrg# time-stamp-format: "%:y-%02m-%02d"
1970126a8a12Smrg# time-stamp-end: "'"
1971126a8a12Smrg# End:
1972