1a850946eSmrg#! /bin/sh
2a850946eSmrg# Configuration validation subroutine script.
3da4b5163Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
4a850946eSmrg
5da4b5163Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6da4b5163Smrg
7da4b5163Smrgtimestamp='2021-08-14'
8a850946eSmrg
99511053fSmrg# This file is free software; you can redistribute it and/or modify it
109511053fSmrg# under the terms of the GNU General Public License as published by
119511053fSmrg# the Free Software Foundation; either version 3 of the License, or
12a850946eSmrg# (at your option) any later version.
13a850946eSmrg#
149511053fSmrg# This program is distributed in the hope that it will be useful, but
159511053fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
169511053fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179511053fSmrg# General Public License for more details.
18a850946eSmrg#
19a850946eSmrg# You should have received a copy of the GNU General Public License
20c44a0236Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2170f7c90cSmrg#
22a850946eSmrg# As a special exception to the GNU General Public License, if you
23a850946eSmrg# distribute this file as part of a program that contains a
24a850946eSmrg# configuration script generated by Autoconf, you may include it under
259511053fSmrg# the same distribution terms that you use for the rest of that
269511053fSmrg# program.  This Exception is an additional permission under section 7
279511053fSmrg# of the GNU General Public License, version 3 ("GPLv3").
28a850946eSmrg
2970f7c90cSmrg
30c44a0236Smrg# Please send patches to <config-patches@gnu.org>.
31a850946eSmrg#
32a850946eSmrg# Configuration subroutine to validate and canonicalize a configuration type.
33a850946eSmrg# Supply the specified configuration type as an argument.
34a850946eSmrg# If it is invalid, we print an error message on stderr and exit with code 1.
35a850946eSmrg# Otherwise, we print the canonical config type on stdout and succeed.
36a850946eSmrg
377dff02feSmrg# You can get the latest version of this script from:
38da4b5163Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
397dff02feSmrg
40a850946eSmrg# This file is supposed to be the same for all GNU packages
41a850946eSmrg# and recognize all the CPU types, system types and aliases
42a850946eSmrg# that are meaningful with *any* GNU software.
43a850946eSmrg# Each package is responsible for reporting which valid configurations
44a850946eSmrg# it does not support.  The user should be able to distinguish
45a850946eSmrg# a failure to support a valid configuration from a meaningless
46a850946eSmrg# configuration.
47a850946eSmrg
48a850946eSmrg# The goal of this file is to map all the various variations of a given
49a850946eSmrg# machine specification into a single specification in the form:
50a850946eSmrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51a850946eSmrg# or in some cases, the newer four-part form:
52a850946eSmrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53a850946eSmrg# It is wrong to echo any other type of specification.
54a850946eSmrg
55da4b5163Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56da4b5163Smrg# about features and limitations of the classic Bourne shell that were
57da4b5163Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58da4b5163Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59da4b5163Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60da4b5163Smrg# have a pre-POSIX /bin/sh.
61da4b5163Smrg
62a850946eSmrgme=`echo "$0" | sed -e 's,.*/,,'`
63a850946eSmrg
64a850946eSmrgusage="\
65c44a0236SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66a850946eSmrg
67a850946eSmrgCanonicalize a configuration name.
68a850946eSmrg
69c44a0236SmrgOptions:
70a850946eSmrg  -h, --help         print this help, then exit
71a850946eSmrg  -t, --time-stamp   print date of last modification, then exit
72a850946eSmrg  -v, --version      print version number, then exit
73a850946eSmrg
74a850946eSmrgReport bugs and patches to <config-patches@gnu.org>."
75a850946eSmrg
76a850946eSmrgversion="\
77a850946eSmrgGNU config.sub ($timestamp)
78a850946eSmrg
79da4b5163SmrgCopyright 1992-2021 Free Software Foundation, Inc.
80a850946eSmrg
81a850946eSmrgThis is free software; see the source for copying conditions.  There is NO
82a850946eSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83a850946eSmrg
84a850946eSmrghelp="
85a850946eSmrgTry \`$me --help' for more information."
86a850946eSmrg
87a850946eSmrg# Parse command line
88a850946eSmrgwhile test $# -gt 0 ; do
89a850946eSmrg  case $1 in
90a850946eSmrg    --time-stamp | --time* | -t )
9170f7c90cSmrg       echo "$timestamp" ; exit ;;
92a850946eSmrg    --version | -v )
9370f7c90cSmrg       echo "$version" ; exit ;;
94a850946eSmrg    --help | --h* | -h )
9570f7c90cSmrg       echo "$usage"; exit ;;
96a850946eSmrg    -- )     # Stop option processing
97a850946eSmrg       shift; break ;;
98a850946eSmrg    - )	# Use stdin as input.
99a850946eSmrg       break ;;
100a850946eSmrg    -* )
101da4b5163Smrg       echo "$me: invalid option $1$help" >&2
102a850946eSmrg       exit 1 ;;
103a850946eSmrg
104a850946eSmrg    *local*)
105a850946eSmrg       # First pass through any local machine types.
106c44a0236Smrg       echo "$1"
10770f7c90cSmrg       exit ;;
108a850946eSmrg
109a850946eSmrg    * )
110a850946eSmrg       break ;;
111a850946eSmrg  esac
112a850946eSmrgdone
113a850946eSmrg
114a850946eSmrgcase $# in
115a850946eSmrg 0) echo "$me: missing argument$help" >&2
116a850946eSmrg    exit 1;;
117a850946eSmrg 1) ;;
118a850946eSmrg *) echo "$me: too many arguments$help" >&2
119a850946eSmrg    exit 1;;
120a850946eSmrgesac
121a850946eSmrg
122da4b5163Smrg# Split fields of configuration type
123da4b5163Smrg# shellcheck disable=SC2162
124da4b5163Smrgsaved_IFS=$IFS
125da4b5163SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126da4b5163Smrg$1
127da4b5163SmrgEOF
128da4b5163SmrgIFS=$saved_IFS
129a850946eSmrg
130da4b5163Smrg# Separate into logical components for further validation
131da4b5163Smrgcase $1 in
132da4b5163Smrg	*-*-*-*-*)
133da4b5163Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134da4b5163Smrg		exit 1
1359511053fSmrg		;;
136da4b5163Smrg	*-*-*-*)
137da4b5163Smrg		basic_machine=$field1-$field2
138da4b5163Smrg		basic_os=$field3-$field4
139a850946eSmrg		;;
140da4b5163Smrg	*-*-*)
141da4b5163Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142da4b5163Smrg		# parts
143da4b5163Smrg		maybe_os=$field2-$field3
144da4b5163Smrg		case $maybe_os in
145da4b5163Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146da4b5163Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147da4b5163Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148da4b5163Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
149da4b5163Smrg				basic_machine=$field1
150da4b5163Smrg				basic_os=$maybe_os
151da4b5163Smrg				;;
152da4b5163Smrg			android-linux)
153da4b5163Smrg				basic_machine=$field1-unknown
154da4b5163Smrg				basic_os=linux-android
155da4b5163Smrg				;;
156da4b5163Smrg			*)
157da4b5163Smrg				basic_machine=$field1-$field2
158da4b5163Smrg				basic_os=$field3
159da4b5163Smrg				;;
160da4b5163Smrg		esac
161a850946eSmrg		;;
162da4b5163Smrg	*-*)
163da4b5163Smrg		# A lone config we happen to match not fitting any pattern
164da4b5163Smrg		case $field1-$field2 in
165da4b5163Smrg			decstation-3100)
166da4b5163Smrg				basic_machine=mips-dec
167da4b5163Smrg				basic_os=
168da4b5163Smrg				;;
169da4b5163Smrg			*-*)
170da4b5163Smrg				# Second component is usually, but not always the OS
171da4b5163Smrg				case $field2 in
172da4b5163Smrg					# Prevent following clause from handling this valid os
173da4b5163Smrg					sun*os*)
174da4b5163Smrg						basic_machine=$field1
175da4b5163Smrg						basic_os=$field2
176da4b5163Smrg						;;
177da4b5163Smrg					zephyr*)
178da4b5163Smrg						basic_machine=$field1-unknown
179da4b5163Smrg						basic_os=$field2
180da4b5163Smrg						;;
181da4b5163Smrg					# Manufacturers
182da4b5163Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183da4b5163Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184da4b5163Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185da4b5163Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186da4b5163Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187da4b5163Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188da4b5163Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189da4b5163Smrg					| microblaze* | sim | cisco \
190da4b5163Smrg					| oki | wec | wrs | winbond)
191da4b5163Smrg						basic_machine=$field1-$field2
192da4b5163Smrg						basic_os=
193da4b5163Smrg						;;
194da4b5163Smrg					*)
195da4b5163Smrg						basic_machine=$field1
196da4b5163Smrg						basic_os=$field2
197da4b5163Smrg						;;
198da4b5163Smrg				esac
199da4b5163Smrg			;;
200da4b5163Smrg		esac
201a850946eSmrg		;;
202da4b5163Smrg	*)
203da4b5163Smrg		# Convert single-component short-hands not valid as part of
204da4b5163Smrg		# multi-component configurations.
205da4b5163Smrg		case $field1 in
206da4b5163Smrg			386bsd)
207da4b5163Smrg				basic_machine=i386-pc
208da4b5163Smrg				basic_os=bsd
209da4b5163Smrg				;;
210da4b5163Smrg			a29khif)
211da4b5163Smrg				basic_machine=a29k-amd
212da4b5163Smrg				basic_os=udi
213da4b5163Smrg				;;
214da4b5163Smrg			adobe68k)
215da4b5163Smrg				basic_machine=m68010-adobe
216da4b5163Smrg				basic_os=scout
217da4b5163Smrg				;;
218da4b5163Smrg			alliant)
219da4b5163Smrg				basic_machine=fx80-alliant
220da4b5163Smrg				basic_os=
221da4b5163Smrg				;;
222da4b5163Smrg			altos | altos3068)
223da4b5163Smrg				basic_machine=m68k-altos
224da4b5163Smrg				basic_os=
225da4b5163Smrg				;;
226da4b5163Smrg			am29k)
227da4b5163Smrg				basic_machine=a29k-none
228da4b5163Smrg				basic_os=bsd
229da4b5163Smrg				;;
230da4b5163Smrg			amdahl)
231da4b5163Smrg				basic_machine=580-amdahl
232da4b5163Smrg				basic_os=sysv
233da4b5163Smrg				;;
234da4b5163Smrg			amiga)
235da4b5163Smrg				basic_machine=m68k-unknown
236da4b5163Smrg				basic_os=
237da4b5163Smrg				;;
238da4b5163Smrg			amigaos | amigados)
239da4b5163Smrg				basic_machine=m68k-unknown
240da4b5163Smrg				basic_os=amigaos
241da4b5163Smrg				;;
242da4b5163Smrg			amigaunix | amix)
243da4b5163Smrg				basic_machine=m68k-unknown
244da4b5163Smrg				basic_os=sysv4
245da4b5163Smrg				;;
246da4b5163Smrg			apollo68)
247da4b5163Smrg				basic_machine=m68k-apollo
248da4b5163Smrg				basic_os=sysv
249da4b5163Smrg				;;
250da4b5163Smrg			apollo68bsd)
251da4b5163Smrg				basic_machine=m68k-apollo
252da4b5163Smrg				basic_os=bsd
253da4b5163Smrg				;;
254da4b5163Smrg			aros)
255da4b5163Smrg				basic_machine=i386-pc
256da4b5163Smrg				basic_os=aros
257da4b5163Smrg				;;
258da4b5163Smrg			aux)
259da4b5163Smrg				basic_machine=m68k-apple
260da4b5163Smrg				basic_os=aux
261da4b5163Smrg				;;
262da4b5163Smrg			balance)
263da4b5163Smrg				basic_machine=ns32k-sequent
264da4b5163Smrg				basic_os=dynix
265da4b5163Smrg				;;
266da4b5163Smrg			blackfin)
267da4b5163Smrg				basic_machine=bfin-unknown
268da4b5163Smrg				basic_os=linux
269da4b5163Smrg				;;
270da4b5163Smrg			cegcc)
271da4b5163Smrg				basic_machine=arm-unknown
272da4b5163Smrg				basic_os=cegcc
273da4b5163Smrg				;;
274da4b5163Smrg			convex-c1)
275da4b5163Smrg				basic_machine=c1-convex
276da4b5163Smrg				basic_os=bsd
277da4b5163Smrg				;;
278da4b5163Smrg			convex-c2)
279da4b5163Smrg				basic_machine=c2-convex
280da4b5163Smrg				basic_os=bsd
281da4b5163Smrg				;;
282da4b5163Smrg			convex-c32)
283da4b5163Smrg				basic_machine=c32-convex
284da4b5163Smrg				basic_os=bsd
285da4b5163Smrg				;;
286da4b5163Smrg			convex-c34)
287da4b5163Smrg				basic_machine=c34-convex
288da4b5163Smrg				basic_os=bsd
289da4b5163Smrg				;;
290da4b5163Smrg			convex-c38)
291da4b5163Smrg				basic_machine=c38-convex
292da4b5163Smrg				basic_os=bsd
293da4b5163Smrg				;;
294da4b5163Smrg			cray)
295da4b5163Smrg				basic_machine=j90-cray
296da4b5163Smrg				basic_os=unicos
297da4b5163Smrg				;;
298da4b5163Smrg			crds | unos)
299da4b5163Smrg				basic_machine=m68k-crds
300da4b5163Smrg				basic_os=
301da4b5163Smrg				;;
302da4b5163Smrg			da30)
303da4b5163Smrg				basic_machine=m68k-da30
304da4b5163Smrg				basic_os=
305da4b5163Smrg				;;
306da4b5163Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307da4b5163Smrg				basic_machine=mips-dec
308da4b5163Smrg				basic_os=
309da4b5163Smrg				;;
310da4b5163Smrg			delta88)
311da4b5163Smrg				basic_machine=m88k-motorola
312da4b5163Smrg				basic_os=sysv3
313da4b5163Smrg				;;
314da4b5163Smrg			dicos)
315da4b5163Smrg				basic_machine=i686-pc
316da4b5163Smrg				basic_os=dicos
317da4b5163Smrg				;;
318da4b5163Smrg			djgpp)
319da4b5163Smrg				basic_machine=i586-pc
320da4b5163Smrg				basic_os=msdosdjgpp
321da4b5163Smrg				;;
322da4b5163Smrg			ebmon29k)
323da4b5163Smrg				basic_machine=a29k-amd
324da4b5163Smrg				basic_os=ebmon
325da4b5163Smrg				;;
326da4b5163Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327da4b5163Smrg				basic_machine=m68k-ericsson
328da4b5163Smrg				basic_os=ose
329da4b5163Smrg				;;
330da4b5163Smrg			gmicro)
331da4b5163Smrg				basic_machine=tron-gmicro
332da4b5163Smrg				basic_os=sysv
333da4b5163Smrg				;;
334da4b5163Smrg			go32)
335da4b5163Smrg				basic_machine=i386-pc
336da4b5163Smrg				basic_os=go32
337da4b5163Smrg				;;
338da4b5163Smrg			h8300hms)
339da4b5163Smrg				basic_machine=h8300-hitachi
340da4b5163Smrg				basic_os=hms
341da4b5163Smrg				;;
342da4b5163Smrg			h8300xray)
343da4b5163Smrg				basic_machine=h8300-hitachi
344da4b5163Smrg				basic_os=xray
345da4b5163Smrg				;;
346da4b5163Smrg			h8500hms)
347da4b5163Smrg				basic_machine=h8500-hitachi
348da4b5163Smrg				basic_os=hms
349da4b5163Smrg				;;
350da4b5163Smrg			harris)
351da4b5163Smrg				basic_machine=m88k-harris
352da4b5163Smrg				basic_os=sysv3
353da4b5163Smrg				;;
354da4b5163Smrg			hp300 | hp300hpux)
355da4b5163Smrg				basic_machine=m68k-hp
356da4b5163Smrg				basic_os=hpux
357da4b5163Smrg				;;
358da4b5163Smrg			hp300bsd)
359da4b5163Smrg				basic_machine=m68k-hp
360da4b5163Smrg				basic_os=bsd
361da4b5163Smrg				;;
362da4b5163Smrg			hppaosf)
363da4b5163Smrg				basic_machine=hppa1.1-hp
364da4b5163Smrg				basic_os=osf
365da4b5163Smrg				;;
366da4b5163Smrg			hppro)
367da4b5163Smrg				basic_machine=hppa1.1-hp
368da4b5163Smrg				basic_os=proelf
369da4b5163Smrg				;;
370da4b5163Smrg			i386mach)
371da4b5163Smrg				basic_machine=i386-mach
372da4b5163Smrg				basic_os=mach
373da4b5163Smrg				;;
374da4b5163Smrg			isi68 | isi)
375da4b5163Smrg				basic_machine=m68k-isi
376da4b5163Smrg				basic_os=sysv
377da4b5163Smrg				;;
378da4b5163Smrg			m68knommu)
379da4b5163Smrg				basic_machine=m68k-unknown
380da4b5163Smrg				basic_os=linux
381da4b5163Smrg				;;
382da4b5163Smrg			magnum | m3230)
383da4b5163Smrg				basic_machine=mips-mips
384da4b5163Smrg				basic_os=sysv
385da4b5163Smrg				;;
386da4b5163Smrg			merlin)
387da4b5163Smrg				basic_machine=ns32k-utek
388da4b5163Smrg				basic_os=sysv
389da4b5163Smrg				;;
390da4b5163Smrg			mingw64)
391da4b5163Smrg				basic_machine=x86_64-pc
392da4b5163Smrg				basic_os=mingw64
393da4b5163Smrg				;;
394da4b5163Smrg			mingw32)
395da4b5163Smrg				basic_machine=i686-pc
396da4b5163Smrg				basic_os=mingw32
397da4b5163Smrg				;;
398da4b5163Smrg			mingw32ce)
399da4b5163Smrg				basic_machine=arm-unknown
400da4b5163Smrg				basic_os=mingw32ce
401da4b5163Smrg				;;
402da4b5163Smrg			monitor)
403da4b5163Smrg				basic_machine=m68k-rom68k
404da4b5163Smrg				basic_os=coff
405da4b5163Smrg				;;
406da4b5163Smrg			morphos)
407da4b5163Smrg				basic_machine=powerpc-unknown
408da4b5163Smrg				basic_os=morphos
409da4b5163Smrg				;;
410da4b5163Smrg			moxiebox)
411da4b5163Smrg				basic_machine=moxie-unknown
412da4b5163Smrg				basic_os=moxiebox
413da4b5163Smrg				;;
414da4b5163Smrg			msdos)
415da4b5163Smrg				basic_machine=i386-pc
416da4b5163Smrg				basic_os=msdos
417da4b5163Smrg				;;
418da4b5163Smrg			msys)
419da4b5163Smrg				basic_machine=i686-pc
420da4b5163Smrg				basic_os=msys
421da4b5163Smrg				;;
422da4b5163Smrg			mvs)
423da4b5163Smrg				basic_machine=i370-ibm
424da4b5163Smrg				basic_os=mvs
425da4b5163Smrg				;;
426da4b5163Smrg			nacl)
427da4b5163Smrg				basic_machine=le32-unknown
428da4b5163Smrg				basic_os=nacl
429da4b5163Smrg				;;
430da4b5163Smrg			ncr3000)
431da4b5163Smrg				basic_machine=i486-ncr
432da4b5163Smrg				basic_os=sysv4
433da4b5163Smrg				;;
434da4b5163Smrg			netbsd386)
435da4b5163Smrg				basic_machine=i386-pc
436da4b5163Smrg				basic_os=netbsd
437da4b5163Smrg				;;
438da4b5163Smrg			netwinder)
439da4b5163Smrg				basic_machine=armv4l-rebel
440da4b5163Smrg				basic_os=linux
441da4b5163Smrg				;;
442da4b5163Smrg			news | news700 | news800 | news900)
443da4b5163Smrg				basic_machine=m68k-sony
444da4b5163Smrg				basic_os=newsos
445da4b5163Smrg				;;
446da4b5163Smrg			news1000)
447da4b5163Smrg				basic_machine=m68030-sony
448da4b5163Smrg				basic_os=newsos
449da4b5163Smrg				;;
450da4b5163Smrg			necv70)
451da4b5163Smrg				basic_machine=v70-nec
452da4b5163Smrg				basic_os=sysv
453da4b5163Smrg				;;
454da4b5163Smrg			nh3000)
455da4b5163Smrg				basic_machine=m68k-harris
456da4b5163Smrg				basic_os=cxux
457da4b5163Smrg				;;
458da4b5163Smrg			nh[45]000)
459da4b5163Smrg				basic_machine=m88k-harris
460da4b5163Smrg				basic_os=cxux
461da4b5163Smrg				;;
462da4b5163Smrg			nindy960)
463da4b5163Smrg				basic_machine=i960-intel
464da4b5163Smrg				basic_os=nindy
465da4b5163Smrg				;;
466da4b5163Smrg			mon960)
467da4b5163Smrg				basic_machine=i960-intel
468da4b5163Smrg				basic_os=mon960
469da4b5163Smrg				;;
470da4b5163Smrg			nonstopux)
471da4b5163Smrg				basic_machine=mips-compaq
472da4b5163Smrg				basic_os=nonstopux
473da4b5163Smrg				;;
474da4b5163Smrg			os400)
475da4b5163Smrg				basic_machine=powerpc-ibm
476da4b5163Smrg				basic_os=os400
477da4b5163Smrg				;;
478da4b5163Smrg			OSE68000 | ose68000)
479da4b5163Smrg				basic_machine=m68000-ericsson
480da4b5163Smrg				basic_os=ose
481da4b5163Smrg				;;
482da4b5163Smrg			os68k)
483da4b5163Smrg				basic_machine=m68k-none
484da4b5163Smrg				basic_os=os68k
485da4b5163Smrg				;;
486da4b5163Smrg			paragon)
487da4b5163Smrg				basic_machine=i860-intel
488da4b5163Smrg				basic_os=osf
489da4b5163Smrg				;;
490da4b5163Smrg			parisc)
491da4b5163Smrg				basic_machine=hppa-unknown
492da4b5163Smrg				basic_os=linux
493da4b5163Smrg				;;
494da4b5163Smrg			psp)
495da4b5163Smrg				basic_machine=mipsallegrexel-sony
496da4b5163Smrg				basic_os=psp
497da4b5163Smrg				;;
498da4b5163Smrg			pw32)
499da4b5163Smrg				basic_machine=i586-unknown
500da4b5163Smrg				basic_os=pw32
501da4b5163Smrg				;;
502da4b5163Smrg			rdos | rdos64)
503da4b5163Smrg				basic_machine=x86_64-pc
504da4b5163Smrg				basic_os=rdos
505da4b5163Smrg				;;
506da4b5163Smrg			rdos32)
507da4b5163Smrg				basic_machine=i386-pc
508da4b5163Smrg				basic_os=rdos
509da4b5163Smrg				;;
510da4b5163Smrg			rom68k)
511da4b5163Smrg				basic_machine=m68k-rom68k
512da4b5163Smrg				basic_os=coff
513da4b5163Smrg				;;
514da4b5163Smrg			sa29200)
515da4b5163Smrg				basic_machine=a29k-amd
516da4b5163Smrg				basic_os=udi
517da4b5163Smrg				;;
518da4b5163Smrg			sei)
519da4b5163Smrg				basic_machine=mips-sei
520da4b5163Smrg				basic_os=seiux
521da4b5163Smrg				;;
522da4b5163Smrg			sequent)
523da4b5163Smrg				basic_machine=i386-sequent
524da4b5163Smrg				basic_os=
525da4b5163Smrg				;;
526da4b5163Smrg			sps7)
527da4b5163Smrg				basic_machine=m68k-bull
528da4b5163Smrg				basic_os=sysv2
529da4b5163Smrg				;;
530da4b5163Smrg			st2000)
531da4b5163Smrg				basic_machine=m68k-tandem
532da4b5163Smrg				basic_os=
533da4b5163Smrg				;;
534da4b5163Smrg			stratus)
535da4b5163Smrg				basic_machine=i860-stratus
536da4b5163Smrg				basic_os=sysv4
537da4b5163Smrg				;;
538da4b5163Smrg			sun2)
539da4b5163Smrg				basic_machine=m68000-sun
540da4b5163Smrg				basic_os=
541da4b5163Smrg				;;
542da4b5163Smrg			sun2os3)
543da4b5163Smrg				basic_machine=m68000-sun
544da4b5163Smrg				basic_os=sunos3
545da4b5163Smrg				;;
546da4b5163Smrg			sun2os4)
547da4b5163Smrg				basic_machine=m68000-sun
548da4b5163Smrg				basic_os=sunos4
549da4b5163Smrg				;;
550da4b5163Smrg			sun3)
551da4b5163Smrg				basic_machine=m68k-sun
552da4b5163Smrg				basic_os=
553da4b5163Smrg				;;
554da4b5163Smrg			sun3os3)
555da4b5163Smrg				basic_machine=m68k-sun
556da4b5163Smrg				basic_os=sunos3
557da4b5163Smrg				;;
558da4b5163Smrg			sun3os4)
559da4b5163Smrg				basic_machine=m68k-sun
560da4b5163Smrg				basic_os=sunos4
561da4b5163Smrg				;;
562da4b5163Smrg			sun4)
563da4b5163Smrg				basic_machine=sparc-sun
564da4b5163Smrg				basic_os=
565da4b5163Smrg				;;
566da4b5163Smrg			sun4os3)
567da4b5163Smrg				basic_machine=sparc-sun
568da4b5163Smrg				basic_os=sunos3
569da4b5163Smrg				;;
570da4b5163Smrg			sun4os4)
571da4b5163Smrg				basic_machine=sparc-sun
572da4b5163Smrg				basic_os=sunos4
573da4b5163Smrg				;;
574da4b5163Smrg			sun4sol2)
575da4b5163Smrg				basic_machine=sparc-sun
576da4b5163Smrg				basic_os=solaris2
577da4b5163Smrg				;;
578da4b5163Smrg			sun386 | sun386i | roadrunner)
579da4b5163Smrg				basic_machine=i386-sun
580da4b5163Smrg				basic_os=
581da4b5163Smrg				;;
582da4b5163Smrg			sv1)
583da4b5163Smrg				basic_machine=sv1-cray
584da4b5163Smrg				basic_os=unicos
585da4b5163Smrg				;;
586da4b5163Smrg			symmetry)
587da4b5163Smrg				basic_machine=i386-sequent
588da4b5163Smrg				basic_os=dynix
589da4b5163Smrg				;;
590da4b5163Smrg			t3e)
591da4b5163Smrg				basic_machine=alphaev5-cray
592da4b5163Smrg				basic_os=unicos
593da4b5163Smrg				;;
594da4b5163Smrg			t90)
595da4b5163Smrg				basic_machine=t90-cray
596da4b5163Smrg				basic_os=unicos
597da4b5163Smrg				;;
598da4b5163Smrg			toad1)
599da4b5163Smrg				basic_machine=pdp10-xkl
600da4b5163Smrg				basic_os=tops20
601da4b5163Smrg				;;
602da4b5163Smrg			tpf)
603da4b5163Smrg				basic_machine=s390x-ibm
604da4b5163Smrg				basic_os=tpf
605da4b5163Smrg				;;
606da4b5163Smrg			udi29k)
607da4b5163Smrg				basic_machine=a29k-amd
608da4b5163Smrg				basic_os=udi
609da4b5163Smrg				;;
610da4b5163Smrg			ultra3)
611da4b5163Smrg				basic_machine=a29k-nyu
612da4b5163Smrg				basic_os=sym1
613da4b5163Smrg				;;
614da4b5163Smrg			v810 | necv810)
615da4b5163Smrg				basic_machine=v810-nec
616da4b5163Smrg				basic_os=none
617da4b5163Smrg				;;
618da4b5163Smrg			vaxv)
619da4b5163Smrg				basic_machine=vax-dec
620da4b5163Smrg				basic_os=sysv
621da4b5163Smrg				;;
622da4b5163Smrg			vms)
623da4b5163Smrg				basic_machine=vax-dec
624da4b5163Smrg				basic_os=vms
625da4b5163Smrg				;;
626da4b5163Smrg			vsta)
627da4b5163Smrg				basic_machine=i386-pc
628da4b5163Smrg				basic_os=vsta
629da4b5163Smrg				;;
630da4b5163Smrg			vxworks960)
631da4b5163Smrg				basic_machine=i960-wrs
632da4b5163Smrg				basic_os=vxworks
633da4b5163Smrg				;;
634da4b5163Smrg			vxworks68)
635da4b5163Smrg				basic_machine=m68k-wrs
636da4b5163Smrg				basic_os=vxworks
637da4b5163Smrg				;;
638da4b5163Smrg			vxworks29k)
639da4b5163Smrg				basic_machine=a29k-wrs
640da4b5163Smrg				basic_os=vxworks
641da4b5163Smrg				;;
642da4b5163Smrg			xbox)
643da4b5163Smrg				basic_machine=i686-pc
644da4b5163Smrg				basic_os=mingw32
645da4b5163Smrg				;;
646da4b5163Smrg			ymp)
647da4b5163Smrg				basic_machine=ymp-cray
648da4b5163Smrg				basic_os=unicos
649da4b5163Smrg				;;
650da4b5163Smrg			*)
651da4b5163Smrg				basic_machine=$1
652da4b5163Smrg				basic_os=
653da4b5163Smrg				;;
654da4b5163Smrg		esac
655a850946eSmrg		;;
656a850946eSmrgesac
657a850946eSmrg
658da4b5163Smrg# Decode 1-component or ad-hoc basic machines
659a850946eSmrgcase $basic_machine in
660da4b5163Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661da4b5163Smrg	# some cases the only manufacturer, in others, it is the most popular.
662da4b5163Smrg	w89k)
663da4b5163Smrg		cpu=hppa1.1
664da4b5163Smrg		vendor=winbond
665c44a0236Smrg		;;
666da4b5163Smrg	op50n)
667da4b5163Smrg		cpu=hppa1.1
668da4b5163Smrg		vendor=oki
669a850946eSmrg		;;
670da4b5163Smrg	op60c)
671da4b5163Smrg		cpu=hppa1.1
672da4b5163Smrg		vendor=oki
673a850946eSmrg		;;
674da4b5163Smrg	ibm*)
675da4b5163Smrg		cpu=i370
676da4b5163Smrg		vendor=ibm
67770f7c90cSmrg		;;
678da4b5163Smrg	orion105)
679da4b5163Smrg		cpu=clipper
680da4b5163Smrg		vendor=highlevel
6819511053fSmrg		;;
682da4b5163Smrg	mac | mpw | mac-mpw)
683da4b5163Smrg		cpu=m68k
684da4b5163Smrg		vendor=apple
6859511053fSmrg		;;
686da4b5163Smrg	pmac | pmac-mpw)
687da4b5163Smrg		cpu=powerpc
688da4b5163Smrg		vendor=apple
6899511053fSmrg		;;
6909511053fSmrg
691a850946eSmrg	# Recognize the various machine names and aliases which stand
692a850946eSmrg	# for a CPU type and a company and sometimes even an OS.
693a850946eSmrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694da4b5163Smrg		cpu=m68000
695da4b5163Smrg		vendor=att
696a850946eSmrg		;;
697a850946eSmrg	3b*)
698da4b5163Smrg		cpu=we32k
699da4b5163Smrg		vendor=att
70070f7c90cSmrg		;;
7017dff02feSmrg	bluegene*)
702da4b5163Smrg		cpu=powerpc
703da4b5163Smrg		vendor=ibm
704da4b5163Smrg		basic_os=cnk
705a850946eSmrg		;;
706a850946eSmrg	decsystem10* | dec10*)
707da4b5163Smrg		cpu=pdp10
708da4b5163Smrg		vendor=dec
709da4b5163Smrg		basic_os=tops10
710a850946eSmrg		;;
711a850946eSmrg	decsystem20* | dec20*)
712da4b5163Smrg		cpu=pdp10
713da4b5163Smrg		vendor=dec
714da4b5163Smrg		basic_os=tops20
715a850946eSmrg		;;
716a850946eSmrg	delta | 3300 | motorola-3300 | motorola-delta \
717a850946eSmrg	      | 3300-motorola | delta-motorola)
718da4b5163Smrg		cpu=m68k
719da4b5163Smrg		vendor=motorola
720a850946eSmrg		;;
721c44a0236Smrg	dpx2*)
722da4b5163Smrg		cpu=m68k
723da4b5163Smrg		vendor=bull
724da4b5163Smrg		basic_os=sysv3
725a850946eSmrg		;;
726a850946eSmrg	encore | umax | mmax)
727da4b5163Smrg		cpu=ns32k
728da4b5163Smrg		vendor=encore
729a850946eSmrg		;;
730da4b5163Smrg	elxsi)
731da4b5163Smrg		cpu=elxsi
732da4b5163Smrg		vendor=elxsi
733da4b5163Smrg		basic_os=${basic_os:-bsd}
734a850946eSmrg		;;
735a850946eSmrg	fx2800)
736da4b5163Smrg		cpu=i860
737da4b5163Smrg		vendor=alliant
738a850946eSmrg		;;
739a850946eSmrg	genix)
740da4b5163Smrg		cpu=ns32k
741da4b5163Smrg		vendor=ns
742a850946eSmrg		;;
743a850946eSmrg	h3050r* | hiux*)
744da4b5163Smrg		cpu=hppa1.1
745da4b5163Smrg		vendor=hitachi
746da4b5163Smrg		basic_os=hiuxwe2
747a850946eSmrg		;;
748a850946eSmrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749da4b5163Smrg		cpu=hppa1.0
750da4b5163Smrg		vendor=hp
751a850946eSmrg		;;
752a850946eSmrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753da4b5163Smrg		cpu=m68000
754da4b5163Smrg		vendor=hp
755a850946eSmrg		;;
756a850946eSmrg	hp9k3[2-9][0-9])
757da4b5163Smrg		cpu=m68k
758da4b5163Smrg		vendor=hp
759a850946eSmrg		;;
760a850946eSmrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761da4b5163Smrg		cpu=hppa1.0
762da4b5163Smrg		vendor=hp
763a850946eSmrg		;;
764a850946eSmrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765da4b5163Smrg		cpu=hppa1.1
766da4b5163Smrg		vendor=hp
767a850946eSmrg		;;
768a850946eSmrg	hp9k78[0-9] | hp78[0-9])
769a850946eSmrg		# FIXME: really hppa2.0-hp
770da4b5163Smrg		cpu=hppa1.1
771da4b5163Smrg		vendor=hp
772a850946eSmrg		;;
773a850946eSmrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774a850946eSmrg		# FIXME: really hppa2.0-hp
775da4b5163Smrg		cpu=hppa1.1
776da4b5163Smrg		vendor=hp
777a850946eSmrg		;;
778a850946eSmrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779da4b5163Smrg		cpu=hppa1.1
780da4b5163Smrg		vendor=hp
781a850946eSmrg		;;
782a850946eSmrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783da4b5163Smrg		cpu=hppa1.0
784da4b5163Smrg		vendor=hp
785a850946eSmrg		;;
786a850946eSmrg	i*86v32)
787da4b5163Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788da4b5163Smrg		vendor=pc
789da4b5163Smrg		basic_os=sysv32
790a850946eSmrg		;;
791a850946eSmrg	i*86v4*)
792da4b5163Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793da4b5163Smrg		vendor=pc
794da4b5163Smrg		basic_os=sysv4
795a850946eSmrg		;;
796a850946eSmrg	i*86v)
797da4b5163Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798da4b5163Smrg		vendor=pc
799da4b5163Smrg		basic_os=sysv
800a850946eSmrg		;;
801a850946eSmrg	i*86sol2)
802da4b5163Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803da4b5163Smrg		vendor=pc
804da4b5163Smrg		basic_os=solaris2
805a850946eSmrg		;;
806da4b5163Smrg	j90 | j90-cray)
807da4b5163Smrg		cpu=j90
808da4b5163Smrg		vendor=cray
809da4b5163Smrg		basic_os=${basic_os:-unicos}
810a850946eSmrg		;;
811a850946eSmrg	iris | iris4d)
812da4b5163Smrg		cpu=mips
813da4b5163Smrg		vendor=sgi
814da4b5163Smrg		case $basic_os in
815da4b5163Smrg		    irix*)
816a850946eSmrg			;;
817a850946eSmrg		    *)
818da4b5163Smrg			basic_os=irix4
819a850946eSmrg			;;
820a850946eSmrg		esac
821a850946eSmrg		;;
822a850946eSmrg	miniframe)
823da4b5163Smrg		cpu=m68000
824da4b5163Smrg		vendor=convergent
825a850946eSmrg		;;
826da4b5163Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827da4b5163Smrg		cpu=m68k
828da4b5163Smrg		vendor=atari
829da4b5163Smrg		basic_os=mint
830a850946eSmrg		;;
831a850946eSmrg	news-3600 | risc-news)
832da4b5163Smrg		cpu=mips
833da4b5163Smrg		vendor=sony
834da4b5163Smrg		basic_os=newsos
835a850946eSmrg		;;
836c44a0236Smrg	next | m*-next)
837da4b5163Smrg		cpu=m68k
838da4b5163Smrg		vendor=next
839da4b5163Smrg		case $basic_os in
840da4b5163Smrg		    openstep*)
841da4b5163Smrg		        ;;
842da4b5163Smrg		    nextstep*)
843a850946eSmrg			;;
844da4b5163Smrg		    ns2*)
845da4b5163Smrg		      basic_os=nextstep2
846a850946eSmrg			;;
847a850946eSmrg		    *)
848da4b5163Smrg		      basic_os=nextstep3
849a850946eSmrg			;;
850a850946eSmrg		esac
851a850946eSmrg		;;
852a850946eSmrg	np1)
853da4b5163Smrg		cpu=np1
854da4b5163Smrg		vendor=gould
855c44a0236Smrg		;;
856a850946eSmrg	op50n-* | op60c-*)
857da4b5163Smrg		cpu=hppa1.1
858da4b5163Smrg		vendor=oki
859da4b5163Smrg		basic_os=proelf
860a850946eSmrg		;;
861a850946eSmrg	pa-hitachi)
862da4b5163Smrg		cpu=hppa1.1
863da4b5163Smrg		vendor=hitachi
864da4b5163Smrg		basic_os=hiuxwe2
86570f7c90cSmrg		;;
866a850946eSmrg	pbd)
867da4b5163Smrg		cpu=sparc
868da4b5163Smrg		vendor=tti
869a850946eSmrg		;;
870a850946eSmrg	pbb)
871da4b5163Smrg		cpu=m68k
872da4b5163Smrg		vendor=tti
873a850946eSmrg		;;
874da4b5163Smrg	pc532)
875da4b5163Smrg		cpu=ns32k
876da4b5163Smrg		vendor=pc532
877a850946eSmrg		;;
878a850946eSmrg	pn)
879da4b5163Smrg		cpu=pn
880da4b5163Smrg		vendor=gould
881a850946eSmrg		;;
882da4b5163Smrg	power)
883da4b5163Smrg		cpu=power
884da4b5163Smrg		vendor=ibm
885a850946eSmrg		;;
886da4b5163Smrg	ps2)
887da4b5163Smrg		cpu=i386
888da4b5163Smrg		vendor=ibm
889a850946eSmrg		;;
890da4b5163Smrg	rm[46]00)
891da4b5163Smrg		cpu=mips
892da4b5163Smrg		vendor=siemens
893a850946eSmrg		;;
894da4b5163Smrg	rtpc | rtpc-*)
895da4b5163Smrg		cpu=romp
896da4b5163Smrg		vendor=ibm
897a850946eSmrg		;;
898da4b5163Smrg	sde)
899da4b5163Smrg		cpu=mipsisa32
900da4b5163Smrg		vendor=sde
901da4b5163Smrg		basic_os=${basic_os:-elf}
902a850946eSmrg		;;
903da4b5163Smrg	simso-wrs)
904da4b5163Smrg		cpu=sparclite
905da4b5163Smrg		vendor=wrs
906da4b5163Smrg		basic_os=vxworks
907a850946eSmrg		;;
908da4b5163Smrg	tower | tower-32)
909da4b5163Smrg		cpu=m68k
910da4b5163Smrg		vendor=ncr
911a850946eSmrg		;;
912da4b5163Smrg	vpp*|vx|vx-*)
913da4b5163Smrg		cpu=f301
914da4b5163Smrg		vendor=fujitsu
9159511053fSmrg		;;
916da4b5163Smrg	w65)
917da4b5163Smrg		cpu=w65
918da4b5163Smrg		vendor=wdc
91970f7c90cSmrg		;;
920da4b5163Smrg	w89k-*)
921da4b5163Smrg		cpu=hppa1.1
922da4b5163Smrg		vendor=winbond
923da4b5163Smrg		basic_os=proelf
924a850946eSmrg		;;
925da4b5163Smrg	none)
926da4b5163Smrg		cpu=none
927da4b5163Smrg		vendor=none
928a850946eSmrg		;;
929da4b5163Smrg	leon|leon[3-9])
930da4b5163Smrg		cpu=sparc
931da4b5163Smrg		vendor=$basic_machine
932a850946eSmrg		;;
933da4b5163Smrg	leon-*|leon[3-9]-*)
934da4b5163Smrg		cpu=sparc
935da4b5163Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93670f7c90cSmrg		;;
937da4b5163Smrg
938da4b5163Smrg	*-*)
939da4b5163Smrg		# shellcheck disable=SC2162
940da4b5163Smrg		saved_IFS=$IFS
941da4b5163Smrg		IFS="-" read cpu vendor <<EOF
942da4b5163Smrg$basic_machine
943da4b5163SmrgEOF
944da4b5163Smrg		IFS=$saved_IFS
94570f7c90cSmrg		;;
946da4b5163Smrg	# We use `pc' rather than `unknown'
947da4b5163Smrg	# because (1) that's what they normally are, and
948da4b5163Smrg	# (2) the word "unknown" tends to confuse beginning users.
949da4b5163Smrg	i*86 | x86_64)
950da4b5163Smrg		cpu=$basic_machine
951da4b5163Smrg		vendor=pc
952a850946eSmrg		;;
953da4b5163Smrg	# These rules are duplicated from below for sake of the special case above;
954da4b5163Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955da4b5163Smrg	pc98)
956da4b5163Smrg		cpu=i386
957da4b5163Smrg		vendor=pc
958a850946eSmrg		;;
959da4b5163Smrg	x64 | amd64)
960da4b5163Smrg		cpu=x86_64
961da4b5163Smrg		vendor=pc
962a850946eSmrg		;;
963da4b5163Smrg	# Recognize the basic CPU types without company name.
964da4b5163Smrg	*)
965da4b5163Smrg		cpu=$basic_machine
966da4b5163Smrg		vendor=unknown
96770f7c90cSmrg		;;
968da4b5163Smrgesac
969da4b5163Smrg
970da4b5163Smrgunset -v basic_machine
971da4b5163Smrg
972da4b5163Smrg# Decode basic machines in the full and proper CPU-Company form.
973da4b5163Smrgcase $cpu-$vendor in
974da4b5163Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975da4b5163Smrg	# some cases the only manufacturer, in others, it is the most popular.
976da4b5163Smrg	craynv-unknown)
977da4b5163Smrg		vendor=cray
978da4b5163Smrg		basic_os=${basic_os:-unicosmp}
979a850946eSmrg		;;
980da4b5163Smrg	c90-unknown | c90-cray)
981da4b5163Smrg		vendor=cray
982da4b5163Smrg		basic_os=${Basic_os:-unicos}
983a850946eSmrg		;;
984da4b5163Smrg	fx80-unknown)
985da4b5163Smrg		vendor=alliant
98670f7c90cSmrg		;;
987da4b5163Smrg	romp-unknown)
988da4b5163Smrg		vendor=ibm
989a850946eSmrg		;;
990da4b5163Smrg	mmix-unknown)
991da4b5163Smrg		vendor=knuth
992a850946eSmrg		;;
993da4b5163Smrg	microblaze-unknown | microblazeel-unknown)
994da4b5163Smrg		vendor=xilinx
995a850946eSmrg		;;
996da4b5163Smrg	rs6000-unknown)
997da4b5163Smrg		vendor=ibm
998a850946eSmrg		;;
999da4b5163Smrg	vax-unknown)
1000da4b5163Smrg		vendor=dec
1001a850946eSmrg		;;
1002da4b5163Smrg	pdp11-unknown)
1003da4b5163Smrg		vendor=dec
10049511053fSmrg		;;
1005da4b5163Smrg	we32k-unknown)
1006da4b5163Smrg		vendor=att
1007a850946eSmrg		;;
1008da4b5163Smrg	cydra-unknown)
1009da4b5163Smrg		vendor=cydrome
1010a850946eSmrg		;;
1011da4b5163Smrg	i370-ibm*)
1012da4b5163Smrg		vendor=ibm
1013a850946eSmrg		;;
1014da4b5163Smrg	orion-unknown)
1015da4b5163Smrg		vendor=highlevel
1016a850946eSmrg		;;
1017da4b5163Smrg	xps-unknown | xps100-unknown)
1018da4b5163Smrg		cpu=xps100
1019da4b5163Smrg		vendor=honeywell
1020a850946eSmrg		;;
1021da4b5163Smrg
1022da4b5163Smrg	# Here we normalize CPU types with a missing or matching vendor
1023da4b5163Smrg	dpx20-unknown | dpx20-bull)
1024da4b5163Smrg		cpu=rs6000
1025da4b5163Smrg		vendor=bull
1026da4b5163Smrg		basic_os=${basic_os:-bosx}
1027a850946eSmrg		;;
1028da4b5163Smrg
1029da4b5163Smrg	# Here we normalize CPU types irrespective of the vendor
1030da4b5163Smrg	amd64-*)
1031da4b5163Smrg		cpu=x86_64
1032a850946eSmrg		;;
1033da4b5163Smrg	blackfin-*)
1034da4b5163Smrg		cpu=bfin
1035da4b5163Smrg		basic_os=linux
1036a850946eSmrg		;;
1037da4b5163Smrg	c54x-*)
1038da4b5163Smrg		cpu=tic54x
1039a850946eSmrg		;;
1040da4b5163Smrg	c55x-*)
1041da4b5163Smrg		cpu=tic55x
1042a850946eSmrg		;;
1043da4b5163Smrg	c6x-*)
1044da4b5163Smrg		cpu=tic6x
1045a850946eSmrg		;;
1046da4b5163Smrg	e500v[12]-*)
1047da4b5163Smrg		cpu=powerpc
1048da4b5163Smrg		basic_os=${basic_os}"spe"
1049a850946eSmrg		;;
1050da4b5163Smrg	mips3*-*)
1051da4b5163Smrg		cpu=mips64
1052a850946eSmrg		;;
1053da4b5163Smrg	ms1-*)
1054da4b5163Smrg		cpu=mt
1055a850946eSmrg		;;
1056da4b5163Smrg	m68knommu-*)
1057da4b5163Smrg		cpu=m68k
1058da4b5163Smrg		basic_os=linux
1059a850946eSmrg		;;
1060da4b5163Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1061da4b5163Smrg		cpu=s12z
106270f7c90cSmrg		;;
1063da4b5163Smrg	openrisc-*)
1064da4b5163Smrg		cpu=or32
1065a850946eSmrg		;;
1066da4b5163Smrg	parisc-*)
1067da4b5163Smrg		cpu=hppa
1068da4b5163Smrg		basic_os=linux
1069a850946eSmrg		;;
1070da4b5163Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1071da4b5163Smrg		cpu=i586
1072a850946eSmrg		;;
1073da4b5163Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1074da4b5163Smrg		cpu=i686
1075a850946eSmrg		;;
1076da4b5163Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1077da4b5163Smrg		cpu=i686
107870f7c90cSmrg		;;
1079da4b5163Smrg	pentium4-*)
1080da4b5163Smrg		cpu=i786
1081a850946eSmrg		;;
1082da4b5163Smrg	pc98-*)
1083da4b5163Smrg		cpu=i386
1084a850946eSmrg		;;
1085da4b5163Smrg	ppc-* | ppcbe-*)
1086da4b5163Smrg		cpu=powerpc
1087a850946eSmrg		;;
1088da4b5163Smrg	ppcle-* | powerpclittle-*)
1089da4b5163Smrg		cpu=powerpcle
1090a850946eSmrg		;;
1091da4b5163Smrg	ppc64-*)
1092da4b5163Smrg		cpu=powerpc64
1093a850946eSmrg		;;
1094da4b5163Smrg	ppc64le-* | powerpc64little-*)
1095da4b5163Smrg		cpu=powerpc64le
1096a850946eSmrg		;;
1097da4b5163Smrg	sb1-*)
1098da4b5163Smrg		cpu=mipsisa64sb1
1099a850946eSmrg		;;
1100da4b5163Smrg	sb1el-*)
1101da4b5163Smrg		cpu=mipsisa64sb1el
1102a850946eSmrg		;;
1103da4b5163Smrg	sh5e[lb]-*)
1104da4b5163Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1105a850946eSmrg		;;
1106da4b5163Smrg	spur-*)
1107da4b5163Smrg		cpu=spur
1108a850946eSmrg		;;
1109da4b5163Smrg	strongarm-* | thumb-*)
1110da4b5163Smrg		cpu=arm
1111a850946eSmrg		;;
1112da4b5163Smrg	tx39-*)
1113da4b5163Smrg		cpu=mipstx39
1114c44a0236Smrg		;;
1115da4b5163Smrg	tx39el-*)
1116da4b5163Smrg		cpu=mipstx39el
111770f7c90cSmrg		;;
1118da4b5163Smrg	x64-*)
1119da4b5163Smrg		cpu=x86_64
1120a850946eSmrg		;;
11219511053fSmrg	xscale-* | xscalee[bl]-*)
1122da4b5163Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1123a850946eSmrg		;;
1124da4b5163Smrg	arm64-*)
1125da4b5163Smrg		cpu=aarch64
1126a850946eSmrg		;;
1127a850946eSmrg
1128da4b5163Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1129da4b5163Smrg	# company names they are paired with.
1130da4b5163Smrg	cr16-*)
1131da4b5163Smrg		basic_os=${basic_os:-elf}
113270f7c90cSmrg		;;
1133da4b5163Smrg	crisv32-* | etraxfs*-*)
1134da4b5163Smrg		cpu=crisv32
1135da4b5163Smrg		vendor=axis
1136a850946eSmrg		;;
1137da4b5163Smrg	cris-* | etrax*-*)
1138da4b5163Smrg		cpu=cris
1139da4b5163Smrg		vendor=axis
1140a850946eSmrg		;;
1141da4b5163Smrg	crx-*)
1142da4b5163Smrg		basic_os=${basic_os:-elf}
1143a850946eSmrg		;;
1144da4b5163Smrg	neo-tandem)
1145da4b5163Smrg		cpu=neo
1146da4b5163Smrg		vendor=tandem
1147a850946eSmrg		;;
1148da4b5163Smrg	nse-tandem)
1149da4b5163Smrg		cpu=nse
1150da4b5163Smrg		vendor=tandem
1151a850946eSmrg		;;
1152da4b5163Smrg	nsr-tandem)
1153da4b5163Smrg		cpu=nsr
1154da4b5163Smrg		vendor=tandem
1155a850946eSmrg		;;
1156da4b5163Smrg	nsv-tandem)
1157da4b5163Smrg		cpu=nsv
1158da4b5163Smrg		vendor=tandem
1159a850946eSmrg		;;
1160da4b5163Smrg	nsx-tandem)
1161da4b5163Smrg		cpu=nsx
1162da4b5163Smrg		vendor=tandem
1163a850946eSmrg		;;
1164da4b5163Smrg	mipsallegrexel-sony)
1165da4b5163Smrg		cpu=mipsallegrexel
1166da4b5163Smrg		vendor=sony
1167a850946eSmrg		;;
1168da4b5163Smrg	tile*-*)
1169da4b5163Smrg		basic_os=${basic_os:-linux-gnu}
1170a850946eSmrg		;;
1171da4b5163Smrg
1172a850946eSmrg	*)
1173da4b5163Smrg		# Recognize the canonical CPU types that are allowed with any
1174da4b5163Smrg		# company name.
1175da4b5163Smrg		case $cpu in
1176da4b5163Smrg			1750a | 580 \
1177da4b5163Smrg			| a29k \
1178da4b5163Smrg			| aarch64 | aarch64_be \
1179da4b5163Smrg			| abacus \
1180da4b5163Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1181da4b5163Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1182da4b5163Smrg			| alphapca5[67] | alpha64pca5[67] \
1183da4b5163Smrg			| am33_2.0 \
1184da4b5163Smrg			| amdgcn \
1185da4b5163Smrg			| arc | arceb | arc32 | arc64 \
1186da4b5163Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1187da4b5163Smrg			| avr | avr32 \
1188da4b5163Smrg			| asmjs \
1189da4b5163Smrg			| ba \
1190da4b5163Smrg			| be32 | be64 \
1191da4b5163Smrg			| bfin | bpf | bs2000 \
1192da4b5163Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1193da4b5163Smrg			| c8051 | clipper | craynv | csky | cydra \
1194da4b5163Smrg			| d10v | d30v | dlx | dsp16xx \
1195da4b5163Smrg			| e2k | elxsi | epiphany \
1196da4b5163Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1197da4b5163Smrg			| h8300 | h8500 \
1198da4b5163Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1199da4b5163Smrg			| hexagon \
1200da4b5163Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1201da4b5163Smrg			| ip2k | iq2000 \
1202da4b5163Smrg			| k1om \
1203da4b5163Smrg			| le32 | le64 \
1204da4b5163Smrg			| lm32 \
1205da4b5163Smrg			| loongarch32 | loongarch64 | loongarchx32 \
1206da4b5163Smrg			| m32c | m32r | m32rle \
1207da4b5163Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1208da4b5163Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1209da4b5163Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1210da4b5163Smrg			| microblaze | microblazeel \
1211da4b5163Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1212da4b5163Smrg			| mips16 \
1213da4b5163Smrg			| mips64 | mips64eb | mips64el \
1214da4b5163Smrg			| mips64octeon | mips64octeonel \
1215da4b5163Smrg			| mips64orion | mips64orionel \
1216da4b5163Smrg			| mips64r5900 | mips64r5900el \
1217da4b5163Smrg			| mips64vr | mips64vrel \
1218da4b5163Smrg			| mips64vr4100 | mips64vr4100el \
1219da4b5163Smrg			| mips64vr4300 | mips64vr4300el \
1220da4b5163Smrg			| mips64vr5000 | mips64vr5000el \
1221da4b5163Smrg			| mips64vr5900 | mips64vr5900el \
1222da4b5163Smrg			| mipsisa32 | mipsisa32el \
1223da4b5163Smrg			| mipsisa32r2 | mipsisa32r2el \
1224da4b5163Smrg			| mipsisa32r3 | mipsisa32r3el \
1225da4b5163Smrg			| mipsisa32r5 | mipsisa32r5el \
1226da4b5163Smrg			| mipsisa32r6 | mipsisa32r6el \
1227da4b5163Smrg			| mipsisa64 | mipsisa64el \
1228da4b5163Smrg			| mipsisa64r2 | mipsisa64r2el \
1229da4b5163Smrg			| mipsisa64r3 | mipsisa64r3el \
1230da4b5163Smrg			| mipsisa64r5 | mipsisa64r5el \
1231da4b5163Smrg			| mipsisa64r6 | mipsisa64r6el \
1232da4b5163Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1233da4b5163Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1234da4b5163Smrg			| mipsr5900 | mipsr5900el \
1235da4b5163Smrg			| mipstx39 | mipstx39el \
1236da4b5163Smrg			| mmix \
1237da4b5163Smrg			| mn10200 | mn10300 \
1238da4b5163Smrg			| moxie \
1239da4b5163Smrg			| mt \
1240da4b5163Smrg			| msp430 \
1241da4b5163Smrg			| nds32 | nds32le | nds32be \
1242da4b5163Smrg			| nfp \
1243da4b5163Smrg			| nios | nios2 | nios2eb | nios2el \
1244da4b5163Smrg			| none | np1 | ns16k | ns32k | nvptx \
1245da4b5163Smrg			| open8 \
1246da4b5163Smrg			| or1k* \
1247da4b5163Smrg			| or32 \
1248da4b5163Smrg			| orion \
1249da4b5163Smrg			| picochip \
1250da4b5163Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1251da4b5163Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1252da4b5163Smrg			| pru \
1253da4b5163Smrg			| pyramid \
1254da4b5163Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1255da4b5163Smrg			| rl78 | romp | rs6000 | rx \
1256da4b5163Smrg			| s390 | s390x \
1257da4b5163Smrg			| score \
1258da4b5163Smrg			| sh | shl \
1259da4b5163Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1260da4b5163Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1261da4b5163Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1262da4b5163Smrg			| sparclite \
1263da4b5163Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1264da4b5163Smrg			| spu \
1265da4b5163Smrg			| tahoe \
1266da4b5163Smrg			| thumbv7* \
1267da4b5163Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1268da4b5163Smrg			| tron \
1269da4b5163Smrg			| ubicom32 \
1270da4b5163Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1271da4b5163Smrg			| vax \
1272da4b5163Smrg			| visium \
1273da4b5163Smrg			| w65 \
1274da4b5163Smrg			| wasm32 | wasm64 \
1275da4b5163Smrg			| we32k \
1276da4b5163Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1277da4b5163Smrg			| xstormy16 | xtensa* \
1278da4b5163Smrg			| ymp \
1279da4b5163Smrg			| z8k | z80)
1280da4b5163Smrg				;;
1281da4b5163Smrg
1282da4b5163Smrg			*)
1283da4b5163Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1284da4b5163Smrg				exit 1
1285da4b5163Smrg				;;
1286da4b5163Smrg		esac
1287a850946eSmrg		;;
1288a850946eSmrgesac
1289a850946eSmrg
1290a850946eSmrg# Here we canonicalize certain aliases for manufacturers.
1291da4b5163Smrgcase $vendor in
1292da4b5163Smrg	digital*)
1293da4b5163Smrg		vendor=dec
1294a850946eSmrg		;;
1295da4b5163Smrg	commodore*)
1296da4b5163Smrg		vendor=cbm
1297a850946eSmrg		;;
1298a850946eSmrg	*)
1299a850946eSmrg		;;
1300a850946eSmrgesac
1301a850946eSmrg
1302a850946eSmrg# Decode manufacturer-specific aliases for certain operating systems.
1303a850946eSmrg
1304da4b5163Smrgif test x$basic_os != x
1305a850946eSmrgthen
1306da4b5163Smrg
1307da4b5163Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1308da4b5163Smrg# set os.
1309da4b5163Smrgcase $basic_os in
1310da4b5163Smrg	gnu/linux*)
1311da4b5163Smrg		kernel=linux
1312da4b5163Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1313da4b5163Smrg		;;
1314da4b5163Smrg	os2-emx)
1315da4b5163Smrg		kernel=os2
1316da4b5163Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1317da4b5163Smrg		;;
1318da4b5163Smrg	nto-qnx*)
1319da4b5163Smrg		kernel=nto
1320da4b5163Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1321da4b5163Smrg		;;
1322da4b5163Smrg	*-*)
1323da4b5163Smrg		# shellcheck disable=SC2162
1324da4b5163Smrg		saved_IFS=$IFS
1325da4b5163Smrg		IFS="-" read kernel os <<EOF
1326da4b5163Smrg$basic_os
1327da4b5163SmrgEOF
1328da4b5163Smrg		IFS=$saved_IFS
1329da4b5163Smrg		;;
1330da4b5163Smrg	# Default OS when just kernel was specified
1331da4b5163Smrg	nto*)
1332da4b5163Smrg		kernel=nto
1333da4b5163Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1334da4b5163Smrg		;;
1335da4b5163Smrg	linux*)
1336da4b5163Smrg		kernel=linux
1337da4b5163Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1338da4b5163Smrg		;;
1339da4b5163Smrg	*)
1340da4b5163Smrg		kernel=
1341da4b5163Smrg		os=$basic_os
1342da4b5163Smrg		;;
1343da4b5163Smrgesac
1344da4b5163Smrg
1345da4b5163Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1346da4b5163Smrg# etc.)
1347a850946eSmrgcase $os in
1348c44a0236Smrg	# First match some system type aliases that might get confused
1349c44a0236Smrg	# with valid system types.
1350da4b5163Smrg	# solaris* is a basic system type, with this one exception.
1351da4b5163Smrg	auroraux)
1352da4b5163Smrg		os=auroraux
13537dff02feSmrg		;;
1354da4b5163Smrg	bluegene*)
1355da4b5163Smrg		os=cnk
1356a850946eSmrg		;;
1357da4b5163Smrg	solaris1 | solaris1.*)
1358da4b5163Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1359a850946eSmrg		;;
1360da4b5163Smrg	solaris)
1361da4b5163Smrg		os=solaris2
1362a850946eSmrg		;;
1363da4b5163Smrg	unixware*)
1364da4b5163Smrg		os=sysv4.2uw
1365a850946eSmrg		;;
1366c44a0236Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1367da4b5163Smrg	es1800*)
1368da4b5163Smrg		os=ose
1369c44a0236Smrg		;;
1370da4b5163Smrg	# Some version numbers need modification
1371da4b5163Smrg	chorusos*)
1372da4b5163Smrg		os=chorusos
1373a850946eSmrg		;;
1374da4b5163Smrg	isc)
1375da4b5163Smrg		os=isc2.2
1376a850946eSmrg		;;
1377da4b5163Smrg	sco6)
1378da4b5163Smrg		os=sco5v6
1379a850946eSmrg		;;
1380da4b5163Smrg	sco5)
1381da4b5163Smrg		os=sco3.2v5
1382a850946eSmrg		;;
1383da4b5163Smrg	sco4)
1384da4b5163Smrg		os=sco3.2v4
1385a850946eSmrg		;;
1386da4b5163Smrg	sco3.2.[4-9]*)
1387da4b5163Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
138870f7c90cSmrg		;;
1389da4b5163Smrg	sco*v* | scout)
1390da4b5163Smrg		# Don't match below
1391a850946eSmrg		;;
1392da4b5163Smrg	sco*)
1393da4b5163Smrg		os=sco3.2v2
1394a850946eSmrg		;;
1395da4b5163Smrg	psos*)
1396da4b5163Smrg		os=psos
1397a850946eSmrg		;;
1398da4b5163Smrg	qnx*)
1399da4b5163Smrg		os=qnx
1400a850946eSmrg		;;
1401da4b5163Smrg	hiux*)
1402da4b5163Smrg		os=hiuxwe2
140370f7c90cSmrg		;;
1404da4b5163Smrg	lynx*178)
1405da4b5163Smrg		os=lynxos178
1406a850946eSmrg		;;
1407da4b5163Smrg	lynx*5)
1408da4b5163Smrg		os=lynxos5
1409a850946eSmrg		;;
1410da4b5163Smrg	lynxos*)
1411da4b5163Smrg		# don't get caught up in next wildcard
1412a850946eSmrg		;;
1413da4b5163Smrg	lynx*)
1414da4b5163Smrg		os=lynxos
1415a850946eSmrg		;;
1416da4b5163Smrg	mac[0-9]*)
1417da4b5163Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
1418a850946eSmrg		;;
1419da4b5163Smrg	opened*)
1420da4b5163Smrg		os=openedition
142170f7c90cSmrg		;;
1422da4b5163Smrg	os400*)
1423da4b5163Smrg		os=os400
1424a850946eSmrg		;;
1425da4b5163Smrg	sunos5*)
1426da4b5163Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1427a850946eSmrg		;;
1428da4b5163Smrg	sunos6*)
1429da4b5163Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1430a850946eSmrg		;;
1431da4b5163Smrg	wince*)
1432da4b5163Smrg		os=wince
1433a850946eSmrg		;;
1434da4b5163Smrg	utek*)
1435da4b5163Smrg		os=bsd
1436a850946eSmrg		;;
1437da4b5163Smrg	dynix*)
1438da4b5163Smrg		os=bsd
1439a850946eSmrg		;;
1440da4b5163Smrg	acis*)
1441da4b5163Smrg		os=aos
1442a850946eSmrg		;;
1443da4b5163Smrg	atheos*)
1444da4b5163Smrg		os=atheos
144570f7c90cSmrg		;;
1446da4b5163Smrg	syllable*)
1447da4b5163Smrg		os=syllable
1448da4b5163Smrg		;;
1449da4b5163Smrg	386bsd)
1450da4b5163Smrg		os=bsd
1451da4b5163Smrg		;;
1452da4b5163Smrg	ctix* | uts*)
1453da4b5163Smrg		os=sysv
1454da4b5163Smrg		;;
1455da4b5163Smrg	nova*)
1456da4b5163Smrg		os=rtmk-nova
1457da4b5163Smrg		;;
1458da4b5163Smrg	ns2)
1459da4b5163Smrg		os=nextstep2
1460da4b5163Smrg		;;
1461da4b5163Smrg	# Preserve the version number of sinix5.
1462da4b5163Smrg	sinix5.*)
1463da4b5163Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1464a850946eSmrg		;;
1465da4b5163Smrg	sinix*)
1466da4b5163Smrg		os=sysv4
1467a850946eSmrg		;;
1468da4b5163Smrg	tpf*)
1469da4b5163Smrg		os=tpf
1470a850946eSmrg		;;
1471da4b5163Smrg	triton*)
1472da4b5163Smrg		os=sysv3
1473a850946eSmrg		;;
1474da4b5163Smrg	oss*)
1475da4b5163Smrg		os=sysv3
1476a850946eSmrg		;;
1477da4b5163Smrg	svr4*)
1478da4b5163Smrg		os=sysv4
1479a850946eSmrg		;;
1480da4b5163Smrg	svr3)
1481da4b5163Smrg		os=sysv3
1482a850946eSmrg		;;
1483da4b5163Smrg	sysvr4)
1484da4b5163Smrg		os=sysv4
1485a850946eSmrg		;;
1486da4b5163Smrg	ose*)
1487da4b5163Smrg		os=ose
148870f7c90cSmrg		;;
1489da4b5163Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1490da4b5163Smrg		os=mint
149170f7c90cSmrg		;;
1492da4b5163Smrg	dicos*)
1493da4b5163Smrg		os=dicos
1494da4b5163Smrg		;;
1495da4b5163Smrg	pikeos*)
1496c44a0236Smrg		# Until real need of OS specific support for
1497c44a0236Smrg		# particular features comes up, bare metal
1498c44a0236Smrg		# configurations are quite functional.
1499da4b5163Smrg		case $cpu in
1500c44a0236Smrg		    arm*)
1501da4b5163Smrg			os=eabi
1502c44a0236Smrg			;;
1503c44a0236Smrg		    *)
1504da4b5163Smrg			os=elf
1505c44a0236Smrg			;;
1506c44a0236Smrg		esac
1507c44a0236Smrg		;;
1508a850946eSmrg	*)
1509da4b5163Smrg		# No normalization, but not necessarily accepted, that comes below.
1510a850946eSmrg		;;
1511a850946eSmrgesac
1512da4b5163Smrg
1513a850946eSmrgelse
1514a850946eSmrg
1515a850946eSmrg# Here we handle the default operating systems that come with various machines.
1516a850946eSmrg# The value should be what the vendor currently ships out the door with their
1517a850946eSmrg# machine or put another way, the most popular os provided with the machine.
1518a850946eSmrg
1519a850946eSmrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
1520a850946eSmrg# "-sun"), then you have to tell the case statement up towards the top
1521a850946eSmrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
1522a850946eSmrg# will signal an error saying that MANUFACTURER isn't an operating
1523a850946eSmrg# system, and we'll never get to this point.
1524a850946eSmrg
1525da4b5163Smrgkernel=
1526da4b5163Smrgcase $cpu-$vendor in
15279511053fSmrg	score-*)
1528da4b5163Smrg		os=elf
152970f7c90cSmrg		;;
15309511053fSmrg	spu-*)
1531da4b5163Smrg		os=elf
153270f7c90cSmrg		;;
1533a850946eSmrg	*-acorn)
1534da4b5163Smrg		os=riscix1.2
1535a850946eSmrg		;;
1536a850946eSmrg	arm*-rebel)
1537da4b5163Smrg		kernel=linux
1538da4b5163Smrg		os=gnu
1539a850946eSmrg		;;
1540a850946eSmrg	arm*-semi)
1541da4b5163Smrg		os=aout
1542a850946eSmrg		;;
15439511053fSmrg	c4x-* | tic4x-*)
1544da4b5163Smrg		os=coff
15459511053fSmrg		;;
1546c44a0236Smrg	c8051-*)
1547da4b5163Smrg		os=elf
1548da4b5163Smrg		;;
1549da4b5163Smrg	clipper-intergraph)
1550da4b5163Smrg		os=clix
1551c44a0236Smrg		;;
15529511053fSmrg	hexagon-*)
1553da4b5163Smrg		os=elf
1554a850946eSmrg		;;
155569a1fe56Smrg	tic54x-*)
1556da4b5163Smrg		os=coff
155769a1fe56Smrg		;;
155869a1fe56Smrg	tic55x-*)
1559da4b5163Smrg		os=coff
156069a1fe56Smrg		;;
156169a1fe56Smrg	tic6x-*)
1562da4b5163Smrg		os=coff
156369a1fe56Smrg		;;
1564a850946eSmrg	# This must come before the *-dec entry.
1565a850946eSmrg	pdp10-*)
1566da4b5163Smrg		os=tops20
1567a850946eSmrg		;;
1568a850946eSmrg	pdp11-*)
1569da4b5163Smrg		os=none
1570a850946eSmrg		;;
1571a850946eSmrg	*-dec | vax-*)
1572da4b5163Smrg		os=ultrix4.2
1573a850946eSmrg		;;
1574a850946eSmrg	m68*-apollo)
1575da4b5163Smrg		os=domain
1576a850946eSmrg		;;
1577a850946eSmrg	i386-sun)
1578da4b5163Smrg		os=sunos4.0.2
1579a850946eSmrg		;;
1580a850946eSmrg	m68000-sun)
1581da4b5163Smrg		os=sunos3
1582a850946eSmrg		;;
1583a850946eSmrg	m68*-cisco)
1584da4b5163Smrg		os=aout
1585a850946eSmrg		;;
15869511053fSmrg	mep-*)
1587da4b5163Smrg		os=elf
158870f7c90cSmrg		;;
1589a850946eSmrg	mips*-cisco)
1590da4b5163Smrg		os=elf
1591a850946eSmrg		;;
1592a850946eSmrg	mips*-*)
1593da4b5163Smrg		os=elf
1594a850946eSmrg		;;
1595a850946eSmrg	or32-*)
1596da4b5163Smrg		os=coff
1597a850946eSmrg		;;
1598a850946eSmrg	*-tti)	# must be before sparc entry or we get the wrong os.
1599da4b5163Smrg		os=sysv3
1600a850946eSmrg		;;
1601a850946eSmrg	sparc-* | *-sun)
1602da4b5163Smrg		os=sunos4.1.1
1603a850946eSmrg		;;
1604c44a0236Smrg	pru-*)
1605da4b5163Smrg		os=elf
1606c44a0236Smrg		;;
1607a850946eSmrg	*-be)
1608da4b5163Smrg		os=beos
1609a850946eSmrg		;;
1610a850946eSmrg	*-ibm)
1611da4b5163Smrg		os=aix
1612a850946eSmrg		;;
16139511053fSmrg	*-knuth)
1614da4b5163Smrg		os=mmixware
161570f7c90cSmrg		;;
1616a850946eSmrg	*-wec)
1617da4b5163Smrg		os=proelf
1618a850946eSmrg		;;
1619a850946eSmrg	*-winbond)
1620da4b5163Smrg		os=proelf
1621a850946eSmrg		;;
1622a850946eSmrg	*-oki)
1623da4b5163Smrg		os=proelf
1624a850946eSmrg		;;
1625a850946eSmrg	*-hp)
1626da4b5163Smrg		os=hpux
1627a850946eSmrg		;;
1628a850946eSmrg	*-hitachi)
1629da4b5163Smrg		os=hiux
1630a850946eSmrg		;;
1631a850946eSmrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1632da4b5163Smrg		os=sysv
1633a850946eSmrg		;;
1634a850946eSmrg	*-cbm)
1635da4b5163Smrg		os=amigaos
1636a850946eSmrg		;;
1637a850946eSmrg	*-dg)
1638da4b5163Smrg		os=dgux
1639a850946eSmrg		;;
1640a850946eSmrg	*-dolphin)
1641da4b5163Smrg		os=sysv3
1642a850946eSmrg		;;
1643a850946eSmrg	m68k-ccur)
1644da4b5163Smrg		os=rtu
1645a850946eSmrg		;;
1646a850946eSmrg	m88k-omron*)
1647da4b5163Smrg		os=luna
1648a850946eSmrg		;;
1649c44a0236Smrg	*-next)
1650da4b5163Smrg		os=nextstep
1651a850946eSmrg		;;
1652a850946eSmrg	*-sequent)
1653da4b5163Smrg		os=ptx
1654a850946eSmrg		;;
1655a850946eSmrg	*-crds)
1656da4b5163Smrg		os=unos
1657a850946eSmrg		;;
1658a850946eSmrg	*-ns)
1659da4b5163Smrg		os=genix
1660a850946eSmrg		;;
1661a850946eSmrg	i370-*)
1662da4b5163Smrg		os=mvs
1663a850946eSmrg		;;
1664a850946eSmrg	*-gould)
1665da4b5163Smrg		os=sysv
1666a850946eSmrg		;;
1667a850946eSmrg	*-highlevel)
1668da4b5163Smrg		os=bsd
1669a850946eSmrg		;;
1670a850946eSmrg	*-encore)
1671da4b5163Smrg		os=bsd
1672a850946eSmrg		;;
1673a850946eSmrg	*-sgi)
1674da4b5163Smrg		os=irix
1675a850946eSmrg		;;
1676a850946eSmrg	*-siemens)
1677da4b5163Smrg		os=sysv4
1678a850946eSmrg		;;
1679a850946eSmrg	*-masscomp)
1680da4b5163Smrg		os=rtu
1681a850946eSmrg		;;
1682a850946eSmrg	f30[01]-fujitsu | f700-fujitsu)
1683da4b5163Smrg		os=uxpv
1684a850946eSmrg		;;
1685a850946eSmrg	*-rom68k)
1686da4b5163Smrg		os=coff
1687a850946eSmrg		;;
1688a850946eSmrg	*-*bug)
1689da4b5163Smrg		os=coff
1690a850946eSmrg		;;
1691a850946eSmrg	*-apple)
1692da4b5163Smrg		os=macos
1693a850946eSmrg		;;
1694a850946eSmrg	*-atari*)
1695da4b5163Smrg		os=mint
1696da4b5163Smrg		;;
1697da4b5163Smrg	*-wrs)
1698da4b5163Smrg		os=vxworks
1699a850946eSmrg		;;
1700a850946eSmrg	*)
1701da4b5163Smrg		os=none
1702a850946eSmrg		;;
1703a850946eSmrgesac
1704da4b5163Smrg
1705a850946eSmrgfi
1706a850946eSmrg
1707da4b5163Smrg# Now, validate our (potentially fixed-up) OS.
1708da4b5163Smrgcase $os in
1709da4b5163Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1710da4b5163Smrg	musl* | newlib* | relibc* | uclibc*)
1711da4b5163Smrg		;;
1712da4b5163Smrg	# Likewise for "kernel-abi"
1713da4b5163Smrg	eabi* | gnueabi*)
1714da4b5163Smrg		;;
1715da4b5163Smrg	# VxWorks passes extra cpu info in the 4th filed.
1716da4b5163Smrg	simlinux | simwindows | spe)
1717da4b5163Smrg		;;
1718da4b5163Smrg	# Now accept the basic system types.
1719da4b5163Smrg	# The portable systems comes first.
1720da4b5163Smrg	# Each alternative MUST end in a * to match a version number.
1721da4b5163Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1722da4b5163Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1723da4b5163Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1724da4b5163Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1725da4b5163Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1726da4b5163Smrg	     | os9* | macos* | osx* | ios* \
1727da4b5163Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1728da4b5163Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1729da4b5163Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1730da4b5163Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1731da4b5163Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1732da4b5163Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1733da4b5163Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1734da4b5163Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1735da4b5163Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1736da4b5163Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1737da4b5163Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1738da4b5163Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1739da4b5163Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1740da4b5163Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1741da4b5163Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1742da4b5163Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1743da4b5163Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1744da4b5163Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1745da4b5163Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1746da4b5163Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1747da4b5163Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1748da4b5163Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1749da4b5163Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1750da4b5163Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1751da4b5163Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
1752da4b5163Smrg		;;
1753da4b5163Smrg	# This one is extra strict with allowed versions
1754da4b5163Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1755da4b5163Smrg		# Don't forget version if it is 3.2v4 or newer.
1756da4b5163Smrg		;;
1757da4b5163Smrg	none)
1758da4b5163Smrg		;;
1759da4b5163Smrg	*)
1760da4b5163Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1761da4b5163Smrg		exit 1
1762da4b5163Smrg		;;
1763da4b5163Smrgesac
1764da4b5163Smrg
1765da4b5163Smrg# As a final step for OS-related things, validate the OS-kernel combination
1766da4b5163Smrg# (given a valid OS), if there is a kernel.
1767da4b5163Smrgcase $kernel-$os in
1768da4b5163Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1769da4b5163Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
1770da4b5163Smrg		;;
1771da4b5163Smrg	uclinux-uclibc* )
1772da4b5163Smrg		;;
1773da4b5163Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
1774da4b5163Smrg		# These are just libc implementations, not actual OSes, and thus
1775da4b5163Smrg		# require a kernel.
1776da4b5163Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1777da4b5163Smrg		exit 1
1778da4b5163Smrg		;;
1779da4b5163Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1780da4b5163Smrg		;;
1781da4b5163Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1782da4b5163Smrg		;;
1783da4b5163Smrg	nto-qnx*)
1784da4b5163Smrg		;;
1785da4b5163Smrg	os2-emx)
1786da4b5163Smrg		;;
1787da4b5163Smrg	*-eabi* | *-gnueabi*)
1788da4b5163Smrg		;;
1789da4b5163Smrg	-*)
1790da4b5163Smrg		# Blank kernel with real OS is always fine.
1791da4b5163Smrg		;;
1792da4b5163Smrg	*-*)
1793da4b5163Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1794da4b5163Smrg		exit 1
1795da4b5163Smrg		;;
1796da4b5163Smrgesac
1797da4b5163Smrg
1798a850946eSmrg# Here we handle the case where we know the os, and the CPU type, but not the
1799a850946eSmrg# manufacturer.  We pick the logical manufacturer.
1800da4b5163Smrgcase $vendor in
1801da4b5163Smrg	unknown)
1802da4b5163Smrg		case $cpu-$os in
1803da4b5163Smrg			*-riscix*)
1804a850946eSmrg				vendor=acorn
1805a850946eSmrg				;;
1806da4b5163Smrg			*-sunos*)
1807a850946eSmrg				vendor=sun
1808a850946eSmrg				;;
1809da4b5163Smrg			*-cnk* | *-aix*)
1810a850946eSmrg				vendor=ibm
1811a850946eSmrg				;;
1812da4b5163Smrg			*-beos*)
1813a850946eSmrg				vendor=be
1814a850946eSmrg				;;
1815da4b5163Smrg			*-hpux*)
1816a850946eSmrg				vendor=hp
1817a850946eSmrg				;;
1818da4b5163Smrg			*-mpeix*)
1819a850946eSmrg				vendor=hp
1820a850946eSmrg				;;
1821da4b5163Smrg			*-hiux*)
1822a850946eSmrg				vendor=hitachi
1823a850946eSmrg				;;
1824da4b5163Smrg			*-unos*)
1825a850946eSmrg				vendor=crds
1826a850946eSmrg				;;
1827da4b5163Smrg			*-dgux*)
1828a850946eSmrg				vendor=dg
1829a850946eSmrg				;;
1830da4b5163Smrg			*-luna*)
1831a850946eSmrg				vendor=omron
1832a850946eSmrg				;;
1833da4b5163Smrg			*-genix*)
1834a850946eSmrg				vendor=ns
1835a850946eSmrg				;;
1836da4b5163Smrg			*-clix*)
1837da4b5163Smrg				vendor=intergraph
1838da4b5163Smrg				;;
1839da4b5163Smrg			*-mvs* | *-opened*)
1840da4b5163Smrg				vendor=ibm
1841da4b5163Smrg				;;
1842da4b5163Smrg			*-os400*)
1843a850946eSmrg				vendor=ibm
1844a850946eSmrg				;;
1845da4b5163Smrg			s390-* | s390x-*)
184670f7c90cSmrg				vendor=ibm
184770f7c90cSmrg				;;
1848da4b5163Smrg			*-ptx*)
1849a850946eSmrg				vendor=sequent
1850a850946eSmrg				;;
1851da4b5163Smrg			*-tpf*)
185270f7c90cSmrg				vendor=ibm
185370f7c90cSmrg				;;
1854da4b5163Smrg			*-vxsim* | *-vxworks* | *-windiss*)
1855a850946eSmrg				vendor=wrs
1856a850946eSmrg				;;
1857da4b5163Smrg			*-aux*)
1858a850946eSmrg				vendor=apple
1859a850946eSmrg				;;
1860da4b5163Smrg			*-hms*)
1861a850946eSmrg				vendor=hitachi
1862a850946eSmrg				;;
1863da4b5163Smrg			*-mpw* | *-macos*)
1864a850946eSmrg				vendor=apple
1865a850946eSmrg				;;
1866da4b5163Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1867a850946eSmrg				vendor=atari
1868a850946eSmrg				;;
1869da4b5163Smrg			*-vos*)
1870a850946eSmrg				vendor=stratus
1871a850946eSmrg				;;
1872a850946eSmrg		esac
1873a850946eSmrg		;;
1874a850946eSmrgesac
1875a850946eSmrg
1876da4b5163Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
187770f7c90cSmrgexit
1878a850946eSmrg
1879a850946eSmrg# Local variables:
1880da4b5163Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1881a850946eSmrg# time-stamp-start: "timestamp='"
1882a850946eSmrg# time-stamp-format: "%:y-%02m-%02d"
1883a850946eSmrg# time-stamp-end: "'"
1884a850946eSmrg# End:
1885