1eaef79e5Smrg#! /bin/sh
2eaef79e5Smrg# Configuration validation subroutine script.
3433d0511Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4eaef79e5Smrg
5433d0511Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6433d0511Smrg
7433d0511Smrgtimestamp='2023-01-21'
8eaef79e5Smrg
9cbc4e2beSmrg# This file is free software; you can redistribute it and/or modify it
10cbc4e2beSmrg# under the terms of the GNU General Public License as published by
11433d0511Smrg# the Free Software Foundation, either version 3 of the License, or
12eaef79e5Smrg# (at your option) any later version.
13eaef79e5Smrg#
14cbc4e2beSmrg# This program is distributed in the hope that it will be useful, but
15cbc4e2beSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16cbc4e2beSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17cbc4e2beSmrg# General Public License for more details.
18eaef79e5Smrg#
19eaef79e5Smrg# You should have received a copy of the GNU General Public License
206654de8bSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21eaef79e5Smrg#
22eaef79e5Smrg# As a special exception to the GNU General Public License, if you
23eaef79e5Smrg# distribute this file as part of a program that contains a
24eaef79e5Smrg# configuration script generated by Autoconf, you may include it under
25cbc4e2beSmrg# the same distribution terms that you use for the rest of that
26cbc4e2beSmrg# program.  This Exception is an additional permission under section 7
27cbc4e2beSmrg# of the GNU General Public License, version 3 ("GPLv3").
28eaef79e5Smrg
29eaef79e5Smrg
30d1a7ce7bSmrg# Please send patches to <config-patches@gnu.org>.
31eaef79e5Smrg#
32eaef79e5Smrg# Configuration subroutine to validate and canonicalize a configuration type.
33eaef79e5Smrg# Supply the specified configuration type as an argument.
34eaef79e5Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
35eaef79e5Smrg# Otherwise, we print the canonical config type on stdout and succeed.
36eaef79e5Smrg
3795e0246bSmrg# You can get the latest version of this script from:
38433d0511Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3995e0246bSmrg
40eaef79e5Smrg# This file is supposed to be the same for all GNU packages
41eaef79e5Smrg# and recognize all the CPU types, system types and aliases
42eaef79e5Smrg# that are meaningful with *any* GNU software.
43eaef79e5Smrg# Each package is responsible for reporting which valid configurations
44eaef79e5Smrg# it does not support.  The user should be able to distinguish
45eaef79e5Smrg# a failure to support a valid configuration from a meaningless
46eaef79e5Smrg# configuration.
47eaef79e5Smrg
48eaef79e5Smrg# The goal of this file is to map all the various variations of a given
49eaef79e5Smrg# machine specification into a single specification in the form:
50eaef79e5Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51eaef79e5Smrg# or in some cases, the newer four-part form:
52eaef79e5Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53eaef79e5Smrg# It is wrong to echo any other type of specification.
54eaef79e5Smrg
55433d0511Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56433d0511Smrg# about features and limitations of the classic Bourne shell that were
57433d0511Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58433d0511Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59433d0511Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60433d0511Smrg# have a pre-POSIX /bin/sh.
61433d0511Smrg
62eaef79e5Smrgme=`echo "$0" | sed -e 's,.*/,,'`
63eaef79e5Smrg
64eaef79e5Smrgusage="\
656654de8bSmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66eaef79e5Smrg
67eaef79e5SmrgCanonicalize a configuration name.
68eaef79e5Smrg
696654de8bSmrgOptions:
70eaef79e5Smrg  -h, --help         print this help, then exit
71eaef79e5Smrg  -t, --time-stamp   print date of last modification, then exit
72eaef79e5Smrg  -v, --version      print version number, then exit
73eaef79e5Smrg
74eaef79e5SmrgReport bugs and patches to <config-patches@gnu.org>."
75eaef79e5Smrg
76eaef79e5Smrgversion="\
77eaef79e5SmrgGNU config.sub ($timestamp)
78eaef79e5Smrg
79433d0511SmrgCopyright 1992-2023 Free Software Foundation, Inc.
80eaef79e5Smrg
81eaef79e5SmrgThis is free software; see the source for copying conditions.  There is NO
82eaef79e5Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83eaef79e5Smrg
84eaef79e5Smrghelp="
85eaef79e5SmrgTry \`$me --help' for more information."
86eaef79e5Smrg
87eaef79e5Smrg# Parse command line
88eaef79e5Smrgwhile test $# -gt 0 ; do
89eaef79e5Smrg  case $1 in
90eaef79e5Smrg    --time-stamp | --time* | -t )
91eaef79e5Smrg       echo "$timestamp" ; exit ;;
92eaef79e5Smrg    --version | -v )
93eaef79e5Smrg       echo "$version" ; exit ;;
94eaef79e5Smrg    --help | --h* | -h )
95eaef79e5Smrg       echo "$usage"; exit ;;
96eaef79e5Smrg    -- )     # Stop option processing
97eaef79e5Smrg       shift; break ;;
98eaef79e5Smrg    - )	# Use stdin as input.
99eaef79e5Smrg       break ;;
100eaef79e5Smrg    -* )
101433d0511Smrg       echo "$me: invalid option $1$help" >&2
102eaef79e5Smrg       exit 1 ;;
103eaef79e5Smrg
104eaef79e5Smrg    *local*)
105eaef79e5Smrg       # First pass through any local machine types.
1066654de8bSmrg       echo "$1"
107eaef79e5Smrg       exit ;;
108eaef79e5Smrg
109eaef79e5Smrg    * )
110eaef79e5Smrg       break ;;
111eaef79e5Smrg  esac
112eaef79e5Smrgdone
113eaef79e5Smrg
114eaef79e5Smrgcase $# in
115eaef79e5Smrg 0) echo "$me: missing argument$help" >&2
116eaef79e5Smrg    exit 1;;
117eaef79e5Smrg 1) ;;
118eaef79e5Smrg *) echo "$me: too many arguments$help" >&2
119eaef79e5Smrg    exit 1;;
120eaef79e5Smrgesac
121eaef79e5Smrg
122433d0511Smrg# Split fields of configuration type
123433d0511Smrg# shellcheck disable=SC2162
124433d0511Smrgsaved_IFS=$IFS
125433d0511SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126433d0511Smrg$1
127433d0511SmrgEOF
128433d0511SmrgIFS=$saved_IFS
129eaef79e5Smrg
130433d0511Smrg# Separate into logical components for further validation
131433d0511Smrgcase $1 in
132433d0511Smrg	*-*-*-*-*)
133433d0511Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134433d0511Smrg		exit 1
135cbc4e2beSmrg		;;
136433d0511Smrg	*-*-*-*)
137433d0511Smrg		basic_machine=$field1-$field2
138433d0511Smrg		basic_os=$field3-$field4
139eaef79e5Smrg		;;
140433d0511Smrg	*-*-*)
141433d0511Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142433d0511Smrg		# parts
143433d0511Smrg		maybe_os=$field2-$field3
144433d0511Smrg		case $maybe_os in
145433d0511Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146433d0511Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147433d0511Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148433d0511Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
149433d0511Smrg				basic_machine=$field1
150433d0511Smrg				basic_os=$maybe_os
151433d0511Smrg				;;
152433d0511Smrg			android-linux)
153433d0511Smrg				basic_machine=$field1-unknown
154433d0511Smrg				basic_os=linux-android
155433d0511Smrg				;;
156433d0511Smrg			*)
157433d0511Smrg				basic_machine=$field1-$field2
158433d0511Smrg				basic_os=$field3
159433d0511Smrg				;;
160433d0511Smrg		esac
161eaef79e5Smrg		;;
162433d0511Smrg	*-*)
163433d0511Smrg		# A lone config we happen to match not fitting any pattern
164433d0511Smrg		case $field1-$field2 in
165433d0511Smrg			decstation-3100)
166433d0511Smrg				basic_machine=mips-dec
167433d0511Smrg				basic_os=
168433d0511Smrg				;;
169433d0511Smrg			*-*)
170433d0511Smrg				# Second component is usually, but not always the OS
171433d0511Smrg				case $field2 in
172433d0511Smrg					# Prevent following clause from handling this valid os
173433d0511Smrg					sun*os*)
174433d0511Smrg						basic_machine=$field1
175433d0511Smrg						basic_os=$field2
176433d0511Smrg						;;
177433d0511Smrg					zephyr*)
178433d0511Smrg						basic_machine=$field1-unknown
179433d0511Smrg						basic_os=$field2
180433d0511Smrg						;;
181433d0511Smrg					# Manufacturers
182433d0511Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183433d0511Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184433d0511Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185433d0511Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186433d0511Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187433d0511Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188433d0511Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189433d0511Smrg					| microblaze* | sim | cisco \
190433d0511Smrg					| oki | wec | wrs | winbond)
191433d0511Smrg						basic_machine=$field1-$field2
192433d0511Smrg						basic_os=
193433d0511Smrg						;;
194433d0511Smrg					*)
195433d0511Smrg						basic_machine=$field1
196433d0511Smrg						basic_os=$field2
197433d0511Smrg						;;
198433d0511Smrg				esac
199433d0511Smrg			;;
200433d0511Smrg		esac
201eaef79e5Smrg		;;
202433d0511Smrg	*)
203433d0511Smrg		# Convert single-component short-hands not valid as part of
204433d0511Smrg		# multi-component configurations.
205433d0511Smrg		case $field1 in
206433d0511Smrg			386bsd)
207433d0511Smrg				basic_machine=i386-pc
208433d0511Smrg				basic_os=bsd
209433d0511Smrg				;;
210433d0511Smrg			a29khif)
211433d0511Smrg				basic_machine=a29k-amd
212433d0511Smrg				basic_os=udi
213433d0511Smrg				;;
214433d0511Smrg			adobe68k)
215433d0511Smrg				basic_machine=m68010-adobe
216433d0511Smrg				basic_os=scout
217433d0511Smrg				;;
218433d0511Smrg			alliant)
219433d0511Smrg				basic_machine=fx80-alliant
220433d0511Smrg				basic_os=
221433d0511Smrg				;;
222433d0511Smrg			altos | altos3068)
223433d0511Smrg				basic_machine=m68k-altos
224433d0511Smrg				basic_os=
225433d0511Smrg				;;
226433d0511Smrg			am29k)
227433d0511Smrg				basic_machine=a29k-none
228433d0511Smrg				basic_os=bsd
229433d0511Smrg				;;
230433d0511Smrg			amdahl)
231433d0511Smrg				basic_machine=580-amdahl
232433d0511Smrg				basic_os=sysv
233433d0511Smrg				;;
234433d0511Smrg			amiga)
235433d0511Smrg				basic_machine=m68k-unknown
236433d0511Smrg				basic_os=
237433d0511Smrg				;;
238433d0511Smrg			amigaos | amigados)
239433d0511Smrg				basic_machine=m68k-unknown
240433d0511Smrg				basic_os=amigaos
241433d0511Smrg				;;
242433d0511Smrg			amigaunix | amix)
243433d0511Smrg				basic_machine=m68k-unknown
244433d0511Smrg				basic_os=sysv4
245433d0511Smrg				;;
246433d0511Smrg			apollo68)
247433d0511Smrg				basic_machine=m68k-apollo
248433d0511Smrg				basic_os=sysv
249433d0511Smrg				;;
250433d0511Smrg			apollo68bsd)
251433d0511Smrg				basic_machine=m68k-apollo
252433d0511Smrg				basic_os=bsd
253433d0511Smrg				;;
254433d0511Smrg			aros)
255433d0511Smrg				basic_machine=i386-pc
256433d0511Smrg				basic_os=aros
257433d0511Smrg				;;
258433d0511Smrg			aux)
259433d0511Smrg				basic_machine=m68k-apple
260433d0511Smrg				basic_os=aux
261433d0511Smrg				;;
262433d0511Smrg			balance)
263433d0511Smrg				basic_machine=ns32k-sequent
264433d0511Smrg				basic_os=dynix
265433d0511Smrg				;;
266433d0511Smrg			blackfin)
267433d0511Smrg				basic_machine=bfin-unknown
268433d0511Smrg				basic_os=linux
269433d0511Smrg				;;
270433d0511Smrg			cegcc)
271433d0511Smrg				basic_machine=arm-unknown
272433d0511Smrg				basic_os=cegcc
273433d0511Smrg				;;
274433d0511Smrg			convex-c1)
275433d0511Smrg				basic_machine=c1-convex
276433d0511Smrg				basic_os=bsd
277433d0511Smrg				;;
278433d0511Smrg			convex-c2)
279433d0511Smrg				basic_machine=c2-convex
280433d0511Smrg				basic_os=bsd
281433d0511Smrg				;;
282433d0511Smrg			convex-c32)
283433d0511Smrg				basic_machine=c32-convex
284433d0511Smrg				basic_os=bsd
285433d0511Smrg				;;
286433d0511Smrg			convex-c34)
287433d0511Smrg				basic_machine=c34-convex
288433d0511Smrg				basic_os=bsd
289433d0511Smrg				;;
290433d0511Smrg			convex-c38)
291433d0511Smrg				basic_machine=c38-convex
292433d0511Smrg				basic_os=bsd
293433d0511Smrg				;;
294433d0511Smrg			cray)
295433d0511Smrg				basic_machine=j90-cray
296433d0511Smrg				basic_os=unicos
297433d0511Smrg				;;
298433d0511Smrg			crds | unos)
299433d0511Smrg				basic_machine=m68k-crds
300433d0511Smrg				basic_os=
301433d0511Smrg				;;
302433d0511Smrg			da30)
303433d0511Smrg				basic_machine=m68k-da30
304433d0511Smrg				basic_os=
305433d0511Smrg				;;
306433d0511Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307433d0511Smrg				basic_machine=mips-dec
308433d0511Smrg				basic_os=
309433d0511Smrg				;;
310433d0511Smrg			delta88)
311433d0511Smrg				basic_machine=m88k-motorola
312433d0511Smrg				basic_os=sysv3
313433d0511Smrg				;;
314433d0511Smrg			dicos)
315433d0511Smrg				basic_machine=i686-pc
316433d0511Smrg				basic_os=dicos
317433d0511Smrg				;;
318433d0511Smrg			djgpp)
319433d0511Smrg				basic_machine=i586-pc
320433d0511Smrg				basic_os=msdosdjgpp
321433d0511Smrg				;;
322433d0511Smrg			ebmon29k)
323433d0511Smrg				basic_machine=a29k-amd
324433d0511Smrg				basic_os=ebmon
325433d0511Smrg				;;
326433d0511Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327433d0511Smrg				basic_machine=m68k-ericsson
328433d0511Smrg				basic_os=ose
329433d0511Smrg				;;
330433d0511Smrg			gmicro)
331433d0511Smrg				basic_machine=tron-gmicro
332433d0511Smrg				basic_os=sysv
333433d0511Smrg				;;
334433d0511Smrg			go32)
335433d0511Smrg				basic_machine=i386-pc
336433d0511Smrg				basic_os=go32
337433d0511Smrg				;;
338433d0511Smrg			h8300hms)
339433d0511Smrg				basic_machine=h8300-hitachi
340433d0511Smrg				basic_os=hms
341433d0511Smrg				;;
342433d0511Smrg			h8300xray)
343433d0511Smrg				basic_machine=h8300-hitachi
344433d0511Smrg				basic_os=xray
345433d0511Smrg				;;
346433d0511Smrg			h8500hms)
347433d0511Smrg				basic_machine=h8500-hitachi
348433d0511Smrg				basic_os=hms
349433d0511Smrg				;;
350433d0511Smrg			harris)
351433d0511Smrg				basic_machine=m88k-harris
352433d0511Smrg				basic_os=sysv3
353433d0511Smrg				;;
354433d0511Smrg			hp300 | hp300hpux)
355433d0511Smrg				basic_machine=m68k-hp
356433d0511Smrg				basic_os=hpux
357433d0511Smrg				;;
358433d0511Smrg			hp300bsd)
359433d0511Smrg				basic_machine=m68k-hp
360433d0511Smrg				basic_os=bsd
361433d0511Smrg				;;
362433d0511Smrg			hppaosf)
363433d0511Smrg				basic_machine=hppa1.1-hp
364433d0511Smrg				basic_os=osf
365433d0511Smrg				;;
366433d0511Smrg			hppro)
367433d0511Smrg				basic_machine=hppa1.1-hp
368433d0511Smrg				basic_os=proelf
369433d0511Smrg				;;
370433d0511Smrg			i386mach)
371433d0511Smrg				basic_machine=i386-mach
372433d0511Smrg				basic_os=mach
373433d0511Smrg				;;
374433d0511Smrg			isi68 | isi)
375433d0511Smrg				basic_machine=m68k-isi
376433d0511Smrg				basic_os=sysv
377433d0511Smrg				;;
378433d0511Smrg			m68knommu)
379433d0511Smrg				basic_machine=m68k-unknown
380433d0511Smrg				basic_os=linux
381433d0511Smrg				;;
382433d0511Smrg			magnum | m3230)
383433d0511Smrg				basic_machine=mips-mips
384433d0511Smrg				basic_os=sysv
385433d0511Smrg				;;
386433d0511Smrg			merlin)
387433d0511Smrg				basic_machine=ns32k-utek
388433d0511Smrg				basic_os=sysv
389433d0511Smrg				;;
390433d0511Smrg			mingw64)
391433d0511Smrg				basic_machine=x86_64-pc
392433d0511Smrg				basic_os=mingw64
393433d0511Smrg				;;
394433d0511Smrg			mingw32)
395433d0511Smrg				basic_machine=i686-pc
396433d0511Smrg				basic_os=mingw32
397433d0511Smrg				;;
398433d0511Smrg			mingw32ce)
399433d0511Smrg				basic_machine=arm-unknown
400433d0511Smrg				basic_os=mingw32ce
401433d0511Smrg				;;
402433d0511Smrg			monitor)
403433d0511Smrg				basic_machine=m68k-rom68k
404433d0511Smrg				basic_os=coff
405433d0511Smrg				;;
406433d0511Smrg			morphos)
407433d0511Smrg				basic_machine=powerpc-unknown
408433d0511Smrg				basic_os=morphos
409433d0511Smrg				;;
410433d0511Smrg			moxiebox)
411433d0511Smrg				basic_machine=moxie-unknown
412433d0511Smrg				basic_os=moxiebox
413433d0511Smrg				;;
414433d0511Smrg			msdos)
415433d0511Smrg				basic_machine=i386-pc
416433d0511Smrg				basic_os=msdos
417433d0511Smrg				;;
418433d0511Smrg			msys)
419433d0511Smrg				basic_machine=i686-pc
420433d0511Smrg				basic_os=msys
421433d0511Smrg				;;
422433d0511Smrg			mvs)
423433d0511Smrg				basic_machine=i370-ibm
424433d0511Smrg				basic_os=mvs
425433d0511Smrg				;;
426433d0511Smrg			nacl)
427433d0511Smrg				basic_machine=le32-unknown
428433d0511Smrg				basic_os=nacl
429433d0511Smrg				;;
430433d0511Smrg			ncr3000)
431433d0511Smrg				basic_machine=i486-ncr
432433d0511Smrg				basic_os=sysv4
433433d0511Smrg				;;
434433d0511Smrg			netbsd386)
435433d0511Smrg				basic_machine=i386-pc
436433d0511Smrg				basic_os=netbsd
437433d0511Smrg				;;
438433d0511Smrg			netwinder)
439433d0511Smrg				basic_machine=armv4l-rebel
440433d0511Smrg				basic_os=linux
441433d0511Smrg				;;
442433d0511Smrg			news | news700 | news800 | news900)
443433d0511Smrg				basic_machine=m68k-sony
444433d0511Smrg				basic_os=newsos
445433d0511Smrg				;;
446433d0511Smrg			news1000)
447433d0511Smrg				basic_machine=m68030-sony
448433d0511Smrg				basic_os=newsos
449433d0511Smrg				;;
450433d0511Smrg			necv70)
451433d0511Smrg				basic_machine=v70-nec
452433d0511Smrg				basic_os=sysv
453433d0511Smrg				;;
454433d0511Smrg			nh3000)
455433d0511Smrg				basic_machine=m68k-harris
456433d0511Smrg				basic_os=cxux
457433d0511Smrg				;;
458433d0511Smrg			nh[45]000)
459433d0511Smrg				basic_machine=m88k-harris
460433d0511Smrg				basic_os=cxux
461433d0511Smrg				;;
462433d0511Smrg			nindy960)
463433d0511Smrg				basic_machine=i960-intel
464433d0511Smrg				basic_os=nindy
465433d0511Smrg				;;
466433d0511Smrg			mon960)
467433d0511Smrg				basic_machine=i960-intel
468433d0511Smrg				basic_os=mon960
469433d0511Smrg				;;
470433d0511Smrg			nonstopux)
471433d0511Smrg				basic_machine=mips-compaq
472433d0511Smrg				basic_os=nonstopux
473433d0511Smrg				;;
474433d0511Smrg			os400)
475433d0511Smrg				basic_machine=powerpc-ibm
476433d0511Smrg				basic_os=os400
477433d0511Smrg				;;
478433d0511Smrg			OSE68000 | ose68000)
479433d0511Smrg				basic_machine=m68000-ericsson
480433d0511Smrg				basic_os=ose
481433d0511Smrg				;;
482433d0511Smrg			os68k)
483433d0511Smrg				basic_machine=m68k-none
484433d0511Smrg				basic_os=os68k
485433d0511Smrg				;;
486433d0511Smrg			paragon)
487433d0511Smrg				basic_machine=i860-intel
488433d0511Smrg				basic_os=osf
489433d0511Smrg				;;
490433d0511Smrg			parisc)
491433d0511Smrg				basic_machine=hppa-unknown
492433d0511Smrg				basic_os=linux
493433d0511Smrg				;;
494433d0511Smrg			psp)
495433d0511Smrg				basic_machine=mipsallegrexel-sony
496433d0511Smrg				basic_os=psp
497433d0511Smrg				;;
498433d0511Smrg			pw32)
499433d0511Smrg				basic_machine=i586-unknown
500433d0511Smrg				basic_os=pw32
501433d0511Smrg				;;
502433d0511Smrg			rdos | rdos64)
503433d0511Smrg				basic_machine=x86_64-pc
504433d0511Smrg				basic_os=rdos
505433d0511Smrg				;;
506433d0511Smrg			rdos32)
507433d0511Smrg				basic_machine=i386-pc
508433d0511Smrg				basic_os=rdos
509433d0511Smrg				;;
510433d0511Smrg			rom68k)
511433d0511Smrg				basic_machine=m68k-rom68k
512433d0511Smrg				basic_os=coff
513433d0511Smrg				;;
514433d0511Smrg			sa29200)
515433d0511Smrg				basic_machine=a29k-amd
516433d0511Smrg				basic_os=udi
517433d0511Smrg				;;
518433d0511Smrg			sei)
519433d0511Smrg				basic_machine=mips-sei
520433d0511Smrg				basic_os=seiux
521433d0511Smrg				;;
522433d0511Smrg			sequent)
523433d0511Smrg				basic_machine=i386-sequent
524433d0511Smrg				basic_os=
525433d0511Smrg				;;
526433d0511Smrg			sps7)
527433d0511Smrg				basic_machine=m68k-bull
528433d0511Smrg				basic_os=sysv2
529433d0511Smrg				;;
530433d0511Smrg			st2000)
531433d0511Smrg				basic_machine=m68k-tandem
532433d0511Smrg				basic_os=
533433d0511Smrg				;;
534433d0511Smrg			stratus)
535433d0511Smrg				basic_machine=i860-stratus
536433d0511Smrg				basic_os=sysv4
537433d0511Smrg				;;
538433d0511Smrg			sun2)
539433d0511Smrg				basic_machine=m68000-sun
540433d0511Smrg				basic_os=
541433d0511Smrg				;;
542433d0511Smrg			sun2os3)
543433d0511Smrg				basic_machine=m68000-sun
544433d0511Smrg				basic_os=sunos3
545433d0511Smrg				;;
546433d0511Smrg			sun2os4)
547433d0511Smrg				basic_machine=m68000-sun
548433d0511Smrg				basic_os=sunos4
549433d0511Smrg				;;
550433d0511Smrg			sun3)
551433d0511Smrg				basic_machine=m68k-sun
552433d0511Smrg				basic_os=
553433d0511Smrg				;;
554433d0511Smrg			sun3os3)
555433d0511Smrg				basic_machine=m68k-sun
556433d0511Smrg				basic_os=sunos3
557433d0511Smrg				;;
558433d0511Smrg			sun3os4)
559433d0511Smrg				basic_machine=m68k-sun
560433d0511Smrg				basic_os=sunos4
561433d0511Smrg				;;
562433d0511Smrg			sun4)
563433d0511Smrg				basic_machine=sparc-sun
564433d0511Smrg				basic_os=
565433d0511Smrg				;;
566433d0511Smrg			sun4os3)
567433d0511Smrg				basic_machine=sparc-sun
568433d0511Smrg				basic_os=sunos3
569433d0511Smrg				;;
570433d0511Smrg			sun4os4)
571433d0511Smrg				basic_machine=sparc-sun
572433d0511Smrg				basic_os=sunos4
573433d0511Smrg				;;
574433d0511Smrg			sun4sol2)
575433d0511Smrg				basic_machine=sparc-sun
576433d0511Smrg				basic_os=solaris2
577433d0511Smrg				;;
578433d0511Smrg			sun386 | sun386i | roadrunner)
579433d0511Smrg				basic_machine=i386-sun
580433d0511Smrg				basic_os=
581433d0511Smrg				;;
582433d0511Smrg			sv1)
583433d0511Smrg				basic_machine=sv1-cray
584433d0511Smrg				basic_os=unicos
585433d0511Smrg				;;
586433d0511Smrg			symmetry)
587433d0511Smrg				basic_machine=i386-sequent
588433d0511Smrg				basic_os=dynix
589433d0511Smrg				;;
590433d0511Smrg			t3e)
591433d0511Smrg				basic_machine=alphaev5-cray
592433d0511Smrg				basic_os=unicos
593433d0511Smrg				;;
594433d0511Smrg			t90)
595433d0511Smrg				basic_machine=t90-cray
596433d0511Smrg				basic_os=unicos
597433d0511Smrg				;;
598433d0511Smrg			toad1)
599433d0511Smrg				basic_machine=pdp10-xkl
600433d0511Smrg				basic_os=tops20
601433d0511Smrg				;;
602433d0511Smrg			tpf)
603433d0511Smrg				basic_machine=s390x-ibm
604433d0511Smrg				basic_os=tpf
605433d0511Smrg				;;
606433d0511Smrg			udi29k)
607433d0511Smrg				basic_machine=a29k-amd
608433d0511Smrg				basic_os=udi
609433d0511Smrg				;;
610433d0511Smrg			ultra3)
611433d0511Smrg				basic_machine=a29k-nyu
612433d0511Smrg				basic_os=sym1
613433d0511Smrg				;;
614433d0511Smrg			v810 | necv810)
615433d0511Smrg				basic_machine=v810-nec
616433d0511Smrg				basic_os=none
617433d0511Smrg				;;
618433d0511Smrg			vaxv)
619433d0511Smrg				basic_machine=vax-dec
620433d0511Smrg				basic_os=sysv
621433d0511Smrg				;;
622433d0511Smrg			vms)
623433d0511Smrg				basic_machine=vax-dec
624433d0511Smrg				basic_os=vms
625433d0511Smrg				;;
626433d0511Smrg			vsta)
627433d0511Smrg				basic_machine=i386-pc
628433d0511Smrg				basic_os=vsta
629433d0511Smrg				;;
630433d0511Smrg			vxworks960)
631433d0511Smrg				basic_machine=i960-wrs
632433d0511Smrg				basic_os=vxworks
633433d0511Smrg				;;
634433d0511Smrg			vxworks68)
635433d0511Smrg				basic_machine=m68k-wrs
636433d0511Smrg				basic_os=vxworks
637433d0511Smrg				;;
638433d0511Smrg			vxworks29k)
639433d0511Smrg				basic_machine=a29k-wrs
640433d0511Smrg				basic_os=vxworks
641433d0511Smrg				;;
642433d0511Smrg			xbox)
643433d0511Smrg				basic_machine=i686-pc
644433d0511Smrg				basic_os=mingw32
645433d0511Smrg				;;
646433d0511Smrg			ymp)
647433d0511Smrg				basic_machine=ymp-cray
648433d0511Smrg				basic_os=unicos
649433d0511Smrg				;;
650433d0511Smrg			*)
651433d0511Smrg				basic_machine=$1
652433d0511Smrg				basic_os=
653433d0511Smrg				;;
654433d0511Smrg		esac
655eaef79e5Smrg		;;
656eaef79e5Smrgesac
657eaef79e5Smrg
658433d0511Smrg# Decode 1-component or ad-hoc basic machines
659eaef79e5Smrgcase $basic_machine in
660433d0511Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661433d0511Smrg	# some cases the only manufacturer, in others, it is the most popular.
662433d0511Smrg	w89k)
663433d0511Smrg		cpu=hppa1.1
664433d0511Smrg		vendor=winbond
665eaef79e5Smrg		;;
666433d0511Smrg	op50n)
667433d0511Smrg		cpu=hppa1.1
668433d0511Smrg		vendor=oki
669eaef79e5Smrg		;;
670433d0511Smrg	op60c)
671433d0511Smrg		cpu=hppa1.1
672433d0511Smrg		vendor=oki
673eaef79e5Smrg		;;
674433d0511Smrg	ibm*)
675433d0511Smrg		cpu=i370
676433d0511Smrg		vendor=ibm
677cbc4e2beSmrg		;;
678433d0511Smrg	orion105)
679433d0511Smrg		cpu=clipper
680433d0511Smrg		vendor=highlevel
681cbc4e2beSmrg		;;
682433d0511Smrg	mac | mpw | mac-mpw)
683433d0511Smrg		cpu=m68k
684433d0511Smrg		vendor=apple
685cbc4e2beSmrg		;;
686433d0511Smrg	pmac | pmac-mpw)
687433d0511Smrg		cpu=powerpc
688433d0511Smrg		vendor=apple
689cbc4e2beSmrg		;;
690cbc4e2beSmrg
691eaef79e5Smrg	# Recognize the various machine names and aliases which stand
692eaef79e5Smrg	# for a CPU type and a company and sometimes even an OS.
693eaef79e5Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694433d0511Smrg		cpu=m68000
695433d0511Smrg		vendor=att
696eaef79e5Smrg		;;
697eaef79e5Smrg	3b*)
698433d0511Smrg		cpu=we32k
699433d0511Smrg		vendor=att
7002b32c8f7Smrg		;;
70195e0246bSmrg	bluegene*)
702433d0511Smrg		cpu=powerpc
703433d0511Smrg		vendor=ibm
704433d0511Smrg		basic_os=cnk
705eaef79e5Smrg		;;
706eaef79e5Smrg	decsystem10* | dec10*)
707433d0511Smrg		cpu=pdp10
708433d0511Smrg		vendor=dec
709433d0511Smrg		basic_os=tops10
710eaef79e5Smrg		;;
711eaef79e5Smrg	decsystem20* | dec20*)
712433d0511Smrg		cpu=pdp10
713433d0511Smrg		vendor=dec
714433d0511Smrg		basic_os=tops20
715eaef79e5Smrg		;;
716eaef79e5Smrg	delta | 3300 | motorola-3300 | motorola-delta \
717eaef79e5Smrg	      | 3300-motorola | delta-motorola)
718433d0511Smrg		cpu=m68k
719433d0511Smrg		vendor=motorola
720eaef79e5Smrg		;;
7216654de8bSmrg	dpx2*)
722433d0511Smrg		cpu=m68k
723433d0511Smrg		vendor=bull
724433d0511Smrg		basic_os=sysv3
725eaef79e5Smrg		;;
726eaef79e5Smrg	encore | umax | mmax)
727433d0511Smrg		cpu=ns32k
728433d0511Smrg		vendor=encore
729eaef79e5Smrg		;;
730433d0511Smrg	elxsi)
731433d0511Smrg		cpu=elxsi
732433d0511Smrg		vendor=elxsi
733433d0511Smrg		basic_os=${basic_os:-bsd}
734eaef79e5Smrg		;;
735eaef79e5Smrg	fx2800)
736433d0511Smrg		cpu=i860
737433d0511Smrg		vendor=alliant
738eaef79e5Smrg		;;
739eaef79e5Smrg	genix)
740433d0511Smrg		cpu=ns32k
741433d0511Smrg		vendor=ns
742eaef79e5Smrg		;;
743eaef79e5Smrg	h3050r* | hiux*)
744433d0511Smrg		cpu=hppa1.1
745433d0511Smrg		vendor=hitachi
746433d0511Smrg		basic_os=hiuxwe2
747eaef79e5Smrg		;;
748eaef79e5Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749433d0511Smrg		cpu=hppa1.0
750433d0511Smrg		vendor=hp
751eaef79e5Smrg		;;
752eaef79e5Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753433d0511Smrg		cpu=m68000
754433d0511Smrg		vendor=hp
755eaef79e5Smrg		;;
756eaef79e5Smrg	hp9k3[2-9][0-9])
757433d0511Smrg		cpu=m68k
758433d0511Smrg		vendor=hp
759eaef79e5Smrg		;;
760eaef79e5Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761433d0511Smrg		cpu=hppa1.0
762433d0511Smrg		vendor=hp
763eaef79e5Smrg		;;
764eaef79e5Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765433d0511Smrg		cpu=hppa1.1
766433d0511Smrg		vendor=hp
767eaef79e5Smrg		;;
768eaef79e5Smrg	hp9k78[0-9] | hp78[0-9])
769eaef79e5Smrg		# FIXME: really hppa2.0-hp
770433d0511Smrg		cpu=hppa1.1
771433d0511Smrg		vendor=hp
772eaef79e5Smrg		;;
773eaef79e5Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774eaef79e5Smrg		# FIXME: really hppa2.0-hp
775433d0511Smrg		cpu=hppa1.1
776433d0511Smrg		vendor=hp
777eaef79e5Smrg		;;
778eaef79e5Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779433d0511Smrg		cpu=hppa1.1
780433d0511Smrg		vendor=hp
781eaef79e5Smrg		;;
782eaef79e5Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783433d0511Smrg		cpu=hppa1.0
784433d0511Smrg		vendor=hp
785eaef79e5Smrg		;;
786eaef79e5Smrg	i*86v32)
787433d0511Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788433d0511Smrg		vendor=pc
789433d0511Smrg		basic_os=sysv32
790eaef79e5Smrg		;;
791eaef79e5Smrg	i*86v4*)
792433d0511Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793433d0511Smrg		vendor=pc
794433d0511Smrg		basic_os=sysv4
795eaef79e5Smrg		;;
796eaef79e5Smrg	i*86v)
797433d0511Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798433d0511Smrg		vendor=pc
799433d0511Smrg		basic_os=sysv
800eaef79e5Smrg		;;
801eaef79e5Smrg	i*86sol2)
802433d0511Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803433d0511Smrg		vendor=pc
804433d0511Smrg		basic_os=solaris2
805eaef79e5Smrg		;;
806433d0511Smrg	j90 | j90-cray)
807433d0511Smrg		cpu=j90
808433d0511Smrg		vendor=cray
809433d0511Smrg		basic_os=${basic_os:-unicos}
810eaef79e5Smrg		;;
811eaef79e5Smrg	iris | iris4d)
812433d0511Smrg		cpu=mips
813433d0511Smrg		vendor=sgi
814433d0511Smrg		case $basic_os in
815433d0511Smrg		    irix*)
816eaef79e5Smrg			;;
817eaef79e5Smrg		    *)
818433d0511Smrg			basic_os=irix4
819eaef79e5Smrg			;;
820eaef79e5Smrg		esac
821eaef79e5Smrg		;;
822eaef79e5Smrg	miniframe)
823433d0511Smrg		cpu=m68000
824433d0511Smrg		vendor=convergent
825eaef79e5Smrg		;;
826433d0511Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827433d0511Smrg		cpu=m68k
828433d0511Smrg		vendor=atari
829433d0511Smrg		basic_os=mint
830eaef79e5Smrg		;;
831eaef79e5Smrg	news-3600 | risc-news)
832433d0511Smrg		cpu=mips
833433d0511Smrg		vendor=sony
834433d0511Smrg		basic_os=newsos
835eaef79e5Smrg		;;
8366654de8bSmrg	next | m*-next)
837433d0511Smrg		cpu=m68k
838433d0511Smrg		vendor=next
839433d0511Smrg		case $basic_os in
840433d0511Smrg		    openstep*)
841433d0511Smrg		        ;;
842433d0511Smrg		    nextstep*)
843eaef79e5Smrg			;;
844433d0511Smrg		    ns2*)
845433d0511Smrg		      basic_os=nextstep2
846eaef79e5Smrg			;;
847eaef79e5Smrg		    *)
848433d0511Smrg		      basic_os=nextstep3
849eaef79e5Smrg			;;
850eaef79e5Smrg		esac
851eaef79e5Smrg		;;
852eaef79e5Smrg	np1)
853433d0511Smrg		cpu=np1
854433d0511Smrg		vendor=gould
8556654de8bSmrg		;;
856eaef79e5Smrg	op50n-* | op60c-*)
857433d0511Smrg		cpu=hppa1.1
858433d0511Smrg		vendor=oki
859433d0511Smrg		basic_os=proelf
860eaef79e5Smrg		;;
861eaef79e5Smrg	pa-hitachi)
862433d0511Smrg		cpu=hppa1.1
863433d0511Smrg		vendor=hitachi
864433d0511Smrg		basic_os=hiuxwe2
8652b32c8f7Smrg		;;
866eaef79e5Smrg	pbd)
867433d0511Smrg		cpu=sparc
868433d0511Smrg		vendor=tti
869eaef79e5Smrg		;;
870eaef79e5Smrg	pbb)
871433d0511Smrg		cpu=m68k
872433d0511Smrg		vendor=tti
873eaef79e5Smrg		;;
874433d0511Smrg	pc532)
875433d0511Smrg		cpu=ns32k
876433d0511Smrg		vendor=pc532
877eaef79e5Smrg		;;
878eaef79e5Smrg	pn)
879433d0511Smrg		cpu=pn
880433d0511Smrg		vendor=gould
881eaef79e5Smrg		;;
882433d0511Smrg	power)
883433d0511Smrg		cpu=power
884433d0511Smrg		vendor=ibm
885eaef79e5Smrg		;;
886433d0511Smrg	ps2)
887433d0511Smrg		cpu=i386
888433d0511Smrg		vendor=ibm
889eaef79e5Smrg		;;
890433d0511Smrg	rm[46]00)
891433d0511Smrg		cpu=mips
892433d0511Smrg		vendor=siemens
893eaef79e5Smrg		;;
894433d0511Smrg	rtpc | rtpc-*)
895433d0511Smrg		cpu=romp
896433d0511Smrg		vendor=ibm
897eaef79e5Smrg		;;
898433d0511Smrg	sde)
899433d0511Smrg		cpu=mipsisa32
900433d0511Smrg		vendor=sde
901433d0511Smrg		basic_os=${basic_os:-elf}
902eaef79e5Smrg		;;
903433d0511Smrg	simso-wrs)
904433d0511Smrg		cpu=sparclite
905433d0511Smrg		vendor=wrs
906433d0511Smrg		basic_os=vxworks
907eaef79e5Smrg		;;
908433d0511Smrg	tower | tower-32)
909433d0511Smrg		cpu=m68k
910433d0511Smrg		vendor=ncr
911eaef79e5Smrg		;;
912433d0511Smrg	vpp*|vx|vx-*)
913433d0511Smrg		cpu=f301
914433d0511Smrg		vendor=fujitsu
915eaef79e5Smrg		;;
916433d0511Smrg	w65)
917433d0511Smrg		cpu=w65
918433d0511Smrg		vendor=wdc
919cbc4e2beSmrg		;;
920433d0511Smrg	w89k-*)
921433d0511Smrg		cpu=hppa1.1
922433d0511Smrg		vendor=winbond
923433d0511Smrg		basic_os=proelf
924eaef79e5Smrg		;;
925433d0511Smrg	none)
926433d0511Smrg		cpu=none
927433d0511Smrg		vendor=none
928eaef79e5Smrg		;;
929433d0511Smrg	leon|leon[3-9])
930433d0511Smrg		cpu=sparc
931433d0511Smrg		vendor=$basic_machine
932eaef79e5Smrg		;;
933433d0511Smrg	leon-*|leon[3-9]-*)
934433d0511Smrg		cpu=sparc
935433d0511Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936eaef79e5Smrg		;;
937433d0511Smrg
938433d0511Smrg	*-*)
939433d0511Smrg		# shellcheck disable=SC2162
940433d0511Smrg		saved_IFS=$IFS
941433d0511Smrg		IFS="-" read cpu vendor <<EOF
942433d0511Smrg$basic_machine
943433d0511SmrgEOF
944433d0511Smrg		IFS=$saved_IFS
945eaef79e5Smrg		;;
946433d0511Smrg	# We use `pc' rather than `unknown'
947433d0511Smrg	# because (1) that's what they normally are, and
948433d0511Smrg	# (2) the word "unknown" tends to confuse beginning users.
949433d0511Smrg	i*86 | x86_64)
950433d0511Smrg		cpu=$basic_machine
951433d0511Smrg		vendor=pc
952eaef79e5Smrg		;;
953433d0511Smrg	# These rules are duplicated from below for sake of the special case above;
954433d0511Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955433d0511Smrg	pc98)
956433d0511Smrg		cpu=i386
957433d0511Smrg		vendor=pc
958eaef79e5Smrg		;;
959433d0511Smrg	x64 | amd64)
960433d0511Smrg		cpu=x86_64
961433d0511Smrg		vendor=pc
962eaef79e5Smrg		;;
963433d0511Smrg	# Recognize the basic CPU types without company name.
964433d0511Smrg	*)
965433d0511Smrg		cpu=$basic_machine
966433d0511Smrg		vendor=unknown
967eaef79e5Smrg		;;
968433d0511Smrgesac
969433d0511Smrg
970433d0511Smrgunset -v basic_machine
971433d0511Smrg
972433d0511Smrg# Decode basic machines in the full and proper CPU-Company form.
973433d0511Smrgcase $cpu-$vendor in
974433d0511Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975433d0511Smrg	# some cases the only manufacturer, in others, it is the most popular.
976433d0511Smrg	craynv-unknown)
977433d0511Smrg		vendor=cray
978433d0511Smrg		basic_os=${basic_os:-unicosmp}
979eaef79e5Smrg		;;
980433d0511Smrg	c90-unknown | c90-cray)
981433d0511Smrg		vendor=cray
982433d0511Smrg		basic_os=${Basic_os:-unicos}
983eaef79e5Smrg		;;
984433d0511Smrg	fx80-unknown)
985433d0511Smrg		vendor=alliant
986eaef79e5Smrg		;;
987433d0511Smrg	romp-unknown)
988433d0511Smrg		vendor=ibm
989eaef79e5Smrg		;;
990433d0511Smrg	mmix-unknown)
991433d0511Smrg		vendor=knuth
992eaef79e5Smrg		;;
993433d0511Smrg	microblaze-unknown | microblazeel-unknown)
994433d0511Smrg		vendor=xilinx
995eaef79e5Smrg		;;
996433d0511Smrg	rs6000-unknown)
997433d0511Smrg		vendor=ibm
998eaef79e5Smrg		;;
999433d0511Smrg	vax-unknown)
1000433d0511Smrg		vendor=dec
1001eaef79e5Smrg		;;
1002433d0511Smrg	pdp11-unknown)
1003433d0511Smrg		vendor=dec
1004eaef79e5Smrg		;;
1005433d0511Smrg	we32k-unknown)
1006433d0511Smrg		vendor=att
1007cbc4e2beSmrg		;;
1008433d0511Smrg	cydra-unknown)
1009433d0511Smrg		vendor=cydrome
1010eaef79e5Smrg		;;
1011433d0511Smrg	i370-ibm*)
1012433d0511Smrg		vendor=ibm
1013eaef79e5Smrg		;;
1014433d0511Smrg	orion-unknown)
1015433d0511Smrg		vendor=highlevel
1016eaef79e5Smrg		;;
1017433d0511Smrg	xps-unknown | xps100-unknown)
1018433d0511Smrg		cpu=xps100
1019433d0511Smrg		vendor=honeywell
1020eaef79e5Smrg		;;
1021433d0511Smrg
1022433d0511Smrg	# Here we normalize CPU types with a missing or matching vendor
1023433d0511Smrg	armh-unknown | armh-alt)
1024433d0511Smrg		cpu=armv7l
1025433d0511Smrg		vendor=alt
1026433d0511Smrg		basic_os=${basic_os:-linux-gnueabihf}
1027eaef79e5Smrg		;;
1028433d0511Smrg	dpx20-unknown | dpx20-bull)
1029433d0511Smrg		cpu=rs6000
1030433d0511Smrg		vendor=bull
1031433d0511Smrg		basic_os=${basic_os:-bosx}
1032eaef79e5Smrg		;;
1033433d0511Smrg
1034433d0511Smrg	# Here we normalize CPU types irrespective of the vendor
1035433d0511Smrg	amd64-*)
1036433d0511Smrg		cpu=x86_64
1037eaef79e5Smrg		;;
1038433d0511Smrg	blackfin-*)
1039433d0511Smrg		cpu=bfin
1040433d0511Smrg		basic_os=linux
1041eaef79e5Smrg		;;
1042433d0511Smrg	c54x-*)
1043433d0511Smrg		cpu=tic54x
1044eaef79e5Smrg		;;
1045433d0511Smrg	c55x-*)
1046433d0511Smrg		cpu=tic55x
1047eaef79e5Smrg		;;
1048433d0511Smrg	c6x-*)
1049433d0511Smrg		cpu=tic6x
1050eaef79e5Smrg		;;
1051433d0511Smrg	e500v[12]-*)
1052433d0511Smrg		cpu=powerpc
1053433d0511Smrg		basic_os=${basic_os}"spe"
1054eaef79e5Smrg		;;
1055433d0511Smrg	mips3*-*)
1056433d0511Smrg		cpu=mips64
1057eaef79e5Smrg		;;
1058433d0511Smrg	ms1-*)
1059433d0511Smrg		cpu=mt
1060eaef79e5Smrg		;;
1061433d0511Smrg	m68knommu-*)
1062433d0511Smrg		cpu=m68k
1063433d0511Smrg		basic_os=linux
1064eaef79e5Smrg		;;
1065433d0511Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1066433d0511Smrg		cpu=s12z
10672b32c8f7Smrg		;;
1068433d0511Smrg	openrisc-*)
1069433d0511Smrg		cpu=or32
1070eaef79e5Smrg		;;
1071433d0511Smrg	parisc-*)
1072433d0511Smrg		cpu=hppa
1073433d0511Smrg		basic_os=linux
1074eaef79e5Smrg		;;
1075433d0511Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1076433d0511Smrg		cpu=i586
1077eaef79e5Smrg		;;
1078433d0511Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1079433d0511Smrg		cpu=i686
1080eaef79e5Smrg		;;
1081433d0511Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1082433d0511Smrg		cpu=i686
1083eaef79e5Smrg		;;
1084433d0511Smrg	pentium4-*)
1085433d0511Smrg		cpu=i786
1086eaef79e5Smrg		;;
1087433d0511Smrg	pc98-*)
1088433d0511Smrg		cpu=i386
1089eaef79e5Smrg		;;
1090433d0511Smrg	ppc-* | ppcbe-*)
1091433d0511Smrg		cpu=powerpc
1092eaef79e5Smrg		;;
1093433d0511Smrg	ppcle-* | powerpclittle-*)
1094433d0511Smrg		cpu=powerpcle
1095eaef79e5Smrg		;;
1096433d0511Smrg	ppc64-*)
1097433d0511Smrg		cpu=powerpc64
1098eaef79e5Smrg		;;
1099433d0511Smrg	ppc64le-* | powerpc64little-*)
1100433d0511Smrg		cpu=powerpc64le
1101eaef79e5Smrg		;;
1102433d0511Smrg	sb1-*)
1103433d0511Smrg		cpu=mipsisa64sb1
1104eaef79e5Smrg		;;
1105433d0511Smrg	sb1el-*)
1106433d0511Smrg		cpu=mipsisa64sb1el
1107eaef79e5Smrg		;;
1108433d0511Smrg	sh5e[lb]-*)
1109433d0511Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110eaef79e5Smrg		;;
1111433d0511Smrg	spur-*)
1112433d0511Smrg		cpu=spur
1113eaef79e5Smrg		;;
1114433d0511Smrg	strongarm-* | thumb-*)
1115433d0511Smrg		cpu=arm
1116eaef79e5Smrg		;;
1117433d0511Smrg	tx39-*)
1118433d0511Smrg		cpu=mipstx39
11196654de8bSmrg		;;
1120433d0511Smrg	tx39el-*)
1121433d0511Smrg		cpu=mipstx39el
1122eaef79e5Smrg		;;
1123433d0511Smrg	x64-*)
1124433d0511Smrg		cpu=x86_64
1125eaef79e5Smrg		;;
1126cbc4e2beSmrg	xscale-* | xscalee[bl]-*)
1127433d0511Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128eaef79e5Smrg		;;
1129433d0511Smrg	arm64-* | aarch64le-*)
1130433d0511Smrg		cpu=aarch64
1131eaef79e5Smrg		;;
1132eaef79e5Smrg
1133433d0511Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1134433d0511Smrg	# company names they are paired with.
1135433d0511Smrg	cr16-*)
1136433d0511Smrg		basic_os=${basic_os:-elf}
1137eaef79e5Smrg		;;
1138433d0511Smrg	crisv32-* | etraxfs*-*)
1139433d0511Smrg		cpu=crisv32
1140433d0511Smrg		vendor=axis
1141eaef79e5Smrg		;;
1142433d0511Smrg	cris-* | etrax*-*)
1143433d0511Smrg		cpu=cris
1144433d0511Smrg		vendor=axis
1145eaef79e5Smrg		;;
1146433d0511Smrg	crx-*)
1147433d0511Smrg		basic_os=${basic_os:-elf}
1148eaef79e5Smrg		;;
1149433d0511Smrg	neo-tandem)
1150433d0511Smrg		cpu=neo
1151433d0511Smrg		vendor=tandem
1152eaef79e5Smrg		;;
1153433d0511Smrg	nse-tandem)
1154433d0511Smrg		cpu=nse
1155433d0511Smrg		vendor=tandem
1156eaef79e5Smrg		;;
1157433d0511Smrg	nsr-tandem)
1158433d0511Smrg		cpu=nsr
1159433d0511Smrg		vendor=tandem
1160eaef79e5Smrg		;;
1161433d0511Smrg	nsv-tandem)
1162433d0511Smrg		cpu=nsv
1163433d0511Smrg		vendor=tandem
1164eaef79e5Smrg		;;
1165433d0511Smrg	nsx-tandem)
1166433d0511Smrg		cpu=nsx
1167433d0511Smrg		vendor=tandem
1168eaef79e5Smrg		;;
1169433d0511Smrg	mipsallegrexel-sony)
1170433d0511Smrg		cpu=mipsallegrexel
1171433d0511Smrg		vendor=sony
1172eaef79e5Smrg		;;
1173433d0511Smrg	tile*-*)
1174433d0511Smrg		basic_os=${basic_os:-linux-gnu}
1175eaef79e5Smrg		;;
1176433d0511Smrg
1177eaef79e5Smrg	*)
1178433d0511Smrg		# Recognize the canonical CPU types that are allowed with any
1179433d0511Smrg		# company name.
1180433d0511Smrg		case $cpu in
1181433d0511Smrg			1750a | 580 \
1182433d0511Smrg			| a29k \
1183433d0511Smrg			| aarch64 | aarch64_be \
1184433d0511Smrg			| abacus \
1185433d0511Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1186433d0511Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1187433d0511Smrg			| alphapca5[67] | alpha64pca5[67] \
1188433d0511Smrg			| am33_2.0 \
1189433d0511Smrg			| amdgcn \
1190433d0511Smrg			| arc | arceb | arc32 | arc64 \
1191433d0511Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1192433d0511Smrg			| avr | avr32 \
1193433d0511Smrg			| asmjs \
1194433d0511Smrg			| ba \
1195433d0511Smrg			| be32 | be64 \
1196433d0511Smrg			| bfin | bpf | bs2000 \
1197433d0511Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1198433d0511Smrg			| c8051 | clipper | craynv | csky | cydra \
1199433d0511Smrg			| d10v | d30v | dlx | dsp16xx \
1200433d0511Smrg			| e2k | elxsi | epiphany \
1201433d0511Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1202433d0511Smrg			| h8300 | h8500 \
1203433d0511Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1204433d0511Smrg			| hexagon \
1205433d0511Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1206433d0511Smrg			| ip2k | iq2000 \
1207433d0511Smrg			| k1om \
1208433d0511Smrg			| le32 | le64 \
1209433d0511Smrg			| lm32 \
1210433d0511Smrg			| loongarch32 | loongarch64 \
1211433d0511Smrg			| m32c | m32r | m32rle \
1212433d0511Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1213433d0511Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1214433d0511Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1215433d0511Smrg			| microblaze | microblazeel \
1216433d0511Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1217433d0511Smrg			| mips16 \
1218433d0511Smrg			| mips64 | mips64eb | mips64el \
1219433d0511Smrg			| mips64octeon | mips64octeonel \
1220433d0511Smrg			| mips64orion | mips64orionel \
1221433d0511Smrg			| mips64r5900 | mips64r5900el \
1222433d0511Smrg			| mips64vr | mips64vrel \
1223433d0511Smrg			| mips64vr4100 | mips64vr4100el \
1224433d0511Smrg			| mips64vr4300 | mips64vr4300el \
1225433d0511Smrg			| mips64vr5000 | mips64vr5000el \
1226433d0511Smrg			| mips64vr5900 | mips64vr5900el \
1227433d0511Smrg			| mipsisa32 | mipsisa32el \
1228433d0511Smrg			| mipsisa32r2 | mipsisa32r2el \
1229433d0511Smrg			| mipsisa32r3 | mipsisa32r3el \
1230433d0511Smrg			| mipsisa32r5 | mipsisa32r5el \
1231433d0511Smrg			| mipsisa32r6 | mipsisa32r6el \
1232433d0511Smrg			| mipsisa64 | mipsisa64el \
1233433d0511Smrg			| mipsisa64r2 | mipsisa64r2el \
1234433d0511Smrg			| mipsisa64r3 | mipsisa64r3el \
1235433d0511Smrg			| mipsisa64r5 | mipsisa64r5el \
1236433d0511Smrg			| mipsisa64r6 | mipsisa64r6el \
1237433d0511Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1238433d0511Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1239433d0511Smrg			| mipsr5900 | mipsr5900el \
1240433d0511Smrg			| mipstx39 | mipstx39el \
1241433d0511Smrg			| mmix \
1242433d0511Smrg			| mn10200 | mn10300 \
1243433d0511Smrg			| moxie \
1244433d0511Smrg			| mt \
1245433d0511Smrg			| msp430 \
1246433d0511Smrg			| nds32 | nds32le | nds32be \
1247433d0511Smrg			| nfp \
1248433d0511Smrg			| nios | nios2 | nios2eb | nios2el \
1249433d0511Smrg			| none | np1 | ns16k | ns32k | nvptx \
1250433d0511Smrg			| open8 \
1251433d0511Smrg			| or1k* \
1252433d0511Smrg			| or32 \
1253433d0511Smrg			| orion \
1254433d0511Smrg			| picochip \
1255433d0511Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1256433d0511Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1257433d0511Smrg			| pru \
1258433d0511Smrg			| pyramid \
1259433d0511Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1260433d0511Smrg			| rl78 | romp | rs6000 | rx \
1261433d0511Smrg			| s390 | s390x \
1262433d0511Smrg			| score \
1263433d0511Smrg			| sh | shl \
1264433d0511Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1265433d0511Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1266433d0511Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1267433d0511Smrg			| sparclite \
1268433d0511Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1269433d0511Smrg			| spu \
1270433d0511Smrg			| tahoe \
1271433d0511Smrg			| thumbv7* \
1272433d0511Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1273433d0511Smrg			| tron \
1274433d0511Smrg			| ubicom32 \
1275433d0511Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1276433d0511Smrg			| vax \
1277433d0511Smrg			| visium \
1278433d0511Smrg			| w65 \
1279433d0511Smrg			| wasm32 | wasm64 \
1280433d0511Smrg			| we32k \
1281433d0511Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1282433d0511Smrg			| xstormy16 | xtensa* \
1283433d0511Smrg			| ymp \
1284433d0511Smrg			| z8k | z80)
1285433d0511Smrg				;;
1286433d0511Smrg
1287433d0511Smrg			*)
1288433d0511Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1289433d0511Smrg				exit 1
1290433d0511Smrg				;;
1291433d0511Smrg		esac
1292eaef79e5Smrg		;;
1293eaef79e5Smrgesac
1294eaef79e5Smrg
1295eaef79e5Smrg# Here we canonicalize certain aliases for manufacturers.
1296433d0511Smrgcase $vendor in
1297433d0511Smrg	digital*)
1298433d0511Smrg		vendor=dec
1299eaef79e5Smrg		;;
1300433d0511Smrg	commodore*)
1301433d0511Smrg		vendor=cbm
1302eaef79e5Smrg		;;
1303eaef79e5Smrg	*)
1304eaef79e5Smrg		;;
1305eaef79e5Smrgesac
1306eaef79e5Smrg
1307eaef79e5Smrg# Decode manufacturer-specific aliases for certain operating systems.
1308eaef79e5Smrg
1309433d0511Smrgif test x$basic_os != x
1310eaef79e5Smrgthen
1311433d0511Smrg
1312433d0511Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1313433d0511Smrg# set os.
1314433d0511Smrgcase $basic_os in
1315433d0511Smrg	gnu/linux*)
1316433d0511Smrg		kernel=linux
1317433d0511Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1318433d0511Smrg		;;
1319433d0511Smrg	os2-emx)
1320433d0511Smrg		kernel=os2
1321433d0511Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1322433d0511Smrg		;;
1323433d0511Smrg	nto-qnx*)
1324433d0511Smrg		kernel=nto
1325433d0511Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1326433d0511Smrg		;;
1327433d0511Smrg	*-*)
1328433d0511Smrg		# shellcheck disable=SC2162
1329433d0511Smrg		saved_IFS=$IFS
1330433d0511Smrg		IFS="-" read kernel os <<EOF
1331433d0511Smrg$basic_os
1332433d0511SmrgEOF
1333433d0511Smrg		IFS=$saved_IFS
1334433d0511Smrg		;;
1335433d0511Smrg	# Default OS when just kernel was specified
1336433d0511Smrg	nto*)
1337433d0511Smrg		kernel=nto
1338433d0511Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1339433d0511Smrg		;;
1340433d0511Smrg	linux*)
1341433d0511Smrg		kernel=linux
1342433d0511Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1343433d0511Smrg		;;
1344433d0511Smrg	managarm*)
1345433d0511Smrg		kernel=managarm
1346433d0511Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1347433d0511Smrg		;;
1348433d0511Smrg	*)
1349433d0511Smrg		kernel=
1350433d0511Smrg		os=$basic_os
1351433d0511Smrg		;;
1352433d0511Smrgesac
1353433d0511Smrg
1354433d0511Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1355433d0511Smrg# etc.)
1356eaef79e5Smrgcase $os in
13576654de8bSmrg	# First match some system type aliases that might get confused
13586654de8bSmrg	# with valid system types.
1359433d0511Smrg	# solaris* is a basic system type, with this one exception.
1360433d0511Smrg	auroraux)
1361433d0511Smrg		os=auroraux
136295e0246bSmrg		;;
1363433d0511Smrg	bluegene*)
1364433d0511Smrg		os=cnk
1365eaef79e5Smrg		;;
1366433d0511Smrg	solaris1 | solaris1.*)
1367433d0511Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368eaef79e5Smrg		;;
1369433d0511Smrg	solaris)
1370433d0511Smrg		os=solaris2
1371eaef79e5Smrg		;;
1372433d0511Smrg	unixware*)
1373433d0511Smrg		os=sysv4.2uw
1374eaef79e5Smrg		;;
13756654de8bSmrg	# es1800 is here to avoid being matched by es* (a different OS)
1376433d0511Smrg	es1800*)
1377433d0511Smrg		os=ose
13786654de8bSmrg		;;
1379433d0511Smrg	# Some version numbers need modification
1380433d0511Smrg	chorusos*)
1381433d0511Smrg		os=chorusos
1382eaef79e5Smrg		;;
1383433d0511Smrg	isc)
1384433d0511Smrg		os=isc2.2
1385eaef79e5Smrg		;;
1386433d0511Smrg	sco6)
1387433d0511Smrg		os=sco5v6
1388eaef79e5Smrg		;;
1389433d0511Smrg	sco5)
1390433d0511Smrg		os=sco3.2v5
1391eaef79e5Smrg		;;
1392433d0511Smrg	sco4)
1393433d0511Smrg		os=sco3.2v4
1394eaef79e5Smrg		;;
1395433d0511Smrg	sco3.2.[4-9]*)
1396433d0511Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397eaef79e5Smrg		;;
1398433d0511Smrg	sco*v* | scout)
1399433d0511Smrg		# Don't match below
1400eaef79e5Smrg		;;
1401433d0511Smrg	sco*)
1402433d0511Smrg		os=sco3.2v2
1403eaef79e5Smrg		;;
1404433d0511Smrg	psos*)
1405433d0511Smrg		os=psos
1406eaef79e5Smrg		;;
1407433d0511Smrg	qnx*)
1408433d0511Smrg		os=qnx
1409eaef79e5Smrg		;;
1410433d0511Smrg	hiux*)
1411433d0511Smrg		os=hiuxwe2
1412eaef79e5Smrg		;;
1413433d0511Smrg	lynx*178)
1414433d0511Smrg		os=lynxos178
1415eaef79e5Smrg		;;
1416433d0511Smrg	lynx*5)
1417433d0511Smrg		os=lynxos5
1418eaef79e5Smrg		;;
1419433d0511Smrg	lynxos*)
1420433d0511Smrg		# don't get caught up in next wildcard
1421eaef79e5Smrg		;;
1422433d0511Smrg	lynx*)
1423433d0511Smrg		os=lynxos
1424eaef79e5Smrg		;;
1425433d0511Smrg	mac[0-9]*)
1426433d0511Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1427eaef79e5Smrg		;;
1428433d0511Smrg	opened*)
1429433d0511Smrg		os=openedition
1430eaef79e5Smrg		;;
1431433d0511Smrg	os400*)
1432433d0511Smrg		os=os400
1433eaef79e5Smrg		;;
1434433d0511Smrg	sunos5*)
1435433d0511Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436eaef79e5Smrg		;;
1437433d0511Smrg	sunos6*)
1438433d0511Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439eaef79e5Smrg		;;
1440433d0511Smrg	wince*)
1441433d0511Smrg		os=wince
1442eaef79e5Smrg		;;
1443433d0511Smrg	utek*)
1444433d0511Smrg		os=bsd
1445eaef79e5Smrg		;;
1446433d0511Smrg	dynix*)
1447433d0511Smrg		os=bsd
1448433d0511Smrg		;;
1449433d0511Smrg	acis*)
1450433d0511Smrg		os=aos
1451433d0511Smrg		;;
1452433d0511Smrg	atheos*)
1453433d0511Smrg		os=atheos
1454433d0511Smrg		;;
1455433d0511Smrg	syllable*)
1456433d0511Smrg		os=syllable
1457eaef79e5Smrg		;;
1458433d0511Smrg	386bsd)
1459433d0511Smrg		os=bsd
1460433d0511Smrg		;;
1461433d0511Smrg	ctix* | uts*)
1462433d0511Smrg		os=sysv
1463eaef79e5Smrg		;;
1464433d0511Smrg	nova*)
1465433d0511Smrg		os=rtmk-nova
1466eaef79e5Smrg		;;
1467433d0511Smrg	ns2)
1468433d0511Smrg		os=nextstep2
1469433d0511Smrg		;;
1470433d0511Smrg	# Preserve the version number of sinix5.
1471433d0511Smrg	sinix5.*)
1472433d0511Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473eaef79e5Smrg		;;
1474433d0511Smrg	sinix*)
1475433d0511Smrg		os=sysv4
1476eaef79e5Smrg		;;
1477433d0511Smrg	tpf*)
1478433d0511Smrg		os=tpf
1479eaef79e5Smrg		;;
1480433d0511Smrg	triton*)
1481433d0511Smrg		os=sysv3
1482eaef79e5Smrg		;;
1483433d0511Smrg	oss*)
1484433d0511Smrg		os=sysv3
1485eaef79e5Smrg		;;
1486433d0511Smrg	svr4*)
1487433d0511Smrg		os=sysv4
1488eaef79e5Smrg		;;
1489433d0511Smrg	svr3)
1490433d0511Smrg		os=sysv3
1491eaef79e5Smrg		;;
1492433d0511Smrg	sysvr4)
1493433d0511Smrg		os=sysv4
1494eaef79e5Smrg		;;
1495433d0511Smrg	ose*)
1496433d0511Smrg		os=ose
1497eaef79e5Smrg		;;
1498433d0511Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1499433d0511Smrg		os=mint
15002b32c8f7Smrg		;;
1501433d0511Smrg	dicos*)
1502433d0511Smrg		os=dicos
1503433d0511Smrg		;;
1504433d0511Smrg	pikeos*)
15056654de8bSmrg		# Until real need of OS specific support for
15066654de8bSmrg		# particular features comes up, bare metal
15076654de8bSmrg		# configurations are quite functional.
1508433d0511Smrg		case $cpu in
15096654de8bSmrg		    arm*)
1510433d0511Smrg			os=eabi
15116654de8bSmrg			;;
15126654de8bSmrg		    *)
1513433d0511Smrg			os=elf
15146654de8bSmrg			;;
15156654de8bSmrg		esac
15166654de8bSmrg		;;
1517eaef79e5Smrg	*)
1518433d0511Smrg		# No normalization, but not necessarily accepted, that comes below.
1519eaef79e5Smrg		;;
1520eaef79e5Smrgesac
1521433d0511Smrg
1522eaef79e5Smrgelse
1523eaef79e5Smrg
1524eaef79e5Smrg# Here we handle the default operating systems that come with various machines.
1525eaef79e5Smrg# The value should be what the vendor currently ships out the door with their
1526eaef79e5Smrg# machine or put another way, the most popular os provided with the machine.
1527eaef79e5Smrg
1528eaef79e5Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529eaef79e5Smrg# "-sun"), then you have to tell the case statement up towards the top
1530eaef79e5Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531eaef79e5Smrg# will signal an error saying that MANUFACTURER isn't an operating
1532eaef79e5Smrg# system, and we'll never get to this point.
1533eaef79e5Smrg
1534433d0511Smrgkernel=
1535433d0511Smrgcase $cpu-$vendor in
1536cbc4e2beSmrg	score-*)
1537433d0511Smrg		os=elf
1538eaef79e5Smrg		;;
1539cbc4e2beSmrg	spu-*)
1540433d0511Smrg		os=elf
1541eaef79e5Smrg		;;
1542eaef79e5Smrg	*-acorn)
1543433d0511Smrg		os=riscix1.2
1544eaef79e5Smrg		;;
1545eaef79e5Smrg	arm*-rebel)
1546433d0511Smrg		kernel=linux
1547433d0511Smrg		os=gnu
1548eaef79e5Smrg		;;
1549eaef79e5Smrg	arm*-semi)
1550433d0511Smrg		os=aout
1551eaef79e5Smrg		;;
1552cbc4e2beSmrg	c4x-* | tic4x-*)
1553433d0511Smrg		os=coff
1554cbc4e2beSmrg		;;
1555d1a7ce7bSmrg	c8051-*)
1556433d0511Smrg		os=elf
1557433d0511Smrg		;;
1558433d0511Smrg	clipper-intergraph)
1559433d0511Smrg		os=clix
1560d1a7ce7bSmrg		;;
1561cbc4e2beSmrg	hexagon-*)
1562433d0511Smrg		os=elf
1563eaef79e5Smrg		;;
156495e0246bSmrg	tic54x-*)
1565433d0511Smrg		os=coff
156695e0246bSmrg		;;
156795e0246bSmrg	tic55x-*)
1568433d0511Smrg		os=coff
156995e0246bSmrg		;;
157095e0246bSmrg	tic6x-*)
1571433d0511Smrg		os=coff
157295e0246bSmrg		;;
1573eaef79e5Smrg	# This must come before the *-dec entry.
1574eaef79e5Smrg	pdp10-*)
1575433d0511Smrg		os=tops20
1576eaef79e5Smrg		;;
1577eaef79e5Smrg	pdp11-*)
1578433d0511Smrg		os=none
1579eaef79e5Smrg		;;
1580eaef79e5Smrg	*-dec | vax-*)
1581433d0511Smrg		os=ultrix4.2
1582eaef79e5Smrg		;;
1583eaef79e5Smrg	m68*-apollo)
1584433d0511Smrg		os=domain
1585eaef79e5Smrg		;;
1586eaef79e5Smrg	i386-sun)
1587433d0511Smrg		os=sunos4.0.2
1588eaef79e5Smrg		;;
1589eaef79e5Smrg	m68000-sun)
1590433d0511Smrg		os=sunos3
1591eaef79e5Smrg		;;
1592eaef79e5Smrg	m68*-cisco)
1593433d0511Smrg		os=aout
1594eaef79e5Smrg		;;
1595cbc4e2beSmrg	mep-*)
1596433d0511Smrg		os=elf
15972b32c8f7Smrg		;;
1598eaef79e5Smrg	mips*-cisco)
1599433d0511Smrg		os=elf
1600eaef79e5Smrg		;;
1601eaef79e5Smrg	mips*-*)
1602433d0511Smrg		os=elf
1603eaef79e5Smrg		;;
1604eaef79e5Smrg	or32-*)
1605433d0511Smrg		os=coff
1606eaef79e5Smrg		;;
1607eaef79e5Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1608433d0511Smrg		os=sysv3
1609eaef79e5Smrg		;;
1610eaef79e5Smrg	sparc-* | *-sun)
1611433d0511Smrg		os=sunos4.1.1
1612eaef79e5Smrg		;;
16136654de8bSmrg	pru-*)
1614433d0511Smrg		os=elf
16156654de8bSmrg		;;
1616eaef79e5Smrg	*-be)
1617433d0511Smrg		os=beos
1618eaef79e5Smrg		;;
1619eaef79e5Smrg	*-ibm)
1620433d0511Smrg		os=aix
1621eaef79e5Smrg		;;
1622cbc4e2beSmrg	*-knuth)
1623433d0511Smrg		os=mmixware
1624eaef79e5Smrg		;;
1625eaef79e5Smrg	*-wec)
1626433d0511Smrg		os=proelf
1627eaef79e5Smrg		;;
1628eaef79e5Smrg	*-winbond)
1629433d0511Smrg		os=proelf
1630eaef79e5Smrg		;;
1631eaef79e5Smrg	*-oki)
1632433d0511Smrg		os=proelf
1633eaef79e5Smrg		;;
1634eaef79e5Smrg	*-hp)
1635433d0511Smrg		os=hpux
1636eaef79e5Smrg		;;
1637eaef79e5Smrg	*-hitachi)
1638433d0511Smrg		os=hiux
1639eaef79e5Smrg		;;
1640eaef79e5Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1641433d0511Smrg		os=sysv
1642eaef79e5Smrg		;;
1643eaef79e5Smrg	*-cbm)
1644433d0511Smrg		os=amigaos
1645eaef79e5Smrg		;;
1646eaef79e5Smrg	*-dg)
1647433d0511Smrg		os=dgux
1648eaef79e5Smrg		;;
1649eaef79e5Smrg	*-dolphin)
1650433d0511Smrg		os=sysv3
1651eaef79e5Smrg		;;
1652eaef79e5Smrg	m68k-ccur)
1653433d0511Smrg		os=rtu
1654eaef79e5Smrg		;;
1655eaef79e5Smrg	m88k-omron*)
1656433d0511Smrg		os=luna
1657eaef79e5Smrg		;;
16586654de8bSmrg	*-next)
1659433d0511Smrg		os=nextstep
1660eaef79e5Smrg		;;
1661eaef79e5Smrg	*-sequent)
1662433d0511Smrg		os=ptx
1663eaef79e5Smrg		;;
1664eaef79e5Smrg	*-crds)
1665433d0511Smrg		os=unos
1666eaef79e5Smrg		;;
1667eaef79e5Smrg	*-ns)
1668433d0511Smrg		os=genix
1669eaef79e5Smrg		;;
1670eaef79e5Smrg	i370-*)
1671433d0511Smrg		os=mvs
1672eaef79e5Smrg		;;
1673eaef79e5Smrg	*-gould)
1674433d0511Smrg		os=sysv
1675eaef79e5Smrg		;;
1676eaef79e5Smrg	*-highlevel)
1677433d0511Smrg		os=bsd
1678eaef79e5Smrg		;;
1679eaef79e5Smrg	*-encore)
1680433d0511Smrg		os=bsd
1681eaef79e5Smrg		;;
1682eaef79e5Smrg	*-sgi)
1683433d0511Smrg		os=irix
1684eaef79e5Smrg		;;
1685eaef79e5Smrg	*-siemens)
1686433d0511Smrg		os=sysv4
1687eaef79e5Smrg		;;
1688eaef79e5Smrg	*-masscomp)
1689433d0511Smrg		os=rtu
1690eaef79e5Smrg		;;
1691eaef79e5Smrg	f30[01]-fujitsu | f700-fujitsu)
1692433d0511Smrg		os=uxpv
1693eaef79e5Smrg		;;
1694eaef79e5Smrg	*-rom68k)
1695433d0511Smrg		os=coff
1696eaef79e5Smrg		;;
1697eaef79e5Smrg	*-*bug)
1698433d0511Smrg		os=coff
1699eaef79e5Smrg		;;
1700eaef79e5Smrg	*-apple)
1701433d0511Smrg		os=macos
1702eaef79e5Smrg		;;
1703eaef79e5Smrg	*-atari*)
1704433d0511Smrg		os=mint
1705433d0511Smrg		;;
1706433d0511Smrg	*-wrs)
1707433d0511Smrg		os=vxworks
1708eaef79e5Smrg		;;
1709eaef79e5Smrg	*)
1710433d0511Smrg		os=none
1711eaef79e5Smrg		;;
1712eaef79e5Smrgesac
1713433d0511Smrg
1714eaef79e5Smrgfi
1715eaef79e5Smrg
1716433d0511Smrg# Now, validate our (potentially fixed-up) OS.
1717433d0511Smrgcase $os in
1718433d0511Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1719433d0511Smrg	musl* | newlib* | relibc* | uclibc*)
1720433d0511Smrg		;;
1721433d0511Smrg	# Likewise for "kernel-abi"
1722433d0511Smrg	eabi* | gnueabi*)
1723433d0511Smrg		;;
1724433d0511Smrg	# VxWorks passes extra cpu info in the 4th filed.
1725433d0511Smrg	simlinux | simwindows | spe)
1726433d0511Smrg		;;
1727433d0511Smrg	# Now accept the basic system types.
1728433d0511Smrg	# The portable systems comes first.
1729433d0511Smrg	# Each alternative MUST end in a * to match a version number.
1730433d0511Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1731433d0511Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1732433d0511Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1733433d0511Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1734433d0511Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1735433d0511Smrg	     | os9* | macos* | osx* | ios* \
1736433d0511Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1737433d0511Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1738433d0511Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1739433d0511Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1740433d0511Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1741433d0511Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1742433d0511Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1743433d0511Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1744433d0511Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1745433d0511Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1746433d0511Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1747433d0511Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1748433d0511Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1749433d0511Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1750433d0511Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1751433d0511Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1752433d0511Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1753433d0511Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1754433d0511Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1755433d0511Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1756433d0511Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1757433d0511Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1758433d0511Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1759433d0511Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1760433d0511Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761433d0511Smrg	     | fiwix* | mlibc* )
1762433d0511Smrg		;;
1763433d0511Smrg	# This one is extra strict with allowed versions
1764433d0511Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1765433d0511Smrg		# Don't forget version if it is 3.2v4 or newer.
1766433d0511Smrg		;;
1767433d0511Smrg	none)
1768433d0511Smrg		;;
1769433d0511Smrg	kernel* )
1770433d0511Smrg		# Restricted further below
1771433d0511Smrg		;;
1772433d0511Smrg	*)
1773433d0511Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1774433d0511Smrg		exit 1
1775433d0511Smrg		;;
1776433d0511Smrgesac
1777433d0511Smrg
1778433d0511Smrg# As a final step for OS-related things, validate the OS-kernel combination
1779433d0511Smrg# (given a valid OS), if there is a kernel.
1780433d0511Smrgcase $kernel-$os in
1781433d0511Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782433d0511Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
1783433d0511Smrg		;;
1784433d0511Smrg	uclinux-uclibc* )
1785433d0511Smrg		;;
1786433d0511Smrg	managarm-mlibc* | managarm-kernel* )
1787433d0511Smrg		;;
1788433d0511Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
1789433d0511Smrg		# These are just libc implementations, not actual OSes, and thus
1790433d0511Smrg		# require a kernel.
1791433d0511Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1792433d0511Smrg		exit 1
1793433d0511Smrg		;;
1794433d0511Smrg	-kernel* )
1795433d0511Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
1796433d0511Smrg		exit 1
1797433d0511Smrg		;;
1798433d0511Smrg	*-kernel* )
1799433d0511Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
1800433d0511Smrg		exit 1
1801433d0511Smrg		;;
1802433d0511Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1803433d0511Smrg		;;
1804433d0511Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1805433d0511Smrg		;;
1806433d0511Smrg	nto-qnx*)
1807433d0511Smrg		;;
1808433d0511Smrg	os2-emx)
1809433d0511Smrg		;;
1810433d0511Smrg	*-eabi* | *-gnueabi*)
1811433d0511Smrg		;;
1812433d0511Smrg	-*)
1813433d0511Smrg		# Blank kernel with real OS is always fine.
1814433d0511Smrg		;;
1815433d0511Smrg	*-*)
1816433d0511Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1817433d0511Smrg		exit 1
1818433d0511Smrg		;;
1819433d0511Smrgesac
1820433d0511Smrg
1821eaef79e5Smrg# Here we handle the case where we know the os, and the CPU type, but not the
1822eaef79e5Smrg# manufacturer.  We pick the logical manufacturer.
1823433d0511Smrgcase $vendor in
1824433d0511Smrg	unknown)
1825433d0511Smrg		case $cpu-$os in
1826433d0511Smrg			*-riscix*)
1827eaef79e5Smrg				vendor=acorn
1828eaef79e5Smrg				;;
1829433d0511Smrg			*-sunos*)
1830eaef79e5Smrg				vendor=sun
1831eaef79e5Smrg				;;
1832433d0511Smrg			*-cnk* | *-aix*)
1833eaef79e5Smrg				vendor=ibm
1834eaef79e5Smrg				;;
1835433d0511Smrg			*-beos*)
1836eaef79e5Smrg				vendor=be
1837eaef79e5Smrg				;;
1838433d0511Smrg			*-hpux*)
1839eaef79e5Smrg				vendor=hp
1840eaef79e5Smrg				;;
1841433d0511Smrg			*-mpeix*)
1842eaef79e5Smrg				vendor=hp
1843eaef79e5Smrg				;;
1844433d0511Smrg			*-hiux*)
1845eaef79e5Smrg				vendor=hitachi
1846eaef79e5Smrg				;;
1847433d0511Smrg			*-unos*)
1848eaef79e5Smrg				vendor=crds
1849eaef79e5Smrg				;;
1850433d0511Smrg			*-dgux*)
1851eaef79e5Smrg				vendor=dg
1852eaef79e5Smrg				;;
1853433d0511Smrg			*-luna*)
1854eaef79e5Smrg				vendor=omron
1855eaef79e5Smrg				;;
1856433d0511Smrg			*-genix*)
1857eaef79e5Smrg				vendor=ns
1858eaef79e5Smrg				;;
1859433d0511Smrg			*-clix*)
1860433d0511Smrg				vendor=intergraph
1861433d0511Smrg				;;
1862433d0511Smrg			*-mvs* | *-opened*)
1863433d0511Smrg				vendor=ibm
1864433d0511Smrg				;;
1865433d0511Smrg			*-os400*)
1866eaef79e5Smrg				vendor=ibm
1867eaef79e5Smrg				;;
1868433d0511Smrg			s390-* | s390x-*)
1869eaef79e5Smrg				vendor=ibm
1870eaef79e5Smrg				;;
1871433d0511Smrg			*-ptx*)
1872eaef79e5Smrg				vendor=sequent
1873eaef79e5Smrg				;;
1874433d0511Smrg			*-tpf*)
1875eaef79e5Smrg				vendor=ibm
1876eaef79e5Smrg				;;
1877433d0511Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1878eaef79e5Smrg				vendor=wrs
1879eaef79e5Smrg				;;
1880433d0511Smrg			*-aux*)
1881eaef79e5Smrg				vendor=apple
1882eaef79e5Smrg				;;
1883433d0511Smrg			*-hms*)
1884eaef79e5Smrg				vendor=hitachi
1885eaef79e5Smrg				;;
1886433d0511Smrg			*-mpw* | *-macos*)
1887eaef79e5Smrg				vendor=apple
1888eaef79e5Smrg				;;
1889433d0511Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890eaef79e5Smrg				vendor=atari
1891eaef79e5Smrg				;;
1892433d0511Smrg			*-vos*)
1893eaef79e5Smrg				vendor=stratus
1894eaef79e5Smrg				;;
1895eaef79e5Smrg		esac
1896eaef79e5Smrg		;;
1897eaef79e5Smrgesac
1898eaef79e5Smrg
1899433d0511Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1900eaef79e5Smrgexit
1901eaef79e5Smrg
1902eaef79e5Smrg# Local variables:
1903433d0511Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1904eaef79e5Smrg# time-stamp-start: "timestamp='"
1905eaef79e5Smrg# time-stamp-format: "%:y-%02m-%02d"
1906eaef79e5Smrg# time-stamp-end: "'"
1907eaef79e5Smrg# End:
1908