1ee3138f1Smrg#! /bin/sh
2ee3138f1Smrg# Configuration validation subroutine script.
38d623946Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
4ee3138f1Smrg
58d623946Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
68d623946Smrg
78d623946Smrgtimestamp='2021-08-14'
8ee3138f1Smrg
9414bd68fSmrg# This file is free software; you can redistribute it and/or modify it
10414bd68fSmrg# under the terms of the GNU General Public License as published by
11414bd68fSmrg# the Free Software Foundation; either version 3 of the License, or
12ee3138f1Smrg# (at your option) any later version.
13ee3138f1Smrg#
14414bd68fSmrg# This program is distributed in the hope that it will be useful, but
15414bd68fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16414bd68fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17414bd68fSmrg# General Public License for more details.
18ee3138f1Smrg#
19ee3138f1Smrg# You should have received a copy of the GNU General Public License
208d623946Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21ee3138f1Smrg#
22ee3138f1Smrg# As a special exception to the GNU General Public License, if you
23ee3138f1Smrg# distribute this file as part of a program that contains a
24ee3138f1Smrg# configuration script generated by Autoconf, you may include it under
25414bd68fSmrg# the same distribution terms that you use for the rest of that
26414bd68fSmrg# program.  This Exception is an additional permission under section 7
27414bd68fSmrg# of the GNU General Public License, version 3 ("GPLv3").
28ee3138f1Smrg
29ee3138f1Smrg
30414bd68fSmrg# Please send patches to <config-patches@gnu.org>.
31ee3138f1Smrg#
32ee3138f1Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33ee3138f1Smrg# Supply the specified configuration type as an argument.
34ee3138f1Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35ee3138f1Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36ee3138f1Smrg
37b425557eSmrg# You can get the latest version of this script from:
388d623946Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39b425557eSmrg
40ee3138f1Smrg# This file is supposed to be the same for all GNU packages
41ee3138f1Smrg# and recognize all the CPU types, system types and aliases
42ee3138f1Smrg# that are meaningful with *any* GNU software.
43ee3138f1Smrg# Each package is responsible for reporting which valid configurations
44ee3138f1Smrg# it does not support.  The user should be able to distinguish
45ee3138f1Smrg# a failure to support a valid configuration from a meaningless
46ee3138f1Smrg# configuration.
47ee3138f1Smrg
48ee3138f1Smrg# The goal of this file is to map all the various variations of a given
49ee3138f1Smrg# machine specification into a single specification in the form:
50ee3138f1Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51ee3138f1Smrg# or in some cases, the newer four-part form:
52ee3138f1Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53ee3138f1Smrg# It is wrong to echo any other type of specification.
54ee3138f1Smrg
558d623946Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
568d623946Smrg# about features and limitations of the classic Bourne shell that were
578d623946Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
588d623946Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
598d623946Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
608d623946Smrg# have a pre-POSIX /bin/sh.
618d623946Smrg
62ee3138f1Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63ee3138f1Smrg
64ee3138f1Smrgusage="\
658d623946SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66ee3138f1Smrg
67ee3138f1SmrgCanonicalize a configuration name.
68ee3138f1Smrg
698d623946SmrgOptions:
70ee3138f1Smrg  -h, --help         print this help, then exit
71ee3138f1Smrg  -t, --time-stamp   print date of last modification, then exit
72ee3138f1Smrg  -v, --version      print version number, then exit
73ee3138f1Smrg
74ee3138f1SmrgReport bugs and patches to <config-patches@gnu.org>."
75ee3138f1Smrg
76ee3138f1Smrgversion="\
77ee3138f1SmrgGNU config.sub ($timestamp)
78ee3138f1Smrg
798d623946SmrgCopyright 1992-2021 Free Software Foundation, Inc.
80ee3138f1Smrg
81ee3138f1SmrgThis is free software; see the source for copying conditions.  There is NO
82ee3138f1Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83ee3138f1Smrg
84ee3138f1Smrghelp="
85ee3138f1SmrgTry \`$me --help' for more information."
86ee3138f1Smrg
87ee3138f1Smrg# Parse command line
88ee3138f1Smrgwhile test $# -gt 0 ; do
89ee3138f1Smrg  case $1 in
90ee3138f1Smrg    --time-stamp | --time* | -t )
91ee3138f1Smrg       echo "$timestamp" ; exit ;;
92ee3138f1Smrg    --version | -v )
93ee3138f1Smrg       echo "$version" ; exit ;;
94ee3138f1Smrg    --help | --h* | -h )
95ee3138f1Smrg       echo "$usage"; exit ;;
96ee3138f1Smrg    -- )     # Stop option processing
97ee3138f1Smrg       shift; break ;;
98ee3138f1Smrg    - )	# Use stdin as input.
99ee3138f1Smrg       break ;;
100ee3138f1Smrg    -* )
1018d623946Smrg       echo "$me: invalid option $1$help" >&2
102ee3138f1Smrg       exit 1 ;;
103ee3138f1Smrg
104ee3138f1Smrg    *local*)
105ee3138f1Smrg       # First pass through any local machine types.
1068d623946Smrg       echo "$1"
107ee3138f1Smrg       exit ;;
108ee3138f1Smrg
109ee3138f1Smrg    * )
110ee3138f1Smrg       break ;;
111ee3138f1Smrg  esac
112ee3138f1Smrgdone
113ee3138f1Smrg
114ee3138f1Smrgcase $# in
115ee3138f1Smrg 0) echo "$me: missing argument$help" >&2
116ee3138f1Smrg    exit 1;;
117ee3138f1Smrg 1) ;;
118ee3138f1Smrg *) echo "$me: too many arguments$help" >&2
119ee3138f1Smrg    exit 1;;
120ee3138f1Smrgesac
121ee3138f1Smrg
1228d623946Smrg# Split fields of configuration type
1238d623946Smrg# shellcheck disable=SC2162
1248d623946Smrgsaved_IFS=$IFS
1258d623946SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1268d623946Smrg$1
1278d623946SmrgEOF
1288d623946SmrgIFS=$saved_IFS
129ee3138f1Smrg
1308d623946Smrg# Separate into logical components for further validation
1318d623946Smrgcase $1 in
1328d623946Smrg	*-*-*-*-*)
1338d623946Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
1348d623946Smrg		exit 1
135ee3138f1Smrg		;;
1368d623946Smrg	*-*-*-*)
1378d623946Smrg		basic_machine=$field1-$field2
1388d623946Smrg		basic_os=$field3-$field4
139ee3138f1Smrg		;;
1408d623946Smrg	*-*-*)
1418d623946Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1428d623946Smrg		# parts
1438d623946Smrg		maybe_os=$field2-$field3
1448d623946Smrg		case $maybe_os in
1458d623946Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1468d623946Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1478d623946Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1488d623946Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
1498d623946Smrg				basic_machine=$field1
1508d623946Smrg				basic_os=$maybe_os
1518d623946Smrg				;;
1528d623946Smrg			android-linux)
1538d623946Smrg				basic_machine=$field1-unknown
1548d623946Smrg				basic_os=linux-android
1558d623946Smrg				;;
1568d623946Smrg			*)
1578d623946Smrg				basic_machine=$field1-$field2
1588d623946Smrg				basic_os=$field3
1598d623946Smrg				;;
1608d623946Smrg		esac
161ee3138f1Smrg		;;
1628d623946Smrg	*-*)
1638d623946Smrg		# A lone config we happen to match not fitting any pattern
1648d623946Smrg		case $field1-$field2 in
1658d623946Smrg			decstation-3100)
1668d623946Smrg				basic_machine=mips-dec
1678d623946Smrg				basic_os=
1688d623946Smrg				;;
1698d623946Smrg			*-*)
1708d623946Smrg				# Second component is usually, but not always the OS
1718d623946Smrg				case $field2 in
1728d623946Smrg					# Prevent following clause from handling this valid os
1738d623946Smrg					sun*os*)
1748d623946Smrg						basic_machine=$field1
1758d623946Smrg						basic_os=$field2
1768d623946Smrg						;;
1778d623946Smrg					zephyr*)
1788d623946Smrg						basic_machine=$field1-unknown
1798d623946Smrg						basic_os=$field2
1808d623946Smrg						;;
1818d623946Smrg					# Manufacturers
1828d623946Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1838d623946Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1848d623946Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1858d623946Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1868d623946Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1878d623946Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1888d623946Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1898d623946Smrg					| microblaze* | sim | cisco \
1908d623946Smrg					| oki | wec | wrs | winbond)
1918d623946Smrg						basic_machine=$field1-$field2
1928d623946Smrg						basic_os=
1938d623946Smrg						;;
1948d623946Smrg					*)
1958d623946Smrg						basic_machine=$field1
1968d623946Smrg						basic_os=$field2
1978d623946Smrg						;;
1988d623946Smrg				esac
1998d623946Smrg			;;
2008d623946Smrg		esac
201ee3138f1Smrg		;;
2028d623946Smrg	*)
2038d623946Smrg		# Convert single-component short-hands not valid as part of
2048d623946Smrg		# multi-component configurations.
2058d623946Smrg		case $field1 in
2068d623946Smrg			386bsd)
2078d623946Smrg				basic_machine=i386-pc
2088d623946Smrg				basic_os=bsd
2098d623946Smrg				;;
2108d623946Smrg			a29khif)
2118d623946Smrg				basic_machine=a29k-amd
2128d623946Smrg				basic_os=udi
2138d623946Smrg				;;
2148d623946Smrg			adobe68k)
2158d623946Smrg				basic_machine=m68010-adobe
2168d623946Smrg				basic_os=scout
2178d623946Smrg				;;
2188d623946Smrg			alliant)
2198d623946Smrg				basic_machine=fx80-alliant
2208d623946Smrg				basic_os=
2218d623946Smrg				;;
2228d623946Smrg			altos | altos3068)
2238d623946Smrg				basic_machine=m68k-altos
2248d623946Smrg				basic_os=
2258d623946Smrg				;;
2268d623946Smrg			am29k)
2278d623946Smrg				basic_machine=a29k-none
2288d623946Smrg				basic_os=bsd
2298d623946Smrg				;;
2308d623946Smrg			amdahl)
2318d623946Smrg				basic_machine=580-amdahl
2328d623946Smrg				basic_os=sysv
2338d623946Smrg				;;
2348d623946Smrg			amiga)
2358d623946Smrg				basic_machine=m68k-unknown
2368d623946Smrg				basic_os=
2378d623946Smrg				;;
2388d623946Smrg			amigaos | amigados)
2398d623946Smrg				basic_machine=m68k-unknown
2408d623946Smrg				basic_os=amigaos
2418d623946Smrg				;;
2428d623946Smrg			amigaunix | amix)
2438d623946Smrg				basic_machine=m68k-unknown
2448d623946Smrg				basic_os=sysv4
2458d623946Smrg				;;
2468d623946Smrg			apollo68)
2478d623946Smrg				basic_machine=m68k-apollo
2488d623946Smrg				basic_os=sysv
2498d623946Smrg				;;
2508d623946Smrg			apollo68bsd)
2518d623946Smrg				basic_machine=m68k-apollo
2528d623946Smrg				basic_os=bsd
2538d623946Smrg				;;
2548d623946Smrg			aros)
2558d623946Smrg				basic_machine=i386-pc
2568d623946Smrg				basic_os=aros
2578d623946Smrg				;;
2588d623946Smrg			aux)
2598d623946Smrg				basic_machine=m68k-apple
2608d623946Smrg				basic_os=aux
2618d623946Smrg				;;
2628d623946Smrg			balance)
2638d623946Smrg				basic_machine=ns32k-sequent
2648d623946Smrg				basic_os=dynix
2658d623946Smrg				;;
2668d623946Smrg			blackfin)
2678d623946Smrg				basic_machine=bfin-unknown
2688d623946Smrg				basic_os=linux
2698d623946Smrg				;;
2708d623946Smrg			cegcc)
2718d623946Smrg				basic_machine=arm-unknown
2728d623946Smrg				basic_os=cegcc
2738d623946Smrg				;;
2748d623946Smrg			convex-c1)
2758d623946Smrg				basic_machine=c1-convex
2768d623946Smrg				basic_os=bsd
2778d623946Smrg				;;
2788d623946Smrg			convex-c2)
2798d623946Smrg				basic_machine=c2-convex
2808d623946Smrg				basic_os=bsd
2818d623946Smrg				;;
2828d623946Smrg			convex-c32)
2838d623946Smrg				basic_machine=c32-convex
2848d623946Smrg				basic_os=bsd
2858d623946Smrg				;;
2868d623946Smrg			convex-c34)
2878d623946Smrg				basic_machine=c34-convex
2888d623946Smrg				basic_os=bsd
2898d623946Smrg				;;
2908d623946Smrg			convex-c38)
2918d623946Smrg				basic_machine=c38-convex
2928d623946Smrg				basic_os=bsd
2938d623946Smrg				;;
2948d623946Smrg			cray)
2958d623946Smrg				basic_machine=j90-cray
2968d623946Smrg				basic_os=unicos
2978d623946Smrg				;;
2988d623946Smrg			crds | unos)
2998d623946Smrg				basic_machine=m68k-crds
3008d623946Smrg				basic_os=
3018d623946Smrg				;;
3028d623946Smrg			da30)
3038d623946Smrg				basic_machine=m68k-da30
3048d623946Smrg				basic_os=
3058d623946Smrg				;;
3068d623946Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3078d623946Smrg				basic_machine=mips-dec
3088d623946Smrg				basic_os=
3098d623946Smrg				;;
3108d623946Smrg			delta88)
3118d623946Smrg				basic_machine=m88k-motorola
3128d623946Smrg				basic_os=sysv3
3138d623946Smrg				;;
3148d623946Smrg			dicos)
3158d623946Smrg				basic_machine=i686-pc
3168d623946Smrg				basic_os=dicos
3178d623946Smrg				;;
3188d623946Smrg			djgpp)
3198d623946Smrg				basic_machine=i586-pc
3208d623946Smrg				basic_os=msdosdjgpp
3218d623946Smrg				;;
3228d623946Smrg			ebmon29k)
3238d623946Smrg				basic_machine=a29k-amd
3248d623946Smrg				basic_os=ebmon
3258d623946Smrg				;;
3268d623946Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3278d623946Smrg				basic_machine=m68k-ericsson
3288d623946Smrg				basic_os=ose
3298d623946Smrg				;;
3308d623946Smrg			gmicro)
3318d623946Smrg				basic_machine=tron-gmicro
3328d623946Smrg				basic_os=sysv
3338d623946Smrg				;;
3348d623946Smrg			go32)
3358d623946Smrg				basic_machine=i386-pc
3368d623946Smrg				basic_os=go32
3378d623946Smrg				;;
3388d623946Smrg			h8300hms)
3398d623946Smrg				basic_machine=h8300-hitachi
3408d623946Smrg				basic_os=hms
3418d623946Smrg				;;
3428d623946Smrg			h8300xray)
3438d623946Smrg				basic_machine=h8300-hitachi
3448d623946Smrg				basic_os=xray
3458d623946Smrg				;;
3468d623946Smrg			h8500hms)
3478d623946Smrg				basic_machine=h8500-hitachi
3488d623946Smrg				basic_os=hms
3498d623946Smrg				;;
3508d623946Smrg			harris)
3518d623946Smrg				basic_machine=m88k-harris
3528d623946Smrg				basic_os=sysv3
3538d623946Smrg				;;
3548d623946Smrg			hp300 | hp300hpux)
3558d623946Smrg				basic_machine=m68k-hp
3568d623946Smrg				basic_os=hpux
3578d623946Smrg				;;
3588d623946Smrg			hp300bsd)
3598d623946Smrg				basic_machine=m68k-hp
3608d623946Smrg				basic_os=bsd
3618d623946Smrg				;;
3628d623946Smrg			hppaosf)
3638d623946Smrg				basic_machine=hppa1.1-hp
3648d623946Smrg				basic_os=osf
3658d623946Smrg				;;
3668d623946Smrg			hppro)
3678d623946Smrg				basic_machine=hppa1.1-hp
3688d623946Smrg				basic_os=proelf
3698d623946Smrg				;;
3708d623946Smrg			i386mach)
3718d623946Smrg				basic_machine=i386-mach
3728d623946Smrg				basic_os=mach
3738d623946Smrg				;;
3748d623946Smrg			isi68 | isi)
3758d623946Smrg				basic_machine=m68k-isi
3768d623946Smrg				basic_os=sysv
3778d623946Smrg				;;
3788d623946Smrg			m68knommu)
3798d623946Smrg				basic_machine=m68k-unknown
3808d623946Smrg				basic_os=linux
3818d623946Smrg				;;
3828d623946Smrg			magnum | m3230)
3838d623946Smrg				basic_machine=mips-mips
3848d623946Smrg				basic_os=sysv
3858d623946Smrg				;;
3868d623946Smrg			merlin)
3878d623946Smrg				basic_machine=ns32k-utek
3888d623946Smrg				basic_os=sysv
3898d623946Smrg				;;
3908d623946Smrg			mingw64)
3918d623946Smrg				basic_machine=x86_64-pc
3928d623946Smrg				basic_os=mingw64
3938d623946Smrg				;;
3948d623946Smrg			mingw32)
3958d623946Smrg				basic_machine=i686-pc
3968d623946Smrg				basic_os=mingw32
3978d623946Smrg				;;
3988d623946Smrg			mingw32ce)
3998d623946Smrg				basic_machine=arm-unknown
4008d623946Smrg				basic_os=mingw32ce
4018d623946Smrg				;;
4028d623946Smrg			monitor)
4038d623946Smrg				basic_machine=m68k-rom68k
4048d623946Smrg				basic_os=coff
4058d623946Smrg				;;
4068d623946Smrg			morphos)
4078d623946Smrg				basic_machine=powerpc-unknown
4088d623946Smrg				basic_os=morphos
4098d623946Smrg				;;
4108d623946Smrg			moxiebox)
4118d623946Smrg				basic_machine=moxie-unknown
4128d623946Smrg				basic_os=moxiebox
4138d623946Smrg				;;
4148d623946Smrg			msdos)
4158d623946Smrg				basic_machine=i386-pc
4168d623946Smrg				basic_os=msdos
4178d623946Smrg				;;
4188d623946Smrg			msys)
4198d623946Smrg				basic_machine=i686-pc
4208d623946Smrg				basic_os=msys
4218d623946Smrg				;;
4228d623946Smrg			mvs)
4238d623946Smrg				basic_machine=i370-ibm
4248d623946Smrg				basic_os=mvs
4258d623946Smrg				;;
4268d623946Smrg			nacl)
4278d623946Smrg				basic_machine=le32-unknown
4288d623946Smrg				basic_os=nacl
4298d623946Smrg				;;
4308d623946Smrg			ncr3000)
4318d623946Smrg				basic_machine=i486-ncr
4328d623946Smrg				basic_os=sysv4
4338d623946Smrg				;;
4348d623946Smrg			netbsd386)
4358d623946Smrg				basic_machine=i386-pc
4368d623946Smrg				basic_os=netbsd
4378d623946Smrg				;;
4388d623946Smrg			netwinder)
4398d623946Smrg				basic_machine=armv4l-rebel
4408d623946Smrg				basic_os=linux
4418d623946Smrg				;;
4428d623946Smrg			news | news700 | news800 | news900)
4438d623946Smrg				basic_machine=m68k-sony
4448d623946Smrg				basic_os=newsos
4458d623946Smrg				;;
4468d623946Smrg			news1000)
4478d623946Smrg				basic_machine=m68030-sony
4488d623946Smrg				basic_os=newsos
4498d623946Smrg				;;
4508d623946Smrg			necv70)
4518d623946Smrg				basic_machine=v70-nec
4528d623946Smrg				basic_os=sysv
4538d623946Smrg				;;
4548d623946Smrg			nh3000)
4558d623946Smrg				basic_machine=m68k-harris
4568d623946Smrg				basic_os=cxux
4578d623946Smrg				;;
4588d623946Smrg			nh[45]000)
4598d623946Smrg				basic_machine=m88k-harris
4608d623946Smrg				basic_os=cxux
4618d623946Smrg				;;
4628d623946Smrg			nindy960)
4638d623946Smrg				basic_machine=i960-intel
4648d623946Smrg				basic_os=nindy
4658d623946Smrg				;;
4668d623946Smrg			mon960)
4678d623946Smrg				basic_machine=i960-intel
4688d623946Smrg				basic_os=mon960
4698d623946Smrg				;;
4708d623946Smrg			nonstopux)
4718d623946Smrg				basic_machine=mips-compaq
4728d623946Smrg				basic_os=nonstopux
4738d623946Smrg				;;
4748d623946Smrg			os400)
4758d623946Smrg				basic_machine=powerpc-ibm
4768d623946Smrg				basic_os=os400
4778d623946Smrg				;;
4788d623946Smrg			OSE68000 | ose68000)
4798d623946Smrg				basic_machine=m68000-ericsson
4808d623946Smrg				basic_os=ose
4818d623946Smrg				;;
4828d623946Smrg			os68k)
4838d623946Smrg				basic_machine=m68k-none
4848d623946Smrg				basic_os=os68k
4858d623946Smrg				;;
4868d623946Smrg			paragon)
4878d623946Smrg				basic_machine=i860-intel
4888d623946Smrg				basic_os=osf
4898d623946Smrg				;;
4908d623946Smrg			parisc)
4918d623946Smrg				basic_machine=hppa-unknown
4928d623946Smrg				basic_os=linux
4938d623946Smrg				;;
4948d623946Smrg			psp)
4958d623946Smrg				basic_machine=mipsallegrexel-sony
4968d623946Smrg				basic_os=psp
4978d623946Smrg				;;
4988d623946Smrg			pw32)
4998d623946Smrg				basic_machine=i586-unknown
5008d623946Smrg				basic_os=pw32
5018d623946Smrg				;;
5028d623946Smrg			rdos | rdos64)
5038d623946Smrg				basic_machine=x86_64-pc
5048d623946Smrg				basic_os=rdos
5058d623946Smrg				;;
5068d623946Smrg			rdos32)
5078d623946Smrg				basic_machine=i386-pc
5088d623946Smrg				basic_os=rdos
5098d623946Smrg				;;
5108d623946Smrg			rom68k)
5118d623946Smrg				basic_machine=m68k-rom68k
5128d623946Smrg				basic_os=coff
5138d623946Smrg				;;
5148d623946Smrg			sa29200)
5158d623946Smrg				basic_machine=a29k-amd
5168d623946Smrg				basic_os=udi
5178d623946Smrg				;;
5188d623946Smrg			sei)
5198d623946Smrg				basic_machine=mips-sei
5208d623946Smrg				basic_os=seiux
5218d623946Smrg				;;
5228d623946Smrg			sequent)
5238d623946Smrg				basic_machine=i386-sequent
5248d623946Smrg				basic_os=
5258d623946Smrg				;;
5268d623946Smrg			sps7)
5278d623946Smrg				basic_machine=m68k-bull
5288d623946Smrg				basic_os=sysv2
5298d623946Smrg				;;
5308d623946Smrg			st2000)
5318d623946Smrg				basic_machine=m68k-tandem
5328d623946Smrg				basic_os=
5338d623946Smrg				;;
5348d623946Smrg			stratus)
5358d623946Smrg				basic_machine=i860-stratus
5368d623946Smrg				basic_os=sysv4
5378d623946Smrg				;;
5388d623946Smrg			sun2)
5398d623946Smrg				basic_machine=m68000-sun
5408d623946Smrg				basic_os=
5418d623946Smrg				;;
5428d623946Smrg			sun2os3)
5438d623946Smrg				basic_machine=m68000-sun
5448d623946Smrg				basic_os=sunos3
5458d623946Smrg				;;
5468d623946Smrg			sun2os4)
5478d623946Smrg				basic_machine=m68000-sun
5488d623946Smrg				basic_os=sunos4
5498d623946Smrg				;;
5508d623946Smrg			sun3)
5518d623946Smrg				basic_machine=m68k-sun
5528d623946Smrg				basic_os=
5538d623946Smrg				;;
5548d623946Smrg			sun3os3)
5558d623946Smrg				basic_machine=m68k-sun
5568d623946Smrg				basic_os=sunos3
5578d623946Smrg				;;
5588d623946Smrg			sun3os4)
5598d623946Smrg				basic_machine=m68k-sun
5608d623946Smrg				basic_os=sunos4
5618d623946Smrg				;;
5628d623946Smrg			sun4)
5638d623946Smrg				basic_machine=sparc-sun
5648d623946Smrg				basic_os=
5658d623946Smrg				;;
5668d623946Smrg			sun4os3)
5678d623946Smrg				basic_machine=sparc-sun
5688d623946Smrg				basic_os=sunos3
5698d623946Smrg				;;
5708d623946Smrg			sun4os4)
5718d623946Smrg				basic_machine=sparc-sun
5728d623946Smrg				basic_os=sunos4
5738d623946Smrg				;;
5748d623946Smrg			sun4sol2)
5758d623946Smrg				basic_machine=sparc-sun
5768d623946Smrg				basic_os=solaris2
5778d623946Smrg				;;
5788d623946Smrg			sun386 | sun386i | roadrunner)
5798d623946Smrg				basic_machine=i386-sun
5808d623946Smrg				basic_os=
5818d623946Smrg				;;
5828d623946Smrg			sv1)
5838d623946Smrg				basic_machine=sv1-cray
5848d623946Smrg				basic_os=unicos
5858d623946Smrg				;;
5868d623946Smrg			symmetry)
5878d623946Smrg				basic_machine=i386-sequent
5888d623946Smrg				basic_os=dynix
5898d623946Smrg				;;
5908d623946Smrg			t3e)
5918d623946Smrg				basic_machine=alphaev5-cray
5928d623946Smrg				basic_os=unicos
5938d623946Smrg				;;
5948d623946Smrg			t90)
5958d623946Smrg				basic_machine=t90-cray
5968d623946Smrg				basic_os=unicos
5978d623946Smrg				;;
5988d623946Smrg			toad1)
5998d623946Smrg				basic_machine=pdp10-xkl
6008d623946Smrg				basic_os=tops20
6018d623946Smrg				;;
6028d623946Smrg			tpf)
6038d623946Smrg				basic_machine=s390x-ibm
6048d623946Smrg				basic_os=tpf
6058d623946Smrg				;;
6068d623946Smrg			udi29k)
6078d623946Smrg				basic_machine=a29k-amd
6088d623946Smrg				basic_os=udi
6098d623946Smrg				;;
6108d623946Smrg			ultra3)
6118d623946Smrg				basic_machine=a29k-nyu
6128d623946Smrg				basic_os=sym1
6138d623946Smrg				;;
6148d623946Smrg			v810 | necv810)
6158d623946Smrg				basic_machine=v810-nec
6168d623946Smrg				basic_os=none
6178d623946Smrg				;;
6188d623946Smrg			vaxv)
6198d623946Smrg				basic_machine=vax-dec
6208d623946Smrg				basic_os=sysv
6218d623946Smrg				;;
6228d623946Smrg			vms)
6238d623946Smrg				basic_machine=vax-dec
6248d623946Smrg				basic_os=vms
6258d623946Smrg				;;
6268d623946Smrg			vsta)
6278d623946Smrg				basic_machine=i386-pc
6288d623946Smrg				basic_os=vsta
6298d623946Smrg				;;
6308d623946Smrg			vxworks960)
6318d623946Smrg				basic_machine=i960-wrs
6328d623946Smrg				basic_os=vxworks
6338d623946Smrg				;;
6348d623946Smrg			vxworks68)
6358d623946Smrg				basic_machine=m68k-wrs
6368d623946Smrg				basic_os=vxworks
6378d623946Smrg				;;
6388d623946Smrg			vxworks29k)
6398d623946Smrg				basic_machine=a29k-wrs
6408d623946Smrg				basic_os=vxworks
6418d623946Smrg				;;
6428d623946Smrg			xbox)
6438d623946Smrg				basic_machine=i686-pc
6448d623946Smrg				basic_os=mingw32
6458d623946Smrg				;;
6468d623946Smrg			ymp)
6478d623946Smrg				basic_machine=ymp-cray
6488d623946Smrg				basic_os=unicos
6498d623946Smrg				;;
6508d623946Smrg			*)
6518d623946Smrg				basic_machine=$1
6528d623946Smrg				basic_os=
6538d623946Smrg				;;
6548d623946Smrg		esac
655ee3138f1Smrg		;;
656ee3138f1Smrgesac
657ee3138f1Smrg
6588d623946Smrg# Decode 1-component or ad-hoc basic machines
659ee3138f1Smrgcase $basic_machine in
6608d623946Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6618d623946Smrg	# some cases the only manufacturer, in others, it is the most popular.
6628d623946Smrg	w89k)
6638d623946Smrg		cpu=hppa1.1
6648d623946Smrg		vendor=winbond
665414bd68fSmrg		;;
6668d623946Smrg	op50n)
6678d623946Smrg		cpu=hppa1.1
6688d623946Smrg		vendor=oki
669ee3138f1Smrg		;;
6708d623946Smrg	op60c)
6718d623946Smrg		cpu=hppa1.1
6728d623946Smrg		vendor=oki
673ee3138f1Smrg		;;
6748d623946Smrg	ibm*)
6758d623946Smrg		cpu=i370
6768d623946Smrg		vendor=ibm
677ee3138f1Smrg		;;
6788d623946Smrg	orion105)
6798d623946Smrg		cpu=clipper
6808d623946Smrg		vendor=highlevel
6813e72ca8cSmrg		;;
6828d623946Smrg	mac | mpw | mac-mpw)
6838d623946Smrg		cpu=m68k
6848d623946Smrg		vendor=apple
6853e72ca8cSmrg		;;
6868d623946Smrg	pmac | pmac-mpw)
6878d623946Smrg		cpu=powerpc
6888d623946Smrg		vendor=apple
6893e72ca8cSmrg		;;
6903e72ca8cSmrg
691ee3138f1Smrg	# Recognize the various machine names and aliases which stand
692ee3138f1Smrg	# for a CPU type and a company and sometimes even an OS.
693ee3138f1Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6948d623946Smrg		cpu=m68000
6958d623946Smrg		vendor=att
696ee3138f1Smrg		;;
697ee3138f1Smrg	3b*)
6988d623946Smrg		cpu=we32k
6998d623946Smrg		vendor=att
70079a8a9c6Smrg		;;
701b425557eSmrg	bluegene*)
7028d623946Smrg		cpu=powerpc
7038d623946Smrg		vendor=ibm
7048d623946Smrg		basic_os=cnk
705ee3138f1Smrg		;;
706ee3138f1Smrg	decsystem10* | dec10*)
7078d623946Smrg		cpu=pdp10
7088d623946Smrg		vendor=dec
7098d623946Smrg		basic_os=tops10
710ee3138f1Smrg		;;
711ee3138f1Smrg	decsystem20* | dec20*)
7128d623946Smrg		cpu=pdp10
7138d623946Smrg		vendor=dec
7148d623946Smrg		basic_os=tops20
715ee3138f1Smrg		;;
716ee3138f1Smrg	delta | 3300 | motorola-3300 | motorola-delta \
717ee3138f1Smrg	      | 3300-motorola | delta-motorola)
7188d623946Smrg		cpu=m68k
7198d623946Smrg		vendor=motorola
720ee3138f1Smrg		;;
7218d623946Smrg	dpx2*)
7228d623946Smrg		cpu=m68k
7238d623946Smrg		vendor=bull
7248d623946Smrg		basic_os=sysv3
725ee3138f1Smrg		;;
726ee3138f1Smrg	encore | umax | mmax)
7278d623946Smrg		cpu=ns32k
7288d623946Smrg		vendor=encore
729ee3138f1Smrg		;;
7308d623946Smrg	elxsi)
7318d623946Smrg		cpu=elxsi
7328d623946Smrg		vendor=elxsi
7338d623946Smrg		basic_os=${basic_os:-bsd}
734ee3138f1Smrg		;;
735ee3138f1Smrg	fx2800)
7368d623946Smrg		cpu=i860
7378d623946Smrg		vendor=alliant
738ee3138f1Smrg		;;
739ee3138f1Smrg	genix)
7408d623946Smrg		cpu=ns32k
7418d623946Smrg		vendor=ns
742ee3138f1Smrg		;;
743ee3138f1Smrg	h3050r* | hiux*)
7448d623946Smrg		cpu=hppa1.1
7458d623946Smrg		vendor=hitachi
7468d623946Smrg		basic_os=hiuxwe2
747ee3138f1Smrg		;;
748ee3138f1Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7498d623946Smrg		cpu=hppa1.0
7508d623946Smrg		vendor=hp
751ee3138f1Smrg		;;
752ee3138f1Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7538d623946Smrg		cpu=m68000
7548d623946Smrg		vendor=hp
755ee3138f1Smrg		;;
756ee3138f1Smrg	hp9k3[2-9][0-9])
7578d623946Smrg		cpu=m68k
7588d623946Smrg		vendor=hp
759ee3138f1Smrg		;;
760ee3138f1Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7618d623946Smrg		cpu=hppa1.0
7628d623946Smrg		vendor=hp
763ee3138f1Smrg		;;
764ee3138f1Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7658d623946Smrg		cpu=hppa1.1
7668d623946Smrg		vendor=hp
767ee3138f1Smrg		;;
768ee3138f1Smrg	hp9k78[0-9] | hp78[0-9])
769ee3138f1Smrg		# FIXME: really hppa2.0-hp
7708d623946Smrg		cpu=hppa1.1
7718d623946Smrg		vendor=hp
772ee3138f1Smrg		;;
773ee3138f1Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774ee3138f1Smrg		# FIXME: really hppa2.0-hp
7758d623946Smrg		cpu=hppa1.1
7768d623946Smrg		vendor=hp
777ee3138f1Smrg		;;
778ee3138f1Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7798d623946Smrg		cpu=hppa1.1
7808d623946Smrg		vendor=hp
781ee3138f1Smrg		;;
782ee3138f1Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7838d623946Smrg		cpu=hppa1.0
7848d623946Smrg		vendor=hp
785ee3138f1Smrg		;;
786ee3138f1Smrg	i*86v32)
7878d623946Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7888d623946Smrg		vendor=pc
7898d623946Smrg		basic_os=sysv32
790ee3138f1Smrg		;;
791ee3138f1Smrg	i*86v4*)
7928d623946Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7938d623946Smrg		vendor=pc
7948d623946Smrg		basic_os=sysv4
795ee3138f1Smrg		;;
796ee3138f1Smrg	i*86v)
7978d623946Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7988d623946Smrg		vendor=pc
7998d623946Smrg		basic_os=sysv
800ee3138f1Smrg		;;
801ee3138f1Smrg	i*86sol2)
8028d623946Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8038d623946Smrg		vendor=pc
8048d623946Smrg		basic_os=solaris2
805ee3138f1Smrg		;;
8068d623946Smrg	j90 | j90-cray)
8078d623946Smrg		cpu=j90
8088d623946Smrg		vendor=cray
8098d623946Smrg		basic_os=${basic_os:-unicos}
810ee3138f1Smrg		;;
811ee3138f1Smrg	iris | iris4d)
8128d623946Smrg		cpu=mips
8138d623946Smrg		vendor=sgi
8148d623946Smrg		case $basic_os in
8158d623946Smrg		    irix*)
816ee3138f1Smrg			;;
817ee3138f1Smrg		    *)
8188d623946Smrg			basic_os=irix4
819ee3138f1Smrg			;;
820ee3138f1Smrg		esac
821ee3138f1Smrg		;;
822ee3138f1Smrg	miniframe)
8238d623946Smrg		cpu=m68000
8248d623946Smrg		vendor=convergent
8253e72ca8cSmrg		;;
8268d623946Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8278d623946Smrg		cpu=m68k
8288d623946Smrg		vendor=atari
8298d623946Smrg		basic_os=mint
830ee3138f1Smrg		;;
831ee3138f1Smrg	news-3600 | risc-news)
8328d623946Smrg		cpu=mips
8338d623946Smrg		vendor=sony
8348d623946Smrg		basic_os=newsos
8358d623946Smrg		;;
8368d623946Smrg	next | m*-next)
8378d623946Smrg		cpu=m68k
8388d623946Smrg		vendor=next
8398d623946Smrg		case $basic_os in
8408d623946Smrg		    openstep*)
8418d623946Smrg		        ;;
8428d623946Smrg		    nextstep*)
843ee3138f1Smrg			;;
8448d623946Smrg		    ns2*)
8458d623946Smrg		      basic_os=nextstep2
846ee3138f1Smrg			;;
847ee3138f1Smrg		    *)
8488d623946Smrg		      basic_os=nextstep3
849ee3138f1Smrg			;;
850ee3138f1Smrg		esac
851ee3138f1Smrg		;;
852ee3138f1Smrg	np1)
8538d623946Smrg		cpu=np1
8548d623946Smrg		vendor=gould
855ee3138f1Smrg		;;
856ee3138f1Smrg	op50n-* | op60c-*)
8578d623946Smrg		cpu=hppa1.1
8588d623946Smrg		vendor=oki
8598d623946Smrg		basic_os=proelf
860ee3138f1Smrg		;;
861ee3138f1Smrg	pa-hitachi)
8628d623946Smrg		cpu=hppa1.1
8638d623946Smrg		vendor=hitachi
8648d623946Smrg		basic_os=hiuxwe2
86579a8a9c6Smrg		;;
866ee3138f1Smrg	pbd)
8678d623946Smrg		cpu=sparc
8688d623946Smrg		vendor=tti
869ee3138f1Smrg		;;
870ee3138f1Smrg	pbb)
8718d623946Smrg		cpu=m68k
8728d623946Smrg		vendor=tti
873ee3138f1Smrg		;;
8748d623946Smrg	pc532)
8758d623946Smrg		cpu=ns32k
8768d623946Smrg		vendor=pc532
877ee3138f1Smrg		;;
878ee3138f1Smrg	pn)
8798d623946Smrg		cpu=pn
8808d623946Smrg		vendor=gould
881ee3138f1Smrg		;;
8828d623946Smrg	power)
8838d623946Smrg		cpu=power
8848d623946Smrg		vendor=ibm
885ee3138f1Smrg		;;
886ee3138f1Smrg	ps2)
8878d623946Smrg		cpu=i386
8888d623946Smrg		vendor=ibm
889ee3138f1Smrg		;;
890ee3138f1Smrg	rm[46]00)
8918d623946Smrg		cpu=mips
8928d623946Smrg		vendor=siemens
893ee3138f1Smrg		;;
894ee3138f1Smrg	rtpc | rtpc-*)
8958d623946Smrg		cpu=romp
8968d623946Smrg		vendor=ibm
897ee3138f1Smrg		;;
8988d623946Smrg	sde)
8998d623946Smrg		cpu=mipsisa32
9008d623946Smrg		vendor=sde
9018d623946Smrg		basic_os=${basic_os:-elf}
902ee3138f1Smrg		;;
9038d623946Smrg	simso-wrs)
9048d623946Smrg		cpu=sparclite
9058d623946Smrg		vendor=wrs
9068d623946Smrg		basic_os=vxworks
907ee3138f1Smrg		;;
9088d623946Smrg	tower | tower-32)
9098d623946Smrg		cpu=m68k
9108d623946Smrg		vendor=ncr
911ee3138f1Smrg		;;
9128d623946Smrg	vpp*|vx|vx-*)
9138d623946Smrg		cpu=f301
9148d623946Smrg		vendor=fujitsu
915ee3138f1Smrg		;;
9168d623946Smrg	w65)
9178d623946Smrg		cpu=w65
9188d623946Smrg		vendor=wdc
919ee3138f1Smrg		;;
9208d623946Smrg	w89k-*)
9218d623946Smrg		cpu=hppa1.1
9228d623946Smrg		vendor=winbond
9238d623946Smrg		basic_os=proelf
924ee3138f1Smrg		;;
9258d623946Smrg	none)
9268d623946Smrg		cpu=none
9278d623946Smrg		vendor=none
928ee3138f1Smrg		;;
9298d623946Smrg	leon|leon[3-9])
9308d623946Smrg		cpu=sparc
9318d623946Smrg		vendor=$basic_machine
932ee3138f1Smrg		;;
9338d623946Smrg	leon-*|leon[3-9]-*)
9348d623946Smrg		cpu=sparc
9358d623946Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936ee3138f1Smrg		;;
9378d623946Smrg
9388d623946Smrg	*-*)
9398d623946Smrg		# shellcheck disable=SC2162
9408d623946Smrg		saved_IFS=$IFS
9418d623946Smrg		IFS="-" read cpu vendor <<EOF
9428d623946Smrg$basic_machine
9438d623946SmrgEOF
9448d623946Smrg		IFS=$saved_IFS
945ee3138f1Smrg		;;
9468d623946Smrg	# We use `pc' rather than `unknown'
9478d623946Smrg	# because (1) that's what they normally are, and
9488d623946Smrg	# (2) the word "unknown" tends to confuse beginning users.
9498d623946Smrg	i*86 | x86_64)
9508d623946Smrg		cpu=$basic_machine
9518d623946Smrg		vendor=pc
952ee3138f1Smrg		;;
9538d623946Smrg	# These rules are duplicated from below for sake of the special case above;
9548d623946Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9558d623946Smrg	pc98)
9568d623946Smrg		cpu=i386
9578d623946Smrg		vendor=pc
958ee3138f1Smrg		;;
9598d623946Smrg	x64 | amd64)
9608d623946Smrg		cpu=x86_64
9618d623946Smrg		vendor=pc
962ee3138f1Smrg		;;
9638d623946Smrg	# Recognize the basic CPU types without company name.
9648d623946Smrg	*)
9658d623946Smrg		cpu=$basic_machine
9668d623946Smrg		vendor=unknown
9673e72ca8cSmrg		;;
9688d623946Smrgesac
9698d623946Smrg
9708d623946Smrgunset -v basic_machine
9718d623946Smrg
9728d623946Smrg# Decode basic machines in the full and proper CPU-Company form.
9738d623946Smrgcase $cpu-$vendor in
9748d623946Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9758d623946Smrg	# some cases the only manufacturer, in others, it is the most popular.
9768d623946Smrg	craynv-unknown)
9778d623946Smrg		vendor=cray
9788d623946Smrg		basic_os=${basic_os:-unicosmp}
979ee3138f1Smrg		;;
9808d623946Smrg	c90-unknown | c90-cray)
9818d623946Smrg		vendor=cray
9828d623946Smrg		basic_os=${Basic_os:-unicos}
983ee3138f1Smrg		;;
9848d623946Smrg	fx80-unknown)
9858d623946Smrg		vendor=alliant
986ee3138f1Smrg		;;
9878d623946Smrg	romp-unknown)
9888d623946Smrg		vendor=ibm
989ee3138f1Smrg		;;
9908d623946Smrg	mmix-unknown)
9918d623946Smrg		vendor=knuth
992ee3138f1Smrg		;;
9938d623946Smrg	microblaze-unknown | microblazeel-unknown)
9948d623946Smrg		vendor=xilinx
995ee3138f1Smrg		;;
9968d623946Smrg	rs6000-unknown)
9978d623946Smrg		vendor=ibm
998ee3138f1Smrg		;;
9998d623946Smrg	vax-unknown)
10008d623946Smrg		vendor=dec
1001ee3138f1Smrg		;;
10028d623946Smrg	pdp11-unknown)
10038d623946Smrg		vendor=dec
1004ee3138f1Smrg		;;
10058d623946Smrg	we32k-unknown)
10068d623946Smrg		vendor=att
1007ee3138f1Smrg		;;
10088d623946Smrg	cydra-unknown)
10098d623946Smrg		vendor=cydrome
1010ee3138f1Smrg		;;
10118d623946Smrg	i370-ibm*)
10128d623946Smrg		vendor=ibm
1013ee3138f1Smrg		;;
10148d623946Smrg	orion-unknown)
10158d623946Smrg		vendor=highlevel
1016ee3138f1Smrg		;;
10178d623946Smrg	xps-unknown | xps100-unknown)
10188d623946Smrg		cpu=xps100
10198d623946Smrg		vendor=honeywell
1020ee3138f1Smrg		;;
10218d623946Smrg
10228d623946Smrg	# Here we normalize CPU types with a missing or matching vendor
10238d623946Smrg	dpx20-unknown | dpx20-bull)
10248d623946Smrg		cpu=rs6000
10258d623946Smrg		vendor=bull
10268d623946Smrg		basic_os=${basic_os:-bosx}
1027ee3138f1Smrg		;;
10288d623946Smrg
10298d623946Smrg	# Here we normalize CPU types irrespective of the vendor
10308d623946Smrg	amd64-*)
10318d623946Smrg		cpu=x86_64
103279a8a9c6Smrg		;;
10338d623946Smrg	blackfin-*)
10348d623946Smrg		cpu=bfin
10358d623946Smrg		basic_os=linux
1036ee3138f1Smrg		;;
10378d623946Smrg	c54x-*)
10388d623946Smrg		cpu=tic54x
1039ee3138f1Smrg		;;
10408d623946Smrg	c55x-*)
10418d623946Smrg		cpu=tic55x
1042ee3138f1Smrg		;;
10438d623946Smrg	c6x-*)
10448d623946Smrg		cpu=tic6x
1045ee3138f1Smrg		;;
10468d623946Smrg	e500v[12]-*)
10478d623946Smrg		cpu=powerpc
10488d623946Smrg		basic_os=${basic_os}"spe"
1049ee3138f1Smrg		;;
10508d623946Smrg	mips3*-*)
10518d623946Smrg		cpu=mips64
1052ee3138f1Smrg		;;
10538d623946Smrg	ms1-*)
10548d623946Smrg		cpu=mt
1055ee3138f1Smrg		;;
10568d623946Smrg	m68knommu-*)
10578d623946Smrg		cpu=m68k
10588d623946Smrg		basic_os=linux
1059ee3138f1Smrg		;;
10608d623946Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10618d623946Smrg		cpu=s12z
1062ee3138f1Smrg		;;
10638d623946Smrg	openrisc-*)
10648d623946Smrg		cpu=or32
1065ee3138f1Smrg		;;
10668d623946Smrg	parisc-*)
10678d623946Smrg		cpu=hppa
10688d623946Smrg		basic_os=linux
1069ee3138f1Smrg		;;
10708d623946Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10718d623946Smrg		cpu=i586
1072ee3138f1Smrg		;;
10738d623946Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
10748d623946Smrg		cpu=i686
1075ee3138f1Smrg		;;
10768d623946Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10778d623946Smrg		cpu=i686
1078ee3138f1Smrg		;;
10798d623946Smrg	pentium4-*)
10808d623946Smrg		cpu=i786
1081ee3138f1Smrg		;;
10828d623946Smrg	pc98-*)
10838d623946Smrg		cpu=i386
1084ee3138f1Smrg		;;
10858d623946Smrg	ppc-* | ppcbe-*)
10868d623946Smrg		cpu=powerpc
1087ee3138f1Smrg		;;
10888d623946Smrg	ppcle-* | powerpclittle-*)
10898d623946Smrg		cpu=powerpcle
1090ee3138f1Smrg		;;
10918d623946Smrg	ppc64-*)
10928d623946Smrg		cpu=powerpc64
10933e72ca8cSmrg		;;
10948d623946Smrg	ppc64le-* | powerpc64little-*)
10958d623946Smrg		cpu=powerpc64le
1096ee3138f1Smrg		;;
10978d623946Smrg	sb1-*)
10988d623946Smrg		cpu=mipsisa64sb1
1099ee3138f1Smrg		;;
11008d623946Smrg	sb1el-*)
11018d623946Smrg		cpu=mipsisa64sb1el
110234977a2fSmrg		;;
11038d623946Smrg	sh5e[lb]-*)
11048d623946Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1105ee3138f1Smrg		;;
11068d623946Smrg	spur-*)
11078d623946Smrg		cpu=spur
1108ee3138f1Smrg		;;
11098d623946Smrg	strongarm-* | thumb-*)
11108d623946Smrg		cpu=arm
1111ee3138f1Smrg		;;
11128d623946Smrg	tx39-*)
11138d623946Smrg		cpu=mipstx39
1114ee3138f1Smrg		;;
11158d623946Smrg	tx39el-*)
11168d623946Smrg		cpu=mipstx39el
1117ee3138f1Smrg		;;
11188d623946Smrg	x64-*)
11198d623946Smrg		cpu=x86_64
1120ee3138f1Smrg		;;
11218d623946Smrg	xscale-* | xscalee[bl]-*)
11228d623946Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1123ee3138f1Smrg		;;
11248d623946Smrg	arm64-*)
11258d623946Smrg		cpu=aarch64
1126ee3138f1Smrg		;;
11278d623946Smrg
11288d623946Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11298d623946Smrg	# company names they are paired with.
11308d623946Smrg	cr16-*)
11318d623946Smrg		basic_os=${basic_os:-elf}
1132ee3138f1Smrg		;;
11338d623946Smrg	crisv32-* | etraxfs*-*)
11348d623946Smrg		cpu=crisv32
11358d623946Smrg		vendor=axis
1136ee3138f1Smrg		;;
11378d623946Smrg	cris-* | etrax*-*)
11388d623946Smrg		cpu=cris
11398d623946Smrg		vendor=axis
1140ee3138f1Smrg		;;
11418d623946Smrg	crx-*)
11428d623946Smrg		basic_os=${basic_os:-elf}
1143ee3138f1Smrg		;;
11448d623946Smrg	neo-tandem)
11458d623946Smrg		cpu=neo
11468d623946Smrg		vendor=tandem
1147ee3138f1Smrg		;;
11488d623946Smrg	nse-tandem)
11498d623946Smrg		cpu=nse
11508d623946Smrg		vendor=tandem
1151ee3138f1Smrg		;;
11528d623946Smrg	nsr-tandem)
11538d623946Smrg		cpu=nsr
11548d623946Smrg		vendor=tandem
1155ee3138f1Smrg		;;
11568d623946Smrg	nsv-tandem)
11578d623946Smrg		cpu=nsv
11588d623946Smrg		vendor=tandem
1159ee3138f1Smrg		;;
11608d623946Smrg	nsx-tandem)
11618d623946Smrg		cpu=nsx
11628d623946Smrg		vendor=tandem
1163ee3138f1Smrg		;;
11648d623946Smrg	mipsallegrexel-sony)
11658d623946Smrg		cpu=mipsallegrexel
11668d623946Smrg		vendor=sony
1167ee3138f1Smrg		;;
11688d623946Smrg	tile*-*)
11698d623946Smrg		basic_os=${basic_os:-linux-gnu}
1170ee3138f1Smrg		;;
11718d623946Smrg
1172ee3138f1Smrg	*)
11738d623946Smrg		# Recognize the canonical CPU types that are allowed with any
11748d623946Smrg		# company name.
11758d623946Smrg		case $cpu in
11768d623946Smrg			1750a | 580 \
11778d623946Smrg			| a29k \
11788d623946Smrg			| aarch64 | aarch64_be \
11798d623946Smrg			| abacus \
11808d623946Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11818d623946Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11828d623946Smrg			| alphapca5[67] | alpha64pca5[67] \
11838d623946Smrg			| am33_2.0 \
11848d623946Smrg			| amdgcn \
11858d623946Smrg			| arc | arceb | arc32 | arc64 \
11868d623946Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11878d623946Smrg			| avr | avr32 \
11888d623946Smrg			| asmjs \
11898d623946Smrg			| ba \
11908d623946Smrg			| be32 | be64 \
11918d623946Smrg			| bfin | bpf | bs2000 \
11928d623946Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11938d623946Smrg			| c8051 | clipper | craynv | csky | cydra \
11948d623946Smrg			| d10v | d30v | dlx | dsp16xx \
11958d623946Smrg			| e2k | elxsi | epiphany \
11968d623946Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
11978d623946Smrg			| h8300 | h8500 \
11988d623946Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
11998d623946Smrg			| hexagon \
12008d623946Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12018d623946Smrg			| ip2k | iq2000 \
12028d623946Smrg			| k1om \
12038d623946Smrg			| le32 | le64 \
12048d623946Smrg			| lm32 \
12058d623946Smrg			| loongarch32 | loongarch64 | loongarchx32 \
12068d623946Smrg			| m32c | m32r | m32rle \
12078d623946Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12088d623946Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12098d623946Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12108d623946Smrg			| microblaze | microblazeel \
12118d623946Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12128d623946Smrg			| mips16 \
12138d623946Smrg			| mips64 | mips64eb | mips64el \
12148d623946Smrg			| mips64octeon | mips64octeonel \
12158d623946Smrg			| mips64orion | mips64orionel \
12168d623946Smrg			| mips64r5900 | mips64r5900el \
12178d623946Smrg			| mips64vr | mips64vrel \
12188d623946Smrg			| mips64vr4100 | mips64vr4100el \
12198d623946Smrg			| mips64vr4300 | mips64vr4300el \
12208d623946Smrg			| mips64vr5000 | mips64vr5000el \
12218d623946Smrg			| mips64vr5900 | mips64vr5900el \
12228d623946Smrg			| mipsisa32 | mipsisa32el \
12238d623946Smrg			| mipsisa32r2 | mipsisa32r2el \
12248d623946Smrg			| mipsisa32r3 | mipsisa32r3el \
12258d623946Smrg			| mipsisa32r5 | mipsisa32r5el \
12268d623946Smrg			| mipsisa32r6 | mipsisa32r6el \
12278d623946Smrg			| mipsisa64 | mipsisa64el \
12288d623946Smrg			| mipsisa64r2 | mipsisa64r2el \
12298d623946Smrg			| mipsisa64r3 | mipsisa64r3el \
12308d623946Smrg			| mipsisa64r5 | mipsisa64r5el \
12318d623946Smrg			| mipsisa64r6 | mipsisa64r6el \
12328d623946Smrg			| mipsisa64sb1 | mipsisa64sb1el \
12338d623946Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
12348d623946Smrg			| mipsr5900 | mipsr5900el \
12358d623946Smrg			| mipstx39 | mipstx39el \
12368d623946Smrg			| mmix \
12378d623946Smrg			| mn10200 | mn10300 \
12388d623946Smrg			| moxie \
12398d623946Smrg			| mt \
12408d623946Smrg			| msp430 \
12418d623946Smrg			| nds32 | nds32le | nds32be \
12428d623946Smrg			| nfp \
12438d623946Smrg			| nios | nios2 | nios2eb | nios2el \
12448d623946Smrg			| none | np1 | ns16k | ns32k | nvptx \
12458d623946Smrg			| open8 \
12468d623946Smrg			| or1k* \
12478d623946Smrg			| or32 \
12488d623946Smrg			| orion \
12498d623946Smrg			| picochip \
12508d623946Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12518d623946Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12528d623946Smrg			| pru \
12538d623946Smrg			| pyramid \
12548d623946Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12558d623946Smrg			| rl78 | romp | rs6000 | rx \
12568d623946Smrg			| s390 | s390x \
12578d623946Smrg			| score \
12588d623946Smrg			| sh | shl \
12598d623946Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12608d623946Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12618d623946Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12628d623946Smrg			| sparclite \
12638d623946Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12648d623946Smrg			| spu \
12658d623946Smrg			| tahoe \
12668d623946Smrg			| thumbv7* \
12678d623946Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12688d623946Smrg			| tron \
12698d623946Smrg			| ubicom32 \
12708d623946Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12718d623946Smrg			| vax \
12728d623946Smrg			| visium \
12738d623946Smrg			| w65 \
12748d623946Smrg			| wasm32 | wasm64 \
12758d623946Smrg			| we32k \
12768d623946Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12778d623946Smrg			| xstormy16 | xtensa* \
12788d623946Smrg			| ymp \
12798d623946Smrg			| z8k | z80)
12808d623946Smrg				;;
12818d623946Smrg
12828d623946Smrg			*)
12838d623946Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12848d623946Smrg				exit 1
12858d623946Smrg				;;
12868d623946Smrg		esac
1287ee3138f1Smrg		;;
1288ee3138f1Smrgesac
1289ee3138f1Smrg
1290ee3138f1Smrg# Here we canonicalize certain aliases for manufacturers.
12918d623946Smrgcase $vendor in
12928d623946Smrg	digital*)
12938d623946Smrg		vendor=dec
1294ee3138f1Smrg		;;
12958d623946Smrg	commodore*)
12968d623946Smrg		vendor=cbm
1297ee3138f1Smrg		;;
1298ee3138f1Smrg	*)
1299ee3138f1Smrg		;;
1300ee3138f1Smrgesac
1301ee3138f1Smrg
1302ee3138f1Smrg# Decode manufacturer-specific aliases for certain operating systems.
1303ee3138f1Smrg
13048d623946Smrgif test x$basic_os != x
1305ee3138f1Smrgthen
13068d623946Smrg
13078d623946Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
13088d623946Smrg# set os.
13098d623946Smrgcase $basic_os in
13108d623946Smrg	gnu/linux*)
13118d623946Smrg		kernel=linux
13128d623946Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13138d623946Smrg		;;
13148d623946Smrg	os2-emx)
13158d623946Smrg		kernel=os2
13168d623946Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13178d623946Smrg		;;
13188d623946Smrg	nto-qnx*)
13198d623946Smrg		kernel=nto
13208d623946Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13218d623946Smrg		;;
13228d623946Smrg	*-*)
13238d623946Smrg		# shellcheck disable=SC2162
13248d623946Smrg		saved_IFS=$IFS
13258d623946Smrg		IFS="-" read kernel os <<EOF
13268d623946Smrg$basic_os
13278d623946SmrgEOF
13288d623946Smrg		IFS=$saved_IFS
13298d623946Smrg		;;
13308d623946Smrg	# Default OS when just kernel was specified
13318d623946Smrg	nto*)
13328d623946Smrg		kernel=nto
13338d623946Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13348d623946Smrg		;;
13358d623946Smrg	linux*)
13368d623946Smrg		kernel=linux
13378d623946Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13388d623946Smrg		;;
13398d623946Smrg	*)
13408d623946Smrg		kernel=
13418d623946Smrg		os=$basic_os
13428d623946Smrg		;;
13438d623946Smrgesac
13448d623946Smrg
13458d623946Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13468d623946Smrg# etc.)
1347ee3138f1Smrgcase $os in
13488d623946Smrg	# First match some system type aliases that might get confused
13498d623946Smrg	# with valid system types.
13508d623946Smrg	# solaris* is a basic system type, with this one exception.
13518d623946Smrg	auroraux)
13528d623946Smrg		os=auroraux
1353b425557eSmrg		;;
13548d623946Smrg	bluegene*)
13558d623946Smrg		os=cnk
1356ee3138f1Smrg		;;
13578d623946Smrg	solaris1 | solaris1.*)
13588d623946Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1359ee3138f1Smrg		;;
13608d623946Smrg	solaris)
13618d623946Smrg		os=solaris2
1362ee3138f1Smrg		;;
13638d623946Smrg	unixware*)
13648d623946Smrg		os=sysv4.2uw
1365ee3138f1Smrg		;;
13668d623946Smrg	# es1800 is here to avoid being matched by es* (a different OS)
13678d623946Smrg	es1800*)
13688d623946Smrg		os=ose
1369ee3138f1Smrg		;;
13708d623946Smrg	# Some version numbers need modification
13718d623946Smrg	chorusos*)
13728d623946Smrg		os=chorusos
1373ee3138f1Smrg		;;
13748d623946Smrg	isc)
13758d623946Smrg		os=isc2.2
1376ee3138f1Smrg		;;
13778d623946Smrg	sco6)
13788d623946Smrg		os=sco5v6
1379ee3138f1Smrg		;;
13808d623946Smrg	sco5)
13818d623946Smrg		os=sco3.2v5
1382ee3138f1Smrg		;;
13838d623946Smrg	sco4)
13848d623946Smrg		os=sco3.2v4
1385ee3138f1Smrg		;;
13868d623946Smrg	sco3.2.[4-9]*)
13878d623946Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1388ee3138f1Smrg		;;
13898d623946Smrg	sco*v* | scout)
13908d623946Smrg		# Don't match below
1391ee3138f1Smrg		;;
13928d623946Smrg	sco*)
13938d623946Smrg		os=sco3.2v2
1394ee3138f1Smrg		;;
13958d623946Smrg	psos*)
13968d623946Smrg		os=psos
1397ee3138f1Smrg		;;
13988d623946Smrg	qnx*)
13998d623946Smrg		os=qnx
1400ee3138f1Smrg		;;
14018d623946Smrg	hiux*)
14028d623946Smrg		os=hiuxwe2
1403ee3138f1Smrg		;;
14048d623946Smrg	lynx*178)
14058d623946Smrg		os=lynxos178
1406ee3138f1Smrg		;;
14078d623946Smrg	lynx*5)
14088d623946Smrg		os=lynxos5
1409ee3138f1Smrg		;;
14108d623946Smrg	lynxos*)
14118d623946Smrg		# don't get caught up in next wildcard
1412ee3138f1Smrg		;;
14138d623946Smrg	lynx*)
14148d623946Smrg		os=lynxos
1415ee3138f1Smrg		;;
14168d623946Smrg	mac[0-9]*)
14178d623946Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1418ee3138f1Smrg		;;
14198d623946Smrg	opened*)
14208d623946Smrg		os=openedition
1421ee3138f1Smrg		;;
14228d623946Smrg	os400*)
14238d623946Smrg		os=os400
1424ee3138f1Smrg		;;
14258d623946Smrg	sunos5*)
14268d623946Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1427ee3138f1Smrg		;;
14288d623946Smrg	sunos6*)
14298d623946Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1430ee3138f1Smrg		;;
14318d623946Smrg	wince*)
14328d623946Smrg		os=wince
1433ee3138f1Smrg		;;
14348d623946Smrg	utek*)
14358d623946Smrg		os=bsd
1436ee3138f1Smrg		;;
14378d623946Smrg	dynix*)
14388d623946Smrg		os=bsd
1439ee3138f1Smrg		;;
14408d623946Smrg	acis*)
14418d623946Smrg		os=aos
1442ee3138f1Smrg		;;
14438d623946Smrg	atheos*)
14448d623946Smrg		os=atheos
1445ee3138f1Smrg		;;
14468d623946Smrg	syllable*)
14478d623946Smrg		os=syllable
1448ee3138f1Smrg		;;
14498d623946Smrg	386bsd)
14508d623946Smrg		os=bsd
1451ee3138f1Smrg		;;
14528d623946Smrg	ctix* | uts*)
14538d623946Smrg		os=sysv
1454ee3138f1Smrg		;;
14558d623946Smrg	nova*)
14568d623946Smrg		os=rtmk-nova
1457ee3138f1Smrg		;;
14588d623946Smrg	ns2)
14598d623946Smrg		os=nextstep2
1460ee3138f1Smrg		;;
14618d623946Smrg	# Preserve the version number of sinix5.
14628d623946Smrg	sinix5.*)
14638d623946Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1464ee3138f1Smrg		;;
14658d623946Smrg	sinix*)
14668d623946Smrg		os=sysv4
1467ee3138f1Smrg		;;
14688d623946Smrg	tpf*)
14698d623946Smrg		os=tpf
1470ee3138f1Smrg		;;
14718d623946Smrg	triton*)
14728d623946Smrg		os=sysv3
1473ee3138f1Smrg		;;
14748d623946Smrg	oss*)
14758d623946Smrg		os=sysv3
1476ee3138f1Smrg		;;
14778d623946Smrg	svr4*)
14788d623946Smrg		os=sysv4
1479ee3138f1Smrg		;;
14808d623946Smrg	svr3)
14818d623946Smrg		os=sysv3
1482ee3138f1Smrg		;;
14838d623946Smrg	sysvr4)
14848d623946Smrg		os=sysv4
1485ee3138f1Smrg		;;
14868d623946Smrg	ose*)
14878d623946Smrg		os=ose
1488ee3138f1Smrg		;;
14898d623946Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14908d623946Smrg		os=mint
149134977a2fSmrg		;;
14928d623946Smrg	dicos*)
14938d623946Smrg		os=dicos
14943e72ca8cSmrg		;;
14958d623946Smrg	pikeos*)
14968d623946Smrg		# Until real need of OS specific support for
14978d623946Smrg		# particular features comes up, bare metal
14988d623946Smrg		# configurations are quite functional.
14998d623946Smrg		case $cpu in
15008d623946Smrg		    arm*)
15018d623946Smrg			os=eabi
15028d623946Smrg			;;
15038d623946Smrg		    *)
15048d623946Smrg			os=elf
15058d623946Smrg			;;
15068d623946Smrg		esac
1507ee3138f1Smrg		;;
1508ee3138f1Smrg	*)
15098d623946Smrg		# No normalization, but not necessarily accepted, that comes below.
1510ee3138f1Smrg		;;
1511ee3138f1Smrgesac
15128d623946Smrg
1513ee3138f1Smrgelse
1514ee3138f1Smrg
1515ee3138f1Smrg# Here we handle the default operating systems that come with various machines.
1516ee3138f1Smrg# The value should be what the vendor currently ships out the door with their
1517ee3138f1Smrg# machine or put another way, the most popular os provided with the machine.
1518ee3138f1Smrg
1519ee3138f1Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1520ee3138f1Smrg# "-sun"), then you have to tell the case statement up towards the top
1521ee3138f1Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1522ee3138f1Smrg# will signal an error saying that MANUFACTURER isn't an operating
1523ee3138f1Smrg# system, and we'll never get to this point.
1524ee3138f1Smrg
15258d623946Smrgkernel=
15268d623946Smrgcase $cpu-$vendor in
15273e72ca8cSmrg	score-*)
15288d623946Smrg		os=elf
1529ee3138f1Smrg		;;
15303e72ca8cSmrg	spu-*)
15318d623946Smrg		os=elf
1532ee3138f1Smrg		;;
1533ee3138f1Smrg	*-acorn)
15348d623946Smrg		os=riscix1.2
1535ee3138f1Smrg		;;
1536ee3138f1Smrg	arm*-rebel)
15378d623946Smrg		kernel=linux
15388d623946Smrg		os=gnu
1539ee3138f1Smrg		;;
1540ee3138f1Smrg	arm*-semi)
15418d623946Smrg		os=aout
1542ee3138f1Smrg		;;
15433e72ca8cSmrg	c4x-* | tic4x-*)
15448d623946Smrg		os=coff
15453e72ca8cSmrg		;;
1546414bd68fSmrg	c8051-*)
15478d623946Smrg		os=elf
15488d623946Smrg		;;
15498d623946Smrg	clipper-intergraph)
15508d623946Smrg		os=clix
1551414bd68fSmrg		;;
15523e72ca8cSmrg	hexagon-*)
15538d623946Smrg		os=elf
15543e72ca8cSmrg		;;
15553e72ca8cSmrg	tic54x-*)
15568d623946Smrg		os=coff
15573e72ca8cSmrg		;;
15583e72ca8cSmrg	tic55x-*)
15598d623946Smrg		os=coff
15603e72ca8cSmrg		;;
15613e72ca8cSmrg	tic6x-*)
15628d623946Smrg		os=coff
1563ee3138f1Smrg		;;
1564ee3138f1Smrg	# This must come before the *-dec entry.
1565ee3138f1Smrg	pdp10-*)
15668d623946Smrg		os=tops20
1567ee3138f1Smrg		;;
1568ee3138f1Smrg	pdp11-*)
15698d623946Smrg		os=none
1570ee3138f1Smrg		;;
1571ee3138f1Smrg	*-dec | vax-*)
15728d623946Smrg		os=ultrix4.2
1573ee3138f1Smrg		;;
1574ee3138f1Smrg	m68*-apollo)
15758d623946Smrg		os=domain
1576ee3138f1Smrg		;;
1577ee3138f1Smrg	i386-sun)
15788d623946Smrg		os=sunos4.0.2
1579ee3138f1Smrg		;;
1580ee3138f1Smrg	m68000-sun)
15818d623946Smrg		os=sunos3
1582ee3138f1Smrg		;;
1583ee3138f1Smrg	m68*-cisco)
15848d623946Smrg		os=aout
1585ee3138f1Smrg		;;
15863e72ca8cSmrg	mep-*)
15878d623946Smrg		os=elf
1588ee3138f1Smrg		;;
1589ee3138f1Smrg	mips*-cisco)
15908d623946Smrg		os=elf
1591ee3138f1Smrg		;;
1592ee3138f1Smrg	mips*-*)
15938d623946Smrg		os=elf
1594ee3138f1Smrg		;;
1595ee3138f1Smrg	or32-*)
15968d623946Smrg		os=coff
1597ee3138f1Smrg		;;
1598ee3138f1Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
15998d623946Smrg		os=sysv3
1600ee3138f1Smrg		;;
1601ee3138f1Smrg	sparc-* | *-sun)
16028d623946Smrg		os=sunos4.1.1
1603ee3138f1Smrg		;;
16048d623946Smrg	pru-*)
16058d623946Smrg		os=elf
1606ee3138f1Smrg		;;
16078d623946Smrg	*-be)
16088d623946Smrg		os=beos
1609ee3138f1Smrg		;;
1610ee3138f1Smrg	*-ibm)
16118d623946Smrg		os=aix
1612ee3138f1Smrg		;;
16133e72ca8cSmrg	*-knuth)
16148d623946Smrg		os=mmixware
1615ee3138f1Smrg		;;
1616ee3138f1Smrg	*-wec)
16178d623946Smrg		os=proelf
1618ee3138f1Smrg		;;
1619ee3138f1Smrg	*-winbond)
16208d623946Smrg		os=proelf
1621ee3138f1Smrg		;;
1622ee3138f1Smrg	*-oki)
16238d623946Smrg		os=proelf
1624ee3138f1Smrg		;;
1625ee3138f1Smrg	*-hp)
16268d623946Smrg		os=hpux
1627ee3138f1Smrg		;;
1628ee3138f1Smrg	*-hitachi)
16298d623946Smrg		os=hiux
1630ee3138f1Smrg		;;
1631ee3138f1Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16328d623946Smrg		os=sysv
1633ee3138f1Smrg		;;
1634ee3138f1Smrg	*-cbm)
16358d623946Smrg		os=amigaos
1636ee3138f1Smrg		;;
1637ee3138f1Smrg	*-dg)
16388d623946Smrg		os=dgux
1639ee3138f1Smrg		;;
1640ee3138f1Smrg	*-dolphin)
16418d623946Smrg		os=sysv3
1642ee3138f1Smrg		;;
1643ee3138f1Smrg	m68k-ccur)
16448d623946Smrg		os=rtu
1645ee3138f1Smrg		;;
1646ee3138f1Smrg	m88k-omron*)
16478d623946Smrg		os=luna
1648ee3138f1Smrg		;;
16498d623946Smrg	*-next)
16508d623946Smrg		os=nextstep
1651ee3138f1Smrg		;;
1652ee3138f1Smrg	*-sequent)
16538d623946Smrg		os=ptx
1654ee3138f1Smrg		;;
1655ee3138f1Smrg	*-crds)
16568d623946Smrg		os=unos
1657ee3138f1Smrg		;;
1658ee3138f1Smrg	*-ns)
16598d623946Smrg		os=genix
1660ee3138f1Smrg		;;
1661ee3138f1Smrg	i370-*)
16628d623946Smrg		os=mvs
1663ee3138f1Smrg		;;
1664ee3138f1Smrg	*-gould)
16658d623946Smrg		os=sysv
1666ee3138f1Smrg		;;
1667ee3138f1Smrg	*-highlevel)
16688d623946Smrg		os=bsd
1669ee3138f1Smrg		;;
1670ee3138f1Smrg	*-encore)
16718d623946Smrg		os=bsd
1672ee3138f1Smrg		;;
1673ee3138f1Smrg	*-sgi)
16748d623946Smrg		os=irix
1675ee3138f1Smrg		;;
1676ee3138f1Smrg	*-siemens)
16778d623946Smrg		os=sysv4
1678ee3138f1Smrg		;;
1679ee3138f1Smrg	*-masscomp)
16808d623946Smrg		os=rtu
1681ee3138f1Smrg		;;
1682ee3138f1Smrg	f30[01]-fujitsu | f700-fujitsu)
16838d623946Smrg		os=uxpv
1684ee3138f1Smrg		;;
1685ee3138f1Smrg	*-rom68k)
16868d623946Smrg		os=coff
1687ee3138f1Smrg		;;
1688ee3138f1Smrg	*-*bug)
16898d623946Smrg		os=coff
1690ee3138f1Smrg		;;
1691ee3138f1Smrg	*-apple)
16928d623946Smrg		os=macos
1693ee3138f1Smrg		;;
1694ee3138f1Smrg	*-atari*)
16958d623946Smrg		os=mint
16968d623946Smrg		;;
16978d623946Smrg	*-wrs)
16988d623946Smrg		os=vxworks
1699ee3138f1Smrg		;;
1700ee3138f1Smrg	*)
17018d623946Smrg		os=none
1702ee3138f1Smrg		;;
1703ee3138f1Smrgesac
17048d623946Smrg
1705ee3138f1Smrgfi
1706ee3138f1Smrg
17078d623946Smrg# Now, validate our (potentially fixed-up) OS.
17088d623946Smrgcase $os in
17098d623946Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17108d623946Smrg	musl* | newlib* | relibc* | uclibc*)
17118d623946Smrg		;;
17128d623946Smrg	# Likewise for "kernel-abi"
17138d623946Smrg	eabi* | gnueabi*)
17148d623946Smrg		;;
17158d623946Smrg	# VxWorks passes extra cpu info in the 4th filed.
17168d623946Smrg	simlinux | simwindows | spe)
17178d623946Smrg		;;
17188d623946Smrg	# Now accept the basic system types.
17198d623946Smrg	# The portable systems comes first.
17208d623946Smrg	# Each alternative MUST end in a * to match a version number.
17218d623946Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17228d623946Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17238d623946Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17248d623946Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17258d623946Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17268d623946Smrg	     | os9* | macos* | osx* | ios* \
17278d623946Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17288d623946Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17298d623946Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17308d623946Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17318d623946Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17328d623946Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17338d623946Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17348d623946Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17358d623946Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17368d623946Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17378d623946Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17388d623946Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17398d623946Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17408d623946Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17418d623946Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17428d623946Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17438d623946Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17448d623946Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17458d623946Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17468d623946Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17478d623946Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17488d623946Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17498d623946Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17508d623946Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17518d623946Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
17528d623946Smrg		;;
17538d623946Smrg	# This one is extra strict with allowed versions
17548d623946Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17558d623946Smrg		# Don't forget version if it is 3.2v4 or newer.
17568d623946Smrg		;;
17578d623946Smrg	none)
17588d623946Smrg		;;
17598d623946Smrg	*)
17608d623946Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17618d623946Smrg		exit 1
17628d623946Smrg		;;
17638d623946Smrgesac
17648d623946Smrg
17658d623946Smrg# As a final step for OS-related things, validate the OS-kernel combination
17668d623946Smrg# (given a valid OS), if there is a kernel.
17678d623946Smrgcase $kernel-$os in
17688d623946Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
17698d623946Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
17708d623946Smrg		;;
17718d623946Smrg	uclinux-uclibc* )
17728d623946Smrg		;;
17738d623946Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
17748d623946Smrg		# These are just libc implementations, not actual OSes, and thus
17758d623946Smrg		# require a kernel.
17768d623946Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17778d623946Smrg		exit 1
17788d623946Smrg		;;
17798d623946Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
17808d623946Smrg		;;
17818d623946Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
17828d623946Smrg		;;
17838d623946Smrg	nto-qnx*)
17848d623946Smrg		;;
17858d623946Smrg	os2-emx)
17868d623946Smrg		;;
17878d623946Smrg	*-eabi* | *-gnueabi*)
17888d623946Smrg		;;
17898d623946Smrg	-*)
17908d623946Smrg		# Blank kernel with real OS is always fine.
17918d623946Smrg		;;
17928d623946Smrg	*-*)
17938d623946Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
17948d623946Smrg		exit 1
17958d623946Smrg		;;
17968d623946Smrgesac
17978d623946Smrg
1798ee3138f1Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1799ee3138f1Smrg# manufacturer.  We pick the logical manufacturer.
18008d623946Smrgcase $vendor in
18018d623946Smrg	unknown)
18028d623946Smrg		case $cpu-$os in
18038d623946Smrg			*-riscix*)
1804ee3138f1Smrg				vendor=acorn
1805ee3138f1Smrg				;;
18068d623946Smrg			*-sunos*)
1807ee3138f1Smrg				vendor=sun
1808ee3138f1Smrg				;;
18098d623946Smrg			*-cnk* | *-aix*)
1810ee3138f1Smrg				vendor=ibm
1811ee3138f1Smrg				;;
18128d623946Smrg			*-beos*)
1813ee3138f1Smrg				vendor=be
1814ee3138f1Smrg				;;
18158d623946Smrg			*-hpux*)
1816ee3138f1Smrg				vendor=hp
1817ee3138f1Smrg				;;
18188d623946Smrg			*-mpeix*)
1819ee3138f1Smrg				vendor=hp
1820ee3138f1Smrg				;;
18218d623946Smrg			*-hiux*)
1822ee3138f1Smrg				vendor=hitachi
1823ee3138f1Smrg				;;
18248d623946Smrg			*-unos*)
1825ee3138f1Smrg				vendor=crds
1826ee3138f1Smrg				;;
18278d623946Smrg			*-dgux*)
1828ee3138f1Smrg				vendor=dg
1829ee3138f1Smrg				;;
18308d623946Smrg			*-luna*)
1831ee3138f1Smrg				vendor=omron
1832ee3138f1Smrg				;;
18338d623946Smrg			*-genix*)
1834ee3138f1Smrg				vendor=ns
1835ee3138f1Smrg				;;
18368d623946Smrg			*-clix*)
18378d623946Smrg				vendor=intergraph
18388d623946Smrg				;;
18398d623946Smrg			*-mvs* | *-opened*)
18408d623946Smrg				vendor=ibm
18418d623946Smrg				;;
18428d623946Smrg			*-os400*)
1843ee3138f1Smrg				vendor=ibm
1844ee3138f1Smrg				;;
18458d623946Smrg			s390-* | s390x-*)
1846ee3138f1Smrg				vendor=ibm
1847ee3138f1Smrg				;;
18488d623946Smrg			*-ptx*)
1849ee3138f1Smrg				vendor=sequent
1850ee3138f1Smrg				;;
18518d623946Smrg			*-tpf*)
1852ee3138f1Smrg				vendor=ibm
1853ee3138f1Smrg				;;
18548d623946Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1855ee3138f1Smrg				vendor=wrs
1856ee3138f1Smrg				;;
18578d623946Smrg			*-aux*)
1858ee3138f1Smrg				vendor=apple
1859ee3138f1Smrg				;;
18608d623946Smrg			*-hms*)
1861ee3138f1Smrg				vendor=hitachi
1862ee3138f1Smrg				;;
18638d623946Smrg			*-mpw* | *-macos*)
1864ee3138f1Smrg				vendor=apple
1865ee3138f1Smrg				;;
18668d623946Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1867ee3138f1Smrg				vendor=atari
1868ee3138f1Smrg				;;
18698d623946Smrg			*-vos*)
1870ee3138f1Smrg				vendor=stratus
1871ee3138f1Smrg				;;
1872ee3138f1Smrg		esac
1873ee3138f1Smrg		;;
1874ee3138f1Smrgesac
1875ee3138f1Smrg
18768d623946Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1877ee3138f1Smrgexit
1878ee3138f1Smrg
1879ee3138f1Smrg# Local variables:
18808d623946Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1881ee3138f1Smrg# time-stamp-start: "timestamp='"
1882ee3138f1Smrg# time-stamp-format: "%:y-%02m-%02d"
1883ee3138f1Smrg# time-stamp-end: "'"
1884ee3138f1Smrg# End:
1885