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