121c2f794Smrg#! /bin/sh
221c2f794Smrg# Configuration validation subroutine script.
3889a2364Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
421c2f794Smrg
5889a2364Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6889a2364Smrg
7889a2364Smrgtimestamp='2021-08-14'
821c2f794Smrg
91b2353dbSmrg# This file is free software; you can redistribute it and/or modify it
101b2353dbSmrg# under the terms of the GNU General Public License as published by
111b2353dbSmrg# the Free Software Foundation; either version 3 of the License, or
1221c2f794Smrg# (at your option) any later version.
1321c2f794Smrg#
141b2353dbSmrg# This program is distributed in the hope that it will be useful, but
151b2353dbSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
161b2353dbSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
171b2353dbSmrg# General Public License for more details.
1821c2f794Smrg#
1921c2f794Smrg# You should have received a copy of the GNU General Public License
20889a2364Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2121c2f794Smrg#
2221c2f794Smrg# As a special exception to the GNU General Public License, if you
2321c2f794Smrg# distribute this file as part of a program that contains a
2421c2f794Smrg# configuration script generated by Autoconf, you may include it under
251b2353dbSmrg# the same distribution terms that you use for the rest of that
261b2353dbSmrg# program.  This Exception is an additional permission under section 7
271b2353dbSmrg# of the GNU General Public License, version 3 ("GPLv3").
2821c2f794Smrg
2921c2f794Smrg
30889a2364Smrg# Please send patches to <config-patches@gnu.org>.
3121c2f794Smrg#
3221c2f794Smrg# Configuration subroutine to validate and canonicalize a configuration type.
3321c2f794Smrg# Supply the specified configuration type as an argument.
3421c2f794Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
3521c2f794Smrg# Otherwise, we print the canonical config type on stdout and succeed.
3621c2f794Smrg
3712391620Smrg# You can get the latest version of this script from:
38889a2364Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3912391620Smrg
4021c2f794Smrg# This file is supposed to be the same for all GNU packages
4121c2f794Smrg# and recognize all the CPU types, system types and aliases
4221c2f794Smrg# that are meaningful with *any* GNU software.
4321c2f794Smrg# Each package is responsible for reporting which valid configurations
4421c2f794Smrg# it does not support.  The user should be able to distinguish
4521c2f794Smrg# a failure to support a valid configuration from a meaningless
4621c2f794Smrg# configuration.
4721c2f794Smrg
4821c2f794Smrg# The goal of this file is to map all the various variations of a given
4921c2f794Smrg# machine specification into a single specification in the form:
5021c2f794Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
5121c2f794Smrg# or in some cases, the newer four-part form:
5221c2f794Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
5321c2f794Smrg# It is wrong to echo any other type of specification.
5421c2f794Smrg
55889a2364Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56889a2364Smrg# about features and limitations of the classic Bourne shell that were
57889a2364Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58889a2364Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59889a2364Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60889a2364Smrg# have a pre-POSIX /bin/sh.
61889a2364Smrg
6221c2f794Smrgme=`echo "$0" | sed -e 's,.*/,,'`
6321c2f794Smrg
6421c2f794Smrgusage="\
65889a2364SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
6621c2f794Smrg
6721c2f794SmrgCanonicalize a configuration name.
6821c2f794Smrg
69889a2364SmrgOptions:
7021c2f794Smrg  -h, --help         print this help, then exit
7121c2f794Smrg  -t, --time-stamp   print date of last modification, then exit
7221c2f794Smrg  -v, --version      print version number, then exit
7321c2f794Smrg
7421c2f794SmrgReport bugs and patches to <config-patches@gnu.org>."
7521c2f794Smrg
7621c2f794Smrgversion="\
7721c2f794SmrgGNU config.sub ($timestamp)
7821c2f794Smrg
79889a2364SmrgCopyright 1992-2021 Free Software Foundation, Inc.
8021c2f794Smrg
8121c2f794SmrgThis is free software; see the source for copying conditions.  There is NO
8221c2f794Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
8321c2f794Smrg
8421c2f794Smrghelp="
8521c2f794SmrgTry \`$me --help' for more information."
8621c2f794Smrg
8721c2f794Smrg# Parse command line
8821c2f794Smrgwhile test $# -gt 0 ; do
8921c2f794Smrg  case $1 in
9021c2f794Smrg    --time-stamp | --time* | -t )
9121c2f794Smrg       echo "$timestamp" ; exit ;;
9221c2f794Smrg    --version | -v )
9321c2f794Smrg       echo "$version" ; exit ;;
9421c2f794Smrg    --help | --h* | -h )
9521c2f794Smrg       echo "$usage"; exit ;;
9621c2f794Smrg    -- )     # Stop option processing
9721c2f794Smrg       shift; break ;;
9821c2f794Smrg    - )	# Use stdin as input.
9921c2f794Smrg       break ;;
10021c2f794Smrg    -* )
101889a2364Smrg       echo "$me: invalid option $1$help" >&2
10221c2f794Smrg       exit 1 ;;
10321c2f794Smrg
10421c2f794Smrg    *local*)
10521c2f794Smrg       # First pass through any local machine types.
106889a2364Smrg       echo "$1"
10721c2f794Smrg       exit ;;
10821c2f794Smrg
10921c2f794Smrg    * )
11021c2f794Smrg       break ;;
11121c2f794Smrg  esac
11221c2f794Smrgdone
11321c2f794Smrg
11421c2f794Smrgcase $# in
11521c2f794Smrg 0) echo "$me: missing argument$help" >&2
11621c2f794Smrg    exit 1;;
11721c2f794Smrg 1) ;;
11821c2f794Smrg *) echo "$me: too many arguments$help" >&2
11921c2f794Smrg    exit 1;;
12021c2f794Smrgesac
12121c2f794Smrg
122889a2364Smrg# Split fields of configuration type
123889a2364Smrg# shellcheck disable=SC2162
124889a2364Smrgsaved_IFS=$IFS
125889a2364SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126889a2364Smrg$1
127889a2364SmrgEOF
128889a2364SmrgIFS=$saved_IFS
12921c2f794Smrg
130889a2364Smrg# Separate into logical components for further validation
131889a2364Smrgcase $1 in
132889a2364Smrg	*-*-*-*-*)
133889a2364Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134889a2364Smrg		exit 1
13521c2f794Smrg		;;
136889a2364Smrg	*-*-*-*)
137889a2364Smrg		basic_machine=$field1-$field2
138889a2364Smrg		basic_os=$field3-$field4
13921c2f794Smrg		;;
140889a2364Smrg	*-*-*)
141889a2364Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142889a2364Smrg		# parts
143889a2364Smrg		maybe_os=$field2-$field3
144889a2364Smrg		case $maybe_os in
145889a2364Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146889a2364Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147889a2364Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148889a2364Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
149889a2364Smrg				basic_machine=$field1
150889a2364Smrg				basic_os=$maybe_os
151889a2364Smrg				;;
152889a2364Smrg			android-linux)
153889a2364Smrg				basic_machine=$field1-unknown
154889a2364Smrg				basic_os=linux-android
155889a2364Smrg				;;
156889a2364Smrg			*)
157889a2364Smrg				basic_machine=$field1-$field2
158889a2364Smrg				basic_os=$field3
159889a2364Smrg				;;
160889a2364Smrg		esac
16121c2f794Smrg		;;
162889a2364Smrg	*-*)
163889a2364Smrg		# A lone config we happen to match not fitting any pattern
164889a2364Smrg		case $field1-$field2 in
165889a2364Smrg			decstation-3100)
166889a2364Smrg				basic_machine=mips-dec
167889a2364Smrg				basic_os=
168889a2364Smrg				;;
169889a2364Smrg			*-*)
170889a2364Smrg				# Second component is usually, but not always the OS
171889a2364Smrg				case $field2 in
172889a2364Smrg					# Prevent following clause from handling this valid os
173889a2364Smrg					sun*os*)
174889a2364Smrg						basic_machine=$field1
175889a2364Smrg						basic_os=$field2
176889a2364Smrg						;;
177889a2364Smrg					zephyr*)
178889a2364Smrg						basic_machine=$field1-unknown
179889a2364Smrg						basic_os=$field2
180889a2364Smrg						;;
181889a2364Smrg					# Manufacturers
182889a2364Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183889a2364Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184889a2364Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185889a2364Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186889a2364Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187889a2364Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188889a2364Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189889a2364Smrg					| microblaze* | sim | cisco \
190889a2364Smrg					| oki | wec | wrs | winbond)
191889a2364Smrg						basic_machine=$field1-$field2
192889a2364Smrg						basic_os=
193889a2364Smrg						;;
194889a2364Smrg					*)
195889a2364Smrg						basic_machine=$field1
196889a2364Smrg						basic_os=$field2
197889a2364Smrg						;;
198889a2364Smrg				esac
199889a2364Smrg			;;
200889a2364Smrg		esac
20121c2f794Smrg		;;
202889a2364Smrg	*)
203889a2364Smrg		# Convert single-component short-hands not valid as part of
204889a2364Smrg		# multi-component configurations.
205889a2364Smrg		case $field1 in
206889a2364Smrg			386bsd)
207889a2364Smrg				basic_machine=i386-pc
208889a2364Smrg				basic_os=bsd
209889a2364Smrg				;;
210889a2364Smrg			a29khif)
211889a2364Smrg				basic_machine=a29k-amd
212889a2364Smrg				basic_os=udi
213889a2364Smrg				;;
214889a2364Smrg			adobe68k)
215889a2364Smrg				basic_machine=m68010-adobe
216889a2364Smrg				basic_os=scout
217889a2364Smrg				;;
218889a2364Smrg			alliant)
219889a2364Smrg				basic_machine=fx80-alliant
220889a2364Smrg				basic_os=
221889a2364Smrg				;;
222889a2364Smrg			altos | altos3068)
223889a2364Smrg				basic_machine=m68k-altos
224889a2364Smrg				basic_os=
225889a2364Smrg				;;
226889a2364Smrg			am29k)
227889a2364Smrg				basic_machine=a29k-none
228889a2364Smrg				basic_os=bsd
229889a2364Smrg				;;
230889a2364Smrg			amdahl)
231889a2364Smrg				basic_machine=580-amdahl
232889a2364Smrg				basic_os=sysv
233889a2364Smrg				;;
234889a2364Smrg			amiga)
235889a2364Smrg				basic_machine=m68k-unknown
236889a2364Smrg				basic_os=
237889a2364Smrg				;;
238889a2364Smrg			amigaos | amigados)
239889a2364Smrg				basic_machine=m68k-unknown
240889a2364Smrg				basic_os=amigaos
241889a2364Smrg				;;
242889a2364Smrg			amigaunix | amix)
243889a2364Smrg				basic_machine=m68k-unknown
244889a2364Smrg				basic_os=sysv4
245889a2364Smrg				;;
246889a2364Smrg			apollo68)
247889a2364Smrg				basic_machine=m68k-apollo
248889a2364Smrg				basic_os=sysv
249889a2364Smrg				;;
250889a2364Smrg			apollo68bsd)
251889a2364Smrg				basic_machine=m68k-apollo
252889a2364Smrg				basic_os=bsd
253889a2364Smrg				;;
254889a2364Smrg			aros)
255889a2364Smrg				basic_machine=i386-pc
256889a2364Smrg				basic_os=aros
257889a2364Smrg				;;
258889a2364Smrg			aux)
259889a2364Smrg				basic_machine=m68k-apple
260889a2364Smrg				basic_os=aux
261889a2364Smrg				;;
262889a2364Smrg			balance)
263889a2364Smrg				basic_machine=ns32k-sequent
264889a2364Smrg				basic_os=dynix
265889a2364Smrg				;;
266889a2364Smrg			blackfin)
267889a2364Smrg				basic_machine=bfin-unknown
268889a2364Smrg				basic_os=linux
269889a2364Smrg				;;
270889a2364Smrg			cegcc)
271889a2364Smrg				basic_machine=arm-unknown
272889a2364Smrg				basic_os=cegcc
273889a2364Smrg				;;
274889a2364Smrg			convex-c1)
275889a2364Smrg				basic_machine=c1-convex
276889a2364Smrg				basic_os=bsd
277889a2364Smrg				;;
278889a2364Smrg			convex-c2)
279889a2364Smrg				basic_machine=c2-convex
280889a2364Smrg				basic_os=bsd
281889a2364Smrg				;;
282889a2364Smrg			convex-c32)
283889a2364Smrg				basic_machine=c32-convex
284889a2364Smrg				basic_os=bsd
285889a2364Smrg				;;
286889a2364Smrg			convex-c34)
287889a2364Smrg				basic_machine=c34-convex
288889a2364Smrg				basic_os=bsd
289889a2364Smrg				;;
290889a2364Smrg			convex-c38)
291889a2364Smrg				basic_machine=c38-convex
292889a2364Smrg				basic_os=bsd
293889a2364Smrg				;;
294889a2364Smrg			cray)
295889a2364Smrg				basic_machine=j90-cray
296889a2364Smrg				basic_os=unicos
297889a2364Smrg				;;
298889a2364Smrg			crds | unos)
299889a2364Smrg				basic_machine=m68k-crds
300889a2364Smrg				basic_os=
301889a2364Smrg				;;
302889a2364Smrg			da30)
303889a2364Smrg				basic_machine=m68k-da30
304889a2364Smrg				basic_os=
305889a2364Smrg				;;
306889a2364Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307889a2364Smrg				basic_machine=mips-dec
308889a2364Smrg				basic_os=
309889a2364Smrg				;;
310889a2364Smrg			delta88)
311889a2364Smrg				basic_machine=m88k-motorola
312889a2364Smrg				basic_os=sysv3
313889a2364Smrg				;;
314889a2364Smrg			dicos)
315889a2364Smrg				basic_machine=i686-pc
316889a2364Smrg				basic_os=dicos
317889a2364Smrg				;;
318889a2364Smrg			djgpp)
319889a2364Smrg				basic_machine=i586-pc
320889a2364Smrg				basic_os=msdosdjgpp
321889a2364Smrg				;;
322889a2364Smrg			ebmon29k)
323889a2364Smrg				basic_machine=a29k-amd
324889a2364Smrg				basic_os=ebmon
325889a2364Smrg				;;
326889a2364Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327889a2364Smrg				basic_machine=m68k-ericsson
328889a2364Smrg				basic_os=ose
329889a2364Smrg				;;
330889a2364Smrg			gmicro)
331889a2364Smrg				basic_machine=tron-gmicro
332889a2364Smrg				basic_os=sysv
333889a2364Smrg				;;
334889a2364Smrg			go32)
335889a2364Smrg				basic_machine=i386-pc
336889a2364Smrg				basic_os=go32
337889a2364Smrg				;;
338889a2364Smrg			h8300hms)
339889a2364Smrg				basic_machine=h8300-hitachi
340889a2364Smrg				basic_os=hms
341889a2364Smrg				;;
342889a2364Smrg			h8300xray)
343889a2364Smrg				basic_machine=h8300-hitachi
344889a2364Smrg				basic_os=xray
345889a2364Smrg				;;
346889a2364Smrg			h8500hms)
347889a2364Smrg				basic_machine=h8500-hitachi
348889a2364Smrg				basic_os=hms
349889a2364Smrg				;;
350889a2364Smrg			harris)
351889a2364Smrg				basic_machine=m88k-harris
352889a2364Smrg				basic_os=sysv3
353889a2364Smrg				;;
354889a2364Smrg			hp300 | hp300hpux)
355889a2364Smrg				basic_machine=m68k-hp
356889a2364Smrg				basic_os=hpux
357889a2364Smrg				;;
358889a2364Smrg			hp300bsd)
359889a2364Smrg				basic_machine=m68k-hp
360889a2364Smrg				basic_os=bsd
361889a2364Smrg				;;
362889a2364Smrg			hppaosf)
363889a2364Smrg				basic_machine=hppa1.1-hp
364889a2364Smrg				basic_os=osf
365889a2364Smrg				;;
366889a2364Smrg			hppro)
367889a2364Smrg				basic_machine=hppa1.1-hp
368889a2364Smrg				basic_os=proelf
369889a2364Smrg				;;
370889a2364Smrg			i386mach)
371889a2364Smrg				basic_machine=i386-mach
372889a2364Smrg				basic_os=mach
373889a2364Smrg				;;
374889a2364Smrg			isi68 | isi)
375889a2364Smrg				basic_machine=m68k-isi
376889a2364Smrg				basic_os=sysv
377889a2364Smrg				;;
378889a2364Smrg			m68knommu)
379889a2364Smrg				basic_machine=m68k-unknown
380889a2364Smrg				basic_os=linux
381889a2364Smrg				;;
382889a2364Smrg			magnum | m3230)
383889a2364Smrg				basic_machine=mips-mips
384889a2364Smrg				basic_os=sysv
385889a2364Smrg				;;
386889a2364Smrg			merlin)
387889a2364Smrg				basic_machine=ns32k-utek
388889a2364Smrg				basic_os=sysv
389889a2364Smrg				;;
390889a2364Smrg			mingw64)
391889a2364Smrg				basic_machine=x86_64-pc
392889a2364Smrg				basic_os=mingw64
393889a2364Smrg				;;
394889a2364Smrg			mingw32)
395889a2364Smrg				basic_machine=i686-pc
396889a2364Smrg				basic_os=mingw32
397889a2364Smrg				;;
398889a2364Smrg			mingw32ce)
399889a2364Smrg				basic_machine=arm-unknown
400889a2364Smrg				basic_os=mingw32ce
401889a2364Smrg				;;
402889a2364Smrg			monitor)
403889a2364Smrg				basic_machine=m68k-rom68k
404889a2364Smrg				basic_os=coff
405889a2364Smrg				;;
406889a2364Smrg			morphos)
407889a2364Smrg				basic_machine=powerpc-unknown
408889a2364Smrg				basic_os=morphos
409889a2364Smrg				;;
410889a2364Smrg			moxiebox)
411889a2364Smrg				basic_machine=moxie-unknown
412889a2364Smrg				basic_os=moxiebox
413889a2364Smrg				;;
414889a2364Smrg			msdos)
415889a2364Smrg				basic_machine=i386-pc
416889a2364Smrg				basic_os=msdos
417889a2364Smrg				;;
418889a2364Smrg			msys)
419889a2364Smrg				basic_machine=i686-pc
420889a2364Smrg				basic_os=msys
421889a2364Smrg				;;
422889a2364Smrg			mvs)
423889a2364Smrg				basic_machine=i370-ibm
424889a2364Smrg				basic_os=mvs
425889a2364Smrg				;;
426889a2364Smrg			nacl)
427889a2364Smrg				basic_machine=le32-unknown
428889a2364Smrg				basic_os=nacl
429889a2364Smrg				;;
430889a2364Smrg			ncr3000)
431889a2364Smrg				basic_machine=i486-ncr
432889a2364Smrg				basic_os=sysv4
433889a2364Smrg				;;
434889a2364Smrg			netbsd386)
435889a2364Smrg				basic_machine=i386-pc
436889a2364Smrg				basic_os=netbsd
437889a2364Smrg				;;
438889a2364Smrg			netwinder)
439889a2364Smrg				basic_machine=armv4l-rebel
440889a2364Smrg				basic_os=linux
441889a2364Smrg				;;
442889a2364Smrg			news | news700 | news800 | news900)
443889a2364Smrg				basic_machine=m68k-sony
444889a2364Smrg				basic_os=newsos
445889a2364Smrg				;;
446889a2364Smrg			news1000)
447889a2364Smrg				basic_machine=m68030-sony
448889a2364Smrg				basic_os=newsos
449889a2364Smrg				;;
450889a2364Smrg			necv70)
451889a2364Smrg				basic_machine=v70-nec
452889a2364Smrg				basic_os=sysv
453889a2364Smrg				;;
454889a2364Smrg			nh3000)
455889a2364Smrg				basic_machine=m68k-harris
456889a2364Smrg				basic_os=cxux
457889a2364Smrg				;;
458889a2364Smrg			nh[45]000)
459889a2364Smrg				basic_machine=m88k-harris
460889a2364Smrg				basic_os=cxux
461889a2364Smrg				;;
462889a2364Smrg			nindy960)
463889a2364Smrg				basic_machine=i960-intel
464889a2364Smrg				basic_os=nindy
465889a2364Smrg				;;
466889a2364Smrg			mon960)
467889a2364Smrg				basic_machine=i960-intel
468889a2364Smrg				basic_os=mon960
469889a2364Smrg				;;
470889a2364Smrg			nonstopux)
471889a2364Smrg				basic_machine=mips-compaq
472889a2364Smrg				basic_os=nonstopux
473889a2364Smrg				;;
474889a2364Smrg			os400)
475889a2364Smrg				basic_machine=powerpc-ibm
476889a2364Smrg				basic_os=os400
477889a2364Smrg				;;
478889a2364Smrg			OSE68000 | ose68000)
479889a2364Smrg				basic_machine=m68000-ericsson
480889a2364Smrg				basic_os=ose
481889a2364Smrg				;;
482889a2364Smrg			os68k)
483889a2364Smrg				basic_machine=m68k-none
484889a2364Smrg				basic_os=os68k
485889a2364Smrg				;;
486889a2364Smrg			paragon)
487889a2364Smrg				basic_machine=i860-intel
488889a2364Smrg				basic_os=osf
489889a2364Smrg				;;
490889a2364Smrg			parisc)
491889a2364Smrg				basic_machine=hppa-unknown
492889a2364Smrg				basic_os=linux
493889a2364Smrg				;;
494889a2364Smrg			psp)
495889a2364Smrg				basic_machine=mipsallegrexel-sony
496889a2364Smrg				basic_os=psp
497889a2364Smrg				;;
498889a2364Smrg			pw32)
499889a2364Smrg				basic_machine=i586-unknown
500889a2364Smrg				basic_os=pw32
501889a2364Smrg				;;
502889a2364Smrg			rdos | rdos64)
503889a2364Smrg				basic_machine=x86_64-pc
504889a2364Smrg				basic_os=rdos
505889a2364Smrg				;;
506889a2364Smrg			rdos32)
507889a2364Smrg				basic_machine=i386-pc
508889a2364Smrg				basic_os=rdos
509889a2364Smrg				;;
510889a2364Smrg			rom68k)
511889a2364Smrg				basic_machine=m68k-rom68k
512889a2364Smrg				basic_os=coff
513889a2364Smrg				;;
514889a2364Smrg			sa29200)
515889a2364Smrg				basic_machine=a29k-amd
516889a2364Smrg				basic_os=udi
517889a2364Smrg				;;
518889a2364Smrg			sei)
519889a2364Smrg				basic_machine=mips-sei
520889a2364Smrg				basic_os=seiux
521889a2364Smrg				;;
522889a2364Smrg			sequent)
523889a2364Smrg				basic_machine=i386-sequent
524889a2364Smrg				basic_os=
525889a2364Smrg				;;
526889a2364Smrg			sps7)
527889a2364Smrg				basic_machine=m68k-bull
528889a2364Smrg				basic_os=sysv2
529889a2364Smrg				;;
530889a2364Smrg			st2000)
531889a2364Smrg				basic_machine=m68k-tandem
532889a2364Smrg				basic_os=
533889a2364Smrg				;;
534889a2364Smrg			stratus)
535889a2364Smrg				basic_machine=i860-stratus
536889a2364Smrg				basic_os=sysv4
537889a2364Smrg				;;
538889a2364Smrg			sun2)
539889a2364Smrg				basic_machine=m68000-sun
540889a2364Smrg				basic_os=
541889a2364Smrg				;;
542889a2364Smrg			sun2os3)
543889a2364Smrg				basic_machine=m68000-sun
544889a2364Smrg				basic_os=sunos3
545889a2364Smrg				;;
546889a2364Smrg			sun2os4)
547889a2364Smrg				basic_machine=m68000-sun
548889a2364Smrg				basic_os=sunos4
549889a2364Smrg				;;
550889a2364Smrg			sun3)
551889a2364Smrg				basic_machine=m68k-sun
552889a2364Smrg				basic_os=
553889a2364Smrg				;;
554889a2364Smrg			sun3os3)
555889a2364Smrg				basic_machine=m68k-sun
556889a2364Smrg				basic_os=sunos3
557889a2364Smrg				;;
558889a2364Smrg			sun3os4)
559889a2364Smrg				basic_machine=m68k-sun
560889a2364Smrg				basic_os=sunos4
561889a2364Smrg				;;
562889a2364Smrg			sun4)
563889a2364Smrg				basic_machine=sparc-sun
564889a2364Smrg				basic_os=
565889a2364Smrg				;;
566889a2364Smrg			sun4os3)
567889a2364Smrg				basic_machine=sparc-sun
568889a2364Smrg				basic_os=sunos3
569889a2364Smrg				;;
570889a2364Smrg			sun4os4)
571889a2364Smrg				basic_machine=sparc-sun
572889a2364Smrg				basic_os=sunos4
573889a2364Smrg				;;
574889a2364Smrg			sun4sol2)
575889a2364Smrg				basic_machine=sparc-sun
576889a2364Smrg				basic_os=solaris2
577889a2364Smrg				;;
578889a2364Smrg			sun386 | sun386i | roadrunner)
579889a2364Smrg				basic_machine=i386-sun
580889a2364Smrg				basic_os=
581889a2364Smrg				;;
582889a2364Smrg			sv1)
583889a2364Smrg				basic_machine=sv1-cray
584889a2364Smrg				basic_os=unicos
585889a2364Smrg				;;
586889a2364Smrg			symmetry)
587889a2364Smrg				basic_machine=i386-sequent
588889a2364Smrg				basic_os=dynix
589889a2364Smrg				;;
590889a2364Smrg			t3e)
591889a2364Smrg				basic_machine=alphaev5-cray
592889a2364Smrg				basic_os=unicos
593889a2364Smrg				;;
594889a2364Smrg			t90)
595889a2364Smrg				basic_machine=t90-cray
596889a2364Smrg				basic_os=unicos
597889a2364Smrg				;;
598889a2364Smrg			toad1)
599889a2364Smrg				basic_machine=pdp10-xkl
600889a2364Smrg				basic_os=tops20
601889a2364Smrg				;;
602889a2364Smrg			tpf)
603889a2364Smrg				basic_machine=s390x-ibm
604889a2364Smrg				basic_os=tpf
605889a2364Smrg				;;
606889a2364Smrg			udi29k)
607889a2364Smrg				basic_machine=a29k-amd
608889a2364Smrg				basic_os=udi
609889a2364Smrg				;;
610889a2364Smrg			ultra3)
611889a2364Smrg				basic_machine=a29k-nyu
612889a2364Smrg				basic_os=sym1
613889a2364Smrg				;;
614889a2364Smrg			v810 | necv810)
615889a2364Smrg				basic_machine=v810-nec
616889a2364Smrg				basic_os=none
617889a2364Smrg				;;
618889a2364Smrg			vaxv)
619889a2364Smrg				basic_machine=vax-dec
620889a2364Smrg				basic_os=sysv
621889a2364Smrg				;;
622889a2364Smrg			vms)
623889a2364Smrg				basic_machine=vax-dec
624889a2364Smrg				basic_os=vms
625889a2364Smrg				;;
626889a2364Smrg			vsta)
627889a2364Smrg				basic_machine=i386-pc
628889a2364Smrg				basic_os=vsta
629889a2364Smrg				;;
630889a2364Smrg			vxworks960)
631889a2364Smrg				basic_machine=i960-wrs
632889a2364Smrg				basic_os=vxworks
633889a2364Smrg				;;
634889a2364Smrg			vxworks68)
635889a2364Smrg				basic_machine=m68k-wrs
636889a2364Smrg				basic_os=vxworks
637889a2364Smrg				;;
638889a2364Smrg			vxworks29k)
639889a2364Smrg				basic_machine=a29k-wrs
640889a2364Smrg				basic_os=vxworks
641889a2364Smrg				;;
642889a2364Smrg			xbox)
643889a2364Smrg				basic_machine=i686-pc
644889a2364Smrg				basic_os=mingw32
645889a2364Smrg				;;
646889a2364Smrg			ymp)
647889a2364Smrg				basic_machine=ymp-cray
648889a2364Smrg				basic_os=unicos
649889a2364Smrg				;;
650889a2364Smrg			*)
651889a2364Smrg				basic_machine=$1
652889a2364Smrg				basic_os=
653889a2364Smrg				;;
654889a2364Smrg		esac
65521c2f794Smrg		;;
65621c2f794Smrgesac
65721c2f794Smrg
658889a2364Smrg# Decode 1-component or ad-hoc basic machines
65921c2f794Smrgcase $basic_machine in
660889a2364Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661889a2364Smrg	# some cases the only manufacturer, in others, it is the most popular.
662889a2364Smrg	w89k)
663889a2364Smrg		cpu=hppa1.1
664889a2364Smrg		vendor=winbond
66521c2f794Smrg		;;
666889a2364Smrg	op50n)
667889a2364Smrg		cpu=hppa1.1
668889a2364Smrg		vendor=oki
66982e12b1bSmrg		;;
670889a2364Smrg	op60c)
671889a2364Smrg		cpu=hppa1.1
672889a2364Smrg		vendor=oki
6731b2353dbSmrg		;;
674889a2364Smrg	ibm*)
675889a2364Smrg		cpu=i370
676889a2364Smrg		vendor=ibm
67782e12b1bSmrg		;;
678889a2364Smrg	orion105)
679889a2364Smrg		cpu=clipper
680889a2364Smrg		vendor=highlevel
68182e12b1bSmrg		;;
682889a2364Smrg	mac | mpw | mac-mpw)
683889a2364Smrg		cpu=m68k
684889a2364Smrg		vendor=apple
68521c2f794Smrg		;;
686889a2364Smrg	pmac | pmac-mpw)
687889a2364Smrg		cpu=powerpc
688889a2364Smrg		vendor=apple
68921c2f794Smrg		;;
690889a2364Smrg
69121c2f794Smrg	# Recognize the various machine names and aliases which stand
69221c2f794Smrg	# for a CPU type and a company and sometimes even an OS.
69321c2f794Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694889a2364Smrg		cpu=m68000
695889a2364Smrg		vendor=att
69621c2f794Smrg		;;
69721c2f794Smrg	3b*)
698889a2364Smrg		cpu=we32k
699889a2364Smrg		vendor=att
70021c2f794Smrg		;;
70112391620Smrg	bluegene*)
702889a2364Smrg		cpu=powerpc
703889a2364Smrg		vendor=ibm
704889a2364Smrg		basic_os=cnk
70521c2f794Smrg		;;
70621c2f794Smrg	decsystem10* | dec10*)
707889a2364Smrg		cpu=pdp10
708889a2364Smrg		vendor=dec
709889a2364Smrg		basic_os=tops10
71021c2f794Smrg		;;
71121c2f794Smrg	decsystem20* | dec20*)
712889a2364Smrg		cpu=pdp10
713889a2364Smrg		vendor=dec
714889a2364Smrg		basic_os=tops20
71521c2f794Smrg		;;
71621c2f794Smrg	delta | 3300 | motorola-3300 | motorola-delta \
71721c2f794Smrg	      | 3300-motorola | delta-motorola)
718889a2364Smrg		cpu=m68k
719889a2364Smrg		vendor=motorola
72021c2f794Smrg		;;
721889a2364Smrg	dpx2*)
722889a2364Smrg		cpu=m68k
723889a2364Smrg		vendor=bull
724889a2364Smrg		basic_os=sysv3
72521c2f794Smrg		;;
72621c2f794Smrg	encore | umax | mmax)
727889a2364Smrg		cpu=ns32k
728889a2364Smrg		vendor=encore
72921c2f794Smrg		;;
730889a2364Smrg	elxsi)
731889a2364Smrg		cpu=elxsi
732889a2364Smrg		vendor=elxsi
733889a2364Smrg		basic_os=${basic_os:-bsd}
73421c2f794Smrg		;;
73521c2f794Smrg	fx2800)
736889a2364Smrg		cpu=i860
737889a2364Smrg		vendor=alliant
73821c2f794Smrg		;;
73921c2f794Smrg	genix)
740889a2364Smrg		cpu=ns32k
741889a2364Smrg		vendor=ns
74221c2f794Smrg		;;
74321c2f794Smrg	h3050r* | hiux*)
744889a2364Smrg		cpu=hppa1.1
745889a2364Smrg		vendor=hitachi
746889a2364Smrg		basic_os=hiuxwe2
74721c2f794Smrg		;;
74821c2f794Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749889a2364Smrg		cpu=hppa1.0
750889a2364Smrg		vendor=hp
75121c2f794Smrg		;;
75221c2f794Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753889a2364Smrg		cpu=m68000
754889a2364Smrg		vendor=hp
75521c2f794Smrg		;;
75621c2f794Smrg	hp9k3[2-9][0-9])
757889a2364Smrg		cpu=m68k
758889a2364Smrg		vendor=hp
75921c2f794Smrg		;;
76021c2f794Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761889a2364Smrg		cpu=hppa1.0
762889a2364Smrg		vendor=hp
76321c2f794Smrg		;;
76421c2f794Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765889a2364Smrg		cpu=hppa1.1
766889a2364Smrg		vendor=hp
76721c2f794Smrg		;;
76821c2f794Smrg	hp9k78[0-9] | hp78[0-9])
76921c2f794Smrg		# FIXME: really hppa2.0-hp
770889a2364Smrg		cpu=hppa1.1
771889a2364Smrg		vendor=hp
77221c2f794Smrg		;;
77321c2f794Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
77421c2f794Smrg		# FIXME: really hppa2.0-hp
775889a2364Smrg		cpu=hppa1.1
776889a2364Smrg		vendor=hp
77721c2f794Smrg		;;
77821c2f794Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779889a2364Smrg		cpu=hppa1.1
780889a2364Smrg		vendor=hp
78121c2f794Smrg		;;
78221c2f794Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783889a2364Smrg		cpu=hppa1.0
784889a2364Smrg		vendor=hp
78521c2f794Smrg		;;
78621c2f794Smrg	i*86v32)
787889a2364Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788889a2364Smrg		vendor=pc
789889a2364Smrg		basic_os=sysv32
79021c2f794Smrg		;;
79121c2f794Smrg	i*86v4*)
792889a2364Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793889a2364Smrg		vendor=pc
794889a2364Smrg		basic_os=sysv4
79521c2f794Smrg		;;
79621c2f794Smrg	i*86v)
797889a2364Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798889a2364Smrg		vendor=pc
799889a2364Smrg		basic_os=sysv
80021c2f794Smrg		;;
80121c2f794Smrg	i*86sol2)
802889a2364Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803889a2364Smrg		vendor=pc
804889a2364Smrg		basic_os=solaris2
80521c2f794Smrg		;;
806889a2364Smrg	j90 | j90-cray)
807889a2364Smrg		cpu=j90
808889a2364Smrg		vendor=cray
809889a2364Smrg		basic_os=${basic_os:-unicos}
81021c2f794Smrg		;;
81121c2f794Smrg	iris | iris4d)
812889a2364Smrg		cpu=mips
813889a2364Smrg		vendor=sgi
814889a2364Smrg		case $basic_os in
815889a2364Smrg		    irix*)
81621c2f794Smrg			;;
81721c2f794Smrg		    *)
818889a2364Smrg			basic_os=irix4
81921c2f794Smrg			;;
82021c2f794Smrg		esac
82121c2f794Smrg		;;
82221c2f794Smrg	miniframe)
823889a2364Smrg		cpu=m68000
824889a2364Smrg		vendor=convergent
82521c2f794Smrg		;;
826889a2364Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827889a2364Smrg		cpu=m68k
828889a2364Smrg		vendor=atari
829889a2364Smrg		basic_os=mint
83021c2f794Smrg		;;
83121c2f794Smrg	news-3600 | risc-news)
832889a2364Smrg		cpu=mips
833889a2364Smrg		vendor=sony
834889a2364Smrg		basic_os=newsos
835889a2364Smrg		;;
836889a2364Smrg	next | m*-next)
837889a2364Smrg		cpu=m68k
838889a2364Smrg		vendor=next
839889a2364Smrg		case $basic_os in
840889a2364Smrg		    openstep*)
841889a2364Smrg		        ;;
842889a2364Smrg		    nextstep*)
84321c2f794Smrg			;;
844889a2364Smrg		    ns2*)
845889a2364Smrg		      basic_os=nextstep2
84621c2f794Smrg			;;
84721c2f794Smrg		    *)
848889a2364Smrg		      basic_os=nextstep3
84921c2f794Smrg			;;
85021c2f794Smrg		esac
85121c2f794Smrg		;;
85221c2f794Smrg	np1)
853889a2364Smrg		cpu=np1
854889a2364Smrg		vendor=gould
85521c2f794Smrg		;;
85621c2f794Smrg	op50n-* | op60c-*)
857889a2364Smrg		cpu=hppa1.1
858889a2364Smrg		vendor=oki
859889a2364Smrg		basic_os=proelf
86021c2f794Smrg		;;
86121c2f794Smrg	pa-hitachi)
862889a2364Smrg		cpu=hppa1.1
863889a2364Smrg		vendor=hitachi
864889a2364Smrg		basic_os=hiuxwe2
86521c2f794Smrg		;;
86621c2f794Smrg	pbd)
867889a2364Smrg		cpu=sparc
868889a2364Smrg		vendor=tti
86921c2f794Smrg		;;
87021c2f794Smrg	pbb)
871889a2364Smrg		cpu=m68k
872889a2364Smrg		vendor=tti
87321c2f794Smrg		;;
874889a2364Smrg	pc532)
875889a2364Smrg		cpu=ns32k
876889a2364Smrg		vendor=pc532
87721c2f794Smrg		;;
87821c2f794Smrg	pn)
879889a2364Smrg		cpu=pn
880889a2364Smrg		vendor=gould
88121c2f794Smrg		;;
882889a2364Smrg	power)
883889a2364Smrg		cpu=power
884889a2364Smrg		vendor=ibm
88521c2f794Smrg		;;
88621c2f794Smrg	ps2)
887889a2364Smrg		cpu=i386
888889a2364Smrg		vendor=ibm
88921c2f794Smrg		;;
89021c2f794Smrg	rm[46]00)
891889a2364Smrg		cpu=mips
892889a2364Smrg		vendor=siemens
89321c2f794Smrg		;;
89421c2f794Smrg	rtpc | rtpc-*)
895889a2364Smrg		cpu=romp
896889a2364Smrg		vendor=ibm
89721c2f794Smrg		;;
898889a2364Smrg	sde)
899889a2364Smrg		cpu=mipsisa32
900889a2364Smrg		vendor=sde
901889a2364Smrg		basic_os=${basic_os:-elf}
90221c2f794Smrg		;;
903889a2364Smrg	simso-wrs)
904889a2364Smrg		cpu=sparclite
905889a2364Smrg		vendor=wrs
906889a2364Smrg		basic_os=vxworks
90721c2f794Smrg		;;
908889a2364Smrg	tower | tower-32)
909889a2364Smrg		cpu=m68k
910889a2364Smrg		vendor=ncr
91121c2f794Smrg		;;
912889a2364Smrg	vpp*|vx|vx-*)
913889a2364Smrg		cpu=f301
914889a2364Smrg		vendor=fujitsu
91521c2f794Smrg		;;
916889a2364Smrg	w65)
917889a2364Smrg		cpu=w65
918889a2364Smrg		vendor=wdc
91921c2f794Smrg		;;
920889a2364Smrg	w89k-*)
921889a2364Smrg		cpu=hppa1.1
922889a2364Smrg		vendor=winbond
923889a2364Smrg		basic_os=proelf
92421c2f794Smrg		;;
925889a2364Smrg	none)
926889a2364Smrg		cpu=none
927889a2364Smrg		vendor=none
92821c2f794Smrg		;;
929889a2364Smrg	leon|leon[3-9])
930889a2364Smrg		cpu=sparc
931889a2364Smrg		vendor=$basic_machine
93221c2f794Smrg		;;
933889a2364Smrg	leon-*|leon[3-9]-*)
934889a2364Smrg		cpu=sparc
935889a2364Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93621c2f794Smrg		;;
937889a2364Smrg
938889a2364Smrg	*-*)
939889a2364Smrg		# shellcheck disable=SC2162
940889a2364Smrg		saved_IFS=$IFS
941889a2364Smrg		IFS="-" read cpu vendor <<EOF
942889a2364Smrg$basic_machine
943889a2364SmrgEOF
944889a2364Smrg		IFS=$saved_IFS
94521c2f794Smrg		;;
946889a2364Smrg	# We use `pc' rather than `unknown'
947889a2364Smrg	# because (1) that's what they normally are, and
948889a2364Smrg	# (2) the word "unknown" tends to confuse beginning users.
949889a2364Smrg	i*86 | x86_64)
950889a2364Smrg		cpu=$basic_machine
951889a2364Smrg		vendor=pc
95221c2f794Smrg		;;
953889a2364Smrg	# These rules are duplicated from below for sake of the special case above;
954889a2364Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955889a2364Smrg	pc98)
956889a2364Smrg		cpu=i386
957889a2364Smrg		vendor=pc
95821c2f794Smrg		;;
959889a2364Smrg	x64 | amd64)
960889a2364Smrg		cpu=x86_64
961889a2364Smrg		vendor=pc
96221c2f794Smrg		;;
963889a2364Smrg	# Recognize the basic CPU types without company name.
964889a2364Smrg	*)
965889a2364Smrg		cpu=$basic_machine
966889a2364Smrg		vendor=unknown
96782e12b1bSmrg		;;
968889a2364Smrgesac
969889a2364Smrg
970889a2364Smrgunset -v basic_machine
971889a2364Smrg
972889a2364Smrg# Decode basic machines in the full and proper CPU-Company form.
973889a2364Smrgcase $cpu-$vendor in
974889a2364Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975889a2364Smrg	# some cases the only manufacturer, in others, it is the most popular.
976889a2364Smrg	craynv-unknown)
977889a2364Smrg		vendor=cray
978889a2364Smrg		basic_os=${basic_os:-unicosmp}
97921c2f794Smrg		;;
980889a2364Smrg	c90-unknown | c90-cray)
981889a2364Smrg		vendor=cray
982889a2364Smrg		basic_os=${Basic_os:-unicos}
98321c2f794Smrg		;;
984889a2364Smrg	fx80-unknown)
985889a2364Smrg		vendor=alliant
98621c2f794Smrg		;;
987889a2364Smrg	romp-unknown)
988889a2364Smrg		vendor=ibm
98921c2f794Smrg		;;
990889a2364Smrg	mmix-unknown)
991889a2364Smrg		vendor=knuth
99221c2f794Smrg		;;
993889a2364Smrg	microblaze-unknown | microblazeel-unknown)
994889a2364Smrg		vendor=xilinx
99521c2f794Smrg		;;
996889a2364Smrg	rs6000-unknown)
997889a2364Smrg		vendor=ibm
99821c2f794Smrg		;;
999889a2364Smrg	vax-unknown)
1000889a2364Smrg		vendor=dec
100121c2f794Smrg		;;
1002889a2364Smrg	pdp11-unknown)
1003889a2364Smrg		vendor=dec
100421c2f794Smrg		;;
1005889a2364Smrg	we32k-unknown)
1006889a2364Smrg		vendor=att
100721c2f794Smrg		;;
1008889a2364Smrg	cydra-unknown)
1009889a2364Smrg		vendor=cydrome
101021c2f794Smrg		;;
1011889a2364Smrg	i370-ibm*)
1012889a2364Smrg		vendor=ibm
101321c2f794Smrg		;;
1014889a2364Smrg	orion-unknown)
1015889a2364Smrg		vendor=highlevel
101621c2f794Smrg		;;
1017889a2364Smrg	xps-unknown | xps100-unknown)
1018889a2364Smrg		cpu=xps100
1019889a2364Smrg		vendor=honeywell
102021c2f794Smrg		;;
1021889a2364Smrg
1022889a2364Smrg	# Here we normalize CPU types with a missing or matching vendor
1023889a2364Smrg	dpx20-unknown | dpx20-bull)
1024889a2364Smrg		cpu=rs6000
1025889a2364Smrg		vendor=bull
1026889a2364Smrg		basic_os=${basic_os:-bosx}
102721c2f794Smrg		;;
1028889a2364Smrg
1029889a2364Smrg	# Here we normalize CPU types irrespective of the vendor
1030889a2364Smrg	amd64-*)
1031889a2364Smrg		cpu=x86_64
103221c2f794Smrg		;;
1033889a2364Smrg	blackfin-*)
1034889a2364Smrg		cpu=bfin
1035889a2364Smrg		basic_os=linux
103621c2f794Smrg		;;
1037889a2364Smrg	c54x-*)
1038889a2364Smrg		cpu=tic54x
103921c2f794Smrg		;;
1040889a2364Smrg	c55x-*)
1041889a2364Smrg		cpu=tic55x
104221c2f794Smrg		;;
1043889a2364Smrg	c6x-*)
1044889a2364Smrg		cpu=tic6x
104521c2f794Smrg		;;
1046889a2364Smrg	e500v[12]-*)
1047889a2364Smrg		cpu=powerpc
1048889a2364Smrg		basic_os=${basic_os}"spe"
104921c2f794Smrg		;;
1050889a2364Smrg	mips3*-*)
1051889a2364Smrg		cpu=mips64
105221c2f794Smrg		;;
1053889a2364Smrg	ms1-*)
1054889a2364Smrg		cpu=mt
105521c2f794Smrg		;;
1056889a2364Smrg	m68knommu-*)
1057889a2364Smrg		cpu=m68k
1058889a2364Smrg		basic_os=linux
105921c2f794Smrg		;;
1060889a2364Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1061889a2364Smrg		cpu=s12z
106221c2f794Smrg		;;
1063889a2364Smrg	openrisc-*)
1064889a2364Smrg		cpu=or32
106521c2f794Smrg		;;
1066889a2364Smrg	parisc-*)
1067889a2364Smrg		cpu=hppa
1068889a2364Smrg		basic_os=linux
106921c2f794Smrg		;;
1070889a2364Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1071889a2364Smrg		cpu=i586
107221c2f794Smrg		;;
1073889a2364Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1074889a2364Smrg		cpu=i686
107521c2f794Smrg		;;
1076889a2364Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1077889a2364Smrg		cpu=i686
107821c2f794Smrg		;;
1079889a2364Smrg	pentium4-*)
1080889a2364Smrg		cpu=i786
108121c2f794Smrg		;;
1082889a2364Smrg	pc98-*)
1083889a2364Smrg		cpu=i386
108421c2f794Smrg		;;
1085889a2364Smrg	ppc-* | ppcbe-*)
1086889a2364Smrg		cpu=powerpc
108721c2f794Smrg		;;
1088889a2364Smrg	ppcle-* | powerpclittle-*)
1089889a2364Smrg		cpu=powerpcle
109021c2f794Smrg		;;
1091889a2364Smrg	ppc64-*)
1092889a2364Smrg		cpu=powerpc64
109382e12b1bSmrg		;;
1094889a2364Smrg	ppc64le-* | powerpc64little-*)
1095889a2364Smrg		cpu=powerpc64le
109621c2f794Smrg		;;
1097889a2364Smrg	sb1-*)
1098889a2364Smrg		cpu=mipsisa64sb1
109921c2f794Smrg		;;
1100889a2364Smrg	sb1el-*)
1101889a2364Smrg		cpu=mipsisa64sb1el
110212391620Smrg		;;
1103889a2364Smrg	sh5e[lb]-*)
1104889a2364Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
110521c2f794Smrg		;;
1106889a2364Smrg	spur-*)
1107889a2364Smrg		cpu=spur
110821c2f794Smrg		;;
1109889a2364Smrg	strongarm-* | thumb-*)
1110889a2364Smrg		cpu=arm
111121c2f794Smrg		;;
1112889a2364Smrg	tx39-*)
1113889a2364Smrg		cpu=mipstx39
111421c2f794Smrg		;;
1115889a2364Smrg	tx39el-*)
1116889a2364Smrg		cpu=mipstx39el
111721c2f794Smrg		;;
1118889a2364Smrg	x64-*)
1119889a2364Smrg		cpu=x86_64
112021c2f794Smrg		;;
1121889a2364Smrg	xscale-* | xscalee[bl]-*)
1122889a2364Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112321c2f794Smrg		;;
1124889a2364Smrg	arm64-*)
1125889a2364Smrg		cpu=aarch64
112621c2f794Smrg		;;
1127889a2364Smrg
1128889a2364Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1129889a2364Smrg	# company names they are paired with.
1130889a2364Smrg	cr16-*)
1131889a2364Smrg		basic_os=${basic_os:-elf}
113221c2f794Smrg		;;
1133889a2364Smrg	crisv32-* | etraxfs*-*)
1134889a2364Smrg		cpu=crisv32
1135889a2364Smrg		vendor=axis
113621c2f794Smrg		;;
1137889a2364Smrg	cris-* | etrax*-*)
1138889a2364Smrg		cpu=cris
1139889a2364Smrg		vendor=axis
114021c2f794Smrg		;;
1141889a2364Smrg	crx-*)
1142889a2364Smrg		basic_os=${basic_os:-elf}
114321c2f794Smrg		;;
1144889a2364Smrg	neo-tandem)
1145889a2364Smrg		cpu=neo
1146889a2364Smrg		vendor=tandem
114721c2f794Smrg		;;
1148889a2364Smrg	nse-tandem)
1149889a2364Smrg		cpu=nse
1150889a2364Smrg		vendor=tandem
115121c2f794Smrg		;;
1152889a2364Smrg	nsr-tandem)
1153889a2364Smrg		cpu=nsr
1154889a2364Smrg		vendor=tandem
115521c2f794Smrg		;;
1156889a2364Smrg	nsv-tandem)
1157889a2364Smrg		cpu=nsv
1158889a2364Smrg		vendor=tandem
115921c2f794Smrg		;;
1160889a2364Smrg	nsx-tandem)
1161889a2364Smrg		cpu=nsx
1162889a2364Smrg		vendor=tandem
116321c2f794Smrg		;;
1164889a2364Smrg	mipsallegrexel-sony)
1165889a2364Smrg		cpu=mipsallegrexel
1166889a2364Smrg		vendor=sony
116721c2f794Smrg		;;
1168889a2364Smrg	tile*-*)
1169889a2364Smrg		basic_os=${basic_os:-linux-gnu}
117021c2f794Smrg		;;
1171889a2364Smrg
117221c2f794Smrg	*)
1173889a2364Smrg		# Recognize the canonical CPU types that are allowed with any
1174889a2364Smrg		# company name.
1175889a2364Smrg		case $cpu in
1176889a2364Smrg			1750a | 580 \
1177889a2364Smrg			| a29k \
1178889a2364Smrg			| aarch64 | aarch64_be \
1179889a2364Smrg			| abacus \
1180889a2364Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1181889a2364Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1182889a2364Smrg			| alphapca5[67] | alpha64pca5[67] \
1183889a2364Smrg			| am33_2.0 \
1184889a2364Smrg			| amdgcn \
1185889a2364Smrg			| arc | arceb | arc32 | arc64 \
1186889a2364Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1187889a2364Smrg			| avr | avr32 \
1188889a2364Smrg			| asmjs \
1189889a2364Smrg			| ba \
1190889a2364Smrg			| be32 | be64 \
1191889a2364Smrg			| bfin | bpf | bs2000 \
1192889a2364Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1193889a2364Smrg			| c8051 | clipper | craynv | csky | cydra \
1194889a2364Smrg			| d10v | d30v | dlx | dsp16xx \
1195889a2364Smrg			| e2k | elxsi | epiphany \
1196889a2364Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1197889a2364Smrg			| h8300 | h8500 \
1198889a2364Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1199889a2364Smrg			| hexagon \
1200889a2364Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1201889a2364Smrg			| ip2k | iq2000 \
1202889a2364Smrg			| k1om \
1203889a2364Smrg			| le32 | le64 \
1204889a2364Smrg			| lm32 \
1205889a2364Smrg			| loongarch32 | loongarch64 | loongarchx32 \
1206889a2364Smrg			| m32c | m32r | m32rle \
1207889a2364Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1208889a2364Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1209889a2364Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1210889a2364Smrg			| microblaze | microblazeel \
1211889a2364Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1212889a2364Smrg			| mips16 \
1213889a2364Smrg			| mips64 | mips64eb | mips64el \
1214889a2364Smrg			| mips64octeon | mips64octeonel \
1215889a2364Smrg			| mips64orion | mips64orionel \
1216889a2364Smrg			| mips64r5900 | mips64r5900el \
1217889a2364Smrg			| mips64vr | mips64vrel \
1218889a2364Smrg			| mips64vr4100 | mips64vr4100el \
1219889a2364Smrg			| mips64vr4300 | mips64vr4300el \
1220889a2364Smrg			| mips64vr5000 | mips64vr5000el \
1221889a2364Smrg			| mips64vr5900 | mips64vr5900el \
1222889a2364Smrg			| mipsisa32 | mipsisa32el \
1223889a2364Smrg			| mipsisa32r2 | mipsisa32r2el \
1224889a2364Smrg			| mipsisa32r3 | mipsisa32r3el \
1225889a2364Smrg			| mipsisa32r5 | mipsisa32r5el \
1226889a2364Smrg			| mipsisa32r6 | mipsisa32r6el \
1227889a2364Smrg			| mipsisa64 | mipsisa64el \
1228889a2364Smrg			| mipsisa64r2 | mipsisa64r2el \
1229889a2364Smrg			| mipsisa64r3 | mipsisa64r3el \
1230889a2364Smrg			| mipsisa64r5 | mipsisa64r5el \
1231889a2364Smrg			| mipsisa64r6 | mipsisa64r6el \
1232889a2364Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1233889a2364Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1234889a2364Smrg			| mipsr5900 | mipsr5900el \
1235889a2364Smrg			| mipstx39 | mipstx39el \
1236889a2364Smrg			| mmix \
1237889a2364Smrg			| mn10200 | mn10300 \
1238889a2364Smrg			| moxie \
1239889a2364Smrg			| mt \
1240889a2364Smrg			| msp430 \
1241889a2364Smrg			| nds32 | nds32le | nds32be \
1242889a2364Smrg			| nfp \
1243889a2364Smrg			| nios | nios2 | nios2eb | nios2el \
1244889a2364Smrg			| none | np1 | ns16k | ns32k | nvptx \
1245889a2364Smrg			| open8 \
1246889a2364Smrg			| or1k* \
1247889a2364Smrg			| or32 \
1248889a2364Smrg			| orion \
1249889a2364Smrg			| picochip \
1250889a2364Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1251889a2364Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1252889a2364Smrg			| pru \
1253889a2364Smrg			| pyramid \
1254889a2364Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1255889a2364Smrg			| rl78 | romp | rs6000 | rx \
1256889a2364Smrg			| s390 | s390x \
1257889a2364Smrg			| score \
1258889a2364Smrg			| sh | shl \
1259889a2364Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1260889a2364Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1261889a2364Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1262889a2364Smrg			| sparclite \
1263889a2364Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1264889a2364Smrg			| spu \
1265889a2364Smrg			| tahoe \
1266889a2364Smrg			| thumbv7* \
1267889a2364Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1268889a2364Smrg			| tron \
1269889a2364Smrg			| ubicom32 \
1270889a2364Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1271889a2364Smrg			| vax \
1272889a2364Smrg			| visium \
1273889a2364Smrg			| w65 \
1274889a2364Smrg			| wasm32 | wasm64 \
1275889a2364Smrg			| we32k \
1276889a2364Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1277889a2364Smrg			| xstormy16 | xtensa* \
1278889a2364Smrg			| ymp \
1279889a2364Smrg			| z8k | z80)
1280889a2364Smrg				;;
1281889a2364Smrg
1282889a2364Smrg			*)
1283889a2364Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1284889a2364Smrg				exit 1
1285889a2364Smrg				;;
1286889a2364Smrg		esac
128721c2f794Smrg		;;
128821c2f794Smrgesac
128921c2f794Smrg
129021c2f794Smrg# Here we canonicalize certain aliases for manufacturers.
1291889a2364Smrgcase $vendor in
1292889a2364Smrg	digital*)
1293889a2364Smrg		vendor=dec
129421c2f794Smrg		;;
1295889a2364Smrg	commodore*)
1296889a2364Smrg		vendor=cbm
129721c2f794Smrg		;;
129821c2f794Smrg	*)
129921c2f794Smrg		;;
130021c2f794Smrgesac
130121c2f794Smrg
130221c2f794Smrg# Decode manufacturer-specific aliases for certain operating systems.
130321c2f794Smrg
1304889a2364Smrgif test x$basic_os != x
130521c2f794Smrgthen
1306889a2364Smrg
1307889a2364Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1308889a2364Smrg# set os.
1309889a2364Smrgcase $basic_os in
1310889a2364Smrg	gnu/linux*)
1311889a2364Smrg		kernel=linux
1312889a2364Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1313889a2364Smrg		;;
1314889a2364Smrg	os2-emx)
1315889a2364Smrg		kernel=os2
1316889a2364Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1317889a2364Smrg		;;
1318889a2364Smrg	nto-qnx*)
1319889a2364Smrg		kernel=nto
1320889a2364Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1321889a2364Smrg		;;
1322889a2364Smrg	*-*)
1323889a2364Smrg		# shellcheck disable=SC2162
1324889a2364Smrg		saved_IFS=$IFS
1325889a2364Smrg		IFS="-" read kernel os <<EOF
1326889a2364Smrg$basic_os
1327889a2364SmrgEOF
1328889a2364Smrg		IFS=$saved_IFS
1329889a2364Smrg		;;
1330889a2364Smrg	# Default OS when just kernel was specified
1331889a2364Smrg	nto*)
1332889a2364Smrg		kernel=nto
1333889a2364Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1334889a2364Smrg		;;
1335889a2364Smrg	linux*)
1336889a2364Smrg		kernel=linux
1337889a2364Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1338889a2364Smrg		;;
1339889a2364Smrg	*)
1340889a2364Smrg		kernel=
1341889a2364Smrg		os=$basic_os
1342889a2364Smrg		;;
1343889a2364Smrgesac
1344889a2364Smrg
1345889a2364Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1346889a2364Smrg# etc.)
134721c2f794Smrgcase $os in
1348889a2364Smrg	# First match some system type aliases that might get confused
1349889a2364Smrg	# with valid system types.
1350889a2364Smrg	# solaris* is a basic system type, with this one exception.
1351889a2364Smrg	auroraux)
1352889a2364Smrg		os=auroraux
135312391620Smrg		;;
1354889a2364Smrg	bluegene*)
1355889a2364Smrg		os=cnk
135621c2f794Smrg		;;
1357889a2364Smrg	solaris1 | solaris1.*)
1358889a2364Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
135921c2f794Smrg		;;
1360889a2364Smrg	solaris)
1361889a2364Smrg		os=solaris2
136221c2f794Smrg		;;
1363889a2364Smrg	unixware*)
1364889a2364Smrg		os=sysv4.2uw
136521c2f794Smrg		;;
1366889a2364Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1367889a2364Smrg	es1800*)
1368889a2364Smrg		os=ose
136921c2f794Smrg		;;
1370889a2364Smrg	# Some version numbers need modification
1371889a2364Smrg	chorusos*)
1372889a2364Smrg		os=chorusos
137321c2f794Smrg		;;
1374889a2364Smrg	isc)
1375889a2364Smrg		os=isc2.2
137621c2f794Smrg		;;
1377889a2364Smrg	sco6)
1378889a2364Smrg		os=sco5v6
137921c2f794Smrg		;;
1380889a2364Smrg	sco5)
1381889a2364Smrg		os=sco3.2v5
138221c2f794Smrg		;;
1383889a2364Smrg	sco4)
1384889a2364Smrg		os=sco3.2v4
138521c2f794Smrg		;;
1386889a2364Smrg	sco3.2.[4-9]*)
1387889a2364Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
138821c2f794Smrg		;;
1389889a2364Smrg	sco*v* | scout)
1390889a2364Smrg		# Don't match below
139121c2f794Smrg		;;
1392889a2364Smrg	sco*)
1393889a2364Smrg		os=sco3.2v2
139421c2f794Smrg		;;
1395889a2364Smrg	psos*)
1396889a2364Smrg		os=psos
139721c2f794Smrg		;;
1398889a2364Smrg	qnx*)
1399889a2364Smrg		os=qnx
140021c2f794Smrg		;;
1401889a2364Smrg	hiux*)
1402889a2364Smrg		os=hiuxwe2
140321c2f794Smrg		;;
1404889a2364Smrg	lynx*178)
1405889a2364Smrg		os=lynxos178
140621c2f794Smrg		;;
1407889a2364Smrg	lynx*5)
1408889a2364Smrg		os=lynxos5
140921c2f794Smrg		;;
1410889a2364Smrg	lynxos*)
1411889a2364Smrg		# don't get caught up in next wildcard
141221c2f794Smrg		;;
1413889a2364Smrg	lynx*)
1414889a2364Smrg		os=lynxos
141521c2f794Smrg		;;
1416889a2364Smrg	mac[0-9]*)
1417889a2364Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
141821c2f794Smrg		;;
1419889a2364Smrg	opened*)
1420889a2364Smrg		os=openedition
142121c2f794Smrg		;;
1422889a2364Smrg	os400*)
1423889a2364Smrg		os=os400
142421c2f794Smrg		;;
1425889a2364Smrg	sunos5*)
1426889a2364Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
142721c2f794Smrg		;;
1428889a2364Smrg	sunos6*)
1429889a2364Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
143021c2f794Smrg		;;
1431889a2364Smrg	wince*)
1432889a2364Smrg		os=wince
143321c2f794Smrg		;;
1434889a2364Smrg	utek*)
1435889a2364Smrg		os=bsd
143621c2f794Smrg		;;
1437889a2364Smrg	dynix*)
1438889a2364Smrg		os=bsd
143921c2f794Smrg		;;
1440889a2364Smrg	acis*)
1441889a2364Smrg		os=aos
144221c2f794Smrg		;;
1443889a2364Smrg	atheos*)
1444889a2364Smrg		os=atheos
144521c2f794Smrg		;;
1446889a2364Smrg	syllable*)
1447889a2364Smrg		os=syllable
144821c2f794Smrg		;;
1449889a2364Smrg	386bsd)
1450889a2364Smrg		os=bsd
145121c2f794Smrg		;;
1452889a2364Smrg	ctix* | uts*)
1453889a2364Smrg		os=sysv
145421c2f794Smrg		;;
1455889a2364Smrg	nova*)
1456889a2364Smrg		os=rtmk-nova
145721c2f794Smrg		;;
1458889a2364Smrg	ns2)
1459889a2364Smrg		os=nextstep2
146021c2f794Smrg		;;
1461889a2364Smrg	# Preserve the version number of sinix5.
1462889a2364Smrg	sinix5.*)
1463889a2364Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
146421c2f794Smrg		;;
1465889a2364Smrg	sinix*)
1466889a2364Smrg		os=sysv4
146721c2f794Smrg		;;
1468889a2364Smrg	tpf*)
1469889a2364Smrg		os=tpf
147021c2f794Smrg		;;
1471889a2364Smrg	triton*)
1472889a2364Smrg		os=sysv3
147321c2f794Smrg		;;
1474889a2364Smrg	oss*)
1475889a2364Smrg		os=sysv3
147621c2f794Smrg		;;
1477889a2364Smrg	svr4*)
1478889a2364Smrg		os=sysv4
147921c2f794Smrg		;;
1480889a2364Smrg	svr3)
1481889a2364Smrg		os=sysv3
148221c2f794Smrg		;;
1483889a2364Smrg	sysvr4)
1484889a2364Smrg		os=sysv4
148521c2f794Smrg		;;
1486889a2364Smrg	ose*)
1487889a2364Smrg		os=ose
148821c2f794Smrg		;;
1489889a2364Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1490889a2364Smrg		os=mint
149112391620Smrg		;;
1492889a2364Smrg	dicos*)
1493889a2364Smrg		os=dicos
149482e12b1bSmrg		;;
1495889a2364Smrg	pikeos*)
1496889a2364Smrg		# Until real need of OS specific support for
1497889a2364Smrg		# particular features comes up, bare metal
1498889a2364Smrg		# configurations are quite functional.
1499889a2364Smrg		case $cpu in
1500889a2364Smrg		    arm*)
1501889a2364Smrg			os=eabi
1502889a2364Smrg			;;
1503889a2364Smrg		    *)
1504889a2364Smrg			os=elf
1505889a2364Smrg			;;
1506889a2364Smrg		esac
150721c2f794Smrg		;;
150821c2f794Smrg	*)
1509889a2364Smrg		# No normalization, but not necessarily accepted, that comes below.
151021c2f794Smrg		;;
151121c2f794Smrgesac
1512889a2364Smrg
151321c2f794Smrgelse
151421c2f794Smrg
151521c2f794Smrg# Here we handle the default operating systems that come with various machines.
151621c2f794Smrg# The value should be what the vendor currently ships out the door with their
151721c2f794Smrg# machine or put another way, the most popular os provided with the machine.
151821c2f794Smrg
151921c2f794Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
152021c2f794Smrg# "-sun"), then you have to tell the case statement up towards the top
152121c2f794Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
152221c2f794Smrg# will signal an error saying that MANUFACTURER isn't an operating
152321c2f794Smrg# system, and we'll never get to this point.
152421c2f794Smrg
1525889a2364Smrgkernel=
1526889a2364Smrgcase $cpu-$vendor in
152782e12b1bSmrg	score-*)
1528889a2364Smrg		os=elf
152921c2f794Smrg		;;
153082e12b1bSmrg	spu-*)
1531889a2364Smrg		os=elf
153221c2f794Smrg		;;
153321c2f794Smrg	*-acorn)
1534889a2364Smrg		os=riscix1.2
153521c2f794Smrg		;;
153621c2f794Smrg	arm*-rebel)
1537889a2364Smrg		kernel=linux
1538889a2364Smrg		os=gnu
153921c2f794Smrg		;;
154021c2f794Smrg	arm*-semi)
1541889a2364Smrg		os=aout
154221c2f794Smrg		;;
154382e12b1bSmrg	c4x-* | tic4x-*)
1544889a2364Smrg		os=coff
154521c2f794Smrg		;;
15461b2353dbSmrg	c8051-*)
1547889a2364Smrg		os=elf
1548889a2364Smrg		;;
1549889a2364Smrg	clipper-intergraph)
1550889a2364Smrg		os=clix
15511b2353dbSmrg		;;
15521b2353dbSmrg	hexagon-*)
1553889a2364Smrg		os=elf
15541b2353dbSmrg		;;
155512391620Smrg	tic54x-*)
1556889a2364Smrg		os=coff
155712391620Smrg		;;
155812391620Smrg	tic55x-*)
1559889a2364Smrg		os=coff
156012391620Smrg		;;
156112391620Smrg	tic6x-*)
1562889a2364Smrg		os=coff
156312391620Smrg		;;
156421c2f794Smrg	# This must come before the *-dec entry.
156521c2f794Smrg	pdp10-*)
1566889a2364Smrg		os=tops20
156721c2f794Smrg		;;
156821c2f794Smrg	pdp11-*)
1569889a2364Smrg		os=none
157021c2f794Smrg		;;
157121c2f794Smrg	*-dec | vax-*)
1572889a2364Smrg		os=ultrix4.2
157321c2f794Smrg		;;
157421c2f794Smrg	m68*-apollo)
1575889a2364Smrg		os=domain
157621c2f794Smrg		;;
157721c2f794Smrg	i386-sun)
1578889a2364Smrg		os=sunos4.0.2
157921c2f794Smrg		;;
158021c2f794Smrg	m68000-sun)
1581889a2364Smrg		os=sunos3
158221c2f794Smrg		;;
158321c2f794Smrg	m68*-cisco)
1584889a2364Smrg		os=aout
158521c2f794Smrg		;;
158682e12b1bSmrg	mep-*)
1587889a2364Smrg		os=elf
158821c2f794Smrg		;;
158921c2f794Smrg	mips*-cisco)
1590889a2364Smrg		os=elf
159121c2f794Smrg		;;
159221c2f794Smrg	mips*-*)
1593889a2364Smrg		os=elf
15941b2353dbSmrg		;;
159521c2f794Smrg	or32-*)
1596889a2364Smrg		os=coff
159721c2f794Smrg		;;
159821c2f794Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1599889a2364Smrg		os=sysv3
160021c2f794Smrg		;;
160121c2f794Smrg	sparc-* | *-sun)
1602889a2364Smrg		os=sunos4.1.1
160321c2f794Smrg		;;
1604889a2364Smrg	pru-*)
1605889a2364Smrg		os=elf
160621c2f794Smrg		;;
1607889a2364Smrg	*-be)
1608889a2364Smrg		os=beos
160921c2f794Smrg		;;
161021c2f794Smrg	*-ibm)
1611889a2364Smrg		os=aix
161221c2f794Smrg		;;
161382e12b1bSmrg	*-knuth)
1614889a2364Smrg		os=mmixware
161521c2f794Smrg		;;
161621c2f794Smrg	*-wec)
1617889a2364Smrg		os=proelf
161821c2f794Smrg		;;
161921c2f794Smrg	*-winbond)
1620889a2364Smrg		os=proelf
162121c2f794Smrg		;;
162221c2f794Smrg	*-oki)
1623889a2364Smrg		os=proelf
162421c2f794Smrg		;;
162521c2f794Smrg	*-hp)
1626889a2364Smrg		os=hpux
162721c2f794Smrg		;;
162821c2f794Smrg	*-hitachi)
1629889a2364Smrg		os=hiux
163021c2f794Smrg		;;
163121c2f794Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1632889a2364Smrg		os=sysv
163321c2f794Smrg		;;
163421c2f794Smrg	*-cbm)
1635889a2364Smrg		os=amigaos
163621c2f794Smrg		;;
163721c2f794Smrg	*-dg)
1638889a2364Smrg		os=dgux
163921c2f794Smrg		;;
164021c2f794Smrg	*-dolphin)
1641889a2364Smrg		os=sysv3
164221c2f794Smrg		;;
164321c2f794Smrg	m68k-ccur)
1644889a2364Smrg		os=rtu
164521c2f794Smrg		;;
164621c2f794Smrg	m88k-omron*)
1647889a2364Smrg		os=luna
164821c2f794Smrg		;;
1649889a2364Smrg	*-next)
1650889a2364Smrg		os=nextstep
165121c2f794Smrg		;;
165221c2f794Smrg	*-sequent)
1653889a2364Smrg		os=ptx
165421c2f794Smrg		;;
165521c2f794Smrg	*-crds)
1656889a2364Smrg		os=unos
165721c2f794Smrg		;;
165821c2f794Smrg	*-ns)
1659889a2364Smrg		os=genix
166021c2f794Smrg		;;
166121c2f794Smrg	i370-*)
1662889a2364Smrg		os=mvs
166321c2f794Smrg		;;
166421c2f794Smrg	*-gould)
1665889a2364Smrg		os=sysv
166621c2f794Smrg		;;
166721c2f794Smrg	*-highlevel)
1668889a2364Smrg		os=bsd
166921c2f794Smrg		;;
167021c2f794Smrg	*-encore)
1671889a2364Smrg		os=bsd
167221c2f794Smrg		;;
167321c2f794Smrg	*-sgi)
1674889a2364Smrg		os=irix
167521c2f794Smrg		;;
167621c2f794Smrg	*-siemens)
1677889a2364Smrg		os=sysv4
167821c2f794Smrg		;;
167921c2f794Smrg	*-masscomp)
1680889a2364Smrg		os=rtu
168121c2f794Smrg		;;
168221c2f794Smrg	f30[01]-fujitsu | f700-fujitsu)
1683889a2364Smrg		os=uxpv
168421c2f794Smrg		;;
168521c2f794Smrg	*-rom68k)
1686889a2364Smrg		os=coff
168721c2f794Smrg		;;
168821c2f794Smrg	*-*bug)
1689889a2364Smrg		os=coff
169021c2f794Smrg		;;
169121c2f794Smrg	*-apple)
1692889a2364Smrg		os=macos
169321c2f794Smrg		;;
169421c2f794Smrg	*-atari*)
1695889a2364Smrg		os=mint
1696889a2364Smrg		;;
1697889a2364Smrg	*-wrs)
1698889a2364Smrg		os=vxworks
169921c2f794Smrg		;;
170021c2f794Smrg	*)
1701889a2364Smrg		os=none
170221c2f794Smrg		;;
170321c2f794Smrgesac
1704889a2364Smrg
170521c2f794Smrgfi
170621c2f794Smrg
1707889a2364Smrg# Now, validate our (potentially fixed-up) OS.
1708889a2364Smrgcase $os in
1709889a2364Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1710889a2364Smrg	musl* | newlib* | relibc* | uclibc*)
1711889a2364Smrg		;;
1712889a2364Smrg	# Likewise for "kernel-abi"
1713889a2364Smrg	eabi* | gnueabi*)
1714889a2364Smrg		;;
1715889a2364Smrg	# VxWorks passes extra cpu info in the 4th filed.
1716889a2364Smrg	simlinux | simwindows | spe)
1717889a2364Smrg		;;
1718889a2364Smrg	# Now accept the basic system types.
1719889a2364Smrg	# The portable systems comes first.
1720889a2364Smrg	# Each alternative MUST end in a * to match a version number.
1721889a2364Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1722889a2364Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1723889a2364Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1724889a2364Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1725889a2364Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1726889a2364Smrg	     | os9* | macos* | osx* | ios* \
1727889a2364Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1728889a2364Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1729889a2364Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1730889a2364Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1731889a2364Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1732889a2364Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1733889a2364Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1734889a2364Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1735889a2364Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1736889a2364Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1737889a2364Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1738889a2364Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1739889a2364Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1740889a2364Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1741889a2364Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1742889a2364Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1743889a2364Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1744889a2364Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1745889a2364Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1746889a2364Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1747889a2364Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1748889a2364Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1749889a2364Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1750889a2364Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1751889a2364Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
1752889a2364Smrg		;;
1753889a2364Smrg	# This one is extra strict with allowed versions
1754889a2364Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1755889a2364Smrg		# Don't forget version if it is 3.2v4 or newer.
1756889a2364Smrg		;;
1757889a2364Smrg	none)
1758889a2364Smrg		;;
1759889a2364Smrg	*)
1760889a2364Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1761889a2364Smrg		exit 1
1762889a2364Smrg		;;
1763889a2364Smrgesac
1764889a2364Smrg
1765889a2364Smrg# As a final step for OS-related things, validate the OS-kernel combination
1766889a2364Smrg# (given a valid OS), if there is a kernel.
1767889a2364Smrgcase $kernel-$os in
1768889a2364Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1769889a2364Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
1770889a2364Smrg		;;
1771889a2364Smrg	uclinux-uclibc* )
1772889a2364Smrg		;;
1773889a2364Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
1774889a2364Smrg		# These are just libc implementations, not actual OSes, and thus
1775889a2364Smrg		# require a kernel.
1776889a2364Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1777889a2364Smrg		exit 1
1778889a2364Smrg		;;
1779889a2364Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1780889a2364Smrg		;;
1781889a2364Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1782889a2364Smrg		;;
1783889a2364Smrg	nto-qnx*)
1784889a2364Smrg		;;
1785889a2364Smrg	os2-emx)
1786889a2364Smrg		;;
1787889a2364Smrg	*-eabi* | *-gnueabi*)
1788889a2364Smrg		;;
1789889a2364Smrg	-*)
1790889a2364Smrg		# Blank kernel with real OS is always fine.
1791889a2364Smrg		;;
1792889a2364Smrg	*-*)
1793889a2364Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1794889a2364Smrg		exit 1
1795889a2364Smrg		;;
1796889a2364Smrgesac
1797889a2364Smrg
179821c2f794Smrg# Here we handle the case where we know the os, and the CPU type, but not the
179921c2f794Smrg# manufacturer.  We pick the logical manufacturer.
1800889a2364Smrgcase $vendor in
1801889a2364Smrg	unknown)
1802889a2364Smrg		case $cpu-$os in
1803889a2364Smrg			*-riscix*)
180421c2f794Smrg				vendor=acorn
180521c2f794Smrg				;;
1806889a2364Smrg			*-sunos*)
180721c2f794Smrg				vendor=sun
180821c2f794Smrg				;;
1809889a2364Smrg			*-cnk* | *-aix*)
181021c2f794Smrg				vendor=ibm
181121c2f794Smrg				;;
1812889a2364Smrg			*-beos*)
181321c2f794Smrg				vendor=be
181421c2f794Smrg				;;
1815889a2364Smrg			*-hpux*)
181621c2f794Smrg				vendor=hp
181721c2f794Smrg				;;
1818889a2364Smrg			*-mpeix*)
181921c2f794Smrg				vendor=hp
182021c2f794Smrg				;;
1821889a2364Smrg			*-hiux*)
182221c2f794Smrg				vendor=hitachi
182321c2f794Smrg				;;
1824889a2364Smrg			*-unos*)
182521c2f794Smrg				vendor=crds
182621c2f794Smrg				;;
1827889a2364Smrg			*-dgux*)
182821c2f794Smrg				vendor=dg
182921c2f794Smrg				;;
1830889a2364Smrg			*-luna*)
183121c2f794Smrg				vendor=omron
183221c2f794Smrg				;;
1833889a2364Smrg			*-genix*)
183421c2f794Smrg				vendor=ns
183521c2f794Smrg				;;
1836889a2364Smrg			*-clix*)
1837889a2364Smrg				vendor=intergraph
1838889a2364Smrg				;;
1839889a2364Smrg			*-mvs* | *-opened*)
1840889a2364Smrg				vendor=ibm
1841889a2364Smrg				;;
1842889a2364Smrg			*-os400*)
184321c2f794Smrg				vendor=ibm
184421c2f794Smrg				;;
1845889a2364Smrg			s390-* | s390x-*)
184621c2f794Smrg				vendor=ibm
184721c2f794Smrg				;;
1848889a2364Smrg			*-ptx*)
184921c2f794Smrg				vendor=sequent
185021c2f794Smrg				;;
1851889a2364Smrg			*-tpf*)
185221c2f794Smrg				vendor=ibm
185321c2f794Smrg				;;
1854889a2364Smrg			*-vxsim* | *-vxworks* | *-windiss*)
185521c2f794Smrg				vendor=wrs
185621c2f794Smrg				;;
1857889a2364Smrg			*-aux*)
185821c2f794Smrg				vendor=apple
185921c2f794Smrg				;;
1860889a2364Smrg			*-hms*)
186121c2f794Smrg				vendor=hitachi
186221c2f794Smrg				;;
1863889a2364Smrg			*-mpw* | *-macos*)
186421c2f794Smrg				vendor=apple
186521c2f794Smrg				;;
1866889a2364Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
186721c2f794Smrg				vendor=atari
186821c2f794Smrg				;;
1869889a2364Smrg			*-vos*)
187021c2f794Smrg				vendor=stratus
187121c2f794Smrg				;;
187221c2f794Smrg		esac
187321c2f794Smrg		;;
187421c2f794Smrgesac
187521c2f794Smrg
1876889a2364Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
187721c2f794Smrgexit
187821c2f794Smrg
187921c2f794Smrg# Local variables:
1880889a2364Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
188121c2f794Smrg# time-stamp-start: "timestamp='"
188221c2f794Smrg# time-stamp-format: "%:y-%02m-%02d"
188321c2f794Smrg# time-stamp-end: "'"
188421c2f794Smrg# End:
1885