17da8b7e3Smrg#! /bin/sh
27da8b7e3Smrg# Configuration validation subroutine script.
3e4efb0bcSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
47da8b7e3Smrg
5e4b60806Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6e4b60806Smrg
7e4efb0bcSmrgtimestamp='2023-01-21'
87da8b7e3Smrg
9c3d5982aSmrg# This file is free software; you can redistribute it and/or modify it
10c3d5982aSmrg# under the terms of the GNU General Public License as published by
11e4efb0bcSmrg# the Free Software Foundation, either version 3 of the License, or
127da8b7e3Smrg# (at your option) any later version.
137da8b7e3Smrg#
14c3d5982aSmrg# This program is distributed in the hope that it will be useful, but
15c3d5982aSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16c3d5982aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17c3d5982aSmrg# General Public License for more details.
187da8b7e3Smrg#
197da8b7e3Smrg# You should have received a copy of the GNU General Public License
20ff143803Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
217da8b7e3Smrg#
227da8b7e3Smrg# As a special exception to the GNU General Public License, if you
237da8b7e3Smrg# distribute this file as part of a program that contains a
247da8b7e3Smrg# configuration script generated by Autoconf, you may include it under
25c3d5982aSmrg# the same distribution terms that you use for the rest of that
26c3d5982aSmrg# program.  This Exception is an additional permission under section 7
27c3d5982aSmrg# of the GNU General Public License, version 3 ("GPLv3").
287da8b7e3Smrg
297da8b7e3Smrg
30ff143803Smrg# Please send patches to <config-patches@gnu.org>.
317da8b7e3Smrg#
327da8b7e3Smrg# Configuration subroutine to validate and canonicalize a configuration type.
337da8b7e3Smrg# Supply the specified configuration type as an argument.
347da8b7e3Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
357da8b7e3Smrg# Otherwise, we print the canonical config type on stdout and succeed.
367da8b7e3Smrg
37bded5d25Smrg# You can get the latest version of this script from:
38e4b60806Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39bded5d25Smrg
407da8b7e3Smrg# This file is supposed to be the same for all GNU packages
417da8b7e3Smrg# and recognize all the CPU types, system types and aliases
427da8b7e3Smrg# that are meaningful with *any* GNU software.
437da8b7e3Smrg# Each package is responsible for reporting which valid configurations
447da8b7e3Smrg# it does not support.  The user should be able to distinguish
457da8b7e3Smrg# a failure to support a valid configuration from a meaningless
467da8b7e3Smrg# configuration.
477da8b7e3Smrg
487da8b7e3Smrg# The goal of this file is to map all the various variations of a given
497da8b7e3Smrg# machine specification into a single specification in the form:
507da8b7e3Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
517da8b7e3Smrg# or in some cases, the newer four-part form:
527da8b7e3Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
537da8b7e3Smrg# It is wrong to echo any other type of specification.
547da8b7e3Smrg
55e4b60806Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56e4b60806Smrg# about features and limitations of the classic Bourne shell that were
57e4b60806Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58e4b60806Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59e4b60806Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60e4b60806Smrg# have a pre-POSIX /bin/sh.
61e4b60806Smrg
627da8b7e3Smrgme=`echo "$0" | sed -e 's,.*/,,'`
637da8b7e3Smrg
647da8b7e3Smrgusage="\
65ff143803SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
667da8b7e3Smrg
677da8b7e3SmrgCanonicalize a configuration name.
687da8b7e3Smrg
69ff143803SmrgOptions:
707da8b7e3Smrg  -h, --help         print this help, then exit
717da8b7e3Smrg  -t, --time-stamp   print date of last modification, then exit
727da8b7e3Smrg  -v, --version      print version number, then exit
737da8b7e3Smrg
747da8b7e3SmrgReport bugs and patches to <config-patches@gnu.org>."
757da8b7e3Smrg
767da8b7e3Smrgversion="\
777da8b7e3SmrgGNU config.sub ($timestamp)
787da8b7e3Smrg
79e4efb0bcSmrgCopyright 1992-2023 Free Software Foundation, Inc.
807da8b7e3Smrg
817da8b7e3SmrgThis is free software; see the source for copying conditions.  There is NO
827da8b7e3Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
837da8b7e3Smrg
847da8b7e3Smrghelp="
857da8b7e3SmrgTry \`$me --help' for more information."
867da8b7e3Smrg
877da8b7e3Smrg# Parse command line
887da8b7e3Smrgwhile test $# -gt 0 ; do
897da8b7e3Smrg  case $1 in
907da8b7e3Smrg    --time-stamp | --time* | -t )
917da8b7e3Smrg       echo "$timestamp" ; exit ;;
927da8b7e3Smrg    --version | -v )
937da8b7e3Smrg       echo "$version" ; exit ;;
947da8b7e3Smrg    --help | --h* | -h )
957da8b7e3Smrg       echo "$usage"; exit ;;
967da8b7e3Smrg    -- )     # Stop option processing
977da8b7e3Smrg       shift; break ;;
987da8b7e3Smrg    - )	# Use stdin as input.
997da8b7e3Smrg       break ;;
1007da8b7e3Smrg    -* )
101e4b60806Smrg       echo "$me: invalid option $1$help" >&2
1027da8b7e3Smrg       exit 1 ;;
1037da8b7e3Smrg
1047da8b7e3Smrg    *local*)
1057da8b7e3Smrg       # First pass through any local machine types.
106ff143803Smrg       echo "$1"
1077da8b7e3Smrg       exit ;;
1087da8b7e3Smrg
1097da8b7e3Smrg    * )
1107da8b7e3Smrg       break ;;
1117da8b7e3Smrg  esac
1127da8b7e3Smrgdone
1137da8b7e3Smrg
1147da8b7e3Smrgcase $# in
1157da8b7e3Smrg 0) echo "$me: missing argument$help" >&2
1167da8b7e3Smrg    exit 1;;
1177da8b7e3Smrg 1) ;;
1187da8b7e3Smrg *) echo "$me: too many arguments$help" >&2
1197da8b7e3Smrg    exit 1;;
1207da8b7e3Smrgesac
1217da8b7e3Smrg
122e4b60806Smrg# Split fields of configuration type
123e4b60806Smrg# shellcheck disable=SC2162
124e4b60806Smrgsaved_IFS=$IFS
125e4b60806SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126e4b60806Smrg$1
127e4b60806SmrgEOF
128e4b60806SmrgIFS=$saved_IFS
1297da8b7e3Smrg
130e4b60806Smrg# Separate into logical components for further validation
131e4b60806Smrgcase $1 in
132e4b60806Smrg	*-*-*-*-*)
133e4b60806Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134e4b60806Smrg		exit 1
135c3d5982aSmrg		;;
136e4b60806Smrg	*-*-*-*)
137e4b60806Smrg		basic_machine=$field1-$field2
138e4b60806Smrg		basic_os=$field3-$field4
1397da8b7e3Smrg		;;
140e4b60806Smrg	*-*-*)
141e4b60806Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142e4b60806Smrg		# parts
143e4b60806Smrg		maybe_os=$field2-$field3
144e4b60806Smrg		case $maybe_os in
145e4b60806Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146e4b60806Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147e4b60806Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148e4efb0bcSmrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
149e4b60806Smrg				basic_machine=$field1
150e4b60806Smrg				basic_os=$maybe_os
151e4b60806Smrg				;;
152e4b60806Smrg			android-linux)
153e4b60806Smrg				basic_machine=$field1-unknown
154e4b60806Smrg				basic_os=linux-android
155e4b60806Smrg				;;
156e4b60806Smrg			*)
157e4b60806Smrg				basic_machine=$field1-$field2
158e4b60806Smrg				basic_os=$field3
159e4b60806Smrg				;;
160e4b60806Smrg		esac
1617da8b7e3Smrg		;;
162e4b60806Smrg	*-*)
163e4b60806Smrg		# A lone config we happen to match not fitting any pattern
164e4b60806Smrg		case $field1-$field2 in
165e4b60806Smrg			decstation-3100)
166e4b60806Smrg				basic_machine=mips-dec
167e4b60806Smrg				basic_os=
168e4b60806Smrg				;;
169e4b60806Smrg			*-*)
170e4b60806Smrg				# Second component is usually, but not always the OS
171e4b60806Smrg				case $field2 in
172e4b60806Smrg					# Prevent following clause from handling this valid os
173e4b60806Smrg					sun*os*)
174e4b60806Smrg						basic_machine=$field1
175e4b60806Smrg						basic_os=$field2
176e4b60806Smrg						;;
177e4b60806Smrg					zephyr*)
178e4b60806Smrg						basic_machine=$field1-unknown
179e4b60806Smrg						basic_os=$field2
180e4b60806Smrg						;;
181e4b60806Smrg					# Manufacturers
182e4b60806Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183e4b60806Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184e4b60806Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185e4b60806Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186e4b60806Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187e4b60806Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188e4b60806Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189e4b60806Smrg					| microblaze* | sim | cisco \
190e4b60806Smrg					| oki | wec | wrs | winbond)
191e4b60806Smrg						basic_machine=$field1-$field2
192e4b60806Smrg						basic_os=
193e4b60806Smrg						;;
194e4b60806Smrg					*)
195e4b60806Smrg						basic_machine=$field1
196e4b60806Smrg						basic_os=$field2
197e4b60806Smrg						;;
198e4b60806Smrg				esac
199e4b60806Smrg			;;
200e4b60806Smrg		esac
2017da8b7e3Smrg		;;
202e4b60806Smrg	*)
203e4b60806Smrg		# Convert single-component short-hands not valid as part of
204e4b60806Smrg		# multi-component configurations.
205e4b60806Smrg		case $field1 in
206e4b60806Smrg			386bsd)
207e4b60806Smrg				basic_machine=i386-pc
208e4b60806Smrg				basic_os=bsd
209e4b60806Smrg				;;
210e4b60806Smrg			a29khif)
211e4b60806Smrg				basic_machine=a29k-amd
212e4b60806Smrg				basic_os=udi
213e4b60806Smrg				;;
214e4b60806Smrg			adobe68k)
215e4b60806Smrg				basic_machine=m68010-adobe
216e4b60806Smrg				basic_os=scout
217e4b60806Smrg				;;
218e4b60806Smrg			alliant)
219e4b60806Smrg				basic_machine=fx80-alliant
220e4b60806Smrg				basic_os=
221e4b60806Smrg				;;
222e4b60806Smrg			altos | altos3068)
223e4b60806Smrg				basic_machine=m68k-altos
224e4b60806Smrg				basic_os=
225e4b60806Smrg				;;
226e4b60806Smrg			am29k)
227e4b60806Smrg				basic_machine=a29k-none
228e4b60806Smrg				basic_os=bsd
229e4b60806Smrg				;;
230e4b60806Smrg			amdahl)
231e4b60806Smrg				basic_machine=580-amdahl
232e4b60806Smrg				basic_os=sysv
233e4b60806Smrg				;;
234e4b60806Smrg			amiga)
235e4b60806Smrg				basic_machine=m68k-unknown
236e4b60806Smrg				basic_os=
237e4b60806Smrg				;;
238e4b60806Smrg			amigaos | amigados)
239e4b60806Smrg				basic_machine=m68k-unknown
240e4b60806Smrg				basic_os=amigaos
241e4b60806Smrg				;;
242e4b60806Smrg			amigaunix | amix)
243e4b60806Smrg				basic_machine=m68k-unknown
244e4b60806Smrg				basic_os=sysv4
245e4b60806Smrg				;;
246e4b60806Smrg			apollo68)
247e4b60806Smrg				basic_machine=m68k-apollo
248e4b60806Smrg				basic_os=sysv
249e4b60806Smrg				;;
250e4b60806Smrg			apollo68bsd)
251e4b60806Smrg				basic_machine=m68k-apollo
252e4b60806Smrg				basic_os=bsd
253e4b60806Smrg				;;
254e4b60806Smrg			aros)
255e4b60806Smrg				basic_machine=i386-pc
256e4b60806Smrg				basic_os=aros
257e4b60806Smrg				;;
258e4b60806Smrg			aux)
259e4b60806Smrg				basic_machine=m68k-apple
260e4b60806Smrg				basic_os=aux
261e4b60806Smrg				;;
262e4b60806Smrg			balance)
263e4b60806Smrg				basic_machine=ns32k-sequent
264e4b60806Smrg				basic_os=dynix
265e4b60806Smrg				;;
266e4b60806Smrg			blackfin)
267e4b60806Smrg				basic_machine=bfin-unknown
268e4b60806Smrg				basic_os=linux
269e4b60806Smrg				;;
270e4b60806Smrg			cegcc)
271e4b60806Smrg				basic_machine=arm-unknown
272e4b60806Smrg				basic_os=cegcc
273e4b60806Smrg				;;
274e4b60806Smrg			convex-c1)
275e4b60806Smrg				basic_machine=c1-convex
276e4b60806Smrg				basic_os=bsd
277e4b60806Smrg				;;
278e4b60806Smrg			convex-c2)
279e4b60806Smrg				basic_machine=c2-convex
280e4b60806Smrg				basic_os=bsd
281e4b60806Smrg				;;
282e4b60806Smrg			convex-c32)
283e4b60806Smrg				basic_machine=c32-convex
284e4b60806Smrg				basic_os=bsd
285e4b60806Smrg				;;
286e4b60806Smrg			convex-c34)
287e4b60806Smrg				basic_machine=c34-convex
288e4b60806Smrg				basic_os=bsd
289e4b60806Smrg				;;
290e4b60806Smrg			convex-c38)
291e4b60806Smrg				basic_machine=c38-convex
292e4b60806Smrg				basic_os=bsd
293e4b60806Smrg				;;
294e4b60806Smrg			cray)
295e4b60806Smrg				basic_machine=j90-cray
296e4b60806Smrg				basic_os=unicos
297e4b60806Smrg				;;
298e4b60806Smrg			crds | unos)
299e4b60806Smrg				basic_machine=m68k-crds
300e4b60806Smrg				basic_os=
301e4b60806Smrg				;;
302e4b60806Smrg			da30)
303e4b60806Smrg				basic_machine=m68k-da30
304e4b60806Smrg				basic_os=
305e4b60806Smrg				;;
306e4b60806Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307e4b60806Smrg				basic_machine=mips-dec
308e4b60806Smrg				basic_os=
309e4b60806Smrg				;;
310e4b60806Smrg			delta88)
311e4b60806Smrg				basic_machine=m88k-motorola
312e4b60806Smrg				basic_os=sysv3
313e4b60806Smrg				;;
314e4b60806Smrg			dicos)
315e4b60806Smrg				basic_machine=i686-pc
316e4b60806Smrg				basic_os=dicos
317e4b60806Smrg				;;
318e4b60806Smrg			djgpp)
319e4b60806Smrg				basic_machine=i586-pc
320e4b60806Smrg				basic_os=msdosdjgpp
321e4b60806Smrg				;;
322e4b60806Smrg			ebmon29k)
323e4b60806Smrg				basic_machine=a29k-amd
324e4b60806Smrg				basic_os=ebmon
325e4b60806Smrg				;;
326e4b60806Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327e4b60806Smrg				basic_machine=m68k-ericsson
328e4b60806Smrg				basic_os=ose
329e4b60806Smrg				;;
330e4b60806Smrg			gmicro)
331e4b60806Smrg				basic_machine=tron-gmicro
332e4b60806Smrg				basic_os=sysv
333e4b60806Smrg				;;
334e4b60806Smrg			go32)
335e4b60806Smrg				basic_machine=i386-pc
336e4b60806Smrg				basic_os=go32
337e4b60806Smrg				;;
338e4b60806Smrg			h8300hms)
339e4b60806Smrg				basic_machine=h8300-hitachi
340e4b60806Smrg				basic_os=hms
341e4b60806Smrg				;;
342e4b60806Smrg			h8300xray)
343e4b60806Smrg				basic_machine=h8300-hitachi
344e4b60806Smrg				basic_os=xray
345e4b60806Smrg				;;
346e4b60806Smrg			h8500hms)
347e4b60806Smrg				basic_machine=h8500-hitachi
348e4b60806Smrg				basic_os=hms
349e4b60806Smrg				;;
350e4b60806Smrg			harris)
351e4b60806Smrg				basic_machine=m88k-harris
352e4b60806Smrg				basic_os=sysv3
353e4b60806Smrg				;;
354e4b60806Smrg			hp300 | hp300hpux)
355e4b60806Smrg				basic_machine=m68k-hp
356e4b60806Smrg				basic_os=hpux
357e4b60806Smrg				;;
358e4b60806Smrg			hp300bsd)
359e4b60806Smrg				basic_machine=m68k-hp
360e4b60806Smrg				basic_os=bsd
361e4b60806Smrg				;;
362e4b60806Smrg			hppaosf)
363e4b60806Smrg				basic_machine=hppa1.1-hp
364e4b60806Smrg				basic_os=osf
365e4b60806Smrg				;;
366e4b60806Smrg			hppro)
367e4b60806Smrg				basic_machine=hppa1.1-hp
368e4b60806Smrg				basic_os=proelf
369e4b60806Smrg				;;
370e4b60806Smrg			i386mach)
371e4b60806Smrg				basic_machine=i386-mach
372e4b60806Smrg				basic_os=mach
373e4b60806Smrg				;;
374e4b60806Smrg			isi68 | isi)
375e4b60806Smrg				basic_machine=m68k-isi
376e4b60806Smrg				basic_os=sysv
377e4b60806Smrg				;;
378e4b60806Smrg			m68knommu)
379e4b60806Smrg				basic_machine=m68k-unknown
380e4b60806Smrg				basic_os=linux
381e4b60806Smrg				;;
382e4b60806Smrg			magnum | m3230)
383e4b60806Smrg				basic_machine=mips-mips
384e4b60806Smrg				basic_os=sysv
385e4b60806Smrg				;;
386e4b60806Smrg			merlin)
387e4b60806Smrg				basic_machine=ns32k-utek
388e4b60806Smrg				basic_os=sysv
389e4b60806Smrg				;;
390e4b60806Smrg			mingw64)
391e4b60806Smrg				basic_machine=x86_64-pc
392e4b60806Smrg				basic_os=mingw64
393e4b60806Smrg				;;
394e4b60806Smrg			mingw32)
395e4b60806Smrg				basic_machine=i686-pc
396e4b60806Smrg				basic_os=mingw32
397e4b60806Smrg				;;
398e4b60806Smrg			mingw32ce)
399e4b60806Smrg				basic_machine=arm-unknown
400e4b60806Smrg				basic_os=mingw32ce
401e4b60806Smrg				;;
402e4b60806Smrg			monitor)
403e4b60806Smrg				basic_machine=m68k-rom68k
404e4b60806Smrg				basic_os=coff
405e4b60806Smrg				;;
406e4b60806Smrg			morphos)
407e4b60806Smrg				basic_machine=powerpc-unknown
408e4b60806Smrg				basic_os=morphos
409e4b60806Smrg				;;
410e4b60806Smrg			moxiebox)
411e4b60806Smrg				basic_machine=moxie-unknown
412e4b60806Smrg				basic_os=moxiebox
413e4b60806Smrg				;;
414e4b60806Smrg			msdos)
415e4b60806Smrg				basic_machine=i386-pc
416e4b60806Smrg				basic_os=msdos
417e4b60806Smrg				;;
418e4b60806Smrg			msys)
419e4b60806Smrg				basic_machine=i686-pc
420e4b60806Smrg				basic_os=msys
421e4b60806Smrg				;;
422e4b60806Smrg			mvs)
423e4b60806Smrg				basic_machine=i370-ibm
424e4b60806Smrg				basic_os=mvs
425e4b60806Smrg				;;
426e4b60806Smrg			nacl)
427e4b60806Smrg				basic_machine=le32-unknown
428e4b60806Smrg				basic_os=nacl
429e4b60806Smrg				;;
430e4b60806Smrg			ncr3000)
431e4b60806Smrg				basic_machine=i486-ncr
432e4b60806Smrg				basic_os=sysv4
433e4b60806Smrg				;;
434e4b60806Smrg			netbsd386)
435e4b60806Smrg				basic_machine=i386-pc
436e4b60806Smrg				basic_os=netbsd
437e4b60806Smrg				;;
438e4b60806Smrg			netwinder)
439e4b60806Smrg				basic_machine=armv4l-rebel
440e4b60806Smrg				basic_os=linux
441e4b60806Smrg				;;
442e4b60806Smrg			news | news700 | news800 | news900)
443e4b60806Smrg				basic_machine=m68k-sony
444e4b60806Smrg				basic_os=newsos
445e4b60806Smrg				;;
446e4b60806Smrg			news1000)
447e4b60806Smrg				basic_machine=m68030-sony
448e4b60806Smrg				basic_os=newsos
449e4b60806Smrg				;;
450e4b60806Smrg			necv70)
451e4b60806Smrg				basic_machine=v70-nec
452e4b60806Smrg				basic_os=sysv
453e4b60806Smrg				;;
454e4b60806Smrg			nh3000)
455e4b60806Smrg				basic_machine=m68k-harris
456e4b60806Smrg				basic_os=cxux
457e4b60806Smrg				;;
458e4b60806Smrg			nh[45]000)
459e4b60806Smrg				basic_machine=m88k-harris
460e4b60806Smrg				basic_os=cxux
461e4b60806Smrg				;;
462e4b60806Smrg			nindy960)
463e4b60806Smrg				basic_machine=i960-intel
464e4b60806Smrg				basic_os=nindy
465e4b60806Smrg				;;
466e4b60806Smrg			mon960)
467e4b60806Smrg				basic_machine=i960-intel
468e4b60806Smrg				basic_os=mon960
469e4b60806Smrg				;;
470e4b60806Smrg			nonstopux)
471e4b60806Smrg				basic_machine=mips-compaq
472e4b60806Smrg				basic_os=nonstopux
473e4b60806Smrg				;;
474e4b60806Smrg			os400)
475e4b60806Smrg				basic_machine=powerpc-ibm
476e4b60806Smrg				basic_os=os400
477e4b60806Smrg				;;
478e4b60806Smrg			OSE68000 | ose68000)
479e4b60806Smrg				basic_machine=m68000-ericsson
480e4b60806Smrg				basic_os=ose
481e4b60806Smrg				;;
482e4b60806Smrg			os68k)
483e4b60806Smrg				basic_machine=m68k-none
484e4b60806Smrg				basic_os=os68k
485e4b60806Smrg				;;
486e4b60806Smrg			paragon)
487e4b60806Smrg				basic_machine=i860-intel
488e4b60806Smrg				basic_os=osf
489e4b60806Smrg				;;
490e4b60806Smrg			parisc)
491e4b60806Smrg				basic_machine=hppa-unknown
492e4b60806Smrg				basic_os=linux
493e4b60806Smrg				;;
494e4b60806Smrg			psp)
495e4b60806Smrg				basic_machine=mipsallegrexel-sony
496e4b60806Smrg				basic_os=psp
497e4b60806Smrg				;;
498e4b60806Smrg			pw32)
499e4b60806Smrg				basic_machine=i586-unknown
500e4b60806Smrg				basic_os=pw32
501e4b60806Smrg				;;
502e4b60806Smrg			rdos | rdos64)
503e4b60806Smrg				basic_machine=x86_64-pc
504e4b60806Smrg				basic_os=rdos
505e4b60806Smrg				;;
506e4b60806Smrg			rdos32)
507e4b60806Smrg				basic_machine=i386-pc
508e4b60806Smrg				basic_os=rdos
509e4b60806Smrg				;;
510e4b60806Smrg			rom68k)
511e4b60806Smrg				basic_machine=m68k-rom68k
512e4b60806Smrg				basic_os=coff
513e4b60806Smrg				;;
514e4b60806Smrg			sa29200)
515e4b60806Smrg				basic_machine=a29k-amd
516e4b60806Smrg				basic_os=udi
517e4b60806Smrg				;;
518e4b60806Smrg			sei)
519e4b60806Smrg				basic_machine=mips-sei
520e4b60806Smrg				basic_os=seiux
521e4b60806Smrg				;;
522e4b60806Smrg			sequent)
523e4b60806Smrg				basic_machine=i386-sequent
524e4b60806Smrg				basic_os=
525e4b60806Smrg				;;
526e4b60806Smrg			sps7)
527e4b60806Smrg				basic_machine=m68k-bull
528e4b60806Smrg				basic_os=sysv2
529e4b60806Smrg				;;
530e4b60806Smrg			st2000)
531e4b60806Smrg				basic_machine=m68k-tandem
532e4b60806Smrg				basic_os=
533e4b60806Smrg				;;
534e4b60806Smrg			stratus)
535e4b60806Smrg				basic_machine=i860-stratus
536e4b60806Smrg				basic_os=sysv4
537e4b60806Smrg				;;
538e4b60806Smrg			sun2)
539e4b60806Smrg				basic_machine=m68000-sun
540e4b60806Smrg				basic_os=
541e4b60806Smrg				;;
542e4b60806Smrg			sun2os3)
543e4b60806Smrg				basic_machine=m68000-sun
544e4b60806Smrg				basic_os=sunos3
545e4b60806Smrg				;;
546e4b60806Smrg			sun2os4)
547e4b60806Smrg				basic_machine=m68000-sun
548e4b60806Smrg				basic_os=sunos4
549e4b60806Smrg				;;
550e4b60806Smrg			sun3)
551e4b60806Smrg				basic_machine=m68k-sun
552e4b60806Smrg				basic_os=
553e4b60806Smrg				;;
554e4b60806Smrg			sun3os3)
555e4b60806Smrg				basic_machine=m68k-sun
556e4b60806Smrg				basic_os=sunos3
557e4b60806Smrg				;;
558e4b60806Smrg			sun3os4)
559e4b60806Smrg				basic_machine=m68k-sun
560e4b60806Smrg				basic_os=sunos4
561e4b60806Smrg				;;
562e4b60806Smrg			sun4)
563e4b60806Smrg				basic_machine=sparc-sun
564e4b60806Smrg				basic_os=
565e4b60806Smrg				;;
566e4b60806Smrg			sun4os3)
567e4b60806Smrg				basic_machine=sparc-sun
568e4b60806Smrg				basic_os=sunos3
569e4b60806Smrg				;;
570e4b60806Smrg			sun4os4)
571e4b60806Smrg				basic_machine=sparc-sun
572e4b60806Smrg				basic_os=sunos4
573e4b60806Smrg				;;
574e4b60806Smrg			sun4sol2)
575e4b60806Smrg				basic_machine=sparc-sun
576e4b60806Smrg				basic_os=solaris2
577e4b60806Smrg				;;
578e4b60806Smrg			sun386 | sun386i | roadrunner)
579e4b60806Smrg				basic_machine=i386-sun
580e4b60806Smrg				basic_os=
581e4b60806Smrg				;;
582e4b60806Smrg			sv1)
583e4b60806Smrg				basic_machine=sv1-cray
584e4b60806Smrg				basic_os=unicos
585e4b60806Smrg				;;
586e4b60806Smrg			symmetry)
587e4b60806Smrg				basic_machine=i386-sequent
588e4b60806Smrg				basic_os=dynix
589e4b60806Smrg				;;
590e4b60806Smrg			t3e)
591e4b60806Smrg				basic_machine=alphaev5-cray
592e4b60806Smrg				basic_os=unicos
593e4b60806Smrg				;;
594e4b60806Smrg			t90)
595e4b60806Smrg				basic_machine=t90-cray
596e4b60806Smrg				basic_os=unicos
597e4b60806Smrg				;;
598e4b60806Smrg			toad1)
599e4b60806Smrg				basic_machine=pdp10-xkl
600e4b60806Smrg				basic_os=tops20
601e4b60806Smrg				;;
602e4b60806Smrg			tpf)
603e4b60806Smrg				basic_machine=s390x-ibm
604e4b60806Smrg				basic_os=tpf
605e4b60806Smrg				;;
606e4b60806Smrg			udi29k)
607e4b60806Smrg				basic_machine=a29k-amd
608e4b60806Smrg				basic_os=udi
609e4b60806Smrg				;;
610e4b60806Smrg			ultra3)
611e4b60806Smrg				basic_machine=a29k-nyu
612e4b60806Smrg				basic_os=sym1
613e4b60806Smrg				;;
614e4b60806Smrg			v810 | necv810)
615e4b60806Smrg				basic_machine=v810-nec
616e4b60806Smrg				basic_os=none
617e4b60806Smrg				;;
618e4b60806Smrg			vaxv)
619e4b60806Smrg				basic_machine=vax-dec
620e4b60806Smrg				basic_os=sysv
621e4b60806Smrg				;;
622e4b60806Smrg			vms)
623e4b60806Smrg				basic_machine=vax-dec
624e4b60806Smrg				basic_os=vms
625e4b60806Smrg				;;
626e4b60806Smrg			vsta)
627e4b60806Smrg				basic_machine=i386-pc
628e4b60806Smrg				basic_os=vsta
629e4b60806Smrg				;;
630e4b60806Smrg			vxworks960)
631e4b60806Smrg				basic_machine=i960-wrs
632e4b60806Smrg				basic_os=vxworks
633e4b60806Smrg				;;
634e4b60806Smrg			vxworks68)
635e4b60806Smrg				basic_machine=m68k-wrs
636e4b60806Smrg				basic_os=vxworks
637e4b60806Smrg				;;
638e4b60806Smrg			vxworks29k)
639e4b60806Smrg				basic_machine=a29k-wrs
640e4b60806Smrg				basic_os=vxworks
641e4b60806Smrg				;;
642e4b60806Smrg			xbox)
643e4b60806Smrg				basic_machine=i686-pc
644e4b60806Smrg				basic_os=mingw32
645e4b60806Smrg				;;
646e4b60806Smrg			ymp)
647e4b60806Smrg				basic_machine=ymp-cray
648e4b60806Smrg				basic_os=unicos
649e4b60806Smrg				;;
650e4b60806Smrg			*)
651e4b60806Smrg				basic_machine=$1
652e4b60806Smrg				basic_os=
653e4b60806Smrg				;;
654e4b60806Smrg		esac
6557da8b7e3Smrg		;;
6567da8b7e3Smrgesac
6577da8b7e3Smrg
658e4b60806Smrg# Decode 1-component or ad-hoc basic machines
6597da8b7e3Smrgcase $basic_machine in
660e4b60806Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661e4b60806Smrg	# some cases the only manufacturer, in others, it is the most popular.
662e4b60806Smrg	w89k)
663e4b60806Smrg		cpu=hppa1.1
664e4b60806Smrg		vendor=winbond
665ff143803Smrg		;;
666e4b60806Smrg	op50n)
667e4b60806Smrg		cpu=hppa1.1
668e4b60806Smrg		vendor=oki
6697da8b7e3Smrg		;;
670e4b60806Smrg	op60c)
671e4b60806Smrg		cpu=hppa1.1
672e4b60806Smrg		vendor=oki
6737da8b7e3Smrg		;;
674e4b60806Smrg	ibm*)
675e4b60806Smrg		cpu=i370
676e4b60806Smrg		vendor=ibm
677123e2cc7Smrg		;;
678e4b60806Smrg	orion105)
679e4b60806Smrg		cpu=clipper
680e4b60806Smrg		vendor=highlevel
681c3d5982aSmrg		;;
682e4b60806Smrg	mac | mpw | mac-mpw)
683e4b60806Smrg		cpu=m68k
684e4b60806Smrg		vendor=apple
685c3d5982aSmrg		;;
686e4b60806Smrg	pmac | pmac-mpw)
687e4b60806Smrg		cpu=powerpc
688e4b60806Smrg		vendor=apple
689c3d5982aSmrg		;;
690c3d5982aSmrg
6917da8b7e3Smrg	# Recognize the various machine names and aliases which stand
6927da8b7e3Smrg	# for a CPU type and a company and sometimes even an OS.
6937da8b7e3Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694e4b60806Smrg		cpu=m68000
695e4b60806Smrg		vendor=att
6967da8b7e3Smrg		;;
6977da8b7e3Smrg	3b*)
698e4b60806Smrg		cpu=we32k
699e4b60806Smrg		vendor=att
700123e2cc7Smrg		;;
701bded5d25Smrg	bluegene*)
702e4b60806Smrg		cpu=powerpc
703e4b60806Smrg		vendor=ibm
704e4b60806Smrg		basic_os=cnk
7057da8b7e3Smrg		;;
7067da8b7e3Smrg	decsystem10* | dec10*)
707e4b60806Smrg		cpu=pdp10
708e4b60806Smrg		vendor=dec
709e4b60806Smrg		basic_os=tops10
7107da8b7e3Smrg		;;
7117da8b7e3Smrg	decsystem20* | dec20*)
712e4b60806Smrg		cpu=pdp10
713e4b60806Smrg		vendor=dec
714e4b60806Smrg		basic_os=tops20
7157da8b7e3Smrg		;;
7167da8b7e3Smrg	delta | 3300 | motorola-3300 | motorola-delta \
7177da8b7e3Smrg	      | 3300-motorola | delta-motorola)
718e4b60806Smrg		cpu=m68k
719e4b60806Smrg		vendor=motorola
7207da8b7e3Smrg		;;
721ff143803Smrg	dpx2*)
722e4b60806Smrg		cpu=m68k
723e4b60806Smrg		vendor=bull
724e4b60806Smrg		basic_os=sysv3
7257da8b7e3Smrg		;;
7267da8b7e3Smrg	encore | umax | mmax)
727e4b60806Smrg		cpu=ns32k
728e4b60806Smrg		vendor=encore
7297da8b7e3Smrg		;;
730e4b60806Smrg	elxsi)
731e4b60806Smrg		cpu=elxsi
732e4b60806Smrg		vendor=elxsi
733e4b60806Smrg		basic_os=${basic_os:-bsd}
7347da8b7e3Smrg		;;
7357da8b7e3Smrg	fx2800)
736e4b60806Smrg		cpu=i860
737e4b60806Smrg		vendor=alliant
7387da8b7e3Smrg		;;
7397da8b7e3Smrg	genix)
740e4b60806Smrg		cpu=ns32k
741e4b60806Smrg		vendor=ns
7427da8b7e3Smrg		;;
7437da8b7e3Smrg	h3050r* | hiux*)
744e4b60806Smrg		cpu=hppa1.1
745e4b60806Smrg		vendor=hitachi
746e4b60806Smrg		basic_os=hiuxwe2
7477da8b7e3Smrg		;;
7487da8b7e3Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749e4b60806Smrg		cpu=hppa1.0
750e4b60806Smrg		vendor=hp
7517da8b7e3Smrg		;;
7527da8b7e3Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753e4b60806Smrg		cpu=m68000
754e4b60806Smrg		vendor=hp
7557da8b7e3Smrg		;;
7567da8b7e3Smrg	hp9k3[2-9][0-9])
757e4b60806Smrg		cpu=m68k
758e4b60806Smrg		vendor=hp
7597da8b7e3Smrg		;;
7607da8b7e3Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761e4b60806Smrg		cpu=hppa1.0
762e4b60806Smrg		vendor=hp
7637da8b7e3Smrg		;;
7647da8b7e3Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765e4b60806Smrg		cpu=hppa1.1
766e4b60806Smrg		vendor=hp
7677da8b7e3Smrg		;;
7687da8b7e3Smrg	hp9k78[0-9] | hp78[0-9])
7697da8b7e3Smrg		# FIXME: really hppa2.0-hp
770e4b60806Smrg		cpu=hppa1.1
771e4b60806Smrg		vendor=hp
7727da8b7e3Smrg		;;
7737da8b7e3Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7747da8b7e3Smrg		# FIXME: really hppa2.0-hp
775e4b60806Smrg		cpu=hppa1.1
776e4b60806Smrg		vendor=hp
7777da8b7e3Smrg		;;
7787da8b7e3Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779e4b60806Smrg		cpu=hppa1.1
780e4b60806Smrg		vendor=hp
7817da8b7e3Smrg		;;
7827da8b7e3Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783e4b60806Smrg		cpu=hppa1.0
784e4b60806Smrg		vendor=hp
7857da8b7e3Smrg		;;
7867da8b7e3Smrg	i*86v32)
787e4b60806Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788e4b60806Smrg		vendor=pc
789e4b60806Smrg		basic_os=sysv32
7907da8b7e3Smrg		;;
7917da8b7e3Smrg	i*86v4*)
792e4b60806Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793e4b60806Smrg		vendor=pc
794e4b60806Smrg		basic_os=sysv4
7957da8b7e3Smrg		;;
7967da8b7e3Smrg	i*86v)
797e4b60806Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798e4b60806Smrg		vendor=pc
799e4b60806Smrg		basic_os=sysv
8007da8b7e3Smrg		;;
8017da8b7e3Smrg	i*86sol2)
802e4b60806Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803e4b60806Smrg		vendor=pc
804e4b60806Smrg		basic_os=solaris2
8057da8b7e3Smrg		;;
806e4b60806Smrg	j90 | j90-cray)
807e4b60806Smrg		cpu=j90
808e4b60806Smrg		vendor=cray
809e4b60806Smrg		basic_os=${basic_os:-unicos}
8107da8b7e3Smrg		;;
8117da8b7e3Smrg	iris | iris4d)
812e4b60806Smrg		cpu=mips
813e4b60806Smrg		vendor=sgi
814e4b60806Smrg		case $basic_os in
815e4b60806Smrg		    irix*)
8167da8b7e3Smrg			;;
8177da8b7e3Smrg		    *)
818e4b60806Smrg			basic_os=irix4
8197da8b7e3Smrg			;;
8207da8b7e3Smrg		esac
8217da8b7e3Smrg		;;
8227da8b7e3Smrg	miniframe)
823e4b60806Smrg		cpu=m68000
824e4b60806Smrg		vendor=convergent
8257da8b7e3Smrg		;;
826e4b60806Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827e4b60806Smrg		cpu=m68k
828e4b60806Smrg		vendor=atari
829e4b60806Smrg		basic_os=mint
8307da8b7e3Smrg		;;
8317da8b7e3Smrg	news-3600 | risc-news)
832e4b60806Smrg		cpu=mips
833e4b60806Smrg		vendor=sony
834e4b60806Smrg		basic_os=newsos
8357da8b7e3Smrg		;;
836ff143803Smrg	next | m*-next)
837e4b60806Smrg		cpu=m68k
838e4b60806Smrg		vendor=next
839e4b60806Smrg		case $basic_os in
840e4b60806Smrg		    openstep*)
841e4b60806Smrg		        ;;
842e4b60806Smrg		    nextstep*)
8437da8b7e3Smrg			;;
844e4b60806Smrg		    ns2*)
845e4b60806Smrg		      basic_os=nextstep2
8467da8b7e3Smrg			;;
8477da8b7e3Smrg		    *)
848e4b60806Smrg		      basic_os=nextstep3
8497da8b7e3Smrg			;;
8507da8b7e3Smrg		esac
8517da8b7e3Smrg		;;
8527da8b7e3Smrg	np1)
853e4b60806Smrg		cpu=np1
854e4b60806Smrg		vendor=gould
855ff143803Smrg		;;
8567da8b7e3Smrg	op50n-* | op60c-*)
857e4b60806Smrg		cpu=hppa1.1
858e4b60806Smrg		vendor=oki
859e4b60806Smrg		basic_os=proelf
8607da8b7e3Smrg		;;
8617da8b7e3Smrg	pa-hitachi)
862e4b60806Smrg		cpu=hppa1.1
863e4b60806Smrg		vendor=hitachi
864e4b60806Smrg		basic_os=hiuxwe2
865123e2cc7Smrg		;;
8667da8b7e3Smrg	pbd)
867e4b60806Smrg		cpu=sparc
868e4b60806Smrg		vendor=tti
8697da8b7e3Smrg		;;
8707da8b7e3Smrg	pbb)
871e4b60806Smrg		cpu=m68k
872e4b60806Smrg		vendor=tti
8737da8b7e3Smrg		;;
874e4b60806Smrg	pc532)
875e4b60806Smrg		cpu=ns32k
876e4b60806Smrg		vendor=pc532
8777da8b7e3Smrg		;;
8787da8b7e3Smrg	pn)
879e4b60806Smrg		cpu=pn
880e4b60806Smrg		vendor=gould
8817da8b7e3Smrg		;;
882e4b60806Smrg	power)
883e4b60806Smrg		cpu=power
884e4b60806Smrg		vendor=ibm
8857da8b7e3Smrg		;;
886e4b60806Smrg	ps2)
887e4b60806Smrg		cpu=i386
888e4b60806Smrg		vendor=ibm
8897da8b7e3Smrg		;;
890e4b60806Smrg	rm[46]00)
891e4b60806Smrg		cpu=mips
892e4b60806Smrg		vendor=siemens
8937da8b7e3Smrg		;;
894e4b60806Smrg	rtpc | rtpc-*)
895e4b60806Smrg		cpu=romp
896e4b60806Smrg		vendor=ibm
8977da8b7e3Smrg		;;
898e4b60806Smrg	sde)
899e4b60806Smrg		cpu=mipsisa32
900e4b60806Smrg		vendor=sde
901e4b60806Smrg		basic_os=${basic_os:-elf}
9027da8b7e3Smrg		;;
903e4b60806Smrg	simso-wrs)
904e4b60806Smrg		cpu=sparclite
905e4b60806Smrg		vendor=wrs
906e4b60806Smrg		basic_os=vxworks
9077da8b7e3Smrg		;;
908e4b60806Smrg	tower | tower-32)
909e4b60806Smrg		cpu=m68k
910e4b60806Smrg		vendor=ncr
9117da8b7e3Smrg		;;
912e4b60806Smrg	vpp*|vx|vx-*)
913e4b60806Smrg		cpu=f301
914e4b60806Smrg		vendor=fujitsu
915c3d5982aSmrg		;;
916e4b60806Smrg	w65)
917e4b60806Smrg		cpu=w65
918e4b60806Smrg		vendor=wdc
919123e2cc7Smrg		;;
920e4b60806Smrg	w89k-*)
921e4b60806Smrg		cpu=hppa1.1
922e4b60806Smrg		vendor=winbond
923e4b60806Smrg		basic_os=proelf
9247da8b7e3Smrg		;;
925e4b60806Smrg	none)
926e4b60806Smrg		cpu=none
927e4b60806Smrg		vendor=none
9287da8b7e3Smrg		;;
929e4b60806Smrg	leon|leon[3-9])
930e4b60806Smrg		cpu=sparc
931e4b60806Smrg		vendor=$basic_machine
9327da8b7e3Smrg		;;
933e4b60806Smrg	leon-*|leon[3-9]-*)
934e4b60806Smrg		cpu=sparc
935e4b60806Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9367da8b7e3Smrg		;;
937e4b60806Smrg
938e4b60806Smrg	*-*)
939e4b60806Smrg		# shellcheck disable=SC2162
940e4b60806Smrg		saved_IFS=$IFS
941e4b60806Smrg		IFS="-" read cpu vendor <<EOF
942e4b60806Smrg$basic_machine
943e4b60806SmrgEOF
944e4b60806Smrg		IFS=$saved_IFS
9457da8b7e3Smrg		;;
946e4b60806Smrg	# We use `pc' rather than `unknown'
947e4b60806Smrg	# because (1) that's what they normally are, and
948e4b60806Smrg	# (2) the word "unknown" tends to confuse beginning users.
949e4b60806Smrg	i*86 | x86_64)
950e4b60806Smrg		cpu=$basic_machine
951e4b60806Smrg		vendor=pc
9527da8b7e3Smrg		;;
953e4b60806Smrg	# These rules are duplicated from below for sake of the special case above;
954e4b60806Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955e4b60806Smrg	pc98)
956e4b60806Smrg		cpu=i386
957e4b60806Smrg		vendor=pc
9587da8b7e3Smrg		;;
959e4b60806Smrg	x64 | amd64)
960e4b60806Smrg		cpu=x86_64
961e4b60806Smrg		vendor=pc
9627da8b7e3Smrg		;;
963e4b60806Smrg	# Recognize the basic CPU types without company name.
964e4b60806Smrg	*)
965e4b60806Smrg		cpu=$basic_machine
966e4b60806Smrg		vendor=unknown
967123e2cc7Smrg		;;
968e4b60806Smrgesac
969e4b60806Smrg
970e4b60806Smrgunset -v basic_machine
971e4b60806Smrg
972e4b60806Smrg# Decode basic machines in the full and proper CPU-Company form.
973e4b60806Smrgcase $cpu-$vendor in
974e4b60806Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975e4b60806Smrg	# some cases the only manufacturer, in others, it is the most popular.
976e4b60806Smrg	craynv-unknown)
977e4b60806Smrg		vendor=cray
978e4b60806Smrg		basic_os=${basic_os:-unicosmp}
9797da8b7e3Smrg		;;
980e4b60806Smrg	c90-unknown | c90-cray)
981e4b60806Smrg		vendor=cray
982e4b60806Smrg		basic_os=${Basic_os:-unicos}
9837da8b7e3Smrg		;;
984e4b60806Smrg	fx80-unknown)
985e4b60806Smrg		vendor=alliant
986123e2cc7Smrg		;;
987e4b60806Smrg	romp-unknown)
988e4b60806Smrg		vendor=ibm
9897da8b7e3Smrg		;;
990e4b60806Smrg	mmix-unknown)
991e4b60806Smrg		vendor=knuth
9927da8b7e3Smrg		;;
993e4b60806Smrg	microblaze-unknown | microblazeel-unknown)
994e4b60806Smrg		vendor=xilinx
9957da8b7e3Smrg		;;
996e4b60806Smrg	rs6000-unknown)
997e4b60806Smrg		vendor=ibm
9987da8b7e3Smrg		;;
999e4b60806Smrg	vax-unknown)
1000e4b60806Smrg		vendor=dec
10017da8b7e3Smrg		;;
1002e4b60806Smrg	pdp11-unknown)
1003e4b60806Smrg		vendor=dec
1004c3d5982aSmrg		;;
1005e4b60806Smrg	we32k-unknown)
1006e4b60806Smrg		vendor=att
10077da8b7e3Smrg		;;
1008e4b60806Smrg	cydra-unknown)
1009e4b60806Smrg		vendor=cydrome
10107da8b7e3Smrg		;;
1011e4b60806Smrg	i370-ibm*)
1012e4b60806Smrg		vendor=ibm
10137da8b7e3Smrg		;;
1014e4b60806Smrg	orion-unknown)
1015e4b60806Smrg		vendor=highlevel
10167da8b7e3Smrg		;;
1017e4b60806Smrg	xps-unknown | xps100-unknown)
1018e4b60806Smrg		cpu=xps100
1019e4b60806Smrg		vendor=honeywell
10207da8b7e3Smrg		;;
1021e4b60806Smrg
1022e4b60806Smrg	# Here we normalize CPU types with a missing or matching vendor
1023e4efb0bcSmrg	armh-unknown | armh-alt)
1024e4efb0bcSmrg		cpu=armv7l
1025e4efb0bcSmrg		vendor=alt
1026e4efb0bcSmrg		basic_os=${basic_os:-linux-gnueabihf}
1027e4efb0bcSmrg		;;
1028e4b60806Smrg	dpx20-unknown | dpx20-bull)
1029e4b60806Smrg		cpu=rs6000
1030e4b60806Smrg		vendor=bull
1031e4b60806Smrg		basic_os=${basic_os:-bosx}
10327da8b7e3Smrg		;;
1033e4b60806Smrg
1034e4b60806Smrg	# Here we normalize CPU types irrespective of the vendor
1035e4b60806Smrg	amd64-*)
1036e4b60806Smrg		cpu=x86_64
10377da8b7e3Smrg		;;
1038e4b60806Smrg	blackfin-*)
1039e4b60806Smrg		cpu=bfin
1040e4b60806Smrg		basic_os=linux
10417da8b7e3Smrg		;;
1042e4b60806Smrg	c54x-*)
1043e4b60806Smrg		cpu=tic54x
10447da8b7e3Smrg		;;
1045e4b60806Smrg	c55x-*)
1046e4b60806Smrg		cpu=tic55x
10477da8b7e3Smrg		;;
1048e4b60806Smrg	c6x-*)
1049e4b60806Smrg		cpu=tic6x
10507da8b7e3Smrg		;;
1051e4b60806Smrg	e500v[12]-*)
1052e4b60806Smrg		cpu=powerpc
1053e4b60806Smrg		basic_os=${basic_os}"spe"
10547da8b7e3Smrg		;;
1055e4b60806Smrg	mips3*-*)
1056e4b60806Smrg		cpu=mips64
10577da8b7e3Smrg		;;
1058e4b60806Smrg	ms1-*)
1059e4b60806Smrg		cpu=mt
10607da8b7e3Smrg		;;
1061e4b60806Smrg	m68knommu-*)
1062e4b60806Smrg		cpu=m68k
1063e4b60806Smrg		basic_os=linux
10647da8b7e3Smrg		;;
1065e4b60806Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1066e4b60806Smrg		cpu=s12z
1067123e2cc7Smrg		;;
1068e4b60806Smrg	openrisc-*)
1069e4b60806Smrg		cpu=or32
10707da8b7e3Smrg		;;
1071e4b60806Smrg	parisc-*)
1072e4b60806Smrg		cpu=hppa
1073e4b60806Smrg		basic_os=linux
10747da8b7e3Smrg		;;
1075e4b60806Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1076e4b60806Smrg		cpu=i586
10777da8b7e3Smrg		;;
1078e4efb0bcSmrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1079e4b60806Smrg		cpu=i686
10807da8b7e3Smrg		;;
1081e4b60806Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1082e4b60806Smrg		cpu=i686
10837da8b7e3Smrg		;;
1084e4b60806Smrg	pentium4-*)
1085e4b60806Smrg		cpu=i786
10867da8b7e3Smrg		;;
1087e4b60806Smrg	pc98-*)
1088e4b60806Smrg		cpu=i386
10897da8b7e3Smrg		;;
1090e4b60806Smrg	ppc-* | ppcbe-*)
1091e4b60806Smrg		cpu=powerpc
10927da8b7e3Smrg		;;
1093e4b60806Smrg	ppcle-* | powerpclittle-*)
1094e4b60806Smrg		cpu=powerpcle
10957da8b7e3Smrg		;;
1096e4b60806Smrg	ppc64-*)
1097e4b60806Smrg		cpu=powerpc64
10987da8b7e3Smrg		;;
1099e4b60806Smrg	ppc64le-* | powerpc64little-*)
1100e4b60806Smrg		cpu=powerpc64le
11017da8b7e3Smrg		;;
1102e4b60806Smrg	sb1-*)
1103e4b60806Smrg		cpu=mipsisa64sb1
11047da8b7e3Smrg		;;
1105e4b60806Smrg	sb1el-*)
1106e4b60806Smrg		cpu=mipsisa64sb1el
11077da8b7e3Smrg		;;
1108e4b60806Smrg	sh5e[lb]-*)
1109e4b60806Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11107da8b7e3Smrg		;;
1111e4b60806Smrg	spur-*)
1112e4b60806Smrg		cpu=spur
11137da8b7e3Smrg		;;
1114e4b60806Smrg	strongarm-* | thumb-*)
1115e4b60806Smrg		cpu=arm
11167da8b7e3Smrg		;;
1117e4b60806Smrg	tx39-*)
1118e4b60806Smrg		cpu=mipstx39
1119ff143803Smrg		;;
1120e4b60806Smrg	tx39el-*)
1121e4b60806Smrg		cpu=mipstx39el
11227da8b7e3Smrg		;;
1123e4b60806Smrg	x64-*)
1124e4b60806Smrg		cpu=x86_64
11257da8b7e3Smrg		;;
1126c3d5982aSmrg	xscale-* | xscalee[bl]-*)
1127e4b60806Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11287da8b7e3Smrg		;;
1129e4efb0bcSmrg	arm64-* | aarch64le-*)
1130e4b60806Smrg		cpu=aarch64
11317da8b7e3Smrg		;;
11327da8b7e3Smrg
1133e4b60806Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1134e4b60806Smrg	# company names they are paired with.
1135e4b60806Smrg	cr16-*)
1136e4b60806Smrg		basic_os=${basic_os:-elf}
11377da8b7e3Smrg		;;
1138e4b60806Smrg	crisv32-* | etraxfs*-*)
1139e4b60806Smrg		cpu=crisv32
1140e4b60806Smrg		vendor=axis
11417da8b7e3Smrg		;;
1142e4b60806Smrg	cris-* | etrax*-*)
1143e4b60806Smrg		cpu=cris
1144e4b60806Smrg		vendor=axis
11457da8b7e3Smrg		;;
1146e4b60806Smrg	crx-*)
1147e4b60806Smrg		basic_os=${basic_os:-elf}
11487da8b7e3Smrg		;;
1149e4b60806Smrg	neo-tandem)
1150e4b60806Smrg		cpu=neo
1151e4b60806Smrg		vendor=tandem
11527da8b7e3Smrg		;;
1153e4b60806Smrg	nse-tandem)
1154e4b60806Smrg		cpu=nse
1155e4b60806Smrg		vendor=tandem
11567da8b7e3Smrg		;;
1157e4b60806Smrg	nsr-tandem)
1158e4b60806Smrg		cpu=nsr
1159e4b60806Smrg		vendor=tandem
11607da8b7e3Smrg		;;
1161e4b60806Smrg	nsv-tandem)
1162e4b60806Smrg		cpu=nsv
1163e4b60806Smrg		vendor=tandem
11647da8b7e3Smrg		;;
1165e4b60806Smrg	nsx-tandem)
1166e4b60806Smrg		cpu=nsx
1167e4b60806Smrg		vendor=tandem
11687da8b7e3Smrg		;;
1169e4b60806Smrg	mipsallegrexel-sony)
1170e4b60806Smrg		cpu=mipsallegrexel
1171e4b60806Smrg		vendor=sony
11727da8b7e3Smrg		;;
1173e4b60806Smrg	tile*-*)
1174e4b60806Smrg		basic_os=${basic_os:-linux-gnu}
11757da8b7e3Smrg		;;
1176e4b60806Smrg
11777da8b7e3Smrg	*)
1178e4b60806Smrg		# Recognize the canonical CPU types that are allowed with any
1179e4b60806Smrg		# company name.
1180e4b60806Smrg		case $cpu in
1181e4b60806Smrg			1750a | 580 \
1182e4b60806Smrg			| a29k \
1183e4b60806Smrg			| aarch64 | aarch64_be \
1184e4b60806Smrg			| abacus \
1185e4b60806Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1186e4b60806Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1187e4b60806Smrg			| alphapca5[67] | alpha64pca5[67] \
1188e4b60806Smrg			| am33_2.0 \
1189e4b60806Smrg			| amdgcn \
1190e4b60806Smrg			| arc | arceb | arc32 | arc64 \
1191e4b60806Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1192e4b60806Smrg			| avr | avr32 \
1193e4b60806Smrg			| asmjs \
1194e4b60806Smrg			| ba \
1195e4b60806Smrg			| be32 | be64 \
1196e4b60806Smrg			| bfin | bpf | bs2000 \
1197e4b60806Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1198e4b60806Smrg			| c8051 | clipper | craynv | csky | cydra \
1199e4b60806Smrg			| d10v | d30v | dlx | dsp16xx \
1200e4b60806Smrg			| e2k | elxsi | epiphany \
1201e4b60806Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1202e4b60806Smrg			| h8300 | h8500 \
1203e4b60806Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1204e4b60806Smrg			| hexagon \
1205e4b60806Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1206e4b60806Smrg			| ip2k | iq2000 \
1207e4b60806Smrg			| k1om \
1208e4b60806Smrg			| le32 | le64 \
1209e4b60806Smrg			| lm32 \
1210e4efb0bcSmrg			| loongarch32 | loongarch64 \
1211e4b60806Smrg			| m32c | m32r | m32rle \
1212e4b60806Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1213e4b60806Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1214e4b60806Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1215e4b60806Smrg			| microblaze | microblazeel \
1216e4b60806Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1217e4b60806Smrg			| mips16 \
1218e4b60806Smrg			| mips64 | mips64eb | mips64el \
1219e4b60806Smrg			| mips64octeon | mips64octeonel \
1220e4b60806Smrg			| mips64orion | mips64orionel \
1221e4b60806Smrg			| mips64r5900 | mips64r5900el \
1222e4b60806Smrg			| mips64vr | mips64vrel \
1223e4b60806Smrg			| mips64vr4100 | mips64vr4100el \
1224e4b60806Smrg			| mips64vr4300 | mips64vr4300el \
1225e4b60806Smrg			| mips64vr5000 | mips64vr5000el \
1226e4b60806Smrg			| mips64vr5900 | mips64vr5900el \
1227e4b60806Smrg			| mipsisa32 | mipsisa32el \
1228e4b60806Smrg			| mipsisa32r2 | mipsisa32r2el \
1229e4b60806Smrg			| mipsisa32r3 | mipsisa32r3el \
1230e4b60806Smrg			| mipsisa32r5 | mipsisa32r5el \
1231e4b60806Smrg			| mipsisa32r6 | mipsisa32r6el \
1232e4b60806Smrg			| mipsisa64 | mipsisa64el \
1233e4b60806Smrg			| mipsisa64r2 | mipsisa64r2el \
1234e4b60806Smrg			| mipsisa64r3 | mipsisa64r3el \
1235e4b60806Smrg			| mipsisa64r5 | mipsisa64r5el \
1236e4b60806Smrg			| mipsisa64r6 | mipsisa64r6el \
1237e4b60806Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1238e4b60806Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1239e4b60806Smrg			| mipsr5900 | mipsr5900el \
1240e4b60806Smrg			| mipstx39 | mipstx39el \
1241e4b60806Smrg			| mmix \
1242e4b60806Smrg			| mn10200 | mn10300 \
1243e4b60806Smrg			| moxie \
1244e4b60806Smrg			| mt \
1245e4b60806Smrg			| msp430 \
1246e4b60806Smrg			| nds32 | nds32le | nds32be \
1247e4b60806Smrg			| nfp \
1248e4b60806Smrg			| nios | nios2 | nios2eb | nios2el \
1249e4b60806Smrg			| none | np1 | ns16k | ns32k | nvptx \
1250e4b60806Smrg			| open8 \
1251e4b60806Smrg			| or1k* \
1252e4b60806Smrg			| or32 \
1253e4b60806Smrg			| orion \
1254e4b60806Smrg			| picochip \
1255e4b60806Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1256e4b60806Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1257e4b60806Smrg			| pru \
1258e4b60806Smrg			| pyramid \
1259e4b60806Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1260e4b60806Smrg			| rl78 | romp | rs6000 | rx \
1261e4b60806Smrg			| s390 | s390x \
1262e4b60806Smrg			| score \
1263e4b60806Smrg			| sh | shl \
1264e4b60806Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1265e4b60806Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1266e4b60806Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1267e4b60806Smrg			| sparclite \
1268e4b60806Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1269e4b60806Smrg			| spu \
1270e4b60806Smrg			| tahoe \
1271e4b60806Smrg			| thumbv7* \
1272e4b60806Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1273e4b60806Smrg			| tron \
1274e4b60806Smrg			| ubicom32 \
1275e4b60806Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1276e4b60806Smrg			| vax \
1277e4b60806Smrg			| visium \
1278e4b60806Smrg			| w65 \
1279e4b60806Smrg			| wasm32 | wasm64 \
1280e4b60806Smrg			| we32k \
1281e4b60806Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1282e4b60806Smrg			| xstormy16 | xtensa* \
1283e4b60806Smrg			| ymp \
1284e4b60806Smrg			| z8k | z80)
1285e4b60806Smrg				;;
1286e4b60806Smrg
1287e4b60806Smrg			*)
1288e4b60806Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1289e4b60806Smrg				exit 1
1290e4b60806Smrg				;;
1291e4b60806Smrg		esac
12927da8b7e3Smrg		;;
12937da8b7e3Smrgesac
12947da8b7e3Smrg
12957da8b7e3Smrg# Here we canonicalize certain aliases for manufacturers.
1296e4b60806Smrgcase $vendor in
1297e4b60806Smrg	digital*)
1298e4b60806Smrg		vendor=dec
12997da8b7e3Smrg		;;
1300e4b60806Smrg	commodore*)
1301e4b60806Smrg		vendor=cbm
13027da8b7e3Smrg		;;
13037da8b7e3Smrg	*)
13047da8b7e3Smrg		;;
13057da8b7e3Smrgesac
13067da8b7e3Smrg
13077da8b7e3Smrg# Decode manufacturer-specific aliases for certain operating systems.
13087da8b7e3Smrg
1309e4b60806Smrgif test x$basic_os != x
13107da8b7e3Smrgthen
1311e4b60806Smrg
1312e4efb0bcSmrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1313e4b60806Smrg# set os.
1314e4b60806Smrgcase $basic_os in
1315e4b60806Smrg	gnu/linux*)
1316e4b60806Smrg		kernel=linux
1317e4b60806Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1318e4b60806Smrg		;;
1319e4b60806Smrg	os2-emx)
1320e4b60806Smrg		kernel=os2
1321e4b60806Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1322e4b60806Smrg		;;
1323e4b60806Smrg	nto-qnx*)
1324e4b60806Smrg		kernel=nto
1325e4b60806Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1326e4b60806Smrg		;;
1327e4b60806Smrg	*-*)
1328e4b60806Smrg		# shellcheck disable=SC2162
1329e4b60806Smrg		saved_IFS=$IFS
1330e4b60806Smrg		IFS="-" read kernel os <<EOF
1331e4b60806Smrg$basic_os
1332e4b60806SmrgEOF
1333e4b60806Smrg		IFS=$saved_IFS
1334e4b60806Smrg		;;
1335e4b60806Smrg	# Default OS when just kernel was specified
1336e4b60806Smrg	nto*)
1337e4b60806Smrg		kernel=nto
1338e4b60806Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1339e4b60806Smrg		;;
1340e4b60806Smrg	linux*)
1341e4b60806Smrg		kernel=linux
1342e4b60806Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1343e4b60806Smrg		;;
1344e4efb0bcSmrg	managarm*)
1345e4efb0bcSmrg		kernel=managarm
1346e4efb0bcSmrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1347e4efb0bcSmrg		;;
1348e4b60806Smrg	*)
1349e4b60806Smrg		kernel=
1350e4b60806Smrg		os=$basic_os
1351e4b60806Smrg		;;
1352e4b60806Smrgesac
1353e4b60806Smrg
1354e4b60806Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1355e4b60806Smrg# etc.)
13567da8b7e3Smrgcase $os in
1357ff143803Smrg	# First match some system type aliases that might get confused
1358ff143803Smrg	# with valid system types.
1359e4b60806Smrg	# solaris* is a basic system type, with this one exception.
1360e4b60806Smrg	auroraux)
1361e4b60806Smrg		os=auroraux
1362bded5d25Smrg		;;
1363e4b60806Smrg	bluegene*)
1364e4b60806Smrg		os=cnk
13657da8b7e3Smrg		;;
1366e4b60806Smrg	solaris1 | solaris1.*)
1367e4b60806Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13687da8b7e3Smrg		;;
1369e4b60806Smrg	solaris)
1370e4b60806Smrg		os=solaris2
13717da8b7e3Smrg		;;
1372e4b60806Smrg	unixware*)
1373e4b60806Smrg		os=sysv4.2uw
13747da8b7e3Smrg		;;
1375ff143803Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1376e4b60806Smrg	es1800*)
1377e4b60806Smrg		os=ose
1378ff143803Smrg		;;
1379e4b60806Smrg	# Some version numbers need modification
1380e4b60806Smrg	chorusos*)
1381e4b60806Smrg		os=chorusos
13827da8b7e3Smrg		;;
1383e4b60806Smrg	isc)
1384e4b60806Smrg		os=isc2.2
13857da8b7e3Smrg		;;
1386e4b60806Smrg	sco6)
1387e4b60806Smrg		os=sco5v6
13887da8b7e3Smrg		;;
1389e4b60806Smrg	sco5)
1390e4b60806Smrg		os=sco3.2v5
13917da8b7e3Smrg		;;
1392e4b60806Smrg	sco4)
1393e4b60806Smrg		os=sco3.2v4
13947da8b7e3Smrg		;;
1395e4b60806Smrg	sco3.2.[4-9]*)
1396e4b60806Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13977da8b7e3Smrg		;;
1398e4b60806Smrg	sco*v* | scout)
1399e4b60806Smrg		# Don't match below
14007da8b7e3Smrg		;;
1401e4b60806Smrg	sco*)
1402e4b60806Smrg		os=sco3.2v2
14037da8b7e3Smrg		;;
1404e4b60806Smrg	psos*)
1405e4b60806Smrg		os=psos
14067da8b7e3Smrg		;;
1407e4b60806Smrg	qnx*)
1408e4b60806Smrg		os=qnx
14097da8b7e3Smrg		;;
1410e4b60806Smrg	hiux*)
1411e4b60806Smrg		os=hiuxwe2
14127da8b7e3Smrg		;;
1413e4b60806Smrg	lynx*178)
1414e4b60806Smrg		os=lynxos178
14157da8b7e3Smrg		;;
1416e4b60806Smrg	lynx*5)
1417e4b60806Smrg		os=lynxos5
14187da8b7e3Smrg		;;
1419e4b60806Smrg	lynxos*)
1420e4b60806Smrg		# don't get caught up in next wildcard
14217da8b7e3Smrg		;;
1422e4b60806Smrg	lynx*)
1423e4b60806Smrg		os=lynxos
14247da8b7e3Smrg		;;
1425e4b60806Smrg	mac[0-9]*)
1426e4b60806Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14277da8b7e3Smrg		;;
1428e4b60806Smrg	opened*)
1429e4b60806Smrg		os=openedition
14307da8b7e3Smrg		;;
1431e4b60806Smrg	os400*)
1432e4b60806Smrg		os=os400
14337da8b7e3Smrg		;;
1434e4b60806Smrg	sunos5*)
1435e4b60806Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
14367da8b7e3Smrg		;;
1437e4b60806Smrg	sunos6*)
1438e4b60806Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14397da8b7e3Smrg		;;
1440e4b60806Smrg	wince*)
1441e4b60806Smrg		os=wince
14427da8b7e3Smrg		;;
1443e4b60806Smrg	utek*)
1444e4b60806Smrg		os=bsd
14457da8b7e3Smrg		;;
1446e4b60806Smrg	dynix*)
1447e4b60806Smrg		os=bsd
14487da8b7e3Smrg		;;
1449e4b60806Smrg	acis*)
1450e4b60806Smrg		os=aos
14517da8b7e3Smrg		;;
1452e4b60806Smrg	atheos*)
1453e4b60806Smrg		os=atheos
14547da8b7e3Smrg		;;
1455e4b60806Smrg	syllable*)
1456e4b60806Smrg		os=syllable
1457e4b60806Smrg		;;
1458e4b60806Smrg	386bsd)
1459e4b60806Smrg		os=bsd
1460e4b60806Smrg		;;
1461e4b60806Smrg	ctix* | uts*)
1462e4b60806Smrg		os=sysv
1463e4b60806Smrg		;;
1464e4b60806Smrg	nova*)
1465e4b60806Smrg		os=rtmk-nova
1466e4b60806Smrg		;;
1467e4b60806Smrg	ns2)
1468e4b60806Smrg		os=nextstep2
1469e4b60806Smrg		;;
1470e4b60806Smrg	# Preserve the version number of sinix5.
1471e4b60806Smrg	sinix5.*)
1472e4b60806Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14737da8b7e3Smrg		;;
1474e4b60806Smrg	sinix*)
1475e4b60806Smrg		os=sysv4
14767da8b7e3Smrg		;;
1477e4b60806Smrg	tpf*)
1478e4b60806Smrg		os=tpf
14797da8b7e3Smrg		;;
1480e4b60806Smrg	triton*)
1481e4b60806Smrg		os=sysv3
14827da8b7e3Smrg		;;
1483e4b60806Smrg	oss*)
1484e4b60806Smrg		os=sysv3
14857da8b7e3Smrg		;;
1486e4b60806Smrg	svr4*)
1487e4b60806Smrg		os=sysv4
14887da8b7e3Smrg		;;
1489e4b60806Smrg	svr3)
1490e4b60806Smrg		os=sysv3
14917da8b7e3Smrg		;;
1492e4b60806Smrg	sysvr4)
1493e4b60806Smrg		os=sysv4
14947da8b7e3Smrg		;;
1495e4b60806Smrg	ose*)
1496e4b60806Smrg		os=ose
14977da8b7e3Smrg		;;
1498e4b60806Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1499e4b60806Smrg		os=mint
1500123e2cc7Smrg		;;
1501e4b60806Smrg	dicos*)
1502e4b60806Smrg		os=dicos
1503e4b60806Smrg		;;
1504e4b60806Smrg	pikeos*)
1505ff143803Smrg		# Until real need of OS specific support for
1506ff143803Smrg		# particular features comes up, bare metal
1507ff143803Smrg		# configurations are quite functional.
1508e4b60806Smrg		case $cpu in
1509ff143803Smrg		    arm*)
1510e4b60806Smrg			os=eabi
1511ff143803Smrg			;;
1512ff143803Smrg		    *)
1513e4b60806Smrg			os=elf
1514ff143803Smrg			;;
1515ff143803Smrg		esac
1516ff143803Smrg		;;
15177da8b7e3Smrg	*)
1518e4b60806Smrg		# No normalization, but not necessarily accepted, that comes below.
15197da8b7e3Smrg		;;
15207da8b7e3Smrgesac
1521e4b60806Smrg
15227da8b7e3Smrgelse
15237da8b7e3Smrg
15247da8b7e3Smrg# Here we handle the default operating systems that come with various machines.
15257da8b7e3Smrg# The value should be what the vendor currently ships out the door with their
15267da8b7e3Smrg# machine or put another way, the most popular os provided with the machine.
15277da8b7e3Smrg
15287da8b7e3Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15297da8b7e3Smrg# "-sun"), then you have to tell the case statement up towards the top
15307da8b7e3Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15317da8b7e3Smrg# will signal an error saying that MANUFACTURER isn't an operating
15327da8b7e3Smrg# system, and we'll never get to this point.
15337da8b7e3Smrg
1534e4b60806Smrgkernel=
1535e4b60806Smrgcase $cpu-$vendor in
1536c3d5982aSmrg	score-*)
1537e4b60806Smrg		os=elf
1538123e2cc7Smrg		;;
1539c3d5982aSmrg	spu-*)
1540e4b60806Smrg		os=elf
1541123e2cc7Smrg		;;
15427da8b7e3Smrg	*-acorn)
1543e4b60806Smrg		os=riscix1.2
15447da8b7e3Smrg		;;
15457da8b7e3Smrg	arm*-rebel)
1546e4b60806Smrg		kernel=linux
1547e4b60806Smrg		os=gnu
15487da8b7e3Smrg		;;
15497da8b7e3Smrg	arm*-semi)
1550e4b60806Smrg		os=aout
15517da8b7e3Smrg		;;
1552c3d5982aSmrg	c4x-* | tic4x-*)
1553e4b60806Smrg		os=coff
1554c3d5982aSmrg		;;
1555ff143803Smrg	c8051-*)
1556e4b60806Smrg		os=elf
1557e4b60806Smrg		;;
1558e4b60806Smrg	clipper-intergraph)
1559e4b60806Smrg		os=clix
1560ff143803Smrg		;;
1561c3d5982aSmrg	hexagon-*)
1562e4b60806Smrg		os=elf
1563123e2cc7Smrg		;;
1564bded5d25Smrg	tic54x-*)
1565e4b60806Smrg		os=coff
1566bded5d25Smrg		;;
1567bded5d25Smrg	tic55x-*)
1568e4b60806Smrg		os=coff
1569bded5d25Smrg		;;
1570bded5d25Smrg	tic6x-*)
1571e4b60806Smrg		os=coff
1572bded5d25Smrg		;;
15737da8b7e3Smrg	# This must come before the *-dec entry.
15747da8b7e3Smrg	pdp10-*)
1575e4b60806Smrg		os=tops20
15767da8b7e3Smrg		;;
15777da8b7e3Smrg	pdp11-*)
1578e4b60806Smrg		os=none
15797da8b7e3Smrg		;;
15807da8b7e3Smrg	*-dec | vax-*)
1581e4b60806Smrg		os=ultrix4.2
15827da8b7e3Smrg		;;
15837da8b7e3Smrg	m68*-apollo)
1584e4b60806Smrg		os=domain
15857da8b7e3Smrg		;;
15867da8b7e3Smrg	i386-sun)
1587e4b60806Smrg		os=sunos4.0.2
15887da8b7e3Smrg		;;
15897da8b7e3Smrg	m68000-sun)
1590e4b60806Smrg		os=sunos3
15917da8b7e3Smrg		;;
15927da8b7e3Smrg	m68*-cisco)
1593e4b60806Smrg		os=aout
15947da8b7e3Smrg		;;
1595c3d5982aSmrg	mep-*)
1596e4b60806Smrg		os=elf
1597123e2cc7Smrg		;;
15987da8b7e3Smrg	mips*-cisco)
1599e4b60806Smrg		os=elf
16007da8b7e3Smrg		;;
16017da8b7e3Smrg	mips*-*)
1602e4b60806Smrg		os=elf
16037da8b7e3Smrg		;;
16047da8b7e3Smrg	or32-*)
1605e4b60806Smrg		os=coff
16067da8b7e3Smrg		;;
16077da8b7e3Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1608e4b60806Smrg		os=sysv3
16097da8b7e3Smrg		;;
16107da8b7e3Smrg	sparc-* | *-sun)
1611e4b60806Smrg		os=sunos4.1.1
16127da8b7e3Smrg		;;
1613ff143803Smrg	pru-*)
1614e4b60806Smrg		os=elf
1615ff143803Smrg		;;
16167da8b7e3Smrg	*-be)
1617e4b60806Smrg		os=beos
16187da8b7e3Smrg		;;
16197da8b7e3Smrg	*-ibm)
1620e4b60806Smrg		os=aix
16217da8b7e3Smrg		;;
1622c3d5982aSmrg	*-knuth)
1623e4b60806Smrg		os=mmixware
16247da8b7e3Smrg		;;
16257da8b7e3Smrg	*-wec)
1626e4b60806Smrg		os=proelf
16277da8b7e3Smrg		;;
16287da8b7e3Smrg	*-winbond)
1629e4b60806Smrg		os=proelf
16307da8b7e3Smrg		;;
16317da8b7e3Smrg	*-oki)
1632e4b60806Smrg		os=proelf
16337da8b7e3Smrg		;;
16347da8b7e3Smrg	*-hp)
1635e4b60806Smrg		os=hpux
16367da8b7e3Smrg		;;
16377da8b7e3Smrg	*-hitachi)
1638e4b60806Smrg		os=hiux
16397da8b7e3Smrg		;;
16407da8b7e3Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1641e4b60806Smrg		os=sysv
16427da8b7e3Smrg		;;
16437da8b7e3Smrg	*-cbm)
1644e4b60806Smrg		os=amigaos
16457da8b7e3Smrg		;;
16467da8b7e3Smrg	*-dg)
1647e4b60806Smrg		os=dgux
16487da8b7e3Smrg		;;
16497da8b7e3Smrg	*-dolphin)
1650e4b60806Smrg		os=sysv3
16517da8b7e3Smrg		;;
16527da8b7e3Smrg	m68k-ccur)
1653e4b60806Smrg		os=rtu
16547da8b7e3Smrg		;;
16557da8b7e3Smrg	m88k-omron*)
1656e4b60806Smrg		os=luna
16577da8b7e3Smrg		;;
1658ff143803Smrg	*-next)
1659e4b60806Smrg		os=nextstep
16607da8b7e3Smrg		;;
16617da8b7e3Smrg	*-sequent)
1662e4b60806Smrg		os=ptx
16637da8b7e3Smrg		;;
16647da8b7e3Smrg	*-crds)
1665e4b60806Smrg		os=unos
16667da8b7e3Smrg		;;
16677da8b7e3Smrg	*-ns)
1668e4b60806Smrg		os=genix
16697da8b7e3Smrg		;;
16707da8b7e3Smrg	i370-*)
1671e4b60806Smrg		os=mvs
16727da8b7e3Smrg		;;
16737da8b7e3Smrg	*-gould)
1674e4b60806Smrg		os=sysv
16757da8b7e3Smrg		;;
16767da8b7e3Smrg	*-highlevel)
1677e4b60806Smrg		os=bsd
16787da8b7e3Smrg		;;
16797da8b7e3Smrg	*-encore)
1680e4b60806Smrg		os=bsd
16817da8b7e3Smrg		;;
16827da8b7e3Smrg	*-sgi)
1683e4b60806Smrg		os=irix
16847da8b7e3Smrg		;;
16857da8b7e3Smrg	*-siemens)
1686e4b60806Smrg		os=sysv4
16877da8b7e3Smrg		;;
16887da8b7e3Smrg	*-masscomp)
1689e4b60806Smrg		os=rtu
16907da8b7e3Smrg		;;
16917da8b7e3Smrg	f30[01]-fujitsu | f700-fujitsu)
1692e4b60806Smrg		os=uxpv
16937da8b7e3Smrg		;;
16947da8b7e3Smrg	*-rom68k)
1695e4b60806Smrg		os=coff
16967da8b7e3Smrg		;;
16977da8b7e3Smrg	*-*bug)
1698e4b60806Smrg		os=coff
16997da8b7e3Smrg		;;
17007da8b7e3Smrg	*-apple)
1701e4b60806Smrg		os=macos
17027da8b7e3Smrg		;;
17037da8b7e3Smrg	*-atari*)
1704e4b60806Smrg		os=mint
1705e4b60806Smrg		;;
1706e4b60806Smrg	*-wrs)
1707e4b60806Smrg		os=vxworks
17087da8b7e3Smrg		;;
17097da8b7e3Smrg	*)
1710e4b60806Smrg		os=none
17117da8b7e3Smrg		;;
17127da8b7e3Smrgesac
1713e4b60806Smrg
17147da8b7e3Smrgfi
17157da8b7e3Smrg
1716e4b60806Smrg# Now, validate our (potentially fixed-up) OS.
1717e4b60806Smrgcase $os in
1718e4b60806Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1719e4b60806Smrg	musl* | newlib* | relibc* | uclibc*)
1720e4b60806Smrg		;;
1721e4b60806Smrg	# Likewise for "kernel-abi"
1722e4b60806Smrg	eabi* | gnueabi*)
1723e4b60806Smrg		;;
1724e4b60806Smrg	# VxWorks passes extra cpu info in the 4th filed.
1725e4b60806Smrg	simlinux | simwindows | spe)
1726e4b60806Smrg		;;
1727e4b60806Smrg	# Now accept the basic system types.
1728e4b60806Smrg	# The portable systems comes first.
1729e4b60806Smrg	# Each alternative MUST end in a * to match a version number.
1730e4b60806Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1731e4b60806Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1732e4b60806Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1733e4b60806Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1734e4b60806Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1735e4b60806Smrg	     | os9* | macos* | osx* | ios* \
1736e4b60806Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1737e4b60806Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1738e4b60806Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1739e4b60806Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1740e4b60806Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1741e4b60806Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1742e4b60806Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1743e4b60806Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1744e4b60806Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1745e4b60806Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1746e4b60806Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1747e4b60806Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1748e4b60806Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1749e4b60806Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1750e4b60806Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1751e4b60806Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1752e4b60806Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1753e4b60806Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1754e4b60806Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1755e4b60806Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1756e4b60806Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1757e4b60806Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1758e4b60806Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1759e4b60806Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1760e4efb0bcSmrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761e4efb0bcSmrg	     | fiwix* | mlibc* )
1762e4b60806Smrg		;;
1763e4b60806Smrg	# This one is extra strict with allowed versions
1764e4b60806Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1765e4b60806Smrg		# Don't forget version if it is 3.2v4 or newer.
1766e4b60806Smrg		;;
1767e4b60806Smrg	none)
1768e4b60806Smrg		;;
1769e4efb0bcSmrg	kernel* )
1770e4efb0bcSmrg		# Restricted further below
1771e4efb0bcSmrg		;;
1772e4b60806Smrg	*)
1773e4b60806Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1774e4b60806Smrg		exit 1
1775e4b60806Smrg		;;
1776e4b60806Smrgesac
1777e4b60806Smrg
1778e4b60806Smrg# As a final step for OS-related things, validate the OS-kernel combination
1779e4b60806Smrg# (given a valid OS), if there is a kernel.
1780e4b60806Smrgcase $kernel-$os in
1781e4b60806Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782e4efb0bcSmrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
1783e4b60806Smrg		;;
1784e4b60806Smrg	uclinux-uclibc* )
1785e4b60806Smrg		;;
1786e4efb0bcSmrg	managarm-mlibc* | managarm-kernel* )
1787e4efb0bcSmrg		;;
1788e4efb0bcSmrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
1789e4b60806Smrg		# These are just libc implementations, not actual OSes, and thus
1790e4b60806Smrg		# require a kernel.
1791e4b60806Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1792e4b60806Smrg		exit 1
1793e4b60806Smrg		;;
1794e4efb0bcSmrg	-kernel* )
1795e4efb0bcSmrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
1796e4efb0bcSmrg		exit 1
1797e4efb0bcSmrg		;;
1798e4efb0bcSmrg	*-kernel* )
1799e4efb0bcSmrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
1800e4efb0bcSmrg		exit 1
1801e4efb0bcSmrg		;;
1802e4b60806Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1803e4b60806Smrg		;;
1804e4b60806Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1805e4b60806Smrg		;;
1806e4b60806Smrg	nto-qnx*)
1807e4b60806Smrg		;;
1808e4b60806Smrg	os2-emx)
1809e4b60806Smrg		;;
1810e4b60806Smrg	*-eabi* | *-gnueabi*)
1811e4b60806Smrg		;;
1812e4b60806Smrg	-*)
1813e4b60806Smrg		# Blank kernel with real OS is always fine.
1814e4b60806Smrg		;;
1815e4b60806Smrg	*-*)
1816e4b60806Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1817e4b60806Smrg		exit 1
1818e4b60806Smrg		;;
1819e4b60806Smrgesac
1820e4b60806Smrg
18217da8b7e3Smrg# Here we handle the case where we know the os, and the CPU type, but not the
18227da8b7e3Smrg# manufacturer.  We pick the logical manufacturer.
1823e4b60806Smrgcase $vendor in
1824e4b60806Smrg	unknown)
1825e4b60806Smrg		case $cpu-$os in
1826e4b60806Smrg			*-riscix*)
18277da8b7e3Smrg				vendor=acorn
18287da8b7e3Smrg				;;
1829e4b60806Smrg			*-sunos*)
18307da8b7e3Smrg				vendor=sun
18317da8b7e3Smrg				;;
1832e4b60806Smrg			*-cnk* | *-aix*)
18337da8b7e3Smrg				vendor=ibm
18347da8b7e3Smrg				;;
1835e4b60806Smrg			*-beos*)
18367da8b7e3Smrg				vendor=be
18377da8b7e3Smrg				;;
1838e4b60806Smrg			*-hpux*)
18397da8b7e3Smrg				vendor=hp
18407da8b7e3Smrg				;;
1841e4b60806Smrg			*-mpeix*)
18427da8b7e3Smrg				vendor=hp
18437da8b7e3Smrg				;;
1844e4b60806Smrg			*-hiux*)
18457da8b7e3Smrg				vendor=hitachi
18467da8b7e3Smrg				;;
1847e4b60806Smrg			*-unos*)
18487da8b7e3Smrg				vendor=crds
18497da8b7e3Smrg				;;
1850e4b60806Smrg			*-dgux*)
18517da8b7e3Smrg				vendor=dg
18527da8b7e3Smrg				;;
1853e4b60806Smrg			*-luna*)
18547da8b7e3Smrg				vendor=omron
18557da8b7e3Smrg				;;
1856e4b60806Smrg			*-genix*)
18577da8b7e3Smrg				vendor=ns
18587da8b7e3Smrg				;;
1859e4b60806Smrg			*-clix*)
1860e4b60806Smrg				vendor=intergraph
1861e4b60806Smrg				;;
1862e4b60806Smrg			*-mvs* | *-opened*)
1863e4b60806Smrg				vendor=ibm
1864e4b60806Smrg				;;
1865e4b60806Smrg			*-os400*)
18667da8b7e3Smrg				vendor=ibm
18677da8b7e3Smrg				;;
1868e4b60806Smrg			s390-* | s390x-*)
18697da8b7e3Smrg				vendor=ibm
18707da8b7e3Smrg				;;
1871e4b60806Smrg			*-ptx*)
18727da8b7e3Smrg				vendor=sequent
18737da8b7e3Smrg				;;
1874e4b60806Smrg			*-tpf*)
18757da8b7e3Smrg				vendor=ibm
18767da8b7e3Smrg				;;
1877e4b60806Smrg			*-vxsim* | *-vxworks* | *-windiss*)
18787da8b7e3Smrg				vendor=wrs
18797da8b7e3Smrg				;;
1880e4b60806Smrg			*-aux*)
18817da8b7e3Smrg				vendor=apple
18827da8b7e3Smrg				;;
1883e4b60806Smrg			*-hms*)
18847da8b7e3Smrg				vendor=hitachi
18857da8b7e3Smrg				;;
1886e4b60806Smrg			*-mpw* | *-macos*)
18877da8b7e3Smrg				vendor=apple
18887da8b7e3Smrg				;;
1889e4b60806Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
18907da8b7e3Smrg				vendor=atari
18917da8b7e3Smrg				;;
1892e4b60806Smrg			*-vos*)
18937da8b7e3Smrg				vendor=stratus
18947da8b7e3Smrg				;;
18957da8b7e3Smrg		esac
18967da8b7e3Smrg		;;
18977da8b7e3Smrgesac
18987da8b7e3Smrg
1899e4b60806Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
19007da8b7e3Smrgexit
19017da8b7e3Smrg
19027da8b7e3Smrg# Local variables:
1903e4b60806Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
19047da8b7e3Smrg# time-stamp-start: "timestamp='"
19057da8b7e3Smrg# time-stamp-format: "%:y-%02m-%02d"
19067da8b7e3Smrg# time-stamp-end: "'"
19077da8b7e3Smrg# End:
1908