xref: /openbsd/usr.sbin/unbound/config.sub (revision 9982a05d)
1a3167c07Ssthen#! /bin/sh
2933707f3Ssthen# Configuration validation subroutine script.
3*9982a05dSsthen#   Copyright 1992-2021 Free Software Foundation, Inc.
4933707f3Ssthen
5*9982a05dSsthentimestamp='2021-01-08'
6933707f3Ssthen
798f3ca02Sbrad# This file is free software; you can redistribute it and/or modify it
898f3ca02Sbrad# under the terms of the GNU General Public License as published by
998f3ca02Sbrad# the Free Software Foundation; either version 3 of the License, or
10933707f3Ssthen# (at your option) any later version.
11933707f3Ssthen#
1298f3ca02Sbrad# This program is distributed in the hope that it will be useful, but
1398f3ca02Sbrad# WITHOUT ANY WARRANTY; without even the implied warranty of
1498f3ca02Sbrad# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1598f3ca02Sbrad# General Public License for more details.
16933707f3Ssthen#
17933707f3Ssthen# You should have received a copy of the GNU General Public License
18a3167c07Ssthen# along with this program; if not, see <https://www.gnu.org/licenses/>.
19933707f3Ssthen#
20933707f3Ssthen# As a special exception to the GNU General Public License, if you
21933707f3Ssthen# distribute this file as part of a program that contains a
22933707f3Ssthen# configuration script generated by Autoconf, you may include it under
2398f3ca02Sbrad# the same distribution terms that you use for the rest of that
2498f3ca02Sbrad# program.  This Exception is an additional permission under section 7
2598f3ca02Sbrad# of the GNU General Public License, version 3 ("GPLv3").
26933707f3Ssthen
27933707f3Ssthen
280990ddf5Ssthen# Please send patches to <config-patches@gnu.org>.
29933707f3Ssthen#
30933707f3Ssthen# Configuration subroutine to validate and canonicalize a configuration type.
31933707f3Ssthen# Supply the specified configuration type as an argument.
32933707f3Ssthen# If it is invalid, we print an error message on stderr and exit with code 1.
33933707f3Ssthen# Otherwise, we print the canonical config type on stdout and succeed.
34933707f3Ssthen
35933707f3Ssthen# You can get the latest version of this script from:
36eba819a2Ssthen# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
37933707f3Ssthen
38933707f3Ssthen# This file is supposed to be the same for all GNU packages
39933707f3Ssthen# and recognize all the CPU types, system types and aliases
40933707f3Ssthen# that are meaningful with *any* GNU software.
41933707f3Ssthen# Each package is responsible for reporting which valid configurations
42933707f3Ssthen# it does not support.  The user should be able to distinguish
43933707f3Ssthen# a failure to support a valid configuration from a meaningless
44933707f3Ssthen# configuration.
45933707f3Ssthen
46933707f3Ssthen# The goal of this file is to map all the various variations of a given
47933707f3Ssthen# machine specification into a single specification in the form:
48933707f3Ssthen#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
49933707f3Ssthen# or in some cases, the newer four-part form:
50933707f3Ssthen#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
51933707f3Ssthen# It is wrong to echo any other type of specification.
52933707f3Ssthen
53eba819a2Ssthenme=$(echo "$0" | sed -e 's,.*/,,')
54933707f3Ssthen
55933707f3Ssthenusage="\
560990ddf5SsthenUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
57933707f3Ssthen
58933707f3SsthenCanonicalize a configuration name.
59933707f3Ssthen
60a3167c07SsthenOptions:
61933707f3Ssthen  -h, --help         print this help, then exit
62933707f3Ssthen  -t, --time-stamp   print date of last modification, then exit
63933707f3Ssthen  -v, --version      print version number, then exit
64933707f3Ssthen
65933707f3SsthenReport bugs and patches to <config-patches@gnu.org>."
66933707f3Ssthen
67933707f3Ssthenversion="\
68933707f3SsthenGNU config.sub ($timestamp)
69933707f3Ssthen
70*9982a05dSsthenCopyright 1992-2021 Free Software Foundation, Inc.
71933707f3Ssthen
72933707f3SsthenThis is free software; see the source for copying conditions.  There is NO
73933707f3Ssthenwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
74933707f3Ssthen
75933707f3Ssthenhelp="
76933707f3SsthenTry \`$me --help' for more information."
77933707f3Ssthen
78933707f3Ssthen# Parse command line
79933707f3Ssthenwhile test $# -gt 0 ; do
80933707f3Ssthen  case $1 in
81933707f3Ssthen    --time-stamp | --time* | -t )
82933707f3Ssthen       echo "$timestamp" ; exit ;;
83933707f3Ssthen    --version | -v )
84933707f3Ssthen       echo "$version" ; exit ;;
85933707f3Ssthen    --help | --h* | -h )
86933707f3Ssthen       echo "$usage"; exit ;;
87933707f3Ssthen    -- )     # Stop option processing
88933707f3Ssthen       shift; break ;;
89933707f3Ssthen    - )	# Use stdin as input.
90933707f3Ssthen       break ;;
91933707f3Ssthen    -* )
92a3167c07Ssthen       echo "$me: invalid option $1$help" >&2
93933707f3Ssthen       exit 1 ;;
94933707f3Ssthen
95933707f3Ssthen    *local*)
96933707f3Ssthen       # First pass through any local machine types.
97a3167c07Ssthen       echo "$1"
98933707f3Ssthen       exit ;;
99933707f3Ssthen
100933707f3Ssthen    * )
101933707f3Ssthen       break ;;
102933707f3Ssthen  esac
103933707f3Ssthendone
104933707f3Ssthen
105933707f3Ssthencase $# in
106933707f3Ssthen 0) echo "$me: missing argument$help" >&2
107933707f3Ssthen    exit 1;;
108933707f3Ssthen 1) ;;
109933707f3Ssthen *) echo "$me: too many arguments$help" >&2
110933707f3Ssthen    exit 1;;
111933707f3Ssthenesac
112933707f3Ssthen
113a3167c07Ssthen# Split fields of configuration type
114a3167c07Ssthen# shellcheck disable=SC2162
115a3167c07SsthenIFS="-" read field1 field2 field3 field4 <<EOF
116a3167c07Ssthen$1
117a3167c07SsthenEOF
118a3167c07Ssthen
119a3167c07Ssthen# Separate into logical components for further validation
120a3167c07Ssthencase $1 in
121a3167c07Ssthen	*-*-*-*-*)
122a3167c07Ssthen		echo Invalid configuration \`"$1"\': more than four components >&2
123a3167c07Ssthen		exit 1
124a3167c07Ssthen		;;
125a3167c07Ssthen	*-*-*-*)
126a3167c07Ssthen		basic_machine=$field1-$field2
127a3167c07Ssthen		basic_os=$field3-$field4
128a3167c07Ssthen		;;
129a3167c07Ssthen	*-*-*)
130a3167c07Ssthen		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
131a3167c07Ssthen		# parts
132a3167c07Ssthen		maybe_os=$field2-$field3
133933707f3Ssthen		case $maybe_os in
134a3167c07Ssthen			nto-qnx* | linux-* | uclinux-uclibc* \
135a3167c07Ssthen			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
136a3167c07Ssthen			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
137a3167c07Ssthen			| storm-chaos* | os2-emx* | rtmk-nova*)
138a3167c07Ssthen				basic_machine=$field1
139a3167c07Ssthen				basic_os=$maybe_os
140933707f3Ssthen				;;
141229e174cSsthen			android-linux)
142a3167c07Ssthen				basic_machine=$field1-unknown
143a3167c07Ssthen				basic_os=linux-android
144229e174cSsthen				;;
145933707f3Ssthen			*)
146a3167c07Ssthen				basic_machine=$field1-$field2
147a3167c07Ssthen				basic_os=$field3
148a3167c07Ssthen				;;
149a3167c07Ssthen		esac
150a3167c07Ssthen		;;
151a3167c07Ssthen	*-*)
152a3167c07Ssthen		# A lone config we happen to match not fitting any pattern
153a3167c07Ssthen		case $field1-$field2 in
154a3167c07Ssthen			decstation-3100)
155a3167c07Ssthen				basic_machine=mips-dec
156a3167c07Ssthen				basic_os=
157a3167c07Ssthen				;;
158a3167c07Ssthen			*-*)
159a3167c07Ssthen				# Second component is usually, but not always the OS
160a3167c07Ssthen				case $field2 in
161a3167c07Ssthen					# Prevent following clause from handling this valid os
162a3167c07Ssthen					sun*os*)
163a3167c07Ssthen						basic_machine=$field1
164a3167c07Ssthen						basic_os=$field2
165a3167c07Ssthen						;;
166a3167c07Ssthen					# Manufacturers
167a3167c07Ssthen					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
168a3167c07Ssthen					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
169a3167c07Ssthen					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
170a3167c07Ssthen					| convergent* | ncr* | news | 32* | 3600* | 3100* \
171a3167c07Ssthen					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
172a3167c07Ssthen					| ultra | tti* | harris | dolphin | highlevel | gould \
173a3167c07Ssthen					| cbm | ns | masscomp | apple | axis | knuth | cray \
174a3167c07Ssthen					| microblaze* | sim | cisco \
175a3167c07Ssthen					| oki | wec | wrs | winbond)
176a3167c07Ssthen						basic_machine=$field1-$field2
177a3167c07Ssthen						basic_os=
178a3167c07Ssthen						;;
179a3167c07Ssthen					*)
180a3167c07Ssthen						basic_machine=$field1
181a3167c07Ssthen						basic_os=$field2
182a3167c07Ssthen						;;
183a3167c07Ssthen				esac
184a3167c07Ssthen			;;
185a3167c07Ssthen		esac
186a3167c07Ssthen		;;
187a3167c07Ssthen	*)
188a3167c07Ssthen		# Convert single-component short-hands not valid as part of
189a3167c07Ssthen		# multi-component configurations.
190a3167c07Ssthen		case $field1 in
191a3167c07Ssthen			386bsd)
192a3167c07Ssthen				basic_machine=i386-pc
193a3167c07Ssthen				basic_os=bsd
194a3167c07Ssthen				;;
195a3167c07Ssthen			a29khif)
196a3167c07Ssthen				basic_machine=a29k-amd
197a3167c07Ssthen				basic_os=udi
198a3167c07Ssthen				;;
199a3167c07Ssthen			adobe68k)
200a3167c07Ssthen				basic_machine=m68010-adobe
201a3167c07Ssthen				basic_os=scout
202a3167c07Ssthen				;;
203a3167c07Ssthen			alliant)
204a3167c07Ssthen				basic_machine=fx80-alliant
205a3167c07Ssthen				basic_os=
206a3167c07Ssthen				;;
207a3167c07Ssthen			altos | altos3068)
208a3167c07Ssthen				basic_machine=m68k-altos
209a3167c07Ssthen				basic_os=
210a3167c07Ssthen				;;
211a3167c07Ssthen			am29k)
212a3167c07Ssthen				basic_machine=a29k-none
213a3167c07Ssthen				basic_os=bsd
214a3167c07Ssthen				;;
215a3167c07Ssthen			amdahl)
216a3167c07Ssthen				basic_machine=580-amdahl
217a3167c07Ssthen				basic_os=sysv
218a3167c07Ssthen				;;
219a3167c07Ssthen			amiga)
220a3167c07Ssthen				basic_machine=m68k-unknown
221a3167c07Ssthen				basic_os=
222a3167c07Ssthen				;;
223a3167c07Ssthen			amigaos | amigados)
224a3167c07Ssthen				basic_machine=m68k-unknown
225a3167c07Ssthen				basic_os=amigaos
226a3167c07Ssthen				;;
227a3167c07Ssthen			amigaunix | amix)
228a3167c07Ssthen				basic_machine=m68k-unknown
229a3167c07Ssthen				basic_os=sysv4
230a3167c07Ssthen				;;
231a3167c07Ssthen			apollo68)
232a3167c07Ssthen				basic_machine=m68k-apollo
233a3167c07Ssthen				basic_os=sysv
234a3167c07Ssthen				;;
235a3167c07Ssthen			apollo68bsd)
236a3167c07Ssthen				basic_machine=m68k-apollo
237a3167c07Ssthen				basic_os=bsd
238a3167c07Ssthen				;;
239a3167c07Ssthen			aros)
240a3167c07Ssthen				basic_machine=i386-pc
241a3167c07Ssthen				basic_os=aros
242a3167c07Ssthen				;;
243a3167c07Ssthen			aux)
244a3167c07Ssthen				basic_machine=m68k-apple
245a3167c07Ssthen				basic_os=aux
246a3167c07Ssthen				;;
247a3167c07Ssthen			balance)
248a3167c07Ssthen				basic_machine=ns32k-sequent
249a3167c07Ssthen				basic_os=dynix
250a3167c07Ssthen				;;
251a3167c07Ssthen			blackfin)
252a3167c07Ssthen				basic_machine=bfin-unknown
253a3167c07Ssthen				basic_os=linux
254a3167c07Ssthen				;;
255a3167c07Ssthen			cegcc)
256a3167c07Ssthen				basic_machine=arm-unknown
257a3167c07Ssthen				basic_os=cegcc
258a3167c07Ssthen				;;
259a3167c07Ssthen			convex-c1)
260a3167c07Ssthen				basic_machine=c1-convex
261a3167c07Ssthen				basic_os=bsd
262a3167c07Ssthen				;;
263a3167c07Ssthen			convex-c2)
264a3167c07Ssthen				basic_machine=c2-convex
265a3167c07Ssthen				basic_os=bsd
266a3167c07Ssthen				;;
267a3167c07Ssthen			convex-c32)
268a3167c07Ssthen				basic_machine=c32-convex
269a3167c07Ssthen				basic_os=bsd
270a3167c07Ssthen				;;
271a3167c07Ssthen			convex-c34)
272a3167c07Ssthen				basic_machine=c34-convex
273a3167c07Ssthen				basic_os=bsd
274a3167c07Ssthen				;;
275a3167c07Ssthen			convex-c38)
276a3167c07Ssthen				basic_machine=c38-convex
277a3167c07Ssthen				basic_os=bsd
278a3167c07Ssthen				;;
279a3167c07Ssthen			cray)
280a3167c07Ssthen				basic_machine=j90-cray
281a3167c07Ssthen				basic_os=unicos
282a3167c07Ssthen				;;
283a3167c07Ssthen			crds | unos)
284a3167c07Ssthen				basic_machine=m68k-crds
285a3167c07Ssthen				basic_os=
286a3167c07Ssthen				;;
287a3167c07Ssthen			da30)
288a3167c07Ssthen				basic_machine=m68k-da30
289a3167c07Ssthen				basic_os=
290a3167c07Ssthen				;;
291a3167c07Ssthen			decstation | pmax | pmin | dec3100 | decstatn)
292a3167c07Ssthen				basic_machine=mips-dec
293a3167c07Ssthen				basic_os=
294a3167c07Ssthen				;;
295a3167c07Ssthen			delta88)
296a3167c07Ssthen				basic_machine=m88k-motorola
297a3167c07Ssthen				basic_os=sysv3
298a3167c07Ssthen				;;
299a3167c07Ssthen			dicos)
300a3167c07Ssthen				basic_machine=i686-pc
301a3167c07Ssthen				basic_os=dicos
302a3167c07Ssthen				;;
303a3167c07Ssthen			djgpp)
304a3167c07Ssthen				basic_machine=i586-pc
305a3167c07Ssthen				basic_os=msdosdjgpp
306a3167c07Ssthen				;;
307a3167c07Ssthen			ebmon29k)
308a3167c07Ssthen				basic_machine=a29k-amd
309a3167c07Ssthen				basic_os=ebmon
310a3167c07Ssthen				;;
311a3167c07Ssthen			es1800 | OSE68k | ose68k | ose | OSE)
312a3167c07Ssthen				basic_machine=m68k-ericsson
313a3167c07Ssthen				basic_os=ose
314a3167c07Ssthen				;;
315a3167c07Ssthen			gmicro)
316a3167c07Ssthen				basic_machine=tron-gmicro
317a3167c07Ssthen				basic_os=sysv
318a3167c07Ssthen				;;
319a3167c07Ssthen			go32)
320a3167c07Ssthen				basic_machine=i386-pc
321a3167c07Ssthen				basic_os=go32
322a3167c07Ssthen				;;
323a3167c07Ssthen			h8300hms)
324a3167c07Ssthen				basic_machine=h8300-hitachi
325a3167c07Ssthen				basic_os=hms
326a3167c07Ssthen				;;
327a3167c07Ssthen			h8300xray)
328a3167c07Ssthen				basic_machine=h8300-hitachi
329a3167c07Ssthen				basic_os=xray
330a3167c07Ssthen				;;
331a3167c07Ssthen			h8500hms)
332a3167c07Ssthen				basic_machine=h8500-hitachi
333a3167c07Ssthen				basic_os=hms
334a3167c07Ssthen				;;
335a3167c07Ssthen			harris)
336a3167c07Ssthen				basic_machine=m88k-harris
337a3167c07Ssthen				basic_os=sysv3
338a3167c07Ssthen				;;
339a3167c07Ssthen			hp300 | hp300hpux)
340a3167c07Ssthen				basic_machine=m68k-hp
341a3167c07Ssthen				basic_os=hpux
342a3167c07Ssthen				;;
343a3167c07Ssthen			hp300bsd)
344a3167c07Ssthen				basic_machine=m68k-hp
345a3167c07Ssthen				basic_os=bsd
346a3167c07Ssthen				;;
347a3167c07Ssthen			hppaosf)
348a3167c07Ssthen				basic_machine=hppa1.1-hp
349a3167c07Ssthen				basic_os=osf
350a3167c07Ssthen				;;
351a3167c07Ssthen			hppro)
352a3167c07Ssthen				basic_machine=hppa1.1-hp
353a3167c07Ssthen				basic_os=proelf
354a3167c07Ssthen				;;
355a3167c07Ssthen			i386mach)
356a3167c07Ssthen				basic_machine=i386-mach
357a3167c07Ssthen				basic_os=mach
358a3167c07Ssthen				;;
359a3167c07Ssthen			isi68 | isi)
360a3167c07Ssthen				basic_machine=m68k-isi
361a3167c07Ssthen				basic_os=sysv
362a3167c07Ssthen				;;
363a3167c07Ssthen			m68knommu)
364a3167c07Ssthen				basic_machine=m68k-unknown
365a3167c07Ssthen				basic_os=linux
366a3167c07Ssthen				;;
367a3167c07Ssthen			magnum | m3230)
368a3167c07Ssthen				basic_machine=mips-mips
369a3167c07Ssthen				basic_os=sysv
370a3167c07Ssthen				;;
371a3167c07Ssthen			merlin)
372a3167c07Ssthen				basic_machine=ns32k-utek
373a3167c07Ssthen				basic_os=sysv
374a3167c07Ssthen				;;
375a3167c07Ssthen			mingw64)
376a3167c07Ssthen				basic_machine=x86_64-pc
377a3167c07Ssthen				basic_os=mingw64
378a3167c07Ssthen				;;
379a3167c07Ssthen			mingw32)
380a3167c07Ssthen				basic_machine=i686-pc
381a3167c07Ssthen				basic_os=mingw32
382a3167c07Ssthen				;;
383a3167c07Ssthen			mingw32ce)
384a3167c07Ssthen				basic_machine=arm-unknown
385a3167c07Ssthen				basic_os=mingw32ce
386a3167c07Ssthen				;;
387a3167c07Ssthen			monitor)
388a3167c07Ssthen				basic_machine=m68k-rom68k
389a3167c07Ssthen				basic_os=coff
390a3167c07Ssthen				;;
391a3167c07Ssthen			morphos)
392a3167c07Ssthen				basic_machine=powerpc-unknown
393a3167c07Ssthen				basic_os=morphos
394a3167c07Ssthen				;;
395a3167c07Ssthen			moxiebox)
396a3167c07Ssthen				basic_machine=moxie-unknown
397a3167c07Ssthen				basic_os=moxiebox
398a3167c07Ssthen				;;
399a3167c07Ssthen			msdos)
400a3167c07Ssthen				basic_machine=i386-pc
401a3167c07Ssthen				basic_os=msdos
402a3167c07Ssthen				;;
403a3167c07Ssthen			msys)
404a3167c07Ssthen				basic_machine=i686-pc
405a3167c07Ssthen				basic_os=msys
406a3167c07Ssthen				;;
407a3167c07Ssthen			mvs)
408a3167c07Ssthen				basic_machine=i370-ibm
409a3167c07Ssthen				basic_os=mvs
410a3167c07Ssthen				;;
411a3167c07Ssthen			nacl)
412a3167c07Ssthen				basic_machine=le32-unknown
413a3167c07Ssthen				basic_os=nacl
414a3167c07Ssthen				;;
415a3167c07Ssthen			ncr3000)
416a3167c07Ssthen				basic_machine=i486-ncr
417a3167c07Ssthen				basic_os=sysv4
418a3167c07Ssthen				;;
419a3167c07Ssthen			netbsd386)
420a3167c07Ssthen				basic_machine=i386-pc
421a3167c07Ssthen				basic_os=netbsd
422a3167c07Ssthen				;;
423a3167c07Ssthen			netwinder)
424a3167c07Ssthen				basic_machine=armv4l-rebel
425a3167c07Ssthen				basic_os=linux
426a3167c07Ssthen				;;
427a3167c07Ssthen			news | news700 | news800 | news900)
428a3167c07Ssthen				basic_machine=m68k-sony
429a3167c07Ssthen				basic_os=newsos
430a3167c07Ssthen				;;
431a3167c07Ssthen			news1000)
432a3167c07Ssthen				basic_machine=m68030-sony
433a3167c07Ssthen				basic_os=newsos
434a3167c07Ssthen				;;
435a3167c07Ssthen			necv70)
436a3167c07Ssthen				basic_machine=v70-nec
437a3167c07Ssthen				basic_os=sysv
438a3167c07Ssthen				;;
439a3167c07Ssthen			nh3000)
440a3167c07Ssthen				basic_machine=m68k-harris
441a3167c07Ssthen				basic_os=cxux
442a3167c07Ssthen				;;
443a3167c07Ssthen			nh[45]000)
444a3167c07Ssthen				basic_machine=m88k-harris
445a3167c07Ssthen				basic_os=cxux
446a3167c07Ssthen				;;
447a3167c07Ssthen			nindy960)
448a3167c07Ssthen				basic_machine=i960-intel
449a3167c07Ssthen				basic_os=nindy
450a3167c07Ssthen				;;
451a3167c07Ssthen			mon960)
452a3167c07Ssthen				basic_machine=i960-intel
453a3167c07Ssthen				basic_os=mon960
454a3167c07Ssthen				;;
455a3167c07Ssthen			nonstopux)
456a3167c07Ssthen				basic_machine=mips-compaq
457a3167c07Ssthen				basic_os=nonstopux
458a3167c07Ssthen				;;
459a3167c07Ssthen			os400)
460a3167c07Ssthen				basic_machine=powerpc-ibm
461a3167c07Ssthen				basic_os=os400
462a3167c07Ssthen				;;
463a3167c07Ssthen			OSE68000 | ose68000)
464a3167c07Ssthen				basic_machine=m68000-ericsson
465a3167c07Ssthen				basic_os=ose
466a3167c07Ssthen				;;
467a3167c07Ssthen			os68k)
468a3167c07Ssthen				basic_machine=m68k-none
469a3167c07Ssthen				basic_os=os68k
470a3167c07Ssthen				;;
471a3167c07Ssthen			paragon)
472a3167c07Ssthen				basic_machine=i860-intel
473a3167c07Ssthen				basic_os=osf
474a3167c07Ssthen				;;
475a3167c07Ssthen			parisc)
476a3167c07Ssthen				basic_machine=hppa-unknown
477a3167c07Ssthen				basic_os=linux
478a3167c07Ssthen				;;
479a3167c07Ssthen			psp)
480a3167c07Ssthen				basic_machine=mipsallegrexel-sony
481a3167c07Ssthen				basic_os=psp
482a3167c07Ssthen				;;
483a3167c07Ssthen			pw32)
484a3167c07Ssthen				basic_machine=i586-unknown
485a3167c07Ssthen				basic_os=pw32
486a3167c07Ssthen				;;
487a3167c07Ssthen			rdos | rdos64)
488a3167c07Ssthen				basic_machine=x86_64-pc
489a3167c07Ssthen				basic_os=rdos
490a3167c07Ssthen				;;
491a3167c07Ssthen			rdos32)
492a3167c07Ssthen				basic_machine=i386-pc
493a3167c07Ssthen				basic_os=rdos
494a3167c07Ssthen				;;
495a3167c07Ssthen			rom68k)
496a3167c07Ssthen				basic_machine=m68k-rom68k
497a3167c07Ssthen				basic_os=coff
498a3167c07Ssthen				;;
499a3167c07Ssthen			sa29200)
500a3167c07Ssthen				basic_machine=a29k-amd
501a3167c07Ssthen				basic_os=udi
502a3167c07Ssthen				;;
503a3167c07Ssthen			sei)
504a3167c07Ssthen				basic_machine=mips-sei
505a3167c07Ssthen				basic_os=seiux
506a3167c07Ssthen				;;
507a3167c07Ssthen			sequent)
508a3167c07Ssthen				basic_machine=i386-sequent
509a3167c07Ssthen				basic_os=
510a3167c07Ssthen				;;
511a3167c07Ssthen			sps7)
512a3167c07Ssthen				basic_machine=m68k-bull
513a3167c07Ssthen				basic_os=sysv2
514a3167c07Ssthen				;;
515a3167c07Ssthen			st2000)
516a3167c07Ssthen				basic_machine=m68k-tandem
517a3167c07Ssthen				basic_os=
518a3167c07Ssthen				;;
519a3167c07Ssthen			stratus)
520a3167c07Ssthen				basic_machine=i860-stratus
521a3167c07Ssthen				basic_os=sysv4
522a3167c07Ssthen				;;
523a3167c07Ssthen			sun2)
524a3167c07Ssthen				basic_machine=m68000-sun
525a3167c07Ssthen				basic_os=
526a3167c07Ssthen				;;
527a3167c07Ssthen			sun2os3)
528a3167c07Ssthen				basic_machine=m68000-sun
529a3167c07Ssthen				basic_os=sunos3
530a3167c07Ssthen				;;
531a3167c07Ssthen			sun2os4)
532a3167c07Ssthen				basic_machine=m68000-sun
533a3167c07Ssthen				basic_os=sunos4
534a3167c07Ssthen				;;
535a3167c07Ssthen			sun3)
536a3167c07Ssthen				basic_machine=m68k-sun
537a3167c07Ssthen				basic_os=
538a3167c07Ssthen				;;
539a3167c07Ssthen			sun3os3)
540a3167c07Ssthen				basic_machine=m68k-sun
541a3167c07Ssthen				basic_os=sunos3
542a3167c07Ssthen				;;
543a3167c07Ssthen			sun3os4)
544a3167c07Ssthen				basic_machine=m68k-sun
545a3167c07Ssthen				basic_os=sunos4
546a3167c07Ssthen				;;
547a3167c07Ssthen			sun4)
548a3167c07Ssthen				basic_machine=sparc-sun
549a3167c07Ssthen				basic_os=
550a3167c07Ssthen				;;
551a3167c07Ssthen			sun4os3)
552a3167c07Ssthen				basic_machine=sparc-sun
553a3167c07Ssthen				basic_os=sunos3
554a3167c07Ssthen				;;
555a3167c07Ssthen			sun4os4)
556a3167c07Ssthen				basic_machine=sparc-sun
557a3167c07Ssthen				basic_os=sunos4
558a3167c07Ssthen				;;
559a3167c07Ssthen			sun4sol2)
560a3167c07Ssthen				basic_machine=sparc-sun
561a3167c07Ssthen				basic_os=solaris2
562a3167c07Ssthen				;;
563a3167c07Ssthen			sun386 | sun386i | roadrunner)
564a3167c07Ssthen				basic_machine=i386-sun
565a3167c07Ssthen				basic_os=
566a3167c07Ssthen				;;
567a3167c07Ssthen			sv1)
568a3167c07Ssthen				basic_machine=sv1-cray
569a3167c07Ssthen				basic_os=unicos
570a3167c07Ssthen				;;
571a3167c07Ssthen			symmetry)
572a3167c07Ssthen				basic_machine=i386-sequent
573a3167c07Ssthen				basic_os=dynix
574a3167c07Ssthen				;;
575a3167c07Ssthen			t3e)
576a3167c07Ssthen				basic_machine=alphaev5-cray
577a3167c07Ssthen				basic_os=unicos
578a3167c07Ssthen				;;
579a3167c07Ssthen			t90)
580a3167c07Ssthen				basic_machine=t90-cray
581a3167c07Ssthen				basic_os=unicos
582a3167c07Ssthen				;;
583a3167c07Ssthen			toad1)
584a3167c07Ssthen				basic_machine=pdp10-xkl
585a3167c07Ssthen				basic_os=tops20
586a3167c07Ssthen				;;
587a3167c07Ssthen			tpf)
588a3167c07Ssthen				basic_machine=s390x-ibm
589a3167c07Ssthen				basic_os=tpf
590a3167c07Ssthen				;;
591a3167c07Ssthen			udi29k)
592a3167c07Ssthen				basic_machine=a29k-amd
593a3167c07Ssthen				basic_os=udi
594a3167c07Ssthen				;;
595a3167c07Ssthen			ultra3)
596a3167c07Ssthen				basic_machine=a29k-nyu
597a3167c07Ssthen				basic_os=sym1
598a3167c07Ssthen				;;
599a3167c07Ssthen			v810 | necv810)
600a3167c07Ssthen				basic_machine=v810-nec
601a3167c07Ssthen				basic_os=none
602a3167c07Ssthen				;;
603a3167c07Ssthen			vaxv)
604a3167c07Ssthen				basic_machine=vax-dec
605a3167c07Ssthen				basic_os=sysv
606a3167c07Ssthen				;;
607a3167c07Ssthen			vms)
608a3167c07Ssthen				basic_machine=vax-dec
609a3167c07Ssthen				basic_os=vms
610a3167c07Ssthen				;;
611a3167c07Ssthen			vsta)
612a3167c07Ssthen				basic_machine=i386-pc
613a3167c07Ssthen				basic_os=vsta
614a3167c07Ssthen				;;
615a3167c07Ssthen			vxworks960)
616a3167c07Ssthen				basic_machine=i960-wrs
617a3167c07Ssthen				basic_os=vxworks
618a3167c07Ssthen				;;
619a3167c07Ssthen			vxworks68)
620a3167c07Ssthen				basic_machine=m68k-wrs
621a3167c07Ssthen				basic_os=vxworks
622a3167c07Ssthen				;;
623a3167c07Ssthen			vxworks29k)
624a3167c07Ssthen				basic_machine=a29k-wrs
625a3167c07Ssthen				basic_os=vxworks
626a3167c07Ssthen				;;
627a3167c07Ssthen			xbox)
628a3167c07Ssthen				basic_machine=i686-pc
629a3167c07Ssthen				basic_os=mingw32
630a3167c07Ssthen				;;
631a3167c07Ssthen			ymp)
632a3167c07Ssthen				basic_machine=ymp-cray
633a3167c07Ssthen				basic_os=unicos
634a3167c07Ssthen				;;
635a3167c07Ssthen			*)
636a3167c07Ssthen				basic_machine=$1
637a3167c07Ssthen				basic_os=
638a3167c07Ssthen				;;
639a3167c07Ssthen		esac
640933707f3Ssthen		;;
641933707f3Ssthenesac
642933707f3Ssthen
643a3167c07Ssthen# Decode 1-component or ad-hoc basic machines
644933707f3Ssthencase $basic_machine in
645a3167c07Ssthen	# Here we handle the default manufacturer of certain CPU types.  It is in
646a3167c07Ssthen	# some cases the only manufacturer, in others, it is the most popular.
647a3167c07Ssthen	w89k)
648a3167c07Ssthen		cpu=hppa1.1
649a3167c07Ssthen		vendor=winbond
650a3167c07Ssthen		;;
651a3167c07Ssthen	op50n)
652a3167c07Ssthen		cpu=hppa1.1
653a3167c07Ssthen		vendor=oki
654a3167c07Ssthen		;;
655a3167c07Ssthen	op60c)
656a3167c07Ssthen		cpu=hppa1.1
657a3167c07Ssthen		vendor=oki
658a3167c07Ssthen		;;
659a3167c07Ssthen	ibm*)
660a3167c07Ssthen		cpu=i370
661a3167c07Ssthen		vendor=ibm
662a3167c07Ssthen		;;
663a3167c07Ssthen	orion105)
664a3167c07Ssthen		cpu=clipper
665a3167c07Ssthen		vendor=highlevel
666a3167c07Ssthen		;;
667a3167c07Ssthen	mac | mpw | mac-mpw)
668a3167c07Ssthen		cpu=m68k
669a3167c07Ssthen		vendor=apple
670a3167c07Ssthen		;;
671a3167c07Ssthen	pmac | pmac-mpw)
672a3167c07Ssthen		cpu=powerpc
673a3167c07Ssthen		vendor=apple
674a3167c07Ssthen		;;
675a3167c07Ssthen
676a3167c07Ssthen	# Recognize the various machine names and aliases which stand
677a3167c07Ssthen	# for a CPU type and a company and sometimes even an OS.
678a3167c07Ssthen	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
679a3167c07Ssthen		cpu=m68000
680a3167c07Ssthen		vendor=att
681a3167c07Ssthen		;;
682a3167c07Ssthen	3b*)
683a3167c07Ssthen		cpu=we32k
684a3167c07Ssthen		vendor=att
685a3167c07Ssthen		;;
686a3167c07Ssthen	bluegene*)
687a3167c07Ssthen		cpu=powerpc
688a3167c07Ssthen		vendor=ibm
689a3167c07Ssthen		basic_os=cnk
690a3167c07Ssthen		;;
691a3167c07Ssthen	decsystem10* | dec10*)
692a3167c07Ssthen		cpu=pdp10
693a3167c07Ssthen		vendor=dec
694a3167c07Ssthen		basic_os=tops10
695a3167c07Ssthen		;;
696a3167c07Ssthen	decsystem20* | dec20*)
697a3167c07Ssthen		cpu=pdp10
698a3167c07Ssthen		vendor=dec
699a3167c07Ssthen		basic_os=tops20
700a3167c07Ssthen		;;
701a3167c07Ssthen	delta | 3300 | motorola-3300 | motorola-delta \
702a3167c07Ssthen	      | 3300-motorola | delta-motorola)
703a3167c07Ssthen		cpu=m68k
704a3167c07Ssthen		vendor=motorola
705a3167c07Ssthen		;;
706a3167c07Ssthen	dpx2*)
707a3167c07Ssthen		cpu=m68k
708a3167c07Ssthen		vendor=bull
709a3167c07Ssthen		basic_os=sysv3
710a3167c07Ssthen		;;
711a3167c07Ssthen	encore | umax | mmax)
712a3167c07Ssthen		cpu=ns32k
713a3167c07Ssthen		vendor=encore
714a3167c07Ssthen		;;
715a3167c07Ssthen	elxsi)
716a3167c07Ssthen		cpu=elxsi
717a3167c07Ssthen		vendor=elxsi
718a3167c07Ssthen		basic_os=${basic_os:-bsd}
719a3167c07Ssthen		;;
720a3167c07Ssthen	fx2800)
721a3167c07Ssthen		cpu=i860
722a3167c07Ssthen		vendor=alliant
723a3167c07Ssthen		;;
724a3167c07Ssthen	genix)
725a3167c07Ssthen		cpu=ns32k
726a3167c07Ssthen		vendor=ns
727a3167c07Ssthen		;;
728a3167c07Ssthen	h3050r* | hiux*)
729a3167c07Ssthen		cpu=hppa1.1
730a3167c07Ssthen		vendor=hitachi
731a3167c07Ssthen		basic_os=hiuxwe2
732a3167c07Ssthen		;;
733a3167c07Ssthen	hp3k9[0-9][0-9] | hp9[0-9][0-9])
734a3167c07Ssthen		cpu=hppa1.0
735a3167c07Ssthen		vendor=hp
736a3167c07Ssthen		;;
737a3167c07Ssthen	hp9k2[0-9][0-9] | hp9k31[0-9])
738a3167c07Ssthen		cpu=m68000
739a3167c07Ssthen		vendor=hp
740a3167c07Ssthen		;;
741a3167c07Ssthen	hp9k3[2-9][0-9])
742a3167c07Ssthen		cpu=m68k
743a3167c07Ssthen		vendor=hp
744a3167c07Ssthen		;;
745a3167c07Ssthen	hp9k6[0-9][0-9] | hp6[0-9][0-9])
746a3167c07Ssthen		cpu=hppa1.0
747a3167c07Ssthen		vendor=hp
748a3167c07Ssthen		;;
749a3167c07Ssthen	hp9k7[0-79][0-9] | hp7[0-79][0-9])
750a3167c07Ssthen		cpu=hppa1.1
751a3167c07Ssthen		vendor=hp
752a3167c07Ssthen		;;
753a3167c07Ssthen	hp9k78[0-9] | hp78[0-9])
754a3167c07Ssthen		# FIXME: really hppa2.0-hp
755a3167c07Ssthen		cpu=hppa1.1
756a3167c07Ssthen		vendor=hp
757a3167c07Ssthen		;;
758a3167c07Ssthen	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
759a3167c07Ssthen		# FIXME: really hppa2.0-hp
760a3167c07Ssthen		cpu=hppa1.1
761a3167c07Ssthen		vendor=hp
762a3167c07Ssthen		;;
763a3167c07Ssthen	hp9k8[0-9][13679] | hp8[0-9][13679])
764a3167c07Ssthen		cpu=hppa1.1
765a3167c07Ssthen		vendor=hp
766a3167c07Ssthen		;;
767a3167c07Ssthen	hp9k8[0-9][0-9] | hp8[0-9][0-9])
768a3167c07Ssthen		cpu=hppa1.0
769a3167c07Ssthen		vendor=hp
770a3167c07Ssthen		;;
771a3167c07Ssthen	i*86v32)
772eba819a2Ssthen		cpu=$(echo "$1" | sed -e 's/86.*/86/')
773a3167c07Ssthen		vendor=pc
774a3167c07Ssthen		basic_os=sysv32
775a3167c07Ssthen		;;
776a3167c07Ssthen	i*86v4*)
777eba819a2Ssthen		cpu=$(echo "$1" | sed -e 's/86.*/86/')
778a3167c07Ssthen		vendor=pc
779a3167c07Ssthen		basic_os=sysv4
780a3167c07Ssthen		;;
781a3167c07Ssthen	i*86v)
782eba819a2Ssthen		cpu=$(echo "$1" | sed -e 's/86.*/86/')
783a3167c07Ssthen		vendor=pc
784a3167c07Ssthen		basic_os=sysv
785a3167c07Ssthen		;;
786a3167c07Ssthen	i*86sol2)
787eba819a2Ssthen		cpu=$(echo "$1" | sed -e 's/86.*/86/')
788a3167c07Ssthen		vendor=pc
789a3167c07Ssthen		basic_os=solaris2
790a3167c07Ssthen		;;
791a3167c07Ssthen	j90 | j90-cray)
792a3167c07Ssthen		cpu=j90
793a3167c07Ssthen		vendor=cray
794a3167c07Ssthen		basic_os=${basic_os:-unicos}
795a3167c07Ssthen		;;
796a3167c07Ssthen	iris | iris4d)
797a3167c07Ssthen		cpu=mips
798a3167c07Ssthen		vendor=sgi
799a3167c07Ssthen		case $basic_os in
800a3167c07Ssthen		    irix*)
801a3167c07Ssthen			;;
802a3167c07Ssthen		    *)
803a3167c07Ssthen			basic_os=irix4
804a3167c07Ssthen			;;
805a3167c07Ssthen		esac
806a3167c07Ssthen		;;
807a3167c07Ssthen	miniframe)
808a3167c07Ssthen		cpu=m68000
809a3167c07Ssthen		vendor=convergent
810a3167c07Ssthen		;;
811a3167c07Ssthen	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
812a3167c07Ssthen		cpu=m68k
813a3167c07Ssthen		vendor=atari
814a3167c07Ssthen		basic_os=mint
815a3167c07Ssthen		;;
816a3167c07Ssthen	news-3600 | risc-news)
817a3167c07Ssthen		cpu=mips
818a3167c07Ssthen		vendor=sony
819a3167c07Ssthen		basic_os=newsos
820a3167c07Ssthen		;;
821a3167c07Ssthen	next | m*-next)
822a3167c07Ssthen		cpu=m68k
823a3167c07Ssthen		vendor=next
824a3167c07Ssthen		case $basic_os in
825a3167c07Ssthen		    openstep*)
826a3167c07Ssthen		        ;;
827a3167c07Ssthen		    nextstep*)
828a3167c07Ssthen			;;
829a3167c07Ssthen		    ns2*)
830a3167c07Ssthen		      basic_os=nextstep2
831a3167c07Ssthen			;;
832a3167c07Ssthen		    *)
833a3167c07Ssthen		      basic_os=nextstep3
834a3167c07Ssthen			;;
835a3167c07Ssthen		esac
836a3167c07Ssthen		;;
837a3167c07Ssthen	np1)
838a3167c07Ssthen		cpu=np1
839a3167c07Ssthen		vendor=gould
840a3167c07Ssthen		;;
841a3167c07Ssthen	op50n-* | op60c-*)
842a3167c07Ssthen		cpu=hppa1.1
843a3167c07Ssthen		vendor=oki
844a3167c07Ssthen		basic_os=proelf
845a3167c07Ssthen		;;
846a3167c07Ssthen	pa-hitachi)
847a3167c07Ssthen		cpu=hppa1.1
848a3167c07Ssthen		vendor=hitachi
849a3167c07Ssthen		basic_os=hiuxwe2
850a3167c07Ssthen		;;
851a3167c07Ssthen	pbd)
852a3167c07Ssthen		cpu=sparc
853a3167c07Ssthen		vendor=tti
854a3167c07Ssthen		;;
855a3167c07Ssthen	pbb)
856a3167c07Ssthen		cpu=m68k
857a3167c07Ssthen		vendor=tti
858a3167c07Ssthen		;;
859a3167c07Ssthen	pc532)
860a3167c07Ssthen		cpu=ns32k
861a3167c07Ssthen		vendor=pc532
862a3167c07Ssthen		;;
863a3167c07Ssthen	pn)
864a3167c07Ssthen		cpu=pn
865a3167c07Ssthen		vendor=gould
866a3167c07Ssthen		;;
867a3167c07Ssthen	power)
868a3167c07Ssthen		cpu=power
869a3167c07Ssthen		vendor=ibm
870a3167c07Ssthen		;;
871a3167c07Ssthen	ps2)
872a3167c07Ssthen		cpu=i386
873a3167c07Ssthen		vendor=ibm
874a3167c07Ssthen		;;
875a3167c07Ssthen	rm[46]00)
876a3167c07Ssthen		cpu=mips
877a3167c07Ssthen		vendor=siemens
878a3167c07Ssthen		;;
879a3167c07Ssthen	rtpc | rtpc-*)
880a3167c07Ssthen		cpu=romp
881a3167c07Ssthen		vendor=ibm
882a3167c07Ssthen		;;
883a3167c07Ssthen	sde)
884a3167c07Ssthen		cpu=mipsisa32
885a3167c07Ssthen		vendor=sde
886a3167c07Ssthen		basic_os=${basic_os:-elf}
887a3167c07Ssthen		;;
888a3167c07Ssthen	simso-wrs)
889a3167c07Ssthen		cpu=sparclite
890a3167c07Ssthen		vendor=wrs
891a3167c07Ssthen		basic_os=vxworks
892a3167c07Ssthen		;;
893a3167c07Ssthen	tower | tower-32)
894a3167c07Ssthen		cpu=m68k
895a3167c07Ssthen		vendor=ncr
896a3167c07Ssthen		;;
897a3167c07Ssthen	vpp*|vx|vx-*)
898a3167c07Ssthen		cpu=f301
899a3167c07Ssthen		vendor=fujitsu
900a3167c07Ssthen		;;
901a3167c07Ssthen	w65)
902a3167c07Ssthen		cpu=w65
903a3167c07Ssthen		vendor=wdc
904a3167c07Ssthen		;;
905a3167c07Ssthen	w89k-*)
906a3167c07Ssthen		cpu=hppa1.1
907a3167c07Ssthen		vendor=winbond
908a3167c07Ssthen		basic_os=proelf
909a3167c07Ssthen		;;
910a3167c07Ssthen	none)
911a3167c07Ssthen		cpu=none
912a3167c07Ssthen		vendor=none
913a3167c07Ssthen		;;
914a3167c07Ssthen	leon|leon[3-9])
915a3167c07Ssthen		cpu=sparc
916a3167c07Ssthen		vendor=$basic_machine
917a3167c07Ssthen		;;
918a3167c07Ssthen	leon-*|leon[3-9]-*)
919a3167c07Ssthen		cpu=sparc
920eba819a2Ssthen		vendor=$(echo "$basic_machine" | sed 's/-.*//')
921a3167c07Ssthen		;;
922a3167c07Ssthen
923a3167c07Ssthen	*-*)
924a3167c07Ssthen		# shellcheck disable=SC2162
925a3167c07Ssthen		IFS="-" read cpu vendor <<EOF
926a3167c07Ssthen$basic_machine
927a3167c07SsthenEOF
928a3167c07Ssthen		;;
929a3167c07Ssthen	# We use `pc' rather than `unknown'
930a3167c07Ssthen	# because (1) that's what they normally are, and
931a3167c07Ssthen	# (2) the word "unknown" tends to confuse beginning users.
932a3167c07Ssthen	i*86 | x86_64)
933a3167c07Ssthen		cpu=$basic_machine
934a3167c07Ssthen		vendor=pc
935a3167c07Ssthen		;;
936a3167c07Ssthen	# These rules are duplicated from below for sake of the special case above;
937a3167c07Ssthen	# i.e. things that normalized to x86 arches should also default to "pc"
938a3167c07Ssthen	pc98)
939a3167c07Ssthen		cpu=i386
940a3167c07Ssthen		vendor=pc
941a3167c07Ssthen		;;
942a3167c07Ssthen	x64 | amd64)
943a3167c07Ssthen		cpu=x86_64
944a3167c07Ssthen		vendor=pc
945a3167c07Ssthen		;;
946933707f3Ssthen	# Recognize the basic CPU types without company name.
947a3167c07Ssthen	*)
948a3167c07Ssthen		cpu=$basic_machine
949a3167c07Ssthen		vendor=unknown
950a3167c07Ssthen		;;
951a3167c07Ssthenesac
952a3167c07Ssthen
953a3167c07Ssthenunset -v basic_machine
954a3167c07Ssthen
955a3167c07Ssthen# Decode basic machines in the full and proper CPU-Company form.
956a3167c07Ssthencase $cpu-$vendor in
957a3167c07Ssthen	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
958a3167c07Ssthen	# some cases the only manufacturer, in others, it is the most popular.
959a3167c07Ssthen	craynv-unknown)
960a3167c07Ssthen		vendor=cray
961a3167c07Ssthen		basic_os=${basic_os:-unicosmp}
962a3167c07Ssthen		;;
963a3167c07Ssthen	c90-unknown | c90-cray)
964a3167c07Ssthen		vendor=cray
965a3167c07Ssthen		basic_os=${Basic_os:-unicos}
966a3167c07Ssthen		;;
967a3167c07Ssthen	fx80-unknown)
968a3167c07Ssthen		vendor=alliant
969a3167c07Ssthen		;;
970a3167c07Ssthen	romp-unknown)
971a3167c07Ssthen		vendor=ibm
972a3167c07Ssthen		;;
973a3167c07Ssthen	mmix-unknown)
974a3167c07Ssthen		vendor=knuth
975a3167c07Ssthen		;;
976a3167c07Ssthen	microblaze-unknown | microblazeel-unknown)
977a3167c07Ssthen		vendor=xilinx
978a3167c07Ssthen		;;
979a3167c07Ssthen	rs6000-unknown)
980a3167c07Ssthen		vendor=ibm
981a3167c07Ssthen		;;
982a3167c07Ssthen	vax-unknown)
983a3167c07Ssthen		vendor=dec
984a3167c07Ssthen		;;
985a3167c07Ssthen	pdp11-unknown)
986a3167c07Ssthen		vendor=dec
987a3167c07Ssthen		;;
988a3167c07Ssthen	we32k-unknown)
989a3167c07Ssthen		vendor=att
990a3167c07Ssthen		;;
991a3167c07Ssthen	cydra-unknown)
992a3167c07Ssthen		vendor=cydrome
993a3167c07Ssthen		;;
994a3167c07Ssthen	i370-ibm*)
995a3167c07Ssthen		vendor=ibm
996a3167c07Ssthen		;;
997a3167c07Ssthen	orion-unknown)
998a3167c07Ssthen		vendor=highlevel
999a3167c07Ssthen		;;
1000a3167c07Ssthen	xps-unknown | xps100-unknown)
1001a3167c07Ssthen		cpu=xps100
1002a3167c07Ssthen		vendor=honeywell
1003a3167c07Ssthen		;;
1004a3167c07Ssthen
1005a3167c07Ssthen	# Here we normalize CPU types with a missing or matching vendor
1006a3167c07Ssthen	dpx20-unknown | dpx20-bull)
1007a3167c07Ssthen		cpu=rs6000
1008a3167c07Ssthen		vendor=bull
1009a3167c07Ssthen		basic_os=${basic_os:-bosx}
1010a3167c07Ssthen		;;
1011a3167c07Ssthen
1012a3167c07Ssthen	# Here we normalize CPU types irrespective of the vendor
1013a3167c07Ssthen	amd64-*)
1014a3167c07Ssthen		cpu=x86_64
1015a3167c07Ssthen		;;
1016a3167c07Ssthen	blackfin-*)
1017a3167c07Ssthen		cpu=bfin
1018a3167c07Ssthen		basic_os=linux
1019a3167c07Ssthen		;;
1020a3167c07Ssthen	c54x-*)
1021a3167c07Ssthen		cpu=tic54x
1022a3167c07Ssthen		;;
1023a3167c07Ssthen	c55x-*)
1024a3167c07Ssthen		cpu=tic55x
1025a3167c07Ssthen		;;
1026a3167c07Ssthen	c6x-*)
1027a3167c07Ssthen		cpu=tic6x
1028a3167c07Ssthen		;;
1029a3167c07Ssthen	e500v[12]-*)
1030a3167c07Ssthen		cpu=powerpc
1031a3167c07Ssthen		basic_os=${basic_os}"spe"
1032a3167c07Ssthen		;;
1033a3167c07Ssthen	mips3*-*)
1034a3167c07Ssthen		cpu=mips64
1035a3167c07Ssthen		;;
1036a3167c07Ssthen	ms1-*)
1037a3167c07Ssthen		cpu=mt
1038a3167c07Ssthen		;;
1039a3167c07Ssthen	m68knommu-*)
1040a3167c07Ssthen		cpu=m68k
1041a3167c07Ssthen		basic_os=linux
1042a3167c07Ssthen		;;
1043a3167c07Ssthen	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1044a3167c07Ssthen		cpu=s12z
1045a3167c07Ssthen		;;
1046a3167c07Ssthen	openrisc-*)
1047a3167c07Ssthen		cpu=or32
1048a3167c07Ssthen		;;
1049a3167c07Ssthen	parisc-*)
1050a3167c07Ssthen		cpu=hppa
1051a3167c07Ssthen		basic_os=linux
1052a3167c07Ssthen		;;
1053a3167c07Ssthen	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1054a3167c07Ssthen		cpu=i586
1055a3167c07Ssthen		;;
1056a3167c07Ssthen	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1057a3167c07Ssthen		cpu=i686
1058a3167c07Ssthen		;;
1059a3167c07Ssthen	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1060a3167c07Ssthen		cpu=i686
1061a3167c07Ssthen		;;
1062a3167c07Ssthen	pentium4-*)
1063a3167c07Ssthen		cpu=i786
1064a3167c07Ssthen		;;
1065a3167c07Ssthen	pc98-*)
1066a3167c07Ssthen		cpu=i386
1067a3167c07Ssthen		;;
1068a3167c07Ssthen	ppc-* | ppcbe-*)
1069a3167c07Ssthen		cpu=powerpc
1070a3167c07Ssthen		;;
1071a3167c07Ssthen	ppcle-* | powerpclittle-*)
1072a3167c07Ssthen		cpu=powerpcle
1073a3167c07Ssthen		;;
1074a3167c07Ssthen	ppc64-*)
1075a3167c07Ssthen		cpu=powerpc64
1076a3167c07Ssthen		;;
1077a3167c07Ssthen	ppc64le-* | powerpc64little-*)
1078a3167c07Ssthen		cpu=powerpc64le
1079a3167c07Ssthen		;;
1080a3167c07Ssthen	sb1-*)
1081a3167c07Ssthen		cpu=mipsisa64sb1
1082a3167c07Ssthen		;;
1083a3167c07Ssthen	sb1el-*)
1084a3167c07Ssthen		cpu=mipsisa64sb1el
1085a3167c07Ssthen		;;
1086a3167c07Ssthen	sh5e[lb]-*)
1087eba819a2Ssthen		cpu=$(echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/')
1088a3167c07Ssthen		;;
1089a3167c07Ssthen	spur-*)
1090a3167c07Ssthen		cpu=spur
1091a3167c07Ssthen		;;
1092a3167c07Ssthen	strongarm-* | thumb-*)
1093a3167c07Ssthen		cpu=arm
1094a3167c07Ssthen		;;
1095a3167c07Ssthen	tx39-*)
1096a3167c07Ssthen		cpu=mipstx39
1097a3167c07Ssthen		;;
1098a3167c07Ssthen	tx39el-*)
1099a3167c07Ssthen		cpu=mipstx39el
1100a3167c07Ssthen		;;
1101a3167c07Ssthen	x64-*)
1102a3167c07Ssthen		cpu=x86_64
1103a3167c07Ssthen		;;
1104a3167c07Ssthen	xscale-* | xscalee[bl]-*)
1105eba819a2Ssthen		cpu=$(echo "$cpu" | sed 's/^xscale/arm/')
1106a3167c07Ssthen		;;
1107a3167c07Ssthen	arm64-*)
1108a3167c07Ssthen		cpu=aarch64
1109a3167c07Ssthen		;;
1110a3167c07Ssthen
1111a3167c07Ssthen	# Recognize the canonical CPU Types that limit and/or modify the
1112a3167c07Ssthen	# company names they are paired with.
1113a3167c07Ssthen	cr16-*)
1114a3167c07Ssthen		basic_os=${basic_os:-elf}
1115a3167c07Ssthen		;;
1116a3167c07Ssthen	crisv32-* | etraxfs*-*)
1117a3167c07Ssthen		cpu=crisv32
1118a3167c07Ssthen		vendor=axis
1119a3167c07Ssthen		;;
1120a3167c07Ssthen	cris-* | etrax*-*)
1121a3167c07Ssthen		cpu=cris
1122a3167c07Ssthen		vendor=axis
1123a3167c07Ssthen		;;
1124a3167c07Ssthen	crx-*)
1125a3167c07Ssthen		basic_os=${basic_os:-elf}
1126a3167c07Ssthen		;;
1127a3167c07Ssthen	neo-tandem)
1128a3167c07Ssthen		cpu=neo
1129a3167c07Ssthen		vendor=tandem
1130a3167c07Ssthen		;;
1131a3167c07Ssthen	nse-tandem)
1132a3167c07Ssthen		cpu=nse
1133a3167c07Ssthen		vendor=tandem
1134a3167c07Ssthen		;;
1135a3167c07Ssthen	nsr-tandem)
1136a3167c07Ssthen		cpu=nsr
1137a3167c07Ssthen		vendor=tandem
1138a3167c07Ssthen		;;
1139a3167c07Ssthen	nsv-tandem)
1140a3167c07Ssthen		cpu=nsv
1141a3167c07Ssthen		vendor=tandem
1142a3167c07Ssthen		;;
1143a3167c07Ssthen	nsx-tandem)
1144a3167c07Ssthen		cpu=nsx
1145a3167c07Ssthen		vendor=tandem
1146a3167c07Ssthen		;;
1147a3167c07Ssthen	mipsallegrexel-sony)
1148a3167c07Ssthen		cpu=mipsallegrexel
1149a3167c07Ssthen		vendor=sony
1150a3167c07Ssthen		;;
1151a3167c07Ssthen	tile*-*)
1152a3167c07Ssthen		basic_os=${basic_os:-linux-gnu}
1153a3167c07Ssthen		;;
1154a3167c07Ssthen
1155a3167c07Ssthen	*)
1156a3167c07Ssthen		# Recognize the canonical CPU types that are allowed with any
1157a3167c07Ssthen		# company name.
1158a3167c07Ssthen		case $cpu in
1159933707f3Ssthen			1750a | 580 \
1160933707f3Ssthen			| a29k \
1161229e174cSsthen			| aarch64 | aarch64_be \
1162a3167c07Ssthen			| abacus \
1163a3167c07Ssthen			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1164a3167c07Ssthen			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1165a3167c07Ssthen			| alphapca5[67] | alpha64pca5[67] \
1166933707f3Ssthen			| am33_2.0 \
1167a3167c07Ssthen			| amdgcn \
116898f3ca02Sbrad			| arc | arceb \
1169a3167c07Ssthen			| arm | arm[lb]e | arme[lb] | armv* \
117098f3ca02Sbrad			| avr | avr32 \
1171a3167c07Ssthen			| asmjs \
11720990ddf5Ssthen			| ba \
1173229e174cSsthen			| be32 | be64 \
1174a3167c07Ssthen			| bfin | bpf | bs2000 \
1175a3167c07Ssthen			| c[123]* | c30 | [cjt]90 | c4x \
1176a3167c07Ssthen			| c8051 | clipper | craynv | csky | cydra \
1177933707f3Ssthen			| d10v | d30v | dlx | dsp16xx \
1178a3167c07Ssthen			| e2k | elxsi | epiphany \
1179a3167c07Ssthen			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1180a3167c07Ssthen			| h8300 | h8500 \
1181a3167c07Ssthen			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1182229e174cSsthen			| hexagon \
1183a3167c07Ssthen			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1184933707f3Ssthen			| ip2k | iq2000 \
11850990ddf5Ssthen			| k1om \
1186229e174cSsthen			| le32 | le64 \
1187933707f3Ssthen			| lm32 \
1188*9982a05dSsthen			| loongarch32 | loongarch64 | loongarchx32 \
1189a3167c07Ssthen			| m32c | m32r | m32rle \
1190a3167c07Ssthen			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1191a3167c07Ssthen			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1192a3167c07Ssthen			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1193a3167c07Ssthen			| microblaze | microblazeel \
1194933707f3Ssthen			| mips | mipsbe | mipseb | mipsel | mipsle \
1195933707f3Ssthen			| mips16 \
1196a3167c07Ssthen			| mips64 | mips64eb | mips64el \
1197933707f3Ssthen			| mips64octeon | mips64octeonel \
1198933707f3Ssthen			| mips64orion | mips64orionel \
1199933707f3Ssthen			| mips64r5900 | mips64r5900el \
1200933707f3Ssthen			| mips64vr | mips64vrel \
1201933707f3Ssthen			| mips64vr4100 | mips64vr4100el \
1202933707f3Ssthen			| mips64vr4300 | mips64vr4300el \
1203933707f3Ssthen			| mips64vr5000 | mips64vr5000el \
1204933707f3Ssthen			| mips64vr5900 | mips64vr5900el \
1205933707f3Ssthen			| mipsisa32 | mipsisa32el \
1206933707f3Ssthen			| mipsisa32r2 | mipsisa32r2el \
12070990ddf5Ssthen			| mipsisa32r6 | mipsisa32r6el \
1208933707f3Ssthen			| mipsisa64 | mipsisa64el \
1209933707f3Ssthen			| mipsisa64r2 | mipsisa64r2el \
12100990ddf5Ssthen			| mipsisa64r6 | mipsisa64r6el \
1211933707f3Ssthen			| mipsisa64sb1 | mipsisa64sb1el \
1212933707f3Ssthen			| mipsisa64sr71k | mipsisa64sr71kel \
121398f3ca02Sbrad			| mipsr5900 | mipsr5900el \
1214933707f3Ssthen			| mipstx39 | mipstx39el \
1215a3167c07Ssthen			| mmix \
1216933707f3Ssthen			| mn10200 | mn10300 \
1217933707f3Ssthen			| moxie \
1218933707f3Ssthen			| mt \
1219933707f3Ssthen			| msp430 \
1220229e174cSsthen			| nds32 | nds32le | nds32be \
1221a3167c07Ssthen			| nfp \
122298f3ca02Sbrad			| nios | nios2 | nios2eb | nios2el \
1223a3167c07Ssthen			| none | np1 | ns16k | ns32k | nvptx \
1224a3167c07Ssthen			| open8 \
1225a3167c07Ssthen			| or1k* \
1226a3167c07Ssthen			| or32 \
1227a3167c07Ssthen			| orion \
1228a3167c07Ssthen			| picochip \
1229a3167c07Ssthen			| pdp10 | pdp11 | pj | pjl | pn | power \
1230a3167c07Ssthen			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1231a3167c07Ssthen			| pru \
1232933707f3Ssthen			| pyramid \
1233*9982a05dSsthen			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1234a3167c07Ssthen			| rl78 | romp | rs6000 | rx \
1235a3167c07Ssthen			| s390 | s390x \
1236933707f3Ssthen			| score \
1237a3167c07Ssthen			| sh | shl \
1238a3167c07Ssthen			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1239a3167c07Ssthen			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1240a3167c07Ssthen			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1241a3167c07Ssthen			| sparclite \
1242a3167c07Ssthen			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1243229e174cSsthen			| spu \
1244a3167c07Ssthen			| tahoe \
1245eba819a2Ssthen			| thumbv7* \
1246a3167c07Ssthen			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1247a3167c07Ssthen			| tron \
1248933707f3Ssthen			| ubicom32 \
1249a3167c07Ssthen			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1250a3167c07Ssthen			| vax \
12510990ddf5Ssthen			| visium \
1252a3167c07Ssthen			| w65 \
1253a3167c07Ssthen			| wasm32 | wasm64 \
1254eaf2578eSsthen			| we32k \
1255a3167c07Ssthen			| x86 | x86_64 | xc16x | xgate | xps100 \
1256a3167c07Ssthen			| xstormy16 | xtensa* \
1257a3167c07Ssthen			| ymp \
1258933707f3Ssthen			| z8k | z80)
1259933707f3Ssthen				;;
1260933707f3Ssthen
1261a3167c07Ssthen			*)
1262a3167c07Ssthen				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1263933707f3Ssthen				exit 1
1264933707f3Ssthen				;;
1265933707f3Ssthen		esac
1266933707f3Ssthen		;;
1267933707f3Ssthenesac
1268933707f3Ssthen
1269933707f3Ssthen# Here we canonicalize certain aliases for manufacturers.
1270a3167c07Ssthencase $vendor in
1271a3167c07Ssthen	digital*)
1272a3167c07Ssthen		vendor=dec
1273933707f3Ssthen		;;
1274a3167c07Ssthen	commodore*)
1275a3167c07Ssthen		vendor=cbm
1276933707f3Ssthen		;;
1277933707f3Ssthen	*)
1278933707f3Ssthen		;;
1279933707f3Ssthenesac
1280933707f3Ssthen
1281933707f3Ssthen# Decode manufacturer-specific aliases for certain operating systems.
1282933707f3Ssthen
12832c144df0Ssthenif test x$basic_os != x
1284933707f3Ssthenthen
1285a3167c07Ssthen
1286a3167c07Ssthen# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1287a3167c07Ssthen# set os.
1288a3167c07Ssthencase $basic_os in
1289a3167c07Ssthen	gnu/linux*)
1290a3167c07Ssthen		kernel=linux
1291eba819a2Ssthen		os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|')
1292eba819a2Ssthen		;;
1293eba819a2Ssthen	os2-emx)
1294eba819a2Ssthen		kernel=os2
1295eba819a2Ssthen		os=$(echo $basic_os | sed -e 's|os2-emx|emx|')
1296933707f3Ssthen		;;
1297a3167c07Ssthen	nto-qnx*)
1298a3167c07Ssthen		kernel=nto
1299eba819a2Ssthen		os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|')
1300a3167c07Ssthen		;;
1301a3167c07Ssthen	*-*)
1302a3167c07Ssthen		# shellcheck disable=SC2162
1303a3167c07Ssthen		IFS="-" read kernel os <<EOF
1304a3167c07Ssthen$basic_os
1305a3167c07SsthenEOF
1306a3167c07Ssthen		;;
1307a3167c07Ssthen	# Default OS when just kernel was specified
1308a3167c07Ssthen	nto*)
1309a3167c07Ssthen		kernel=nto
1310eba819a2Ssthen		os=$(echo $basic_os | sed -e 's|nto|qnx|')
1311a3167c07Ssthen		;;
1312a3167c07Ssthen	linux*)
1313a3167c07Ssthen		kernel=linux
1314eba819a2Ssthen		os=$(echo $basic_os | sed -e 's|linux|gnu|')
1315a3167c07Ssthen		;;
1316a3167c07Ssthen	*)
1317a3167c07Ssthen		kernel=
1318a3167c07Ssthen		os=$basic_os
1319a3167c07Ssthen		;;
1320a3167c07Ssthenesac
1321a3167c07Ssthen
1322a3167c07Ssthen# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1323a3167c07Ssthen# etc.)
1324a3167c07Ssthencase $os in
1325a3167c07Ssthen	# First match some system type aliases that might get confused
1326a3167c07Ssthen	# with valid system types.
1327a3167c07Ssthen	# solaris* is a basic system type, with this one exception.
1328a3167c07Ssthen	auroraux)
1329a3167c07Ssthen		os=auroraux
1330a3167c07Ssthen		;;
1331a3167c07Ssthen	bluegene*)
1332a3167c07Ssthen		os=cnk
1333a3167c07Ssthen		;;
1334a3167c07Ssthen	solaris1 | solaris1.*)
1335eba819a2Ssthen		os=$(echo $os | sed -e 's|solaris1|sunos4|')
1336933707f3Ssthen		;;
1337a3167c07Ssthen	solaris)
1338a3167c07Ssthen		os=solaris2
1339933707f3Ssthen		;;
1340a3167c07Ssthen	unixware*)
1341a3167c07Ssthen		os=sysv4.2uw
1342eaf2578eSsthen		;;
1343a3167c07Ssthen	# es1800 is here to avoid being matched by es* (a different OS)
1344a3167c07Ssthen	es1800*)
1345a3167c07Ssthen		os=ose
1346933707f3Ssthen		;;
1347a3167c07Ssthen	# Some version numbers need modification
1348a3167c07Ssthen	chorusos*)
1349a3167c07Ssthen		os=chorusos
1350933707f3Ssthen		;;
1351a3167c07Ssthen	isc)
1352a3167c07Ssthen		os=isc2.2
1353933707f3Ssthen		;;
1354a3167c07Ssthen	sco6)
1355a3167c07Ssthen		os=sco5v6
1356a3167c07Ssthen		;;
1357a3167c07Ssthen	sco5)
1358a3167c07Ssthen		os=sco3.2v5
1359a3167c07Ssthen		;;
1360a3167c07Ssthen	sco4)
1361a3167c07Ssthen		os=sco3.2v4
1362a3167c07Ssthen		;;
1363a3167c07Ssthen	sco3.2.[4-9]*)
1364eba819a2Ssthen		os=$(echo $os | sed -e 's/sco3.2./sco3.2v/')
1365a3167c07Ssthen		;;
1366a3167c07Ssthen	sco*v* | scout)
1367a3167c07Ssthen		# Don't match below
1368a3167c07Ssthen		;;
1369a3167c07Ssthen	sco*)
1370a3167c07Ssthen		os=sco3.2v2
1371a3167c07Ssthen		;;
1372a3167c07Ssthen	psos*)
1373a3167c07Ssthen		os=psos
1374a3167c07Ssthen		;;
1375a3167c07Ssthen	qnx*)
13762c144df0Ssthen		os=qnx
1377933707f3Ssthen		;;
1378a3167c07Ssthen	hiux*)
1379a3167c07Ssthen		os=hiuxwe2
1380933707f3Ssthen		;;
1381a3167c07Ssthen	lynx*178)
1382a3167c07Ssthen		os=lynxos178
1383933707f3Ssthen		;;
1384a3167c07Ssthen	lynx*5)
1385a3167c07Ssthen		os=lynxos5
1386933707f3Ssthen		;;
1387a3167c07Ssthen	lynxos*)
1388a3167c07Ssthen		# don't get caught up in next wildcard
1389933707f3Ssthen		;;
1390a3167c07Ssthen	lynx*)
1391a3167c07Ssthen		os=lynxos
1392933707f3Ssthen		;;
1393a3167c07Ssthen	mac[0-9]*)
1394eba819a2Ssthen		os=$(echo "$os" | sed -e 's|mac|macos|')
1395933707f3Ssthen		;;
1396a3167c07Ssthen	opened*)
1397a3167c07Ssthen		os=openedition
1398933707f3Ssthen		;;
1399a3167c07Ssthen	os400*)
1400a3167c07Ssthen		os=os400
1401933707f3Ssthen		;;
1402a3167c07Ssthen	sunos5*)
1403eba819a2Ssthen		os=$(echo "$os" | sed -e 's|sunos5|solaris2|')
1404933707f3Ssthen		;;
1405a3167c07Ssthen	sunos6*)
1406eba819a2Ssthen		os=$(echo "$os" | sed -e 's|sunos6|solaris3|')
1407933707f3Ssthen		;;
1408a3167c07Ssthen	wince*)
1409a3167c07Ssthen		os=wince
1410933707f3Ssthen		;;
1411a3167c07Ssthen	utek*)
1412a3167c07Ssthen		os=bsd
1413eaf2578eSsthen		;;
1414a3167c07Ssthen	dynix*)
1415a3167c07Ssthen		os=bsd
1416eaf2578eSsthen		;;
1417a3167c07Ssthen	acis*)
1418a3167c07Ssthen		os=aos
1419933707f3Ssthen		;;
1420a3167c07Ssthen	atheos*)
1421a3167c07Ssthen		os=atheos
1422933707f3Ssthen		;;
1423a3167c07Ssthen	syllable*)
1424a3167c07Ssthen		os=syllable
1425933707f3Ssthen		;;
1426a3167c07Ssthen	386bsd)
1427a3167c07Ssthen		os=bsd
1428933707f3Ssthen		;;
1429a3167c07Ssthen	ctix* | uts*)
1430a3167c07Ssthen		os=sysv
1431933707f3Ssthen		;;
1432a3167c07Ssthen	nova*)
1433a3167c07Ssthen		os=rtmk-nova
1434933707f3Ssthen		;;
1435a3167c07Ssthen	ns2)
1436a3167c07Ssthen		os=nextstep2
1437933707f3Ssthen		;;
1438933707f3Ssthen	# Preserve the version number of sinix5.
1439a3167c07Ssthen	sinix5.*)
1440eba819a2Ssthen		os=$(echo $os | sed -e 's|sinix|sysv|')
1441933707f3Ssthen		;;
1442a3167c07Ssthen	sinix*)
1443a3167c07Ssthen		os=sysv4
1444933707f3Ssthen		;;
1445a3167c07Ssthen	tpf*)
1446a3167c07Ssthen		os=tpf
1447933707f3Ssthen		;;
1448a3167c07Ssthen	triton*)
1449a3167c07Ssthen		os=sysv3
1450933707f3Ssthen		;;
1451a3167c07Ssthen	oss*)
1452a3167c07Ssthen		os=sysv3
1453933707f3Ssthen		;;
1454a3167c07Ssthen	svr4*)
1455a3167c07Ssthen		os=sysv4
1456933707f3Ssthen		;;
1457a3167c07Ssthen	svr3)
1458a3167c07Ssthen		os=sysv3
1459933707f3Ssthen		;;
1460a3167c07Ssthen	sysvr4)
1461a3167c07Ssthen		os=sysv4
1462933707f3Ssthen		;;
1463a3167c07Ssthen	ose*)
1464a3167c07Ssthen		os=ose
1465933707f3Ssthen		;;
1466a3167c07Ssthen	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1467a3167c07Ssthen		os=mint
1468933707f3Ssthen		;;
1469a3167c07Ssthen	dicos*)
1470a3167c07Ssthen		os=dicos
1471eaf2578eSsthen		;;
1472a3167c07Ssthen	pikeos*)
1473a3167c07Ssthen		# Until real need of OS specific support for
1474a3167c07Ssthen		# particular features comes up, bare metal
1475a3167c07Ssthen		# configurations are quite functional.
1476a3167c07Ssthen		case $cpu in
1477a3167c07Ssthen		    arm*)
1478a3167c07Ssthen			os=eabi
1479933707f3Ssthen			;;
1480933707f3Ssthen		    *)
1481a3167c07Ssthen			os=elf
1482933707f3Ssthen			;;
1483933707f3Ssthen		esac
1484a3167c07Ssthen		;;
1485a3167c07Ssthen	*)
1486a3167c07Ssthen		# No normalization, but not necessarily accepted, that comes below.
1487a3167c07Ssthen		;;
1488a3167c07Ssthenesac
1489a3167c07Ssthen
1490933707f3Ssthenelse
1491933707f3Ssthen
1492933707f3Ssthen# Here we handle the default operating systems that come with various machines.
1493933707f3Ssthen# The value should be what the vendor currently ships out the door with their
1494933707f3Ssthen# machine or put another way, the most popular os provided with the machine.
1495933707f3Ssthen
1496933707f3Ssthen# Note that if you're going to try to match "-MANUFACTURER" here (say,
1497933707f3Ssthen# "-sun"), then you have to tell the case statement up towards the top
1498933707f3Ssthen# that MANUFACTURER isn't an operating system.  Otherwise, code above
1499933707f3Ssthen# will signal an error saying that MANUFACTURER isn't an operating
1500933707f3Ssthen# system, and we'll never get to this point.
1501933707f3Ssthen
1502a3167c07Ssthenkernel=
1503a3167c07Ssthencase $cpu-$vendor in
1504933707f3Ssthen	score-*)
1505a3167c07Ssthen		os=elf
1506933707f3Ssthen		;;
1507933707f3Ssthen	spu-*)
1508a3167c07Ssthen		os=elf
1509933707f3Ssthen		;;
1510933707f3Ssthen	*-acorn)
1511a3167c07Ssthen		os=riscix1.2
1512933707f3Ssthen		;;
1513933707f3Ssthen	arm*-rebel)
1514a3167c07Ssthen		kernel=linux
1515a3167c07Ssthen		os=gnu
1516933707f3Ssthen		;;
1517933707f3Ssthen	arm*-semi)
1518a3167c07Ssthen		os=aout
1519933707f3Ssthen		;;
1520933707f3Ssthen	c4x-* | tic4x-*)
1521a3167c07Ssthen		os=coff
1522933707f3Ssthen		;;
152398f3ca02Sbrad	c8051-*)
1524a3167c07Ssthen		os=elf
1525a3167c07Ssthen		;;
1526a3167c07Ssthen	clipper-intergraph)
1527a3167c07Ssthen		os=clix
152898f3ca02Sbrad		;;
1529229e174cSsthen	hexagon-*)
1530a3167c07Ssthen		os=elf
1531229e174cSsthen		;;
1532229e174cSsthen	tic54x-*)
1533a3167c07Ssthen		os=coff
1534229e174cSsthen		;;
1535229e174cSsthen	tic55x-*)
1536a3167c07Ssthen		os=coff
1537229e174cSsthen		;;
1538229e174cSsthen	tic6x-*)
1539a3167c07Ssthen		os=coff
1540229e174cSsthen		;;
1541933707f3Ssthen	# This must come before the *-dec entry.
1542933707f3Ssthen	pdp10-*)
1543a3167c07Ssthen		os=tops20
1544933707f3Ssthen		;;
1545933707f3Ssthen	pdp11-*)
1546a3167c07Ssthen		os=none
1547933707f3Ssthen		;;
1548933707f3Ssthen	*-dec | vax-*)
1549a3167c07Ssthen		os=ultrix4.2
1550933707f3Ssthen		;;
1551933707f3Ssthen	m68*-apollo)
1552a3167c07Ssthen		os=domain
1553933707f3Ssthen		;;
1554933707f3Ssthen	i386-sun)
1555a3167c07Ssthen		os=sunos4.0.2
1556933707f3Ssthen		;;
1557933707f3Ssthen	m68000-sun)
1558a3167c07Ssthen		os=sunos3
1559933707f3Ssthen		;;
1560933707f3Ssthen	m68*-cisco)
1561a3167c07Ssthen		os=aout
1562933707f3Ssthen		;;
1563933707f3Ssthen	mep-*)
1564a3167c07Ssthen		os=elf
1565933707f3Ssthen		;;
1566933707f3Ssthen	mips*-cisco)
1567a3167c07Ssthen		os=elf
1568933707f3Ssthen		;;
1569933707f3Ssthen	mips*-*)
1570a3167c07Ssthen		os=elf
1571933707f3Ssthen		;;
1572933707f3Ssthen	or32-*)
1573a3167c07Ssthen		os=coff
1574933707f3Ssthen		;;
1575933707f3Ssthen	*-tti)	# must be before sparc entry or we get the wrong os.
1576a3167c07Ssthen		os=sysv3
1577933707f3Ssthen		;;
1578933707f3Ssthen	sparc-* | *-sun)
1579a3167c07Ssthen		os=sunos4.1.1
1580a3167c07Ssthen		;;
1581a3167c07Ssthen	pru-*)
1582a3167c07Ssthen		os=elf
1583933707f3Ssthen		;;
1584933707f3Ssthen	*-be)
1585a3167c07Ssthen		os=beos
1586eaf2578eSsthen		;;
1587933707f3Ssthen	*-ibm)
1588a3167c07Ssthen		os=aix
1589933707f3Ssthen		;;
1590933707f3Ssthen	*-knuth)
1591a3167c07Ssthen		os=mmixware
1592933707f3Ssthen		;;
1593933707f3Ssthen	*-wec)
1594a3167c07Ssthen		os=proelf
1595933707f3Ssthen		;;
1596933707f3Ssthen	*-winbond)
1597a3167c07Ssthen		os=proelf
1598933707f3Ssthen		;;
1599933707f3Ssthen	*-oki)
1600a3167c07Ssthen		os=proelf
1601933707f3Ssthen		;;
1602933707f3Ssthen	*-hp)
1603a3167c07Ssthen		os=hpux
1604933707f3Ssthen		;;
1605933707f3Ssthen	*-hitachi)
1606a3167c07Ssthen		os=hiux
1607933707f3Ssthen		;;
1608933707f3Ssthen	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1609a3167c07Ssthen		os=sysv
1610933707f3Ssthen		;;
1611933707f3Ssthen	*-cbm)
1612a3167c07Ssthen		os=amigaos
1613933707f3Ssthen		;;
1614933707f3Ssthen	*-dg)
1615a3167c07Ssthen		os=dgux
1616933707f3Ssthen		;;
1617933707f3Ssthen	*-dolphin)
1618a3167c07Ssthen		os=sysv3
1619933707f3Ssthen		;;
1620933707f3Ssthen	m68k-ccur)
1621a3167c07Ssthen		os=rtu
1622933707f3Ssthen		;;
1623933707f3Ssthen	m88k-omron*)
1624a3167c07Ssthen		os=luna
1625933707f3Ssthen		;;
1626933707f3Ssthen	*-next)
1627a3167c07Ssthen		os=nextstep
1628933707f3Ssthen		;;
1629933707f3Ssthen	*-sequent)
1630a3167c07Ssthen		os=ptx
1631933707f3Ssthen		;;
1632933707f3Ssthen	*-crds)
1633a3167c07Ssthen		os=unos
1634933707f3Ssthen		;;
1635933707f3Ssthen	*-ns)
1636a3167c07Ssthen		os=genix
1637933707f3Ssthen		;;
1638933707f3Ssthen	i370-*)
1639a3167c07Ssthen		os=mvs
1640eaf2578eSsthen		;;
1641933707f3Ssthen	*-gould)
1642a3167c07Ssthen		os=sysv
1643933707f3Ssthen		;;
1644933707f3Ssthen	*-highlevel)
1645a3167c07Ssthen		os=bsd
1646933707f3Ssthen		;;
1647933707f3Ssthen	*-encore)
1648a3167c07Ssthen		os=bsd
1649933707f3Ssthen		;;
1650933707f3Ssthen	*-sgi)
1651a3167c07Ssthen		os=irix
1652933707f3Ssthen		;;
1653933707f3Ssthen	*-siemens)
1654a3167c07Ssthen		os=sysv4
1655933707f3Ssthen		;;
1656933707f3Ssthen	*-masscomp)
1657a3167c07Ssthen		os=rtu
1658933707f3Ssthen		;;
1659933707f3Ssthen	f30[01]-fujitsu | f700-fujitsu)
1660a3167c07Ssthen		os=uxpv
1661933707f3Ssthen		;;
1662933707f3Ssthen	*-rom68k)
1663a3167c07Ssthen		os=coff
1664933707f3Ssthen		;;
1665933707f3Ssthen	*-*bug)
1666a3167c07Ssthen		os=coff
1667933707f3Ssthen		;;
1668933707f3Ssthen	*-apple)
1669a3167c07Ssthen		os=macos
1670933707f3Ssthen		;;
1671933707f3Ssthen	*-atari*)
1672a3167c07Ssthen		os=mint
1673a3167c07Ssthen		;;
1674a3167c07Ssthen	*-wrs)
1675a3167c07Ssthen		os=vxworks
1676933707f3Ssthen		;;
1677933707f3Ssthen	*)
1678a3167c07Ssthen		os=none
1679933707f3Ssthen		;;
1680933707f3Ssthenesac
1681a3167c07Ssthen
1682933707f3Ssthenfi
1683933707f3Ssthen
1684a3167c07Ssthen# Now, validate our (potentially fixed-up) OS.
1685a3167c07Ssthencase $os in
1686*9982a05dSsthen	# Sometimes we do "kernel-libc", so those need to count as OSes.
1687a3167c07Ssthen	musl* | newlib* | uclibc*)
1688a3167c07Ssthen		;;
1689*9982a05dSsthen	# Likewise for "kernel-abi"
1690*9982a05dSsthen	eabi* | gnueabi*)
1691*9982a05dSsthen		;;
1692*9982a05dSsthen	# VxWorks passes extra cpu info in the 4th filed.
1693*9982a05dSsthen	simlinux | simwindows | spe)
1694a3167c07Ssthen		;;
1695a3167c07Ssthen	# Now accept the basic system types.
1696a3167c07Ssthen	# The portable systems comes first.
1697a3167c07Ssthen	# Each alternative MUST end in a * to match a version number.
1698a3167c07Ssthen	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1699a3167c07Ssthen	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1700a3167c07Ssthen	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1701a3167c07Ssthen	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1702a3167c07Ssthen	     | hiux* | abug | nacl* | netware* | windows* \
1703a3167c07Ssthen	     | os9* | macos* | osx* | ios* \
1704a3167c07Ssthen	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1705a3167c07Ssthen	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1706a3167c07Ssthen	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1707a3167c07Ssthen	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1708a3167c07Ssthen	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1709a3167c07Ssthen	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1710a3167c07Ssthen	     | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
1711a3167c07Ssthen	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1712a3167c07Ssthen	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1713a3167c07Ssthen	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1714a3167c07Ssthen	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1715a3167c07Ssthen	     | chorusrdb* | cegcc* | glidix* \
1716a3167c07Ssthen	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1717a3167c07Ssthen	     | midipix* | mingw32* | mingw64* | mint* \
1718a3167c07Ssthen	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1719a3167c07Ssthen	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1720a3167c07Ssthen	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1721a3167c07Ssthen	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1722a3167c07Ssthen	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1723a3167c07Ssthen	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1724a3167c07Ssthen	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1725a3167c07Ssthen	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1726a3167c07Ssthen	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1727a3167c07Ssthen	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1728eba819a2Ssthen	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*)
1729a3167c07Ssthen		;;
1730a3167c07Ssthen	# This one is extra strict with allowed versions
1731a3167c07Ssthen	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1732a3167c07Ssthen		# Don't forget version if it is 3.2v4 or newer.
1733a3167c07Ssthen		;;
1734a3167c07Ssthen	none)
1735a3167c07Ssthen		;;
1736a3167c07Ssthen	*)
1737a3167c07Ssthen		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1738a3167c07Ssthen		exit 1
1739a3167c07Ssthen		;;
1740a3167c07Ssthenesac
1741a3167c07Ssthen
1742a3167c07Ssthen# As a final step for OS-related things, validate the OS-kernel combination
1743a3167c07Ssthen# (given a valid OS), if there is a kernel.
1744a3167c07Ssthencase $kernel-$os in
1745a3167c07Ssthen	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
1746a3167c07Ssthen		;;
17472c144df0Ssthen	uclinux-uclibc* )
17482c144df0Ssthen		;;
1749a3167c07Ssthen	-dietlibc* | -newlib* | -musl* | -uclibc* )
1750a3167c07Ssthen		# These are just libc implementations, not actual OSes, and thus
1751a3167c07Ssthen		# require a kernel.
1752a3167c07Ssthen		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1753a3167c07Ssthen		exit 1
1754a3167c07Ssthen		;;
1755a3167c07Ssthen	kfreebsd*-gnu* | kopensolaris*-gnu*)
1756a3167c07Ssthen		;;
1757*9982a05dSsthen	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1758*9982a05dSsthen		;;
1759a3167c07Ssthen	nto-qnx*)
1760a3167c07Ssthen		;;
1761eba819a2Ssthen	os2-emx)
1762eba819a2Ssthen		;;
1763a3167c07Ssthen	*-eabi* | *-gnueabi*)
1764a3167c07Ssthen		;;
1765a3167c07Ssthen	-*)
1766a3167c07Ssthen		# Blank kernel with real OS is always fine.
1767a3167c07Ssthen		;;
1768a3167c07Ssthen	*-*)
1769a3167c07Ssthen		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1770a3167c07Ssthen		exit 1
1771a3167c07Ssthen		;;
1772a3167c07Ssthenesac
1773a3167c07Ssthen
1774933707f3Ssthen# Here we handle the case where we know the os, and the CPU type, but not the
1775933707f3Ssthen# manufacturer.  We pick the logical manufacturer.
1776a3167c07Ssthencase $vendor in
1777a3167c07Ssthen	unknown)
1778a3167c07Ssthen		case $cpu-$os in
1779a3167c07Ssthen			*-riscix*)
1780933707f3Ssthen				vendor=acorn
1781933707f3Ssthen				;;
1782a3167c07Ssthen			*-sunos*)
1783933707f3Ssthen				vendor=sun
1784933707f3Ssthen				;;
1785a3167c07Ssthen			*-cnk* | *-aix*)
1786933707f3Ssthen				vendor=ibm
1787933707f3Ssthen				;;
1788a3167c07Ssthen			*-beos*)
1789933707f3Ssthen				vendor=be
1790933707f3Ssthen				;;
1791a3167c07Ssthen			*-hpux*)
1792933707f3Ssthen				vendor=hp
1793933707f3Ssthen				;;
1794a3167c07Ssthen			*-mpeix*)
1795933707f3Ssthen				vendor=hp
1796933707f3Ssthen				;;
1797a3167c07Ssthen			*-hiux*)
1798933707f3Ssthen				vendor=hitachi
1799933707f3Ssthen				;;
1800a3167c07Ssthen			*-unos*)
1801933707f3Ssthen				vendor=crds
1802933707f3Ssthen				;;
1803a3167c07Ssthen			*-dgux*)
1804933707f3Ssthen				vendor=dg
1805933707f3Ssthen				;;
1806a3167c07Ssthen			*-luna*)
1807933707f3Ssthen				vendor=omron
1808933707f3Ssthen				;;
1809a3167c07Ssthen			*-genix*)
1810933707f3Ssthen				vendor=ns
1811933707f3Ssthen				;;
1812a3167c07Ssthen			*-clix*)
1813a3167c07Ssthen				vendor=intergraph
1814a3167c07Ssthen				;;
1815a3167c07Ssthen			*-mvs* | *-opened*)
1816933707f3Ssthen				vendor=ibm
1817933707f3Ssthen				;;
1818a3167c07Ssthen			*-os400*)
1819933707f3Ssthen				vendor=ibm
1820933707f3Ssthen				;;
1821a3167c07Ssthen			s390-* | s390x-*)
1822a3167c07Ssthen				vendor=ibm
1823a3167c07Ssthen				;;
1824a3167c07Ssthen			*-ptx*)
1825933707f3Ssthen				vendor=sequent
1826933707f3Ssthen				;;
1827a3167c07Ssthen			*-tpf*)
1828933707f3Ssthen				vendor=ibm
1829933707f3Ssthen				;;
1830a3167c07Ssthen			*-vxsim* | *-vxworks* | *-windiss*)
1831933707f3Ssthen				vendor=wrs
1832933707f3Ssthen				;;
1833a3167c07Ssthen			*-aux*)
1834933707f3Ssthen				vendor=apple
1835933707f3Ssthen				;;
1836a3167c07Ssthen			*-hms*)
1837933707f3Ssthen				vendor=hitachi
1838933707f3Ssthen				;;
1839a3167c07Ssthen			*-mpw* | *-macos*)
1840933707f3Ssthen				vendor=apple
1841933707f3Ssthen				;;
1842a3167c07Ssthen			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1843933707f3Ssthen				vendor=atari
1844933707f3Ssthen				;;
1845a3167c07Ssthen			*-vos*)
1846933707f3Ssthen				vendor=stratus
1847933707f3Ssthen				;;
1848933707f3Ssthen		esac
1849933707f3Ssthen		;;
1850933707f3Ssthenesac
1851933707f3Ssthen
1852a3167c07Ssthenecho "$cpu-$vendor-${kernel:+$kernel-}$os"
1853933707f3Ssthenexit
1854933707f3Ssthen
1855933707f3Ssthen# Local variables:
1856a3167c07Ssthen# eval: (add-hook 'before-save-hook 'time-stamp)
1857933707f3Ssthen# time-stamp-start: "timestamp='"
1858933707f3Ssthen# time-stamp-format: "%:y-%02m-%02d"
1859933707f3Ssthen# time-stamp-end: "'"
1860933707f3Ssthen# End:
1861