176910425Smrg#! /bin/sh
276910425Smrg# Configuration validation subroutine script.
38bfe6addSmrg#   Copyright 1992-2024 Free Software Foundation, Inc.
476910425Smrg
5a67f45c3Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6a67f45c3Smrg
78bfe6addSmrgtimestamp='2024-01-01'
876910425Smrg
99ff100acSmrg# This file is free software; you can redistribute it and/or modify it
109ff100acSmrg# under the terms of the GNU General Public License as published by
118bfe6addSmrg# the Free Software Foundation, either version 3 of the License, or
1276910425Smrg# (at your option) any later version.
1376910425Smrg#
149ff100acSmrg# This program is distributed in the hope that it will be useful, but
159ff100acSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
169ff100acSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179ff100acSmrg# General Public License for more details.
1876910425Smrg#
1976910425Smrg# You should have received a copy of the GNU General Public License
20a67f45c3Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2176910425Smrg#
2276910425Smrg# As a special exception to the GNU General Public License, if you
2376910425Smrg# distribute this file as part of a program that contains a
2476910425Smrg# configuration script generated by Autoconf, you may include it under
259ff100acSmrg# the same distribution terms that you use for the rest of that
269ff100acSmrg# program.  This Exception is an additional permission under section 7
279ff100acSmrg# of the GNU General Public License, version 3 ("GPLv3").
2876910425Smrg
2976910425Smrg
309ff100acSmrg# Please send patches to <config-patches@gnu.org>.
3176910425Smrg#
3276910425Smrg# Configuration subroutine to validate and canonicalize a configuration type.
3376910425Smrg# Supply the specified configuration type as an argument.
3476910425Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
3576910425Smrg# Otherwise, we print the canonical config type on stdout and succeed.
3676910425Smrg
37482df631Smrg# You can get the latest version of this script from:
38a67f45c3Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39482df631Smrg
4076910425Smrg# This file is supposed to be the same for all GNU packages
4176910425Smrg# and recognize all the CPU types, system types and aliases
4276910425Smrg# that are meaningful with *any* GNU software.
4376910425Smrg# Each package is responsible for reporting which valid configurations
4476910425Smrg# it does not support.  The user should be able to distinguish
4576910425Smrg# a failure to support a valid configuration from a meaningless
4676910425Smrg# configuration.
4776910425Smrg
4876910425Smrg# The goal of this file is to map all the various variations of a given
4976910425Smrg# machine specification into a single specification in the form:
5076910425Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
5176910425Smrg# or in some cases, the newer four-part form:
5276910425Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
5376910425Smrg# It is wrong to echo any other type of specification.
5476910425Smrg
55a67f45c3Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56a67f45c3Smrg# about features and limitations of the classic Bourne shell that were
57a67f45c3Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58a67f45c3Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59a67f45c3Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60a67f45c3Smrg# have a pre-POSIX /bin/sh.
61a67f45c3Smrg
6276910425Smrgme=`echo "$0" | sed -e 's,.*/,,'`
6376910425Smrg
6476910425Smrgusage="\
65a67f45c3SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
6676910425Smrg
6776910425SmrgCanonicalize a configuration name.
6876910425Smrg
69a67f45c3SmrgOptions:
7076910425Smrg  -h, --help         print this help, then exit
7176910425Smrg  -t, --time-stamp   print date of last modification, then exit
7276910425Smrg  -v, --version      print version number, then exit
7376910425Smrg
7476910425SmrgReport bugs and patches to <config-patches@gnu.org>."
7576910425Smrg
7676910425Smrgversion="\
7776910425SmrgGNU config.sub ($timestamp)
7876910425Smrg
798bfe6addSmrgCopyright 1992-2024 Free Software Foundation, Inc.
8076910425Smrg
8176910425SmrgThis is free software; see the source for copying conditions.  There is NO
8276910425Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
8376910425Smrg
8476910425Smrghelp="
858bfe6addSmrgTry '$me --help' for more information."
8676910425Smrg
8776910425Smrg# Parse command line
8876910425Smrgwhile test $# -gt 0 ; do
8976910425Smrg  case $1 in
9076910425Smrg    --time-stamp | --time* | -t )
9176910425Smrg       echo "$timestamp" ; exit ;;
9276910425Smrg    --version | -v )
9376910425Smrg       echo "$version" ; exit ;;
9476910425Smrg    --help | --h* | -h )
9576910425Smrg       echo "$usage"; exit ;;
9676910425Smrg    -- )     # Stop option processing
9776910425Smrg       shift; break ;;
9876910425Smrg    - )	# Use stdin as input.
9976910425Smrg       break ;;
10076910425Smrg    -* )
101a67f45c3Smrg       echo "$me: invalid option $1$help" >&2
10276910425Smrg       exit 1 ;;
10376910425Smrg
10476910425Smrg    *local*)
10576910425Smrg       # First pass through any local machine types.
106a67f45c3Smrg       echo "$1"
10776910425Smrg       exit ;;
10876910425Smrg
10976910425Smrg    * )
11076910425Smrg       break ;;
11176910425Smrg  esac
11276910425Smrgdone
11376910425Smrg
11476910425Smrgcase $# in
11576910425Smrg 0) echo "$me: missing argument$help" >&2
11676910425Smrg    exit 1;;
11776910425Smrg 1) ;;
11876910425Smrg *) echo "$me: too many arguments$help" >&2
11976910425Smrg    exit 1;;
12076910425Smrgesac
12176910425Smrg
122a67f45c3Smrg# Split fields of configuration type
123a67f45c3Smrg# shellcheck disable=SC2162
124a67f45c3Smrgsaved_IFS=$IFS
125a67f45c3SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126a67f45c3Smrg$1
127a67f45c3SmrgEOF
128a67f45c3SmrgIFS=$saved_IFS
12976910425Smrg
130a67f45c3Smrg# Separate into logical components for further validation
131a67f45c3Smrgcase $1 in
132a67f45c3Smrg	*-*-*-*-*)
1338bfe6addSmrg		echo "Invalid configuration '$1': more than four components" >&2
134a67f45c3Smrg		exit 1
13576910425Smrg		;;
136a67f45c3Smrg	*-*-*-*)
137a67f45c3Smrg		basic_machine=$field1-$field2
138a67f45c3Smrg		basic_os=$field3-$field4
13976910425Smrg		;;
140a67f45c3Smrg	*-*-*)
141a67f45c3Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142a67f45c3Smrg		# parts
143a67f45c3Smrg		maybe_os=$field2-$field3
144a67f45c3Smrg		case $maybe_os in
145a67f45c3Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146a67f45c3Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147a67f45c3Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1488bfe6addSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
1498bfe6addSmrg			| windows-* )
150a67f45c3Smrg				basic_machine=$field1
151a67f45c3Smrg				basic_os=$maybe_os
152a67f45c3Smrg				;;
153a67f45c3Smrg			android-linux)
154a67f45c3Smrg				basic_machine=$field1-unknown
155a67f45c3Smrg				basic_os=linux-android
156a67f45c3Smrg				;;
157a67f45c3Smrg			*)
158a67f45c3Smrg				basic_machine=$field1-$field2
159a67f45c3Smrg				basic_os=$field3
160a67f45c3Smrg				;;
161a67f45c3Smrg		esac
16276910425Smrg		;;
163a67f45c3Smrg	*-*)
164a67f45c3Smrg		# A lone config we happen to match not fitting any pattern
165a67f45c3Smrg		case $field1-$field2 in
166a67f45c3Smrg			decstation-3100)
167a67f45c3Smrg				basic_machine=mips-dec
168a67f45c3Smrg				basic_os=
169a67f45c3Smrg				;;
170a67f45c3Smrg			*-*)
171a67f45c3Smrg				# Second component is usually, but not always the OS
172a67f45c3Smrg				case $field2 in
173a67f45c3Smrg					# Prevent following clause from handling this valid os
174a67f45c3Smrg					sun*os*)
175a67f45c3Smrg						basic_machine=$field1
176a67f45c3Smrg						basic_os=$field2
177a67f45c3Smrg						;;
178a67f45c3Smrg					zephyr*)
179a67f45c3Smrg						basic_machine=$field1-unknown
180a67f45c3Smrg						basic_os=$field2
181a67f45c3Smrg						;;
182a67f45c3Smrg					# Manufacturers
183a67f45c3Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
184a67f45c3Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
185a67f45c3Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
186a67f45c3Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
187a67f45c3Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
188a67f45c3Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
189a67f45c3Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
190a67f45c3Smrg					| microblaze* | sim | cisco \
191a67f45c3Smrg					| oki | wec | wrs | winbond)
192a67f45c3Smrg						basic_machine=$field1-$field2
193a67f45c3Smrg						basic_os=
194a67f45c3Smrg						;;
195a67f45c3Smrg					*)
196a67f45c3Smrg						basic_machine=$field1
197a67f45c3Smrg						basic_os=$field2
198a67f45c3Smrg						;;
199a67f45c3Smrg				esac
200a67f45c3Smrg			;;
201a67f45c3Smrg		esac
20276910425Smrg		;;
203a67f45c3Smrg	*)
204a67f45c3Smrg		# Convert single-component short-hands not valid as part of
205a67f45c3Smrg		# multi-component configurations.
206a67f45c3Smrg		case $field1 in
207a67f45c3Smrg			386bsd)
208a67f45c3Smrg				basic_machine=i386-pc
209a67f45c3Smrg				basic_os=bsd
210a67f45c3Smrg				;;
211a67f45c3Smrg			a29khif)
212a67f45c3Smrg				basic_machine=a29k-amd
213a67f45c3Smrg				basic_os=udi
214a67f45c3Smrg				;;
215a67f45c3Smrg			adobe68k)
216a67f45c3Smrg				basic_machine=m68010-adobe
217a67f45c3Smrg				basic_os=scout
218a67f45c3Smrg				;;
219a67f45c3Smrg			alliant)
220a67f45c3Smrg				basic_machine=fx80-alliant
221a67f45c3Smrg				basic_os=
222a67f45c3Smrg				;;
223a67f45c3Smrg			altos | altos3068)
224a67f45c3Smrg				basic_machine=m68k-altos
225a67f45c3Smrg				basic_os=
226a67f45c3Smrg				;;
227a67f45c3Smrg			am29k)
228a67f45c3Smrg				basic_machine=a29k-none
229a67f45c3Smrg				basic_os=bsd
230a67f45c3Smrg				;;
231a67f45c3Smrg			amdahl)
232a67f45c3Smrg				basic_machine=580-amdahl
233a67f45c3Smrg				basic_os=sysv
234a67f45c3Smrg				;;
235a67f45c3Smrg			amiga)
236a67f45c3Smrg				basic_machine=m68k-unknown
237a67f45c3Smrg				basic_os=
238a67f45c3Smrg				;;
239a67f45c3Smrg			amigaos | amigados)
240a67f45c3Smrg				basic_machine=m68k-unknown
241a67f45c3Smrg				basic_os=amigaos
242a67f45c3Smrg				;;
243a67f45c3Smrg			amigaunix | amix)
244a67f45c3Smrg				basic_machine=m68k-unknown
245a67f45c3Smrg				basic_os=sysv4
246a67f45c3Smrg				;;
247a67f45c3Smrg			apollo68)
248a67f45c3Smrg				basic_machine=m68k-apollo
249a67f45c3Smrg				basic_os=sysv
250a67f45c3Smrg				;;
251a67f45c3Smrg			apollo68bsd)
252a67f45c3Smrg				basic_machine=m68k-apollo
253a67f45c3Smrg				basic_os=bsd
254a67f45c3Smrg				;;
255a67f45c3Smrg			aros)
256a67f45c3Smrg				basic_machine=i386-pc
257a67f45c3Smrg				basic_os=aros
258a67f45c3Smrg				;;
259a67f45c3Smrg			aux)
260a67f45c3Smrg				basic_machine=m68k-apple
261a67f45c3Smrg				basic_os=aux
262a67f45c3Smrg				;;
263a67f45c3Smrg			balance)
264a67f45c3Smrg				basic_machine=ns32k-sequent
265a67f45c3Smrg				basic_os=dynix
266a67f45c3Smrg				;;
267a67f45c3Smrg			blackfin)
268a67f45c3Smrg				basic_machine=bfin-unknown
269a67f45c3Smrg				basic_os=linux
270a67f45c3Smrg				;;
271a67f45c3Smrg			cegcc)
272a67f45c3Smrg				basic_machine=arm-unknown
273a67f45c3Smrg				basic_os=cegcc
274a67f45c3Smrg				;;
275a67f45c3Smrg			convex-c1)
276a67f45c3Smrg				basic_machine=c1-convex
277a67f45c3Smrg				basic_os=bsd
278a67f45c3Smrg				;;
279a67f45c3Smrg			convex-c2)
280a67f45c3Smrg				basic_machine=c2-convex
281a67f45c3Smrg				basic_os=bsd
282a67f45c3Smrg				;;
283a67f45c3Smrg			convex-c32)
284a67f45c3Smrg				basic_machine=c32-convex
285a67f45c3Smrg				basic_os=bsd
286a67f45c3Smrg				;;
287a67f45c3Smrg			convex-c34)
288a67f45c3Smrg				basic_machine=c34-convex
289a67f45c3Smrg				basic_os=bsd
290a67f45c3Smrg				;;
291a67f45c3Smrg			convex-c38)
292a67f45c3Smrg				basic_machine=c38-convex
293a67f45c3Smrg				basic_os=bsd
294a67f45c3Smrg				;;
295a67f45c3Smrg			cray)
296a67f45c3Smrg				basic_machine=j90-cray
297a67f45c3Smrg				basic_os=unicos
298a67f45c3Smrg				;;
299a67f45c3Smrg			crds | unos)
300a67f45c3Smrg				basic_machine=m68k-crds
301a67f45c3Smrg				basic_os=
302a67f45c3Smrg				;;
303a67f45c3Smrg			da30)
304a67f45c3Smrg				basic_machine=m68k-da30
305a67f45c3Smrg				basic_os=
306a67f45c3Smrg				;;
307a67f45c3Smrg			decstation | pmax | pmin | dec3100 | decstatn)
308a67f45c3Smrg				basic_machine=mips-dec
309a67f45c3Smrg				basic_os=
310a67f45c3Smrg				;;
311a67f45c3Smrg			delta88)
312a67f45c3Smrg				basic_machine=m88k-motorola
313a67f45c3Smrg				basic_os=sysv3
314a67f45c3Smrg				;;
315a67f45c3Smrg			dicos)
316a67f45c3Smrg				basic_machine=i686-pc
317a67f45c3Smrg				basic_os=dicos
318a67f45c3Smrg				;;
319a67f45c3Smrg			djgpp)
320a67f45c3Smrg				basic_machine=i586-pc
321a67f45c3Smrg				basic_os=msdosdjgpp
322a67f45c3Smrg				;;
323a67f45c3Smrg			ebmon29k)
324a67f45c3Smrg				basic_machine=a29k-amd
325a67f45c3Smrg				basic_os=ebmon
326a67f45c3Smrg				;;
327a67f45c3Smrg			es1800 | OSE68k | ose68k | ose | OSE)
328a67f45c3Smrg				basic_machine=m68k-ericsson
329a67f45c3Smrg				basic_os=ose
330a67f45c3Smrg				;;
331a67f45c3Smrg			gmicro)
332a67f45c3Smrg				basic_machine=tron-gmicro
333a67f45c3Smrg				basic_os=sysv
334a67f45c3Smrg				;;
335a67f45c3Smrg			go32)
336a67f45c3Smrg				basic_machine=i386-pc
337a67f45c3Smrg				basic_os=go32
338a67f45c3Smrg				;;
339a67f45c3Smrg			h8300hms)
340a67f45c3Smrg				basic_machine=h8300-hitachi
341a67f45c3Smrg				basic_os=hms
342a67f45c3Smrg				;;
343a67f45c3Smrg			h8300xray)
344a67f45c3Smrg				basic_machine=h8300-hitachi
345a67f45c3Smrg				basic_os=xray
346a67f45c3Smrg				;;
347a67f45c3Smrg			h8500hms)
348a67f45c3Smrg				basic_machine=h8500-hitachi
349a67f45c3Smrg				basic_os=hms
350a67f45c3Smrg				;;
351a67f45c3Smrg			harris)
352a67f45c3Smrg				basic_machine=m88k-harris
353a67f45c3Smrg				basic_os=sysv3
354a67f45c3Smrg				;;
355a67f45c3Smrg			hp300 | hp300hpux)
356a67f45c3Smrg				basic_machine=m68k-hp
357a67f45c3Smrg				basic_os=hpux
358a67f45c3Smrg				;;
359a67f45c3Smrg			hp300bsd)
360a67f45c3Smrg				basic_machine=m68k-hp
361a67f45c3Smrg				basic_os=bsd
362a67f45c3Smrg				;;
363a67f45c3Smrg			hppaosf)
364a67f45c3Smrg				basic_machine=hppa1.1-hp
365a67f45c3Smrg				basic_os=osf
366a67f45c3Smrg				;;
367a67f45c3Smrg			hppro)
368a67f45c3Smrg				basic_machine=hppa1.1-hp
369a67f45c3Smrg				basic_os=proelf
370a67f45c3Smrg				;;
371a67f45c3Smrg			i386mach)
372a67f45c3Smrg				basic_machine=i386-mach
373a67f45c3Smrg				basic_os=mach
374a67f45c3Smrg				;;
375a67f45c3Smrg			isi68 | isi)
376a67f45c3Smrg				basic_machine=m68k-isi
377a67f45c3Smrg				basic_os=sysv
378a67f45c3Smrg				;;
379a67f45c3Smrg			m68knommu)
380a67f45c3Smrg				basic_machine=m68k-unknown
381a67f45c3Smrg				basic_os=linux
382a67f45c3Smrg				;;
383a67f45c3Smrg			magnum | m3230)
384a67f45c3Smrg				basic_machine=mips-mips
385a67f45c3Smrg				basic_os=sysv
386a67f45c3Smrg				;;
387a67f45c3Smrg			merlin)
388a67f45c3Smrg				basic_machine=ns32k-utek
389a67f45c3Smrg				basic_os=sysv
390a67f45c3Smrg				;;
391a67f45c3Smrg			mingw64)
392a67f45c3Smrg				basic_machine=x86_64-pc
393a67f45c3Smrg				basic_os=mingw64
394a67f45c3Smrg				;;
395a67f45c3Smrg			mingw32)
396a67f45c3Smrg				basic_machine=i686-pc
397a67f45c3Smrg				basic_os=mingw32
398a67f45c3Smrg				;;
399a67f45c3Smrg			mingw32ce)
400a67f45c3Smrg				basic_machine=arm-unknown
401a67f45c3Smrg				basic_os=mingw32ce
402a67f45c3Smrg				;;
403a67f45c3Smrg			monitor)
404a67f45c3Smrg				basic_machine=m68k-rom68k
405a67f45c3Smrg				basic_os=coff
406a67f45c3Smrg				;;
407a67f45c3Smrg			morphos)
408a67f45c3Smrg				basic_machine=powerpc-unknown
409a67f45c3Smrg				basic_os=morphos
410a67f45c3Smrg				;;
411a67f45c3Smrg			moxiebox)
412a67f45c3Smrg				basic_machine=moxie-unknown
413a67f45c3Smrg				basic_os=moxiebox
414a67f45c3Smrg				;;
415a67f45c3Smrg			msdos)
416a67f45c3Smrg				basic_machine=i386-pc
417a67f45c3Smrg				basic_os=msdos
418a67f45c3Smrg				;;
419a67f45c3Smrg			msys)
420a67f45c3Smrg				basic_machine=i686-pc
421a67f45c3Smrg				basic_os=msys
422a67f45c3Smrg				;;
423a67f45c3Smrg			mvs)
424a67f45c3Smrg				basic_machine=i370-ibm
425a67f45c3Smrg				basic_os=mvs
426a67f45c3Smrg				;;
427a67f45c3Smrg			nacl)
428a67f45c3Smrg				basic_machine=le32-unknown
429a67f45c3Smrg				basic_os=nacl
430a67f45c3Smrg				;;
431a67f45c3Smrg			ncr3000)
432a67f45c3Smrg				basic_machine=i486-ncr
433a67f45c3Smrg				basic_os=sysv4
434a67f45c3Smrg				;;
435a67f45c3Smrg			netbsd386)
436a67f45c3Smrg				basic_machine=i386-pc
437a67f45c3Smrg				basic_os=netbsd
438a67f45c3Smrg				;;
439a67f45c3Smrg			netwinder)
440a67f45c3Smrg				basic_machine=armv4l-rebel
441a67f45c3Smrg				basic_os=linux
442a67f45c3Smrg				;;
443a67f45c3Smrg			news | news700 | news800 | news900)
444a67f45c3Smrg				basic_machine=m68k-sony
445a67f45c3Smrg				basic_os=newsos
446a67f45c3Smrg				;;
447a67f45c3Smrg			news1000)
448a67f45c3Smrg				basic_machine=m68030-sony
449a67f45c3Smrg				basic_os=newsos
450a67f45c3Smrg				;;
451a67f45c3Smrg			necv70)
452a67f45c3Smrg				basic_machine=v70-nec
453a67f45c3Smrg				basic_os=sysv
454a67f45c3Smrg				;;
455a67f45c3Smrg			nh3000)
456a67f45c3Smrg				basic_machine=m68k-harris
457a67f45c3Smrg				basic_os=cxux
458a67f45c3Smrg				;;
459a67f45c3Smrg			nh[45]000)
460a67f45c3Smrg				basic_machine=m88k-harris
461a67f45c3Smrg				basic_os=cxux
462a67f45c3Smrg				;;
463a67f45c3Smrg			nindy960)
464a67f45c3Smrg				basic_machine=i960-intel
465a67f45c3Smrg				basic_os=nindy
466a67f45c3Smrg				;;
467a67f45c3Smrg			mon960)
468a67f45c3Smrg				basic_machine=i960-intel
469a67f45c3Smrg				basic_os=mon960
470a67f45c3Smrg				;;
471a67f45c3Smrg			nonstopux)
472a67f45c3Smrg				basic_machine=mips-compaq
473a67f45c3Smrg				basic_os=nonstopux
474a67f45c3Smrg				;;
475a67f45c3Smrg			os400)
476a67f45c3Smrg				basic_machine=powerpc-ibm
477a67f45c3Smrg				basic_os=os400
478a67f45c3Smrg				;;
479a67f45c3Smrg			OSE68000 | ose68000)
480a67f45c3Smrg				basic_machine=m68000-ericsson
481a67f45c3Smrg				basic_os=ose
482a67f45c3Smrg				;;
483a67f45c3Smrg			os68k)
484a67f45c3Smrg				basic_machine=m68k-none
485a67f45c3Smrg				basic_os=os68k
486a67f45c3Smrg				;;
487a67f45c3Smrg			paragon)
488a67f45c3Smrg				basic_machine=i860-intel
489a67f45c3Smrg				basic_os=osf
490a67f45c3Smrg				;;
491a67f45c3Smrg			parisc)
492a67f45c3Smrg				basic_machine=hppa-unknown
493a67f45c3Smrg				basic_os=linux
494a67f45c3Smrg				;;
495a67f45c3Smrg			psp)
496a67f45c3Smrg				basic_machine=mipsallegrexel-sony
497a67f45c3Smrg				basic_os=psp
498a67f45c3Smrg				;;
499a67f45c3Smrg			pw32)
500a67f45c3Smrg				basic_machine=i586-unknown
501a67f45c3Smrg				basic_os=pw32
502a67f45c3Smrg				;;
503a67f45c3Smrg			rdos | rdos64)
504a67f45c3Smrg				basic_machine=x86_64-pc
505a67f45c3Smrg				basic_os=rdos
506a67f45c3Smrg				;;
507a67f45c3Smrg			rdos32)
508a67f45c3Smrg				basic_machine=i386-pc
509a67f45c3Smrg				basic_os=rdos
510a67f45c3Smrg				;;
511a67f45c3Smrg			rom68k)
512a67f45c3Smrg				basic_machine=m68k-rom68k
513a67f45c3Smrg				basic_os=coff
514a67f45c3Smrg				;;
515a67f45c3Smrg			sa29200)
516a67f45c3Smrg				basic_machine=a29k-amd
517a67f45c3Smrg				basic_os=udi
518a67f45c3Smrg				;;
519a67f45c3Smrg			sei)
520a67f45c3Smrg				basic_machine=mips-sei
521a67f45c3Smrg				basic_os=seiux
522a67f45c3Smrg				;;
523a67f45c3Smrg			sequent)
524a67f45c3Smrg				basic_machine=i386-sequent
525a67f45c3Smrg				basic_os=
526a67f45c3Smrg				;;
527a67f45c3Smrg			sps7)
528a67f45c3Smrg				basic_machine=m68k-bull
529a67f45c3Smrg				basic_os=sysv2
530a67f45c3Smrg				;;
531a67f45c3Smrg			st2000)
532a67f45c3Smrg				basic_machine=m68k-tandem
533a67f45c3Smrg				basic_os=
534a67f45c3Smrg				;;
535a67f45c3Smrg			stratus)
536a67f45c3Smrg				basic_machine=i860-stratus
537a67f45c3Smrg				basic_os=sysv4
538a67f45c3Smrg				;;
539a67f45c3Smrg			sun2)
540a67f45c3Smrg				basic_machine=m68000-sun
541a67f45c3Smrg				basic_os=
542a67f45c3Smrg				;;
543a67f45c3Smrg			sun2os3)
544a67f45c3Smrg				basic_machine=m68000-sun
545a67f45c3Smrg				basic_os=sunos3
546a67f45c3Smrg				;;
547a67f45c3Smrg			sun2os4)
548a67f45c3Smrg				basic_machine=m68000-sun
549a67f45c3Smrg				basic_os=sunos4
550a67f45c3Smrg				;;
551a67f45c3Smrg			sun3)
552a67f45c3Smrg				basic_machine=m68k-sun
553a67f45c3Smrg				basic_os=
554a67f45c3Smrg				;;
555a67f45c3Smrg			sun3os3)
556a67f45c3Smrg				basic_machine=m68k-sun
557a67f45c3Smrg				basic_os=sunos3
558a67f45c3Smrg				;;
559a67f45c3Smrg			sun3os4)
560a67f45c3Smrg				basic_machine=m68k-sun
561a67f45c3Smrg				basic_os=sunos4
562a67f45c3Smrg				;;
563a67f45c3Smrg			sun4)
564a67f45c3Smrg				basic_machine=sparc-sun
565a67f45c3Smrg				basic_os=
566a67f45c3Smrg				;;
567a67f45c3Smrg			sun4os3)
568a67f45c3Smrg				basic_machine=sparc-sun
569a67f45c3Smrg				basic_os=sunos3
570a67f45c3Smrg				;;
571a67f45c3Smrg			sun4os4)
572a67f45c3Smrg				basic_machine=sparc-sun
573a67f45c3Smrg				basic_os=sunos4
574a67f45c3Smrg				;;
575a67f45c3Smrg			sun4sol2)
576a67f45c3Smrg				basic_machine=sparc-sun
577a67f45c3Smrg				basic_os=solaris2
578a67f45c3Smrg				;;
579a67f45c3Smrg			sun386 | sun386i | roadrunner)
580a67f45c3Smrg				basic_machine=i386-sun
581a67f45c3Smrg				basic_os=
582a67f45c3Smrg				;;
583a67f45c3Smrg			sv1)
584a67f45c3Smrg				basic_machine=sv1-cray
585a67f45c3Smrg				basic_os=unicos
586a67f45c3Smrg				;;
587a67f45c3Smrg			symmetry)
588a67f45c3Smrg				basic_machine=i386-sequent
589a67f45c3Smrg				basic_os=dynix
590a67f45c3Smrg				;;
591a67f45c3Smrg			t3e)
592a67f45c3Smrg				basic_machine=alphaev5-cray
593a67f45c3Smrg				basic_os=unicos
594a67f45c3Smrg				;;
595a67f45c3Smrg			t90)
596a67f45c3Smrg				basic_machine=t90-cray
597a67f45c3Smrg				basic_os=unicos
598a67f45c3Smrg				;;
599a67f45c3Smrg			toad1)
600a67f45c3Smrg				basic_machine=pdp10-xkl
601a67f45c3Smrg				basic_os=tops20
602a67f45c3Smrg				;;
603a67f45c3Smrg			tpf)
604a67f45c3Smrg				basic_machine=s390x-ibm
605a67f45c3Smrg				basic_os=tpf
606a67f45c3Smrg				;;
607a67f45c3Smrg			udi29k)
608a67f45c3Smrg				basic_machine=a29k-amd
609a67f45c3Smrg				basic_os=udi
610a67f45c3Smrg				;;
611a67f45c3Smrg			ultra3)
612a67f45c3Smrg				basic_machine=a29k-nyu
613a67f45c3Smrg				basic_os=sym1
614a67f45c3Smrg				;;
615a67f45c3Smrg			v810 | necv810)
616a67f45c3Smrg				basic_machine=v810-nec
617a67f45c3Smrg				basic_os=none
618a67f45c3Smrg				;;
619a67f45c3Smrg			vaxv)
620a67f45c3Smrg				basic_machine=vax-dec
621a67f45c3Smrg				basic_os=sysv
622a67f45c3Smrg				;;
623a67f45c3Smrg			vms)
624a67f45c3Smrg				basic_machine=vax-dec
625a67f45c3Smrg				basic_os=vms
626a67f45c3Smrg				;;
627a67f45c3Smrg			vsta)
628a67f45c3Smrg				basic_machine=i386-pc
629a67f45c3Smrg				basic_os=vsta
630a67f45c3Smrg				;;
631a67f45c3Smrg			vxworks960)
632a67f45c3Smrg				basic_machine=i960-wrs
633a67f45c3Smrg				basic_os=vxworks
634a67f45c3Smrg				;;
635a67f45c3Smrg			vxworks68)
636a67f45c3Smrg				basic_machine=m68k-wrs
637a67f45c3Smrg				basic_os=vxworks
638a67f45c3Smrg				;;
639a67f45c3Smrg			vxworks29k)
640a67f45c3Smrg				basic_machine=a29k-wrs
641a67f45c3Smrg				basic_os=vxworks
642a67f45c3Smrg				;;
643a67f45c3Smrg			xbox)
644a67f45c3Smrg				basic_machine=i686-pc
645a67f45c3Smrg				basic_os=mingw32
646a67f45c3Smrg				;;
647a67f45c3Smrg			ymp)
648a67f45c3Smrg				basic_machine=ymp-cray
649a67f45c3Smrg				basic_os=unicos
650a67f45c3Smrg				;;
651a67f45c3Smrg			*)
652a67f45c3Smrg				basic_machine=$1
653a67f45c3Smrg				basic_os=
654a67f45c3Smrg				;;
655a67f45c3Smrg		esac
65676910425Smrg		;;
65776910425Smrgesac
65876910425Smrg
659a67f45c3Smrg# Decode 1-component or ad-hoc basic machines
66076910425Smrgcase $basic_machine in
661a67f45c3Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
662a67f45c3Smrg	# some cases the only manufacturer, in others, it is the most popular.
663a67f45c3Smrg	w89k)
664a67f45c3Smrg		cpu=hppa1.1
665a67f45c3Smrg		vendor=winbond
6669ff100acSmrg		;;
667a67f45c3Smrg	op50n)
668a67f45c3Smrg		cpu=hppa1.1
669a67f45c3Smrg		vendor=oki
67076910425Smrg		;;
671a67f45c3Smrg	op60c)
672a67f45c3Smrg		cpu=hppa1.1
673a67f45c3Smrg		vendor=oki
67476910425Smrg		;;
675a67f45c3Smrg	ibm*)
676a67f45c3Smrg		cpu=i370
677a67f45c3Smrg		vendor=ibm
678db17cd6dSmrg		;;
679a67f45c3Smrg	orion105)
680a67f45c3Smrg		cpu=clipper
681a67f45c3Smrg		vendor=highlevel
6829ff100acSmrg		;;
683a67f45c3Smrg	mac | mpw | mac-mpw)
684a67f45c3Smrg		cpu=m68k
685a67f45c3Smrg		vendor=apple
6869ff100acSmrg		;;
687a67f45c3Smrg	pmac | pmac-mpw)
688a67f45c3Smrg		cpu=powerpc
689a67f45c3Smrg		vendor=apple
6909ff100acSmrg		;;
6919ff100acSmrg
69276910425Smrg	# Recognize the various machine names and aliases which stand
69376910425Smrg	# for a CPU type and a company and sometimes even an OS.
69476910425Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
695a67f45c3Smrg		cpu=m68000
696a67f45c3Smrg		vendor=att
69776910425Smrg		;;
69876910425Smrg	3b*)
699a67f45c3Smrg		cpu=we32k
700a67f45c3Smrg		vendor=att
701db17cd6dSmrg		;;
702482df631Smrg	bluegene*)
703a67f45c3Smrg		cpu=powerpc
704a67f45c3Smrg		vendor=ibm
705a67f45c3Smrg		basic_os=cnk
70676910425Smrg		;;
70776910425Smrg	decsystem10* | dec10*)
708a67f45c3Smrg		cpu=pdp10
709a67f45c3Smrg		vendor=dec
710a67f45c3Smrg		basic_os=tops10
71176910425Smrg		;;
71276910425Smrg	decsystem20* | dec20*)
713a67f45c3Smrg		cpu=pdp10
714a67f45c3Smrg		vendor=dec
715a67f45c3Smrg		basic_os=tops20
71676910425Smrg		;;
71776910425Smrg	delta | 3300 | motorola-3300 | motorola-delta \
71876910425Smrg	      | 3300-motorola | delta-motorola)
719a67f45c3Smrg		cpu=m68k
720a67f45c3Smrg		vendor=motorola
72176910425Smrg		;;
722a67f45c3Smrg	dpx2*)
723a67f45c3Smrg		cpu=m68k
724a67f45c3Smrg		vendor=bull
725a67f45c3Smrg		basic_os=sysv3
72676910425Smrg		;;
72776910425Smrg	encore | umax | mmax)
728a67f45c3Smrg		cpu=ns32k
729a67f45c3Smrg		vendor=encore
73076910425Smrg		;;
731a67f45c3Smrg	elxsi)
732a67f45c3Smrg		cpu=elxsi
733a67f45c3Smrg		vendor=elxsi
734a67f45c3Smrg		basic_os=${basic_os:-bsd}
73576910425Smrg		;;
73676910425Smrg	fx2800)
737a67f45c3Smrg		cpu=i860
738a67f45c3Smrg		vendor=alliant
73976910425Smrg		;;
74076910425Smrg	genix)
741a67f45c3Smrg		cpu=ns32k
742a67f45c3Smrg		vendor=ns
74376910425Smrg		;;
74476910425Smrg	h3050r* | hiux*)
745a67f45c3Smrg		cpu=hppa1.1
746a67f45c3Smrg		vendor=hitachi
747a67f45c3Smrg		basic_os=hiuxwe2
74876910425Smrg		;;
74976910425Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
750a67f45c3Smrg		cpu=hppa1.0
751a67f45c3Smrg		vendor=hp
75276910425Smrg		;;
75376910425Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
754a67f45c3Smrg		cpu=m68000
755a67f45c3Smrg		vendor=hp
75676910425Smrg		;;
75776910425Smrg	hp9k3[2-9][0-9])
758a67f45c3Smrg		cpu=m68k
759a67f45c3Smrg		vendor=hp
76076910425Smrg		;;
76176910425Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
762a67f45c3Smrg		cpu=hppa1.0
763a67f45c3Smrg		vendor=hp
76476910425Smrg		;;
76576910425Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
766a67f45c3Smrg		cpu=hppa1.1
767a67f45c3Smrg		vendor=hp
76876910425Smrg		;;
76976910425Smrg	hp9k78[0-9] | hp78[0-9])
77076910425Smrg		# FIXME: really hppa2.0-hp
771a67f45c3Smrg		cpu=hppa1.1
772a67f45c3Smrg		vendor=hp
77376910425Smrg		;;
77476910425Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
77576910425Smrg		# FIXME: really hppa2.0-hp
776a67f45c3Smrg		cpu=hppa1.1
777a67f45c3Smrg		vendor=hp
77876910425Smrg		;;
77976910425Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
780a67f45c3Smrg		cpu=hppa1.1
781a67f45c3Smrg		vendor=hp
78276910425Smrg		;;
78376910425Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
784a67f45c3Smrg		cpu=hppa1.0
785a67f45c3Smrg		vendor=hp
78676910425Smrg		;;
78776910425Smrg	i*86v32)
788a67f45c3Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
789a67f45c3Smrg		vendor=pc
790a67f45c3Smrg		basic_os=sysv32
79176910425Smrg		;;
79276910425Smrg	i*86v4*)
793a67f45c3Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
794a67f45c3Smrg		vendor=pc
795a67f45c3Smrg		basic_os=sysv4
79676910425Smrg		;;
79776910425Smrg	i*86v)
798a67f45c3Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
799a67f45c3Smrg		vendor=pc
800a67f45c3Smrg		basic_os=sysv
80176910425Smrg		;;
80276910425Smrg	i*86sol2)
803a67f45c3Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
804a67f45c3Smrg		vendor=pc
805a67f45c3Smrg		basic_os=solaris2
80676910425Smrg		;;
807a67f45c3Smrg	j90 | j90-cray)
808a67f45c3Smrg		cpu=j90
809a67f45c3Smrg		vendor=cray
810a67f45c3Smrg		basic_os=${basic_os:-unicos}
81176910425Smrg		;;
81276910425Smrg	iris | iris4d)
813a67f45c3Smrg		cpu=mips
814a67f45c3Smrg		vendor=sgi
815a67f45c3Smrg		case $basic_os in
816a67f45c3Smrg		    irix*)
81776910425Smrg			;;
81876910425Smrg		    *)
819a67f45c3Smrg			basic_os=irix4
82076910425Smrg			;;
82176910425Smrg		esac
82276910425Smrg		;;
82376910425Smrg	miniframe)
824a67f45c3Smrg		cpu=m68000
825a67f45c3Smrg		vendor=convergent
8269ff100acSmrg		;;
827a67f45c3Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
828a67f45c3Smrg		cpu=m68k
829a67f45c3Smrg		vendor=atari
830a67f45c3Smrg		basic_os=mint
83176910425Smrg		;;
83276910425Smrg	news-3600 | risc-news)
833a67f45c3Smrg		cpu=mips
834a67f45c3Smrg		vendor=sony
835a67f45c3Smrg		basic_os=newsos
836a67f45c3Smrg		;;
837a67f45c3Smrg	next | m*-next)
838a67f45c3Smrg		cpu=m68k
839a67f45c3Smrg		vendor=next
840a67f45c3Smrg		case $basic_os in
841a67f45c3Smrg		    openstep*)
842a67f45c3Smrg		        ;;
843a67f45c3Smrg		    nextstep*)
84476910425Smrg			;;
845a67f45c3Smrg		    ns2*)
846a67f45c3Smrg		      basic_os=nextstep2
84776910425Smrg			;;
84876910425Smrg		    *)
849a67f45c3Smrg		      basic_os=nextstep3
85076910425Smrg			;;
85176910425Smrg		esac
85276910425Smrg		;;
85376910425Smrg	np1)
854a67f45c3Smrg		cpu=np1
855a67f45c3Smrg		vendor=gould
85676910425Smrg		;;
85776910425Smrg	op50n-* | op60c-*)
858a67f45c3Smrg		cpu=hppa1.1
859a67f45c3Smrg		vendor=oki
860a67f45c3Smrg		basic_os=proelf
86176910425Smrg		;;
86276910425Smrg	pa-hitachi)
863a67f45c3Smrg		cpu=hppa1.1
864a67f45c3Smrg		vendor=hitachi
865a67f45c3Smrg		basic_os=hiuxwe2
866db17cd6dSmrg		;;
86776910425Smrg	pbd)
868a67f45c3Smrg		cpu=sparc
869a67f45c3Smrg		vendor=tti
87076910425Smrg		;;
87176910425Smrg	pbb)
872a67f45c3Smrg		cpu=m68k
873a67f45c3Smrg		vendor=tti
874db17cd6dSmrg		;;
875a67f45c3Smrg	pc532)
876a67f45c3Smrg		cpu=ns32k
877a67f45c3Smrg		vendor=pc532
87876910425Smrg		;;
87976910425Smrg	pn)
880a67f45c3Smrg		cpu=pn
881a67f45c3Smrg		vendor=gould
88276910425Smrg		;;
883a67f45c3Smrg	power)
884a67f45c3Smrg		cpu=power
885a67f45c3Smrg		vendor=ibm
88676910425Smrg		;;
88776910425Smrg	ps2)
888a67f45c3Smrg		cpu=i386
889a67f45c3Smrg		vendor=ibm
89076910425Smrg		;;
89176910425Smrg	rm[46]00)
892a67f45c3Smrg		cpu=mips
893a67f45c3Smrg		vendor=siemens
89476910425Smrg		;;
89576910425Smrg	rtpc | rtpc-*)
896a67f45c3Smrg		cpu=romp
897a67f45c3Smrg		vendor=ibm
89876910425Smrg		;;
899a67f45c3Smrg	sde)
900a67f45c3Smrg		cpu=mipsisa32
901a67f45c3Smrg		vendor=sde
902a67f45c3Smrg		basic_os=${basic_os:-elf}
90376910425Smrg		;;
904a67f45c3Smrg	simso-wrs)
905a67f45c3Smrg		cpu=sparclite
906a67f45c3Smrg		vendor=wrs
907a67f45c3Smrg		basic_os=vxworks
90876910425Smrg		;;
909a67f45c3Smrg	tower | tower-32)
910a67f45c3Smrg		cpu=m68k
911a67f45c3Smrg		vendor=ncr
912db17cd6dSmrg		;;
913a67f45c3Smrg	vpp*|vx|vx-*)
914a67f45c3Smrg		cpu=f301
915a67f45c3Smrg		vendor=fujitsu
91676910425Smrg		;;
917a67f45c3Smrg	w65)
918a67f45c3Smrg		cpu=w65
919a67f45c3Smrg		vendor=wdc
92076910425Smrg		;;
921a67f45c3Smrg	w89k-*)
922a67f45c3Smrg		cpu=hppa1.1
923a67f45c3Smrg		vendor=winbond
924a67f45c3Smrg		basic_os=proelf
92576910425Smrg		;;
926a67f45c3Smrg	none)
927a67f45c3Smrg		cpu=none
928a67f45c3Smrg		vendor=none
929db17cd6dSmrg		;;
930a67f45c3Smrg	leon|leon[3-9])
931a67f45c3Smrg		cpu=sparc
932a67f45c3Smrg		vendor=$basic_machine
93376910425Smrg		;;
934a67f45c3Smrg	leon-*|leon[3-9]-*)
935a67f45c3Smrg		cpu=sparc
936a67f45c3Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93776910425Smrg		;;
938a67f45c3Smrg
939a67f45c3Smrg	*-*)
940a67f45c3Smrg		# shellcheck disable=SC2162
941a67f45c3Smrg		saved_IFS=$IFS
942a67f45c3Smrg		IFS="-" read cpu vendor <<EOF
943a67f45c3Smrg$basic_machine
944a67f45c3SmrgEOF
945a67f45c3Smrg		IFS=$saved_IFS
94676910425Smrg		;;
9478bfe6addSmrg	# We use 'pc' rather than 'unknown'
948a67f45c3Smrg	# because (1) that's what they normally are, and
949a67f45c3Smrg	# (2) the word "unknown" tends to confuse beginning users.
950a67f45c3Smrg	i*86 | x86_64)
951a67f45c3Smrg		cpu=$basic_machine
952a67f45c3Smrg		vendor=pc
95376910425Smrg		;;
954a67f45c3Smrg	# These rules are duplicated from below for sake of the special case above;
955a67f45c3Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
956a67f45c3Smrg	pc98)
957a67f45c3Smrg		cpu=i386
958a67f45c3Smrg		vendor=pc
95976910425Smrg		;;
960a67f45c3Smrg	x64 | amd64)
961a67f45c3Smrg		cpu=x86_64
962a67f45c3Smrg		vendor=pc
96376910425Smrg		;;
964a67f45c3Smrg	# Recognize the basic CPU types without company name.
965a67f45c3Smrg	*)
966a67f45c3Smrg		cpu=$basic_machine
967a67f45c3Smrg		vendor=unknown
9689ff100acSmrg		;;
969a67f45c3Smrgesac
970a67f45c3Smrg
971a67f45c3Smrgunset -v basic_machine
972a67f45c3Smrg
973a67f45c3Smrg# Decode basic machines in the full and proper CPU-Company form.
974a67f45c3Smrgcase $cpu-$vendor in
975a67f45c3Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
976a67f45c3Smrg	# some cases the only manufacturer, in others, it is the most popular.
977a67f45c3Smrg	craynv-unknown)
978a67f45c3Smrg		vendor=cray
979a67f45c3Smrg		basic_os=${basic_os:-unicosmp}
98076910425Smrg		;;
981a67f45c3Smrg	c90-unknown | c90-cray)
982a67f45c3Smrg		vendor=cray
983a67f45c3Smrg		basic_os=${Basic_os:-unicos}
98476910425Smrg		;;
985a67f45c3Smrg	fx80-unknown)
986a67f45c3Smrg		vendor=alliant
98776910425Smrg		;;
988a67f45c3Smrg	romp-unknown)
989a67f45c3Smrg		vendor=ibm
99076910425Smrg		;;
991a67f45c3Smrg	mmix-unknown)
992a67f45c3Smrg		vendor=knuth
99376910425Smrg		;;
994a67f45c3Smrg	microblaze-unknown | microblazeel-unknown)
995a67f45c3Smrg		vendor=xilinx
99676910425Smrg		;;
997a67f45c3Smrg	rs6000-unknown)
998a67f45c3Smrg		vendor=ibm
99976910425Smrg		;;
1000a67f45c3Smrg	vax-unknown)
1001a67f45c3Smrg		vendor=dec
100276910425Smrg		;;
1003a67f45c3Smrg	pdp11-unknown)
1004a67f45c3Smrg		vendor=dec
100576910425Smrg		;;
1006a67f45c3Smrg	we32k-unknown)
1007a67f45c3Smrg		vendor=att
100876910425Smrg		;;
1009a67f45c3Smrg	cydra-unknown)
1010a67f45c3Smrg		vendor=cydrome
101176910425Smrg		;;
1012a67f45c3Smrg	i370-ibm*)
1013a67f45c3Smrg		vendor=ibm
101476910425Smrg		;;
1015a67f45c3Smrg	orion-unknown)
1016a67f45c3Smrg		vendor=highlevel
101776910425Smrg		;;
1018a67f45c3Smrg	xps-unknown | xps100-unknown)
1019a67f45c3Smrg		cpu=xps100
1020a67f45c3Smrg		vendor=honeywell
102176910425Smrg		;;
1022a67f45c3Smrg
1023a67f45c3Smrg	# Here we normalize CPU types with a missing or matching vendor
10248bfe6addSmrg	armh-unknown | armh-alt)
10258bfe6addSmrg		cpu=armv7l
10268bfe6addSmrg		vendor=alt
10278bfe6addSmrg		basic_os=${basic_os:-linux-gnueabihf}
10288bfe6addSmrg		;;
1029a67f45c3Smrg	dpx20-unknown | dpx20-bull)
1030a67f45c3Smrg		cpu=rs6000
1031a67f45c3Smrg		vendor=bull
1032a67f45c3Smrg		basic_os=${basic_os:-bosx}
103376910425Smrg		;;
1034a67f45c3Smrg
1035a67f45c3Smrg	# Here we normalize CPU types irrespective of the vendor
1036a67f45c3Smrg	amd64-*)
1037a67f45c3Smrg		cpu=x86_64
1038db17cd6dSmrg		;;
1039a67f45c3Smrg	blackfin-*)
1040a67f45c3Smrg		cpu=bfin
1041a67f45c3Smrg		basic_os=linux
104276910425Smrg		;;
1043a67f45c3Smrg	c54x-*)
1044a67f45c3Smrg		cpu=tic54x
104576910425Smrg		;;
1046a67f45c3Smrg	c55x-*)
1047a67f45c3Smrg		cpu=tic55x
104876910425Smrg		;;
1049a67f45c3Smrg	c6x-*)
1050a67f45c3Smrg		cpu=tic6x
105176910425Smrg		;;
1052a67f45c3Smrg	e500v[12]-*)
1053a67f45c3Smrg		cpu=powerpc
1054a67f45c3Smrg		basic_os=${basic_os}"spe"
105576910425Smrg		;;
1056a67f45c3Smrg	mips3*-*)
1057a67f45c3Smrg		cpu=mips64
105876910425Smrg		;;
1059a67f45c3Smrg	ms1-*)
1060a67f45c3Smrg		cpu=mt
106176910425Smrg		;;
1062a67f45c3Smrg	m68knommu-*)
1063a67f45c3Smrg		cpu=m68k
1064a67f45c3Smrg		basic_os=linux
106576910425Smrg		;;
1066a67f45c3Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1067a67f45c3Smrg		cpu=s12z
106876910425Smrg		;;
1069a67f45c3Smrg	openrisc-*)
1070a67f45c3Smrg		cpu=or32
107176910425Smrg		;;
1072a67f45c3Smrg	parisc-*)
1073a67f45c3Smrg		cpu=hppa
1074a67f45c3Smrg		basic_os=linux
107576910425Smrg		;;
1076a67f45c3Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1077a67f45c3Smrg		cpu=i586
107876910425Smrg		;;
10798bfe6addSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1080a67f45c3Smrg		cpu=i686
108176910425Smrg		;;
1082a67f45c3Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1083a67f45c3Smrg		cpu=i686
108476910425Smrg		;;
1085a67f45c3Smrg	pentium4-*)
1086a67f45c3Smrg		cpu=i786
108776910425Smrg		;;
1088a67f45c3Smrg	pc98-*)
1089a67f45c3Smrg		cpu=i386
109076910425Smrg		;;
1091a67f45c3Smrg	ppc-* | ppcbe-*)
1092a67f45c3Smrg		cpu=powerpc
109376910425Smrg		;;
1094a67f45c3Smrg	ppcle-* | powerpclittle-*)
1095a67f45c3Smrg		cpu=powerpcle
109676910425Smrg		;;
1097a67f45c3Smrg	ppc64-*)
1098a67f45c3Smrg		cpu=powerpc64
10999ff100acSmrg		;;
1100a67f45c3Smrg	ppc64le-* | powerpc64little-*)
1101a67f45c3Smrg		cpu=powerpc64le
110276910425Smrg		;;
1103a67f45c3Smrg	sb1-*)
1104a67f45c3Smrg		cpu=mipsisa64sb1
110576910425Smrg		;;
1106a67f45c3Smrg	sb1el-*)
1107a67f45c3Smrg		cpu=mipsisa64sb1el
1108db17cd6dSmrg		;;
1109a67f45c3Smrg	sh5e[lb]-*)
1110a67f45c3Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
111176910425Smrg		;;
1112a67f45c3Smrg	spur-*)
1113a67f45c3Smrg		cpu=spur
111476910425Smrg		;;
1115a67f45c3Smrg	strongarm-* | thumb-*)
1116a67f45c3Smrg		cpu=arm
111776910425Smrg		;;
1118a67f45c3Smrg	tx39-*)
1119a67f45c3Smrg		cpu=mipstx39
112076910425Smrg		;;
1121a67f45c3Smrg	tx39el-*)
1122a67f45c3Smrg		cpu=mipstx39el
112376910425Smrg		;;
1124a67f45c3Smrg	x64-*)
1125a67f45c3Smrg		cpu=x86_64
112676910425Smrg		;;
1127a67f45c3Smrg	xscale-* | xscalee[bl]-*)
1128a67f45c3Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112976910425Smrg		;;
11308bfe6addSmrg	arm64-* | aarch64le-*)
1131a67f45c3Smrg		cpu=aarch64
113276910425Smrg		;;
1133a67f45c3Smrg
1134a67f45c3Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1135a67f45c3Smrg	# company names they are paired with.
1136a67f45c3Smrg	cr16-*)
1137a67f45c3Smrg		basic_os=${basic_os:-elf}
113876910425Smrg		;;
1139a67f45c3Smrg	crisv32-* | etraxfs*-*)
1140a67f45c3Smrg		cpu=crisv32
1141a67f45c3Smrg		vendor=axis
114276910425Smrg		;;
1143a67f45c3Smrg	cris-* | etrax*-*)
1144a67f45c3Smrg		cpu=cris
1145a67f45c3Smrg		vendor=axis
114676910425Smrg		;;
1147a67f45c3Smrg	crx-*)
1148a67f45c3Smrg		basic_os=${basic_os:-elf}
114976910425Smrg		;;
1150a67f45c3Smrg	neo-tandem)
1151a67f45c3Smrg		cpu=neo
1152a67f45c3Smrg		vendor=tandem
115376910425Smrg		;;
1154a67f45c3Smrg	nse-tandem)
1155a67f45c3Smrg		cpu=nse
1156a67f45c3Smrg		vendor=tandem
115776910425Smrg		;;
1158a67f45c3Smrg	nsr-tandem)
1159a67f45c3Smrg		cpu=nsr
1160a67f45c3Smrg		vendor=tandem
116176910425Smrg		;;
1162a67f45c3Smrg	nsv-tandem)
1163a67f45c3Smrg		cpu=nsv
1164a67f45c3Smrg		vendor=tandem
116576910425Smrg		;;
1166a67f45c3Smrg	nsx-tandem)
1167a67f45c3Smrg		cpu=nsx
1168a67f45c3Smrg		vendor=tandem
116976910425Smrg		;;
1170a67f45c3Smrg	mipsallegrexel-sony)
1171a67f45c3Smrg		cpu=mipsallegrexel
1172a67f45c3Smrg		vendor=sony
117376910425Smrg		;;
1174a67f45c3Smrg	tile*-*)
1175a67f45c3Smrg		basic_os=${basic_os:-linux-gnu}
117676910425Smrg		;;
1177a67f45c3Smrg
117876910425Smrg	*)
1179a67f45c3Smrg		# Recognize the canonical CPU types that are allowed with any
1180a67f45c3Smrg		# company name.
1181a67f45c3Smrg		case $cpu in
1182a67f45c3Smrg			1750a | 580 \
1183a67f45c3Smrg			| a29k \
11848bfe6addSmrg			| aarch64 | aarch64_be | aarch64c | arm64ec \
1185a67f45c3Smrg			| abacus \
1186a67f45c3Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1187a67f45c3Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1188a67f45c3Smrg			| alphapca5[67] | alpha64pca5[67] \
1189a67f45c3Smrg			| am33_2.0 \
1190a67f45c3Smrg			| amdgcn \
1191a67f45c3Smrg			| arc | arceb | arc32 | arc64 \
1192a67f45c3Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1193a67f45c3Smrg			| avr | avr32 \
1194a67f45c3Smrg			| asmjs \
1195a67f45c3Smrg			| ba \
1196a67f45c3Smrg			| be32 | be64 \
1197a67f45c3Smrg			| bfin | bpf | bs2000 \
1198a67f45c3Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1199a67f45c3Smrg			| c8051 | clipper | craynv | csky | cydra \
1200a67f45c3Smrg			| d10v | d30v | dlx | dsp16xx \
1201a67f45c3Smrg			| e2k | elxsi | epiphany \
1202a67f45c3Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12038bfe6addSmrg			| javascript \
1204a67f45c3Smrg			| h8300 | h8500 \
1205a67f45c3Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1206a67f45c3Smrg			| hexagon \
1207a67f45c3Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1208a67f45c3Smrg			| ip2k | iq2000 \
1209a67f45c3Smrg			| k1om \
12108bfe6addSmrg			| kvx \
1211a67f45c3Smrg			| le32 | le64 \
1212a67f45c3Smrg			| lm32 \
12138bfe6addSmrg			| loongarch32 | loongarch64 \
1214a67f45c3Smrg			| m32c | m32r | m32rle \
1215a67f45c3Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1216a67f45c3Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1217a67f45c3Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1218a67f45c3Smrg			| microblaze | microblazeel \
12198bfe6addSmrg			| mips* \
1220a67f45c3Smrg			| mmix \
1221a67f45c3Smrg			| mn10200 | mn10300 \
1222a67f45c3Smrg			| moxie \
1223a67f45c3Smrg			| mt \
1224a67f45c3Smrg			| msp430 \
12258bfe6addSmrg			| nanomips* \
1226a67f45c3Smrg			| nds32 | nds32le | nds32be \
1227a67f45c3Smrg			| nfp \
1228a67f45c3Smrg			| nios | nios2 | nios2eb | nios2el \
1229a67f45c3Smrg			| none | np1 | ns16k | ns32k | nvptx \
1230a67f45c3Smrg			| open8 \
1231a67f45c3Smrg			| or1k* \
1232a67f45c3Smrg			| or32 \
1233a67f45c3Smrg			| orion \
1234a67f45c3Smrg			| picochip \
1235a67f45c3Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1236a67f45c3Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1237a67f45c3Smrg			| pru \
1238a67f45c3Smrg			| pyramid \
1239a67f45c3Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1240a67f45c3Smrg			| rl78 | romp | rs6000 | rx \
1241a67f45c3Smrg			| s390 | s390x \
1242a67f45c3Smrg			| score \
1243a67f45c3Smrg			| sh | shl \
1244a67f45c3Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1245a67f45c3Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1246a67f45c3Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1247a67f45c3Smrg			| sparclite \
1248a67f45c3Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1249a67f45c3Smrg			| spu \
1250a67f45c3Smrg			| tahoe \
1251a67f45c3Smrg			| thumbv7* \
1252a67f45c3Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1253a67f45c3Smrg			| tron \
1254a67f45c3Smrg			| ubicom32 \
1255a67f45c3Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1256a67f45c3Smrg			| vax \
12578bfe6addSmrg			| vc4 \
1258a67f45c3Smrg			| visium \
1259a67f45c3Smrg			| w65 \
1260a67f45c3Smrg			| wasm32 | wasm64 \
1261a67f45c3Smrg			| we32k \
1262a67f45c3Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1263a67f45c3Smrg			| xstormy16 | xtensa* \
1264a67f45c3Smrg			| ymp \
1265a67f45c3Smrg			| z8k | z80)
1266a67f45c3Smrg				;;
1267a67f45c3Smrg
1268a67f45c3Smrg			*)
12698bfe6addSmrg				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1270a67f45c3Smrg				exit 1
1271a67f45c3Smrg				;;
1272a67f45c3Smrg		esac
127376910425Smrg		;;
127476910425Smrgesac
127576910425Smrg
127676910425Smrg# Here we canonicalize certain aliases for manufacturers.
1277a67f45c3Smrgcase $vendor in
1278a67f45c3Smrg	digital*)
1279a67f45c3Smrg		vendor=dec
128076910425Smrg		;;
1281a67f45c3Smrg	commodore*)
1282a67f45c3Smrg		vendor=cbm
128376910425Smrg		;;
128476910425Smrg	*)
128576910425Smrg		;;
128676910425Smrgesac
128776910425Smrg
128876910425Smrg# Decode manufacturer-specific aliases for certain operating systems.
128976910425Smrg
12908bfe6addSmrgif test x"$basic_os" != x
129176910425Smrgthen
1292a67f45c3Smrg
12938bfe6addSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1294a67f45c3Smrg# set os.
12958bfe6addSmrgobj=
1296a67f45c3Smrgcase $basic_os in
1297a67f45c3Smrg	gnu/linux*)
1298a67f45c3Smrg		kernel=linux
1299a67f45c3Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1300a67f45c3Smrg		;;
1301a67f45c3Smrg	os2-emx)
1302a67f45c3Smrg		kernel=os2
1303a67f45c3Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1304a67f45c3Smrg		;;
1305a67f45c3Smrg	nto-qnx*)
1306a67f45c3Smrg		kernel=nto
1307a67f45c3Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1308a67f45c3Smrg		;;
1309a67f45c3Smrg	*-*)
1310a67f45c3Smrg		# shellcheck disable=SC2162
1311a67f45c3Smrg		saved_IFS=$IFS
1312a67f45c3Smrg		IFS="-" read kernel os <<EOF
1313a67f45c3Smrg$basic_os
1314a67f45c3SmrgEOF
1315a67f45c3Smrg		IFS=$saved_IFS
1316a67f45c3Smrg		;;
1317a67f45c3Smrg	# Default OS when just kernel was specified
1318a67f45c3Smrg	nto*)
1319a67f45c3Smrg		kernel=nto
1320a67f45c3Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1321a67f45c3Smrg		;;
1322a67f45c3Smrg	linux*)
1323a67f45c3Smrg		kernel=linux
1324a67f45c3Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1325a67f45c3Smrg		;;
13268bfe6addSmrg	managarm*)
13278bfe6addSmrg		kernel=managarm
13288bfe6addSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
13298bfe6addSmrg		;;
1330a67f45c3Smrg	*)
1331a67f45c3Smrg		kernel=
1332a67f45c3Smrg		os=$basic_os
1333a67f45c3Smrg		;;
1334a67f45c3Smrgesac
1335a67f45c3Smrg
1336a67f45c3Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1337a67f45c3Smrg# etc.)
133876910425Smrgcase $os in
1339a67f45c3Smrg	# First match some system type aliases that might get confused
1340a67f45c3Smrg	# with valid system types.
1341a67f45c3Smrg	# solaris* is a basic system type, with this one exception.
1342a67f45c3Smrg	auroraux)
1343a67f45c3Smrg		os=auroraux
1344482df631Smrg		;;
1345a67f45c3Smrg	bluegene*)
1346a67f45c3Smrg		os=cnk
134776910425Smrg		;;
1348a67f45c3Smrg	solaris1 | solaris1.*)
1349a67f45c3Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
135076910425Smrg		;;
1351a67f45c3Smrg	solaris)
1352a67f45c3Smrg		os=solaris2
135376910425Smrg		;;
1354a67f45c3Smrg	unixware*)
1355a67f45c3Smrg		os=sysv4.2uw
135676910425Smrg		;;
1357a67f45c3Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1358a67f45c3Smrg	es1800*)
1359a67f45c3Smrg		os=ose
136076910425Smrg		;;
1361a67f45c3Smrg	# Some version numbers need modification
1362a67f45c3Smrg	chorusos*)
1363a67f45c3Smrg		os=chorusos
136476910425Smrg		;;
1365a67f45c3Smrg	isc)
1366a67f45c3Smrg		os=isc2.2
136776910425Smrg		;;
1368a67f45c3Smrg	sco6)
1369a67f45c3Smrg		os=sco5v6
137076910425Smrg		;;
1371a67f45c3Smrg	sco5)
1372a67f45c3Smrg		os=sco3.2v5
137376910425Smrg		;;
1374a67f45c3Smrg	sco4)
1375a67f45c3Smrg		os=sco3.2v4
137676910425Smrg		;;
1377a67f45c3Smrg	sco3.2.[4-9]*)
1378a67f45c3Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
137976910425Smrg		;;
1380a67f45c3Smrg	sco*v* | scout)
1381a67f45c3Smrg		# Don't match below
138276910425Smrg		;;
1383a67f45c3Smrg	sco*)
1384a67f45c3Smrg		os=sco3.2v2
138576910425Smrg		;;
1386a67f45c3Smrg	psos*)
1387a67f45c3Smrg		os=psos
138876910425Smrg		;;
1389a67f45c3Smrg	qnx*)
1390a67f45c3Smrg		os=qnx
139176910425Smrg		;;
1392a67f45c3Smrg	hiux*)
1393a67f45c3Smrg		os=hiuxwe2
139476910425Smrg		;;
1395a67f45c3Smrg	lynx*178)
1396a67f45c3Smrg		os=lynxos178
139776910425Smrg		;;
1398a67f45c3Smrg	lynx*5)
1399a67f45c3Smrg		os=lynxos5
140076910425Smrg		;;
1401a67f45c3Smrg	lynxos*)
1402a67f45c3Smrg		# don't get caught up in next wildcard
140376910425Smrg		;;
1404a67f45c3Smrg	lynx*)
1405a67f45c3Smrg		os=lynxos
140676910425Smrg		;;
1407a67f45c3Smrg	mac[0-9]*)
1408a67f45c3Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
140976910425Smrg		;;
1410a67f45c3Smrg	opened*)
1411a67f45c3Smrg		os=openedition
141276910425Smrg		;;
1413a67f45c3Smrg	os400*)
1414a67f45c3Smrg		os=os400
141576910425Smrg		;;
1416a67f45c3Smrg	sunos5*)
1417a67f45c3Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
141876910425Smrg		;;
1419a67f45c3Smrg	sunos6*)
1420a67f45c3Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
142176910425Smrg		;;
1422a67f45c3Smrg	wince*)
1423a67f45c3Smrg		os=wince
142476910425Smrg		;;
1425a67f45c3Smrg	utek*)
1426a67f45c3Smrg		os=bsd
142776910425Smrg		;;
1428a67f45c3Smrg	dynix*)
1429a67f45c3Smrg		os=bsd
143076910425Smrg		;;
1431a67f45c3Smrg	acis*)
1432a67f45c3Smrg		os=aos
143376910425Smrg		;;
1434a67f45c3Smrg	atheos*)
1435a67f45c3Smrg		os=atheos
143676910425Smrg		;;
1437a67f45c3Smrg	syllable*)
1438a67f45c3Smrg		os=syllable
143976910425Smrg		;;
1440a67f45c3Smrg	386bsd)
1441a67f45c3Smrg		os=bsd
144276910425Smrg		;;
1443a67f45c3Smrg	ctix* | uts*)
1444a67f45c3Smrg		os=sysv
144576910425Smrg		;;
1446a67f45c3Smrg	nova*)
1447a67f45c3Smrg		os=rtmk-nova
144876910425Smrg		;;
1449a67f45c3Smrg	ns2)
1450a67f45c3Smrg		os=nextstep2
145176910425Smrg		;;
1452a67f45c3Smrg	# Preserve the version number of sinix5.
1453a67f45c3Smrg	sinix5.*)
1454a67f45c3Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
145576910425Smrg		;;
1456a67f45c3Smrg	sinix*)
1457a67f45c3Smrg		os=sysv4
145876910425Smrg		;;
1459a67f45c3Smrg	tpf*)
1460a67f45c3Smrg		os=tpf
146176910425Smrg		;;
1462a67f45c3Smrg	triton*)
1463a67f45c3Smrg		os=sysv3
146476910425Smrg		;;
1465a67f45c3Smrg	oss*)
1466a67f45c3Smrg		os=sysv3
146776910425Smrg		;;
1468a67f45c3Smrg	svr4*)
1469a67f45c3Smrg		os=sysv4
147076910425Smrg		;;
1471a67f45c3Smrg	svr3)
1472a67f45c3Smrg		os=sysv3
147376910425Smrg		;;
1474a67f45c3Smrg	sysvr4)
1475a67f45c3Smrg		os=sysv4
147676910425Smrg		;;
1477a67f45c3Smrg	ose*)
1478a67f45c3Smrg		os=ose
147976910425Smrg		;;
1480a67f45c3Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1481a67f45c3Smrg		os=mint
1482db17cd6dSmrg		;;
1483a67f45c3Smrg	dicos*)
1484a67f45c3Smrg		os=dicos
14859ff100acSmrg		;;
1486a67f45c3Smrg	pikeos*)
1487a67f45c3Smrg		# Until real need of OS specific support for
1488a67f45c3Smrg		# particular features comes up, bare metal
1489a67f45c3Smrg		# configurations are quite functional.
1490a67f45c3Smrg		case $cpu in
1491a67f45c3Smrg		    arm*)
1492a67f45c3Smrg			os=eabi
1493a67f45c3Smrg			;;
1494a67f45c3Smrg		    *)
14958bfe6addSmrg			os=
14968bfe6addSmrg			obj=elf
1497a67f45c3Smrg			;;
1498a67f45c3Smrg		esac
149976910425Smrg		;;
15008bfe6addSmrg	aout* | coff* | elf* | pe*)
15018bfe6addSmrg		# These are machine code file formats, not OSes
15028bfe6addSmrg		obj=$os
15038bfe6addSmrg		os=
15048bfe6addSmrg		;;
150576910425Smrg	*)
1506a67f45c3Smrg		# No normalization, but not necessarily accepted, that comes below.
150776910425Smrg		;;
150876910425Smrgesac
1509a67f45c3Smrg
151076910425Smrgelse
151176910425Smrg
151276910425Smrg# Here we handle the default operating systems that come with various machines.
151376910425Smrg# The value should be what the vendor currently ships out the door with their
151476910425Smrg# machine or put another way, the most popular os provided with the machine.
151576910425Smrg
151676910425Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
151776910425Smrg# "-sun"), then you have to tell the case statement up towards the top
151876910425Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
151976910425Smrg# will signal an error saying that MANUFACTURER isn't an operating
152076910425Smrg# system, and we'll never get to this point.
152176910425Smrg
1522a67f45c3Smrgkernel=
15238bfe6addSmrgobj=
1524a67f45c3Smrgcase $cpu-$vendor in
15259ff100acSmrg	score-*)
15268bfe6addSmrg		os=
15278bfe6addSmrg		obj=elf
1528db17cd6dSmrg		;;
15299ff100acSmrg	spu-*)
15308bfe6addSmrg		os=
15318bfe6addSmrg		obj=elf
1532db17cd6dSmrg		;;
153376910425Smrg	*-acorn)
1534a67f45c3Smrg		os=riscix1.2
153576910425Smrg		;;
153676910425Smrg	arm*-rebel)
1537a67f45c3Smrg		kernel=linux
1538a67f45c3Smrg		os=gnu
153976910425Smrg		;;
154076910425Smrg	arm*-semi)
15418bfe6addSmrg		os=
15428bfe6addSmrg		obj=aout
154376910425Smrg		;;
15449ff100acSmrg	c4x-* | tic4x-*)
15458bfe6addSmrg		os=
15468bfe6addSmrg		obj=coff
15479ff100acSmrg		;;
15489ff100acSmrg	c8051-*)
15498bfe6addSmrg		os=
15508bfe6addSmrg		obj=elf
1551a67f45c3Smrg		;;
1552a67f45c3Smrg	clipper-intergraph)
1553a67f45c3Smrg		os=clix
15549ff100acSmrg		;;
15559ff100acSmrg	hexagon-*)
15568bfe6addSmrg		os=
15578bfe6addSmrg		obj=elf
1558db17cd6dSmrg		;;
1559482df631Smrg	tic54x-*)
15608bfe6addSmrg		os=
15618bfe6addSmrg		obj=coff
1562482df631Smrg		;;
1563482df631Smrg	tic55x-*)
15648bfe6addSmrg		os=
15658bfe6addSmrg		obj=coff
1566482df631Smrg		;;
1567482df631Smrg	tic6x-*)
15688bfe6addSmrg		os=
15698bfe6addSmrg		obj=coff
1570482df631Smrg		;;
157176910425Smrg	# This must come before the *-dec entry.
157276910425Smrg	pdp10-*)
1573a67f45c3Smrg		os=tops20
157476910425Smrg		;;
157576910425Smrg	pdp11-*)
1576a67f45c3Smrg		os=none
157776910425Smrg		;;
157876910425Smrg	*-dec | vax-*)
1579a67f45c3Smrg		os=ultrix4.2
158076910425Smrg		;;
158176910425Smrg	m68*-apollo)
1582a67f45c3Smrg		os=domain
158376910425Smrg		;;
158476910425Smrg	i386-sun)
1585a67f45c3Smrg		os=sunos4.0.2
158676910425Smrg		;;
158776910425Smrg	m68000-sun)
1588a67f45c3Smrg		os=sunos3
158976910425Smrg		;;
159076910425Smrg	m68*-cisco)
15918bfe6addSmrg		os=
15928bfe6addSmrg		obj=aout
159376910425Smrg		;;
15949ff100acSmrg	mep-*)
15958bfe6addSmrg		os=
15968bfe6addSmrg		obj=elf
1597db17cd6dSmrg		;;
159876910425Smrg	mips*-cisco)
15998bfe6addSmrg		os=
16008bfe6addSmrg		obj=elf
160176910425Smrg		;;
16028bfe6addSmrg	mips*-*|nanomips*-*)
16038bfe6addSmrg		os=
16048bfe6addSmrg		obj=elf
160576910425Smrg		;;
160676910425Smrg	or32-*)
16078bfe6addSmrg		os=
16088bfe6addSmrg		obj=coff
160976910425Smrg		;;
161076910425Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1611a67f45c3Smrg		os=sysv3
161276910425Smrg		;;
161376910425Smrg	sparc-* | *-sun)
1614a67f45c3Smrg		os=sunos4.1.1
161576910425Smrg		;;
1616a67f45c3Smrg	pru-*)
16178bfe6addSmrg		os=
16188bfe6addSmrg		obj=elf
161976910425Smrg		;;
1620a67f45c3Smrg	*-be)
1621a67f45c3Smrg		os=beos
162276910425Smrg		;;
162376910425Smrg	*-ibm)
1624a67f45c3Smrg		os=aix
162576910425Smrg		;;
16269ff100acSmrg	*-knuth)
1627a67f45c3Smrg		os=mmixware
162876910425Smrg		;;
162976910425Smrg	*-wec)
1630a67f45c3Smrg		os=proelf
163176910425Smrg		;;
163276910425Smrg	*-winbond)
1633a67f45c3Smrg		os=proelf
163476910425Smrg		;;
163576910425Smrg	*-oki)
1636a67f45c3Smrg		os=proelf
163776910425Smrg		;;
163876910425Smrg	*-hp)
1639a67f45c3Smrg		os=hpux
164076910425Smrg		;;
164176910425Smrg	*-hitachi)
1642a67f45c3Smrg		os=hiux
164376910425Smrg		;;
164476910425Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1645a67f45c3Smrg		os=sysv
164676910425Smrg		;;
164776910425Smrg	*-cbm)
1648a67f45c3Smrg		os=amigaos
164976910425Smrg		;;
165076910425Smrg	*-dg)
1651a67f45c3Smrg		os=dgux
165276910425Smrg		;;
165376910425Smrg	*-dolphin)
1654a67f45c3Smrg		os=sysv3
165576910425Smrg		;;
165676910425Smrg	m68k-ccur)
1657a67f45c3Smrg		os=rtu
165876910425Smrg		;;
165976910425Smrg	m88k-omron*)
1660a67f45c3Smrg		os=luna
166176910425Smrg		;;
1662a67f45c3Smrg	*-next)
1663a67f45c3Smrg		os=nextstep
166476910425Smrg		;;
166576910425Smrg	*-sequent)
1666a67f45c3Smrg		os=ptx
166776910425Smrg		;;
166876910425Smrg	*-crds)
1669a67f45c3Smrg		os=unos
167076910425Smrg		;;
167176910425Smrg	*-ns)
1672a67f45c3Smrg		os=genix
167376910425Smrg		;;
167476910425Smrg	i370-*)
1675a67f45c3Smrg		os=mvs
167676910425Smrg		;;
167776910425Smrg	*-gould)
1678a67f45c3Smrg		os=sysv
167976910425Smrg		;;
168076910425Smrg	*-highlevel)
1681a67f45c3Smrg		os=bsd
168276910425Smrg		;;
168376910425Smrg	*-encore)
1684a67f45c3Smrg		os=bsd
168576910425Smrg		;;
168676910425Smrg	*-sgi)
1687a67f45c3Smrg		os=irix
168876910425Smrg		;;
168976910425Smrg	*-siemens)
1690a67f45c3Smrg		os=sysv4
169176910425Smrg		;;
169276910425Smrg	*-masscomp)
1693a67f45c3Smrg		os=rtu
169476910425Smrg		;;
169576910425Smrg	f30[01]-fujitsu | f700-fujitsu)
1696a67f45c3Smrg		os=uxpv
169776910425Smrg		;;
169876910425Smrg	*-rom68k)
16998bfe6addSmrg		os=
17008bfe6addSmrg		obj=coff
170176910425Smrg		;;
170276910425Smrg	*-*bug)
17038bfe6addSmrg		os=
17048bfe6addSmrg		obj=coff
170576910425Smrg		;;
170676910425Smrg	*-apple)
1707a67f45c3Smrg		os=macos
170876910425Smrg		;;
170976910425Smrg	*-atari*)
1710a67f45c3Smrg		os=mint
1711a67f45c3Smrg		;;
1712a67f45c3Smrg	*-wrs)
1713a67f45c3Smrg		os=vxworks
171476910425Smrg		;;
171576910425Smrg	*)
1716a67f45c3Smrg		os=none
171776910425Smrg		;;
171876910425Smrgesac
1719a67f45c3Smrg
172076910425Smrgfi
172176910425Smrg
17228bfe6addSmrg# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
17238bfe6addSmrg
1724a67f45c3Smrgcase $os in
1725a67f45c3Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17268bfe6addSmrg	llvm* | musl* | newlib* | relibc* | uclibc*)
1727a67f45c3Smrg		;;
1728a67f45c3Smrg	# Likewise for "kernel-abi"
1729a67f45c3Smrg	eabi* | gnueabi*)
1730a67f45c3Smrg		;;
1731a67f45c3Smrg	# VxWorks passes extra cpu info in the 4th filed.
1732a67f45c3Smrg	simlinux | simwindows | spe)
1733a67f45c3Smrg		;;
17348bfe6addSmrg	# See `case $cpu-$os` validation below
17358bfe6addSmrg	ghcjs)
17368bfe6addSmrg		;;
1737a67f45c3Smrg	# Now accept the basic system types.
1738a67f45c3Smrg	# The portable systems comes first.
1739a67f45c3Smrg	# Each alternative MUST end in a * to match a version number.
1740a67f45c3Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1741a67f45c3Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1742a67f45c3Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1743a67f45c3Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1744a67f45c3Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17458bfe6addSmrg	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
1746a67f45c3Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1747a67f45c3Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1748a67f45c3Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1749a67f45c3Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1750a67f45c3Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1751a67f45c3Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1752a67f45c3Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1753a67f45c3Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17548bfe6addSmrg	     | bosx* | nextstep* | cxux* | oabi* \
17558bfe6addSmrg	     | ptx* | ecoff* | winnt* | domain* | vsta* \
1756a67f45c3Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1757a67f45c3Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17588bfe6addSmrg	     | cygwin* | msys* | moss* | proelf* | rtems* \
1759a67f45c3Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1760a67f45c3Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1761a67f45c3Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1762a67f45c3Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1763a67f45c3Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1764a67f45c3Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1765a67f45c3Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1766a67f45c3Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1767a67f45c3Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1768a67f45c3Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1769a67f45c3Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17708bfe6addSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
17718bfe6addSmrg	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
1772a67f45c3Smrg		;;
1773a67f45c3Smrg	# This one is extra strict with allowed versions
1774a67f45c3Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1775a67f45c3Smrg		# Don't forget version if it is 3.2v4 or newer.
1776a67f45c3Smrg		;;
17778bfe6addSmrg	# This refers to builds using the UEFI calling convention
17788bfe6addSmrg	# (which depends on the architecture) and PE file format.
17798bfe6addSmrg	# Note that this is both a different calling convention and
17808bfe6addSmrg	# different file format than that of GNU-EFI
17818bfe6addSmrg	# (x86_64-w64-mingw32).
17828bfe6addSmrg	uefi)
17838bfe6addSmrg		;;
1784a67f45c3Smrg	none)
1785a67f45c3Smrg		;;
17868bfe6addSmrg	kernel* | msvc* )
17878bfe6addSmrg		# Restricted further below
17888bfe6addSmrg		;;
17898bfe6addSmrg	'')
17908bfe6addSmrg		if test x"$obj" = x
17918bfe6addSmrg		then
17928bfe6addSmrg			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
17938bfe6addSmrg		fi
17948bfe6addSmrg		;;
1795a67f45c3Smrg	*)
17968bfe6addSmrg		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
17978bfe6addSmrg		exit 1
17988bfe6addSmrg		;;
17998bfe6addSmrgesac
18008bfe6addSmrg
18018bfe6addSmrgcase $obj in
18028bfe6addSmrg	aout* | coff* | elf* | pe*)
18038bfe6addSmrg		;;
18048bfe6addSmrg	'')
18058bfe6addSmrg		# empty is fine
18068bfe6addSmrg		;;
18078bfe6addSmrg	*)
18088bfe6addSmrg		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
18098bfe6addSmrg		exit 1
18108bfe6addSmrg		;;
18118bfe6addSmrgesac
18128bfe6addSmrg
18138bfe6addSmrg# Here we handle the constraint that a (synthetic) cpu and os are
18148bfe6addSmrg# valid only in combination with each other and nowhere else.
18158bfe6addSmrgcase $cpu-$os in
18168bfe6addSmrg	# The "javascript-unknown-ghcjs" triple is used by GHC; we
18178bfe6addSmrg	# accept it here in order to tolerate that, but reject any
18188bfe6addSmrg	# variations.
18198bfe6addSmrg	javascript-ghcjs)
18208bfe6addSmrg		;;
18218bfe6addSmrg	javascript-* | *-ghcjs)
18228bfe6addSmrg		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
1823a67f45c3Smrg		exit 1
1824a67f45c3Smrg		;;
1825a67f45c3Smrgesac
1826a67f45c3Smrg
1827a67f45c3Smrg# As a final step for OS-related things, validate the OS-kernel combination
1828a67f45c3Smrg# (given a valid OS), if there is a kernel.
18298bfe6addSmrgcase $kernel-$os-$obj in
18308bfe6addSmrg	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
18318bfe6addSmrg		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
18328bfe6addSmrg		    | linux-relibc*- | linux-uclibc*- )
18338bfe6addSmrg		;;
18348bfe6addSmrg	uclinux-uclibc*- )
18358bfe6addSmrg		;;
18368bfe6addSmrg	managarm-mlibc*- | managarm-kernel*- )
1837a67f45c3Smrg		;;
18388bfe6addSmrg	windows*-msvc*-)
1839a67f45c3Smrg		;;
18408bfe6addSmrg	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
18418bfe6addSmrg		    | -uclibc*- )
1842a67f45c3Smrg		# These are just libc implementations, not actual OSes, and thus
1843a67f45c3Smrg		# require a kernel.
18448bfe6addSmrg		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
1845a67f45c3Smrg		exit 1
1846a67f45c3Smrg		;;
18478bfe6addSmrg	-kernel*- )
18488bfe6addSmrg		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
18498bfe6addSmrg		exit 1
1850a67f45c3Smrg		;;
18518bfe6addSmrg	*-kernel*- )
18528bfe6addSmrg		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
18538bfe6addSmrg		exit 1
1854a67f45c3Smrg		;;
18558bfe6addSmrg	*-msvc*- )
18568bfe6addSmrg		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
18578bfe6addSmrg		exit 1
1858a67f45c3Smrg		;;
18598bfe6addSmrg	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
18608bfe6addSmrg		;;
18618bfe6addSmrg	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
18628bfe6addSmrg		;;
18638bfe6addSmrg	nto-qnx*-)
18648bfe6addSmrg		;;
18658bfe6addSmrg	os2-emx-)
1866a67f45c3Smrg		;;
18678bfe6addSmrg	*-eabi*- | *-gnueabi*-)
1868a67f45c3Smrg		;;
18698bfe6addSmrg	none--*)
18708bfe6addSmrg		# None (no kernel, i.e. freestanding / bare metal),
18718bfe6addSmrg		# can be paired with an machine code file format
18728bfe6addSmrg		;;
18738bfe6addSmrg	-*-)
1874a67f45c3Smrg		# Blank kernel with real OS is always fine.
1875a67f45c3Smrg		;;
18768bfe6addSmrg	--*)
18778bfe6addSmrg		# Blank kernel and OS with real machine code file format is always fine.
18788bfe6addSmrg		;;
18798bfe6addSmrg	*-*-*)
18808bfe6addSmrg		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
1881a67f45c3Smrg		exit 1
1882a67f45c3Smrg		;;
1883a67f45c3Smrgesac
1884a67f45c3Smrg
188576910425Smrg# Here we handle the case where we know the os, and the CPU type, but not the
188676910425Smrg# manufacturer.  We pick the logical manufacturer.
1887a67f45c3Smrgcase $vendor in
1888a67f45c3Smrg	unknown)
1889a67f45c3Smrg		case $cpu-$os in
1890a67f45c3Smrg			*-riscix*)
189176910425Smrg				vendor=acorn
189276910425Smrg				;;
1893a67f45c3Smrg			*-sunos*)
189476910425Smrg				vendor=sun
189576910425Smrg				;;
1896a67f45c3Smrg			*-cnk* | *-aix*)
189776910425Smrg				vendor=ibm
189876910425Smrg				;;
1899a67f45c3Smrg			*-beos*)
190076910425Smrg				vendor=be
190176910425Smrg				;;
1902a67f45c3Smrg			*-hpux*)
190376910425Smrg				vendor=hp
190476910425Smrg				;;
1905a67f45c3Smrg			*-mpeix*)
190676910425Smrg				vendor=hp
190776910425Smrg				;;
1908a67f45c3Smrg			*-hiux*)
190976910425Smrg				vendor=hitachi
191076910425Smrg				;;
1911a67f45c3Smrg			*-unos*)
191276910425Smrg				vendor=crds
191376910425Smrg				;;
1914a67f45c3Smrg			*-dgux*)
191576910425Smrg				vendor=dg
191676910425Smrg				;;
1917a67f45c3Smrg			*-luna*)
191876910425Smrg				vendor=omron
191976910425Smrg				;;
1920a67f45c3Smrg			*-genix*)
192176910425Smrg				vendor=ns
192276910425Smrg				;;
1923a67f45c3Smrg			*-clix*)
1924a67f45c3Smrg				vendor=intergraph
1925a67f45c3Smrg				;;
1926a67f45c3Smrg			*-mvs* | *-opened*)
1927a67f45c3Smrg				vendor=ibm
1928a67f45c3Smrg				;;
1929a67f45c3Smrg			*-os400*)
193076910425Smrg				vendor=ibm
193176910425Smrg				;;
1932a67f45c3Smrg			s390-* | s390x-*)
193376910425Smrg				vendor=ibm
193476910425Smrg				;;
1935a67f45c3Smrg			*-ptx*)
193676910425Smrg				vendor=sequent
193776910425Smrg				;;
1938a67f45c3Smrg			*-tpf*)
193976910425Smrg				vendor=ibm
194076910425Smrg				;;
1941a67f45c3Smrg			*-vxsim* | *-vxworks* | *-windiss*)
194276910425Smrg				vendor=wrs
194376910425Smrg				;;
1944a67f45c3Smrg			*-aux*)
194576910425Smrg				vendor=apple
194676910425Smrg				;;
1947a67f45c3Smrg			*-hms*)
194876910425Smrg				vendor=hitachi
194976910425Smrg				;;
1950a67f45c3Smrg			*-mpw* | *-macos*)
195176910425Smrg				vendor=apple
195276910425Smrg				;;
1953a67f45c3Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
195476910425Smrg				vendor=atari
195576910425Smrg				;;
1956a67f45c3Smrg			*-vos*)
195776910425Smrg				vendor=stratus
195876910425Smrg				;;
195976910425Smrg		esac
196076910425Smrg		;;
196176910425Smrgesac
196276910425Smrg
19638bfe6addSmrgecho "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
196476910425Smrgexit
196576910425Smrg
196676910425Smrg# Local variables:
1967a67f45c3Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
196876910425Smrg# time-stamp-start: "timestamp='"
196976910425Smrg# time-stamp-format: "%:y-%02m-%02d"
197076910425Smrg# time-stamp-end: "'"
197176910425Smrg# End:
1972