11f0ac6a5Smrg#! /bin/sh
21f0ac6a5Smrg# Configuration validation subroutine script.
36ee7d557Smrg#   Copyright 1992-2024 Free Software Foundation, Inc.
41f0ac6a5Smrg
5d21ab8bcSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6d21ab8bcSmrg
76ee7d557Smrgtimestamp='2024-01-01'
81f0ac6a5Smrg
989c04b6cSmrg# This file is free software; you can redistribute it and/or modify it
1089c04b6cSmrg# under the terms of the GNU General Public License as published by
116ee7d557Smrg# the Free Software Foundation, either version 3 of the License, or
121f0ac6a5Smrg# (at your option) any later version.
131f0ac6a5Smrg#
1489c04b6cSmrg# This program is distributed in the hope that it will be useful, but
1589c04b6cSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1689c04b6cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1789c04b6cSmrg# General Public License for more details.
181f0ac6a5Smrg#
191f0ac6a5Smrg# You should have received a copy of the GNU General Public License
20d21ab8bcSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21e5410a46Smrg#
221f0ac6a5Smrg# As a special exception to the GNU General Public License, if you
231f0ac6a5Smrg# distribute this file as part of a program that contains a
241f0ac6a5Smrg# configuration script generated by Autoconf, you may include it under
2589c04b6cSmrg# the same distribution terms that you use for the rest of that
2689c04b6cSmrg# program.  This Exception is an additional permission under section 7
2789c04b6cSmrg# of the GNU General Public License, version 3 ("GPLv3").
281f0ac6a5Smrg
29e5410a46Smrg
30d21ab8bcSmrg# Please send patches to <config-patches@gnu.org>.
311f0ac6a5Smrg#
321f0ac6a5Smrg# Configuration subroutine to validate and canonicalize a configuration type.
331f0ac6a5Smrg# Supply the specified configuration type as an argument.
341f0ac6a5Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
351f0ac6a5Smrg# Otherwise, we print the canonical config type on stdout and succeed.
361f0ac6a5Smrg
379c9ff80cSmrg# You can get the latest version of this script from:
38d21ab8bcSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
399c9ff80cSmrg
401f0ac6a5Smrg# This file is supposed to be the same for all GNU packages
411f0ac6a5Smrg# and recognize all the CPU types, system types and aliases
421f0ac6a5Smrg# that are meaningful with *any* GNU software.
431f0ac6a5Smrg# Each package is responsible for reporting which valid configurations
441f0ac6a5Smrg# it does not support.  The user should be able to distinguish
451f0ac6a5Smrg# a failure to support a valid configuration from a meaningless
461f0ac6a5Smrg# configuration.
471f0ac6a5Smrg
481f0ac6a5Smrg# The goal of this file is to map all the various variations of a given
491f0ac6a5Smrg# machine specification into a single specification in the form:
501f0ac6a5Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
511f0ac6a5Smrg# or in some cases, the newer four-part form:
521f0ac6a5Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
531f0ac6a5Smrg# It is wrong to echo any other type of specification.
541f0ac6a5Smrg
55d21ab8bcSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
56d21ab8bcSmrg# about features and limitations of the classic Bourne shell that were
57d21ab8bcSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
58d21ab8bcSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59d21ab8bcSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60d21ab8bcSmrg# have a pre-POSIX /bin/sh.
61d21ab8bcSmrg
621f0ac6a5Smrgme=`echo "$0" | sed -e 's,.*/,,'`
631f0ac6a5Smrg
641f0ac6a5Smrgusage="\
65d21ab8bcSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
661f0ac6a5Smrg
671f0ac6a5SmrgCanonicalize a configuration name.
681f0ac6a5Smrg
69d21ab8bcSmrgOptions:
701f0ac6a5Smrg  -h, --help         print this help, then exit
711f0ac6a5Smrg  -t, --time-stamp   print date of last modification, then exit
721f0ac6a5Smrg  -v, --version      print version number, then exit
731f0ac6a5Smrg
741f0ac6a5SmrgReport bugs and patches to <config-patches@gnu.org>."
751f0ac6a5Smrg
761f0ac6a5Smrgversion="\
771f0ac6a5SmrgGNU config.sub ($timestamp)
781f0ac6a5Smrg
796ee7d557SmrgCopyright 1992-2024 Free Software Foundation, Inc.
801f0ac6a5Smrg
811f0ac6a5SmrgThis is free software; see the source for copying conditions.  There is NO
821f0ac6a5Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
831f0ac6a5Smrg
841f0ac6a5Smrghelp="
856ee7d557SmrgTry '$me --help' for more information."
861f0ac6a5Smrg
871f0ac6a5Smrg# Parse command line
881f0ac6a5Smrgwhile test $# -gt 0 ; do
891f0ac6a5Smrg  case $1 in
901f0ac6a5Smrg    --time-stamp | --time* | -t )
91e5410a46Smrg       echo "$timestamp" ; exit ;;
921f0ac6a5Smrg    --version | -v )
93e5410a46Smrg       echo "$version" ; exit ;;
941f0ac6a5Smrg    --help | --h* | -h )
95e5410a46Smrg       echo "$usage"; exit ;;
961f0ac6a5Smrg    -- )     # Stop option processing
971f0ac6a5Smrg       shift; break ;;
981f0ac6a5Smrg    - )	# Use stdin as input.
991f0ac6a5Smrg       break ;;
1001f0ac6a5Smrg    -* )
101d21ab8bcSmrg       echo "$me: invalid option $1$help" >&2
1021f0ac6a5Smrg       exit 1 ;;
1031f0ac6a5Smrg
1041f0ac6a5Smrg    *local*)
1051f0ac6a5Smrg       # First pass through any local machine types.
106d21ab8bcSmrg       echo "$1"
107e5410a46Smrg       exit ;;
1081f0ac6a5Smrg
1091f0ac6a5Smrg    * )
1101f0ac6a5Smrg       break ;;
1111f0ac6a5Smrg  esac
1121f0ac6a5Smrgdone
1131f0ac6a5Smrg
1141f0ac6a5Smrgcase $# in
1151f0ac6a5Smrg 0) echo "$me: missing argument$help" >&2
1161f0ac6a5Smrg    exit 1;;
1171f0ac6a5Smrg 1) ;;
1181f0ac6a5Smrg *) echo "$me: too many arguments$help" >&2
1191f0ac6a5Smrg    exit 1;;
1201f0ac6a5Smrgesac
1211f0ac6a5Smrg
122d21ab8bcSmrg# Split fields of configuration type
123d21ab8bcSmrg# shellcheck disable=SC2162
124d21ab8bcSmrgsaved_IFS=$IFS
125d21ab8bcSmrgIFS="-" read field1 field2 field3 field4 <<EOF
126d21ab8bcSmrg$1
127d21ab8bcSmrgEOF
128d21ab8bcSmrgIFS=$saved_IFS
1291f0ac6a5Smrg
130d21ab8bcSmrg# Separate into logical components for further validation
131d21ab8bcSmrgcase $1 in
132d21ab8bcSmrg	*-*-*-*-*)
1336ee7d557Smrg		echo "Invalid configuration '$1': more than four components" >&2
134d21ab8bcSmrg		exit 1
1351f0ac6a5Smrg		;;
136d21ab8bcSmrg	*-*-*-*)
137d21ab8bcSmrg		basic_machine=$field1-$field2
138d21ab8bcSmrg		basic_os=$field3-$field4
1391f0ac6a5Smrg		;;
140d21ab8bcSmrg	*-*-*)
141d21ab8bcSmrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142d21ab8bcSmrg		# parts
143d21ab8bcSmrg		maybe_os=$field2-$field3
144d21ab8bcSmrg		case $maybe_os in
145d21ab8bcSmrg			nto-qnx* | linux-* | uclinux-uclibc* \
146d21ab8bcSmrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147d21ab8bcSmrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1486ee7d557Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
1496ee7d557Smrg			| windows-* )
150d21ab8bcSmrg				basic_machine=$field1
151d21ab8bcSmrg				basic_os=$maybe_os
152d21ab8bcSmrg				;;
153d21ab8bcSmrg			android-linux)
154d21ab8bcSmrg				basic_machine=$field1-unknown
155d21ab8bcSmrg				basic_os=linux-android
156d21ab8bcSmrg				;;
157d21ab8bcSmrg			*)
158d21ab8bcSmrg				basic_machine=$field1-$field2
159d21ab8bcSmrg				basic_os=$field3
160d21ab8bcSmrg				;;
161d21ab8bcSmrg		esac
1621f0ac6a5Smrg		;;
163d21ab8bcSmrg	*-*)
164d21ab8bcSmrg		# A lone config we happen to match not fitting any pattern
165d21ab8bcSmrg		case $field1-$field2 in
166d21ab8bcSmrg			decstation-3100)
167d21ab8bcSmrg				basic_machine=mips-dec
168d21ab8bcSmrg				basic_os=
169d21ab8bcSmrg				;;
170d21ab8bcSmrg			*-*)
171d21ab8bcSmrg				# Second component is usually, but not always the OS
172d21ab8bcSmrg				case $field2 in
173d21ab8bcSmrg					# Prevent following clause from handling this valid os
174d21ab8bcSmrg					sun*os*)
175d21ab8bcSmrg						basic_machine=$field1
176d21ab8bcSmrg						basic_os=$field2
177d21ab8bcSmrg						;;
178d21ab8bcSmrg					zephyr*)
179d21ab8bcSmrg						basic_machine=$field1-unknown
180d21ab8bcSmrg						basic_os=$field2
181d21ab8bcSmrg						;;
182d21ab8bcSmrg					# Manufacturers
183d21ab8bcSmrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
184d21ab8bcSmrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
185d21ab8bcSmrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
186d21ab8bcSmrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
187d21ab8bcSmrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
188d21ab8bcSmrg					| ultra | tti* | harris | dolphin | highlevel | gould \
189d21ab8bcSmrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
190d21ab8bcSmrg					| microblaze* | sim | cisco \
191d21ab8bcSmrg					| oki | wec | wrs | winbond)
192d21ab8bcSmrg						basic_machine=$field1-$field2
193d21ab8bcSmrg						basic_os=
194d21ab8bcSmrg						;;
195d21ab8bcSmrg					*)
196d21ab8bcSmrg						basic_machine=$field1
197d21ab8bcSmrg						basic_os=$field2
198d21ab8bcSmrg						;;
199d21ab8bcSmrg				esac
200d21ab8bcSmrg			;;
201d21ab8bcSmrg		esac
2021f0ac6a5Smrg		;;
203d21ab8bcSmrg	*)
204d21ab8bcSmrg		# Convert single-component short-hands not valid as part of
205d21ab8bcSmrg		# multi-component configurations.
206d21ab8bcSmrg		case $field1 in
207d21ab8bcSmrg			386bsd)
208d21ab8bcSmrg				basic_machine=i386-pc
209d21ab8bcSmrg				basic_os=bsd
210d21ab8bcSmrg				;;
211d21ab8bcSmrg			a29khif)
212d21ab8bcSmrg				basic_machine=a29k-amd
213d21ab8bcSmrg				basic_os=udi
214d21ab8bcSmrg				;;
215d21ab8bcSmrg			adobe68k)
216d21ab8bcSmrg				basic_machine=m68010-adobe
217d21ab8bcSmrg				basic_os=scout
218d21ab8bcSmrg				;;
219d21ab8bcSmrg			alliant)
220d21ab8bcSmrg				basic_machine=fx80-alliant
221d21ab8bcSmrg				basic_os=
222d21ab8bcSmrg				;;
223d21ab8bcSmrg			altos | altos3068)
224d21ab8bcSmrg				basic_machine=m68k-altos
225d21ab8bcSmrg				basic_os=
226d21ab8bcSmrg				;;
227d21ab8bcSmrg			am29k)
228d21ab8bcSmrg				basic_machine=a29k-none
229d21ab8bcSmrg				basic_os=bsd
230d21ab8bcSmrg				;;
231d21ab8bcSmrg			amdahl)
232d21ab8bcSmrg				basic_machine=580-amdahl
233d21ab8bcSmrg				basic_os=sysv
234d21ab8bcSmrg				;;
235d21ab8bcSmrg			amiga)
236d21ab8bcSmrg				basic_machine=m68k-unknown
237d21ab8bcSmrg				basic_os=
238d21ab8bcSmrg				;;
239d21ab8bcSmrg			amigaos | amigados)
240d21ab8bcSmrg				basic_machine=m68k-unknown
241d21ab8bcSmrg				basic_os=amigaos
242d21ab8bcSmrg				;;
243d21ab8bcSmrg			amigaunix | amix)
244d21ab8bcSmrg				basic_machine=m68k-unknown
245d21ab8bcSmrg				basic_os=sysv4
246d21ab8bcSmrg				;;
247d21ab8bcSmrg			apollo68)
248d21ab8bcSmrg				basic_machine=m68k-apollo
249d21ab8bcSmrg				basic_os=sysv
250d21ab8bcSmrg				;;
251d21ab8bcSmrg			apollo68bsd)
252d21ab8bcSmrg				basic_machine=m68k-apollo
253d21ab8bcSmrg				basic_os=bsd
254d21ab8bcSmrg				;;
255d21ab8bcSmrg			aros)
256d21ab8bcSmrg				basic_machine=i386-pc
257d21ab8bcSmrg				basic_os=aros
258d21ab8bcSmrg				;;
259d21ab8bcSmrg			aux)
260d21ab8bcSmrg				basic_machine=m68k-apple
261d21ab8bcSmrg				basic_os=aux
262d21ab8bcSmrg				;;
263d21ab8bcSmrg			balance)
264d21ab8bcSmrg				basic_machine=ns32k-sequent
265d21ab8bcSmrg				basic_os=dynix
266d21ab8bcSmrg				;;
267d21ab8bcSmrg			blackfin)
268d21ab8bcSmrg				basic_machine=bfin-unknown
269d21ab8bcSmrg				basic_os=linux
270d21ab8bcSmrg				;;
271d21ab8bcSmrg			cegcc)
272d21ab8bcSmrg				basic_machine=arm-unknown
273d21ab8bcSmrg				basic_os=cegcc
274d21ab8bcSmrg				;;
275d21ab8bcSmrg			convex-c1)
276d21ab8bcSmrg				basic_machine=c1-convex
277d21ab8bcSmrg				basic_os=bsd
278d21ab8bcSmrg				;;
279d21ab8bcSmrg			convex-c2)
280d21ab8bcSmrg				basic_machine=c2-convex
281d21ab8bcSmrg				basic_os=bsd
282d21ab8bcSmrg				;;
283d21ab8bcSmrg			convex-c32)
284d21ab8bcSmrg				basic_machine=c32-convex
285d21ab8bcSmrg				basic_os=bsd
286d21ab8bcSmrg				;;
287d21ab8bcSmrg			convex-c34)
288d21ab8bcSmrg				basic_machine=c34-convex
289d21ab8bcSmrg				basic_os=bsd
290d21ab8bcSmrg				;;
291d21ab8bcSmrg			convex-c38)
292d21ab8bcSmrg				basic_machine=c38-convex
293d21ab8bcSmrg				basic_os=bsd
294d21ab8bcSmrg				;;
295d21ab8bcSmrg			cray)
296d21ab8bcSmrg				basic_machine=j90-cray
297d21ab8bcSmrg				basic_os=unicos
298d21ab8bcSmrg				;;
299d21ab8bcSmrg			crds | unos)
300d21ab8bcSmrg				basic_machine=m68k-crds
301d21ab8bcSmrg				basic_os=
302d21ab8bcSmrg				;;
303d21ab8bcSmrg			da30)
304d21ab8bcSmrg				basic_machine=m68k-da30
305d21ab8bcSmrg				basic_os=
306d21ab8bcSmrg				;;
307d21ab8bcSmrg			decstation | pmax | pmin | dec3100 | decstatn)
308d21ab8bcSmrg				basic_machine=mips-dec
309d21ab8bcSmrg				basic_os=
310d21ab8bcSmrg				;;
311d21ab8bcSmrg			delta88)
312d21ab8bcSmrg				basic_machine=m88k-motorola
313d21ab8bcSmrg				basic_os=sysv3
314d21ab8bcSmrg				;;
315d21ab8bcSmrg			dicos)
316d21ab8bcSmrg				basic_machine=i686-pc
317d21ab8bcSmrg				basic_os=dicos
318d21ab8bcSmrg				;;
319d21ab8bcSmrg			djgpp)
320d21ab8bcSmrg				basic_machine=i586-pc
321d21ab8bcSmrg				basic_os=msdosdjgpp
322d21ab8bcSmrg				;;
323d21ab8bcSmrg			ebmon29k)
324d21ab8bcSmrg				basic_machine=a29k-amd
325d21ab8bcSmrg				basic_os=ebmon
326d21ab8bcSmrg				;;
327d21ab8bcSmrg			es1800 | OSE68k | ose68k | ose | OSE)
328d21ab8bcSmrg				basic_machine=m68k-ericsson
329d21ab8bcSmrg				basic_os=ose
330d21ab8bcSmrg				;;
331d21ab8bcSmrg			gmicro)
332d21ab8bcSmrg				basic_machine=tron-gmicro
333d21ab8bcSmrg				basic_os=sysv
334d21ab8bcSmrg				;;
335d21ab8bcSmrg			go32)
336d21ab8bcSmrg				basic_machine=i386-pc
337d21ab8bcSmrg				basic_os=go32
338d21ab8bcSmrg				;;
339d21ab8bcSmrg			h8300hms)
340d21ab8bcSmrg				basic_machine=h8300-hitachi
341d21ab8bcSmrg				basic_os=hms
342d21ab8bcSmrg				;;
343d21ab8bcSmrg			h8300xray)
344d21ab8bcSmrg				basic_machine=h8300-hitachi
345d21ab8bcSmrg				basic_os=xray
346d21ab8bcSmrg				;;
347d21ab8bcSmrg			h8500hms)
348d21ab8bcSmrg				basic_machine=h8500-hitachi
349d21ab8bcSmrg				basic_os=hms
350d21ab8bcSmrg				;;
351d21ab8bcSmrg			harris)
352d21ab8bcSmrg				basic_machine=m88k-harris
353d21ab8bcSmrg				basic_os=sysv3
354d21ab8bcSmrg				;;
355d21ab8bcSmrg			hp300 | hp300hpux)
356d21ab8bcSmrg				basic_machine=m68k-hp
357d21ab8bcSmrg				basic_os=hpux
358d21ab8bcSmrg				;;
359d21ab8bcSmrg			hp300bsd)
360d21ab8bcSmrg				basic_machine=m68k-hp
361d21ab8bcSmrg				basic_os=bsd
362d21ab8bcSmrg				;;
363d21ab8bcSmrg			hppaosf)
364d21ab8bcSmrg				basic_machine=hppa1.1-hp
365d21ab8bcSmrg				basic_os=osf
366d21ab8bcSmrg				;;
367d21ab8bcSmrg			hppro)
368d21ab8bcSmrg				basic_machine=hppa1.1-hp
369d21ab8bcSmrg				basic_os=proelf
370d21ab8bcSmrg				;;
371d21ab8bcSmrg			i386mach)
372d21ab8bcSmrg				basic_machine=i386-mach
373d21ab8bcSmrg				basic_os=mach
374d21ab8bcSmrg				;;
375d21ab8bcSmrg			isi68 | isi)
376d21ab8bcSmrg				basic_machine=m68k-isi
377d21ab8bcSmrg				basic_os=sysv
378d21ab8bcSmrg				;;
379d21ab8bcSmrg			m68knommu)
380d21ab8bcSmrg				basic_machine=m68k-unknown
381d21ab8bcSmrg				basic_os=linux
382d21ab8bcSmrg				;;
383d21ab8bcSmrg			magnum | m3230)
384d21ab8bcSmrg				basic_machine=mips-mips
385d21ab8bcSmrg				basic_os=sysv
386d21ab8bcSmrg				;;
387d21ab8bcSmrg			merlin)
388d21ab8bcSmrg				basic_machine=ns32k-utek
389d21ab8bcSmrg				basic_os=sysv
390d21ab8bcSmrg				;;
391d21ab8bcSmrg			mingw64)
392d21ab8bcSmrg				basic_machine=x86_64-pc
393d21ab8bcSmrg				basic_os=mingw64
394d21ab8bcSmrg				;;
395d21ab8bcSmrg			mingw32)
396d21ab8bcSmrg				basic_machine=i686-pc
397d21ab8bcSmrg				basic_os=mingw32
398d21ab8bcSmrg				;;
399d21ab8bcSmrg			mingw32ce)
400d21ab8bcSmrg				basic_machine=arm-unknown
401d21ab8bcSmrg				basic_os=mingw32ce
402d21ab8bcSmrg				;;
403d21ab8bcSmrg			monitor)
404d21ab8bcSmrg				basic_machine=m68k-rom68k
405d21ab8bcSmrg				basic_os=coff
406d21ab8bcSmrg				;;
407d21ab8bcSmrg			morphos)
408d21ab8bcSmrg				basic_machine=powerpc-unknown
409d21ab8bcSmrg				basic_os=morphos
410d21ab8bcSmrg				;;
411d21ab8bcSmrg			moxiebox)
412d21ab8bcSmrg				basic_machine=moxie-unknown
413d21ab8bcSmrg				basic_os=moxiebox
414d21ab8bcSmrg				;;
415d21ab8bcSmrg			msdos)
416d21ab8bcSmrg				basic_machine=i386-pc
417d21ab8bcSmrg				basic_os=msdos
418d21ab8bcSmrg				;;
419d21ab8bcSmrg			msys)
420d21ab8bcSmrg				basic_machine=i686-pc
421d21ab8bcSmrg				basic_os=msys
422d21ab8bcSmrg				;;
423d21ab8bcSmrg			mvs)
424d21ab8bcSmrg				basic_machine=i370-ibm
425d21ab8bcSmrg				basic_os=mvs
426d21ab8bcSmrg				;;
427d21ab8bcSmrg			nacl)
428d21ab8bcSmrg				basic_machine=le32-unknown
429d21ab8bcSmrg				basic_os=nacl
430d21ab8bcSmrg				;;
431d21ab8bcSmrg			ncr3000)
432d21ab8bcSmrg				basic_machine=i486-ncr
433d21ab8bcSmrg				basic_os=sysv4
434d21ab8bcSmrg				;;
435d21ab8bcSmrg			netbsd386)
436d21ab8bcSmrg				basic_machine=i386-pc
437d21ab8bcSmrg				basic_os=netbsd
438d21ab8bcSmrg				;;
439d21ab8bcSmrg			netwinder)
440d21ab8bcSmrg				basic_machine=armv4l-rebel
441d21ab8bcSmrg				basic_os=linux
442d21ab8bcSmrg				;;
443d21ab8bcSmrg			news | news700 | news800 | news900)
444d21ab8bcSmrg				basic_machine=m68k-sony
445d21ab8bcSmrg				basic_os=newsos
446d21ab8bcSmrg				;;
447d21ab8bcSmrg			news1000)
448d21ab8bcSmrg				basic_machine=m68030-sony
449d21ab8bcSmrg				basic_os=newsos
450d21ab8bcSmrg				;;
451d21ab8bcSmrg			necv70)
452d21ab8bcSmrg				basic_machine=v70-nec
453d21ab8bcSmrg				basic_os=sysv
454d21ab8bcSmrg				;;
455d21ab8bcSmrg			nh3000)
456d21ab8bcSmrg				basic_machine=m68k-harris
457d21ab8bcSmrg				basic_os=cxux
458d21ab8bcSmrg				;;
459d21ab8bcSmrg			nh[45]000)
460d21ab8bcSmrg				basic_machine=m88k-harris
461d21ab8bcSmrg				basic_os=cxux
462d21ab8bcSmrg				;;
463d21ab8bcSmrg			nindy960)
464d21ab8bcSmrg				basic_machine=i960-intel
465d21ab8bcSmrg				basic_os=nindy
466d21ab8bcSmrg				;;
467d21ab8bcSmrg			mon960)
468d21ab8bcSmrg				basic_machine=i960-intel
469d21ab8bcSmrg				basic_os=mon960
470d21ab8bcSmrg				;;
471d21ab8bcSmrg			nonstopux)
472d21ab8bcSmrg				basic_machine=mips-compaq
473d21ab8bcSmrg				basic_os=nonstopux
474d21ab8bcSmrg				;;
475d21ab8bcSmrg			os400)
476d21ab8bcSmrg				basic_machine=powerpc-ibm
477d21ab8bcSmrg				basic_os=os400
478d21ab8bcSmrg				;;
479d21ab8bcSmrg			OSE68000 | ose68000)
480d21ab8bcSmrg				basic_machine=m68000-ericsson
481d21ab8bcSmrg				basic_os=ose
482d21ab8bcSmrg				;;
483d21ab8bcSmrg			os68k)
484d21ab8bcSmrg				basic_machine=m68k-none
485d21ab8bcSmrg				basic_os=os68k
486d21ab8bcSmrg				;;
487d21ab8bcSmrg			paragon)
488d21ab8bcSmrg				basic_machine=i860-intel
489d21ab8bcSmrg				basic_os=osf
490d21ab8bcSmrg				;;
491d21ab8bcSmrg			parisc)
492d21ab8bcSmrg				basic_machine=hppa-unknown
493d21ab8bcSmrg				basic_os=linux
494d21ab8bcSmrg				;;
495d21ab8bcSmrg			psp)
496d21ab8bcSmrg				basic_machine=mipsallegrexel-sony
497d21ab8bcSmrg				basic_os=psp
498d21ab8bcSmrg				;;
499d21ab8bcSmrg			pw32)
500d21ab8bcSmrg				basic_machine=i586-unknown
501d21ab8bcSmrg				basic_os=pw32
502d21ab8bcSmrg				;;
503d21ab8bcSmrg			rdos | rdos64)
504d21ab8bcSmrg				basic_machine=x86_64-pc
505d21ab8bcSmrg				basic_os=rdos
506d21ab8bcSmrg				;;
507d21ab8bcSmrg			rdos32)
508d21ab8bcSmrg				basic_machine=i386-pc
509d21ab8bcSmrg				basic_os=rdos
510d21ab8bcSmrg				;;
511d21ab8bcSmrg			rom68k)
512d21ab8bcSmrg				basic_machine=m68k-rom68k
513d21ab8bcSmrg				basic_os=coff
514d21ab8bcSmrg				;;
515d21ab8bcSmrg			sa29200)
516d21ab8bcSmrg				basic_machine=a29k-amd
517d21ab8bcSmrg				basic_os=udi
518d21ab8bcSmrg				;;
519d21ab8bcSmrg			sei)
520d21ab8bcSmrg				basic_machine=mips-sei
521d21ab8bcSmrg				basic_os=seiux
522d21ab8bcSmrg				;;
523d21ab8bcSmrg			sequent)
524d21ab8bcSmrg				basic_machine=i386-sequent
525d21ab8bcSmrg				basic_os=
526d21ab8bcSmrg				;;
527d21ab8bcSmrg			sps7)
528d21ab8bcSmrg				basic_machine=m68k-bull
529d21ab8bcSmrg				basic_os=sysv2
530d21ab8bcSmrg				;;
531d21ab8bcSmrg			st2000)
532d21ab8bcSmrg				basic_machine=m68k-tandem
533d21ab8bcSmrg				basic_os=
534d21ab8bcSmrg				;;
535d21ab8bcSmrg			stratus)
536d21ab8bcSmrg				basic_machine=i860-stratus
537d21ab8bcSmrg				basic_os=sysv4
538d21ab8bcSmrg				;;
539d21ab8bcSmrg			sun2)
540d21ab8bcSmrg				basic_machine=m68000-sun
541d21ab8bcSmrg				basic_os=
542d21ab8bcSmrg				;;
543d21ab8bcSmrg			sun2os3)
544d21ab8bcSmrg				basic_machine=m68000-sun
545d21ab8bcSmrg				basic_os=sunos3
546d21ab8bcSmrg				;;
547d21ab8bcSmrg			sun2os4)
548d21ab8bcSmrg				basic_machine=m68000-sun
549d21ab8bcSmrg				basic_os=sunos4
550d21ab8bcSmrg				;;
551d21ab8bcSmrg			sun3)
552d21ab8bcSmrg				basic_machine=m68k-sun
553d21ab8bcSmrg				basic_os=
554d21ab8bcSmrg				;;
555d21ab8bcSmrg			sun3os3)
556d21ab8bcSmrg				basic_machine=m68k-sun
557d21ab8bcSmrg				basic_os=sunos3
558d21ab8bcSmrg				;;
559d21ab8bcSmrg			sun3os4)
560d21ab8bcSmrg				basic_machine=m68k-sun
561d21ab8bcSmrg				basic_os=sunos4
562d21ab8bcSmrg				;;
563d21ab8bcSmrg			sun4)
564d21ab8bcSmrg				basic_machine=sparc-sun
565d21ab8bcSmrg				basic_os=
566d21ab8bcSmrg				;;
567d21ab8bcSmrg			sun4os3)
568d21ab8bcSmrg				basic_machine=sparc-sun
569d21ab8bcSmrg				basic_os=sunos3
570d21ab8bcSmrg				;;
571d21ab8bcSmrg			sun4os4)
572d21ab8bcSmrg				basic_machine=sparc-sun
573d21ab8bcSmrg				basic_os=sunos4
574d21ab8bcSmrg				;;
575d21ab8bcSmrg			sun4sol2)
576d21ab8bcSmrg				basic_machine=sparc-sun
577d21ab8bcSmrg				basic_os=solaris2
578d21ab8bcSmrg				;;
579d21ab8bcSmrg			sun386 | sun386i | roadrunner)
580d21ab8bcSmrg				basic_machine=i386-sun
581d21ab8bcSmrg				basic_os=
582d21ab8bcSmrg				;;
583d21ab8bcSmrg			sv1)
584d21ab8bcSmrg				basic_machine=sv1-cray
585d21ab8bcSmrg				basic_os=unicos
586d21ab8bcSmrg				;;
587d21ab8bcSmrg			symmetry)
588d21ab8bcSmrg				basic_machine=i386-sequent
589d21ab8bcSmrg				basic_os=dynix
590d21ab8bcSmrg				;;
591d21ab8bcSmrg			t3e)
592d21ab8bcSmrg				basic_machine=alphaev5-cray
593d21ab8bcSmrg				basic_os=unicos
594d21ab8bcSmrg				;;
595d21ab8bcSmrg			t90)
596d21ab8bcSmrg				basic_machine=t90-cray
597d21ab8bcSmrg				basic_os=unicos
598d21ab8bcSmrg				;;
599d21ab8bcSmrg			toad1)
600d21ab8bcSmrg				basic_machine=pdp10-xkl
601d21ab8bcSmrg				basic_os=tops20
602d21ab8bcSmrg				;;
603d21ab8bcSmrg			tpf)
604d21ab8bcSmrg				basic_machine=s390x-ibm
605d21ab8bcSmrg				basic_os=tpf
606d21ab8bcSmrg				;;
607d21ab8bcSmrg			udi29k)
608d21ab8bcSmrg				basic_machine=a29k-amd
609d21ab8bcSmrg				basic_os=udi
610d21ab8bcSmrg				;;
611d21ab8bcSmrg			ultra3)
612d21ab8bcSmrg				basic_machine=a29k-nyu
613d21ab8bcSmrg				basic_os=sym1
614d21ab8bcSmrg				;;
615d21ab8bcSmrg			v810 | necv810)
616d21ab8bcSmrg				basic_machine=v810-nec
617d21ab8bcSmrg				basic_os=none
618d21ab8bcSmrg				;;
619d21ab8bcSmrg			vaxv)
620d21ab8bcSmrg				basic_machine=vax-dec
621d21ab8bcSmrg				basic_os=sysv
622d21ab8bcSmrg				;;
623d21ab8bcSmrg			vms)
624d21ab8bcSmrg				basic_machine=vax-dec
625d21ab8bcSmrg				basic_os=vms
626d21ab8bcSmrg				;;
627d21ab8bcSmrg			vsta)
628d21ab8bcSmrg				basic_machine=i386-pc
629d21ab8bcSmrg				basic_os=vsta
630d21ab8bcSmrg				;;
631d21ab8bcSmrg			vxworks960)
632d21ab8bcSmrg				basic_machine=i960-wrs
633d21ab8bcSmrg				basic_os=vxworks
634d21ab8bcSmrg				;;
635d21ab8bcSmrg			vxworks68)
636d21ab8bcSmrg				basic_machine=m68k-wrs
637d21ab8bcSmrg				basic_os=vxworks
638d21ab8bcSmrg				;;
639d21ab8bcSmrg			vxworks29k)
640d21ab8bcSmrg				basic_machine=a29k-wrs
641d21ab8bcSmrg				basic_os=vxworks
642d21ab8bcSmrg				;;
643d21ab8bcSmrg			xbox)
644d21ab8bcSmrg				basic_machine=i686-pc
645d21ab8bcSmrg				basic_os=mingw32
646d21ab8bcSmrg				;;
647d21ab8bcSmrg			ymp)
648d21ab8bcSmrg				basic_machine=ymp-cray
649d21ab8bcSmrg				basic_os=unicos
650d21ab8bcSmrg				;;
651d21ab8bcSmrg			*)
652d21ab8bcSmrg				basic_machine=$1
653d21ab8bcSmrg				basic_os=
654d21ab8bcSmrg				;;
655d21ab8bcSmrg		esac
6561f0ac6a5Smrg		;;
6571f0ac6a5Smrgesac
6581f0ac6a5Smrg
659d21ab8bcSmrg# Decode 1-component or ad-hoc basic machines
6601f0ac6a5Smrgcase $basic_machine in
661d21ab8bcSmrg	# Here we handle the default manufacturer of certain CPU types.  It is in
662d21ab8bcSmrg	# some cases the only manufacturer, in others, it is the most popular.
663d21ab8bcSmrg	w89k)
664d21ab8bcSmrg		cpu=hppa1.1
665d21ab8bcSmrg		vendor=winbond
666e5410a46Smrg		;;
667d21ab8bcSmrg	op50n)
668d21ab8bcSmrg		cpu=hppa1.1
669d21ab8bcSmrg		vendor=oki
67089c04b6cSmrg		;;
671d21ab8bcSmrg	op60c)
672d21ab8bcSmrg		cpu=hppa1.1
673d21ab8bcSmrg		vendor=oki
67489c04b6cSmrg		;;
675d21ab8bcSmrg	ibm*)
676d21ab8bcSmrg		cpu=i370
677d21ab8bcSmrg		vendor=ibm
67889c04b6cSmrg		;;
679d21ab8bcSmrg	orion105)
680d21ab8bcSmrg		cpu=clipper
681d21ab8bcSmrg		vendor=highlevel
68289c04b6cSmrg		;;
683d21ab8bcSmrg	mac | mpw | mac-mpw)
684d21ab8bcSmrg		cpu=m68k
685d21ab8bcSmrg		vendor=apple
6861f0ac6a5Smrg		;;
687d21ab8bcSmrg	pmac | pmac-mpw)
688d21ab8bcSmrg		cpu=powerpc
689d21ab8bcSmrg		vendor=apple
690e5410a46Smrg		;;
691d21ab8bcSmrg
6921f0ac6a5Smrg	# Recognize the various machine names and aliases which stand
6931f0ac6a5Smrg	# for a CPU type and a company and sometimes even an OS.
6941f0ac6a5Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
695d21ab8bcSmrg		cpu=m68000
696d21ab8bcSmrg		vendor=att
6971f0ac6a5Smrg		;;
6981f0ac6a5Smrg	3b*)
699d21ab8bcSmrg		cpu=we32k
700d21ab8bcSmrg		vendor=att
701e5410a46Smrg		;;
7029c9ff80cSmrg	bluegene*)
703d21ab8bcSmrg		cpu=powerpc
704d21ab8bcSmrg		vendor=ibm
705d21ab8bcSmrg		basic_os=cnk
7061f0ac6a5Smrg		;;
7071f0ac6a5Smrg	decsystem10* | dec10*)
708d21ab8bcSmrg		cpu=pdp10
709d21ab8bcSmrg		vendor=dec
710d21ab8bcSmrg		basic_os=tops10
7111f0ac6a5Smrg		;;
7121f0ac6a5Smrg	decsystem20* | dec20*)
713d21ab8bcSmrg		cpu=pdp10
714d21ab8bcSmrg		vendor=dec
715d21ab8bcSmrg		basic_os=tops20
7161f0ac6a5Smrg		;;
7171f0ac6a5Smrg	delta | 3300 | motorola-3300 | motorola-delta \
7181f0ac6a5Smrg	      | 3300-motorola | delta-motorola)
719d21ab8bcSmrg		cpu=m68k
720d21ab8bcSmrg		vendor=motorola
7211f0ac6a5Smrg		;;
722d21ab8bcSmrg	dpx2*)
723d21ab8bcSmrg		cpu=m68k
724d21ab8bcSmrg		vendor=bull
725d21ab8bcSmrg		basic_os=sysv3
7261f0ac6a5Smrg		;;
7271f0ac6a5Smrg	encore | umax | mmax)
728d21ab8bcSmrg		cpu=ns32k
729d21ab8bcSmrg		vendor=encore
7301f0ac6a5Smrg		;;
731d21ab8bcSmrg	elxsi)
732d21ab8bcSmrg		cpu=elxsi
733d21ab8bcSmrg		vendor=elxsi
734d21ab8bcSmrg		basic_os=${basic_os:-bsd}
7351f0ac6a5Smrg		;;
7361f0ac6a5Smrg	fx2800)
737d21ab8bcSmrg		cpu=i860
738d21ab8bcSmrg		vendor=alliant
7391f0ac6a5Smrg		;;
7401f0ac6a5Smrg	genix)
741d21ab8bcSmrg		cpu=ns32k
742d21ab8bcSmrg		vendor=ns
7431f0ac6a5Smrg		;;
7441f0ac6a5Smrg	h3050r* | hiux*)
745d21ab8bcSmrg		cpu=hppa1.1
746d21ab8bcSmrg		vendor=hitachi
747d21ab8bcSmrg		basic_os=hiuxwe2
7481f0ac6a5Smrg		;;
7491f0ac6a5Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
750d21ab8bcSmrg		cpu=hppa1.0
751d21ab8bcSmrg		vendor=hp
7521f0ac6a5Smrg		;;
7531f0ac6a5Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
754d21ab8bcSmrg		cpu=m68000
755d21ab8bcSmrg		vendor=hp
7561f0ac6a5Smrg		;;
7571f0ac6a5Smrg	hp9k3[2-9][0-9])
758d21ab8bcSmrg		cpu=m68k
759d21ab8bcSmrg		vendor=hp
7601f0ac6a5Smrg		;;
7611f0ac6a5Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
762d21ab8bcSmrg		cpu=hppa1.0
763d21ab8bcSmrg		vendor=hp
7641f0ac6a5Smrg		;;
7651f0ac6a5Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
766d21ab8bcSmrg		cpu=hppa1.1
767d21ab8bcSmrg		vendor=hp
7681f0ac6a5Smrg		;;
7691f0ac6a5Smrg	hp9k78[0-9] | hp78[0-9])
7701f0ac6a5Smrg		# FIXME: really hppa2.0-hp
771d21ab8bcSmrg		cpu=hppa1.1
772d21ab8bcSmrg		vendor=hp
7731f0ac6a5Smrg		;;
7741f0ac6a5Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7751f0ac6a5Smrg		# FIXME: really hppa2.0-hp
776d21ab8bcSmrg		cpu=hppa1.1
777d21ab8bcSmrg		vendor=hp
7781f0ac6a5Smrg		;;
7791f0ac6a5Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
780d21ab8bcSmrg		cpu=hppa1.1
781d21ab8bcSmrg		vendor=hp
7821f0ac6a5Smrg		;;
7831f0ac6a5Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
784d21ab8bcSmrg		cpu=hppa1.0
785d21ab8bcSmrg		vendor=hp
7861f0ac6a5Smrg		;;
7871f0ac6a5Smrg	i*86v32)
788d21ab8bcSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
789d21ab8bcSmrg		vendor=pc
790d21ab8bcSmrg		basic_os=sysv32
7911f0ac6a5Smrg		;;
7921f0ac6a5Smrg	i*86v4*)
793d21ab8bcSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
794d21ab8bcSmrg		vendor=pc
795d21ab8bcSmrg		basic_os=sysv4
7961f0ac6a5Smrg		;;
7971f0ac6a5Smrg	i*86v)
798d21ab8bcSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
799d21ab8bcSmrg		vendor=pc
800d21ab8bcSmrg		basic_os=sysv
8011f0ac6a5Smrg		;;
8021f0ac6a5Smrg	i*86sol2)
803d21ab8bcSmrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
804d21ab8bcSmrg		vendor=pc
805d21ab8bcSmrg		basic_os=solaris2
8061f0ac6a5Smrg		;;
807d21ab8bcSmrg	j90 | j90-cray)
808d21ab8bcSmrg		cpu=j90
809d21ab8bcSmrg		vendor=cray
810d21ab8bcSmrg		basic_os=${basic_os:-unicos}
8111f0ac6a5Smrg		;;
8121f0ac6a5Smrg	iris | iris4d)
813d21ab8bcSmrg		cpu=mips
814d21ab8bcSmrg		vendor=sgi
815d21ab8bcSmrg		case $basic_os in
816d21ab8bcSmrg		    irix*)
8171f0ac6a5Smrg			;;
8181f0ac6a5Smrg		    *)
819d21ab8bcSmrg			basic_os=irix4
8201f0ac6a5Smrg			;;
8211f0ac6a5Smrg		esac
8221f0ac6a5Smrg		;;
8231f0ac6a5Smrg	miniframe)
824d21ab8bcSmrg		cpu=m68000
825d21ab8bcSmrg		vendor=convergent
8261f0ac6a5Smrg		;;
827d21ab8bcSmrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
828d21ab8bcSmrg		cpu=m68k
829d21ab8bcSmrg		vendor=atari
830d21ab8bcSmrg		basic_os=mint
8311f0ac6a5Smrg		;;
8321f0ac6a5Smrg	news-3600 | risc-news)
833d21ab8bcSmrg		cpu=mips
834d21ab8bcSmrg		vendor=sony
835d21ab8bcSmrg		basic_os=newsos
836d21ab8bcSmrg		;;
837d21ab8bcSmrg	next | m*-next)
838d21ab8bcSmrg		cpu=m68k
839d21ab8bcSmrg		vendor=next
840d21ab8bcSmrg		case $basic_os in
841d21ab8bcSmrg		    openstep*)
842d21ab8bcSmrg		        ;;
843d21ab8bcSmrg		    nextstep*)
8441f0ac6a5Smrg			;;
845d21ab8bcSmrg		    ns2*)
846d21ab8bcSmrg		      basic_os=nextstep2
8471f0ac6a5Smrg			;;
8481f0ac6a5Smrg		    *)
849d21ab8bcSmrg		      basic_os=nextstep3
8501f0ac6a5Smrg			;;
8511f0ac6a5Smrg		esac
8521f0ac6a5Smrg		;;
8531f0ac6a5Smrg	np1)
854d21ab8bcSmrg		cpu=np1
855d21ab8bcSmrg		vendor=gould
8561f0ac6a5Smrg		;;
8571f0ac6a5Smrg	op50n-* | op60c-*)
858d21ab8bcSmrg		cpu=hppa1.1
859d21ab8bcSmrg		vendor=oki
860d21ab8bcSmrg		basic_os=proelf
8611f0ac6a5Smrg		;;
8621f0ac6a5Smrg	pa-hitachi)
863d21ab8bcSmrg		cpu=hppa1.1
864d21ab8bcSmrg		vendor=hitachi
865d21ab8bcSmrg		basic_os=hiuxwe2
866e5410a46Smrg		;;
8671f0ac6a5Smrg	pbd)
868d21ab8bcSmrg		cpu=sparc
869d21ab8bcSmrg		vendor=tti
8701f0ac6a5Smrg		;;
8711f0ac6a5Smrg	pbb)
872d21ab8bcSmrg		cpu=m68k
873d21ab8bcSmrg		vendor=tti
874e5410a46Smrg		;;
875d21ab8bcSmrg	pc532)
876d21ab8bcSmrg		cpu=ns32k
877d21ab8bcSmrg		vendor=pc532
8781f0ac6a5Smrg		;;
8791f0ac6a5Smrg	pn)
880d21ab8bcSmrg		cpu=pn
881d21ab8bcSmrg		vendor=gould
8821f0ac6a5Smrg		;;
883d21ab8bcSmrg	power)
884d21ab8bcSmrg		cpu=power
885d21ab8bcSmrg		vendor=ibm
8861f0ac6a5Smrg		;;
8871f0ac6a5Smrg	ps2)
888d21ab8bcSmrg		cpu=i386
889d21ab8bcSmrg		vendor=ibm
8901f0ac6a5Smrg		;;
8911f0ac6a5Smrg	rm[46]00)
892d21ab8bcSmrg		cpu=mips
893d21ab8bcSmrg		vendor=siemens
8941f0ac6a5Smrg		;;
8951f0ac6a5Smrg	rtpc | rtpc-*)
896d21ab8bcSmrg		cpu=romp
897d21ab8bcSmrg		vendor=ibm
8981f0ac6a5Smrg		;;
899d21ab8bcSmrg	sde)
900d21ab8bcSmrg		cpu=mipsisa32
901d21ab8bcSmrg		vendor=sde
902d21ab8bcSmrg		basic_os=${basic_os:-elf}
9031f0ac6a5Smrg		;;
904d21ab8bcSmrg	simso-wrs)
905d21ab8bcSmrg		cpu=sparclite
906d21ab8bcSmrg		vendor=wrs
907d21ab8bcSmrg		basic_os=vxworks
9081f0ac6a5Smrg		;;
909d21ab8bcSmrg	tower | tower-32)
910d21ab8bcSmrg		cpu=m68k
911d21ab8bcSmrg		vendor=ncr
912e5410a46Smrg		;;
913d21ab8bcSmrg	vpp*|vx|vx-*)
914d21ab8bcSmrg		cpu=f301
915d21ab8bcSmrg		vendor=fujitsu
9161f0ac6a5Smrg		;;
917d21ab8bcSmrg	w65)
918d21ab8bcSmrg		cpu=w65
919d21ab8bcSmrg		vendor=wdc
9201f0ac6a5Smrg		;;
921d21ab8bcSmrg	w89k-*)
922d21ab8bcSmrg		cpu=hppa1.1
923d21ab8bcSmrg		vendor=winbond
924d21ab8bcSmrg		basic_os=proelf
9251f0ac6a5Smrg		;;
926d21ab8bcSmrg	none)
927d21ab8bcSmrg		cpu=none
928d21ab8bcSmrg		vendor=none
929e5410a46Smrg		;;
930d21ab8bcSmrg	leon|leon[3-9])
931d21ab8bcSmrg		cpu=sparc
932d21ab8bcSmrg		vendor=$basic_machine
9331f0ac6a5Smrg		;;
934d21ab8bcSmrg	leon-*|leon[3-9]-*)
935d21ab8bcSmrg		cpu=sparc
936d21ab8bcSmrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9371f0ac6a5Smrg		;;
938d21ab8bcSmrg
939d21ab8bcSmrg	*-*)
940d21ab8bcSmrg		# shellcheck disable=SC2162
941d21ab8bcSmrg		saved_IFS=$IFS
942d21ab8bcSmrg		IFS="-" read cpu vendor <<EOF
943d21ab8bcSmrg$basic_machine
944d21ab8bcSmrgEOF
945d21ab8bcSmrg		IFS=$saved_IFS
9461f0ac6a5Smrg		;;
9476ee7d557Smrg	# We use 'pc' rather than 'unknown'
948d21ab8bcSmrg	# because (1) that's what they normally are, and
949d21ab8bcSmrg	# (2) the word "unknown" tends to confuse beginning users.
950d21ab8bcSmrg	i*86 | x86_64)
951d21ab8bcSmrg		cpu=$basic_machine
952d21ab8bcSmrg		vendor=pc
9531f0ac6a5Smrg		;;
954d21ab8bcSmrg	# These rules are duplicated from below for sake of the special case above;
955d21ab8bcSmrg	# i.e. things that normalized to x86 arches should also default to "pc"
956d21ab8bcSmrg	pc98)
957d21ab8bcSmrg		cpu=i386
958d21ab8bcSmrg		vendor=pc
9591f0ac6a5Smrg		;;
960d21ab8bcSmrg	x64 | amd64)
961d21ab8bcSmrg		cpu=x86_64
962d21ab8bcSmrg		vendor=pc
9631f0ac6a5Smrg		;;
964d21ab8bcSmrg	# Recognize the basic CPU types without company name.
965d21ab8bcSmrg	*)
966d21ab8bcSmrg		cpu=$basic_machine
967d21ab8bcSmrg		vendor=unknown
96889c04b6cSmrg		;;
969d21ab8bcSmrgesac
970d21ab8bcSmrg
971d21ab8bcSmrgunset -v basic_machine
972d21ab8bcSmrg
973d21ab8bcSmrg# Decode basic machines in the full and proper CPU-Company form.
974d21ab8bcSmrgcase $cpu-$vendor in
975d21ab8bcSmrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
976d21ab8bcSmrg	# some cases the only manufacturer, in others, it is the most popular.
977d21ab8bcSmrg	craynv-unknown)
978d21ab8bcSmrg		vendor=cray
979d21ab8bcSmrg		basic_os=${basic_os:-unicosmp}
9801f0ac6a5Smrg		;;
981d21ab8bcSmrg	c90-unknown | c90-cray)
982d21ab8bcSmrg		vendor=cray
983d21ab8bcSmrg		basic_os=${Basic_os:-unicos}
9841f0ac6a5Smrg		;;
985d21ab8bcSmrg	fx80-unknown)
986d21ab8bcSmrg		vendor=alliant
9871f0ac6a5Smrg		;;
988d21ab8bcSmrg	romp-unknown)
989d21ab8bcSmrg		vendor=ibm
9901f0ac6a5Smrg		;;
991d21ab8bcSmrg	mmix-unknown)
992d21ab8bcSmrg		vendor=knuth
9931f0ac6a5Smrg		;;
994d21ab8bcSmrg	microblaze-unknown | microblazeel-unknown)
995d21ab8bcSmrg		vendor=xilinx
9961f0ac6a5Smrg		;;
997d21ab8bcSmrg	rs6000-unknown)
998d21ab8bcSmrg		vendor=ibm
9991f0ac6a5Smrg		;;
1000d21ab8bcSmrg	vax-unknown)
1001d21ab8bcSmrg		vendor=dec
10021f0ac6a5Smrg		;;
1003d21ab8bcSmrg	pdp11-unknown)
1004d21ab8bcSmrg		vendor=dec
10051f0ac6a5Smrg		;;
1006d21ab8bcSmrg	we32k-unknown)
1007d21ab8bcSmrg		vendor=att
10081f0ac6a5Smrg		;;
1009d21ab8bcSmrg	cydra-unknown)
1010d21ab8bcSmrg		vendor=cydrome
10111f0ac6a5Smrg		;;
1012d21ab8bcSmrg	i370-ibm*)
1013d21ab8bcSmrg		vendor=ibm
10141f0ac6a5Smrg		;;
1015d21ab8bcSmrg	orion-unknown)
1016d21ab8bcSmrg		vendor=highlevel
10171f0ac6a5Smrg		;;
1018d21ab8bcSmrg	xps-unknown | xps100-unknown)
1019d21ab8bcSmrg		cpu=xps100
1020d21ab8bcSmrg		vendor=honeywell
10211f0ac6a5Smrg		;;
1022d21ab8bcSmrg
1023d21ab8bcSmrg	# Here we normalize CPU types with a missing or matching vendor
10246ee7d557Smrg	armh-unknown | armh-alt)
10256ee7d557Smrg		cpu=armv7l
10266ee7d557Smrg		vendor=alt
10276ee7d557Smrg		basic_os=${basic_os:-linux-gnueabihf}
10286ee7d557Smrg		;;
1029d21ab8bcSmrg	dpx20-unknown | dpx20-bull)
1030d21ab8bcSmrg		cpu=rs6000
1031d21ab8bcSmrg		vendor=bull
1032d21ab8bcSmrg		basic_os=${basic_os:-bosx}
10331f0ac6a5Smrg		;;
1034d21ab8bcSmrg
1035d21ab8bcSmrg	# Here we normalize CPU types irrespective of the vendor
1036d21ab8bcSmrg	amd64-*)
1037d21ab8bcSmrg		cpu=x86_64
1038e5410a46Smrg		;;
1039d21ab8bcSmrg	blackfin-*)
1040d21ab8bcSmrg		cpu=bfin
1041d21ab8bcSmrg		basic_os=linux
10421f0ac6a5Smrg		;;
1043d21ab8bcSmrg	c54x-*)
1044d21ab8bcSmrg		cpu=tic54x
10451f0ac6a5Smrg		;;
1046d21ab8bcSmrg	c55x-*)
1047d21ab8bcSmrg		cpu=tic55x
10481f0ac6a5Smrg		;;
1049d21ab8bcSmrg	c6x-*)
1050d21ab8bcSmrg		cpu=tic6x
10511f0ac6a5Smrg		;;
1052d21ab8bcSmrg	e500v[12]-*)
1053d21ab8bcSmrg		cpu=powerpc
1054d21ab8bcSmrg		basic_os=${basic_os}"spe"
1055e5410a46Smrg		;;
1056d21ab8bcSmrg	mips3*-*)
1057d21ab8bcSmrg		cpu=mips64
10581f0ac6a5Smrg		;;
1059d21ab8bcSmrg	ms1-*)
1060d21ab8bcSmrg		cpu=mt
10611f0ac6a5Smrg		;;
1062d21ab8bcSmrg	m68knommu-*)
1063d21ab8bcSmrg		cpu=m68k
1064d21ab8bcSmrg		basic_os=linux
10651f0ac6a5Smrg		;;
1066d21ab8bcSmrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1067d21ab8bcSmrg		cpu=s12z
10681f0ac6a5Smrg		;;
1069d21ab8bcSmrg	openrisc-*)
1070d21ab8bcSmrg		cpu=or32
10711f0ac6a5Smrg		;;
1072d21ab8bcSmrg	parisc-*)
1073d21ab8bcSmrg		cpu=hppa
1074d21ab8bcSmrg		basic_os=linux
10751f0ac6a5Smrg		;;
1076d21ab8bcSmrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1077d21ab8bcSmrg		cpu=i586
10781f0ac6a5Smrg		;;
10796ee7d557Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1080d21ab8bcSmrg		cpu=i686
10811f0ac6a5Smrg		;;
1082d21ab8bcSmrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1083d21ab8bcSmrg		cpu=i686
10841f0ac6a5Smrg		;;
1085d21ab8bcSmrg	pentium4-*)
1086d21ab8bcSmrg		cpu=i786
10871f0ac6a5Smrg		;;
1088d21ab8bcSmrg	pc98-*)
1089d21ab8bcSmrg		cpu=i386
10901f0ac6a5Smrg		;;
1091d21ab8bcSmrg	ppc-* | ppcbe-*)
1092d21ab8bcSmrg		cpu=powerpc
1093e5410a46Smrg		;;
1094d21ab8bcSmrg	ppcle-* | powerpclittle-*)
1095d21ab8bcSmrg		cpu=powerpcle
10961f0ac6a5Smrg		;;
1097d21ab8bcSmrg	ppc64-*)
1098d21ab8bcSmrg		cpu=powerpc64
109989c04b6cSmrg		;;
1100d21ab8bcSmrg	ppc64le-* | powerpc64little-*)
1101d21ab8bcSmrg		cpu=powerpc64le
11021f0ac6a5Smrg		;;
1103d21ab8bcSmrg	sb1-*)
1104d21ab8bcSmrg		cpu=mipsisa64sb1
11051f0ac6a5Smrg		;;
1106d21ab8bcSmrg	sb1el-*)
1107d21ab8bcSmrg		cpu=mipsisa64sb1el
11089c9ff80cSmrg		;;
1109d21ab8bcSmrg	sh5e[lb]-*)
1110d21ab8bcSmrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11111f0ac6a5Smrg		;;
1112d21ab8bcSmrg	spur-*)
1113d21ab8bcSmrg		cpu=spur
11141f0ac6a5Smrg		;;
1115d21ab8bcSmrg	strongarm-* | thumb-*)
1116d21ab8bcSmrg		cpu=arm
11171f0ac6a5Smrg		;;
1118d21ab8bcSmrg	tx39-*)
1119d21ab8bcSmrg		cpu=mipstx39
11201f0ac6a5Smrg		;;
1121d21ab8bcSmrg	tx39el-*)
1122d21ab8bcSmrg		cpu=mipstx39el
11231f0ac6a5Smrg		;;
1124d21ab8bcSmrg	x64-*)
1125d21ab8bcSmrg		cpu=x86_64
1126e5410a46Smrg		;;
1127d21ab8bcSmrg	xscale-* | xscalee[bl]-*)
1128d21ab8bcSmrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11291f0ac6a5Smrg		;;
11306ee7d557Smrg	arm64-* | aarch64le-*)
1131d21ab8bcSmrg		cpu=aarch64
11321f0ac6a5Smrg		;;
1133d21ab8bcSmrg
1134d21ab8bcSmrg	# Recognize the canonical CPU Types that limit and/or modify the
1135d21ab8bcSmrg	# company names they are paired with.
1136d21ab8bcSmrg	cr16-*)
1137d21ab8bcSmrg		basic_os=${basic_os:-elf}
11381f0ac6a5Smrg		;;
1139d21ab8bcSmrg	crisv32-* | etraxfs*-*)
1140d21ab8bcSmrg		cpu=crisv32
1141d21ab8bcSmrg		vendor=axis
11421f0ac6a5Smrg		;;
1143d21ab8bcSmrg	cris-* | etrax*-*)
1144d21ab8bcSmrg		cpu=cris
1145d21ab8bcSmrg		vendor=axis
11461f0ac6a5Smrg		;;
1147d21ab8bcSmrg	crx-*)
1148d21ab8bcSmrg		basic_os=${basic_os:-elf}
11491f0ac6a5Smrg		;;
1150d21ab8bcSmrg	neo-tandem)
1151d21ab8bcSmrg		cpu=neo
1152d21ab8bcSmrg		vendor=tandem
11531f0ac6a5Smrg		;;
1154d21ab8bcSmrg	nse-tandem)
1155d21ab8bcSmrg		cpu=nse
1156d21ab8bcSmrg		vendor=tandem
11571f0ac6a5Smrg		;;
1158d21ab8bcSmrg	nsr-tandem)
1159d21ab8bcSmrg		cpu=nsr
1160d21ab8bcSmrg		vendor=tandem
11611f0ac6a5Smrg		;;
1162d21ab8bcSmrg	nsv-tandem)
1163d21ab8bcSmrg		cpu=nsv
1164d21ab8bcSmrg		vendor=tandem
11651f0ac6a5Smrg		;;
1166d21ab8bcSmrg	nsx-tandem)
1167d21ab8bcSmrg		cpu=nsx
1168d21ab8bcSmrg		vendor=tandem
11691f0ac6a5Smrg		;;
1170d21ab8bcSmrg	mipsallegrexel-sony)
1171d21ab8bcSmrg		cpu=mipsallegrexel
1172d21ab8bcSmrg		vendor=sony
11731f0ac6a5Smrg		;;
1174d21ab8bcSmrg	tile*-*)
1175d21ab8bcSmrg		basic_os=${basic_os:-linux-gnu}
11761f0ac6a5Smrg		;;
1177d21ab8bcSmrg
11781f0ac6a5Smrg	*)
1179d21ab8bcSmrg		# Recognize the canonical CPU types that are allowed with any
1180d21ab8bcSmrg		# company name.
1181d21ab8bcSmrg		case $cpu in
1182d21ab8bcSmrg			1750a | 580 \
1183d21ab8bcSmrg			| a29k \
11846ee7d557Smrg			| aarch64 | aarch64_be | aarch64c | arm64ec \
1185d21ab8bcSmrg			| abacus \
1186d21ab8bcSmrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1187d21ab8bcSmrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1188d21ab8bcSmrg			| alphapca5[67] | alpha64pca5[67] \
1189d21ab8bcSmrg			| am33_2.0 \
1190d21ab8bcSmrg			| amdgcn \
1191d21ab8bcSmrg			| arc | arceb | arc32 | arc64 \
1192d21ab8bcSmrg			| arm | arm[lb]e | arme[lb] | armv* \
1193d21ab8bcSmrg			| avr | avr32 \
1194d21ab8bcSmrg			| asmjs \
1195d21ab8bcSmrg			| ba \
1196d21ab8bcSmrg			| be32 | be64 \
1197d21ab8bcSmrg			| bfin | bpf | bs2000 \
1198d21ab8bcSmrg			| c[123]* | c30 | [cjt]90 | c4x \
1199d21ab8bcSmrg			| c8051 | clipper | craynv | csky | cydra \
1200d21ab8bcSmrg			| d10v | d30v | dlx | dsp16xx \
1201d21ab8bcSmrg			| e2k | elxsi | epiphany \
1202d21ab8bcSmrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12036ee7d557Smrg			| javascript \
1204d21ab8bcSmrg			| h8300 | h8500 \
1205d21ab8bcSmrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1206d21ab8bcSmrg			| hexagon \
1207d21ab8bcSmrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1208d21ab8bcSmrg			| ip2k | iq2000 \
1209d21ab8bcSmrg			| k1om \
12106ee7d557Smrg			| kvx \
1211d21ab8bcSmrg			| le32 | le64 \
1212d21ab8bcSmrg			| lm32 \
12136ee7d557Smrg			| loongarch32 | loongarch64 \
1214d21ab8bcSmrg			| m32c | m32r | m32rle \
1215d21ab8bcSmrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1216d21ab8bcSmrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1217d21ab8bcSmrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1218d21ab8bcSmrg			| microblaze | microblazeel \
12196ee7d557Smrg			| mips* \
1220d21ab8bcSmrg			| mmix \
1221d21ab8bcSmrg			| mn10200 | mn10300 \
1222d21ab8bcSmrg			| moxie \
1223d21ab8bcSmrg			| mt \
1224d21ab8bcSmrg			| msp430 \
12256ee7d557Smrg			| nanomips* \
1226d21ab8bcSmrg			| nds32 | nds32le | nds32be \
1227d21ab8bcSmrg			| nfp \
1228d21ab8bcSmrg			| nios | nios2 | nios2eb | nios2el \
1229d21ab8bcSmrg			| none | np1 | ns16k | ns32k | nvptx \
1230d21ab8bcSmrg			| open8 \
1231d21ab8bcSmrg			| or1k* \
1232d21ab8bcSmrg			| or32 \
1233d21ab8bcSmrg			| orion \
1234d21ab8bcSmrg			| picochip \
1235d21ab8bcSmrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1236d21ab8bcSmrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1237d21ab8bcSmrg			| pru \
1238d21ab8bcSmrg			| pyramid \
1239d21ab8bcSmrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1240d21ab8bcSmrg			| rl78 | romp | rs6000 | rx \
1241d21ab8bcSmrg			| s390 | s390x \
1242d21ab8bcSmrg			| score \
1243d21ab8bcSmrg			| sh | shl \
1244d21ab8bcSmrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1245d21ab8bcSmrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1246d21ab8bcSmrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1247d21ab8bcSmrg			| sparclite \
1248d21ab8bcSmrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1249d21ab8bcSmrg			| spu \
1250d21ab8bcSmrg			| tahoe \
1251d21ab8bcSmrg			| thumbv7* \
1252d21ab8bcSmrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1253d21ab8bcSmrg			| tron \
1254d21ab8bcSmrg			| ubicom32 \
1255d21ab8bcSmrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1256d21ab8bcSmrg			| vax \
12576ee7d557Smrg			| vc4 \
1258d21ab8bcSmrg			| visium \
1259d21ab8bcSmrg			| w65 \
1260d21ab8bcSmrg			| wasm32 | wasm64 \
1261d21ab8bcSmrg			| we32k \
1262d21ab8bcSmrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1263d21ab8bcSmrg			| xstormy16 | xtensa* \
1264d21ab8bcSmrg			| ymp \
1265d21ab8bcSmrg			| z8k | z80)
1266d21ab8bcSmrg				;;
1267d21ab8bcSmrg
1268d21ab8bcSmrg			*)
12696ee7d557Smrg				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1270d21ab8bcSmrg				exit 1
1271d21ab8bcSmrg				;;
1272d21ab8bcSmrg		esac
12731f0ac6a5Smrg		;;
12741f0ac6a5Smrgesac
12751f0ac6a5Smrg
12761f0ac6a5Smrg# Here we canonicalize certain aliases for manufacturers.
1277d21ab8bcSmrgcase $vendor in
1278d21ab8bcSmrg	digital*)
1279d21ab8bcSmrg		vendor=dec
12801f0ac6a5Smrg		;;
1281d21ab8bcSmrg	commodore*)
1282d21ab8bcSmrg		vendor=cbm
12831f0ac6a5Smrg		;;
12841f0ac6a5Smrg	*)
12851f0ac6a5Smrg		;;
12861f0ac6a5Smrgesac
12871f0ac6a5Smrg
12881f0ac6a5Smrg# Decode manufacturer-specific aliases for certain operating systems.
12891f0ac6a5Smrg
12906ee7d557Smrgif test x"$basic_os" != x
12911f0ac6a5Smrgthen
1292d21ab8bcSmrg
12936ee7d557Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1294d21ab8bcSmrg# set os.
12956ee7d557Smrgobj=
1296d21ab8bcSmrgcase $basic_os in
1297d21ab8bcSmrg	gnu/linux*)
1298d21ab8bcSmrg		kernel=linux
1299d21ab8bcSmrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1300d21ab8bcSmrg		;;
1301d21ab8bcSmrg	os2-emx)
1302d21ab8bcSmrg		kernel=os2
1303d21ab8bcSmrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1304d21ab8bcSmrg		;;
1305d21ab8bcSmrg	nto-qnx*)
1306d21ab8bcSmrg		kernel=nto
1307d21ab8bcSmrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1308d21ab8bcSmrg		;;
1309d21ab8bcSmrg	*-*)
1310d21ab8bcSmrg		# shellcheck disable=SC2162
1311d21ab8bcSmrg		saved_IFS=$IFS
1312d21ab8bcSmrg		IFS="-" read kernel os <<EOF
1313d21ab8bcSmrg$basic_os
1314d21ab8bcSmrgEOF
1315d21ab8bcSmrg		IFS=$saved_IFS
1316d21ab8bcSmrg		;;
1317d21ab8bcSmrg	# Default OS when just kernel was specified
1318d21ab8bcSmrg	nto*)
1319d21ab8bcSmrg		kernel=nto
1320d21ab8bcSmrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1321d21ab8bcSmrg		;;
1322d21ab8bcSmrg	linux*)
1323d21ab8bcSmrg		kernel=linux
1324d21ab8bcSmrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1325d21ab8bcSmrg		;;
13266ee7d557Smrg	managarm*)
13276ee7d557Smrg		kernel=managarm
13286ee7d557Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13296ee7d557Smrg		;;
1330d21ab8bcSmrg	*)
1331d21ab8bcSmrg		kernel=
1332d21ab8bcSmrg		os=$basic_os
1333d21ab8bcSmrg		;;
1334d21ab8bcSmrgesac
1335d21ab8bcSmrg
1336d21ab8bcSmrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1337d21ab8bcSmrg# etc.)
13381f0ac6a5Smrgcase $os in
1339d21ab8bcSmrg	# First match some system type aliases that might get confused
1340d21ab8bcSmrg	# with valid system types.
1341d21ab8bcSmrg	# solaris* is a basic system type, with this one exception.
1342d21ab8bcSmrg	auroraux)
1343d21ab8bcSmrg		os=auroraux
13449c9ff80cSmrg		;;
1345d21ab8bcSmrg	bluegene*)
1346d21ab8bcSmrg		os=cnk
13471f0ac6a5Smrg		;;
1348d21ab8bcSmrg	solaris1 | solaris1.*)
1349d21ab8bcSmrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13501f0ac6a5Smrg		;;
1351d21ab8bcSmrg	solaris)
1352d21ab8bcSmrg		os=solaris2
13531f0ac6a5Smrg		;;
1354d21ab8bcSmrg	unixware*)
1355d21ab8bcSmrg		os=sysv4.2uw
13561f0ac6a5Smrg		;;
1357d21ab8bcSmrg	# es1800 is here to avoid being matched by es* (a different OS)
1358d21ab8bcSmrg	es1800*)
1359d21ab8bcSmrg		os=ose
13601f0ac6a5Smrg		;;
1361d21ab8bcSmrg	# Some version numbers need modification
1362d21ab8bcSmrg	chorusos*)
1363d21ab8bcSmrg		os=chorusos
13641f0ac6a5Smrg		;;
1365d21ab8bcSmrg	isc)
1366d21ab8bcSmrg		os=isc2.2
13671f0ac6a5Smrg		;;
1368d21ab8bcSmrg	sco6)
1369d21ab8bcSmrg		os=sco5v6
13701f0ac6a5Smrg		;;
1371d21ab8bcSmrg	sco5)
1372d21ab8bcSmrg		os=sco3.2v5
13731f0ac6a5Smrg		;;
1374d21ab8bcSmrg	sco4)
1375d21ab8bcSmrg		os=sco3.2v4
13761f0ac6a5Smrg		;;
1377d21ab8bcSmrg	sco3.2.[4-9]*)
1378d21ab8bcSmrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1379e5410a46Smrg		;;
1380d21ab8bcSmrg	sco*v* | scout)
1381d21ab8bcSmrg		# Don't match below
13821f0ac6a5Smrg		;;
1383d21ab8bcSmrg	sco*)
1384d21ab8bcSmrg		os=sco3.2v2
13851f0ac6a5Smrg		;;
1386d21ab8bcSmrg	psos*)
1387d21ab8bcSmrg		os=psos
13881f0ac6a5Smrg		;;
1389d21ab8bcSmrg	qnx*)
1390d21ab8bcSmrg		os=qnx
13911f0ac6a5Smrg		;;
1392d21ab8bcSmrg	hiux*)
1393d21ab8bcSmrg		os=hiuxwe2
1394e5410a46Smrg		;;
1395d21ab8bcSmrg	lynx*178)
1396d21ab8bcSmrg		os=lynxos178
13971f0ac6a5Smrg		;;
1398d21ab8bcSmrg	lynx*5)
1399d21ab8bcSmrg		os=lynxos5
14001f0ac6a5Smrg		;;
1401d21ab8bcSmrg	lynxos*)
1402d21ab8bcSmrg		# don't get caught up in next wildcard
14031f0ac6a5Smrg		;;
1404d21ab8bcSmrg	lynx*)
1405d21ab8bcSmrg		os=lynxos
14061f0ac6a5Smrg		;;
1407d21ab8bcSmrg	mac[0-9]*)
1408d21ab8bcSmrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14091f0ac6a5Smrg		;;
1410d21ab8bcSmrg	opened*)
1411d21ab8bcSmrg		os=openedition
14121f0ac6a5Smrg		;;
1413d21ab8bcSmrg	os400*)
1414d21ab8bcSmrg		os=os400
14151f0ac6a5Smrg		;;
1416d21ab8bcSmrg	sunos5*)
1417d21ab8bcSmrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1418e5410a46Smrg		;;
1419d21ab8bcSmrg	sunos6*)
1420d21ab8bcSmrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14211f0ac6a5Smrg		;;
1422d21ab8bcSmrg	wince*)
1423d21ab8bcSmrg		os=wince
14241f0ac6a5Smrg		;;
1425d21ab8bcSmrg	utek*)
1426d21ab8bcSmrg		os=bsd
14271f0ac6a5Smrg		;;
1428d21ab8bcSmrg	dynix*)
1429d21ab8bcSmrg		os=bsd
14301f0ac6a5Smrg		;;
1431d21ab8bcSmrg	acis*)
1432d21ab8bcSmrg		os=aos
14331f0ac6a5Smrg		;;
1434d21ab8bcSmrg	atheos*)
1435d21ab8bcSmrg		os=atheos
14361f0ac6a5Smrg		;;
1437d21ab8bcSmrg	syllable*)
1438d21ab8bcSmrg		os=syllable
14391f0ac6a5Smrg		;;
1440d21ab8bcSmrg	386bsd)
1441d21ab8bcSmrg		os=bsd
1442e5410a46Smrg		;;
1443d21ab8bcSmrg	ctix* | uts*)
1444d21ab8bcSmrg		os=sysv
14451f0ac6a5Smrg		;;
1446d21ab8bcSmrg	nova*)
1447d21ab8bcSmrg		os=rtmk-nova
14481f0ac6a5Smrg		;;
1449d21ab8bcSmrg	ns2)
1450d21ab8bcSmrg		os=nextstep2
14511f0ac6a5Smrg		;;
1452d21ab8bcSmrg	# Preserve the version number of sinix5.
1453d21ab8bcSmrg	sinix5.*)
1454d21ab8bcSmrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14551f0ac6a5Smrg		;;
1456d21ab8bcSmrg	sinix*)
1457d21ab8bcSmrg		os=sysv4
14581f0ac6a5Smrg		;;
1459d21ab8bcSmrg	tpf*)
1460d21ab8bcSmrg		os=tpf
14611f0ac6a5Smrg		;;
1462d21ab8bcSmrg	triton*)
1463d21ab8bcSmrg		os=sysv3
14641f0ac6a5Smrg		;;
1465d21ab8bcSmrg	oss*)
1466d21ab8bcSmrg		os=sysv3
14671f0ac6a5Smrg		;;
1468d21ab8bcSmrg	svr4*)
1469d21ab8bcSmrg		os=sysv4
14701f0ac6a5Smrg		;;
1471d21ab8bcSmrg	svr3)
1472d21ab8bcSmrg		os=sysv3
14731f0ac6a5Smrg		;;
1474d21ab8bcSmrg	sysvr4)
1475d21ab8bcSmrg		os=sysv4
14761f0ac6a5Smrg		;;
1477d21ab8bcSmrg	ose*)
1478d21ab8bcSmrg		os=ose
1479e5410a46Smrg		;;
1480d21ab8bcSmrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1481d21ab8bcSmrg		os=mint
14829c9ff80cSmrg		;;
1483d21ab8bcSmrg	dicos*)
1484d21ab8bcSmrg		os=dicos
148589c04b6cSmrg		;;
1486d21ab8bcSmrg	pikeos*)
1487d21ab8bcSmrg		# Until real need of OS specific support for
1488d21ab8bcSmrg		# particular features comes up, bare metal
1489d21ab8bcSmrg		# configurations are quite functional.
1490d21ab8bcSmrg		case $cpu in
1491d21ab8bcSmrg		    arm*)
1492d21ab8bcSmrg			os=eabi
1493d21ab8bcSmrg			;;
1494d21ab8bcSmrg		    *)
14956ee7d557Smrg			os=
14966ee7d557Smrg			obj=elf
1497d21ab8bcSmrg			;;
1498d21ab8bcSmrg		esac
14991f0ac6a5Smrg		;;
15006ee7d557Smrg	aout* | coff* | elf* | pe*)
15016ee7d557Smrg		# These are machine code file formats, not OSes
15026ee7d557Smrg		obj=$os
15036ee7d557Smrg		os=
15046ee7d557Smrg		;;
15051f0ac6a5Smrg	*)
1506d21ab8bcSmrg		# No normalization, but not necessarily accepted, that comes below.
15071f0ac6a5Smrg		;;
15081f0ac6a5Smrgesac
1509d21ab8bcSmrg
15101f0ac6a5Smrgelse
15111f0ac6a5Smrg
15121f0ac6a5Smrg# Here we handle the default operating systems that come with various machines.
15131f0ac6a5Smrg# The value should be what the vendor currently ships out the door with their
15141f0ac6a5Smrg# machine or put another way, the most popular os provided with the machine.
15151f0ac6a5Smrg
15161f0ac6a5Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15171f0ac6a5Smrg# "-sun"), then you have to tell the case statement up towards the top
15181f0ac6a5Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15191f0ac6a5Smrg# will signal an error saying that MANUFACTURER isn't an operating
15201f0ac6a5Smrg# system, and we'll never get to this point.
15211f0ac6a5Smrg
1522d21ab8bcSmrgkernel=
15236ee7d557Smrgobj=
1524d21ab8bcSmrgcase $cpu-$vendor in
152589c04b6cSmrg	score-*)
15266ee7d557Smrg		os=
15276ee7d557Smrg		obj=elf
1528e5410a46Smrg		;;
152989c04b6cSmrg	spu-*)
15306ee7d557Smrg		os=
15316ee7d557Smrg		obj=elf
1532e5410a46Smrg		;;
15331f0ac6a5Smrg	*-acorn)
1534d21ab8bcSmrg		os=riscix1.2
15351f0ac6a5Smrg		;;
15361f0ac6a5Smrg	arm*-rebel)
1537d21ab8bcSmrg		kernel=linux
1538d21ab8bcSmrg		os=gnu
15391f0ac6a5Smrg		;;
15401f0ac6a5Smrg	arm*-semi)
15416ee7d557Smrg		os=
15426ee7d557Smrg		obj=aout
15431f0ac6a5Smrg		;;
154489c04b6cSmrg	c4x-* | tic4x-*)
15456ee7d557Smrg		os=
15466ee7d557Smrg		obj=coff
154789c04b6cSmrg		;;
1548b9867631Smrg	c8051-*)
15496ee7d557Smrg		os=
15506ee7d557Smrg		obj=elf
1551d21ab8bcSmrg		;;
1552d21ab8bcSmrg	clipper-intergraph)
1553d21ab8bcSmrg		os=clix
1554b9867631Smrg		;;
155589c04b6cSmrg	hexagon-*)
15566ee7d557Smrg		os=
15576ee7d557Smrg		obj=elf
1558e5410a46Smrg		;;
15596fae4e5dSmrg	tic54x-*)
15606ee7d557Smrg		os=
15616ee7d557Smrg		obj=coff
15626fae4e5dSmrg		;;
15636fae4e5dSmrg	tic55x-*)
15646ee7d557Smrg		os=
15656ee7d557Smrg		obj=coff
15666fae4e5dSmrg		;;
15676fae4e5dSmrg	tic6x-*)
15686ee7d557Smrg		os=
15696ee7d557Smrg		obj=coff
15706fae4e5dSmrg		;;
15711f0ac6a5Smrg	# This must come before the *-dec entry.
15721f0ac6a5Smrg	pdp10-*)
1573d21ab8bcSmrg		os=tops20
15741f0ac6a5Smrg		;;
15751f0ac6a5Smrg	pdp11-*)
1576d21ab8bcSmrg		os=none
15771f0ac6a5Smrg		;;
15781f0ac6a5Smrg	*-dec | vax-*)
1579d21ab8bcSmrg		os=ultrix4.2
15801f0ac6a5Smrg		;;
15811f0ac6a5Smrg	m68*-apollo)
1582d21ab8bcSmrg		os=domain
15831f0ac6a5Smrg		;;
15841f0ac6a5Smrg	i386-sun)
1585d21ab8bcSmrg		os=sunos4.0.2
15861f0ac6a5Smrg		;;
15871f0ac6a5Smrg	m68000-sun)
1588d21ab8bcSmrg		os=sunos3
15891f0ac6a5Smrg		;;
15901f0ac6a5Smrg	m68*-cisco)
15916ee7d557Smrg		os=
15926ee7d557Smrg		obj=aout
15931f0ac6a5Smrg		;;
159489c04b6cSmrg	mep-*)
15956ee7d557Smrg		os=
15966ee7d557Smrg		obj=elf
1597e5410a46Smrg		;;
15981f0ac6a5Smrg	mips*-cisco)
15996ee7d557Smrg		os=
16006ee7d557Smrg		obj=elf
16011f0ac6a5Smrg		;;
16026ee7d557Smrg	mips*-*|nanomips*-*)
16036ee7d557Smrg		os=
16046ee7d557Smrg		obj=elf
16052fd96bc7Smrg		;;
16061f0ac6a5Smrg	or32-*)
16076ee7d557Smrg		os=
16086ee7d557Smrg		obj=coff
16091f0ac6a5Smrg		;;
16101f0ac6a5Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1611d21ab8bcSmrg		os=sysv3
16121f0ac6a5Smrg		;;
16131f0ac6a5Smrg	sparc-* | *-sun)
1614d21ab8bcSmrg		os=sunos4.1.1
16151f0ac6a5Smrg		;;
1616d21ab8bcSmrg	pru-*)
16176ee7d557Smrg		os=
16186ee7d557Smrg		obj=elf
16191f0ac6a5Smrg		;;
1620d21ab8bcSmrg	*-be)
1621d21ab8bcSmrg		os=beos
1622e5410a46Smrg		;;
16231f0ac6a5Smrg	*-ibm)
1624d21ab8bcSmrg		os=aix
16251f0ac6a5Smrg		;;
162689c04b6cSmrg	*-knuth)
1627d21ab8bcSmrg		os=mmixware
1628e5410a46Smrg		;;
16291f0ac6a5Smrg	*-wec)
1630d21ab8bcSmrg		os=proelf
16311f0ac6a5Smrg		;;
16321f0ac6a5Smrg	*-winbond)
1633d21ab8bcSmrg		os=proelf
16341f0ac6a5Smrg		;;
16351f0ac6a5Smrg	*-oki)
1636d21ab8bcSmrg		os=proelf
16371f0ac6a5Smrg		;;
16381f0ac6a5Smrg	*-hp)
1639d21ab8bcSmrg		os=hpux
16401f0ac6a5Smrg		;;
16411f0ac6a5Smrg	*-hitachi)
1642d21ab8bcSmrg		os=hiux
16431f0ac6a5Smrg		;;
16441f0ac6a5Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1645d21ab8bcSmrg		os=sysv
16461f0ac6a5Smrg		;;
16471f0ac6a5Smrg	*-cbm)
1648d21ab8bcSmrg		os=amigaos
16491f0ac6a5Smrg		;;
16501f0ac6a5Smrg	*-dg)
1651d21ab8bcSmrg		os=dgux
16521f0ac6a5Smrg		;;
16531f0ac6a5Smrg	*-dolphin)
1654d21ab8bcSmrg		os=sysv3
16551f0ac6a5Smrg		;;
16561f0ac6a5Smrg	m68k-ccur)
1657d21ab8bcSmrg		os=rtu
16581f0ac6a5Smrg		;;
16591f0ac6a5Smrg	m88k-omron*)
1660d21ab8bcSmrg		os=luna
16611f0ac6a5Smrg		;;
1662d21ab8bcSmrg	*-next)
1663d21ab8bcSmrg		os=nextstep
16641f0ac6a5Smrg		;;
16651f0ac6a5Smrg	*-sequent)
1666d21ab8bcSmrg		os=ptx
16671f0ac6a5Smrg		;;
16681f0ac6a5Smrg	*-crds)
1669d21ab8bcSmrg		os=unos
16701f0ac6a5Smrg		;;
16711f0ac6a5Smrg	*-ns)
1672d21ab8bcSmrg		os=genix
16731f0ac6a5Smrg		;;
16741f0ac6a5Smrg	i370-*)
1675d21ab8bcSmrg		os=mvs
16761f0ac6a5Smrg		;;
16771f0ac6a5Smrg	*-gould)
1678d21ab8bcSmrg		os=sysv
16791f0ac6a5Smrg		;;
16801f0ac6a5Smrg	*-highlevel)
1681d21ab8bcSmrg		os=bsd
16821f0ac6a5Smrg		;;
16831f0ac6a5Smrg	*-encore)
1684d21ab8bcSmrg		os=bsd
16851f0ac6a5Smrg		;;
16861f0ac6a5Smrg	*-sgi)
1687d21ab8bcSmrg		os=irix
16881f0ac6a5Smrg		;;
16891f0ac6a5Smrg	*-siemens)
1690d21ab8bcSmrg		os=sysv4
16911f0ac6a5Smrg		;;
16921f0ac6a5Smrg	*-masscomp)
1693d21ab8bcSmrg		os=rtu
16941f0ac6a5Smrg		;;
16951f0ac6a5Smrg	f30[01]-fujitsu | f700-fujitsu)
1696d21ab8bcSmrg		os=uxpv
16971f0ac6a5Smrg		;;
16981f0ac6a5Smrg	*-rom68k)
16996ee7d557Smrg		os=
17006ee7d557Smrg		obj=coff
17011f0ac6a5Smrg		;;
17021f0ac6a5Smrg	*-*bug)
17036ee7d557Smrg		os=
17046ee7d557Smrg		obj=coff
17051f0ac6a5Smrg		;;
17061f0ac6a5Smrg	*-apple)
1707d21ab8bcSmrg		os=macos
17081f0ac6a5Smrg		;;
17091f0ac6a5Smrg	*-atari*)
1710d21ab8bcSmrg		os=mint
1711d21ab8bcSmrg		;;
1712d21ab8bcSmrg	*-wrs)
1713d21ab8bcSmrg		os=vxworks
17141f0ac6a5Smrg		;;
17151f0ac6a5Smrg	*)
1716d21ab8bcSmrg		os=none
17171f0ac6a5Smrg		;;
17181f0ac6a5Smrgesac
1719d21ab8bcSmrg
17201f0ac6a5Smrgfi
17211f0ac6a5Smrg
17226ee7d557Smrg# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
17236ee7d557Smrg
1724d21ab8bcSmrgcase $os in
1725d21ab8bcSmrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17266ee7d557Smrg	llvm* | musl* | newlib* | relibc* | uclibc*)
1727d21ab8bcSmrg		;;
1728d21ab8bcSmrg	# Likewise for "kernel-abi"
1729d21ab8bcSmrg	eabi* | gnueabi*)
1730d21ab8bcSmrg		;;
1731d21ab8bcSmrg	# VxWorks passes extra cpu info in the 4th filed.
1732d21ab8bcSmrg	simlinux | simwindows | spe)
1733d21ab8bcSmrg		;;
17346ee7d557Smrg	# See `case $cpu-$os` validation below
17356ee7d557Smrg	ghcjs)
17366ee7d557Smrg		;;
1737d21ab8bcSmrg	# Now accept the basic system types.
1738d21ab8bcSmrg	# The portable systems comes first.
1739d21ab8bcSmrg	# Each alternative MUST end in a * to match a version number.
1740d21ab8bcSmrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1741d21ab8bcSmrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1742d21ab8bcSmrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1743d21ab8bcSmrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1744d21ab8bcSmrg	     | hiux* | abug | nacl* | netware* | windows* \
17456ee7d557Smrg	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
1746d21ab8bcSmrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1747d21ab8bcSmrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1748d21ab8bcSmrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1749d21ab8bcSmrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1750d21ab8bcSmrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1751d21ab8bcSmrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1752d21ab8bcSmrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1753d21ab8bcSmrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17546ee7d557Smrg	     | bosx* | nextstep* | cxux* | oabi* \
17556ee7d557Smrg	     | ptx* | ecoff* | winnt* | domain* | vsta* \
1756d21ab8bcSmrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1757d21ab8bcSmrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17586ee7d557Smrg	     | cygwin* | msys* | moss* | proelf* | rtems* \
1759d21ab8bcSmrg	     | midipix* | mingw32* | mingw64* | mint* \
1760d21ab8bcSmrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1761d21ab8bcSmrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1762d21ab8bcSmrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1763d21ab8bcSmrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1764d21ab8bcSmrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1765d21ab8bcSmrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1766d21ab8bcSmrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1767d21ab8bcSmrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1768d21ab8bcSmrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1769d21ab8bcSmrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17706ee7d557Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17716ee7d557Smrg	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
1772d21ab8bcSmrg		;;
1773d21ab8bcSmrg	# This one is extra strict with allowed versions
1774d21ab8bcSmrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1775d21ab8bcSmrg		# Don't forget version if it is 3.2v4 or newer.
1776d21ab8bcSmrg		;;
17776ee7d557Smrg	# This refers to builds using the UEFI calling convention
17786ee7d557Smrg	# (which depends on the architecture) and PE file format.
17796ee7d557Smrg	# Note that this is both a different calling convention and
17806ee7d557Smrg	# different file format than that of GNU-EFI
17816ee7d557Smrg	# (x86_64-w64-mingw32).
17826ee7d557Smrg	uefi)
17836ee7d557Smrg		;;
1784d21ab8bcSmrg	none)
1785d21ab8bcSmrg		;;
17866ee7d557Smrg	kernel* | msvc* )
17876ee7d557Smrg		# Restricted further below
17886ee7d557Smrg		;;
17896ee7d557Smrg	'')
17906ee7d557Smrg		if test x"$obj" = x
17916ee7d557Smrg		then
17926ee7d557Smrg			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
17936ee7d557Smrg		fi
17946ee7d557Smrg		;;
1795d21ab8bcSmrg	*)
17966ee7d557Smrg		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
17976ee7d557Smrg		exit 1
17986ee7d557Smrg		;;
17996ee7d557Smrgesac
18006ee7d557Smrg
18016ee7d557Smrgcase $obj in
18026ee7d557Smrg	aout* | coff* | elf* | pe*)
18036ee7d557Smrg		;;
18046ee7d557Smrg	'')
18056ee7d557Smrg		# empty is fine
18066ee7d557Smrg		;;
18076ee7d557Smrg	*)
18086ee7d557Smrg		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
18096ee7d557Smrg		exit 1
18106ee7d557Smrg		;;
18116ee7d557Smrgesac
18126ee7d557Smrg
18136ee7d557Smrg# Here we handle the constraint that a (synthetic) cpu and os are
18146ee7d557Smrg# valid only in combination with each other and nowhere else.
18156ee7d557Smrgcase $cpu-$os in
18166ee7d557Smrg	# The "javascript-unknown-ghcjs" triple is used by GHC; we
18176ee7d557Smrg	# accept it here in order to tolerate that, but reject any
18186ee7d557Smrg	# variations.
18196ee7d557Smrg	javascript-ghcjs)
18206ee7d557Smrg		;;
18216ee7d557Smrg	javascript-* | *-ghcjs)
18226ee7d557Smrg		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
1823d21ab8bcSmrg		exit 1
1824d21ab8bcSmrg		;;
1825d21ab8bcSmrgesac
1826d21ab8bcSmrg
1827d21ab8bcSmrg# As a final step for OS-related things, validate the OS-kernel combination
1828d21ab8bcSmrg# (given a valid OS), if there is a kernel.
18296ee7d557Smrgcase $kernel-$os-$obj in
18306ee7d557Smrg	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
18316ee7d557Smrg		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
18326ee7d557Smrg		    | linux-relibc*- | linux-uclibc*- )
18336ee7d557Smrg		;;
18346ee7d557Smrg	uclinux-uclibc*- )
18356ee7d557Smrg		;;
18366ee7d557Smrg	managarm-mlibc*- | managarm-kernel*- )
1837d21ab8bcSmrg		;;
18386ee7d557Smrg	windows*-msvc*-)
1839d21ab8bcSmrg		;;
18406ee7d557Smrg	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
18416ee7d557Smrg		    | -uclibc*- )
1842d21ab8bcSmrg		# These are just libc implementations, not actual OSes, and thus
1843d21ab8bcSmrg		# require a kernel.
18446ee7d557Smrg		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
1845d21ab8bcSmrg		exit 1
1846d21ab8bcSmrg		;;
18476ee7d557Smrg	-kernel*- )
18486ee7d557Smrg		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
18496ee7d557Smrg		exit 1
1850d21ab8bcSmrg		;;
18516ee7d557Smrg	*-kernel*- )
18526ee7d557Smrg		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
18536ee7d557Smrg		exit 1
1854d21ab8bcSmrg		;;
18556ee7d557Smrg	*-msvc*- )
18566ee7d557Smrg		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
18576ee7d557Smrg		exit 1
1858d21ab8bcSmrg		;;
18596ee7d557Smrg	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
18606ee7d557Smrg		;;
18616ee7d557Smrg	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
18626ee7d557Smrg		;;
18636ee7d557Smrg	nto-qnx*-)
18646ee7d557Smrg		;;
18656ee7d557Smrg	os2-emx-)
1866d21ab8bcSmrg		;;
18676ee7d557Smrg	*-eabi*- | *-gnueabi*-)
1868d21ab8bcSmrg		;;
18696ee7d557Smrg	none--*)
18706ee7d557Smrg		# None (no kernel, i.e. freestanding / bare metal),
18716ee7d557Smrg		# can be paired with an machine code file format
18726ee7d557Smrg		;;
18736ee7d557Smrg	-*-)
1874d21ab8bcSmrg		# Blank kernel with real OS is always fine.
1875d21ab8bcSmrg		;;
18766ee7d557Smrg	--*)
18776ee7d557Smrg		# Blank kernel and OS with real machine code file format is always fine.
18786ee7d557Smrg		;;
18796ee7d557Smrg	*-*-*)
18806ee7d557Smrg		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
1881d21ab8bcSmrg		exit 1
1882d21ab8bcSmrg		;;
1883d21ab8bcSmrgesac
1884d21ab8bcSmrg
18851f0ac6a5Smrg# Here we handle the case where we know the os, and the CPU type, but not the
18861f0ac6a5Smrg# manufacturer.  We pick the logical manufacturer.
1887d21ab8bcSmrgcase $vendor in
1888d21ab8bcSmrg	unknown)
1889d21ab8bcSmrg		case $cpu-$os in
1890d21ab8bcSmrg			*-riscix*)
18911f0ac6a5Smrg				vendor=acorn
18921f0ac6a5Smrg				;;
1893d21ab8bcSmrg			*-sunos*)
18941f0ac6a5Smrg				vendor=sun
18951f0ac6a5Smrg				;;
1896d21ab8bcSmrg			*-cnk* | *-aix*)
18971f0ac6a5Smrg				vendor=ibm
18981f0ac6a5Smrg				;;
1899d21ab8bcSmrg			*-beos*)
19001f0ac6a5Smrg				vendor=be
19011f0ac6a5Smrg				;;
1902d21ab8bcSmrg			*-hpux*)
19031f0ac6a5Smrg				vendor=hp
19041f0ac6a5Smrg				;;
1905d21ab8bcSmrg			*-mpeix*)
19061f0ac6a5Smrg				vendor=hp
19071f0ac6a5Smrg				;;
1908d21ab8bcSmrg			*-hiux*)
19091f0ac6a5Smrg				vendor=hitachi
19101f0ac6a5Smrg				;;
1911d21ab8bcSmrg			*-unos*)
19121f0ac6a5Smrg				vendor=crds
19131f0ac6a5Smrg				;;
1914d21ab8bcSmrg			*-dgux*)
19151f0ac6a5Smrg				vendor=dg
19161f0ac6a5Smrg				;;
1917d21ab8bcSmrg			*-luna*)
19181f0ac6a5Smrg				vendor=omron
19191f0ac6a5Smrg				;;
1920d21ab8bcSmrg			*-genix*)
19211f0ac6a5Smrg				vendor=ns
19221f0ac6a5Smrg				;;
1923d21ab8bcSmrg			*-clix*)
1924d21ab8bcSmrg				vendor=intergraph
1925d21ab8bcSmrg				;;
1926d21ab8bcSmrg			*-mvs* | *-opened*)
1927d21ab8bcSmrg				vendor=ibm
1928d21ab8bcSmrg				;;
1929d21ab8bcSmrg			*-os400*)
19301f0ac6a5Smrg				vendor=ibm
19311f0ac6a5Smrg				;;
1932d21ab8bcSmrg			s390-* | s390x-*)
1933e5410a46Smrg				vendor=ibm
1934e5410a46Smrg				;;
1935d21ab8bcSmrg			*-ptx*)
19361f0ac6a5Smrg				vendor=sequent
19371f0ac6a5Smrg				;;
1938d21ab8bcSmrg			*-tpf*)
1939e5410a46Smrg				vendor=ibm
1940e5410a46Smrg				;;
1941d21ab8bcSmrg			*-vxsim* | *-vxworks* | *-windiss*)
19421f0ac6a5Smrg				vendor=wrs
19431f0ac6a5Smrg				;;
1944d21ab8bcSmrg			*-aux*)
19451f0ac6a5Smrg				vendor=apple
19461f0ac6a5Smrg				;;
1947d21ab8bcSmrg			*-hms*)
19481f0ac6a5Smrg				vendor=hitachi
19491f0ac6a5Smrg				;;
1950d21ab8bcSmrg			*-mpw* | *-macos*)
19511f0ac6a5Smrg				vendor=apple
19521f0ac6a5Smrg				;;
1953d21ab8bcSmrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
19541f0ac6a5Smrg				vendor=atari
19551f0ac6a5Smrg				;;
1956d21ab8bcSmrg			*-vos*)
19571f0ac6a5Smrg				vendor=stratus
19581f0ac6a5Smrg				;;
19591f0ac6a5Smrg		esac
19601f0ac6a5Smrg		;;
19611f0ac6a5Smrgesac
19621f0ac6a5Smrg
19636ee7d557Smrgecho "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
1964e5410a46Smrgexit
19651f0ac6a5Smrg
19661f0ac6a5Smrg# Local variables:
1967d21ab8bcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
19681f0ac6a5Smrg# time-stamp-start: "timestamp='"
19691f0ac6a5Smrg# time-stamp-format: "%:y-%02m-%02d"
19701f0ac6a5Smrg# time-stamp-end: "'"
19711f0ac6a5Smrg# End:
1972