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