1b042e37fSmrg#! /bin/sh
2b042e37fSmrg# Configuration validation subroutine script.
30c674dbdSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4b042e37fSmrg
58d0bc965Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
68d0bc965Smrg
70c674dbdSmrgtimestamp='2023-01-21'
8b042e37fSmrg
98bd17e5fSmrg# This file is free software; you can redistribute it and/or modify it
108bd17e5fSmrg# under the terms of the GNU General Public License as published by
110c674dbdSmrg# the Free Software Foundation, either version 3 of the License, or
12b042e37fSmrg# (at your option) any later version.
13b042e37fSmrg#
148bd17e5fSmrg# This program is distributed in the hope that it will be useful, but
158bd17e5fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
168bd17e5fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
178bd17e5fSmrg# General Public License for more details.
18b042e37fSmrg#
19b042e37fSmrg# You should have received a copy of the GNU General Public License
203169be4bSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
218c4a8e55Smrg#
22b042e37fSmrg# As a special exception to the GNU General Public License, if you
23b042e37fSmrg# distribute this file as part of a program that contains a
24b042e37fSmrg# configuration script generated by Autoconf, you may include it under
258bd17e5fSmrg# the same distribution terms that you use for the rest of that
268bd17e5fSmrg# program.  This Exception is an additional permission under section 7
278bd17e5fSmrg# of the GNU General Public License, version 3 ("GPLv3").
28b042e37fSmrg
298c4a8e55Smrg
303169be4bSmrg# Please send patches to <config-patches@gnu.org>.
31b042e37fSmrg#
32b042e37fSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33b042e37fSmrg# Supply the specified configuration type as an argument.
34b042e37fSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35b042e37fSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36b042e37fSmrg
37706b6b52Smrg# You can get the latest version of this script from:
388d0bc965Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39706b6b52Smrg
40b042e37fSmrg# This file is supposed to be the same for all GNU packages
41b042e37fSmrg# and recognize all the CPU types, system types and aliases
42b042e37fSmrg# that are meaningful with *any* GNU software.
43b042e37fSmrg# Each package is responsible for reporting which valid configurations
44b042e37fSmrg# it does not support.  The user should be able to distinguish
45b042e37fSmrg# a failure to support a valid configuration from a meaningless
46b042e37fSmrg# configuration.
47b042e37fSmrg
48b042e37fSmrg# The goal of this file is to map all the various variations of a given
49b042e37fSmrg# machine specification into a single specification in the form:
50b042e37fSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51b042e37fSmrg# or in some cases, the newer four-part form:
52b042e37fSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53b042e37fSmrg# It is wrong to echo any other type of specification.
54b042e37fSmrg
558d0bc965Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
568d0bc965Smrg# about features and limitations of the classic Bourne shell that were
578d0bc965Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
588d0bc965Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
598d0bc965Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
608d0bc965Smrg# have a pre-POSIX /bin/sh.
618d0bc965Smrg
62b042e37fSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63b042e37fSmrg
64b042e37fSmrgusage="\
653169be4bSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66b042e37fSmrg
67b042e37fSmrgCanonicalize a configuration name.
68b042e37fSmrg
693169be4bSmrgOptions:
70b042e37fSmrg  -h, --help         print this help, then exit
71b042e37fSmrg  -t, --time-stamp   print date of last modification, then exit
72b042e37fSmrg  -v, --version      print version number, then exit
73b042e37fSmrg
74b042e37fSmrgReport bugs and patches to <config-patches@gnu.org>."
75b042e37fSmrg
76b042e37fSmrgversion="\
77b042e37fSmrgGNU config.sub ($timestamp)
78b042e37fSmrg
790c674dbdSmrgCopyright 1992-2023 Free Software Foundation, Inc.
80b042e37fSmrg
81b042e37fSmrgThis is free software; see the source for copying conditions.  There is NO
82b042e37fSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83b042e37fSmrg
84b042e37fSmrghelp="
85b042e37fSmrgTry \`$me --help' for more information."
86b042e37fSmrg
87b042e37fSmrg# Parse command line
88b042e37fSmrgwhile test $# -gt 0 ; do
89b042e37fSmrg  case $1 in
90b042e37fSmrg    --time-stamp | --time* | -t )
918c4a8e55Smrg       echo "$timestamp" ; exit ;;
92b042e37fSmrg    --version | -v )
938c4a8e55Smrg       echo "$version" ; exit ;;
94b042e37fSmrg    --help | --h* | -h )
958c4a8e55Smrg       echo "$usage"; exit ;;
96b042e37fSmrg    -- )     # Stop option processing
97b042e37fSmrg       shift; break ;;
98b042e37fSmrg    - )	# Use stdin as input.
99b042e37fSmrg       break ;;
100b042e37fSmrg    -* )
1018d0bc965Smrg       echo "$me: invalid option $1$help" >&2
102b042e37fSmrg       exit 1 ;;
103b042e37fSmrg
104b042e37fSmrg    *local*)
105b042e37fSmrg       # First pass through any local machine types.
1063169be4bSmrg       echo "$1"
1078c4a8e55Smrg       exit ;;
108b042e37fSmrg
109b042e37fSmrg    * )
110b042e37fSmrg       break ;;
111b042e37fSmrg  esac
112b042e37fSmrgdone
113b042e37fSmrg
114b042e37fSmrgcase $# in
115b042e37fSmrg 0) echo "$me: missing argument$help" >&2
116b042e37fSmrg    exit 1;;
117b042e37fSmrg 1) ;;
118b042e37fSmrg *) echo "$me: too many arguments$help" >&2
119b042e37fSmrg    exit 1;;
120b042e37fSmrgesac
121b042e37fSmrg
1228d0bc965Smrg# Split fields of configuration type
1238d0bc965Smrg# shellcheck disable=SC2162
1248d0bc965Smrgsaved_IFS=$IFS
1258d0bc965SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1268d0bc965Smrg$1
1278d0bc965SmrgEOF
1288d0bc965SmrgIFS=$saved_IFS
129b042e37fSmrg
1308d0bc965Smrg# Separate into logical components for further validation
1318d0bc965Smrgcase $1 in
1328d0bc965Smrg	*-*-*-*-*)
1338d0bc965Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
1348d0bc965Smrg		exit 1
1358bd17e5fSmrg		;;
1368d0bc965Smrg	*-*-*-*)
1378d0bc965Smrg		basic_machine=$field1-$field2
1388d0bc965Smrg		basic_os=$field3-$field4
139b042e37fSmrg		;;
1408d0bc965Smrg	*-*-*)
1418d0bc965Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1428d0bc965Smrg		# parts
1438d0bc965Smrg		maybe_os=$field2-$field3
1448d0bc965Smrg		case $maybe_os in
1458d0bc965Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1468d0bc965Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1478d0bc965Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1480c674dbdSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
1498d0bc965Smrg				basic_machine=$field1
1508d0bc965Smrg				basic_os=$maybe_os
1518d0bc965Smrg				;;
1528d0bc965Smrg			android-linux)
1538d0bc965Smrg				basic_machine=$field1-unknown
1548d0bc965Smrg				basic_os=linux-android
1558d0bc965Smrg				;;
1568d0bc965Smrg			*)
1578d0bc965Smrg				basic_machine=$field1-$field2
1588d0bc965Smrg				basic_os=$field3
1598d0bc965Smrg				;;
1608d0bc965Smrg		esac
161b042e37fSmrg		;;
1628d0bc965Smrg	*-*)
1638d0bc965Smrg		# A lone config we happen to match not fitting any pattern
1648d0bc965Smrg		case $field1-$field2 in
1658d0bc965Smrg			decstation-3100)
1668d0bc965Smrg				basic_machine=mips-dec
1678d0bc965Smrg				basic_os=
1688d0bc965Smrg				;;
1698d0bc965Smrg			*-*)
1708d0bc965Smrg				# Second component is usually, but not always the OS
1718d0bc965Smrg				case $field2 in
1728d0bc965Smrg					# Prevent following clause from handling this valid os
1738d0bc965Smrg					sun*os*)
1748d0bc965Smrg						basic_machine=$field1
1758d0bc965Smrg						basic_os=$field2
1768d0bc965Smrg						;;
1778d0bc965Smrg					zephyr*)
1788d0bc965Smrg						basic_machine=$field1-unknown
1798d0bc965Smrg						basic_os=$field2
1808d0bc965Smrg						;;
1818d0bc965Smrg					# Manufacturers
1828d0bc965Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1838d0bc965Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1848d0bc965Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1858d0bc965Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1868d0bc965Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1878d0bc965Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1888d0bc965Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1898d0bc965Smrg					| microblaze* | sim | cisco \
1908d0bc965Smrg					| oki | wec | wrs | winbond)
1918d0bc965Smrg						basic_machine=$field1-$field2
1928d0bc965Smrg						basic_os=
1938d0bc965Smrg						;;
1948d0bc965Smrg					*)
1958d0bc965Smrg						basic_machine=$field1
1968d0bc965Smrg						basic_os=$field2
1978d0bc965Smrg						;;
1988d0bc965Smrg				esac
1998d0bc965Smrg			;;
2008d0bc965Smrg		esac
201b042e37fSmrg		;;
2028d0bc965Smrg	*)
2038d0bc965Smrg		# Convert single-component short-hands not valid as part of
2048d0bc965Smrg		# multi-component configurations.
2058d0bc965Smrg		case $field1 in
2068d0bc965Smrg			386bsd)
2078d0bc965Smrg				basic_machine=i386-pc
2088d0bc965Smrg				basic_os=bsd
2098d0bc965Smrg				;;
2108d0bc965Smrg			a29khif)
2118d0bc965Smrg				basic_machine=a29k-amd
2128d0bc965Smrg				basic_os=udi
2138d0bc965Smrg				;;
2148d0bc965Smrg			adobe68k)
2158d0bc965Smrg				basic_machine=m68010-adobe
2168d0bc965Smrg				basic_os=scout
2178d0bc965Smrg				;;
2188d0bc965Smrg			alliant)
2198d0bc965Smrg				basic_machine=fx80-alliant
2208d0bc965Smrg				basic_os=
2218d0bc965Smrg				;;
2228d0bc965Smrg			altos | altos3068)
2238d0bc965Smrg				basic_machine=m68k-altos
2248d0bc965Smrg				basic_os=
2258d0bc965Smrg				;;
2268d0bc965Smrg			am29k)
2278d0bc965Smrg				basic_machine=a29k-none
2288d0bc965Smrg				basic_os=bsd
2298d0bc965Smrg				;;
2308d0bc965Smrg			amdahl)
2318d0bc965Smrg				basic_machine=580-amdahl
2328d0bc965Smrg				basic_os=sysv
2338d0bc965Smrg				;;
2348d0bc965Smrg			amiga)
2358d0bc965Smrg				basic_machine=m68k-unknown
2368d0bc965Smrg				basic_os=
2378d0bc965Smrg				;;
2388d0bc965Smrg			amigaos | amigados)
2398d0bc965Smrg				basic_machine=m68k-unknown
2408d0bc965Smrg				basic_os=amigaos
2418d0bc965Smrg				;;
2428d0bc965Smrg			amigaunix | amix)
2438d0bc965Smrg				basic_machine=m68k-unknown
2448d0bc965Smrg				basic_os=sysv4
2458d0bc965Smrg				;;
2468d0bc965Smrg			apollo68)
2478d0bc965Smrg				basic_machine=m68k-apollo
2488d0bc965Smrg				basic_os=sysv
2498d0bc965Smrg				;;
2508d0bc965Smrg			apollo68bsd)
2518d0bc965Smrg				basic_machine=m68k-apollo
2528d0bc965Smrg				basic_os=bsd
2538d0bc965Smrg				;;
2548d0bc965Smrg			aros)
2558d0bc965Smrg				basic_machine=i386-pc
2568d0bc965Smrg				basic_os=aros
2578d0bc965Smrg				;;
2588d0bc965Smrg			aux)
2598d0bc965Smrg				basic_machine=m68k-apple
2608d0bc965Smrg				basic_os=aux
2618d0bc965Smrg				;;
2628d0bc965Smrg			balance)
2638d0bc965Smrg				basic_machine=ns32k-sequent
2648d0bc965Smrg				basic_os=dynix
2658d0bc965Smrg				;;
2668d0bc965Smrg			blackfin)
2678d0bc965Smrg				basic_machine=bfin-unknown
2688d0bc965Smrg				basic_os=linux
2698d0bc965Smrg				;;
2708d0bc965Smrg			cegcc)
2718d0bc965Smrg				basic_machine=arm-unknown
2728d0bc965Smrg				basic_os=cegcc
2738d0bc965Smrg				;;
2748d0bc965Smrg			convex-c1)
2758d0bc965Smrg				basic_machine=c1-convex
2768d0bc965Smrg				basic_os=bsd
2778d0bc965Smrg				;;
2788d0bc965Smrg			convex-c2)
2798d0bc965Smrg				basic_machine=c2-convex
2808d0bc965Smrg				basic_os=bsd
2818d0bc965Smrg				;;
2828d0bc965Smrg			convex-c32)
2838d0bc965Smrg				basic_machine=c32-convex
2848d0bc965Smrg				basic_os=bsd
2858d0bc965Smrg				;;
2868d0bc965Smrg			convex-c34)
2878d0bc965Smrg				basic_machine=c34-convex
2888d0bc965Smrg				basic_os=bsd
2898d0bc965Smrg				;;
2908d0bc965Smrg			convex-c38)
2918d0bc965Smrg				basic_machine=c38-convex
2928d0bc965Smrg				basic_os=bsd
2938d0bc965Smrg				;;
2948d0bc965Smrg			cray)
2958d0bc965Smrg				basic_machine=j90-cray
2968d0bc965Smrg				basic_os=unicos
2978d0bc965Smrg				;;
2988d0bc965Smrg			crds | unos)
2998d0bc965Smrg				basic_machine=m68k-crds
3008d0bc965Smrg				basic_os=
3018d0bc965Smrg				;;
3028d0bc965Smrg			da30)
3038d0bc965Smrg				basic_machine=m68k-da30
3048d0bc965Smrg				basic_os=
3058d0bc965Smrg				;;
3068d0bc965Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3078d0bc965Smrg				basic_machine=mips-dec
3088d0bc965Smrg				basic_os=
3098d0bc965Smrg				;;
3108d0bc965Smrg			delta88)
3118d0bc965Smrg				basic_machine=m88k-motorola
3128d0bc965Smrg				basic_os=sysv3
3138d0bc965Smrg				;;
3148d0bc965Smrg			dicos)
3158d0bc965Smrg				basic_machine=i686-pc
3168d0bc965Smrg				basic_os=dicos
3178d0bc965Smrg				;;
3188d0bc965Smrg			djgpp)
3198d0bc965Smrg				basic_machine=i586-pc
3208d0bc965Smrg				basic_os=msdosdjgpp
3218d0bc965Smrg				;;
3228d0bc965Smrg			ebmon29k)
3238d0bc965Smrg				basic_machine=a29k-amd
3248d0bc965Smrg				basic_os=ebmon
3258d0bc965Smrg				;;
3268d0bc965Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3278d0bc965Smrg				basic_machine=m68k-ericsson
3288d0bc965Smrg				basic_os=ose
3298d0bc965Smrg				;;
3308d0bc965Smrg			gmicro)
3318d0bc965Smrg				basic_machine=tron-gmicro
3328d0bc965Smrg				basic_os=sysv
3338d0bc965Smrg				;;
3348d0bc965Smrg			go32)
3358d0bc965Smrg				basic_machine=i386-pc
3368d0bc965Smrg				basic_os=go32
3378d0bc965Smrg				;;
3388d0bc965Smrg			h8300hms)
3398d0bc965Smrg				basic_machine=h8300-hitachi
3408d0bc965Smrg				basic_os=hms
3418d0bc965Smrg				;;
3428d0bc965Smrg			h8300xray)
3438d0bc965Smrg				basic_machine=h8300-hitachi
3448d0bc965Smrg				basic_os=xray
3458d0bc965Smrg				;;
3468d0bc965Smrg			h8500hms)
3478d0bc965Smrg				basic_machine=h8500-hitachi
3488d0bc965Smrg				basic_os=hms
3498d0bc965Smrg				;;
3508d0bc965Smrg			harris)
3518d0bc965Smrg				basic_machine=m88k-harris
3528d0bc965Smrg				basic_os=sysv3
3538d0bc965Smrg				;;
3548d0bc965Smrg			hp300 | hp300hpux)
3558d0bc965Smrg				basic_machine=m68k-hp
3568d0bc965Smrg				basic_os=hpux
3578d0bc965Smrg				;;
3588d0bc965Smrg			hp300bsd)
3598d0bc965Smrg				basic_machine=m68k-hp
3608d0bc965Smrg				basic_os=bsd
3618d0bc965Smrg				;;
3628d0bc965Smrg			hppaosf)
3638d0bc965Smrg				basic_machine=hppa1.1-hp
3648d0bc965Smrg				basic_os=osf
3658d0bc965Smrg				;;
3668d0bc965Smrg			hppro)
3678d0bc965Smrg				basic_machine=hppa1.1-hp
3688d0bc965Smrg				basic_os=proelf
3698d0bc965Smrg				;;
3708d0bc965Smrg			i386mach)
3718d0bc965Smrg				basic_machine=i386-mach
3728d0bc965Smrg				basic_os=mach
3738d0bc965Smrg				;;
3748d0bc965Smrg			isi68 | isi)
3758d0bc965Smrg				basic_machine=m68k-isi
3768d0bc965Smrg				basic_os=sysv
3778d0bc965Smrg				;;
3788d0bc965Smrg			m68knommu)
3798d0bc965Smrg				basic_machine=m68k-unknown
3808d0bc965Smrg				basic_os=linux
3818d0bc965Smrg				;;
3828d0bc965Smrg			magnum | m3230)
3838d0bc965Smrg				basic_machine=mips-mips
3848d0bc965Smrg				basic_os=sysv
3858d0bc965Smrg				;;
3868d0bc965Smrg			merlin)
3878d0bc965Smrg				basic_machine=ns32k-utek
3888d0bc965Smrg				basic_os=sysv
3898d0bc965Smrg				;;
3908d0bc965Smrg			mingw64)
3918d0bc965Smrg				basic_machine=x86_64-pc
3928d0bc965Smrg				basic_os=mingw64
3938d0bc965Smrg				;;
3948d0bc965Smrg			mingw32)
3958d0bc965Smrg				basic_machine=i686-pc
3968d0bc965Smrg				basic_os=mingw32
3978d0bc965Smrg				;;
3988d0bc965Smrg			mingw32ce)
3998d0bc965Smrg				basic_machine=arm-unknown
4008d0bc965Smrg				basic_os=mingw32ce
4018d0bc965Smrg				;;
4028d0bc965Smrg			monitor)
4038d0bc965Smrg				basic_machine=m68k-rom68k
4048d0bc965Smrg				basic_os=coff
4058d0bc965Smrg				;;
4068d0bc965Smrg			morphos)
4078d0bc965Smrg				basic_machine=powerpc-unknown
4088d0bc965Smrg				basic_os=morphos
4098d0bc965Smrg				;;
4108d0bc965Smrg			moxiebox)
4118d0bc965Smrg				basic_machine=moxie-unknown
4128d0bc965Smrg				basic_os=moxiebox
4138d0bc965Smrg				;;
4148d0bc965Smrg			msdos)
4158d0bc965Smrg				basic_machine=i386-pc
4168d0bc965Smrg				basic_os=msdos
4178d0bc965Smrg				;;
4188d0bc965Smrg			msys)
4198d0bc965Smrg				basic_machine=i686-pc
4208d0bc965Smrg				basic_os=msys
4218d0bc965Smrg				;;
4228d0bc965Smrg			mvs)
4238d0bc965Smrg				basic_machine=i370-ibm
4248d0bc965Smrg				basic_os=mvs
4258d0bc965Smrg				;;
4268d0bc965Smrg			nacl)
4278d0bc965Smrg				basic_machine=le32-unknown
4288d0bc965Smrg				basic_os=nacl
4298d0bc965Smrg				;;
4308d0bc965Smrg			ncr3000)
4318d0bc965Smrg				basic_machine=i486-ncr
4328d0bc965Smrg				basic_os=sysv4
4338d0bc965Smrg				;;
4348d0bc965Smrg			netbsd386)
4358d0bc965Smrg				basic_machine=i386-pc
4368d0bc965Smrg				basic_os=netbsd
4378d0bc965Smrg				;;
4388d0bc965Smrg			netwinder)
4398d0bc965Smrg				basic_machine=armv4l-rebel
4408d0bc965Smrg				basic_os=linux
4418d0bc965Smrg				;;
4428d0bc965Smrg			news | news700 | news800 | news900)
4438d0bc965Smrg				basic_machine=m68k-sony
4448d0bc965Smrg				basic_os=newsos
4458d0bc965Smrg				;;
4468d0bc965Smrg			news1000)
4478d0bc965Smrg				basic_machine=m68030-sony
4488d0bc965Smrg				basic_os=newsos
4498d0bc965Smrg				;;
4508d0bc965Smrg			necv70)
4518d0bc965Smrg				basic_machine=v70-nec
4528d0bc965Smrg				basic_os=sysv
4538d0bc965Smrg				;;
4548d0bc965Smrg			nh3000)
4558d0bc965Smrg				basic_machine=m68k-harris
4568d0bc965Smrg				basic_os=cxux
4578d0bc965Smrg				;;
4588d0bc965Smrg			nh[45]000)
4598d0bc965Smrg				basic_machine=m88k-harris
4608d0bc965Smrg				basic_os=cxux
4618d0bc965Smrg				;;
4628d0bc965Smrg			nindy960)
4638d0bc965Smrg				basic_machine=i960-intel
4648d0bc965Smrg				basic_os=nindy
4658d0bc965Smrg				;;
4668d0bc965Smrg			mon960)
4678d0bc965Smrg				basic_machine=i960-intel
4688d0bc965Smrg				basic_os=mon960
4698d0bc965Smrg				;;
4708d0bc965Smrg			nonstopux)
4718d0bc965Smrg				basic_machine=mips-compaq
4728d0bc965Smrg				basic_os=nonstopux
4738d0bc965Smrg				;;
4748d0bc965Smrg			os400)
4758d0bc965Smrg				basic_machine=powerpc-ibm
4768d0bc965Smrg				basic_os=os400
4778d0bc965Smrg				;;
4788d0bc965Smrg			OSE68000 | ose68000)
4798d0bc965Smrg				basic_machine=m68000-ericsson
4808d0bc965Smrg				basic_os=ose
4818d0bc965Smrg				;;
4828d0bc965Smrg			os68k)
4838d0bc965Smrg				basic_machine=m68k-none
4848d0bc965Smrg				basic_os=os68k
4858d0bc965Smrg				;;
4868d0bc965Smrg			paragon)
4878d0bc965Smrg				basic_machine=i860-intel
4888d0bc965Smrg				basic_os=osf
4898d0bc965Smrg				;;
4908d0bc965Smrg			parisc)
4918d0bc965Smrg				basic_machine=hppa-unknown
4928d0bc965Smrg				basic_os=linux
4938d0bc965Smrg				;;
4948d0bc965Smrg			psp)
4958d0bc965Smrg				basic_machine=mipsallegrexel-sony
4968d0bc965Smrg				basic_os=psp
4978d0bc965Smrg				;;
4988d0bc965Smrg			pw32)
4998d0bc965Smrg				basic_machine=i586-unknown
5008d0bc965Smrg				basic_os=pw32
5018d0bc965Smrg				;;
5028d0bc965Smrg			rdos | rdos64)
5038d0bc965Smrg				basic_machine=x86_64-pc
5048d0bc965Smrg				basic_os=rdos
5058d0bc965Smrg				;;
5068d0bc965Smrg			rdos32)
5078d0bc965Smrg				basic_machine=i386-pc
5088d0bc965Smrg				basic_os=rdos
5098d0bc965Smrg				;;
5108d0bc965Smrg			rom68k)
5118d0bc965Smrg				basic_machine=m68k-rom68k
5128d0bc965Smrg				basic_os=coff
5138d0bc965Smrg				;;
5148d0bc965Smrg			sa29200)
5158d0bc965Smrg				basic_machine=a29k-amd
5168d0bc965Smrg				basic_os=udi
5178d0bc965Smrg				;;
5188d0bc965Smrg			sei)
5198d0bc965Smrg				basic_machine=mips-sei
5208d0bc965Smrg				basic_os=seiux
5218d0bc965Smrg				;;
5228d0bc965Smrg			sequent)
5238d0bc965Smrg				basic_machine=i386-sequent
5248d0bc965Smrg				basic_os=
5258d0bc965Smrg				;;
5268d0bc965Smrg			sps7)
5278d0bc965Smrg				basic_machine=m68k-bull
5288d0bc965Smrg				basic_os=sysv2
5298d0bc965Smrg				;;
5308d0bc965Smrg			st2000)
5318d0bc965Smrg				basic_machine=m68k-tandem
5328d0bc965Smrg				basic_os=
5338d0bc965Smrg				;;
5348d0bc965Smrg			stratus)
5358d0bc965Smrg				basic_machine=i860-stratus
5368d0bc965Smrg				basic_os=sysv4
5378d0bc965Smrg				;;
5388d0bc965Smrg			sun2)
5398d0bc965Smrg				basic_machine=m68000-sun
5408d0bc965Smrg				basic_os=
5418d0bc965Smrg				;;
5428d0bc965Smrg			sun2os3)
5438d0bc965Smrg				basic_machine=m68000-sun
5448d0bc965Smrg				basic_os=sunos3
5458d0bc965Smrg				;;
5468d0bc965Smrg			sun2os4)
5478d0bc965Smrg				basic_machine=m68000-sun
5488d0bc965Smrg				basic_os=sunos4
5498d0bc965Smrg				;;
5508d0bc965Smrg			sun3)
5518d0bc965Smrg				basic_machine=m68k-sun
5528d0bc965Smrg				basic_os=
5538d0bc965Smrg				;;
5548d0bc965Smrg			sun3os3)
5558d0bc965Smrg				basic_machine=m68k-sun
5568d0bc965Smrg				basic_os=sunos3
5578d0bc965Smrg				;;
5588d0bc965Smrg			sun3os4)
5598d0bc965Smrg				basic_machine=m68k-sun
5608d0bc965Smrg				basic_os=sunos4
5618d0bc965Smrg				;;
5628d0bc965Smrg			sun4)
5638d0bc965Smrg				basic_machine=sparc-sun
5648d0bc965Smrg				basic_os=
5658d0bc965Smrg				;;
5668d0bc965Smrg			sun4os3)
5678d0bc965Smrg				basic_machine=sparc-sun
5688d0bc965Smrg				basic_os=sunos3
5698d0bc965Smrg				;;
5708d0bc965Smrg			sun4os4)
5718d0bc965Smrg				basic_machine=sparc-sun
5728d0bc965Smrg				basic_os=sunos4
5738d0bc965Smrg				;;
5748d0bc965Smrg			sun4sol2)
5758d0bc965Smrg				basic_machine=sparc-sun
5768d0bc965Smrg				basic_os=solaris2
5778d0bc965Smrg				;;
5788d0bc965Smrg			sun386 | sun386i | roadrunner)
5798d0bc965Smrg				basic_machine=i386-sun
5808d0bc965Smrg				basic_os=
5818d0bc965Smrg				;;
5828d0bc965Smrg			sv1)
5838d0bc965Smrg				basic_machine=sv1-cray
5848d0bc965Smrg				basic_os=unicos
5858d0bc965Smrg				;;
5868d0bc965Smrg			symmetry)
5878d0bc965Smrg				basic_machine=i386-sequent
5888d0bc965Smrg				basic_os=dynix
5898d0bc965Smrg				;;
5908d0bc965Smrg			t3e)
5918d0bc965Smrg				basic_machine=alphaev5-cray
5928d0bc965Smrg				basic_os=unicos
5938d0bc965Smrg				;;
5948d0bc965Smrg			t90)
5958d0bc965Smrg				basic_machine=t90-cray
5968d0bc965Smrg				basic_os=unicos
5978d0bc965Smrg				;;
5988d0bc965Smrg			toad1)
5998d0bc965Smrg				basic_machine=pdp10-xkl
6008d0bc965Smrg				basic_os=tops20
6018d0bc965Smrg				;;
6028d0bc965Smrg			tpf)
6038d0bc965Smrg				basic_machine=s390x-ibm
6048d0bc965Smrg				basic_os=tpf
6058d0bc965Smrg				;;
6068d0bc965Smrg			udi29k)
6078d0bc965Smrg				basic_machine=a29k-amd
6088d0bc965Smrg				basic_os=udi
6098d0bc965Smrg				;;
6108d0bc965Smrg			ultra3)
6118d0bc965Smrg				basic_machine=a29k-nyu
6128d0bc965Smrg				basic_os=sym1
6138d0bc965Smrg				;;
6148d0bc965Smrg			v810 | necv810)
6158d0bc965Smrg				basic_machine=v810-nec
6168d0bc965Smrg				basic_os=none
6178d0bc965Smrg				;;
6188d0bc965Smrg			vaxv)
6198d0bc965Smrg				basic_machine=vax-dec
6208d0bc965Smrg				basic_os=sysv
6218d0bc965Smrg				;;
6228d0bc965Smrg			vms)
6238d0bc965Smrg				basic_machine=vax-dec
6248d0bc965Smrg				basic_os=vms
6258d0bc965Smrg				;;
6268d0bc965Smrg			vsta)
6278d0bc965Smrg				basic_machine=i386-pc
6288d0bc965Smrg				basic_os=vsta
6298d0bc965Smrg				;;
6308d0bc965Smrg			vxworks960)
6318d0bc965Smrg				basic_machine=i960-wrs
6328d0bc965Smrg				basic_os=vxworks
6338d0bc965Smrg				;;
6348d0bc965Smrg			vxworks68)
6358d0bc965Smrg				basic_machine=m68k-wrs
6368d0bc965Smrg				basic_os=vxworks
6378d0bc965Smrg				;;
6388d0bc965Smrg			vxworks29k)
6398d0bc965Smrg				basic_machine=a29k-wrs
6408d0bc965Smrg				basic_os=vxworks
6418d0bc965Smrg				;;
6428d0bc965Smrg			xbox)
6438d0bc965Smrg				basic_machine=i686-pc
6448d0bc965Smrg				basic_os=mingw32
6458d0bc965Smrg				;;
6468d0bc965Smrg			ymp)
6478d0bc965Smrg				basic_machine=ymp-cray
6488d0bc965Smrg				basic_os=unicos
6498d0bc965Smrg				;;
6508d0bc965Smrg			*)
6518d0bc965Smrg				basic_machine=$1
6528d0bc965Smrg				basic_os=
6538d0bc965Smrg				;;
6548d0bc965Smrg		esac
655b042e37fSmrg		;;
656b042e37fSmrgesac
657b042e37fSmrg
6588d0bc965Smrg# Decode 1-component or ad-hoc basic machines
659b042e37fSmrgcase $basic_machine in
6608d0bc965Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6618d0bc965Smrg	# some cases the only manufacturer, in others, it is the most popular.
6628d0bc965Smrg	w89k)
6638d0bc965Smrg		cpu=hppa1.1
6648d0bc965Smrg		vendor=winbond
6653169be4bSmrg		;;
6668d0bc965Smrg	op50n)
6678d0bc965Smrg		cpu=hppa1.1
6688d0bc965Smrg		vendor=oki
669b042e37fSmrg		;;
6708d0bc965Smrg	op60c)
6718d0bc965Smrg		cpu=hppa1.1
6728d0bc965Smrg		vendor=oki
673b042e37fSmrg		;;
6748d0bc965Smrg	ibm*)
6758d0bc965Smrg		cpu=i370
6768d0bc965Smrg		vendor=ibm
6778c4a8e55Smrg		;;
6788d0bc965Smrg	orion105)
6798d0bc965Smrg		cpu=clipper
6808d0bc965Smrg		vendor=highlevel
6818bd17e5fSmrg		;;
6828d0bc965Smrg	mac | mpw | mac-mpw)
6838d0bc965Smrg		cpu=m68k
6848d0bc965Smrg		vendor=apple
6850597fb56Smrg		;;
6868d0bc965Smrg	pmac | pmac-mpw)
6878d0bc965Smrg		cpu=powerpc
6888d0bc965Smrg		vendor=apple
6890597fb56Smrg		;;
6900597fb56Smrg
691b042e37fSmrg	# Recognize the various machine names and aliases which stand
692b042e37fSmrg	# for a CPU type and a company and sometimes even an OS.
693b042e37fSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6948d0bc965Smrg		cpu=m68000
6958d0bc965Smrg		vendor=att
696b042e37fSmrg		;;
697b042e37fSmrg	3b*)
6988d0bc965Smrg		cpu=we32k
6998d0bc965Smrg		vendor=att
700706b6b52Smrg		;;
701706b6b52Smrg	bluegene*)
7028d0bc965Smrg		cpu=powerpc
7038d0bc965Smrg		vendor=ibm
7048d0bc965Smrg		basic_os=cnk
705b042e37fSmrg		;;
706b042e37fSmrg	decsystem10* | dec10*)
7078d0bc965Smrg		cpu=pdp10
7088d0bc965Smrg		vendor=dec
7098d0bc965Smrg		basic_os=tops10
710b042e37fSmrg		;;
711b042e37fSmrg	decsystem20* | dec20*)
7128d0bc965Smrg		cpu=pdp10
7138d0bc965Smrg		vendor=dec
7148d0bc965Smrg		basic_os=tops20
715b042e37fSmrg		;;
716b042e37fSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717b042e37fSmrg	      | 3300-motorola | delta-motorola)
7188d0bc965Smrg		cpu=m68k
7198d0bc965Smrg		vendor=motorola
720b042e37fSmrg		;;
7213169be4bSmrg	dpx2*)
7228d0bc965Smrg		cpu=m68k
7238d0bc965Smrg		vendor=bull
7248d0bc965Smrg		basic_os=sysv3
725b042e37fSmrg		;;
726b042e37fSmrg	encore | umax | mmax)
7278d0bc965Smrg		cpu=ns32k
7288d0bc965Smrg		vendor=encore
729b042e37fSmrg		;;
7308d0bc965Smrg	elxsi)
7318d0bc965Smrg		cpu=elxsi
7328d0bc965Smrg		vendor=elxsi
7338d0bc965Smrg		basic_os=${basic_os:-bsd}
734b042e37fSmrg		;;
735b042e37fSmrg	fx2800)
7368d0bc965Smrg		cpu=i860
7378d0bc965Smrg		vendor=alliant
738b042e37fSmrg		;;
739b042e37fSmrg	genix)
7408d0bc965Smrg		cpu=ns32k
7418d0bc965Smrg		vendor=ns
742b042e37fSmrg		;;
743b042e37fSmrg	h3050r* | hiux*)
7448d0bc965Smrg		cpu=hppa1.1
7458d0bc965Smrg		vendor=hitachi
7468d0bc965Smrg		basic_os=hiuxwe2
747b042e37fSmrg		;;
748b042e37fSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7498d0bc965Smrg		cpu=hppa1.0
7508d0bc965Smrg		vendor=hp
751b042e37fSmrg		;;
752b042e37fSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7538d0bc965Smrg		cpu=m68000
7548d0bc965Smrg		vendor=hp
755b042e37fSmrg		;;
756b042e37fSmrg	hp9k3[2-9][0-9])
7578d0bc965Smrg		cpu=m68k
7588d0bc965Smrg		vendor=hp
759b042e37fSmrg		;;
760b042e37fSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7618d0bc965Smrg		cpu=hppa1.0
7628d0bc965Smrg		vendor=hp
763b042e37fSmrg		;;
764b042e37fSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7658d0bc965Smrg		cpu=hppa1.1
7668d0bc965Smrg		vendor=hp
767b042e37fSmrg		;;
768b042e37fSmrg	hp9k78[0-9] | hp78[0-9])
769b042e37fSmrg		# FIXME: really hppa2.0-hp
7708d0bc965Smrg		cpu=hppa1.1
7718d0bc965Smrg		vendor=hp
772b042e37fSmrg		;;
773b042e37fSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774b042e37fSmrg		# FIXME: really hppa2.0-hp
7758d0bc965Smrg		cpu=hppa1.1
7768d0bc965Smrg		vendor=hp
777b042e37fSmrg		;;
778b042e37fSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7798d0bc965Smrg		cpu=hppa1.1
7808d0bc965Smrg		vendor=hp
781b042e37fSmrg		;;
782b042e37fSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7838d0bc965Smrg		cpu=hppa1.0
7848d0bc965Smrg		vendor=hp
785b042e37fSmrg		;;
786b042e37fSmrg	i*86v32)
7878d0bc965Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7888d0bc965Smrg		vendor=pc
7898d0bc965Smrg		basic_os=sysv32
790b042e37fSmrg		;;
791b042e37fSmrg	i*86v4*)
7928d0bc965Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7938d0bc965Smrg		vendor=pc
7948d0bc965Smrg		basic_os=sysv4
795b042e37fSmrg		;;
796b042e37fSmrg	i*86v)
7978d0bc965Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7988d0bc965Smrg		vendor=pc
7998d0bc965Smrg		basic_os=sysv
800b042e37fSmrg		;;
801b042e37fSmrg	i*86sol2)
8028d0bc965Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8038d0bc965Smrg		vendor=pc
8048d0bc965Smrg		basic_os=solaris2
805b042e37fSmrg		;;
8068d0bc965Smrg	j90 | j90-cray)
8078d0bc965Smrg		cpu=j90
8088d0bc965Smrg		vendor=cray
8098d0bc965Smrg		basic_os=${basic_os:-unicos}
810b042e37fSmrg		;;
811b042e37fSmrg	iris | iris4d)
8128d0bc965Smrg		cpu=mips
8138d0bc965Smrg		vendor=sgi
8148d0bc965Smrg		case $basic_os in
8158d0bc965Smrg		    irix*)
816b042e37fSmrg			;;
817b042e37fSmrg		    *)
8188d0bc965Smrg			basic_os=irix4
819b042e37fSmrg			;;
820b042e37fSmrg		esac
821b042e37fSmrg		;;
822b042e37fSmrg	miniframe)
8238d0bc965Smrg		cpu=m68000
8248d0bc965Smrg		vendor=convergent
825b042e37fSmrg		;;
8268d0bc965Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8278d0bc965Smrg		cpu=m68k
8288d0bc965Smrg		vendor=atari
8298d0bc965Smrg		basic_os=mint
830b042e37fSmrg		;;
831b042e37fSmrg	news-3600 | risc-news)
8328d0bc965Smrg		cpu=mips
8338d0bc965Smrg		vendor=sony
8348d0bc965Smrg		basic_os=newsos
835b042e37fSmrg		;;
8363169be4bSmrg	next | m*-next)
8378d0bc965Smrg		cpu=m68k
8388d0bc965Smrg		vendor=next
8398d0bc965Smrg		case $basic_os in
8408d0bc965Smrg		    openstep*)
8418d0bc965Smrg		        ;;
8428d0bc965Smrg		    nextstep*)
843b042e37fSmrg			;;
8448d0bc965Smrg		    ns2*)
8458d0bc965Smrg		      basic_os=nextstep2
846b042e37fSmrg			;;
847b042e37fSmrg		    *)
8488d0bc965Smrg		      basic_os=nextstep3
849b042e37fSmrg			;;
850b042e37fSmrg		esac
851b042e37fSmrg		;;
852b042e37fSmrg	np1)
8538d0bc965Smrg		cpu=np1
8548d0bc965Smrg		vendor=gould
8553169be4bSmrg		;;
856b042e37fSmrg	op50n-* | op60c-*)
8578d0bc965Smrg		cpu=hppa1.1
8588d0bc965Smrg		vendor=oki
8598d0bc965Smrg		basic_os=proelf
860b042e37fSmrg		;;
861b042e37fSmrg	pa-hitachi)
8628d0bc965Smrg		cpu=hppa1.1
8638d0bc965Smrg		vendor=hitachi
8648d0bc965Smrg		basic_os=hiuxwe2
865706b6b52Smrg		;;
866b042e37fSmrg	pbd)
8678d0bc965Smrg		cpu=sparc
8688d0bc965Smrg		vendor=tti
869b042e37fSmrg		;;
870b042e37fSmrg	pbb)
8718d0bc965Smrg		cpu=m68k
8728d0bc965Smrg		vendor=tti
873b042e37fSmrg		;;
8748d0bc965Smrg	pc532)
8758d0bc965Smrg		cpu=ns32k
8768d0bc965Smrg		vendor=pc532
877b042e37fSmrg		;;
878b042e37fSmrg	pn)
8798d0bc965Smrg		cpu=pn
8808d0bc965Smrg		vendor=gould
881b042e37fSmrg		;;
8828d0bc965Smrg	power)
8838d0bc965Smrg		cpu=power
8848d0bc965Smrg		vendor=ibm
885b042e37fSmrg		;;
8868d0bc965Smrg	ps2)
8878d0bc965Smrg		cpu=i386
8888d0bc965Smrg		vendor=ibm
889b042e37fSmrg		;;
8908d0bc965Smrg	rm[46]00)
8918d0bc965Smrg		cpu=mips
8928d0bc965Smrg		vendor=siemens
893b042e37fSmrg		;;
8948d0bc965Smrg	rtpc | rtpc-*)
8958d0bc965Smrg		cpu=romp
8968d0bc965Smrg		vendor=ibm
897b042e37fSmrg		;;
8988d0bc965Smrg	sde)
8998d0bc965Smrg		cpu=mipsisa32
9008d0bc965Smrg		vendor=sde
9018d0bc965Smrg		basic_os=${basic_os:-elf}
902b042e37fSmrg		;;
9038d0bc965Smrg	simso-wrs)
9048d0bc965Smrg		cpu=sparclite
9058d0bc965Smrg		vendor=wrs
9068d0bc965Smrg		basic_os=vxworks
907b042e37fSmrg		;;
9088d0bc965Smrg	tower | tower-32)
9098d0bc965Smrg		cpu=m68k
9108d0bc965Smrg		vendor=ncr
911b042e37fSmrg		;;
9128d0bc965Smrg	vpp*|vx|vx-*)
9138d0bc965Smrg		cpu=f301
9148d0bc965Smrg		vendor=fujitsu
9158bd17e5fSmrg		;;
9168d0bc965Smrg	w65)
9178d0bc965Smrg		cpu=w65
9188d0bc965Smrg		vendor=wdc
9198c4a8e55Smrg		;;
9208d0bc965Smrg	w89k-*)
9218d0bc965Smrg		cpu=hppa1.1
9228d0bc965Smrg		vendor=winbond
9238d0bc965Smrg		basic_os=proelf
924b042e37fSmrg		;;
9258d0bc965Smrg	none)
9268d0bc965Smrg		cpu=none
9278d0bc965Smrg		vendor=none
928b042e37fSmrg		;;
9298d0bc965Smrg	leon|leon[3-9])
9308d0bc965Smrg		cpu=sparc
9318d0bc965Smrg		vendor=$basic_machine
932b042e37fSmrg		;;
9338d0bc965Smrg	leon-*|leon[3-9]-*)
9348d0bc965Smrg		cpu=sparc
9358d0bc965Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936b042e37fSmrg		;;
9378d0bc965Smrg
9388d0bc965Smrg	*-*)
9398d0bc965Smrg		# shellcheck disable=SC2162
9408d0bc965Smrg		saved_IFS=$IFS
9418d0bc965Smrg		IFS="-" read cpu vendor <<EOF
9428d0bc965Smrg$basic_machine
9438d0bc965SmrgEOF
9448d0bc965Smrg		IFS=$saved_IFS
945b042e37fSmrg		;;
9468d0bc965Smrg	# We use `pc' rather than `unknown'
9478d0bc965Smrg	# because (1) that's what they normally are, and
9488d0bc965Smrg	# (2) the word "unknown" tends to confuse beginning users.
9498d0bc965Smrg	i*86 | x86_64)
9508d0bc965Smrg		cpu=$basic_machine
9518d0bc965Smrg		vendor=pc
952b042e37fSmrg		;;
9538d0bc965Smrg	# These rules are duplicated from below for sake of the special case above;
9548d0bc965Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9558d0bc965Smrg	pc98)
9568d0bc965Smrg		cpu=i386
9578d0bc965Smrg		vendor=pc
958b042e37fSmrg		;;
9598d0bc965Smrg	x64 | amd64)
9608d0bc965Smrg		cpu=x86_64
9618d0bc965Smrg		vendor=pc
962b042e37fSmrg		;;
9638d0bc965Smrg	# Recognize the basic CPU types without company name.
9648d0bc965Smrg	*)
9658d0bc965Smrg		cpu=$basic_machine
9668d0bc965Smrg		vendor=unknown
9678c4a8e55Smrg		;;
9688d0bc965Smrgesac
9698d0bc965Smrg
9708d0bc965Smrgunset -v basic_machine
9718d0bc965Smrg
9728d0bc965Smrg# Decode basic machines in the full and proper CPU-Company form.
9738d0bc965Smrgcase $cpu-$vendor in
9748d0bc965Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9758d0bc965Smrg	# some cases the only manufacturer, in others, it is the most popular.
9768d0bc965Smrg	craynv-unknown)
9778d0bc965Smrg		vendor=cray
9788d0bc965Smrg		basic_os=${basic_os:-unicosmp}
979b042e37fSmrg		;;
9808d0bc965Smrg	c90-unknown | c90-cray)
9818d0bc965Smrg		vendor=cray
9828d0bc965Smrg		basic_os=${Basic_os:-unicos}
983b042e37fSmrg		;;
9848d0bc965Smrg	fx80-unknown)
9858d0bc965Smrg		vendor=alliant
986706b6b52Smrg		;;
9878d0bc965Smrg	romp-unknown)
9888d0bc965Smrg		vendor=ibm
989b042e37fSmrg		;;
9908d0bc965Smrg	mmix-unknown)
9918d0bc965Smrg		vendor=knuth
992b042e37fSmrg		;;
9938d0bc965Smrg	microblaze-unknown | microblazeel-unknown)
9948d0bc965Smrg		vendor=xilinx
995b042e37fSmrg		;;
9968d0bc965Smrg	rs6000-unknown)
9978d0bc965Smrg		vendor=ibm
998b042e37fSmrg		;;
9998d0bc965Smrg	vax-unknown)
10008d0bc965Smrg		vendor=dec
1001b042e37fSmrg		;;
10028d0bc965Smrg	pdp11-unknown)
10038d0bc965Smrg		vendor=dec
10040597fb56Smrg		;;
10058d0bc965Smrg	we32k-unknown)
10068d0bc965Smrg		vendor=att
1007b042e37fSmrg		;;
10088d0bc965Smrg	cydra-unknown)
10098d0bc965Smrg		vendor=cydrome
1010b042e37fSmrg		;;
10118d0bc965Smrg	i370-ibm*)
10128d0bc965Smrg		vendor=ibm
1013b042e37fSmrg		;;
10148d0bc965Smrg	orion-unknown)
10158d0bc965Smrg		vendor=highlevel
1016b042e37fSmrg		;;
10178d0bc965Smrg	xps-unknown | xps100-unknown)
10188d0bc965Smrg		cpu=xps100
10198d0bc965Smrg		vendor=honeywell
1020b042e37fSmrg		;;
10218d0bc965Smrg
10228d0bc965Smrg	# Here we normalize CPU types with a missing or matching vendor
10230c674dbdSmrg	armh-unknown | armh-alt)
10240c674dbdSmrg		cpu=armv7l
10250c674dbdSmrg		vendor=alt
10260c674dbdSmrg		basic_os=${basic_os:-linux-gnueabihf}
10270c674dbdSmrg		;;
10288d0bc965Smrg	dpx20-unknown | dpx20-bull)
10298d0bc965Smrg		cpu=rs6000
10308d0bc965Smrg		vendor=bull
10318d0bc965Smrg		basic_os=${basic_os:-bosx}
1032b042e37fSmrg		;;
10338d0bc965Smrg
10348d0bc965Smrg	# Here we normalize CPU types irrespective of the vendor
10358d0bc965Smrg	amd64-*)
10368d0bc965Smrg		cpu=x86_64
1037b042e37fSmrg		;;
10388d0bc965Smrg	blackfin-*)
10398d0bc965Smrg		cpu=bfin
10408d0bc965Smrg		basic_os=linux
1041b042e37fSmrg		;;
10428d0bc965Smrg	c54x-*)
10438d0bc965Smrg		cpu=tic54x
1044b042e37fSmrg		;;
10458d0bc965Smrg	c55x-*)
10468d0bc965Smrg		cpu=tic55x
1047b042e37fSmrg		;;
10488d0bc965Smrg	c6x-*)
10498d0bc965Smrg		cpu=tic6x
1050b042e37fSmrg		;;
10518d0bc965Smrg	e500v[12]-*)
10528d0bc965Smrg		cpu=powerpc
10538d0bc965Smrg		basic_os=${basic_os}"spe"
1054b042e37fSmrg		;;
10558d0bc965Smrg	mips3*-*)
10568d0bc965Smrg		cpu=mips64
1057b042e37fSmrg		;;
10588d0bc965Smrg	ms1-*)
10598d0bc965Smrg		cpu=mt
1060b042e37fSmrg		;;
10618d0bc965Smrg	m68knommu-*)
10628d0bc965Smrg		cpu=m68k
10638d0bc965Smrg		basic_os=linux
1064b042e37fSmrg		;;
10658d0bc965Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10668d0bc965Smrg		cpu=s12z
1067b042e37fSmrg		;;
10688d0bc965Smrg	openrisc-*)
10698d0bc965Smrg		cpu=or32
1070b042e37fSmrg		;;
10718d0bc965Smrg	parisc-*)
10728d0bc965Smrg		cpu=hppa
10738d0bc965Smrg		basic_os=linux
1074b042e37fSmrg		;;
10758d0bc965Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10768d0bc965Smrg		cpu=i586
1077b042e37fSmrg		;;
10780c674dbdSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10798d0bc965Smrg		cpu=i686
1080b042e37fSmrg		;;
10818d0bc965Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10828d0bc965Smrg		cpu=i686
10838c4a8e55Smrg		;;
10848d0bc965Smrg	pentium4-*)
10858d0bc965Smrg		cpu=i786
1086b042e37fSmrg		;;
10878d0bc965Smrg	pc98-*)
10888d0bc965Smrg		cpu=i386
1089b042e37fSmrg		;;
10908d0bc965Smrg	ppc-* | ppcbe-*)
10918d0bc965Smrg		cpu=powerpc
1092b042e37fSmrg		;;
10938d0bc965Smrg	ppcle-* | powerpclittle-*)
10948d0bc965Smrg		cpu=powerpcle
1095b042e37fSmrg		;;
10968d0bc965Smrg	ppc64-*)
10978d0bc965Smrg		cpu=powerpc64
1098b042e37fSmrg		;;
10998d0bc965Smrg	ppc64le-* | powerpc64little-*)
11008d0bc965Smrg		cpu=powerpc64le
1101b042e37fSmrg		;;
11028d0bc965Smrg	sb1-*)
11038d0bc965Smrg		cpu=mipsisa64sb1
1104b042e37fSmrg		;;
11058d0bc965Smrg	sb1el-*)
11068d0bc965Smrg		cpu=mipsisa64sb1el
1107b042e37fSmrg		;;
11088d0bc965Smrg	sh5e[lb]-*)
11098d0bc965Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110b042e37fSmrg		;;
11118d0bc965Smrg	spur-*)
11128d0bc965Smrg		cpu=spur
1113b042e37fSmrg		;;
11148d0bc965Smrg	strongarm-* | thumb-*)
11158d0bc965Smrg		cpu=arm
1116b042e37fSmrg		;;
11178d0bc965Smrg	tx39-*)
11188d0bc965Smrg		cpu=mipstx39
11193169be4bSmrg		;;
11208d0bc965Smrg	tx39el-*)
11218d0bc965Smrg		cpu=mipstx39el
11228c4a8e55Smrg		;;
11238d0bc965Smrg	x64-*)
11248d0bc965Smrg		cpu=x86_64
1125b042e37fSmrg		;;
11260597fb56Smrg	xscale-* | xscalee[bl]-*)
11278d0bc965Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128b042e37fSmrg		;;
11290c674dbdSmrg	arm64-* | aarch64le-*)
11308d0bc965Smrg		cpu=aarch64
1131b042e37fSmrg		;;
1132b042e37fSmrg
11338d0bc965Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11348d0bc965Smrg	# company names they are paired with.
11358d0bc965Smrg	cr16-*)
11368d0bc965Smrg		basic_os=${basic_os:-elf}
11378c4a8e55Smrg		;;
11388d0bc965Smrg	crisv32-* | etraxfs*-*)
11398d0bc965Smrg		cpu=crisv32
11408d0bc965Smrg		vendor=axis
1141b042e37fSmrg		;;
11428d0bc965Smrg	cris-* | etrax*-*)
11438d0bc965Smrg		cpu=cris
11448d0bc965Smrg		vendor=axis
1145b042e37fSmrg		;;
11468d0bc965Smrg	crx-*)
11478d0bc965Smrg		basic_os=${basic_os:-elf}
1148b042e37fSmrg		;;
11498d0bc965Smrg	neo-tandem)
11508d0bc965Smrg		cpu=neo
11518d0bc965Smrg		vendor=tandem
1152b042e37fSmrg		;;
11538d0bc965Smrg	nse-tandem)
11548d0bc965Smrg		cpu=nse
11558d0bc965Smrg		vendor=tandem
1156b042e37fSmrg		;;
11578d0bc965Smrg	nsr-tandem)
11588d0bc965Smrg		cpu=nsr
11598d0bc965Smrg		vendor=tandem
1160b042e37fSmrg		;;
11618d0bc965Smrg	nsv-tandem)
11628d0bc965Smrg		cpu=nsv
11638d0bc965Smrg		vendor=tandem
1164b042e37fSmrg		;;
11658d0bc965Smrg	nsx-tandem)
11668d0bc965Smrg		cpu=nsx
11678d0bc965Smrg		vendor=tandem
1168b042e37fSmrg		;;
11698d0bc965Smrg	mipsallegrexel-sony)
11708d0bc965Smrg		cpu=mipsallegrexel
11718d0bc965Smrg		vendor=sony
1172b042e37fSmrg		;;
11738d0bc965Smrg	tile*-*)
11748d0bc965Smrg		basic_os=${basic_os:-linux-gnu}
1175b042e37fSmrg		;;
11768d0bc965Smrg
1177b042e37fSmrg	*)
11788d0bc965Smrg		# Recognize the canonical CPU types that are allowed with any
11798d0bc965Smrg		# company name.
11808d0bc965Smrg		case $cpu in
11818d0bc965Smrg			1750a | 580 \
11828d0bc965Smrg			| a29k \
11838d0bc965Smrg			| aarch64 | aarch64_be \
11848d0bc965Smrg			| abacus \
11858d0bc965Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11868d0bc965Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11878d0bc965Smrg			| alphapca5[67] | alpha64pca5[67] \
11888d0bc965Smrg			| am33_2.0 \
11898d0bc965Smrg			| amdgcn \
11908d0bc965Smrg			| arc | arceb | arc32 | arc64 \
11918d0bc965Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11928d0bc965Smrg			| avr | avr32 \
11938d0bc965Smrg			| asmjs \
11948d0bc965Smrg			| ba \
11958d0bc965Smrg			| be32 | be64 \
11968d0bc965Smrg			| bfin | bpf | bs2000 \
11978d0bc965Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11988d0bc965Smrg			| c8051 | clipper | craynv | csky | cydra \
11998d0bc965Smrg			| d10v | d30v | dlx | dsp16xx \
12008d0bc965Smrg			| e2k | elxsi | epiphany \
12018d0bc965Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12028d0bc965Smrg			| h8300 | h8500 \
12038d0bc965Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12048d0bc965Smrg			| hexagon \
12058d0bc965Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12068d0bc965Smrg			| ip2k | iq2000 \
12078d0bc965Smrg			| k1om \
12088d0bc965Smrg			| le32 | le64 \
12098d0bc965Smrg			| lm32 \
12100c674dbdSmrg			| loongarch32 | loongarch64 \
12118d0bc965Smrg			| m32c | m32r | m32rle \
12128d0bc965Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12138d0bc965Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12148d0bc965Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12158d0bc965Smrg			| microblaze | microblazeel \
12168d0bc965Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12178d0bc965Smrg			| mips16 \
12188d0bc965Smrg			| mips64 | mips64eb | mips64el \
12198d0bc965Smrg			| mips64octeon | mips64octeonel \
12208d0bc965Smrg			| mips64orion | mips64orionel \
12218d0bc965Smrg			| mips64r5900 | mips64r5900el \
12228d0bc965Smrg			| mips64vr | mips64vrel \
12238d0bc965Smrg			| mips64vr4100 | mips64vr4100el \
12248d0bc965Smrg			| mips64vr4300 | mips64vr4300el \
12258d0bc965Smrg			| mips64vr5000 | mips64vr5000el \
12268d0bc965Smrg			| mips64vr5900 | mips64vr5900el \
12278d0bc965Smrg			| mipsisa32 | mipsisa32el \
12288d0bc965Smrg			| mipsisa32r2 | mipsisa32r2el \
12298d0bc965Smrg			| mipsisa32r3 | mipsisa32r3el \
12308d0bc965Smrg			| mipsisa32r5 | mipsisa32r5el \
12318d0bc965Smrg			| mipsisa32r6 | mipsisa32r6el \
12328d0bc965Smrg			| mipsisa64 | mipsisa64el \
12338d0bc965Smrg			| mipsisa64r2 | mipsisa64r2el \
12348d0bc965Smrg			| mipsisa64r3 | mipsisa64r3el \
12358d0bc965Smrg			| mipsisa64r5 | mipsisa64r5el \
12368d0bc965Smrg			| mipsisa64r6 | mipsisa64r6el \
12378d0bc965Smrg			| mipsisa64sb1 | mipsisa64sb1el \
12388d0bc965Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
12398d0bc965Smrg			| mipsr5900 | mipsr5900el \
12408d0bc965Smrg			| mipstx39 | mipstx39el \
12418d0bc965Smrg			| mmix \
12428d0bc965Smrg			| mn10200 | mn10300 \
12438d0bc965Smrg			| moxie \
12448d0bc965Smrg			| mt \
12458d0bc965Smrg			| msp430 \
12468d0bc965Smrg			| nds32 | nds32le | nds32be \
12478d0bc965Smrg			| nfp \
12488d0bc965Smrg			| nios | nios2 | nios2eb | nios2el \
12498d0bc965Smrg			| none | np1 | ns16k | ns32k | nvptx \
12508d0bc965Smrg			| open8 \
12518d0bc965Smrg			| or1k* \
12528d0bc965Smrg			| or32 \
12538d0bc965Smrg			| orion \
12548d0bc965Smrg			| picochip \
12558d0bc965Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12568d0bc965Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12578d0bc965Smrg			| pru \
12588d0bc965Smrg			| pyramid \
12598d0bc965Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12608d0bc965Smrg			| rl78 | romp | rs6000 | rx \
12618d0bc965Smrg			| s390 | s390x \
12628d0bc965Smrg			| score \
12638d0bc965Smrg			| sh | shl \
12648d0bc965Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12658d0bc965Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12668d0bc965Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12678d0bc965Smrg			| sparclite \
12688d0bc965Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12698d0bc965Smrg			| spu \
12708d0bc965Smrg			| tahoe \
12718d0bc965Smrg			| thumbv7* \
12728d0bc965Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12738d0bc965Smrg			| tron \
12748d0bc965Smrg			| ubicom32 \
12758d0bc965Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12768d0bc965Smrg			| vax \
12778d0bc965Smrg			| visium \
12788d0bc965Smrg			| w65 \
12798d0bc965Smrg			| wasm32 | wasm64 \
12808d0bc965Smrg			| we32k \
12818d0bc965Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12828d0bc965Smrg			| xstormy16 | xtensa* \
12838d0bc965Smrg			| ymp \
12848d0bc965Smrg			| z8k | z80)
12858d0bc965Smrg				;;
12868d0bc965Smrg
12878d0bc965Smrg			*)
12888d0bc965Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12898d0bc965Smrg				exit 1
12908d0bc965Smrg				;;
12918d0bc965Smrg		esac
1292b042e37fSmrg		;;
1293b042e37fSmrgesac
1294b042e37fSmrg
1295b042e37fSmrg# Here we canonicalize certain aliases for manufacturers.
12968d0bc965Smrgcase $vendor in
12978d0bc965Smrg	digital*)
12988d0bc965Smrg		vendor=dec
1299b042e37fSmrg		;;
13008d0bc965Smrg	commodore*)
13018d0bc965Smrg		vendor=cbm
1302b042e37fSmrg		;;
1303b042e37fSmrg	*)
1304b042e37fSmrg		;;
1305b042e37fSmrgesac
1306b042e37fSmrg
1307b042e37fSmrg# Decode manufacturer-specific aliases for certain operating systems.
1308b042e37fSmrg
13098d0bc965Smrgif test x$basic_os != x
1310b042e37fSmrgthen
13118d0bc965Smrg
13120c674dbdSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13138d0bc965Smrg# set os.
13148d0bc965Smrgcase $basic_os in
13158d0bc965Smrg	gnu/linux*)
13168d0bc965Smrg		kernel=linux
13178d0bc965Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13188d0bc965Smrg		;;
13198d0bc965Smrg	os2-emx)
13208d0bc965Smrg		kernel=os2
13218d0bc965Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13228d0bc965Smrg		;;
13238d0bc965Smrg	nto-qnx*)
13248d0bc965Smrg		kernel=nto
13258d0bc965Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13268d0bc965Smrg		;;
13278d0bc965Smrg	*-*)
13288d0bc965Smrg		# shellcheck disable=SC2162
13298d0bc965Smrg		saved_IFS=$IFS
13308d0bc965Smrg		IFS="-" read kernel os <<EOF
13318d0bc965Smrg$basic_os
13328d0bc965SmrgEOF
13338d0bc965Smrg		IFS=$saved_IFS
13348d0bc965Smrg		;;
13358d0bc965Smrg	# Default OS when just kernel was specified
13368d0bc965Smrg	nto*)
13378d0bc965Smrg		kernel=nto
13388d0bc965Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13398d0bc965Smrg		;;
13408d0bc965Smrg	linux*)
13418d0bc965Smrg		kernel=linux
13428d0bc965Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13438d0bc965Smrg		;;
13440c674dbdSmrg	managarm*)
13450c674dbdSmrg		kernel=managarm
13460c674dbdSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13470c674dbdSmrg		;;
13488d0bc965Smrg	*)
13498d0bc965Smrg		kernel=
13508d0bc965Smrg		os=$basic_os
13518d0bc965Smrg		;;
13528d0bc965Smrgesac
13538d0bc965Smrg
13548d0bc965Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13558d0bc965Smrg# etc.)
1356b042e37fSmrgcase $os in
13573169be4bSmrg	# First match some system type aliases that might get confused
13583169be4bSmrg	# with valid system types.
13598d0bc965Smrg	# solaris* is a basic system type, with this one exception.
13608d0bc965Smrg	auroraux)
13618d0bc965Smrg		os=auroraux
1362706b6b52Smrg		;;
13638d0bc965Smrg	bluegene*)
13648d0bc965Smrg		os=cnk
1365b042e37fSmrg		;;
13668d0bc965Smrg	solaris1 | solaris1.*)
13678d0bc965Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368b042e37fSmrg		;;
13698d0bc965Smrg	solaris)
13708d0bc965Smrg		os=solaris2
1371b042e37fSmrg		;;
13728d0bc965Smrg	unixware*)
13738d0bc965Smrg		os=sysv4.2uw
1374b042e37fSmrg		;;
13753169be4bSmrg	# es1800 is here to avoid being matched by es* (a different OS)
13768d0bc965Smrg	es1800*)
13778d0bc965Smrg		os=ose
13783169be4bSmrg		;;
13798d0bc965Smrg	# Some version numbers need modification
13808d0bc965Smrg	chorusos*)
13818d0bc965Smrg		os=chorusos
1382b042e37fSmrg		;;
13838d0bc965Smrg	isc)
13848d0bc965Smrg		os=isc2.2
1385b042e37fSmrg		;;
13868d0bc965Smrg	sco6)
13878d0bc965Smrg		os=sco5v6
1388b042e37fSmrg		;;
13898d0bc965Smrg	sco5)
13908d0bc965Smrg		os=sco3.2v5
1391b042e37fSmrg		;;
13928d0bc965Smrg	sco4)
13938d0bc965Smrg		os=sco3.2v4
1394b042e37fSmrg		;;
13958d0bc965Smrg	sco3.2.[4-9]*)
13968d0bc965Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13978c4a8e55Smrg		;;
13988d0bc965Smrg	sco*v* | scout)
13998d0bc965Smrg		# Don't match below
1400b042e37fSmrg		;;
14018d0bc965Smrg	sco*)
14028d0bc965Smrg		os=sco3.2v2
1403b042e37fSmrg		;;
14048d0bc965Smrg	psos*)
14058d0bc965Smrg		os=psos
1406b042e37fSmrg		;;
14078d0bc965Smrg	qnx*)
14088d0bc965Smrg		os=qnx
1409b042e37fSmrg		;;
14108d0bc965Smrg	hiux*)
14118d0bc965Smrg		os=hiuxwe2
14128c4a8e55Smrg		;;
14138d0bc965Smrg	lynx*178)
14148d0bc965Smrg		os=lynxos178
1415b042e37fSmrg		;;
14168d0bc965Smrg	lynx*5)
14178d0bc965Smrg		os=lynxos5
1418b042e37fSmrg		;;
14198d0bc965Smrg	lynxos*)
14208d0bc965Smrg		# don't get caught up in next wildcard
1421b042e37fSmrg		;;
14228d0bc965Smrg	lynx*)
14238d0bc965Smrg		os=lynxos
1424b042e37fSmrg		;;
14258d0bc965Smrg	mac[0-9]*)
14268d0bc965Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427b042e37fSmrg		;;
14288d0bc965Smrg	opened*)
14298d0bc965Smrg		os=openedition
14308c4a8e55Smrg		;;
14318d0bc965Smrg	os400*)
14328d0bc965Smrg		os=os400
1433b042e37fSmrg		;;
14348d0bc965Smrg	sunos5*)
14358d0bc965Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436b042e37fSmrg		;;
14378d0bc965Smrg	sunos6*)
14388d0bc965Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439b042e37fSmrg		;;
14408d0bc965Smrg	wince*)
14418d0bc965Smrg		os=wince
1442b042e37fSmrg		;;
14438d0bc965Smrg	utek*)
14448d0bc965Smrg		os=bsd
1445b042e37fSmrg		;;
14468d0bc965Smrg	dynix*)
14478d0bc965Smrg		os=bsd
1448b042e37fSmrg		;;
14498d0bc965Smrg	acis*)
14508d0bc965Smrg		os=aos
1451b042e37fSmrg		;;
14528d0bc965Smrg	atheos*)
14538d0bc965Smrg		os=atheos
14548c4a8e55Smrg		;;
14558d0bc965Smrg	syllable*)
14568d0bc965Smrg		os=syllable
14578d0bc965Smrg		;;
14588d0bc965Smrg	386bsd)
14598d0bc965Smrg		os=bsd
14608d0bc965Smrg		;;
14618d0bc965Smrg	ctix* | uts*)
14628d0bc965Smrg		os=sysv
14638d0bc965Smrg		;;
14648d0bc965Smrg	nova*)
14658d0bc965Smrg		os=rtmk-nova
14668d0bc965Smrg		;;
14678d0bc965Smrg	ns2)
14688d0bc965Smrg		os=nextstep2
14698d0bc965Smrg		;;
14708d0bc965Smrg	# Preserve the version number of sinix5.
14718d0bc965Smrg	sinix5.*)
14728d0bc965Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473b042e37fSmrg		;;
14748d0bc965Smrg	sinix*)
14758d0bc965Smrg		os=sysv4
1476b042e37fSmrg		;;
14778d0bc965Smrg	tpf*)
14788d0bc965Smrg		os=tpf
1479b042e37fSmrg		;;
14808d0bc965Smrg	triton*)
14818d0bc965Smrg		os=sysv3
1482b042e37fSmrg		;;
14838d0bc965Smrg	oss*)
14848d0bc965Smrg		os=sysv3
1485b042e37fSmrg		;;
14868d0bc965Smrg	svr4*)
14878d0bc965Smrg		os=sysv4
1488b042e37fSmrg		;;
14898d0bc965Smrg	svr3)
14908d0bc965Smrg		os=sysv3
1491b042e37fSmrg		;;
14928d0bc965Smrg	sysvr4)
14938d0bc965Smrg		os=sysv4
1494b042e37fSmrg		;;
14958d0bc965Smrg	ose*)
14968d0bc965Smrg		os=ose
14978c4a8e55Smrg		;;
14988d0bc965Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14998d0bc965Smrg		os=mint
1500706b6b52Smrg		;;
15018d0bc965Smrg	dicos*)
15028d0bc965Smrg		os=dicos
15038d0bc965Smrg		;;
15048d0bc965Smrg	pikeos*)
15053169be4bSmrg		# Until real need of OS specific support for
15063169be4bSmrg		# particular features comes up, bare metal
15073169be4bSmrg		# configurations are quite functional.
15088d0bc965Smrg		case $cpu in
15093169be4bSmrg		    arm*)
15108d0bc965Smrg			os=eabi
15113169be4bSmrg			;;
15123169be4bSmrg		    *)
15138d0bc965Smrg			os=elf
15143169be4bSmrg			;;
15153169be4bSmrg		esac
15163169be4bSmrg		;;
1517b042e37fSmrg	*)
15188d0bc965Smrg		# No normalization, but not necessarily accepted, that comes below.
1519b042e37fSmrg		;;
1520b042e37fSmrgesac
15218d0bc965Smrg
1522b042e37fSmrgelse
1523b042e37fSmrg
1524b042e37fSmrg# Here we handle the default operating systems that come with various machines.
1525b042e37fSmrg# The value should be what the vendor currently ships out the door with their
1526b042e37fSmrg# machine or put another way, the most popular os provided with the machine.
1527b042e37fSmrg
1528b042e37fSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529b042e37fSmrg# "-sun"), then you have to tell the case statement up towards the top
1530b042e37fSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531b042e37fSmrg# will signal an error saying that MANUFACTURER isn't an operating
1532b042e37fSmrg# system, and we'll never get to this point.
1533b042e37fSmrg
15348d0bc965Smrgkernel=
15358d0bc965Smrgcase $cpu-$vendor in
15360597fb56Smrg	score-*)
15378d0bc965Smrg		os=elf
15388c4a8e55Smrg		;;
15390597fb56Smrg	spu-*)
15408d0bc965Smrg		os=elf
15418c4a8e55Smrg		;;
1542b042e37fSmrg	*-acorn)
15438d0bc965Smrg		os=riscix1.2
1544b042e37fSmrg		;;
1545b042e37fSmrg	arm*-rebel)
15468d0bc965Smrg		kernel=linux
15478d0bc965Smrg		os=gnu
1548b042e37fSmrg		;;
1549b042e37fSmrg	arm*-semi)
15508d0bc965Smrg		os=aout
1551b042e37fSmrg		;;
15520597fb56Smrg	c4x-* | tic4x-*)
15538d0bc965Smrg		os=coff
15548c4a8e55Smrg		;;
155567594505Smrg	c8051-*)
15568d0bc965Smrg		os=elf
15578d0bc965Smrg		;;
15588d0bc965Smrg	clipper-intergraph)
15598d0bc965Smrg		os=clix
156067594505Smrg		;;
15618bd17e5fSmrg	hexagon-*)
15628d0bc965Smrg		os=elf
15638bd17e5fSmrg		;;
1564706b6b52Smrg	tic54x-*)
15658d0bc965Smrg		os=coff
1566706b6b52Smrg		;;
1567706b6b52Smrg	tic55x-*)
15688d0bc965Smrg		os=coff
1569706b6b52Smrg		;;
1570706b6b52Smrg	tic6x-*)
15718d0bc965Smrg		os=coff
1572706b6b52Smrg		;;
1573b042e37fSmrg	# This must come before the *-dec entry.
1574b042e37fSmrg	pdp10-*)
15758d0bc965Smrg		os=tops20
1576b042e37fSmrg		;;
1577b042e37fSmrg	pdp11-*)
15788d0bc965Smrg		os=none
1579b042e37fSmrg		;;
1580b042e37fSmrg	*-dec | vax-*)
15818d0bc965Smrg		os=ultrix4.2
1582b042e37fSmrg		;;
1583b042e37fSmrg	m68*-apollo)
15848d0bc965Smrg		os=domain
1585b042e37fSmrg		;;
1586b042e37fSmrg	i386-sun)
15878d0bc965Smrg		os=sunos4.0.2
1588b042e37fSmrg		;;
1589b042e37fSmrg	m68000-sun)
15908d0bc965Smrg		os=sunos3
1591b042e37fSmrg		;;
1592b042e37fSmrg	m68*-cisco)
15938d0bc965Smrg		os=aout
1594b042e37fSmrg		;;
15950597fb56Smrg	mep-*)
15968d0bc965Smrg		os=elf
1597706b6b52Smrg		;;
1598b042e37fSmrg	mips*-cisco)
15998d0bc965Smrg		os=elf
1600b042e37fSmrg		;;
1601b042e37fSmrg	mips*-*)
16028d0bc965Smrg		os=elf
1603b042e37fSmrg		;;
1604b042e37fSmrg	or32-*)
16058d0bc965Smrg		os=coff
1606b042e37fSmrg		;;
1607b042e37fSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
16088d0bc965Smrg		os=sysv3
1609b042e37fSmrg		;;
1610b042e37fSmrg	sparc-* | *-sun)
16118d0bc965Smrg		os=sunos4.1.1
1612b042e37fSmrg		;;
16133169be4bSmrg	pru-*)
16148d0bc965Smrg		os=elf
16153169be4bSmrg		;;
1616b042e37fSmrg	*-be)
16178d0bc965Smrg		os=beos
1618b042e37fSmrg		;;
1619b042e37fSmrg	*-ibm)
16208d0bc965Smrg		os=aix
1621b042e37fSmrg		;;
16220597fb56Smrg	*-knuth)
16238d0bc965Smrg		os=mmixware
16248c4a8e55Smrg		;;
1625b042e37fSmrg	*-wec)
16268d0bc965Smrg		os=proelf
1627b042e37fSmrg		;;
1628b042e37fSmrg	*-winbond)
16298d0bc965Smrg		os=proelf
1630b042e37fSmrg		;;
1631b042e37fSmrg	*-oki)
16328d0bc965Smrg		os=proelf
1633b042e37fSmrg		;;
1634b042e37fSmrg	*-hp)
16358d0bc965Smrg		os=hpux
1636b042e37fSmrg		;;
1637b042e37fSmrg	*-hitachi)
16388d0bc965Smrg		os=hiux
1639b042e37fSmrg		;;
1640b042e37fSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16418d0bc965Smrg		os=sysv
1642b042e37fSmrg		;;
1643b042e37fSmrg	*-cbm)
16448d0bc965Smrg		os=amigaos
1645b042e37fSmrg		;;
1646b042e37fSmrg	*-dg)
16478d0bc965Smrg		os=dgux
1648b042e37fSmrg		;;
1649b042e37fSmrg	*-dolphin)
16508d0bc965Smrg		os=sysv3
1651b042e37fSmrg		;;
1652b042e37fSmrg	m68k-ccur)
16538d0bc965Smrg		os=rtu
1654b042e37fSmrg		;;
1655b042e37fSmrg	m88k-omron*)
16568d0bc965Smrg		os=luna
1657b042e37fSmrg		;;
16583169be4bSmrg	*-next)
16598d0bc965Smrg		os=nextstep
1660b042e37fSmrg		;;
1661b042e37fSmrg	*-sequent)
16628d0bc965Smrg		os=ptx
1663b042e37fSmrg		;;
1664b042e37fSmrg	*-crds)
16658d0bc965Smrg		os=unos
1666b042e37fSmrg		;;
1667b042e37fSmrg	*-ns)
16688d0bc965Smrg		os=genix
1669b042e37fSmrg		;;
1670b042e37fSmrg	i370-*)
16718d0bc965Smrg		os=mvs
1672b042e37fSmrg		;;
1673b042e37fSmrg	*-gould)
16748d0bc965Smrg		os=sysv
1675b042e37fSmrg		;;
1676b042e37fSmrg	*-highlevel)
16778d0bc965Smrg		os=bsd
1678b042e37fSmrg		;;
1679b042e37fSmrg	*-encore)
16808d0bc965Smrg		os=bsd
1681b042e37fSmrg		;;
1682b042e37fSmrg	*-sgi)
16838d0bc965Smrg		os=irix
1684b042e37fSmrg		;;
1685b042e37fSmrg	*-siemens)
16868d0bc965Smrg		os=sysv4
1687b042e37fSmrg		;;
1688b042e37fSmrg	*-masscomp)
16898d0bc965Smrg		os=rtu
1690b042e37fSmrg		;;
1691b042e37fSmrg	f30[01]-fujitsu | f700-fujitsu)
16928d0bc965Smrg		os=uxpv
1693b042e37fSmrg		;;
1694b042e37fSmrg	*-rom68k)
16958d0bc965Smrg		os=coff
1696b042e37fSmrg		;;
1697b042e37fSmrg	*-*bug)
16988d0bc965Smrg		os=coff
1699b042e37fSmrg		;;
1700b042e37fSmrg	*-apple)
17018d0bc965Smrg		os=macos
1702b042e37fSmrg		;;
1703b042e37fSmrg	*-atari*)
17048d0bc965Smrg		os=mint
17058d0bc965Smrg		;;
17068d0bc965Smrg	*-wrs)
17078d0bc965Smrg		os=vxworks
1708b042e37fSmrg		;;
1709b042e37fSmrg	*)
17108d0bc965Smrg		os=none
1711b042e37fSmrg		;;
1712b042e37fSmrgesac
17138d0bc965Smrg
1714b042e37fSmrgfi
1715b042e37fSmrg
17168d0bc965Smrg# Now, validate our (potentially fixed-up) OS.
17178d0bc965Smrgcase $os in
17188d0bc965Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17198d0bc965Smrg	musl* | newlib* | relibc* | uclibc*)
17208d0bc965Smrg		;;
17218d0bc965Smrg	# Likewise for "kernel-abi"
17228d0bc965Smrg	eabi* | gnueabi*)
17238d0bc965Smrg		;;
17248d0bc965Smrg	# VxWorks passes extra cpu info in the 4th filed.
17258d0bc965Smrg	simlinux | simwindows | spe)
17268d0bc965Smrg		;;
17278d0bc965Smrg	# Now accept the basic system types.
17288d0bc965Smrg	# The portable systems comes first.
17298d0bc965Smrg	# Each alternative MUST end in a * to match a version number.
17308d0bc965Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17318d0bc965Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17328d0bc965Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17338d0bc965Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17348d0bc965Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17358d0bc965Smrg	     | os9* | macos* | osx* | ios* \
17368d0bc965Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17378d0bc965Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17388d0bc965Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17398d0bc965Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17408d0bc965Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17418d0bc965Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17428d0bc965Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17438d0bc965Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17448d0bc965Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17458d0bc965Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17468d0bc965Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17478d0bc965Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17488d0bc965Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17498d0bc965Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17508d0bc965Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17518d0bc965Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17528d0bc965Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17538d0bc965Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17548d0bc965Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17558d0bc965Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17568d0bc965Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17578d0bc965Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17588d0bc965Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17598d0bc965Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17600c674dbdSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17610c674dbdSmrg	     | fiwix* | mlibc* )
17628d0bc965Smrg		;;
17638d0bc965Smrg	# This one is extra strict with allowed versions
17648d0bc965Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17658d0bc965Smrg		# Don't forget version if it is 3.2v4 or newer.
17668d0bc965Smrg		;;
17678d0bc965Smrg	none)
17688d0bc965Smrg		;;
17690c674dbdSmrg	kernel* )
17700c674dbdSmrg		# Restricted further below
17710c674dbdSmrg		;;
17728d0bc965Smrg	*)
17738d0bc965Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17748d0bc965Smrg		exit 1
17758d0bc965Smrg		;;
17768d0bc965Smrgesac
17778d0bc965Smrg
17788d0bc965Smrg# As a final step for OS-related things, validate the OS-kernel combination
17798d0bc965Smrg# (given a valid OS), if there is a kernel.
17808d0bc965Smrgcase $kernel-$os in
17818d0bc965Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
17820c674dbdSmrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17838d0bc965Smrg		;;
17848d0bc965Smrg	uclinux-uclibc* )
17858d0bc965Smrg		;;
17860c674dbdSmrg	managarm-mlibc* | managarm-kernel* )
17870c674dbdSmrg		;;
17880c674dbdSmrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17898d0bc965Smrg		# These are just libc implementations, not actual OSes, and thus
17908d0bc965Smrg		# require a kernel.
17918d0bc965Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17928d0bc965Smrg		exit 1
17938d0bc965Smrg		;;
17940c674dbdSmrg	-kernel* )
17950c674dbdSmrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
17960c674dbdSmrg		exit 1
17970c674dbdSmrg		;;
17980c674dbdSmrg	*-kernel* )
17990c674dbdSmrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
18000c674dbdSmrg		exit 1
18010c674dbdSmrg		;;
18028d0bc965Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
18038d0bc965Smrg		;;
18048d0bc965Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
18058d0bc965Smrg		;;
18068d0bc965Smrg	nto-qnx*)
18078d0bc965Smrg		;;
18088d0bc965Smrg	os2-emx)
18098d0bc965Smrg		;;
18108d0bc965Smrg	*-eabi* | *-gnueabi*)
18118d0bc965Smrg		;;
18128d0bc965Smrg	-*)
18138d0bc965Smrg		# Blank kernel with real OS is always fine.
18148d0bc965Smrg		;;
18158d0bc965Smrg	*-*)
18168d0bc965Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18178d0bc965Smrg		exit 1
18188d0bc965Smrg		;;
18198d0bc965Smrgesac
18208d0bc965Smrg
1821b042e37fSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1822b042e37fSmrg# manufacturer.  We pick the logical manufacturer.
18238d0bc965Smrgcase $vendor in
18248d0bc965Smrg	unknown)
18258d0bc965Smrg		case $cpu-$os in
18268d0bc965Smrg			*-riscix*)
1827b042e37fSmrg				vendor=acorn
1828b042e37fSmrg				;;
18298d0bc965Smrg			*-sunos*)
1830b042e37fSmrg				vendor=sun
1831b042e37fSmrg				;;
18328d0bc965Smrg			*-cnk* | *-aix*)
1833b042e37fSmrg				vendor=ibm
1834b042e37fSmrg				;;
18358d0bc965Smrg			*-beos*)
1836b042e37fSmrg				vendor=be
1837b042e37fSmrg				;;
18388d0bc965Smrg			*-hpux*)
1839b042e37fSmrg				vendor=hp
1840b042e37fSmrg				;;
18418d0bc965Smrg			*-mpeix*)
1842b042e37fSmrg				vendor=hp
1843b042e37fSmrg				;;
18448d0bc965Smrg			*-hiux*)
1845b042e37fSmrg				vendor=hitachi
1846b042e37fSmrg				;;
18478d0bc965Smrg			*-unos*)
1848b042e37fSmrg				vendor=crds
1849b042e37fSmrg				;;
18508d0bc965Smrg			*-dgux*)
1851b042e37fSmrg				vendor=dg
1852b042e37fSmrg				;;
18538d0bc965Smrg			*-luna*)
1854b042e37fSmrg				vendor=omron
1855b042e37fSmrg				;;
18568d0bc965Smrg			*-genix*)
1857b042e37fSmrg				vendor=ns
1858b042e37fSmrg				;;
18598d0bc965Smrg			*-clix*)
18608d0bc965Smrg				vendor=intergraph
18618d0bc965Smrg				;;
18628d0bc965Smrg			*-mvs* | *-opened*)
18638d0bc965Smrg				vendor=ibm
18648d0bc965Smrg				;;
18658d0bc965Smrg			*-os400*)
1866b042e37fSmrg				vendor=ibm
1867b042e37fSmrg				;;
18688d0bc965Smrg			s390-* | s390x-*)
18698c4a8e55Smrg				vendor=ibm
18708c4a8e55Smrg				;;
18718d0bc965Smrg			*-ptx*)
1872b042e37fSmrg				vendor=sequent
1873b042e37fSmrg				;;
18748d0bc965Smrg			*-tpf*)
18758c4a8e55Smrg				vendor=ibm
18768c4a8e55Smrg				;;
18778d0bc965Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1878b042e37fSmrg				vendor=wrs
1879b042e37fSmrg				;;
18808d0bc965Smrg			*-aux*)
1881b042e37fSmrg				vendor=apple
1882b042e37fSmrg				;;
18838d0bc965Smrg			*-hms*)
1884b042e37fSmrg				vendor=hitachi
1885b042e37fSmrg				;;
18868d0bc965Smrg			*-mpw* | *-macos*)
1887b042e37fSmrg				vendor=apple
1888b042e37fSmrg				;;
18898d0bc965Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890b042e37fSmrg				vendor=atari
1891b042e37fSmrg				;;
18928d0bc965Smrg			*-vos*)
1893b042e37fSmrg				vendor=stratus
1894b042e37fSmrg				;;
1895b042e37fSmrg		esac
1896b042e37fSmrg		;;
1897b042e37fSmrgesac
1898b042e37fSmrg
18998d0bc965Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
19008c4a8e55Smrgexit
1901b042e37fSmrg
1902b042e37fSmrg# Local variables:
19038d0bc965Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904b042e37fSmrg# time-stamp-start: "timestamp='"
1905b042e37fSmrg# time-stamp-format: "%:y-%02m-%02d"
1906b042e37fSmrg# time-stamp-end: "'"
1907b042e37fSmrg# End:
1908