1ba6a1819Smrg#! /bin/sh
2ba6a1819Smrg# Configuration validation subroutine script.
300ca1914Smrg#   Copyright 1992-2024 Free Software Foundation, Inc.
4ba6a1819Smrg
5da1f2d5dSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6da1f2d5dSmrg
700ca1914Smrgtimestamp='2024-01-01'
8ba6a1819Smrg
91bedbe3fSmrg# This file is free software; you can redistribute it and/or modify it
101bedbe3fSmrg# under the terms of the GNU General Public License as published by
1100ca1914Smrg# the Free Software Foundation, either version 3 of the License, or
12ba6a1819Smrg# (at your option) any later version.
13ba6a1819Smrg#
141bedbe3fSmrg# This program is distributed in the hope that it will be useful, but
151bedbe3fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
161bedbe3fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
171bedbe3fSmrg# General Public License for more details.
18ba6a1819Smrg#
19ba6a1819Smrg# You should have received a copy of the GNU General Public License
20fe4c343aSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21ba6a1819Smrg#
22ba6a1819Smrg# As a special exception to the GNU General Public License, if you
23ba6a1819Smrg# distribute this file as part of a program that contains a
24ba6a1819Smrg# configuration script generated by Autoconf, you may include it under
251bedbe3fSmrg# the same distribution terms that you use for the rest of that
261bedbe3fSmrg# program.  This Exception is an additional permission under section 7
271bedbe3fSmrg# of the GNU General Public License, version 3 ("GPLv3").
28ba6a1819Smrg
29ba6a1819Smrg
30298453a4Smrg# Please send patches to <config-patches@gnu.org>.
31ba6a1819Smrg#
32ba6a1819Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33ba6a1819Smrg# Supply the specified configuration type as an argument.
34ba6a1819Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35ba6a1819Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36ba6a1819Smrg
37549e21daSmrg# You can get the latest version of this script from:
38da1f2d5dSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39549e21daSmrg
40ba6a1819Smrg# This file is supposed to be the same for all GNU packages
41ba6a1819Smrg# and recognize all the CPU types, system types and aliases
42ba6a1819Smrg# that are meaningful with *any* GNU software.
43ba6a1819Smrg# Each package is responsible for reporting which valid configurations
44ba6a1819Smrg# it does not support.  The user should be able to distinguish
45ba6a1819Smrg# a failure to support a valid configuration from a meaningless
46ba6a1819Smrg# configuration.
47ba6a1819Smrg
48ba6a1819Smrg# The goal of this file is to map all the various variations of a given
49ba6a1819Smrg# machine specification into a single specification in the form:
50ba6a1819Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51ba6a1819Smrg# or in some cases, the newer four-part form:
52ba6a1819Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53ba6a1819Smrg# It is wrong to echo any other type of specification.
54ba6a1819Smrg
55da1f2d5dSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
56da1f2d5dSmrg# about features and limitations of the classic Bourne shell that were
57da1f2d5dSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
58da1f2d5dSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59da1f2d5dSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60da1f2d5dSmrg# have a pre-POSIX /bin/sh.
61da1f2d5dSmrg
62ba6a1819Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63ba6a1819Smrg
64ba6a1819Smrgusage="\
65fe4c343aSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66ba6a1819Smrg
67ba6a1819SmrgCanonicalize a configuration name.
68ba6a1819Smrg
69fe4c343aSmrgOptions:
70ba6a1819Smrg  -h, --help         print this help, then exit
71ba6a1819Smrg  -t, --time-stamp   print date of last modification, then exit
72ba6a1819Smrg  -v, --version      print version number, then exit
73ba6a1819Smrg
74ba6a1819SmrgReport bugs and patches to <config-patches@gnu.org>."
75ba6a1819Smrg
76ba6a1819Smrgversion="\
77ba6a1819SmrgGNU config.sub ($timestamp)
78ba6a1819Smrg
7900ca1914SmrgCopyright 1992-2024 Free Software Foundation, Inc.
80ba6a1819Smrg
81ba6a1819SmrgThis is free software; see the source for copying conditions.  There is NO
82ba6a1819Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83ba6a1819Smrg
84ba6a1819Smrghelp="
8500ca1914SmrgTry '$me --help' for more information."
86ba6a1819Smrg
87ba6a1819Smrg# Parse command line
88ba6a1819Smrgwhile test $# -gt 0 ; do
89ba6a1819Smrg  case $1 in
90ba6a1819Smrg    --time-stamp | --time* | -t )
91ba6a1819Smrg       echo "$timestamp" ; exit ;;
92ba6a1819Smrg    --version | -v )
93ba6a1819Smrg       echo "$version" ; exit ;;
94ba6a1819Smrg    --help | --h* | -h )
95ba6a1819Smrg       echo "$usage"; exit ;;
96ba6a1819Smrg    -- )     # Stop option processing
97ba6a1819Smrg       shift; break ;;
98ba6a1819Smrg    - )	# Use stdin as input.
99ba6a1819Smrg       break ;;
100ba6a1819Smrg    -* )
101da1f2d5dSmrg       echo "$me: invalid option $1$help" >&2
102ba6a1819Smrg       exit 1 ;;
103ba6a1819Smrg
104ba6a1819Smrg    *local*)
105ba6a1819Smrg       # First pass through any local machine types.
106fe4c343aSmrg       echo "$1"
107ba6a1819Smrg       exit ;;
108ba6a1819Smrg
109ba6a1819Smrg    * )
110ba6a1819Smrg       break ;;
111ba6a1819Smrg  esac
112ba6a1819Smrgdone
113ba6a1819Smrg
114ba6a1819Smrgcase $# in
115ba6a1819Smrg 0) echo "$me: missing argument$help" >&2
116ba6a1819Smrg    exit 1;;
117ba6a1819Smrg 1) ;;
118ba6a1819Smrg *) echo "$me: too many arguments$help" >&2
119ba6a1819Smrg    exit 1;;
120ba6a1819Smrgesac
121ba6a1819Smrg
122da1f2d5dSmrg# Split fields of configuration type
123da1f2d5dSmrg# shellcheck disable=SC2162
124da1f2d5dSmrgsaved_IFS=$IFS
125da1f2d5dSmrgIFS="-" read field1 field2 field3 field4 <<EOF
126da1f2d5dSmrg$1
127da1f2d5dSmrgEOF
128da1f2d5dSmrgIFS=$saved_IFS
129ba6a1819Smrg
130da1f2d5dSmrg# Separate into logical components for further validation
131da1f2d5dSmrgcase $1 in
132da1f2d5dSmrg	*-*-*-*-*)
13300ca1914Smrg		echo "Invalid configuration '$1': more than four components" >&2
134da1f2d5dSmrg		exit 1
1351bedbe3fSmrg		;;
136da1f2d5dSmrg	*-*-*-*)
137da1f2d5dSmrg		basic_machine=$field1-$field2
138da1f2d5dSmrg		basic_os=$field3-$field4
139ba6a1819Smrg		;;
140da1f2d5dSmrg	*-*-*)
141da1f2d5dSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142da1f2d5dSmrg		# parts
143da1f2d5dSmrg		maybe_os=$field2-$field3
144da1f2d5dSmrg		case $maybe_os in
145da1f2d5dSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
146da1f2d5dSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147da1f2d5dSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14800ca1914Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
14900ca1914Smrg			| windows-* )
150da1f2d5dSmrg				basic_machine=$field1
151da1f2d5dSmrg				basic_os=$maybe_os
152da1f2d5dSmrg				;;
153da1f2d5dSmrg			android-linux)
154da1f2d5dSmrg				basic_machine=$field1-unknown
155da1f2d5dSmrg				basic_os=linux-android
156da1f2d5dSmrg				;;
157da1f2d5dSmrg			*)
158da1f2d5dSmrg				basic_machine=$field1-$field2
159da1f2d5dSmrg				basic_os=$field3
160da1f2d5dSmrg				;;
161da1f2d5dSmrg		esac
162ba6a1819Smrg		;;
163da1f2d5dSmrg	*-*)
164da1f2d5dSmrg		# A lone config we happen to match not fitting any pattern
165da1f2d5dSmrg		case $field1-$field2 in
166da1f2d5dSmrg			decstation-3100)
167da1f2d5dSmrg				basic_machine=mips-dec
168da1f2d5dSmrg				basic_os=
169da1f2d5dSmrg				;;
170da1f2d5dSmrg			*-*)
171da1f2d5dSmrg				# Second component is usually, but not always the OS
172da1f2d5dSmrg				case $field2 in
173da1f2d5dSmrg					# Prevent following clause from handling this valid os
174da1f2d5dSmrg					sun*os*)
175da1f2d5dSmrg						basic_machine=$field1
176da1f2d5dSmrg						basic_os=$field2
177da1f2d5dSmrg						;;
178da1f2d5dSmrg					zephyr*)
179da1f2d5dSmrg						basic_machine=$field1-unknown
180da1f2d5dSmrg						basic_os=$field2
181da1f2d5dSmrg						;;
182da1f2d5dSmrg					# Manufacturers
183da1f2d5dSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
184da1f2d5dSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
185da1f2d5dSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
186da1f2d5dSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
187da1f2d5dSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
188da1f2d5dSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
189da1f2d5dSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
190da1f2d5dSmrg					| microblaze* | sim | cisco \
191da1f2d5dSmrg					| oki | wec | wrs | winbond)
192da1f2d5dSmrg						basic_machine=$field1-$field2
193da1f2d5dSmrg						basic_os=
194da1f2d5dSmrg						;;
195da1f2d5dSmrg					*)
196da1f2d5dSmrg						basic_machine=$field1
197da1f2d5dSmrg						basic_os=$field2
198da1f2d5dSmrg						;;
199da1f2d5dSmrg				esac
200da1f2d5dSmrg			;;
201da1f2d5dSmrg		esac
202ba6a1819Smrg		;;
203da1f2d5dSmrg	*)
204da1f2d5dSmrg		# Convert single-component short-hands not valid as part of
205da1f2d5dSmrg		# multi-component configurations.
206da1f2d5dSmrg		case $field1 in
207da1f2d5dSmrg			386bsd)
208da1f2d5dSmrg				basic_machine=i386-pc
209da1f2d5dSmrg				basic_os=bsd
210da1f2d5dSmrg				;;
211da1f2d5dSmrg			a29khif)
212da1f2d5dSmrg				basic_machine=a29k-amd
213da1f2d5dSmrg				basic_os=udi
214da1f2d5dSmrg				;;
215da1f2d5dSmrg			adobe68k)
216da1f2d5dSmrg				basic_machine=m68010-adobe
217da1f2d5dSmrg				basic_os=scout
218da1f2d5dSmrg				;;
219da1f2d5dSmrg			alliant)
220da1f2d5dSmrg				basic_machine=fx80-alliant
221da1f2d5dSmrg				basic_os=
222da1f2d5dSmrg				;;
223da1f2d5dSmrg			altos | altos3068)
224da1f2d5dSmrg				basic_machine=m68k-altos
225da1f2d5dSmrg				basic_os=
226da1f2d5dSmrg				;;
227da1f2d5dSmrg			am29k)
228da1f2d5dSmrg				basic_machine=a29k-none
229da1f2d5dSmrg				basic_os=bsd
230da1f2d5dSmrg				;;
231da1f2d5dSmrg			amdahl)
232da1f2d5dSmrg				basic_machine=580-amdahl
233da1f2d5dSmrg				basic_os=sysv
234da1f2d5dSmrg				;;
235da1f2d5dSmrg			amiga)
236da1f2d5dSmrg				basic_machine=m68k-unknown
237da1f2d5dSmrg				basic_os=
238da1f2d5dSmrg				;;
239da1f2d5dSmrg			amigaos | amigados)
240da1f2d5dSmrg				basic_machine=m68k-unknown
241da1f2d5dSmrg				basic_os=amigaos
242da1f2d5dSmrg				;;
243da1f2d5dSmrg			amigaunix | amix)
244da1f2d5dSmrg				basic_machine=m68k-unknown
245da1f2d5dSmrg				basic_os=sysv4
246da1f2d5dSmrg				;;
247da1f2d5dSmrg			apollo68)
248da1f2d5dSmrg				basic_machine=m68k-apollo
249da1f2d5dSmrg				basic_os=sysv
250da1f2d5dSmrg				;;
251da1f2d5dSmrg			apollo68bsd)
252da1f2d5dSmrg				basic_machine=m68k-apollo
253da1f2d5dSmrg				basic_os=bsd
254da1f2d5dSmrg				;;
255da1f2d5dSmrg			aros)
256da1f2d5dSmrg				basic_machine=i386-pc
257da1f2d5dSmrg				basic_os=aros
258da1f2d5dSmrg				;;
259da1f2d5dSmrg			aux)
260da1f2d5dSmrg				basic_machine=m68k-apple
261da1f2d5dSmrg				basic_os=aux
262da1f2d5dSmrg				;;
263da1f2d5dSmrg			balance)
264da1f2d5dSmrg				basic_machine=ns32k-sequent
265da1f2d5dSmrg				basic_os=dynix
266da1f2d5dSmrg				;;
267da1f2d5dSmrg			blackfin)
268da1f2d5dSmrg				basic_machine=bfin-unknown
269da1f2d5dSmrg				basic_os=linux
270da1f2d5dSmrg				;;
271da1f2d5dSmrg			cegcc)
272da1f2d5dSmrg				basic_machine=arm-unknown
273da1f2d5dSmrg				basic_os=cegcc
274da1f2d5dSmrg				;;
275da1f2d5dSmrg			convex-c1)
276da1f2d5dSmrg				basic_machine=c1-convex
277da1f2d5dSmrg				basic_os=bsd
278da1f2d5dSmrg				;;
279da1f2d5dSmrg			convex-c2)
280da1f2d5dSmrg				basic_machine=c2-convex
281da1f2d5dSmrg				basic_os=bsd
282da1f2d5dSmrg				;;
283da1f2d5dSmrg			convex-c32)
284da1f2d5dSmrg				basic_machine=c32-convex
285da1f2d5dSmrg				basic_os=bsd
286da1f2d5dSmrg				;;
287da1f2d5dSmrg			convex-c34)
288da1f2d5dSmrg				basic_machine=c34-convex
289da1f2d5dSmrg				basic_os=bsd
290da1f2d5dSmrg				;;
291da1f2d5dSmrg			convex-c38)
292da1f2d5dSmrg				basic_machine=c38-convex
293da1f2d5dSmrg				basic_os=bsd
294da1f2d5dSmrg				;;
295da1f2d5dSmrg			cray)
296da1f2d5dSmrg				basic_machine=j90-cray
297da1f2d5dSmrg				basic_os=unicos
298da1f2d5dSmrg				;;
299da1f2d5dSmrg			crds | unos)
300da1f2d5dSmrg				basic_machine=m68k-crds
301da1f2d5dSmrg				basic_os=
302da1f2d5dSmrg				;;
303da1f2d5dSmrg			da30)
304da1f2d5dSmrg				basic_machine=m68k-da30
305da1f2d5dSmrg				basic_os=
306da1f2d5dSmrg				;;
307da1f2d5dSmrg			decstation | pmax | pmin | dec3100 | decstatn)
308da1f2d5dSmrg				basic_machine=mips-dec
309da1f2d5dSmrg				basic_os=
310da1f2d5dSmrg				;;
311da1f2d5dSmrg			delta88)
312da1f2d5dSmrg				basic_machine=m88k-motorola
313da1f2d5dSmrg				basic_os=sysv3
314da1f2d5dSmrg				;;
315da1f2d5dSmrg			dicos)
316da1f2d5dSmrg				basic_machine=i686-pc
317da1f2d5dSmrg				basic_os=dicos
318da1f2d5dSmrg				;;
319da1f2d5dSmrg			djgpp)
320da1f2d5dSmrg				basic_machine=i586-pc
321da1f2d5dSmrg				basic_os=msdosdjgpp
322da1f2d5dSmrg				;;
323da1f2d5dSmrg			ebmon29k)
324da1f2d5dSmrg				basic_machine=a29k-amd
325da1f2d5dSmrg				basic_os=ebmon
326da1f2d5dSmrg				;;
327da1f2d5dSmrg			es1800 | OSE68k | ose68k | ose | OSE)
328da1f2d5dSmrg				basic_machine=m68k-ericsson
329da1f2d5dSmrg				basic_os=ose
330da1f2d5dSmrg				;;
331da1f2d5dSmrg			gmicro)
332da1f2d5dSmrg				basic_machine=tron-gmicro
333da1f2d5dSmrg				basic_os=sysv
334da1f2d5dSmrg				;;
335da1f2d5dSmrg			go32)
336da1f2d5dSmrg				basic_machine=i386-pc
337da1f2d5dSmrg				basic_os=go32
338da1f2d5dSmrg				;;
339da1f2d5dSmrg			h8300hms)
340da1f2d5dSmrg				basic_machine=h8300-hitachi
341da1f2d5dSmrg				basic_os=hms
342da1f2d5dSmrg				;;
343da1f2d5dSmrg			h8300xray)
344da1f2d5dSmrg				basic_machine=h8300-hitachi
345da1f2d5dSmrg				basic_os=xray
346da1f2d5dSmrg				;;
347da1f2d5dSmrg			h8500hms)
348da1f2d5dSmrg				basic_machine=h8500-hitachi
349da1f2d5dSmrg				basic_os=hms
350da1f2d5dSmrg				;;
351da1f2d5dSmrg			harris)
352da1f2d5dSmrg				basic_machine=m88k-harris
353da1f2d5dSmrg				basic_os=sysv3
354da1f2d5dSmrg				;;
355da1f2d5dSmrg			hp300 | hp300hpux)
356da1f2d5dSmrg				basic_machine=m68k-hp
357da1f2d5dSmrg				basic_os=hpux
358da1f2d5dSmrg				;;
359da1f2d5dSmrg			hp300bsd)
360da1f2d5dSmrg				basic_machine=m68k-hp
361da1f2d5dSmrg				basic_os=bsd
362da1f2d5dSmrg				;;
363da1f2d5dSmrg			hppaosf)
364da1f2d5dSmrg				basic_machine=hppa1.1-hp
365da1f2d5dSmrg				basic_os=osf
366da1f2d5dSmrg				;;
367da1f2d5dSmrg			hppro)
368da1f2d5dSmrg				basic_machine=hppa1.1-hp
369da1f2d5dSmrg				basic_os=proelf
370da1f2d5dSmrg				;;
371da1f2d5dSmrg			i386mach)
372da1f2d5dSmrg				basic_machine=i386-mach
373da1f2d5dSmrg				basic_os=mach
374da1f2d5dSmrg				;;
375da1f2d5dSmrg			isi68 | isi)
376da1f2d5dSmrg				basic_machine=m68k-isi
377da1f2d5dSmrg				basic_os=sysv
378da1f2d5dSmrg				;;
379da1f2d5dSmrg			m68knommu)
380da1f2d5dSmrg				basic_machine=m68k-unknown
381da1f2d5dSmrg				basic_os=linux
382da1f2d5dSmrg				;;
383da1f2d5dSmrg			magnum | m3230)
384da1f2d5dSmrg				basic_machine=mips-mips
385da1f2d5dSmrg				basic_os=sysv
386da1f2d5dSmrg				;;
387da1f2d5dSmrg			merlin)
388da1f2d5dSmrg				basic_machine=ns32k-utek
389da1f2d5dSmrg				basic_os=sysv
390da1f2d5dSmrg				;;
391da1f2d5dSmrg			mingw64)
392da1f2d5dSmrg				basic_machine=x86_64-pc
393da1f2d5dSmrg				basic_os=mingw64
394da1f2d5dSmrg				;;
395da1f2d5dSmrg			mingw32)
396da1f2d5dSmrg				basic_machine=i686-pc
397da1f2d5dSmrg				basic_os=mingw32
398da1f2d5dSmrg				;;
399da1f2d5dSmrg			mingw32ce)
400da1f2d5dSmrg				basic_machine=arm-unknown
401da1f2d5dSmrg				basic_os=mingw32ce
402da1f2d5dSmrg				;;
403da1f2d5dSmrg			monitor)
404da1f2d5dSmrg				basic_machine=m68k-rom68k
405da1f2d5dSmrg				basic_os=coff
406da1f2d5dSmrg				;;
407da1f2d5dSmrg			morphos)
408da1f2d5dSmrg				basic_machine=powerpc-unknown
409da1f2d5dSmrg				basic_os=morphos
410da1f2d5dSmrg				;;
411da1f2d5dSmrg			moxiebox)
412da1f2d5dSmrg				basic_machine=moxie-unknown
413da1f2d5dSmrg				basic_os=moxiebox
414da1f2d5dSmrg				;;
415da1f2d5dSmrg			msdos)
416da1f2d5dSmrg				basic_machine=i386-pc
417da1f2d5dSmrg				basic_os=msdos
418da1f2d5dSmrg				;;
419da1f2d5dSmrg			msys)
420da1f2d5dSmrg				basic_machine=i686-pc
421da1f2d5dSmrg				basic_os=msys
422da1f2d5dSmrg				;;
423da1f2d5dSmrg			mvs)
424da1f2d5dSmrg				basic_machine=i370-ibm
425da1f2d5dSmrg				basic_os=mvs
426da1f2d5dSmrg				;;
427da1f2d5dSmrg			nacl)
428da1f2d5dSmrg				basic_machine=le32-unknown
429da1f2d5dSmrg				basic_os=nacl
430da1f2d5dSmrg				;;
431da1f2d5dSmrg			ncr3000)
432da1f2d5dSmrg				basic_machine=i486-ncr
433da1f2d5dSmrg				basic_os=sysv4
434da1f2d5dSmrg				;;
435da1f2d5dSmrg			netbsd386)
436da1f2d5dSmrg				basic_machine=i386-pc
437da1f2d5dSmrg				basic_os=netbsd
438da1f2d5dSmrg				;;
439da1f2d5dSmrg			netwinder)
440da1f2d5dSmrg				basic_machine=armv4l-rebel
441da1f2d5dSmrg				basic_os=linux
442da1f2d5dSmrg				;;
443da1f2d5dSmrg			news | news700 | news800 | news900)
444da1f2d5dSmrg				basic_machine=m68k-sony
445da1f2d5dSmrg				basic_os=newsos
446da1f2d5dSmrg				;;
447da1f2d5dSmrg			news1000)
448da1f2d5dSmrg				basic_machine=m68030-sony
449da1f2d5dSmrg				basic_os=newsos
450da1f2d5dSmrg				;;
451da1f2d5dSmrg			necv70)
452da1f2d5dSmrg				basic_machine=v70-nec
453da1f2d5dSmrg				basic_os=sysv
454da1f2d5dSmrg				;;
455da1f2d5dSmrg			nh3000)
456da1f2d5dSmrg				basic_machine=m68k-harris
457da1f2d5dSmrg				basic_os=cxux
458da1f2d5dSmrg				;;
459da1f2d5dSmrg			nh[45]000)
460da1f2d5dSmrg				basic_machine=m88k-harris
461da1f2d5dSmrg				basic_os=cxux
462da1f2d5dSmrg				;;
463da1f2d5dSmrg			nindy960)
464da1f2d5dSmrg				basic_machine=i960-intel
465da1f2d5dSmrg				basic_os=nindy
466da1f2d5dSmrg				;;
467da1f2d5dSmrg			mon960)
468da1f2d5dSmrg				basic_machine=i960-intel
469da1f2d5dSmrg				basic_os=mon960
470da1f2d5dSmrg				;;
471da1f2d5dSmrg			nonstopux)
472da1f2d5dSmrg				basic_machine=mips-compaq
473da1f2d5dSmrg				basic_os=nonstopux
474da1f2d5dSmrg				;;
475da1f2d5dSmrg			os400)
476da1f2d5dSmrg				basic_machine=powerpc-ibm
477da1f2d5dSmrg				basic_os=os400
478da1f2d5dSmrg				;;
479da1f2d5dSmrg			OSE68000 | ose68000)
480da1f2d5dSmrg				basic_machine=m68000-ericsson
481da1f2d5dSmrg				basic_os=ose
482da1f2d5dSmrg				;;
483da1f2d5dSmrg			os68k)
484da1f2d5dSmrg				basic_machine=m68k-none
485da1f2d5dSmrg				basic_os=os68k
486da1f2d5dSmrg				;;
487da1f2d5dSmrg			paragon)
488da1f2d5dSmrg				basic_machine=i860-intel
489da1f2d5dSmrg				basic_os=osf
490da1f2d5dSmrg				;;
491da1f2d5dSmrg			parisc)
492da1f2d5dSmrg				basic_machine=hppa-unknown
493da1f2d5dSmrg				basic_os=linux
494da1f2d5dSmrg				;;
495da1f2d5dSmrg			psp)
496da1f2d5dSmrg				basic_machine=mipsallegrexel-sony
497da1f2d5dSmrg				basic_os=psp
498da1f2d5dSmrg				;;
499da1f2d5dSmrg			pw32)
500da1f2d5dSmrg				basic_machine=i586-unknown
501da1f2d5dSmrg				basic_os=pw32
502da1f2d5dSmrg				;;
503da1f2d5dSmrg			rdos | rdos64)
504da1f2d5dSmrg				basic_machine=x86_64-pc
505da1f2d5dSmrg				basic_os=rdos
506da1f2d5dSmrg				;;
507da1f2d5dSmrg			rdos32)
508da1f2d5dSmrg				basic_machine=i386-pc
509da1f2d5dSmrg				basic_os=rdos
510da1f2d5dSmrg				;;
511da1f2d5dSmrg			rom68k)
512da1f2d5dSmrg				basic_machine=m68k-rom68k
513da1f2d5dSmrg				basic_os=coff
514da1f2d5dSmrg				;;
515da1f2d5dSmrg			sa29200)
516da1f2d5dSmrg				basic_machine=a29k-amd
517da1f2d5dSmrg				basic_os=udi
518da1f2d5dSmrg				;;
519da1f2d5dSmrg			sei)
520da1f2d5dSmrg				basic_machine=mips-sei
521da1f2d5dSmrg				basic_os=seiux
522da1f2d5dSmrg				;;
523da1f2d5dSmrg			sequent)
524da1f2d5dSmrg				basic_machine=i386-sequent
525da1f2d5dSmrg				basic_os=
526da1f2d5dSmrg				;;
527da1f2d5dSmrg			sps7)
528da1f2d5dSmrg				basic_machine=m68k-bull
529da1f2d5dSmrg				basic_os=sysv2
530da1f2d5dSmrg				;;
531da1f2d5dSmrg			st2000)
532da1f2d5dSmrg				basic_machine=m68k-tandem
533da1f2d5dSmrg				basic_os=
534da1f2d5dSmrg				;;
535da1f2d5dSmrg			stratus)
536da1f2d5dSmrg				basic_machine=i860-stratus
537da1f2d5dSmrg				basic_os=sysv4
538da1f2d5dSmrg				;;
539da1f2d5dSmrg			sun2)
540da1f2d5dSmrg				basic_machine=m68000-sun
541da1f2d5dSmrg				basic_os=
542da1f2d5dSmrg				;;
543da1f2d5dSmrg			sun2os3)
544da1f2d5dSmrg				basic_machine=m68000-sun
545da1f2d5dSmrg				basic_os=sunos3
546da1f2d5dSmrg				;;
547da1f2d5dSmrg			sun2os4)
548da1f2d5dSmrg				basic_machine=m68000-sun
549da1f2d5dSmrg				basic_os=sunos4
550da1f2d5dSmrg				;;
551da1f2d5dSmrg			sun3)
552da1f2d5dSmrg				basic_machine=m68k-sun
553da1f2d5dSmrg				basic_os=
554da1f2d5dSmrg				;;
555da1f2d5dSmrg			sun3os3)
556da1f2d5dSmrg				basic_machine=m68k-sun
557da1f2d5dSmrg				basic_os=sunos3
558da1f2d5dSmrg				;;
559da1f2d5dSmrg			sun3os4)
560da1f2d5dSmrg				basic_machine=m68k-sun
561da1f2d5dSmrg				basic_os=sunos4
562da1f2d5dSmrg				;;
563da1f2d5dSmrg			sun4)
564da1f2d5dSmrg				basic_machine=sparc-sun
565da1f2d5dSmrg				basic_os=
566da1f2d5dSmrg				;;
567da1f2d5dSmrg			sun4os3)
568da1f2d5dSmrg				basic_machine=sparc-sun
569da1f2d5dSmrg				basic_os=sunos3
570da1f2d5dSmrg				;;
571da1f2d5dSmrg			sun4os4)
572da1f2d5dSmrg				basic_machine=sparc-sun
573da1f2d5dSmrg				basic_os=sunos4
574da1f2d5dSmrg				;;
575da1f2d5dSmrg			sun4sol2)
576da1f2d5dSmrg				basic_machine=sparc-sun
577da1f2d5dSmrg				basic_os=solaris2
578da1f2d5dSmrg				;;
579da1f2d5dSmrg			sun386 | sun386i | roadrunner)
580da1f2d5dSmrg				basic_machine=i386-sun
581da1f2d5dSmrg				basic_os=
582da1f2d5dSmrg				;;
583da1f2d5dSmrg			sv1)
584da1f2d5dSmrg				basic_machine=sv1-cray
585da1f2d5dSmrg				basic_os=unicos
586da1f2d5dSmrg				;;
587da1f2d5dSmrg			symmetry)
588da1f2d5dSmrg				basic_machine=i386-sequent
589da1f2d5dSmrg				basic_os=dynix
590da1f2d5dSmrg				;;
591da1f2d5dSmrg			t3e)
592da1f2d5dSmrg				basic_machine=alphaev5-cray
593da1f2d5dSmrg				basic_os=unicos
594da1f2d5dSmrg				;;
595da1f2d5dSmrg			t90)
596da1f2d5dSmrg				basic_machine=t90-cray
597da1f2d5dSmrg				basic_os=unicos
598da1f2d5dSmrg				;;
599da1f2d5dSmrg			toad1)
600da1f2d5dSmrg				basic_machine=pdp10-xkl
601da1f2d5dSmrg				basic_os=tops20
602da1f2d5dSmrg				;;
603da1f2d5dSmrg			tpf)
604da1f2d5dSmrg				basic_machine=s390x-ibm
605da1f2d5dSmrg				basic_os=tpf
606da1f2d5dSmrg				;;
607da1f2d5dSmrg			udi29k)
608da1f2d5dSmrg				basic_machine=a29k-amd
609da1f2d5dSmrg				basic_os=udi
610da1f2d5dSmrg				;;
611da1f2d5dSmrg			ultra3)
612da1f2d5dSmrg				basic_machine=a29k-nyu
613da1f2d5dSmrg				basic_os=sym1
614da1f2d5dSmrg				;;
615da1f2d5dSmrg			v810 | necv810)
616da1f2d5dSmrg				basic_machine=v810-nec
617da1f2d5dSmrg				basic_os=none
618da1f2d5dSmrg				;;
619da1f2d5dSmrg			vaxv)
620da1f2d5dSmrg				basic_machine=vax-dec
621da1f2d5dSmrg				basic_os=sysv
622da1f2d5dSmrg				;;
623da1f2d5dSmrg			vms)
624da1f2d5dSmrg				basic_machine=vax-dec
625da1f2d5dSmrg				basic_os=vms
626da1f2d5dSmrg				;;
627da1f2d5dSmrg			vsta)
628da1f2d5dSmrg				basic_machine=i386-pc
629da1f2d5dSmrg				basic_os=vsta
630da1f2d5dSmrg				;;
631da1f2d5dSmrg			vxworks960)
632da1f2d5dSmrg				basic_machine=i960-wrs
633da1f2d5dSmrg				basic_os=vxworks
634da1f2d5dSmrg				;;
635da1f2d5dSmrg			vxworks68)
636da1f2d5dSmrg				basic_machine=m68k-wrs
637da1f2d5dSmrg				basic_os=vxworks
638da1f2d5dSmrg				;;
639da1f2d5dSmrg			vxworks29k)
640da1f2d5dSmrg				basic_machine=a29k-wrs
641da1f2d5dSmrg				basic_os=vxworks
642da1f2d5dSmrg				;;
643da1f2d5dSmrg			xbox)
644da1f2d5dSmrg				basic_machine=i686-pc
645da1f2d5dSmrg				basic_os=mingw32
646da1f2d5dSmrg				;;
647da1f2d5dSmrg			ymp)
648da1f2d5dSmrg				basic_machine=ymp-cray
649da1f2d5dSmrg				basic_os=unicos
650da1f2d5dSmrg				;;
651da1f2d5dSmrg			*)
652da1f2d5dSmrg				basic_machine=$1
653da1f2d5dSmrg				basic_os=
654da1f2d5dSmrg				;;
655da1f2d5dSmrg		esac
656ba6a1819Smrg		;;
657ba6a1819Smrgesac
658ba6a1819Smrg
659da1f2d5dSmrg# Decode 1-component or ad-hoc basic machines
660ba6a1819Smrgcase $basic_machine in
661da1f2d5dSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
662da1f2d5dSmrg	# some cases the only manufacturer, in others, it is the most popular.
663da1f2d5dSmrg	w89k)
664da1f2d5dSmrg		cpu=hppa1.1
665da1f2d5dSmrg		vendor=winbond
666298453a4Smrg		;;
667da1f2d5dSmrg	op50n)
668da1f2d5dSmrg		cpu=hppa1.1
669da1f2d5dSmrg		vendor=oki
670ba6a1819Smrg		;;
671da1f2d5dSmrg	op60c)
672da1f2d5dSmrg		cpu=hppa1.1
673da1f2d5dSmrg		vendor=oki
674ba6a1819Smrg		;;
675da1f2d5dSmrg	ibm*)
676da1f2d5dSmrg		cpu=i370
677da1f2d5dSmrg		vendor=ibm
678ba6a1819Smrg		;;
679da1f2d5dSmrg	orion105)
680da1f2d5dSmrg		cpu=clipper
681da1f2d5dSmrg		vendor=highlevel
6821bedbe3fSmrg		;;
683da1f2d5dSmrg	mac | mpw | mac-mpw)
684da1f2d5dSmrg		cpu=m68k
685da1f2d5dSmrg		vendor=apple
6861bedbe3fSmrg		;;
687da1f2d5dSmrg	pmac | pmac-mpw)
688da1f2d5dSmrg		cpu=powerpc
689da1f2d5dSmrg		vendor=apple
6901bedbe3fSmrg		;;
6911bedbe3fSmrg
692ba6a1819Smrg	# Recognize the various machine names and aliases which stand
693ba6a1819Smrg	# for a CPU type and a company and sometimes even an OS.
694ba6a1819Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
695da1f2d5dSmrg		cpu=m68000
696da1f2d5dSmrg		vendor=att
697ba6a1819Smrg		;;
698ba6a1819Smrg	3b*)
699da1f2d5dSmrg		cpu=we32k
700da1f2d5dSmrg		vendor=att
701549e21daSmrg		;;
702549e21daSmrg	bluegene*)
703da1f2d5dSmrg		cpu=powerpc
704da1f2d5dSmrg		vendor=ibm
705da1f2d5dSmrg		basic_os=cnk
706ba6a1819Smrg		;;
707ba6a1819Smrg	decsystem10* | dec10*)
708da1f2d5dSmrg		cpu=pdp10
709da1f2d5dSmrg		vendor=dec
710da1f2d5dSmrg		basic_os=tops10
711ba6a1819Smrg		;;
712ba6a1819Smrg	decsystem20* | dec20*)
713da1f2d5dSmrg		cpu=pdp10
714da1f2d5dSmrg		vendor=dec
715da1f2d5dSmrg		basic_os=tops20
716ba6a1819Smrg		;;
717ba6a1819Smrg	delta | 3300 | motorola-3300 | motorola-delta \
718ba6a1819Smrg	      | 3300-motorola | delta-motorola)
719da1f2d5dSmrg		cpu=m68k
720da1f2d5dSmrg		vendor=motorola
721ba6a1819Smrg		;;
722fe4c343aSmrg	dpx2*)
723da1f2d5dSmrg		cpu=m68k
724da1f2d5dSmrg		vendor=bull
725da1f2d5dSmrg		basic_os=sysv3
726ba6a1819Smrg		;;
727ba6a1819Smrg	encore | umax | mmax)
728da1f2d5dSmrg		cpu=ns32k
729da1f2d5dSmrg		vendor=encore
730ba6a1819Smrg		;;
731da1f2d5dSmrg	elxsi)
732da1f2d5dSmrg		cpu=elxsi
733da1f2d5dSmrg		vendor=elxsi
734da1f2d5dSmrg		basic_os=${basic_os:-bsd}
735ba6a1819Smrg		;;
736ba6a1819Smrg	fx2800)
737da1f2d5dSmrg		cpu=i860
738da1f2d5dSmrg		vendor=alliant
739ba6a1819Smrg		;;
740ba6a1819Smrg	genix)
741da1f2d5dSmrg		cpu=ns32k
742da1f2d5dSmrg		vendor=ns
743ba6a1819Smrg		;;
744ba6a1819Smrg	h3050r* | hiux*)
745da1f2d5dSmrg		cpu=hppa1.1
746da1f2d5dSmrg		vendor=hitachi
747da1f2d5dSmrg		basic_os=hiuxwe2
748ba6a1819Smrg		;;
749ba6a1819Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
750da1f2d5dSmrg		cpu=hppa1.0
751da1f2d5dSmrg		vendor=hp
752ba6a1819Smrg		;;
753ba6a1819Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
754da1f2d5dSmrg		cpu=m68000
755da1f2d5dSmrg		vendor=hp
756ba6a1819Smrg		;;
757ba6a1819Smrg	hp9k3[2-9][0-9])
758da1f2d5dSmrg		cpu=m68k
759da1f2d5dSmrg		vendor=hp
760ba6a1819Smrg		;;
761ba6a1819Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
762da1f2d5dSmrg		cpu=hppa1.0
763da1f2d5dSmrg		vendor=hp
764ba6a1819Smrg		;;
765ba6a1819Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
766da1f2d5dSmrg		cpu=hppa1.1
767da1f2d5dSmrg		vendor=hp
768ba6a1819Smrg		;;
769ba6a1819Smrg	hp9k78[0-9] | hp78[0-9])
770ba6a1819Smrg		# FIXME: really hppa2.0-hp
771da1f2d5dSmrg		cpu=hppa1.1
772da1f2d5dSmrg		vendor=hp
773ba6a1819Smrg		;;
774ba6a1819Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
775ba6a1819Smrg		# FIXME: really hppa2.0-hp
776da1f2d5dSmrg		cpu=hppa1.1
777da1f2d5dSmrg		vendor=hp
778ba6a1819Smrg		;;
779ba6a1819Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
780da1f2d5dSmrg		cpu=hppa1.1
781da1f2d5dSmrg		vendor=hp
782ba6a1819Smrg		;;
783ba6a1819Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
784da1f2d5dSmrg		cpu=hppa1.0
785da1f2d5dSmrg		vendor=hp
786ba6a1819Smrg		;;
787ba6a1819Smrg	i*86v32)
788da1f2d5dSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
789da1f2d5dSmrg		vendor=pc
790da1f2d5dSmrg		basic_os=sysv32
791ba6a1819Smrg		;;
792ba6a1819Smrg	i*86v4*)
793da1f2d5dSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
794da1f2d5dSmrg		vendor=pc
795da1f2d5dSmrg		basic_os=sysv4
796ba6a1819Smrg		;;
797ba6a1819Smrg	i*86v)
798da1f2d5dSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
799da1f2d5dSmrg		vendor=pc
800da1f2d5dSmrg		basic_os=sysv
801ba6a1819Smrg		;;
802ba6a1819Smrg	i*86sol2)
803da1f2d5dSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
804da1f2d5dSmrg		vendor=pc
805da1f2d5dSmrg		basic_os=solaris2
806ba6a1819Smrg		;;
807da1f2d5dSmrg	j90 | j90-cray)
808da1f2d5dSmrg		cpu=j90
809da1f2d5dSmrg		vendor=cray
810da1f2d5dSmrg		basic_os=${basic_os:-unicos}
811ba6a1819Smrg		;;
812ba6a1819Smrg	iris | iris4d)
813da1f2d5dSmrg		cpu=mips
814da1f2d5dSmrg		vendor=sgi
815da1f2d5dSmrg		case $basic_os in
816da1f2d5dSmrg		    irix*)
817ba6a1819Smrg			;;
818ba6a1819Smrg		    *)
819da1f2d5dSmrg			basic_os=irix4
820ba6a1819Smrg			;;
821ba6a1819Smrg		esac
822ba6a1819Smrg		;;
823ba6a1819Smrg	miniframe)
824da1f2d5dSmrg		cpu=m68000
825da1f2d5dSmrg		vendor=convergent
826ba6a1819Smrg		;;
827da1f2d5dSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
828da1f2d5dSmrg		cpu=m68k
829da1f2d5dSmrg		vendor=atari
830da1f2d5dSmrg		basic_os=mint
831ba6a1819Smrg		;;
832ba6a1819Smrg	news-3600 | risc-news)
833da1f2d5dSmrg		cpu=mips
834da1f2d5dSmrg		vendor=sony
835da1f2d5dSmrg		basic_os=newsos
836ba6a1819Smrg		;;
837fe4c343aSmrg	next | m*-next)
838da1f2d5dSmrg		cpu=m68k
839da1f2d5dSmrg		vendor=next
840da1f2d5dSmrg		case $basic_os in
841da1f2d5dSmrg		    openstep*)
842da1f2d5dSmrg		        ;;
843da1f2d5dSmrg		    nextstep*)
844ba6a1819Smrg			;;
845da1f2d5dSmrg		    ns2*)
846da1f2d5dSmrg		      basic_os=nextstep2
847ba6a1819Smrg			;;
848ba6a1819Smrg		    *)
849da1f2d5dSmrg		      basic_os=nextstep3
850ba6a1819Smrg			;;
851ba6a1819Smrg		esac
852ba6a1819Smrg		;;
853ba6a1819Smrg	np1)
854da1f2d5dSmrg		cpu=np1
855da1f2d5dSmrg		vendor=gould
856fe4c343aSmrg		;;
857ba6a1819Smrg	op50n-* | op60c-*)
858da1f2d5dSmrg		cpu=hppa1.1
859da1f2d5dSmrg		vendor=oki
860da1f2d5dSmrg		basic_os=proelf
861ba6a1819Smrg		;;
862ba6a1819Smrg	pa-hitachi)
863da1f2d5dSmrg		cpu=hppa1.1
864da1f2d5dSmrg		vendor=hitachi
865da1f2d5dSmrg		basic_os=hiuxwe2
866549e21daSmrg		;;
867ba6a1819Smrg	pbd)
868da1f2d5dSmrg		cpu=sparc
869da1f2d5dSmrg		vendor=tti
870ba6a1819Smrg		;;
871ba6a1819Smrg	pbb)
872da1f2d5dSmrg		cpu=m68k
873da1f2d5dSmrg		vendor=tti
874ba6a1819Smrg		;;
875da1f2d5dSmrg	pc532)
876da1f2d5dSmrg		cpu=ns32k
877da1f2d5dSmrg		vendor=pc532
878ba6a1819Smrg		;;
879ba6a1819Smrg	pn)
880da1f2d5dSmrg		cpu=pn
881da1f2d5dSmrg		vendor=gould
882ba6a1819Smrg		;;
883da1f2d5dSmrg	power)
884da1f2d5dSmrg		cpu=power
885da1f2d5dSmrg		vendor=ibm
886ba6a1819Smrg		;;
887da1f2d5dSmrg	ps2)
888da1f2d5dSmrg		cpu=i386
889da1f2d5dSmrg		vendor=ibm
890ba6a1819Smrg		;;
891da1f2d5dSmrg	rm[46]00)
892da1f2d5dSmrg		cpu=mips
893da1f2d5dSmrg		vendor=siemens
894ba6a1819Smrg		;;
895da1f2d5dSmrg	rtpc | rtpc-*)
896da1f2d5dSmrg		cpu=romp
897da1f2d5dSmrg		vendor=ibm
898ba6a1819Smrg		;;
899da1f2d5dSmrg	sde)
900da1f2d5dSmrg		cpu=mipsisa32
901da1f2d5dSmrg		vendor=sde
902da1f2d5dSmrg		basic_os=${basic_os:-elf}
903ba6a1819Smrg		;;
904da1f2d5dSmrg	simso-wrs)
905da1f2d5dSmrg		cpu=sparclite
906da1f2d5dSmrg		vendor=wrs
907da1f2d5dSmrg		basic_os=vxworks
908ba6a1819Smrg		;;
909da1f2d5dSmrg	tower | tower-32)
910da1f2d5dSmrg		cpu=m68k
911da1f2d5dSmrg		vendor=ncr
912ba6a1819Smrg		;;
913da1f2d5dSmrg	vpp*|vx|vx-*)
914da1f2d5dSmrg		cpu=f301
915da1f2d5dSmrg		vendor=fujitsu
9161bedbe3fSmrg		;;
917da1f2d5dSmrg	w65)
918da1f2d5dSmrg		cpu=w65
919da1f2d5dSmrg		vendor=wdc
920ba6a1819Smrg		;;
921da1f2d5dSmrg	w89k-*)
922da1f2d5dSmrg		cpu=hppa1.1
923da1f2d5dSmrg		vendor=winbond
924da1f2d5dSmrg		basic_os=proelf
925ba6a1819Smrg		;;
926da1f2d5dSmrg	none)
927da1f2d5dSmrg		cpu=none
928da1f2d5dSmrg		vendor=none
929ba6a1819Smrg		;;
930da1f2d5dSmrg	leon|leon[3-9])
931da1f2d5dSmrg		cpu=sparc
932da1f2d5dSmrg		vendor=$basic_machine
933ba6a1819Smrg		;;
934da1f2d5dSmrg	leon-*|leon[3-9]-*)
935da1f2d5dSmrg		cpu=sparc
936da1f2d5dSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
937ba6a1819Smrg		;;
938da1f2d5dSmrg
939da1f2d5dSmrg	*-*)
940da1f2d5dSmrg		# shellcheck disable=SC2162
941da1f2d5dSmrg		saved_IFS=$IFS
942da1f2d5dSmrg		IFS="-" read cpu vendor <<EOF
943da1f2d5dSmrg$basic_machine
944da1f2d5dSmrgEOF
945da1f2d5dSmrg		IFS=$saved_IFS
946ba6a1819Smrg		;;
94700ca1914Smrg	# We use 'pc' rather than 'unknown'
948da1f2d5dSmrg	# because (1) that's what they normally are, and
949da1f2d5dSmrg	# (2) the word "unknown" tends to confuse beginning users.
950da1f2d5dSmrg	i*86 | x86_64)
951da1f2d5dSmrg		cpu=$basic_machine
952da1f2d5dSmrg		vendor=pc
953ba6a1819Smrg		;;
954da1f2d5dSmrg	# These rules are duplicated from below for sake of the special case above;
955da1f2d5dSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
956da1f2d5dSmrg	pc98)
957da1f2d5dSmrg		cpu=i386
958da1f2d5dSmrg		vendor=pc
959ba6a1819Smrg		;;
960da1f2d5dSmrg	x64 | amd64)
961da1f2d5dSmrg		cpu=x86_64
962da1f2d5dSmrg		vendor=pc
963ba6a1819Smrg		;;
964da1f2d5dSmrg	# Recognize the basic CPU types without company name.
965da1f2d5dSmrg	*)
966da1f2d5dSmrg		cpu=$basic_machine
967da1f2d5dSmrg		vendor=unknown
968549e21daSmrg		;;
969da1f2d5dSmrgesac
970da1f2d5dSmrg
971da1f2d5dSmrgunset -v basic_machine
972da1f2d5dSmrg
973da1f2d5dSmrg# Decode basic machines in the full and proper CPU-Company form.
974da1f2d5dSmrgcase $cpu-$vendor in
975da1f2d5dSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
976da1f2d5dSmrg	# some cases the only manufacturer, in others, it is the most popular.
977da1f2d5dSmrg	craynv-unknown)
978da1f2d5dSmrg		vendor=cray
979da1f2d5dSmrg		basic_os=${basic_os:-unicosmp}
980ba6a1819Smrg		;;
981da1f2d5dSmrg	c90-unknown | c90-cray)
982da1f2d5dSmrg		vendor=cray
983da1f2d5dSmrg		basic_os=${Basic_os:-unicos}
984ba6a1819Smrg		;;
985da1f2d5dSmrg	fx80-unknown)
986da1f2d5dSmrg		vendor=alliant
987549e21daSmrg		;;
988da1f2d5dSmrg	romp-unknown)
989da1f2d5dSmrg		vendor=ibm
990ba6a1819Smrg		;;
991da1f2d5dSmrg	mmix-unknown)
992da1f2d5dSmrg		vendor=knuth
993ba6a1819Smrg		;;
994da1f2d5dSmrg	microblaze-unknown | microblazeel-unknown)
995da1f2d5dSmrg		vendor=xilinx
996ba6a1819Smrg		;;
997da1f2d5dSmrg	rs6000-unknown)
998da1f2d5dSmrg		vendor=ibm
999ba6a1819Smrg		;;
1000da1f2d5dSmrg	vax-unknown)
1001da1f2d5dSmrg		vendor=dec
1002ba6a1819Smrg		;;
1003da1f2d5dSmrg	pdp11-unknown)
1004da1f2d5dSmrg		vendor=dec
10051bedbe3fSmrg		;;
1006da1f2d5dSmrg	we32k-unknown)
1007da1f2d5dSmrg		vendor=att
1008ba6a1819Smrg		;;
1009da1f2d5dSmrg	cydra-unknown)
1010da1f2d5dSmrg		vendor=cydrome
1011ba6a1819Smrg		;;
1012da1f2d5dSmrg	i370-ibm*)
1013da1f2d5dSmrg		vendor=ibm
1014ba6a1819Smrg		;;
1015da1f2d5dSmrg	orion-unknown)
1016da1f2d5dSmrg		vendor=highlevel
1017ba6a1819Smrg		;;
1018da1f2d5dSmrg	xps-unknown | xps100-unknown)
1019da1f2d5dSmrg		cpu=xps100
1020da1f2d5dSmrg		vendor=honeywell
1021ba6a1819Smrg		;;
1022da1f2d5dSmrg
1023da1f2d5dSmrg	# Here we normalize CPU types with a missing or matching vendor
102400ca1914Smrg	armh-unknown | armh-alt)
102500ca1914Smrg		cpu=armv7l
102600ca1914Smrg		vendor=alt
102700ca1914Smrg		basic_os=${basic_os:-linux-gnueabihf}
102800ca1914Smrg		;;
1029da1f2d5dSmrg	dpx20-unknown | dpx20-bull)
1030da1f2d5dSmrg		cpu=rs6000
1031da1f2d5dSmrg		vendor=bull
1032da1f2d5dSmrg		basic_os=${basic_os:-bosx}
1033ba6a1819Smrg		;;
1034da1f2d5dSmrg
1035da1f2d5dSmrg	# Here we normalize CPU types irrespective of the vendor
1036da1f2d5dSmrg	amd64-*)
1037da1f2d5dSmrg		cpu=x86_64
1038ba6a1819Smrg		;;
1039da1f2d5dSmrg	blackfin-*)
1040da1f2d5dSmrg		cpu=bfin
1041da1f2d5dSmrg		basic_os=linux
1042ba6a1819Smrg		;;
1043da1f2d5dSmrg	c54x-*)
1044da1f2d5dSmrg		cpu=tic54x
1045ba6a1819Smrg		;;
1046da1f2d5dSmrg	c55x-*)
1047da1f2d5dSmrg		cpu=tic55x
1048ba6a1819Smrg		;;
1049da1f2d5dSmrg	c6x-*)
1050da1f2d5dSmrg		cpu=tic6x
1051ba6a1819Smrg		;;
1052da1f2d5dSmrg	e500v[12]-*)
1053da1f2d5dSmrg		cpu=powerpc
1054da1f2d5dSmrg		basic_os=${basic_os}"spe"
1055ba6a1819Smrg		;;
1056da1f2d5dSmrg	mips3*-*)
1057da1f2d5dSmrg		cpu=mips64
1058ba6a1819Smrg		;;
1059da1f2d5dSmrg	ms1-*)
1060da1f2d5dSmrg		cpu=mt
1061ba6a1819Smrg		;;
1062da1f2d5dSmrg	m68knommu-*)
1063da1f2d5dSmrg		cpu=m68k
1064da1f2d5dSmrg		basic_os=linux
1065ba6a1819Smrg		;;
1066da1f2d5dSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1067da1f2d5dSmrg		cpu=s12z
1068ba6a1819Smrg		;;
1069da1f2d5dSmrg	openrisc-*)
1070da1f2d5dSmrg		cpu=or32
1071ba6a1819Smrg		;;
1072da1f2d5dSmrg	parisc-*)
1073da1f2d5dSmrg		cpu=hppa
1074da1f2d5dSmrg		basic_os=linux
1075ba6a1819Smrg		;;
1076da1f2d5dSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1077da1f2d5dSmrg		cpu=i586
1078ba6a1819Smrg		;;
107900ca1914Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1080da1f2d5dSmrg		cpu=i686
1081ba6a1819Smrg		;;
1082da1f2d5dSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1083da1f2d5dSmrg		cpu=i686
1084ba6a1819Smrg		;;
1085da1f2d5dSmrg	pentium4-*)
1086da1f2d5dSmrg		cpu=i786
1087ba6a1819Smrg		;;
1088da1f2d5dSmrg	pc98-*)
1089da1f2d5dSmrg		cpu=i386
1090ba6a1819Smrg		;;
1091da1f2d5dSmrg	ppc-* | ppcbe-*)
1092da1f2d5dSmrg		cpu=powerpc
1093ba6a1819Smrg		;;
1094da1f2d5dSmrg	ppcle-* | powerpclittle-*)
1095da1f2d5dSmrg		cpu=powerpcle
1096ba6a1819Smrg		;;
1097da1f2d5dSmrg	ppc64-*)
1098da1f2d5dSmrg		cpu=powerpc64
1099ba6a1819Smrg		;;
1100da1f2d5dSmrg	ppc64le-* | powerpc64little-*)
1101da1f2d5dSmrg		cpu=powerpc64le
1102ba6a1819Smrg		;;
1103da1f2d5dSmrg	sb1-*)
1104da1f2d5dSmrg		cpu=mipsisa64sb1
1105ba6a1819Smrg		;;
1106da1f2d5dSmrg	sb1el-*)
1107da1f2d5dSmrg		cpu=mipsisa64sb1el
1108ba6a1819Smrg		;;
1109da1f2d5dSmrg	sh5e[lb]-*)
1110da1f2d5dSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1111ba6a1819Smrg		;;
1112da1f2d5dSmrg	spur-*)
1113da1f2d5dSmrg		cpu=spur
1114ba6a1819Smrg		;;
1115da1f2d5dSmrg	strongarm-* | thumb-*)
1116da1f2d5dSmrg		cpu=arm
1117ba6a1819Smrg		;;
1118da1f2d5dSmrg	tx39-*)
1119da1f2d5dSmrg		cpu=mipstx39
1120fe4c343aSmrg		;;
1121da1f2d5dSmrg	tx39el-*)
1122da1f2d5dSmrg		cpu=mipstx39el
1123ba6a1819Smrg		;;
1124da1f2d5dSmrg	x64-*)
1125da1f2d5dSmrg		cpu=x86_64
1126ba6a1819Smrg		;;
11271bedbe3fSmrg	xscale-* | xscalee[bl]-*)
1128da1f2d5dSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1129ba6a1819Smrg		;;
113000ca1914Smrg	arm64-* | aarch64le-*)
1131da1f2d5dSmrg		cpu=aarch64
1132ba6a1819Smrg		;;
1133ba6a1819Smrg
1134da1f2d5dSmrg	# Recognize the canonical CPU Types that limit and/or modify the
1135da1f2d5dSmrg	# company names they are paired with.
1136da1f2d5dSmrg	cr16-*)
1137da1f2d5dSmrg		basic_os=${basic_os:-elf}
1138ba6a1819Smrg		;;
1139da1f2d5dSmrg	crisv32-* | etraxfs*-*)
1140da1f2d5dSmrg		cpu=crisv32
1141da1f2d5dSmrg		vendor=axis
1142ba6a1819Smrg		;;
1143da1f2d5dSmrg	cris-* | etrax*-*)
1144da1f2d5dSmrg		cpu=cris
1145da1f2d5dSmrg		vendor=axis
1146ba6a1819Smrg		;;
1147da1f2d5dSmrg	crx-*)
1148da1f2d5dSmrg		basic_os=${basic_os:-elf}
1149ba6a1819Smrg		;;
1150da1f2d5dSmrg	neo-tandem)
1151da1f2d5dSmrg		cpu=neo
1152da1f2d5dSmrg		vendor=tandem
1153ba6a1819Smrg		;;
1154da1f2d5dSmrg	nse-tandem)
1155da1f2d5dSmrg		cpu=nse
1156da1f2d5dSmrg		vendor=tandem
1157ba6a1819Smrg		;;
1158da1f2d5dSmrg	nsr-tandem)
1159da1f2d5dSmrg		cpu=nsr
1160da1f2d5dSmrg		vendor=tandem
1161ba6a1819Smrg		;;
1162da1f2d5dSmrg	nsv-tandem)
1163da1f2d5dSmrg		cpu=nsv
1164da1f2d5dSmrg		vendor=tandem
1165ba6a1819Smrg		;;
1166da1f2d5dSmrg	nsx-tandem)
1167da1f2d5dSmrg		cpu=nsx
1168da1f2d5dSmrg		vendor=tandem
1169ba6a1819Smrg		;;
1170da1f2d5dSmrg	mipsallegrexel-sony)
1171da1f2d5dSmrg		cpu=mipsallegrexel
1172da1f2d5dSmrg		vendor=sony
1173ba6a1819Smrg		;;
1174da1f2d5dSmrg	tile*-*)
1175da1f2d5dSmrg		basic_os=${basic_os:-linux-gnu}
1176ba6a1819Smrg		;;
1177da1f2d5dSmrg
1178ba6a1819Smrg	*)
1179da1f2d5dSmrg		# Recognize the canonical CPU types that are allowed with any
1180da1f2d5dSmrg		# company name.
1181da1f2d5dSmrg		case $cpu in
1182da1f2d5dSmrg			1750a | 580 \
1183da1f2d5dSmrg			| a29k \
118400ca1914Smrg			| aarch64 | aarch64_be | aarch64c | arm64ec \
1185da1f2d5dSmrg			| abacus \
1186da1f2d5dSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1187da1f2d5dSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1188da1f2d5dSmrg			| alphapca5[67] | alpha64pca5[67] \
1189da1f2d5dSmrg			| am33_2.0 \
1190da1f2d5dSmrg			| amdgcn \
1191da1f2d5dSmrg			| arc | arceb | arc32 | arc64 \
1192da1f2d5dSmrg			| arm | arm[lb]e | arme[lb] | armv* \
1193da1f2d5dSmrg			| avr | avr32 \
1194da1f2d5dSmrg			| asmjs \
1195da1f2d5dSmrg			| ba \
1196da1f2d5dSmrg			| be32 | be64 \
1197da1f2d5dSmrg			| bfin | bpf | bs2000 \
1198da1f2d5dSmrg			| c[123]* | c30 | [cjt]90 | c4x \
1199da1f2d5dSmrg			| c8051 | clipper | craynv | csky | cydra \
1200da1f2d5dSmrg			| d10v | d30v | dlx | dsp16xx \
1201da1f2d5dSmrg			| e2k | elxsi | epiphany \
1202da1f2d5dSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
120300ca1914Smrg			| javascript \
1204da1f2d5dSmrg			| h8300 | h8500 \
1205da1f2d5dSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1206da1f2d5dSmrg			| hexagon \
1207da1f2d5dSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1208da1f2d5dSmrg			| ip2k | iq2000 \
1209da1f2d5dSmrg			| k1om \
121000ca1914Smrg			| kvx \
1211da1f2d5dSmrg			| le32 | le64 \
1212da1f2d5dSmrg			| lm32 \
121300ca1914Smrg			| loongarch32 | loongarch64 \
1214da1f2d5dSmrg			| m32c | m32r | m32rle \
1215da1f2d5dSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1216da1f2d5dSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1217da1f2d5dSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1218da1f2d5dSmrg			| microblaze | microblazeel \
121900ca1914Smrg			| mips* \
1220da1f2d5dSmrg			| mmix \
1221da1f2d5dSmrg			| mn10200 | mn10300 \
1222da1f2d5dSmrg			| moxie \
1223da1f2d5dSmrg			| mt \
1224da1f2d5dSmrg			| msp430 \
122500ca1914Smrg			| nanomips* \
1226da1f2d5dSmrg			| nds32 | nds32le | nds32be \
1227da1f2d5dSmrg			| nfp \
1228da1f2d5dSmrg			| nios | nios2 | nios2eb | nios2el \
1229da1f2d5dSmrg			| none | np1 | ns16k | ns32k | nvptx \
1230da1f2d5dSmrg			| open8 \
1231da1f2d5dSmrg			| or1k* \
1232da1f2d5dSmrg			| or32 \
1233da1f2d5dSmrg			| orion \
1234da1f2d5dSmrg			| picochip \
1235da1f2d5dSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1236da1f2d5dSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1237da1f2d5dSmrg			| pru \
1238da1f2d5dSmrg			| pyramid \
1239da1f2d5dSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1240da1f2d5dSmrg			| rl78 | romp | rs6000 | rx \
1241da1f2d5dSmrg			| s390 | s390x \
1242da1f2d5dSmrg			| score \
1243da1f2d5dSmrg			| sh | shl \
1244da1f2d5dSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1245da1f2d5dSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1246da1f2d5dSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1247da1f2d5dSmrg			| sparclite \
1248da1f2d5dSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1249da1f2d5dSmrg			| spu \
1250da1f2d5dSmrg			| tahoe \
1251da1f2d5dSmrg			| thumbv7* \
1252da1f2d5dSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1253da1f2d5dSmrg			| tron \
1254da1f2d5dSmrg			| ubicom32 \
1255da1f2d5dSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1256da1f2d5dSmrg			| vax \
125700ca1914Smrg			| vc4 \
1258da1f2d5dSmrg			| visium \
1259da1f2d5dSmrg			| w65 \
1260da1f2d5dSmrg			| wasm32 | wasm64 \
1261da1f2d5dSmrg			| we32k \
1262da1f2d5dSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1263da1f2d5dSmrg			| xstormy16 | xtensa* \
1264da1f2d5dSmrg			| ymp \
1265da1f2d5dSmrg			| z8k | z80)
1266da1f2d5dSmrg				;;
1267da1f2d5dSmrg
1268da1f2d5dSmrg			*)
126900ca1914Smrg				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1270da1f2d5dSmrg				exit 1
1271da1f2d5dSmrg				;;
1272da1f2d5dSmrg		esac
1273ba6a1819Smrg		;;
1274ba6a1819Smrgesac
1275ba6a1819Smrg
1276ba6a1819Smrg# Here we canonicalize certain aliases for manufacturers.
1277da1f2d5dSmrgcase $vendor in
1278da1f2d5dSmrg	digital*)
1279da1f2d5dSmrg		vendor=dec
1280ba6a1819Smrg		;;
1281da1f2d5dSmrg	commodore*)
1282da1f2d5dSmrg		vendor=cbm
1283ba6a1819Smrg		;;
1284ba6a1819Smrg	*)
1285ba6a1819Smrg		;;
1286ba6a1819Smrgesac
1287ba6a1819Smrg
1288ba6a1819Smrg# Decode manufacturer-specific aliases for certain operating systems.
1289ba6a1819Smrg
129000ca1914Smrgif test x"$basic_os" != x
1291ba6a1819Smrgthen
1292da1f2d5dSmrg
129300ca1914Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1294da1f2d5dSmrg# set os.
129500ca1914Smrgobj=
1296da1f2d5dSmrgcase $basic_os in
1297da1f2d5dSmrg	gnu/linux*)
1298da1f2d5dSmrg		kernel=linux
1299da1f2d5dSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1300da1f2d5dSmrg		;;
1301da1f2d5dSmrg	os2-emx)
1302da1f2d5dSmrg		kernel=os2
1303da1f2d5dSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1304da1f2d5dSmrg		;;
1305da1f2d5dSmrg	nto-qnx*)
1306da1f2d5dSmrg		kernel=nto
1307da1f2d5dSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1308da1f2d5dSmrg		;;
1309da1f2d5dSmrg	*-*)
1310da1f2d5dSmrg		# shellcheck disable=SC2162
1311da1f2d5dSmrg		saved_IFS=$IFS
1312da1f2d5dSmrg		IFS="-" read kernel os <<EOF
1313da1f2d5dSmrg$basic_os
1314da1f2d5dSmrgEOF
1315da1f2d5dSmrg		IFS=$saved_IFS
1316da1f2d5dSmrg		;;
1317da1f2d5dSmrg	# Default OS when just kernel was specified
1318da1f2d5dSmrg	nto*)
1319da1f2d5dSmrg		kernel=nto
1320da1f2d5dSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1321da1f2d5dSmrg		;;
1322da1f2d5dSmrg	linux*)
1323da1f2d5dSmrg		kernel=linux
1324da1f2d5dSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1325da1f2d5dSmrg		;;
132600ca1914Smrg	managarm*)
132700ca1914Smrg		kernel=managarm
132800ca1914Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
132900ca1914Smrg		;;
1330da1f2d5dSmrg	*)
1331da1f2d5dSmrg		kernel=
1332da1f2d5dSmrg		os=$basic_os
1333da1f2d5dSmrg		;;
1334da1f2d5dSmrgesac
1335da1f2d5dSmrg
1336da1f2d5dSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1337da1f2d5dSmrg# etc.)
1338ba6a1819Smrgcase $os in
1339fe4c343aSmrg	# First match some system type aliases that might get confused
1340fe4c343aSmrg	# with valid system types.
1341da1f2d5dSmrg	# solaris* is a basic system type, with this one exception.
1342da1f2d5dSmrg	auroraux)
1343da1f2d5dSmrg		os=auroraux
1344549e21daSmrg		;;
1345da1f2d5dSmrg	bluegene*)
1346da1f2d5dSmrg		os=cnk
1347ba6a1819Smrg		;;
1348da1f2d5dSmrg	solaris1 | solaris1.*)
1349da1f2d5dSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1350ba6a1819Smrg		;;
1351da1f2d5dSmrg	solaris)
1352da1f2d5dSmrg		os=solaris2
1353ba6a1819Smrg		;;
1354da1f2d5dSmrg	unixware*)
1355da1f2d5dSmrg		os=sysv4.2uw
1356ba6a1819Smrg		;;
1357fe4c343aSmrg	# es1800 is here to avoid being matched by es* (a different OS)
1358da1f2d5dSmrg	es1800*)
1359da1f2d5dSmrg		os=ose
1360fe4c343aSmrg		;;
1361da1f2d5dSmrg	# Some version numbers need modification
1362da1f2d5dSmrg	chorusos*)
1363da1f2d5dSmrg		os=chorusos
1364ba6a1819Smrg		;;
1365da1f2d5dSmrg	isc)
1366da1f2d5dSmrg		os=isc2.2
1367ba6a1819Smrg		;;
1368da1f2d5dSmrg	sco6)
1369da1f2d5dSmrg		os=sco5v6
1370ba6a1819Smrg		;;
1371da1f2d5dSmrg	sco5)
1372da1f2d5dSmrg		os=sco3.2v5
1373ba6a1819Smrg		;;
1374da1f2d5dSmrg	sco4)
1375da1f2d5dSmrg		os=sco3.2v4
1376ba6a1819Smrg		;;
1377da1f2d5dSmrg	sco3.2.[4-9]*)
1378da1f2d5dSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1379ba6a1819Smrg		;;
1380da1f2d5dSmrg	sco*v* | scout)
1381da1f2d5dSmrg		# Don't match below
1382ba6a1819Smrg		;;
1383da1f2d5dSmrg	sco*)
1384da1f2d5dSmrg		os=sco3.2v2
1385ba6a1819Smrg		;;
1386da1f2d5dSmrg	psos*)
1387da1f2d5dSmrg		os=psos
1388ba6a1819Smrg		;;
1389da1f2d5dSmrg	qnx*)
1390da1f2d5dSmrg		os=qnx
1391ba6a1819Smrg		;;
1392da1f2d5dSmrg	hiux*)
1393da1f2d5dSmrg		os=hiuxwe2
1394ba6a1819Smrg		;;
1395da1f2d5dSmrg	lynx*178)
1396da1f2d5dSmrg		os=lynxos178
1397ba6a1819Smrg		;;
1398da1f2d5dSmrg	lynx*5)
1399da1f2d5dSmrg		os=lynxos5
1400ba6a1819Smrg		;;
1401da1f2d5dSmrg	lynxos*)
1402da1f2d5dSmrg		# don't get caught up in next wildcard
1403ba6a1819Smrg		;;
1404da1f2d5dSmrg	lynx*)
1405da1f2d5dSmrg		os=lynxos
1406ba6a1819Smrg		;;
1407da1f2d5dSmrg	mac[0-9]*)
1408da1f2d5dSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1409ba6a1819Smrg		;;
1410da1f2d5dSmrg	opened*)
1411da1f2d5dSmrg		os=openedition
1412ba6a1819Smrg		;;
1413da1f2d5dSmrg	os400*)
1414da1f2d5dSmrg		os=os400
1415ba6a1819Smrg		;;
1416da1f2d5dSmrg	sunos5*)
1417da1f2d5dSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1418ba6a1819Smrg		;;
1419da1f2d5dSmrg	sunos6*)
1420da1f2d5dSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1421ba6a1819Smrg		;;
1422da1f2d5dSmrg	wince*)
1423da1f2d5dSmrg		os=wince
1424ba6a1819Smrg		;;
1425da1f2d5dSmrg	utek*)
1426da1f2d5dSmrg		os=bsd
1427ba6a1819Smrg		;;
1428da1f2d5dSmrg	dynix*)
1429da1f2d5dSmrg		os=bsd
1430ba6a1819Smrg		;;
1431da1f2d5dSmrg	acis*)
1432da1f2d5dSmrg		os=aos
1433ba6a1819Smrg		;;
1434da1f2d5dSmrg	atheos*)
1435da1f2d5dSmrg		os=atheos
1436ba6a1819Smrg		;;
1437da1f2d5dSmrg	syllable*)
1438da1f2d5dSmrg		os=syllable
1439da1f2d5dSmrg		;;
1440da1f2d5dSmrg	386bsd)
1441da1f2d5dSmrg		os=bsd
1442da1f2d5dSmrg		;;
1443da1f2d5dSmrg	ctix* | uts*)
1444da1f2d5dSmrg		os=sysv
1445da1f2d5dSmrg		;;
1446da1f2d5dSmrg	nova*)
1447da1f2d5dSmrg		os=rtmk-nova
1448da1f2d5dSmrg		;;
1449da1f2d5dSmrg	ns2)
1450da1f2d5dSmrg		os=nextstep2
1451da1f2d5dSmrg		;;
1452da1f2d5dSmrg	# Preserve the version number of sinix5.
1453da1f2d5dSmrg	sinix5.*)
1454da1f2d5dSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1455ba6a1819Smrg		;;
1456da1f2d5dSmrg	sinix*)
1457da1f2d5dSmrg		os=sysv4
1458ba6a1819Smrg		;;
1459da1f2d5dSmrg	tpf*)
1460da1f2d5dSmrg		os=tpf
1461ba6a1819Smrg		;;
1462da1f2d5dSmrg	triton*)
1463da1f2d5dSmrg		os=sysv3
1464ba6a1819Smrg		;;
1465da1f2d5dSmrg	oss*)
1466da1f2d5dSmrg		os=sysv3
1467ba6a1819Smrg		;;
1468da1f2d5dSmrg	svr4*)
1469da1f2d5dSmrg		os=sysv4
1470ba6a1819Smrg		;;
1471da1f2d5dSmrg	svr3)
1472da1f2d5dSmrg		os=sysv3
1473ba6a1819Smrg		;;
1474da1f2d5dSmrg	sysvr4)
1475da1f2d5dSmrg		os=sysv4
1476ba6a1819Smrg		;;
1477da1f2d5dSmrg	ose*)
1478da1f2d5dSmrg		os=ose
1479ba6a1819Smrg		;;
1480da1f2d5dSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1481da1f2d5dSmrg		os=mint
1482549e21daSmrg		;;
1483da1f2d5dSmrg	dicos*)
1484da1f2d5dSmrg		os=dicos
1485da1f2d5dSmrg		;;
1486da1f2d5dSmrg	pikeos*)
1487fe4c343aSmrg		# Until real need of OS specific support for
1488fe4c343aSmrg		# particular features comes up, bare metal
1489fe4c343aSmrg		# configurations are quite functional.
1490da1f2d5dSmrg		case $cpu in
1491fe4c343aSmrg		    arm*)
1492da1f2d5dSmrg			os=eabi
1493fe4c343aSmrg			;;
1494fe4c343aSmrg		    *)
149500ca1914Smrg			os=
149600ca1914Smrg			obj=elf
1497fe4c343aSmrg			;;
1498fe4c343aSmrg		esac
1499fe4c343aSmrg		;;
150000ca1914Smrg	aout* | coff* | elf* | pe*)
150100ca1914Smrg		# These are machine code file formats, not OSes
150200ca1914Smrg		obj=$os
150300ca1914Smrg		os=
150400ca1914Smrg		;;
1505ba6a1819Smrg	*)
1506da1f2d5dSmrg		# No normalization, but not necessarily accepted, that comes below.
1507ba6a1819Smrg		;;
1508ba6a1819Smrgesac
1509da1f2d5dSmrg
1510ba6a1819Smrgelse
1511ba6a1819Smrg
1512ba6a1819Smrg# Here we handle the default operating systems that come with various machines.
1513ba6a1819Smrg# The value should be what the vendor currently ships out the door with their
1514ba6a1819Smrg# machine or put another way, the most popular os provided with the machine.
1515ba6a1819Smrg
1516ba6a1819Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1517ba6a1819Smrg# "-sun"), then you have to tell the case statement up towards the top
1518ba6a1819Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1519ba6a1819Smrg# will signal an error saying that MANUFACTURER isn't an operating
1520ba6a1819Smrg# system, and we'll never get to this point.
1521ba6a1819Smrg
1522da1f2d5dSmrgkernel=
152300ca1914Smrgobj=
1524da1f2d5dSmrgcase $cpu-$vendor in
15251bedbe3fSmrg	score-*)
152600ca1914Smrg		os=
152700ca1914Smrg		obj=elf
1528549e21daSmrg		;;
15291bedbe3fSmrg	spu-*)
153000ca1914Smrg		os=
153100ca1914Smrg		obj=elf
1532549e21daSmrg		;;
1533ba6a1819Smrg	*-acorn)
1534da1f2d5dSmrg		os=riscix1.2
1535ba6a1819Smrg		;;
1536ba6a1819Smrg	arm*-rebel)
1537da1f2d5dSmrg		kernel=linux
1538da1f2d5dSmrg		os=gnu
1539ba6a1819Smrg		;;
1540ba6a1819Smrg	arm*-semi)
154100ca1914Smrg		os=
154200ca1914Smrg		obj=aout
1543ba6a1819Smrg		;;
15441bedbe3fSmrg	c4x-* | tic4x-*)
154500ca1914Smrg		os=
154600ca1914Smrg		obj=coff
15471bedbe3fSmrg		;;
1548298453a4Smrg	c8051-*)
154900ca1914Smrg		os=
155000ca1914Smrg		obj=elf
1551da1f2d5dSmrg		;;
1552da1f2d5dSmrg	clipper-intergraph)
1553da1f2d5dSmrg		os=clix
1554298453a4Smrg		;;
15551bedbe3fSmrg	hexagon-*)
155600ca1914Smrg		os=
155700ca1914Smrg		obj=elf
1558549e21daSmrg		;;
1559549e21daSmrg	tic54x-*)
156000ca1914Smrg		os=
156100ca1914Smrg		obj=coff
1562549e21daSmrg		;;
1563549e21daSmrg	tic55x-*)
156400ca1914Smrg		os=
156500ca1914Smrg		obj=coff
1566549e21daSmrg		;;
1567549e21daSmrg	tic6x-*)
156800ca1914Smrg		os=
156900ca1914Smrg		obj=coff
1570549e21daSmrg		;;
1571ba6a1819Smrg	# This must come before the *-dec entry.
1572ba6a1819Smrg	pdp10-*)
1573da1f2d5dSmrg		os=tops20
1574ba6a1819Smrg		;;
1575ba6a1819Smrg	pdp11-*)
1576da1f2d5dSmrg		os=none
1577ba6a1819Smrg		;;
1578ba6a1819Smrg	*-dec | vax-*)
1579da1f2d5dSmrg		os=ultrix4.2
1580ba6a1819Smrg		;;
1581ba6a1819Smrg	m68*-apollo)
1582da1f2d5dSmrg		os=domain
1583ba6a1819Smrg		;;
1584ba6a1819Smrg	i386-sun)
1585da1f2d5dSmrg		os=sunos4.0.2
1586ba6a1819Smrg		;;
1587ba6a1819Smrg	m68000-sun)
1588da1f2d5dSmrg		os=sunos3
1589ba6a1819Smrg		;;
1590ba6a1819Smrg	m68*-cisco)
159100ca1914Smrg		os=
159200ca1914Smrg		obj=aout
1593ba6a1819Smrg		;;
15941bedbe3fSmrg	mep-*)
159500ca1914Smrg		os=
159600ca1914Smrg		obj=elf
1597549e21daSmrg		;;
1598ba6a1819Smrg	mips*-cisco)
159900ca1914Smrg		os=
160000ca1914Smrg		obj=elf
1601ba6a1819Smrg		;;
160200ca1914Smrg	mips*-*|nanomips*-*)
160300ca1914Smrg		os=
160400ca1914Smrg		obj=elf
1605ba6a1819Smrg		;;
1606ba6a1819Smrg	or32-*)
160700ca1914Smrg		os=
160800ca1914Smrg		obj=coff
1609ba6a1819Smrg		;;
1610ba6a1819Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1611da1f2d5dSmrg		os=sysv3
1612ba6a1819Smrg		;;
1613ba6a1819Smrg	sparc-* | *-sun)
1614da1f2d5dSmrg		os=sunos4.1.1
1615ba6a1819Smrg		;;
1616fe4c343aSmrg	pru-*)
161700ca1914Smrg		os=
161800ca1914Smrg		obj=elf
1619fe4c343aSmrg		;;
1620ba6a1819Smrg	*-be)
1621da1f2d5dSmrg		os=beos
1622ba6a1819Smrg		;;
1623ba6a1819Smrg	*-ibm)
1624da1f2d5dSmrg		os=aix
1625ba6a1819Smrg		;;
16261bedbe3fSmrg	*-knuth)
1627da1f2d5dSmrg		os=mmixware
1628ba6a1819Smrg		;;
1629ba6a1819Smrg	*-wec)
1630da1f2d5dSmrg		os=proelf
1631ba6a1819Smrg		;;
1632ba6a1819Smrg	*-winbond)
1633da1f2d5dSmrg		os=proelf
1634ba6a1819Smrg		;;
1635ba6a1819Smrg	*-oki)
1636da1f2d5dSmrg		os=proelf
1637ba6a1819Smrg		;;
1638ba6a1819Smrg	*-hp)
1639da1f2d5dSmrg		os=hpux
1640ba6a1819Smrg		;;
1641ba6a1819Smrg	*-hitachi)
1642da1f2d5dSmrg		os=hiux
1643ba6a1819Smrg		;;
1644ba6a1819Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1645da1f2d5dSmrg		os=sysv
1646ba6a1819Smrg		;;
1647ba6a1819Smrg	*-cbm)
1648da1f2d5dSmrg		os=amigaos
1649ba6a1819Smrg		;;
1650ba6a1819Smrg	*-dg)
1651da1f2d5dSmrg		os=dgux
1652ba6a1819Smrg		;;
1653ba6a1819Smrg	*-dolphin)
1654da1f2d5dSmrg		os=sysv3
1655ba6a1819Smrg		;;
1656ba6a1819Smrg	m68k-ccur)
1657da1f2d5dSmrg		os=rtu
1658ba6a1819Smrg		;;
1659ba6a1819Smrg	m88k-omron*)
1660da1f2d5dSmrg		os=luna
1661ba6a1819Smrg		;;
1662fe4c343aSmrg	*-next)
1663da1f2d5dSmrg		os=nextstep
1664ba6a1819Smrg		;;
1665ba6a1819Smrg	*-sequent)
1666da1f2d5dSmrg		os=ptx
1667ba6a1819Smrg		;;
1668ba6a1819Smrg	*-crds)
1669da1f2d5dSmrg		os=unos
1670ba6a1819Smrg		;;
1671ba6a1819Smrg	*-ns)
1672da1f2d5dSmrg		os=genix
1673ba6a1819Smrg		;;
1674ba6a1819Smrg	i370-*)
1675da1f2d5dSmrg		os=mvs
1676ba6a1819Smrg		;;
1677ba6a1819Smrg	*-gould)
1678da1f2d5dSmrg		os=sysv
1679ba6a1819Smrg		;;
1680ba6a1819Smrg	*-highlevel)
1681da1f2d5dSmrg		os=bsd
1682ba6a1819Smrg		;;
1683ba6a1819Smrg	*-encore)
1684da1f2d5dSmrg		os=bsd
1685ba6a1819Smrg		;;
1686ba6a1819Smrg	*-sgi)
1687da1f2d5dSmrg		os=irix
1688ba6a1819Smrg		;;
1689ba6a1819Smrg	*-siemens)
1690da1f2d5dSmrg		os=sysv4
1691ba6a1819Smrg		;;
1692ba6a1819Smrg	*-masscomp)
1693da1f2d5dSmrg		os=rtu
1694ba6a1819Smrg		;;
1695ba6a1819Smrg	f30[01]-fujitsu | f700-fujitsu)
1696da1f2d5dSmrg		os=uxpv
1697ba6a1819Smrg		;;
1698ba6a1819Smrg	*-rom68k)
169900ca1914Smrg		os=
170000ca1914Smrg		obj=coff
1701ba6a1819Smrg		;;
1702ba6a1819Smrg	*-*bug)
170300ca1914Smrg		os=
170400ca1914Smrg		obj=coff
1705ba6a1819Smrg		;;
1706ba6a1819Smrg	*-apple)
1707da1f2d5dSmrg		os=macos
1708ba6a1819Smrg		;;
1709ba6a1819Smrg	*-atari*)
1710da1f2d5dSmrg		os=mint
1711da1f2d5dSmrg		;;
1712da1f2d5dSmrg	*-wrs)
1713da1f2d5dSmrg		os=vxworks
1714ba6a1819Smrg		;;
1715ba6a1819Smrg	*)
1716da1f2d5dSmrg		os=none
1717ba6a1819Smrg		;;
1718ba6a1819Smrgesac
1719da1f2d5dSmrg
1720ba6a1819Smrgfi
1721ba6a1819Smrg
172200ca1914Smrg# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
172300ca1914Smrg
1724da1f2d5dSmrgcase $os in
1725da1f2d5dSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
172600ca1914Smrg	llvm* | musl* | newlib* | relibc* | uclibc*)
1727da1f2d5dSmrg		;;
1728da1f2d5dSmrg	# Likewise for "kernel-abi"
1729da1f2d5dSmrg	eabi* | gnueabi*)
1730da1f2d5dSmrg		;;
1731da1f2d5dSmrg	# VxWorks passes extra cpu info in the 4th filed.
1732da1f2d5dSmrg	simlinux | simwindows | spe)
1733da1f2d5dSmrg		;;
173400ca1914Smrg	# See `case $cpu-$os` validation below
173500ca1914Smrg	ghcjs)
173600ca1914Smrg		;;
1737da1f2d5dSmrg	# Now accept the basic system types.
1738da1f2d5dSmrg	# The portable systems comes first.
1739da1f2d5dSmrg	# Each alternative MUST end in a * to match a version number.
1740da1f2d5dSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1741da1f2d5dSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1742da1f2d5dSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1743da1f2d5dSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1744da1f2d5dSmrg	     | hiux* | abug | nacl* | netware* | windows* \
174500ca1914Smrg	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
1746da1f2d5dSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1747da1f2d5dSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1748da1f2d5dSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1749da1f2d5dSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1750da1f2d5dSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1751da1f2d5dSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1752da1f2d5dSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1753da1f2d5dSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
175400ca1914Smrg	     | bosx* | nextstep* | cxux* | oabi* \
175500ca1914Smrg	     | ptx* | ecoff* | winnt* | domain* | vsta* \
1756da1f2d5dSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1757da1f2d5dSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
175800ca1914Smrg	     | cygwin* | msys* | moss* | proelf* | rtems* \
1759da1f2d5dSmrg	     | midipix* | mingw32* | mingw64* | mint* \
1760da1f2d5dSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1761da1f2d5dSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1762da1f2d5dSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1763da1f2d5dSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1764da1f2d5dSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1765da1f2d5dSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1766da1f2d5dSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1767da1f2d5dSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1768da1f2d5dSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1769da1f2d5dSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
177000ca1914Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
177100ca1914Smrg	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
1772da1f2d5dSmrg		;;
1773da1f2d5dSmrg	# This one is extra strict with allowed versions
1774da1f2d5dSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1775da1f2d5dSmrg		# Don't forget version if it is 3.2v4 or newer.
1776da1f2d5dSmrg		;;
177700ca1914Smrg	# This refers to builds using the UEFI calling convention
177800ca1914Smrg	# (which depends on the architecture) and PE file format.
177900ca1914Smrg	# Note that this is both a different calling convention and
178000ca1914Smrg	# different file format than that of GNU-EFI
178100ca1914Smrg	# (x86_64-w64-mingw32).
178200ca1914Smrg	uefi)
178300ca1914Smrg		;;
1784da1f2d5dSmrg	none)
1785da1f2d5dSmrg		;;
178600ca1914Smrg	kernel* | msvc* )
178700ca1914Smrg		# Restricted further below
178800ca1914Smrg		;;
178900ca1914Smrg	'')
179000ca1914Smrg		if test x"$obj" = x
179100ca1914Smrg		then
179200ca1914Smrg			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
179300ca1914Smrg		fi
179400ca1914Smrg		;;
1795da1f2d5dSmrg	*)
179600ca1914Smrg		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
179700ca1914Smrg		exit 1
179800ca1914Smrg		;;
179900ca1914Smrgesac
180000ca1914Smrg
180100ca1914Smrgcase $obj in
180200ca1914Smrg	aout* | coff* | elf* | pe*)
180300ca1914Smrg		;;
180400ca1914Smrg	'')
180500ca1914Smrg		# empty is fine
180600ca1914Smrg		;;
180700ca1914Smrg	*)
180800ca1914Smrg		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
180900ca1914Smrg		exit 1
181000ca1914Smrg		;;
181100ca1914Smrgesac
181200ca1914Smrg
181300ca1914Smrg# Here we handle the constraint that a (synthetic) cpu and os are
181400ca1914Smrg# valid only in combination with each other and nowhere else.
181500ca1914Smrgcase $cpu-$os in
181600ca1914Smrg	# The "javascript-unknown-ghcjs" triple is used by GHC; we
181700ca1914Smrg	# accept it here in order to tolerate that, but reject any
181800ca1914Smrg	# variations.
181900ca1914Smrg	javascript-ghcjs)
182000ca1914Smrg		;;
182100ca1914Smrg	javascript-* | *-ghcjs)
182200ca1914Smrg		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
1823da1f2d5dSmrg		exit 1
1824da1f2d5dSmrg		;;
1825da1f2d5dSmrgesac
1826da1f2d5dSmrg
1827da1f2d5dSmrg# As a final step for OS-related things, validate the OS-kernel combination
1828da1f2d5dSmrg# (given a valid OS), if there is a kernel.
182900ca1914Smrgcase $kernel-$os-$obj in
183000ca1914Smrg	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
183100ca1914Smrg		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
183200ca1914Smrg		    | linux-relibc*- | linux-uclibc*- )
183300ca1914Smrg		;;
183400ca1914Smrg	uclinux-uclibc*- )
183500ca1914Smrg		;;
183600ca1914Smrg	managarm-mlibc*- | managarm-kernel*- )
1837da1f2d5dSmrg		;;
183800ca1914Smrg	windows*-msvc*-)
1839da1f2d5dSmrg		;;
184000ca1914Smrg	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
184100ca1914Smrg		    | -uclibc*- )
1842da1f2d5dSmrg		# These are just libc implementations, not actual OSes, and thus
1843da1f2d5dSmrg		# require a kernel.
184400ca1914Smrg		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
1845da1f2d5dSmrg		exit 1
1846da1f2d5dSmrg		;;
184700ca1914Smrg	-kernel*- )
184800ca1914Smrg		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
184900ca1914Smrg		exit 1
1850da1f2d5dSmrg		;;
185100ca1914Smrg	*-kernel*- )
185200ca1914Smrg		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
185300ca1914Smrg		exit 1
1854da1f2d5dSmrg		;;
185500ca1914Smrg	*-msvc*- )
185600ca1914Smrg		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
185700ca1914Smrg		exit 1
1858da1f2d5dSmrg		;;
185900ca1914Smrg	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
186000ca1914Smrg		;;
186100ca1914Smrg	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
186200ca1914Smrg		;;
186300ca1914Smrg	nto-qnx*-)
186400ca1914Smrg		;;
186500ca1914Smrg	os2-emx-)
1866da1f2d5dSmrg		;;
186700ca1914Smrg	*-eabi*- | *-gnueabi*-)
1868da1f2d5dSmrg		;;
186900ca1914Smrg	none--*)
187000ca1914Smrg		# None (no kernel, i.e. freestanding / bare metal),
187100ca1914Smrg		# can be paired with an machine code file format
187200ca1914Smrg		;;
187300ca1914Smrg	-*-)
1874da1f2d5dSmrg		# Blank kernel with real OS is always fine.
1875da1f2d5dSmrg		;;
187600ca1914Smrg	--*)
187700ca1914Smrg		# Blank kernel and OS with real machine code file format is always fine.
187800ca1914Smrg		;;
187900ca1914Smrg	*-*-*)
188000ca1914Smrg		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
1881da1f2d5dSmrg		exit 1
1882da1f2d5dSmrg		;;
1883da1f2d5dSmrgesac
1884da1f2d5dSmrg
1885ba6a1819Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1886ba6a1819Smrg# manufacturer.  We pick the logical manufacturer.
1887da1f2d5dSmrgcase $vendor in
1888da1f2d5dSmrg	unknown)
1889da1f2d5dSmrg		case $cpu-$os in
1890da1f2d5dSmrg			*-riscix*)
1891ba6a1819Smrg				vendor=acorn
1892ba6a1819Smrg				;;
1893da1f2d5dSmrg			*-sunos*)
1894ba6a1819Smrg				vendor=sun
1895ba6a1819Smrg				;;
1896da1f2d5dSmrg			*-cnk* | *-aix*)
1897ba6a1819Smrg				vendor=ibm
1898ba6a1819Smrg				;;
1899da1f2d5dSmrg			*-beos*)
1900ba6a1819Smrg				vendor=be
1901ba6a1819Smrg				;;
1902da1f2d5dSmrg			*-hpux*)
1903ba6a1819Smrg				vendor=hp
1904ba6a1819Smrg				;;
1905da1f2d5dSmrg			*-mpeix*)
1906ba6a1819Smrg				vendor=hp
1907ba6a1819Smrg				;;
1908da1f2d5dSmrg			*-hiux*)
1909ba6a1819Smrg				vendor=hitachi
1910ba6a1819Smrg				;;
1911da1f2d5dSmrg			*-unos*)
1912ba6a1819Smrg				vendor=crds
1913ba6a1819Smrg				;;
1914da1f2d5dSmrg			*-dgux*)
1915ba6a1819Smrg				vendor=dg
1916ba6a1819Smrg				;;
1917da1f2d5dSmrg			*-luna*)
1918ba6a1819Smrg				vendor=omron
1919ba6a1819Smrg				;;
1920da1f2d5dSmrg			*-genix*)
1921ba6a1819Smrg				vendor=ns
1922ba6a1819Smrg				;;
1923da1f2d5dSmrg			*-clix*)
1924da1f2d5dSmrg				vendor=intergraph
1925da1f2d5dSmrg				;;
1926da1f2d5dSmrg			*-mvs* | *-opened*)
1927da1f2d5dSmrg				vendor=ibm
1928da1f2d5dSmrg				;;
1929da1f2d5dSmrg			*-os400*)
1930ba6a1819Smrg				vendor=ibm
1931ba6a1819Smrg				;;
1932da1f2d5dSmrg			s390-* | s390x-*)
1933ba6a1819Smrg				vendor=ibm
1934ba6a1819Smrg				;;
1935da1f2d5dSmrg			*-ptx*)
1936ba6a1819Smrg				vendor=sequent
1937ba6a1819Smrg				;;
1938da1f2d5dSmrg			*-tpf*)
1939ba6a1819Smrg				vendor=ibm
1940ba6a1819Smrg				;;
1941da1f2d5dSmrg			*-vxsim* | *-vxworks* | *-windiss*)
1942ba6a1819Smrg				vendor=wrs
1943ba6a1819Smrg				;;
1944da1f2d5dSmrg			*-aux*)
1945ba6a1819Smrg				vendor=apple
1946ba6a1819Smrg				;;
1947da1f2d5dSmrg			*-hms*)
1948ba6a1819Smrg				vendor=hitachi
1949ba6a1819Smrg				;;
1950da1f2d5dSmrg			*-mpw* | *-macos*)
1951ba6a1819Smrg				vendor=apple
1952ba6a1819Smrg				;;
1953da1f2d5dSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1954ba6a1819Smrg				vendor=atari
1955ba6a1819Smrg				;;
1956da1f2d5dSmrg			*-vos*)
1957ba6a1819Smrg				vendor=stratus
1958ba6a1819Smrg				;;
1959ba6a1819Smrg		esac
1960ba6a1819Smrg		;;
1961ba6a1819Smrgesac
1962ba6a1819Smrg
196300ca1914Smrgecho "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
1964ba6a1819Smrgexit
1965ba6a1819Smrg
1966ba6a1819Smrg# Local variables:
1967da1f2d5dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1968ba6a1819Smrg# time-stamp-start: "timestamp='"
1969ba6a1819Smrg# time-stamp-format: "%:y-%02m-%02d"
1970ba6a1819Smrg# time-stamp-end: "'"
1971ba6a1819Smrg# End:
1972