14b0ead49Smrg#! /bin/sh
24b0ead49Smrg# Configuration validation subroutine script.
3c3e29c03Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
44b0ead49Smrg
5c3e29c03Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6c3e29c03Smrg
7c3e29c03Smrgtimestamp='2021-08-14'
84b0ead49Smrg
926372658Smrg# This file is free software; you can redistribute it and/or modify it
1026372658Smrg# under the terms of the GNU General Public License as published by
1126372658Smrg# the Free Software Foundation; either version 3 of the License, or
124b0ead49Smrg# (at your option) any later version.
134b0ead49Smrg#
1426372658Smrg# This program is distributed in the hope that it will be useful, but
1526372658Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1626372658Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1726372658Smrg# General Public License for more details.
184b0ead49Smrg#
194b0ead49Smrg# You should have received a copy of the GNU General Public License
2026372658Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
214b0ead49Smrg#
224b0ead49Smrg# As a special exception to the GNU General Public License, if you
234b0ead49Smrg# distribute this file as part of a program that contains a
244b0ead49Smrg# configuration script generated by Autoconf, you may include it under
2526372658Smrg# the same distribution terms that you use for the rest of that
2626372658Smrg# program.  This Exception is an additional permission under section 7
2726372658Smrg# of the GNU General Public License, version 3 ("GPLv3").
284b0ead49Smrg
294b0ead49Smrg
3026372658Smrg# Please send patches to <config-patches@gnu.org>.
314b0ead49Smrg#
324b0ead49Smrg# Configuration subroutine to validate and canonicalize a configuration type.
334b0ead49Smrg# Supply the specified configuration type as an argument.
344b0ead49Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
354b0ead49Smrg# Otherwise, we print the canonical config type on stdout and succeed.
364b0ead49Smrg
3749dc963fSmrg# You can get the latest version of this script from:
38c3e29c03Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3949dc963fSmrg
404b0ead49Smrg# This file is supposed to be the same for all GNU packages
414b0ead49Smrg# and recognize all the CPU types, system types and aliases
424b0ead49Smrg# that are meaningful with *any* GNU software.
434b0ead49Smrg# Each package is responsible for reporting which valid configurations
444b0ead49Smrg# it does not support.  The user should be able to distinguish
454b0ead49Smrg# a failure to support a valid configuration from a meaningless
464b0ead49Smrg# configuration.
474b0ead49Smrg
484b0ead49Smrg# The goal of this file is to map all the various variations of a given
494b0ead49Smrg# machine specification into a single specification in the form:
504b0ead49Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
514b0ead49Smrg# or in some cases, the newer four-part form:
524b0ead49Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
534b0ead49Smrg# It is wrong to echo any other type of specification.
544b0ead49Smrg
55c3e29c03Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56c3e29c03Smrg# about features and limitations of the classic Bourne shell that were
57c3e29c03Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58c3e29c03Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59c3e29c03Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60c3e29c03Smrg# have a pre-POSIX /bin/sh.
61c3e29c03Smrg
624b0ead49Smrgme=`echo "$0" | sed -e 's,.*/,,'`
634b0ead49Smrg
644b0ead49Smrgusage="\
6526372658SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
664b0ead49Smrg
674b0ead49SmrgCanonicalize a configuration name.
684b0ead49Smrg
6926372658SmrgOptions:
704b0ead49Smrg  -h, --help         print this help, then exit
714b0ead49Smrg  -t, --time-stamp   print date of last modification, then exit
724b0ead49Smrg  -v, --version      print version number, then exit
734b0ead49Smrg
744b0ead49SmrgReport bugs and patches to <config-patches@gnu.org>."
754b0ead49Smrg
764b0ead49Smrgversion="\
774b0ead49SmrgGNU config.sub ($timestamp)
784b0ead49Smrg
79c3e29c03SmrgCopyright 1992-2021 Free Software Foundation, Inc.
804b0ead49Smrg
814b0ead49SmrgThis is free software; see the source for copying conditions.  There is NO
824b0ead49Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
834b0ead49Smrg
844b0ead49Smrghelp="
854b0ead49SmrgTry \`$me --help' for more information."
864b0ead49Smrg
874b0ead49Smrg# Parse command line
884b0ead49Smrgwhile test $# -gt 0 ; do
894b0ead49Smrg  case $1 in
904b0ead49Smrg    --time-stamp | --time* | -t )
914b0ead49Smrg       echo "$timestamp" ; exit ;;
924b0ead49Smrg    --version | -v )
934b0ead49Smrg       echo "$version" ; exit ;;
944b0ead49Smrg    --help | --h* | -h )
954b0ead49Smrg       echo "$usage"; exit ;;
964b0ead49Smrg    -- )     # Stop option processing
974b0ead49Smrg       shift; break ;;
984b0ead49Smrg    - )	# Use stdin as input.
994b0ead49Smrg       break ;;
1004b0ead49Smrg    -* )
101c3e29c03Smrg       echo "$me: invalid option $1$help" >&2
1024b0ead49Smrg       exit 1 ;;
1034b0ead49Smrg
1044b0ead49Smrg    *local*)
1054b0ead49Smrg       # First pass through any local machine types.
10626372658Smrg       echo "$1"
1074b0ead49Smrg       exit ;;
1084b0ead49Smrg
1094b0ead49Smrg    * )
1104b0ead49Smrg       break ;;
1114b0ead49Smrg  esac
1124b0ead49Smrgdone
1134b0ead49Smrg
1144b0ead49Smrgcase $# in
1154b0ead49Smrg 0) echo "$me: missing argument$help" >&2
1164b0ead49Smrg    exit 1;;
1174b0ead49Smrg 1) ;;
1184b0ead49Smrg *) echo "$me: too many arguments$help" >&2
1194b0ead49Smrg    exit 1;;
1204b0ead49Smrgesac
1214b0ead49Smrg
122c3e29c03Smrg# Split fields of configuration type
123c3e29c03Smrg# shellcheck disable=SC2162
124c3e29c03Smrgsaved_IFS=$IFS
125c3e29c03SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126c3e29c03Smrg$1
127c3e29c03SmrgEOF
128c3e29c03SmrgIFS=$saved_IFS
1294b0ead49Smrg
130c3e29c03Smrg# Separate into logical components for further validation
131c3e29c03Smrgcase $1 in
132c3e29c03Smrg	*-*-*-*-*)
133c3e29c03Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134c3e29c03Smrg		exit 1
1354b0ead49Smrg		;;
136c3e29c03Smrg	*-*-*-*)
137c3e29c03Smrg		basic_machine=$field1-$field2
138c3e29c03Smrg		basic_os=$field3-$field4
1394b0ead49Smrg		;;
140c3e29c03Smrg	*-*-*)
141c3e29c03Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142c3e29c03Smrg		# parts
143c3e29c03Smrg		maybe_os=$field2-$field3
144c3e29c03Smrg		case $maybe_os in
145c3e29c03Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146c3e29c03Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147c3e29c03Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148c3e29c03Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
149c3e29c03Smrg				basic_machine=$field1
150c3e29c03Smrg				basic_os=$maybe_os
151c3e29c03Smrg				;;
152c3e29c03Smrg			android-linux)
153c3e29c03Smrg				basic_machine=$field1-unknown
154c3e29c03Smrg				basic_os=linux-android
155c3e29c03Smrg				;;
156c3e29c03Smrg			*)
157c3e29c03Smrg				basic_machine=$field1-$field2
158c3e29c03Smrg				basic_os=$field3
159c3e29c03Smrg				;;
160c3e29c03Smrg		esac
1614b0ead49Smrg		;;
162c3e29c03Smrg	*-*)
163c3e29c03Smrg		# A lone config we happen to match not fitting any pattern
164c3e29c03Smrg		case $field1-$field2 in
165c3e29c03Smrg			decstation-3100)
166c3e29c03Smrg				basic_machine=mips-dec
167c3e29c03Smrg				basic_os=
168c3e29c03Smrg				;;
169c3e29c03Smrg			*-*)
170c3e29c03Smrg				# Second component is usually, but not always the OS
171c3e29c03Smrg				case $field2 in
172c3e29c03Smrg					# Prevent following clause from handling this valid os
173c3e29c03Smrg					sun*os*)
174c3e29c03Smrg						basic_machine=$field1
175c3e29c03Smrg						basic_os=$field2
176c3e29c03Smrg						;;
177c3e29c03Smrg					zephyr*)
178c3e29c03Smrg						basic_machine=$field1-unknown
179c3e29c03Smrg						basic_os=$field2
180c3e29c03Smrg						;;
181c3e29c03Smrg					# Manufacturers
182c3e29c03Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183c3e29c03Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184c3e29c03Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185c3e29c03Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186c3e29c03Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187c3e29c03Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188c3e29c03Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189c3e29c03Smrg					| microblaze* | sim | cisco \
190c3e29c03Smrg					| oki | wec | wrs | winbond)
191c3e29c03Smrg						basic_machine=$field1-$field2
192c3e29c03Smrg						basic_os=
193c3e29c03Smrg						;;
194c3e29c03Smrg					*)
195c3e29c03Smrg						basic_machine=$field1
196c3e29c03Smrg						basic_os=$field2
197c3e29c03Smrg						;;
198c3e29c03Smrg				esac
199c3e29c03Smrg			;;
200c3e29c03Smrg		esac
2014b0ead49Smrg		;;
202c3e29c03Smrg	*)
203c3e29c03Smrg		# Convert single-component short-hands not valid as part of
204c3e29c03Smrg		# multi-component configurations.
205c3e29c03Smrg		case $field1 in
206c3e29c03Smrg			386bsd)
207c3e29c03Smrg				basic_machine=i386-pc
208c3e29c03Smrg				basic_os=bsd
209c3e29c03Smrg				;;
210c3e29c03Smrg			a29khif)
211c3e29c03Smrg				basic_machine=a29k-amd
212c3e29c03Smrg				basic_os=udi
213c3e29c03Smrg				;;
214c3e29c03Smrg			adobe68k)
215c3e29c03Smrg				basic_machine=m68010-adobe
216c3e29c03Smrg				basic_os=scout
217c3e29c03Smrg				;;
218c3e29c03Smrg			alliant)
219c3e29c03Smrg				basic_machine=fx80-alliant
220c3e29c03Smrg				basic_os=
221c3e29c03Smrg				;;
222c3e29c03Smrg			altos | altos3068)
223c3e29c03Smrg				basic_machine=m68k-altos
224c3e29c03Smrg				basic_os=
225c3e29c03Smrg				;;
226c3e29c03Smrg			am29k)
227c3e29c03Smrg				basic_machine=a29k-none
228c3e29c03Smrg				basic_os=bsd
229c3e29c03Smrg				;;
230c3e29c03Smrg			amdahl)
231c3e29c03Smrg				basic_machine=580-amdahl
232c3e29c03Smrg				basic_os=sysv
233c3e29c03Smrg				;;
234c3e29c03Smrg			amiga)
235c3e29c03Smrg				basic_machine=m68k-unknown
236c3e29c03Smrg				basic_os=
237c3e29c03Smrg				;;
238c3e29c03Smrg			amigaos | amigados)
239c3e29c03Smrg				basic_machine=m68k-unknown
240c3e29c03Smrg				basic_os=amigaos
241c3e29c03Smrg				;;
242c3e29c03Smrg			amigaunix | amix)
243c3e29c03Smrg				basic_machine=m68k-unknown
244c3e29c03Smrg				basic_os=sysv4
245c3e29c03Smrg				;;
246c3e29c03Smrg			apollo68)
247c3e29c03Smrg				basic_machine=m68k-apollo
248c3e29c03Smrg				basic_os=sysv
249c3e29c03Smrg				;;
250c3e29c03Smrg			apollo68bsd)
251c3e29c03Smrg				basic_machine=m68k-apollo
252c3e29c03Smrg				basic_os=bsd
253c3e29c03Smrg				;;
254c3e29c03Smrg			aros)
255c3e29c03Smrg				basic_machine=i386-pc
256c3e29c03Smrg				basic_os=aros
257c3e29c03Smrg				;;
258c3e29c03Smrg			aux)
259c3e29c03Smrg				basic_machine=m68k-apple
260c3e29c03Smrg				basic_os=aux
261c3e29c03Smrg				;;
262c3e29c03Smrg			balance)
263c3e29c03Smrg				basic_machine=ns32k-sequent
264c3e29c03Smrg				basic_os=dynix
265c3e29c03Smrg				;;
266c3e29c03Smrg			blackfin)
267c3e29c03Smrg				basic_machine=bfin-unknown
268c3e29c03Smrg				basic_os=linux
269c3e29c03Smrg				;;
270c3e29c03Smrg			cegcc)
271c3e29c03Smrg				basic_machine=arm-unknown
272c3e29c03Smrg				basic_os=cegcc
273c3e29c03Smrg				;;
274c3e29c03Smrg			convex-c1)
275c3e29c03Smrg				basic_machine=c1-convex
276c3e29c03Smrg				basic_os=bsd
277c3e29c03Smrg				;;
278c3e29c03Smrg			convex-c2)
279c3e29c03Smrg				basic_machine=c2-convex
280c3e29c03Smrg				basic_os=bsd
281c3e29c03Smrg				;;
282c3e29c03Smrg			convex-c32)
283c3e29c03Smrg				basic_machine=c32-convex
284c3e29c03Smrg				basic_os=bsd
285c3e29c03Smrg				;;
286c3e29c03Smrg			convex-c34)
287c3e29c03Smrg				basic_machine=c34-convex
288c3e29c03Smrg				basic_os=bsd
289c3e29c03Smrg				;;
290c3e29c03Smrg			convex-c38)
291c3e29c03Smrg				basic_machine=c38-convex
292c3e29c03Smrg				basic_os=bsd
293c3e29c03Smrg				;;
294c3e29c03Smrg			cray)
295c3e29c03Smrg				basic_machine=j90-cray
296c3e29c03Smrg				basic_os=unicos
297c3e29c03Smrg				;;
298c3e29c03Smrg			crds | unos)
299c3e29c03Smrg				basic_machine=m68k-crds
300c3e29c03Smrg				basic_os=
301c3e29c03Smrg				;;
302c3e29c03Smrg			da30)
303c3e29c03Smrg				basic_machine=m68k-da30
304c3e29c03Smrg				basic_os=
305c3e29c03Smrg				;;
306c3e29c03Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307c3e29c03Smrg				basic_machine=mips-dec
308c3e29c03Smrg				basic_os=
309c3e29c03Smrg				;;
310c3e29c03Smrg			delta88)
311c3e29c03Smrg				basic_machine=m88k-motorola
312c3e29c03Smrg				basic_os=sysv3
313c3e29c03Smrg				;;
314c3e29c03Smrg			dicos)
315c3e29c03Smrg				basic_machine=i686-pc
316c3e29c03Smrg				basic_os=dicos
317c3e29c03Smrg				;;
318c3e29c03Smrg			djgpp)
319c3e29c03Smrg				basic_machine=i586-pc
320c3e29c03Smrg				basic_os=msdosdjgpp
321c3e29c03Smrg				;;
322c3e29c03Smrg			ebmon29k)
323c3e29c03Smrg				basic_machine=a29k-amd
324c3e29c03Smrg				basic_os=ebmon
325c3e29c03Smrg				;;
326c3e29c03Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327c3e29c03Smrg				basic_machine=m68k-ericsson
328c3e29c03Smrg				basic_os=ose
329c3e29c03Smrg				;;
330c3e29c03Smrg			gmicro)
331c3e29c03Smrg				basic_machine=tron-gmicro
332c3e29c03Smrg				basic_os=sysv
333c3e29c03Smrg				;;
334c3e29c03Smrg			go32)
335c3e29c03Smrg				basic_machine=i386-pc
336c3e29c03Smrg				basic_os=go32
337c3e29c03Smrg				;;
338c3e29c03Smrg			h8300hms)
339c3e29c03Smrg				basic_machine=h8300-hitachi
340c3e29c03Smrg				basic_os=hms
341c3e29c03Smrg				;;
342c3e29c03Smrg			h8300xray)
343c3e29c03Smrg				basic_machine=h8300-hitachi
344c3e29c03Smrg				basic_os=xray
345c3e29c03Smrg				;;
346c3e29c03Smrg			h8500hms)
347c3e29c03Smrg				basic_machine=h8500-hitachi
348c3e29c03Smrg				basic_os=hms
349c3e29c03Smrg				;;
350c3e29c03Smrg			harris)
351c3e29c03Smrg				basic_machine=m88k-harris
352c3e29c03Smrg				basic_os=sysv3
353c3e29c03Smrg				;;
354c3e29c03Smrg			hp300 | hp300hpux)
355c3e29c03Smrg				basic_machine=m68k-hp
356c3e29c03Smrg				basic_os=hpux
357c3e29c03Smrg				;;
358c3e29c03Smrg			hp300bsd)
359c3e29c03Smrg				basic_machine=m68k-hp
360c3e29c03Smrg				basic_os=bsd
361c3e29c03Smrg				;;
362c3e29c03Smrg			hppaosf)
363c3e29c03Smrg				basic_machine=hppa1.1-hp
364c3e29c03Smrg				basic_os=osf
365c3e29c03Smrg				;;
366c3e29c03Smrg			hppro)
367c3e29c03Smrg				basic_machine=hppa1.1-hp
368c3e29c03Smrg				basic_os=proelf
369c3e29c03Smrg				;;
370c3e29c03Smrg			i386mach)
371c3e29c03Smrg				basic_machine=i386-mach
372c3e29c03Smrg				basic_os=mach
373c3e29c03Smrg				;;
374c3e29c03Smrg			isi68 | isi)
375c3e29c03Smrg				basic_machine=m68k-isi
376c3e29c03Smrg				basic_os=sysv
377c3e29c03Smrg				;;
378c3e29c03Smrg			m68knommu)
379c3e29c03Smrg				basic_machine=m68k-unknown
380c3e29c03Smrg				basic_os=linux
381c3e29c03Smrg				;;
382c3e29c03Smrg			magnum | m3230)
383c3e29c03Smrg				basic_machine=mips-mips
384c3e29c03Smrg				basic_os=sysv
385c3e29c03Smrg				;;
386c3e29c03Smrg			merlin)
387c3e29c03Smrg				basic_machine=ns32k-utek
388c3e29c03Smrg				basic_os=sysv
389c3e29c03Smrg				;;
390c3e29c03Smrg			mingw64)
391c3e29c03Smrg				basic_machine=x86_64-pc
392c3e29c03Smrg				basic_os=mingw64
393c3e29c03Smrg				;;
394c3e29c03Smrg			mingw32)
395c3e29c03Smrg				basic_machine=i686-pc
396c3e29c03Smrg				basic_os=mingw32
397c3e29c03Smrg				;;
398c3e29c03Smrg			mingw32ce)
399c3e29c03Smrg				basic_machine=arm-unknown
400c3e29c03Smrg				basic_os=mingw32ce
401c3e29c03Smrg				;;
402c3e29c03Smrg			monitor)
403c3e29c03Smrg				basic_machine=m68k-rom68k
404c3e29c03Smrg				basic_os=coff
405c3e29c03Smrg				;;
406c3e29c03Smrg			morphos)
407c3e29c03Smrg				basic_machine=powerpc-unknown
408c3e29c03Smrg				basic_os=morphos
409c3e29c03Smrg				;;
410c3e29c03Smrg			moxiebox)
411c3e29c03Smrg				basic_machine=moxie-unknown
412c3e29c03Smrg				basic_os=moxiebox
413c3e29c03Smrg				;;
414c3e29c03Smrg			msdos)
415c3e29c03Smrg				basic_machine=i386-pc
416c3e29c03Smrg				basic_os=msdos
417c3e29c03Smrg				;;
418c3e29c03Smrg			msys)
419c3e29c03Smrg				basic_machine=i686-pc
420c3e29c03Smrg				basic_os=msys
421c3e29c03Smrg				;;
422c3e29c03Smrg			mvs)
423c3e29c03Smrg				basic_machine=i370-ibm
424c3e29c03Smrg				basic_os=mvs
425c3e29c03Smrg				;;
426c3e29c03Smrg			nacl)
427c3e29c03Smrg				basic_machine=le32-unknown
428c3e29c03Smrg				basic_os=nacl
429c3e29c03Smrg				;;
430c3e29c03Smrg			ncr3000)
431c3e29c03Smrg				basic_machine=i486-ncr
432c3e29c03Smrg				basic_os=sysv4
433c3e29c03Smrg				;;
434c3e29c03Smrg			netbsd386)
435c3e29c03Smrg				basic_machine=i386-pc
436c3e29c03Smrg				basic_os=netbsd
437c3e29c03Smrg				;;
438c3e29c03Smrg			netwinder)
439c3e29c03Smrg				basic_machine=armv4l-rebel
440c3e29c03Smrg				basic_os=linux
441c3e29c03Smrg				;;
442c3e29c03Smrg			news | news700 | news800 | news900)
443c3e29c03Smrg				basic_machine=m68k-sony
444c3e29c03Smrg				basic_os=newsos
445c3e29c03Smrg				;;
446c3e29c03Smrg			news1000)
447c3e29c03Smrg				basic_machine=m68030-sony
448c3e29c03Smrg				basic_os=newsos
449c3e29c03Smrg				;;
450c3e29c03Smrg			necv70)
451c3e29c03Smrg				basic_machine=v70-nec
452c3e29c03Smrg				basic_os=sysv
453c3e29c03Smrg				;;
454c3e29c03Smrg			nh3000)
455c3e29c03Smrg				basic_machine=m68k-harris
456c3e29c03Smrg				basic_os=cxux
457c3e29c03Smrg				;;
458c3e29c03Smrg			nh[45]000)
459c3e29c03Smrg				basic_machine=m88k-harris
460c3e29c03Smrg				basic_os=cxux
461c3e29c03Smrg				;;
462c3e29c03Smrg			nindy960)
463c3e29c03Smrg				basic_machine=i960-intel
464c3e29c03Smrg				basic_os=nindy
465c3e29c03Smrg				;;
466c3e29c03Smrg			mon960)
467c3e29c03Smrg				basic_machine=i960-intel
468c3e29c03Smrg				basic_os=mon960
469c3e29c03Smrg				;;
470c3e29c03Smrg			nonstopux)
471c3e29c03Smrg				basic_machine=mips-compaq
472c3e29c03Smrg				basic_os=nonstopux
473c3e29c03Smrg				;;
474c3e29c03Smrg			os400)
475c3e29c03Smrg				basic_machine=powerpc-ibm
476c3e29c03Smrg				basic_os=os400
477c3e29c03Smrg				;;
478c3e29c03Smrg			OSE68000 | ose68000)
479c3e29c03Smrg				basic_machine=m68000-ericsson
480c3e29c03Smrg				basic_os=ose
481c3e29c03Smrg				;;
482c3e29c03Smrg			os68k)
483c3e29c03Smrg				basic_machine=m68k-none
484c3e29c03Smrg				basic_os=os68k
485c3e29c03Smrg				;;
486c3e29c03Smrg			paragon)
487c3e29c03Smrg				basic_machine=i860-intel
488c3e29c03Smrg				basic_os=osf
489c3e29c03Smrg				;;
490c3e29c03Smrg			parisc)
491c3e29c03Smrg				basic_machine=hppa-unknown
492c3e29c03Smrg				basic_os=linux
493c3e29c03Smrg				;;
494c3e29c03Smrg			psp)
495c3e29c03Smrg				basic_machine=mipsallegrexel-sony
496c3e29c03Smrg				basic_os=psp
497c3e29c03Smrg				;;
498c3e29c03Smrg			pw32)
499c3e29c03Smrg				basic_machine=i586-unknown
500c3e29c03Smrg				basic_os=pw32
501c3e29c03Smrg				;;
502c3e29c03Smrg			rdos | rdos64)
503c3e29c03Smrg				basic_machine=x86_64-pc
504c3e29c03Smrg				basic_os=rdos
505c3e29c03Smrg				;;
506c3e29c03Smrg			rdos32)
507c3e29c03Smrg				basic_machine=i386-pc
508c3e29c03Smrg				basic_os=rdos
509c3e29c03Smrg				;;
510c3e29c03Smrg			rom68k)
511c3e29c03Smrg				basic_machine=m68k-rom68k
512c3e29c03Smrg				basic_os=coff
513c3e29c03Smrg				;;
514c3e29c03Smrg			sa29200)
515c3e29c03Smrg				basic_machine=a29k-amd
516c3e29c03Smrg				basic_os=udi
517c3e29c03Smrg				;;
518c3e29c03Smrg			sei)
519c3e29c03Smrg				basic_machine=mips-sei
520c3e29c03Smrg				basic_os=seiux
521c3e29c03Smrg				;;
522c3e29c03Smrg			sequent)
523c3e29c03Smrg				basic_machine=i386-sequent
524c3e29c03Smrg				basic_os=
525c3e29c03Smrg				;;
526c3e29c03Smrg			sps7)
527c3e29c03Smrg				basic_machine=m68k-bull
528c3e29c03Smrg				basic_os=sysv2
529c3e29c03Smrg				;;
530c3e29c03Smrg			st2000)
531c3e29c03Smrg				basic_machine=m68k-tandem
532c3e29c03Smrg				basic_os=
533c3e29c03Smrg				;;
534c3e29c03Smrg			stratus)
535c3e29c03Smrg				basic_machine=i860-stratus
536c3e29c03Smrg				basic_os=sysv4
537c3e29c03Smrg				;;
538c3e29c03Smrg			sun2)
539c3e29c03Smrg				basic_machine=m68000-sun
540c3e29c03Smrg				basic_os=
541c3e29c03Smrg				;;
542c3e29c03Smrg			sun2os3)
543c3e29c03Smrg				basic_machine=m68000-sun
544c3e29c03Smrg				basic_os=sunos3
545c3e29c03Smrg				;;
546c3e29c03Smrg			sun2os4)
547c3e29c03Smrg				basic_machine=m68000-sun
548c3e29c03Smrg				basic_os=sunos4
549c3e29c03Smrg				;;
550c3e29c03Smrg			sun3)
551c3e29c03Smrg				basic_machine=m68k-sun
552c3e29c03Smrg				basic_os=
553c3e29c03Smrg				;;
554c3e29c03Smrg			sun3os3)
555c3e29c03Smrg				basic_machine=m68k-sun
556c3e29c03Smrg				basic_os=sunos3
557c3e29c03Smrg				;;
558c3e29c03Smrg			sun3os4)
559c3e29c03Smrg				basic_machine=m68k-sun
560c3e29c03Smrg				basic_os=sunos4
561c3e29c03Smrg				;;
562c3e29c03Smrg			sun4)
563c3e29c03Smrg				basic_machine=sparc-sun
564c3e29c03Smrg				basic_os=
565c3e29c03Smrg				;;
566c3e29c03Smrg			sun4os3)
567c3e29c03Smrg				basic_machine=sparc-sun
568c3e29c03Smrg				basic_os=sunos3
569c3e29c03Smrg				;;
570c3e29c03Smrg			sun4os4)
571c3e29c03Smrg				basic_machine=sparc-sun
572c3e29c03Smrg				basic_os=sunos4
573c3e29c03Smrg				;;
574c3e29c03Smrg			sun4sol2)
575c3e29c03Smrg				basic_machine=sparc-sun
576c3e29c03Smrg				basic_os=solaris2
577c3e29c03Smrg				;;
578c3e29c03Smrg			sun386 | sun386i | roadrunner)
579c3e29c03Smrg				basic_machine=i386-sun
580c3e29c03Smrg				basic_os=
581c3e29c03Smrg				;;
582c3e29c03Smrg			sv1)
583c3e29c03Smrg				basic_machine=sv1-cray
584c3e29c03Smrg				basic_os=unicos
585c3e29c03Smrg				;;
586c3e29c03Smrg			symmetry)
587c3e29c03Smrg				basic_machine=i386-sequent
588c3e29c03Smrg				basic_os=dynix
589c3e29c03Smrg				;;
590c3e29c03Smrg			t3e)
591c3e29c03Smrg				basic_machine=alphaev5-cray
592c3e29c03Smrg				basic_os=unicos
593c3e29c03Smrg				;;
594c3e29c03Smrg			t90)
595c3e29c03Smrg				basic_machine=t90-cray
596c3e29c03Smrg				basic_os=unicos
597c3e29c03Smrg				;;
598c3e29c03Smrg			toad1)
599c3e29c03Smrg				basic_machine=pdp10-xkl
600c3e29c03Smrg				basic_os=tops20
601c3e29c03Smrg				;;
602c3e29c03Smrg			tpf)
603c3e29c03Smrg				basic_machine=s390x-ibm
604c3e29c03Smrg				basic_os=tpf
605c3e29c03Smrg				;;
606c3e29c03Smrg			udi29k)
607c3e29c03Smrg				basic_machine=a29k-amd
608c3e29c03Smrg				basic_os=udi
609c3e29c03Smrg				;;
610c3e29c03Smrg			ultra3)
611c3e29c03Smrg				basic_machine=a29k-nyu
612c3e29c03Smrg				basic_os=sym1
613c3e29c03Smrg				;;
614c3e29c03Smrg			v810 | necv810)
615c3e29c03Smrg				basic_machine=v810-nec
616c3e29c03Smrg				basic_os=none
617c3e29c03Smrg				;;
618c3e29c03Smrg			vaxv)
619c3e29c03Smrg				basic_machine=vax-dec
620c3e29c03Smrg				basic_os=sysv
621c3e29c03Smrg				;;
622c3e29c03Smrg			vms)
623c3e29c03Smrg				basic_machine=vax-dec
624c3e29c03Smrg				basic_os=vms
625c3e29c03Smrg				;;
626c3e29c03Smrg			vsta)
627c3e29c03Smrg				basic_machine=i386-pc
628c3e29c03Smrg				basic_os=vsta
629c3e29c03Smrg				;;
630c3e29c03Smrg			vxworks960)
631c3e29c03Smrg				basic_machine=i960-wrs
632c3e29c03Smrg				basic_os=vxworks
633c3e29c03Smrg				;;
634c3e29c03Smrg			vxworks68)
635c3e29c03Smrg				basic_machine=m68k-wrs
636c3e29c03Smrg				basic_os=vxworks
637c3e29c03Smrg				;;
638c3e29c03Smrg			vxworks29k)
639c3e29c03Smrg				basic_machine=a29k-wrs
640c3e29c03Smrg				basic_os=vxworks
641c3e29c03Smrg				;;
642c3e29c03Smrg			xbox)
643c3e29c03Smrg				basic_machine=i686-pc
644c3e29c03Smrg				basic_os=mingw32
645c3e29c03Smrg				;;
646c3e29c03Smrg			ymp)
647c3e29c03Smrg				basic_machine=ymp-cray
648c3e29c03Smrg				basic_os=unicos
649c3e29c03Smrg				;;
650c3e29c03Smrg			*)
651c3e29c03Smrg				basic_machine=$1
652c3e29c03Smrg				basic_os=
653c3e29c03Smrg				;;
654c3e29c03Smrg		esac
6554b0ead49Smrg		;;
6564b0ead49Smrgesac
6574b0ead49Smrg
658c3e29c03Smrg# Decode 1-component or ad-hoc basic machines
6594b0ead49Smrgcase $basic_machine in
660c3e29c03Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661c3e29c03Smrg	# some cases the only manufacturer, in others, it is the most popular.
662c3e29c03Smrg	w89k)
663c3e29c03Smrg		cpu=hppa1.1
664c3e29c03Smrg		vendor=winbond
66526372658Smrg		;;
666c3e29c03Smrg	op50n)
667c3e29c03Smrg		cpu=hppa1.1
668c3e29c03Smrg		vendor=oki
6694b0ead49Smrg		;;
670c3e29c03Smrg	op60c)
671c3e29c03Smrg		cpu=hppa1.1
672c3e29c03Smrg		vendor=oki
6734b0ead49Smrg		;;
674c3e29c03Smrg	ibm*)
675c3e29c03Smrg		cpu=i370
676c3e29c03Smrg		vendor=ibm
67752b01e16Smrg		;;
678c3e29c03Smrg	orion105)
679c3e29c03Smrg		cpu=clipper
680c3e29c03Smrg		vendor=highlevel
68126372658Smrg		;;
682c3e29c03Smrg	mac | mpw | mac-mpw)
683c3e29c03Smrg		cpu=m68k
684c3e29c03Smrg		vendor=apple
6854e7590efSmrg		;;
686c3e29c03Smrg	pmac | pmac-mpw)
687c3e29c03Smrg		cpu=powerpc
688c3e29c03Smrg		vendor=apple
6894e7590efSmrg		;;
6904e7590efSmrg
6914b0ead49Smrg	# Recognize the various machine names and aliases which stand
6924b0ead49Smrg	# for a CPU type and a company and sometimes even an OS.
6934b0ead49Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694c3e29c03Smrg		cpu=m68000
695c3e29c03Smrg		vendor=att
6964b0ead49Smrg		;;
6974b0ead49Smrg	3b*)
698c3e29c03Smrg		cpu=we32k
699c3e29c03Smrg		vendor=att
70052b01e16Smrg		;;
70149dc963fSmrg	bluegene*)
702c3e29c03Smrg		cpu=powerpc
703c3e29c03Smrg		vendor=ibm
704c3e29c03Smrg		basic_os=cnk
7054b0ead49Smrg		;;
7064b0ead49Smrg	decsystem10* | dec10*)
707c3e29c03Smrg		cpu=pdp10
708c3e29c03Smrg		vendor=dec
709c3e29c03Smrg		basic_os=tops10
7104b0ead49Smrg		;;
7114b0ead49Smrg	decsystem20* | dec20*)
712c3e29c03Smrg		cpu=pdp10
713c3e29c03Smrg		vendor=dec
714c3e29c03Smrg		basic_os=tops20
7154b0ead49Smrg		;;
7164b0ead49Smrg	delta | 3300 | motorola-3300 | motorola-delta \
7174b0ead49Smrg	      | 3300-motorola | delta-motorola)
718c3e29c03Smrg		cpu=m68k
719c3e29c03Smrg		vendor=motorola
7204b0ead49Smrg		;;
72126372658Smrg	dpx2*)
722c3e29c03Smrg		cpu=m68k
723c3e29c03Smrg		vendor=bull
724c3e29c03Smrg		basic_os=sysv3
7254b0ead49Smrg		;;
7264b0ead49Smrg	encore | umax | mmax)
727c3e29c03Smrg		cpu=ns32k
728c3e29c03Smrg		vendor=encore
7294b0ead49Smrg		;;
730c3e29c03Smrg	elxsi)
731c3e29c03Smrg		cpu=elxsi
732c3e29c03Smrg		vendor=elxsi
733c3e29c03Smrg		basic_os=${basic_os:-bsd}
7344b0ead49Smrg		;;
7354b0ead49Smrg	fx2800)
736c3e29c03Smrg		cpu=i860
737c3e29c03Smrg		vendor=alliant
7384b0ead49Smrg		;;
7394b0ead49Smrg	genix)
740c3e29c03Smrg		cpu=ns32k
741c3e29c03Smrg		vendor=ns
7424b0ead49Smrg		;;
7434b0ead49Smrg	h3050r* | hiux*)
744c3e29c03Smrg		cpu=hppa1.1
745c3e29c03Smrg		vendor=hitachi
746c3e29c03Smrg		basic_os=hiuxwe2
7474b0ead49Smrg		;;
7484b0ead49Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749c3e29c03Smrg		cpu=hppa1.0
750c3e29c03Smrg		vendor=hp
7514b0ead49Smrg		;;
7524b0ead49Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753c3e29c03Smrg		cpu=m68000
754c3e29c03Smrg		vendor=hp
7554b0ead49Smrg		;;
7564b0ead49Smrg	hp9k3[2-9][0-9])
757c3e29c03Smrg		cpu=m68k
758c3e29c03Smrg		vendor=hp
7594b0ead49Smrg		;;
7604b0ead49Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761c3e29c03Smrg		cpu=hppa1.0
762c3e29c03Smrg		vendor=hp
7634b0ead49Smrg		;;
7644b0ead49Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765c3e29c03Smrg		cpu=hppa1.1
766c3e29c03Smrg		vendor=hp
7674b0ead49Smrg		;;
7684b0ead49Smrg	hp9k78[0-9] | hp78[0-9])
7694b0ead49Smrg		# FIXME: really hppa2.0-hp
770c3e29c03Smrg		cpu=hppa1.1
771c3e29c03Smrg		vendor=hp
7724b0ead49Smrg		;;
7734b0ead49Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7744b0ead49Smrg		# FIXME: really hppa2.0-hp
775c3e29c03Smrg		cpu=hppa1.1
776c3e29c03Smrg		vendor=hp
7774b0ead49Smrg		;;
7784b0ead49Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779c3e29c03Smrg		cpu=hppa1.1
780c3e29c03Smrg		vendor=hp
7814b0ead49Smrg		;;
7824b0ead49Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783c3e29c03Smrg		cpu=hppa1.0
784c3e29c03Smrg		vendor=hp
7854b0ead49Smrg		;;
7864b0ead49Smrg	i*86v32)
787c3e29c03Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788c3e29c03Smrg		vendor=pc
789c3e29c03Smrg		basic_os=sysv32
7904b0ead49Smrg		;;
7914b0ead49Smrg	i*86v4*)
792c3e29c03Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793c3e29c03Smrg		vendor=pc
794c3e29c03Smrg		basic_os=sysv4
7954b0ead49Smrg		;;
7964b0ead49Smrg	i*86v)
797c3e29c03Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798c3e29c03Smrg		vendor=pc
799c3e29c03Smrg		basic_os=sysv
8004b0ead49Smrg		;;
8014b0ead49Smrg	i*86sol2)
802c3e29c03Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803c3e29c03Smrg		vendor=pc
804c3e29c03Smrg		basic_os=solaris2
8054b0ead49Smrg		;;
806c3e29c03Smrg	j90 | j90-cray)
807c3e29c03Smrg		cpu=j90
808c3e29c03Smrg		vendor=cray
809c3e29c03Smrg		basic_os=${basic_os:-unicos}
8104b0ead49Smrg		;;
8114b0ead49Smrg	iris | iris4d)
812c3e29c03Smrg		cpu=mips
813c3e29c03Smrg		vendor=sgi
814c3e29c03Smrg		case $basic_os in
815c3e29c03Smrg		    irix*)
8164b0ead49Smrg			;;
8174b0ead49Smrg		    *)
818c3e29c03Smrg			basic_os=irix4
8194b0ead49Smrg			;;
8204b0ead49Smrg		esac
8214b0ead49Smrg		;;
8224b0ead49Smrg	miniframe)
823c3e29c03Smrg		cpu=m68000
824c3e29c03Smrg		vendor=convergent
8254b0ead49Smrg		;;
826c3e29c03Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827c3e29c03Smrg		cpu=m68k
828c3e29c03Smrg		vendor=atari
829c3e29c03Smrg		basic_os=mint
8304b0ead49Smrg		;;
8314b0ead49Smrg	news-3600 | risc-news)
832c3e29c03Smrg		cpu=mips
833c3e29c03Smrg		vendor=sony
834c3e29c03Smrg		basic_os=newsos
8354b0ead49Smrg		;;
83626372658Smrg	next | m*-next)
837c3e29c03Smrg		cpu=m68k
838c3e29c03Smrg		vendor=next
839c3e29c03Smrg		case $basic_os in
840c3e29c03Smrg		    openstep*)
841c3e29c03Smrg		        ;;
842c3e29c03Smrg		    nextstep*)
8434b0ead49Smrg			;;
844c3e29c03Smrg		    ns2*)
845c3e29c03Smrg		      basic_os=nextstep2
8464b0ead49Smrg			;;
8474b0ead49Smrg		    *)
848c3e29c03Smrg		      basic_os=nextstep3
8494b0ead49Smrg			;;
8504b0ead49Smrg		esac
8514b0ead49Smrg		;;
8524b0ead49Smrg	np1)
853c3e29c03Smrg		cpu=np1
854c3e29c03Smrg		vendor=gould
85526372658Smrg		;;
8564b0ead49Smrg	op50n-* | op60c-*)
857c3e29c03Smrg		cpu=hppa1.1
858c3e29c03Smrg		vendor=oki
859c3e29c03Smrg		basic_os=proelf
8604b0ead49Smrg		;;
8614b0ead49Smrg	pa-hitachi)
862c3e29c03Smrg		cpu=hppa1.1
863c3e29c03Smrg		vendor=hitachi
864c3e29c03Smrg		basic_os=hiuxwe2
86552b01e16Smrg		;;
8664b0ead49Smrg	pbd)
867c3e29c03Smrg		cpu=sparc
868c3e29c03Smrg		vendor=tti
8694b0ead49Smrg		;;
8704b0ead49Smrg	pbb)
871c3e29c03Smrg		cpu=m68k
872c3e29c03Smrg		vendor=tti
8734b0ead49Smrg		;;
874c3e29c03Smrg	pc532)
875c3e29c03Smrg		cpu=ns32k
876c3e29c03Smrg		vendor=pc532
8774b0ead49Smrg		;;
8784b0ead49Smrg	pn)
879c3e29c03Smrg		cpu=pn
880c3e29c03Smrg		vendor=gould
8814b0ead49Smrg		;;
882c3e29c03Smrg	power)
883c3e29c03Smrg		cpu=power
884c3e29c03Smrg		vendor=ibm
8854b0ead49Smrg		;;
886c3e29c03Smrg	ps2)
887c3e29c03Smrg		cpu=i386
888c3e29c03Smrg		vendor=ibm
8894b0ead49Smrg		;;
890c3e29c03Smrg	rm[46]00)
891c3e29c03Smrg		cpu=mips
892c3e29c03Smrg		vendor=siemens
8934b0ead49Smrg		;;
894c3e29c03Smrg	rtpc | rtpc-*)
895c3e29c03Smrg		cpu=romp
896c3e29c03Smrg		vendor=ibm
8974b0ead49Smrg		;;
898c3e29c03Smrg	sde)
899c3e29c03Smrg		cpu=mipsisa32
900c3e29c03Smrg		vendor=sde
901c3e29c03Smrg		basic_os=${basic_os:-elf}
9024b0ead49Smrg		;;
903c3e29c03Smrg	simso-wrs)
904c3e29c03Smrg		cpu=sparclite
905c3e29c03Smrg		vendor=wrs
906c3e29c03Smrg		basic_os=vxworks
9074b0ead49Smrg		;;
908c3e29c03Smrg	tower | tower-32)
909c3e29c03Smrg		cpu=m68k
910c3e29c03Smrg		vendor=ncr
9114b0ead49Smrg		;;
912c3e29c03Smrg	vpp*|vx|vx-*)
913c3e29c03Smrg		cpu=f301
914c3e29c03Smrg		vendor=fujitsu
91526372658Smrg		;;
916c3e29c03Smrg	w65)
917c3e29c03Smrg		cpu=w65
918c3e29c03Smrg		vendor=wdc
91952b01e16Smrg		;;
920c3e29c03Smrg	w89k-*)
921c3e29c03Smrg		cpu=hppa1.1
922c3e29c03Smrg		vendor=winbond
923c3e29c03Smrg		basic_os=proelf
9244b0ead49Smrg		;;
925c3e29c03Smrg	none)
926c3e29c03Smrg		cpu=none
927c3e29c03Smrg		vendor=none
9284b0ead49Smrg		;;
929c3e29c03Smrg	leon|leon[3-9])
930c3e29c03Smrg		cpu=sparc
931c3e29c03Smrg		vendor=$basic_machine
9324b0ead49Smrg		;;
933c3e29c03Smrg	leon-*|leon[3-9]-*)
934c3e29c03Smrg		cpu=sparc
935c3e29c03Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9364b0ead49Smrg		;;
937c3e29c03Smrg
938c3e29c03Smrg	*-*)
939c3e29c03Smrg		# shellcheck disable=SC2162
940c3e29c03Smrg		saved_IFS=$IFS
941c3e29c03Smrg		IFS="-" read cpu vendor <<EOF
942c3e29c03Smrg$basic_machine
943c3e29c03SmrgEOF
944c3e29c03Smrg		IFS=$saved_IFS
9454b0ead49Smrg		;;
946c3e29c03Smrg	# We use `pc' rather than `unknown'
947c3e29c03Smrg	# because (1) that's what they normally are, and
948c3e29c03Smrg	# (2) the word "unknown" tends to confuse beginning users.
949c3e29c03Smrg	i*86 | x86_64)
950c3e29c03Smrg		cpu=$basic_machine
951c3e29c03Smrg		vendor=pc
9524b0ead49Smrg		;;
953c3e29c03Smrg	# These rules are duplicated from below for sake of the special case above;
954c3e29c03Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955c3e29c03Smrg	pc98)
956c3e29c03Smrg		cpu=i386
957c3e29c03Smrg		vendor=pc
9584b0ead49Smrg		;;
959c3e29c03Smrg	x64 | amd64)
960c3e29c03Smrg		cpu=x86_64
961c3e29c03Smrg		vendor=pc
9624b0ead49Smrg		;;
963c3e29c03Smrg	# Recognize the basic CPU types without company name.
964c3e29c03Smrg	*)
965c3e29c03Smrg		cpu=$basic_machine
966c3e29c03Smrg		vendor=unknown
96752b01e16Smrg		;;
968c3e29c03Smrgesac
969c3e29c03Smrg
970c3e29c03Smrgunset -v basic_machine
971c3e29c03Smrg
972c3e29c03Smrg# Decode basic machines in the full and proper CPU-Company form.
973c3e29c03Smrgcase $cpu-$vendor in
974c3e29c03Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975c3e29c03Smrg	# some cases the only manufacturer, in others, it is the most popular.
976c3e29c03Smrg	craynv-unknown)
977c3e29c03Smrg		vendor=cray
978c3e29c03Smrg		basic_os=${basic_os:-unicosmp}
9794b0ead49Smrg		;;
980c3e29c03Smrg	c90-unknown | c90-cray)
981c3e29c03Smrg		vendor=cray
982c3e29c03Smrg		basic_os=${Basic_os:-unicos}
9834b0ead49Smrg		;;
984c3e29c03Smrg	fx80-unknown)
985c3e29c03Smrg		vendor=alliant
98652b01e16Smrg		;;
987c3e29c03Smrg	romp-unknown)
988c3e29c03Smrg		vendor=ibm
9894b0ead49Smrg		;;
990c3e29c03Smrg	mmix-unknown)
991c3e29c03Smrg		vendor=knuth
9924b0ead49Smrg		;;
993c3e29c03Smrg	microblaze-unknown | microblazeel-unknown)
994c3e29c03Smrg		vendor=xilinx
9954b0ead49Smrg		;;
996c3e29c03Smrg	rs6000-unknown)
997c3e29c03Smrg		vendor=ibm
9984b0ead49Smrg		;;
999c3e29c03Smrg	vax-unknown)
1000c3e29c03Smrg		vendor=dec
10014b0ead49Smrg		;;
1002c3e29c03Smrg	pdp11-unknown)
1003c3e29c03Smrg		vendor=dec
10044e7590efSmrg		;;
1005c3e29c03Smrg	we32k-unknown)
1006c3e29c03Smrg		vendor=att
10074b0ead49Smrg		;;
1008c3e29c03Smrg	cydra-unknown)
1009c3e29c03Smrg		vendor=cydrome
10104b0ead49Smrg		;;
1011c3e29c03Smrg	i370-ibm*)
1012c3e29c03Smrg		vendor=ibm
10134b0ead49Smrg		;;
1014c3e29c03Smrg	orion-unknown)
1015c3e29c03Smrg		vendor=highlevel
10164b0ead49Smrg		;;
1017c3e29c03Smrg	xps-unknown | xps100-unknown)
1018c3e29c03Smrg		cpu=xps100
1019c3e29c03Smrg		vendor=honeywell
10204b0ead49Smrg		;;
1021c3e29c03Smrg
1022c3e29c03Smrg	# Here we normalize CPU types with a missing or matching vendor
1023c3e29c03Smrg	dpx20-unknown | dpx20-bull)
1024c3e29c03Smrg		cpu=rs6000
1025c3e29c03Smrg		vendor=bull
1026c3e29c03Smrg		basic_os=${basic_os:-bosx}
10274b0ead49Smrg		;;
1028c3e29c03Smrg
1029c3e29c03Smrg	# Here we normalize CPU types irrespective of the vendor
1030c3e29c03Smrg	amd64-*)
1031c3e29c03Smrg		cpu=x86_64
10324b0ead49Smrg		;;
1033c3e29c03Smrg	blackfin-*)
1034c3e29c03Smrg		cpu=bfin
1035c3e29c03Smrg		basic_os=linux
10364b0ead49Smrg		;;
1037c3e29c03Smrg	c54x-*)
1038c3e29c03Smrg		cpu=tic54x
10394b0ead49Smrg		;;
1040c3e29c03Smrg	c55x-*)
1041c3e29c03Smrg		cpu=tic55x
10424b0ead49Smrg		;;
1043c3e29c03Smrg	c6x-*)
1044c3e29c03Smrg		cpu=tic6x
10454b0ead49Smrg		;;
1046c3e29c03Smrg	e500v[12]-*)
1047c3e29c03Smrg		cpu=powerpc
1048c3e29c03Smrg		basic_os=${basic_os}"spe"
10494b0ead49Smrg		;;
1050c3e29c03Smrg	mips3*-*)
1051c3e29c03Smrg		cpu=mips64
10524b0ead49Smrg		;;
1053c3e29c03Smrg	ms1-*)
1054c3e29c03Smrg		cpu=mt
10554b0ead49Smrg		;;
1056c3e29c03Smrg	m68knommu-*)
1057c3e29c03Smrg		cpu=m68k
1058c3e29c03Smrg		basic_os=linux
10594b0ead49Smrg		;;
1060c3e29c03Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1061c3e29c03Smrg		cpu=s12z
106252b01e16Smrg		;;
1063c3e29c03Smrg	openrisc-*)
1064c3e29c03Smrg		cpu=or32
10654b0ead49Smrg		;;
1066c3e29c03Smrg	parisc-*)
1067c3e29c03Smrg		cpu=hppa
1068c3e29c03Smrg		basic_os=linux
10694b0ead49Smrg		;;
1070c3e29c03Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1071c3e29c03Smrg		cpu=i586
10724b0ead49Smrg		;;
1073c3e29c03Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1074c3e29c03Smrg		cpu=i686
10754b0ead49Smrg		;;
1076c3e29c03Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1077c3e29c03Smrg		cpu=i686
10784b0ead49Smrg		;;
1079c3e29c03Smrg	pentium4-*)
1080c3e29c03Smrg		cpu=i786
10814b0ead49Smrg		;;
1082c3e29c03Smrg	pc98-*)
1083c3e29c03Smrg		cpu=i386
10844b0ead49Smrg		;;
1085c3e29c03Smrg	ppc-* | ppcbe-*)
1086c3e29c03Smrg		cpu=powerpc
10874b0ead49Smrg		;;
1088c3e29c03Smrg	ppcle-* | powerpclittle-*)
1089c3e29c03Smrg		cpu=powerpcle
10904b0ead49Smrg		;;
1091c3e29c03Smrg	ppc64-*)
1092c3e29c03Smrg		cpu=powerpc64
10934b0ead49Smrg		;;
1094c3e29c03Smrg	ppc64le-* | powerpc64little-*)
1095c3e29c03Smrg		cpu=powerpc64le
10964b0ead49Smrg		;;
1097c3e29c03Smrg	sb1-*)
1098c3e29c03Smrg		cpu=mipsisa64sb1
10994b0ead49Smrg		;;
1100c3e29c03Smrg	sb1el-*)
1101c3e29c03Smrg		cpu=mipsisa64sb1el
11024b0ead49Smrg		;;
1103c3e29c03Smrg	sh5e[lb]-*)
1104c3e29c03Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11054b0ead49Smrg		;;
1106c3e29c03Smrg	spur-*)
1107c3e29c03Smrg		cpu=spur
11084b0ead49Smrg		;;
1109c3e29c03Smrg	strongarm-* | thumb-*)
1110c3e29c03Smrg		cpu=arm
11114b0ead49Smrg		;;
1112c3e29c03Smrg	tx39-*)
1113c3e29c03Smrg		cpu=mipstx39
111426372658Smrg		;;
1115c3e29c03Smrg	tx39el-*)
1116c3e29c03Smrg		cpu=mipstx39el
11174b0ead49Smrg		;;
1118c3e29c03Smrg	x64-*)
1119c3e29c03Smrg		cpu=x86_64
11204b0ead49Smrg		;;
11214e7590efSmrg	xscale-* | xscalee[bl]-*)
1122c3e29c03Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11234b0ead49Smrg		;;
1124c3e29c03Smrg	arm64-*)
1125c3e29c03Smrg		cpu=aarch64
11264b0ead49Smrg		;;
11274b0ead49Smrg
1128c3e29c03Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1129c3e29c03Smrg	# company names they are paired with.
1130c3e29c03Smrg	cr16-*)
1131c3e29c03Smrg		basic_os=${basic_os:-elf}
11324b0ead49Smrg		;;
1133c3e29c03Smrg	crisv32-* | etraxfs*-*)
1134c3e29c03Smrg		cpu=crisv32
1135c3e29c03Smrg		vendor=axis
11364b0ead49Smrg		;;
1137c3e29c03Smrg	cris-* | etrax*-*)
1138c3e29c03Smrg		cpu=cris
1139c3e29c03Smrg		vendor=axis
11404b0ead49Smrg		;;
1141c3e29c03Smrg	crx-*)
1142c3e29c03Smrg		basic_os=${basic_os:-elf}
11434b0ead49Smrg		;;
1144c3e29c03Smrg	neo-tandem)
1145c3e29c03Smrg		cpu=neo
1146c3e29c03Smrg		vendor=tandem
11474b0ead49Smrg		;;
1148c3e29c03Smrg	nse-tandem)
1149c3e29c03Smrg		cpu=nse
1150c3e29c03Smrg		vendor=tandem
11514b0ead49Smrg		;;
1152c3e29c03Smrg	nsr-tandem)
1153c3e29c03Smrg		cpu=nsr
1154c3e29c03Smrg		vendor=tandem
11554b0ead49Smrg		;;
1156c3e29c03Smrg	nsv-tandem)
1157c3e29c03Smrg		cpu=nsv
1158c3e29c03Smrg		vendor=tandem
11594b0ead49Smrg		;;
1160c3e29c03Smrg	nsx-tandem)
1161c3e29c03Smrg		cpu=nsx
1162c3e29c03Smrg		vendor=tandem
11634b0ead49Smrg		;;
1164c3e29c03Smrg	mipsallegrexel-sony)
1165c3e29c03Smrg		cpu=mipsallegrexel
1166c3e29c03Smrg		vendor=sony
11674b0ead49Smrg		;;
1168c3e29c03Smrg	tile*-*)
1169c3e29c03Smrg		basic_os=${basic_os:-linux-gnu}
11704b0ead49Smrg		;;
1171c3e29c03Smrg
11724b0ead49Smrg	*)
1173c3e29c03Smrg		# Recognize the canonical CPU types that are allowed with any
1174c3e29c03Smrg		# company name.
1175c3e29c03Smrg		case $cpu in
1176c3e29c03Smrg			1750a | 580 \
1177c3e29c03Smrg			| a29k \
1178c3e29c03Smrg			| aarch64 | aarch64_be \
1179c3e29c03Smrg			| abacus \
1180c3e29c03Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1181c3e29c03Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1182c3e29c03Smrg			| alphapca5[67] | alpha64pca5[67] \
1183c3e29c03Smrg			| am33_2.0 \
1184c3e29c03Smrg			| amdgcn \
1185c3e29c03Smrg			| arc | arceb | arc32 | arc64 \
1186c3e29c03Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1187c3e29c03Smrg			| avr | avr32 \
1188c3e29c03Smrg			| asmjs \
1189c3e29c03Smrg			| ba \
1190c3e29c03Smrg			| be32 | be64 \
1191c3e29c03Smrg			| bfin | bpf | bs2000 \
1192c3e29c03Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1193c3e29c03Smrg			| c8051 | clipper | craynv | csky | cydra \
1194c3e29c03Smrg			| d10v | d30v | dlx | dsp16xx \
1195c3e29c03Smrg			| e2k | elxsi | epiphany \
1196c3e29c03Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1197c3e29c03Smrg			| h8300 | h8500 \
1198c3e29c03Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1199c3e29c03Smrg			| hexagon \
1200c3e29c03Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1201c3e29c03Smrg			| ip2k | iq2000 \
1202c3e29c03Smrg			| k1om \
1203c3e29c03Smrg			| le32 | le64 \
1204c3e29c03Smrg			| lm32 \
1205c3e29c03Smrg			| loongarch32 | loongarch64 | loongarchx32 \
1206c3e29c03Smrg			| m32c | m32r | m32rle \
1207c3e29c03Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1208c3e29c03Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1209c3e29c03Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1210c3e29c03Smrg			| microblaze | microblazeel \
1211c3e29c03Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1212c3e29c03Smrg			| mips16 \
1213c3e29c03Smrg			| mips64 | mips64eb | mips64el \
1214c3e29c03Smrg			| mips64octeon | mips64octeonel \
1215c3e29c03Smrg			| mips64orion | mips64orionel \
1216c3e29c03Smrg			| mips64r5900 | mips64r5900el \
1217c3e29c03Smrg			| mips64vr | mips64vrel \
1218c3e29c03Smrg			| mips64vr4100 | mips64vr4100el \
1219c3e29c03Smrg			| mips64vr4300 | mips64vr4300el \
1220c3e29c03Smrg			| mips64vr5000 | mips64vr5000el \
1221c3e29c03Smrg			| mips64vr5900 | mips64vr5900el \
1222c3e29c03Smrg			| mipsisa32 | mipsisa32el \
1223c3e29c03Smrg			| mipsisa32r2 | mipsisa32r2el \
1224c3e29c03Smrg			| mipsisa32r3 | mipsisa32r3el \
1225c3e29c03Smrg			| mipsisa32r5 | mipsisa32r5el \
1226c3e29c03Smrg			| mipsisa32r6 | mipsisa32r6el \
1227c3e29c03Smrg			| mipsisa64 | mipsisa64el \
1228c3e29c03Smrg			| mipsisa64r2 | mipsisa64r2el \
1229c3e29c03Smrg			| mipsisa64r3 | mipsisa64r3el \
1230c3e29c03Smrg			| mipsisa64r5 | mipsisa64r5el \
1231c3e29c03Smrg			| mipsisa64r6 | mipsisa64r6el \
1232c3e29c03Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1233c3e29c03Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1234c3e29c03Smrg			| mipsr5900 | mipsr5900el \
1235c3e29c03Smrg			| mipstx39 | mipstx39el \
1236c3e29c03Smrg			| mmix \
1237c3e29c03Smrg			| mn10200 | mn10300 \
1238c3e29c03Smrg			| moxie \
1239c3e29c03Smrg			| mt \
1240c3e29c03Smrg			| msp430 \
1241c3e29c03Smrg			| nds32 | nds32le | nds32be \
1242c3e29c03Smrg			| nfp \
1243c3e29c03Smrg			| nios | nios2 | nios2eb | nios2el \
1244c3e29c03Smrg			| none | np1 | ns16k | ns32k | nvptx \
1245c3e29c03Smrg			| open8 \
1246c3e29c03Smrg			| or1k* \
1247c3e29c03Smrg			| or32 \
1248c3e29c03Smrg			| orion \
1249c3e29c03Smrg			| picochip \
1250c3e29c03Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1251c3e29c03Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1252c3e29c03Smrg			| pru \
1253c3e29c03Smrg			| pyramid \
1254c3e29c03Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1255c3e29c03Smrg			| rl78 | romp | rs6000 | rx \
1256c3e29c03Smrg			| s390 | s390x \
1257c3e29c03Smrg			| score \
1258c3e29c03Smrg			| sh | shl \
1259c3e29c03Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1260c3e29c03Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1261c3e29c03Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1262c3e29c03Smrg			| sparclite \
1263c3e29c03Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1264c3e29c03Smrg			| spu \
1265c3e29c03Smrg			| tahoe \
1266c3e29c03Smrg			| thumbv7* \
1267c3e29c03Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1268c3e29c03Smrg			| tron \
1269c3e29c03Smrg			| ubicom32 \
1270c3e29c03Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1271c3e29c03Smrg			| vax \
1272c3e29c03Smrg			| visium \
1273c3e29c03Smrg			| w65 \
1274c3e29c03Smrg			| wasm32 | wasm64 \
1275c3e29c03Smrg			| we32k \
1276c3e29c03Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1277c3e29c03Smrg			| xstormy16 | xtensa* \
1278c3e29c03Smrg			| ymp \
1279c3e29c03Smrg			| z8k | z80)
1280c3e29c03Smrg				;;
1281c3e29c03Smrg
1282c3e29c03Smrg			*)
1283c3e29c03Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1284c3e29c03Smrg				exit 1
1285c3e29c03Smrg				;;
1286c3e29c03Smrg		esac
12874b0ead49Smrg		;;
12884b0ead49Smrgesac
12894b0ead49Smrg
12904b0ead49Smrg# Here we canonicalize certain aliases for manufacturers.
1291c3e29c03Smrgcase $vendor in
1292c3e29c03Smrg	digital*)
1293c3e29c03Smrg		vendor=dec
12944b0ead49Smrg		;;
1295c3e29c03Smrg	commodore*)
1296c3e29c03Smrg		vendor=cbm
12974b0ead49Smrg		;;
12984b0ead49Smrg	*)
12994b0ead49Smrg		;;
13004b0ead49Smrgesac
13014b0ead49Smrg
13024b0ead49Smrg# Decode manufacturer-specific aliases for certain operating systems.
13034b0ead49Smrg
1304c3e29c03Smrgif test x$basic_os != x
13054b0ead49Smrgthen
1306c3e29c03Smrg
1307c3e29c03Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1308c3e29c03Smrg# set os.
1309c3e29c03Smrgcase $basic_os in
1310c3e29c03Smrg	gnu/linux*)
1311c3e29c03Smrg		kernel=linux
1312c3e29c03Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1313c3e29c03Smrg		;;
1314c3e29c03Smrg	os2-emx)
1315c3e29c03Smrg		kernel=os2
1316c3e29c03Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1317c3e29c03Smrg		;;
1318c3e29c03Smrg	nto-qnx*)
1319c3e29c03Smrg		kernel=nto
1320c3e29c03Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1321c3e29c03Smrg		;;
1322c3e29c03Smrg	*-*)
1323c3e29c03Smrg		# shellcheck disable=SC2162
1324c3e29c03Smrg		saved_IFS=$IFS
1325c3e29c03Smrg		IFS="-" read kernel os <<EOF
1326c3e29c03Smrg$basic_os
1327c3e29c03SmrgEOF
1328c3e29c03Smrg		IFS=$saved_IFS
1329c3e29c03Smrg		;;
1330c3e29c03Smrg	# Default OS when just kernel was specified
1331c3e29c03Smrg	nto*)
1332c3e29c03Smrg		kernel=nto
1333c3e29c03Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1334c3e29c03Smrg		;;
1335c3e29c03Smrg	linux*)
1336c3e29c03Smrg		kernel=linux
1337c3e29c03Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1338c3e29c03Smrg		;;
1339c3e29c03Smrg	*)
1340c3e29c03Smrg		kernel=
1341c3e29c03Smrg		os=$basic_os
1342c3e29c03Smrg		;;
1343c3e29c03Smrgesac
1344c3e29c03Smrg
1345c3e29c03Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1346c3e29c03Smrg# etc.)
13474b0ead49Smrgcase $os in
134826372658Smrg	# First match some system type aliases that might get confused
134926372658Smrg	# with valid system types.
1350c3e29c03Smrg	# solaris* is a basic system type, with this one exception.
1351c3e29c03Smrg	auroraux)
1352c3e29c03Smrg		os=auroraux
135349dc963fSmrg		;;
1354c3e29c03Smrg	bluegene*)
1355c3e29c03Smrg		os=cnk
13564b0ead49Smrg		;;
1357c3e29c03Smrg	solaris1 | solaris1.*)
1358c3e29c03Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13594b0ead49Smrg		;;
1360c3e29c03Smrg	solaris)
1361c3e29c03Smrg		os=solaris2
13624b0ead49Smrg		;;
1363c3e29c03Smrg	unixware*)
1364c3e29c03Smrg		os=sysv4.2uw
13654b0ead49Smrg		;;
136626372658Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1367c3e29c03Smrg	es1800*)
1368c3e29c03Smrg		os=ose
136926372658Smrg		;;
1370c3e29c03Smrg	# Some version numbers need modification
1371c3e29c03Smrg	chorusos*)
1372c3e29c03Smrg		os=chorusos
13734b0ead49Smrg		;;
1374c3e29c03Smrg	isc)
1375c3e29c03Smrg		os=isc2.2
13764b0ead49Smrg		;;
1377c3e29c03Smrg	sco6)
1378c3e29c03Smrg		os=sco5v6
13794b0ead49Smrg		;;
1380c3e29c03Smrg	sco5)
1381c3e29c03Smrg		os=sco3.2v5
13824b0ead49Smrg		;;
1383c3e29c03Smrg	sco4)
1384c3e29c03Smrg		os=sco3.2v4
13854b0ead49Smrg		;;
1386c3e29c03Smrg	sco3.2.[4-9]*)
1387c3e29c03Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13884b0ead49Smrg		;;
1389c3e29c03Smrg	sco*v* | scout)
1390c3e29c03Smrg		# Don't match below
13914b0ead49Smrg		;;
1392c3e29c03Smrg	sco*)
1393c3e29c03Smrg		os=sco3.2v2
13944b0ead49Smrg		;;
1395c3e29c03Smrg	psos*)
1396c3e29c03Smrg		os=psos
13974b0ead49Smrg		;;
1398c3e29c03Smrg	qnx*)
1399c3e29c03Smrg		os=qnx
14004b0ead49Smrg		;;
1401c3e29c03Smrg	hiux*)
1402c3e29c03Smrg		os=hiuxwe2
14034b0ead49Smrg		;;
1404c3e29c03Smrg	lynx*178)
1405c3e29c03Smrg		os=lynxos178
14064b0ead49Smrg		;;
1407c3e29c03Smrg	lynx*5)
1408c3e29c03Smrg		os=lynxos5
14094b0ead49Smrg		;;
1410c3e29c03Smrg	lynxos*)
1411c3e29c03Smrg		# don't get caught up in next wildcard
14124b0ead49Smrg		;;
1413c3e29c03Smrg	lynx*)
1414c3e29c03Smrg		os=lynxos
14154b0ead49Smrg		;;
1416c3e29c03Smrg	mac[0-9]*)
1417c3e29c03Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14184b0ead49Smrg		;;
1419c3e29c03Smrg	opened*)
1420c3e29c03Smrg		os=openedition
14214b0ead49Smrg		;;
1422c3e29c03Smrg	os400*)
1423c3e29c03Smrg		os=os400
14244b0ead49Smrg		;;
1425c3e29c03Smrg	sunos5*)
1426c3e29c03Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
14274b0ead49Smrg		;;
1428c3e29c03Smrg	sunos6*)
1429c3e29c03Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14304b0ead49Smrg		;;
1431c3e29c03Smrg	wince*)
1432c3e29c03Smrg		os=wince
14334b0ead49Smrg		;;
1434c3e29c03Smrg	utek*)
1435c3e29c03Smrg		os=bsd
14364b0ead49Smrg		;;
1437c3e29c03Smrg	dynix*)
1438c3e29c03Smrg		os=bsd
14394b0ead49Smrg		;;
1440c3e29c03Smrg	acis*)
1441c3e29c03Smrg		os=aos
14424b0ead49Smrg		;;
1443c3e29c03Smrg	atheos*)
1444c3e29c03Smrg		os=atheos
14454b0ead49Smrg		;;
1446c3e29c03Smrg	syllable*)
1447c3e29c03Smrg		os=syllable
1448c3e29c03Smrg		;;
1449c3e29c03Smrg	386bsd)
1450c3e29c03Smrg		os=bsd
1451c3e29c03Smrg		;;
1452c3e29c03Smrg	ctix* | uts*)
1453c3e29c03Smrg		os=sysv
1454c3e29c03Smrg		;;
1455c3e29c03Smrg	nova*)
1456c3e29c03Smrg		os=rtmk-nova
1457c3e29c03Smrg		;;
1458c3e29c03Smrg	ns2)
1459c3e29c03Smrg		os=nextstep2
1460c3e29c03Smrg		;;
1461c3e29c03Smrg	# Preserve the version number of sinix5.
1462c3e29c03Smrg	sinix5.*)
1463c3e29c03Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14644b0ead49Smrg		;;
1465c3e29c03Smrg	sinix*)
1466c3e29c03Smrg		os=sysv4
14674b0ead49Smrg		;;
1468c3e29c03Smrg	tpf*)
1469c3e29c03Smrg		os=tpf
14704b0ead49Smrg		;;
1471c3e29c03Smrg	triton*)
1472c3e29c03Smrg		os=sysv3
14734b0ead49Smrg		;;
1474c3e29c03Smrg	oss*)
1475c3e29c03Smrg		os=sysv3
14764b0ead49Smrg		;;
1477c3e29c03Smrg	svr4*)
1478c3e29c03Smrg		os=sysv4
14794b0ead49Smrg		;;
1480c3e29c03Smrg	svr3)
1481c3e29c03Smrg		os=sysv3
14824b0ead49Smrg		;;
1483c3e29c03Smrg	sysvr4)
1484c3e29c03Smrg		os=sysv4
14854b0ead49Smrg		;;
1486c3e29c03Smrg	ose*)
1487c3e29c03Smrg		os=ose
14884b0ead49Smrg		;;
1489c3e29c03Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1490c3e29c03Smrg		os=mint
149149dc963fSmrg		;;
1492c3e29c03Smrg	dicos*)
1493c3e29c03Smrg		os=dicos
1494c3e29c03Smrg		;;
1495c3e29c03Smrg	pikeos*)
149626372658Smrg		# Until real need of OS specific support for
149726372658Smrg		# particular features comes up, bare metal
149826372658Smrg		# configurations are quite functional.
1499c3e29c03Smrg		case $cpu in
150026372658Smrg		    arm*)
1501c3e29c03Smrg			os=eabi
150226372658Smrg			;;
150326372658Smrg		    *)
1504c3e29c03Smrg			os=elf
150526372658Smrg			;;
150626372658Smrg		esac
150726372658Smrg		;;
15084b0ead49Smrg	*)
1509c3e29c03Smrg		# No normalization, but not necessarily accepted, that comes below.
15104b0ead49Smrg		;;
15114b0ead49Smrgesac
1512c3e29c03Smrg
15134b0ead49Smrgelse
15144b0ead49Smrg
15154b0ead49Smrg# Here we handle the default operating systems that come with various machines.
15164b0ead49Smrg# The value should be what the vendor currently ships out the door with their
15174b0ead49Smrg# machine or put another way, the most popular os provided with the machine.
15184b0ead49Smrg
15194b0ead49Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15204b0ead49Smrg# "-sun"), then you have to tell the case statement up towards the top
15214b0ead49Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15224b0ead49Smrg# will signal an error saying that MANUFACTURER isn't an operating
15234b0ead49Smrg# system, and we'll never get to this point.
15244b0ead49Smrg
1525c3e29c03Smrgkernel=
1526c3e29c03Smrgcase $cpu-$vendor in
15274e7590efSmrg	score-*)
1528c3e29c03Smrg		os=elf
152952b01e16Smrg		;;
15304e7590efSmrg	spu-*)
1531c3e29c03Smrg		os=elf
153252b01e16Smrg		;;
15334b0ead49Smrg	*-acorn)
1534c3e29c03Smrg		os=riscix1.2
15354b0ead49Smrg		;;
15364b0ead49Smrg	arm*-rebel)
1537c3e29c03Smrg		kernel=linux
1538c3e29c03Smrg		os=gnu
15394b0ead49Smrg		;;
15404b0ead49Smrg	arm*-semi)
1541c3e29c03Smrg		os=aout
15424b0ead49Smrg		;;
15434e7590efSmrg	c4x-* | tic4x-*)
1544c3e29c03Smrg		os=coff
154552b01e16Smrg		;;
154626372658Smrg	c8051-*)
1547c3e29c03Smrg		os=elf
1548c3e29c03Smrg		;;
1549c3e29c03Smrg	clipper-intergraph)
1550c3e29c03Smrg		os=clix
155126372658Smrg		;;
155226372658Smrg	hexagon-*)
1553c3e29c03Smrg		os=elf
155426372658Smrg		;;
15557aa89044Smrg	tic54x-*)
1556c3e29c03Smrg		os=coff
15577aa89044Smrg		;;
15587aa89044Smrg	tic55x-*)
1559c3e29c03Smrg		os=coff
15607aa89044Smrg		;;
15617aa89044Smrg	tic6x-*)
1562c3e29c03Smrg		os=coff
15637aa89044Smrg		;;
15644b0ead49Smrg	# This must come before the *-dec entry.
15654b0ead49Smrg	pdp10-*)
1566c3e29c03Smrg		os=tops20
15674b0ead49Smrg		;;
15684b0ead49Smrg	pdp11-*)
1569c3e29c03Smrg		os=none
15704b0ead49Smrg		;;
15714b0ead49Smrg	*-dec | vax-*)
1572c3e29c03Smrg		os=ultrix4.2
15734b0ead49Smrg		;;
15744b0ead49Smrg	m68*-apollo)
1575c3e29c03Smrg		os=domain
15764b0ead49Smrg		;;
15774b0ead49Smrg	i386-sun)
1578c3e29c03Smrg		os=sunos4.0.2
15794b0ead49Smrg		;;
15804b0ead49Smrg	m68000-sun)
1581c3e29c03Smrg		os=sunos3
15824b0ead49Smrg		;;
15834b0ead49Smrg	m68*-cisco)
1584c3e29c03Smrg		os=aout
15854b0ead49Smrg		;;
15864e7590efSmrg	mep-*)
1587c3e29c03Smrg		os=elf
158852b01e16Smrg		;;
15894b0ead49Smrg	mips*-cisco)
1590c3e29c03Smrg		os=elf
15914b0ead49Smrg		;;
15924b0ead49Smrg	mips*-*)
1593c3e29c03Smrg		os=elf
15944b0ead49Smrg		;;
15954b0ead49Smrg	or32-*)
1596c3e29c03Smrg		os=coff
15974b0ead49Smrg		;;
15984b0ead49Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1599c3e29c03Smrg		os=sysv3
16004b0ead49Smrg		;;
16014b0ead49Smrg	sparc-* | *-sun)
1602c3e29c03Smrg		os=sunos4.1.1
16034b0ead49Smrg		;;
160426372658Smrg	pru-*)
1605c3e29c03Smrg		os=elf
160626372658Smrg		;;
16074b0ead49Smrg	*-be)
1608c3e29c03Smrg		os=beos
16094b0ead49Smrg		;;
16104b0ead49Smrg	*-ibm)
1611c3e29c03Smrg		os=aix
16124b0ead49Smrg		;;
16134e7590efSmrg	*-knuth)
1614c3e29c03Smrg		os=mmixware
16154b0ead49Smrg		;;
16164b0ead49Smrg	*-wec)
1617c3e29c03Smrg		os=proelf
16184b0ead49Smrg		;;
16194b0ead49Smrg	*-winbond)
1620c3e29c03Smrg		os=proelf
16214b0ead49Smrg		;;
16224b0ead49Smrg	*-oki)
1623c3e29c03Smrg		os=proelf
16244b0ead49Smrg		;;
16254b0ead49Smrg	*-hp)
1626c3e29c03Smrg		os=hpux
16274b0ead49Smrg		;;
16284b0ead49Smrg	*-hitachi)
1629c3e29c03Smrg		os=hiux
16304b0ead49Smrg		;;
16314b0ead49Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1632c3e29c03Smrg		os=sysv
16334b0ead49Smrg		;;
16344b0ead49Smrg	*-cbm)
1635c3e29c03Smrg		os=amigaos
16364b0ead49Smrg		;;
16374b0ead49Smrg	*-dg)
1638c3e29c03Smrg		os=dgux
16394b0ead49Smrg		;;
16404b0ead49Smrg	*-dolphin)
1641c3e29c03Smrg		os=sysv3
16424b0ead49Smrg		;;
16434b0ead49Smrg	m68k-ccur)
1644c3e29c03Smrg		os=rtu
16454b0ead49Smrg		;;
16464b0ead49Smrg	m88k-omron*)
1647c3e29c03Smrg		os=luna
16484b0ead49Smrg		;;
164926372658Smrg	*-next)
1650c3e29c03Smrg		os=nextstep
16514b0ead49Smrg		;;
16524b0ead49Smrg	*-sequent)
1653c3e29c03Smrg		os=ptx
16544b0ead49Smrg		;;
16554b0ead49Smrg	*-crds)
1656c3e29c03Smrg		os=unos
16574b0ead49Smrg		;;
16584b0ead49Smrg	*-ns)
1659c3e29c03Smrg		os=genix
16604b0ead49Smrg		;;
16614b0ead49Smrg	i370-*)
1662c3e29c03Smrg		os=mvs
16634b0ead49Smrg		;;
16644b0ead49Smrg	*-gould)
1665c3e29c03Smrg		os=sysv
16664b0ead49Smrg		;;
16674b0ead49Smrg	*-highlevel)
1668c3e29c03Smrg		os=bsd
16694b0ead49Smrg		;;
16704b0ead49Smrg	*-encore)
1671c3e29c03Smrg		os=bsd
16724b0ead49Smrg		;;
16734b0ead49Smrg	*-sgi)
1674c3e29c03Smrg		os=irix
16754b0ead49Smrg		;;
16764b0ead49Smrg	*-siemens)
1677c3e29c03Smrg		os=sysv4
16784b0ead49Smrg		;;
16794b0ead49Smrg	*-masscomp)
1680c3e29c03Smrg		os=rtu
16814b0ead49Smrg		;;
16824b0ead49Smrg	f30[01]-fujitsu | f700-fujitsu)
1683c3e29c03Smrg		os=uxpv
16844b0ead49Smrg		;;
16854b0ead49Smrg	*-rom68k)
1686c3e29c03Smrg		os=coff
16874b0ead49Smrg		;;
16884b0ead49Smrg	*-*bug)
1689c3e29c03Smrg		os=coff
16904b0ead49Smrg		;;
16914b0ead49Smrg	*-apple)
1692c3e29c03Smrg		os=macos
16934b0ead49Smrg		;;
16944b0ead49Smrg	*-atari*)
1695c3e29c03Smrg		os=mint
1696c3e29c03Smrg		;;
1697c3e29c03Smrg	*-wrs)
1698c3e29c03Smrg		os=vxworks
16994b0ead49Smrg		;;
17004b0ead49Smrg	*)
1701c3e29c03Smrg		os=none
17024b0ead49Smrg		;;
17034b0ead49Smrgesac
1704c3e29c03Smrg
17054b0ead49Smrgfi
17064b0ead49Smrg
1707c3e29c03Smrg# Now, validate our (potentially fixed-up) OS.
1708c3e29c03Smrgcase $os in
1709c3e29c03Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1710c3e29c03Smrg	musl* | newlib* | relibc* | uclibc*)
1711c3e29c03Smrg		;;
1712c3e29c03Smrg	# Likewise for "kernel-abi"
1713c3e29c03Smrg	eabi* | gnueabi*)
1714c3e29c03Smrg		;;
1715c3e29c03Smrg	# VxWorks passes extra cpu info in the 4th filed.
1716c3e29c03Smrg	simlinux | simwindows | spe)
1717c3e29c03Smrg		;;
1718c3e29c03Smrg	# Now accept the basic system types.
1719c3e29c03Smrg	# The portable systems comes first.
1720c3e29c03Smrg	# Each alternative MUST end in a * to match a version number.
1721c3e29c03Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1722c3e29c03Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1723c3e29c03Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1724c3e29c03Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1725c3e29c03Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1726c3e29c03Smrg	     | os9* | macos* | osx* | ios* \
1727c3e29c03Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1728c3e29c03Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1729c3e29c03Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1730c3e29c03Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1731c3e29c03Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1732c3e29c03Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1733c3e29c03Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1734c3e29c03Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1735c3e29c03Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1736c3e29c03Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1737c3e29c03Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1738c3e29c03Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1739c3e29c03Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1740c3e29c03Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1741c3e29c03Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1742c3e29c03Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1743c3e29c03Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1744c3e29c03Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1745c3e29c03Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1746c3e29c03Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1747c3e29c03Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1748c3e29c03Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1749c3e29c03Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1750c3e29c03Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1751c3e29c03Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
1752c3e29c03Smrg		;;
1753c3e29c03Smrg	# This one is extra strict with allowed versions
1754c3e29c03Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1755c3e29c03Smrg		# Don't forget version if it is 3.2v4 or newer.
1756c3e29c03Smrg		;;
1757c3e29c03Smrg	none)
1758c3e29c03Smrg		;;
1759c3e29c03Smrg	*)
1760c3e29c03Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1761c3e29c03Smrg		exit 1
1762c3e29c03Smrg		;;
1763c3e29c03Smrgesac
1764c3e29c03Smrg
1765c3e29c03Smrg# As a final step for OS-related things, validate the OS-kernel combination
1766c3e29c03Smrg# (given a valid OS), if there is a kernel.
1767c3e29c03Smrgcase $kernel-$os in
1768c3e29c03Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1769c3e29c03Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
1770c3e29c03Smrg		;;
1771c3e29c03Smrg	uclinux-uclibc* )
1772c3e29c03Smrg		;;
1773c3e29c03Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
1774c3e29c03Smrg		# These are just libc implementations, not actual OSes, and thus
1775c3e29c03Smrg		# require a kernel.
1776c3e29c03Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1777c3e29c03Smrg		exit 1
1778c3e29c03Smrg		;;
1779c3e29c03Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1780c3e29c03Smrg		;;
1781c3e29c03Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1782c3e29c03Smrg		;;
1783c3e29c03Smrg	nto-qnx*)
1784c3e29c03Smrg		;;
1785c3e29c03Smrg	os2-emx)
1786c3e29c03Smrg		;;
1787c3e29c03Smrg	*-eabi* | *-gnueabi*)
1788c3e29c03Smrg		;;
1789c3e29c03Smrg	-*)
1790c3e29c03Smrg		# Blank kernel with real OS is always fine.
1791c3e29c03Smrg		;;
1792c3e29c03Smrg	*-*)
1793c3e29c03Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1794c3e29c03Smrg		exit 1
1795c3e29c03Smrg		;;
1796c3e29c03Smrgesac
1797c3e29c03Smrg
17984b0ead49Smrg# Here we handle the case where we know the os, and the CPU type, but not the
17994b0ead49Smrg# manufacturer.  We pick the logical manufacturer.
1800c3e29c03Smrgcase $vendor in
1801c3e29c03Smrg	unknown)
1802c3e29c03Smrg		case $cpu-$os in
1803c3e29c03Smrg			*-riscix*)
18044b0ead49Smrg				vendor=acorn
18054b0ead49Smrg				;;
1806c3e29c03Smrg			*-sunos*)
18074b0ead49Smrg				vendor=sun
18084b0ead49Smrg				;;
1809c3e29c03Smrg			*-cnk* | *-aix*)
18104b0ead49Smrg				vendor=ibm
18114b0ead49Smrg				;;
1812c3e29c03Smrg			*-beos*)
18134b0ead49Smrg				vendor=be
18144b0ead49Smrg				;;
1815c3e29c03Smrg			*-hpux*)
18164b0ead49Smrg				vendor=hp
18174b0ead49Smrg				;;
1818c3e29c03Smrg			*-mpeix*)
18194b0ead49Smrg				vendor=hp
18204b0ead49Smrg				;;
1821c3e29c03Smrg			*-hiux*)
18224b0ead49Smrg				vendor=hitachi
18234b0ead49Smrg				;;
1824c3e29c03Smrg			*-unos*)
18254b0ead49Smrg				vendor=crds
18264b0ead49Smrg				;;
1827c3e29c03Smrg			*-dgux*)
18284b0ead49Smrg				vendor=dg
18294b0ead49Smrg				;;
1830c3e29c03Smrg			*-luna*)
18314b0ead49Smrg				vendor=omron
18324b0ead49Smrg				;;
1833c3e29c03Smrg			*-genix*)
18344b0ead49Smrg				vendor=ns
18354b0ead49Smrg				;;
1836c3e29c03Smrg			*-clix*)
1837c3e29c03Smrg				vendor=intergraph
1838c3e29c03Smrg				;;
1839c3e29c03Smrg			*-mvs* | *-opened*)
1840c3e29c03Smrg				vendor=ibm
1841c3e29c03Smrg				;;
1842c3e29c03Smrg			*-os400*)
18434b0ead49Smrg				vendor=ibm
18444b0ead49Smrg				;;
1845c3e29c03Smrg			s390-* | s390x-*)
18464b0ead49Smrg				vendor=ibm
18474b0ead49Smrg				;;
1848c3e29c03Smrg			*-ptx*)
18494b0ead49Smrg				vendor=sequent
18504b0ead49Smrg				;;
1851c3e29c03Smrg			*-tpf*)
18524b0ead49Smrg				vendor=ibm
18534b0ead49Smrg				;;
1854c3e29c03Smrg			*-vxsim* | *-vxworks* | *-windiss*)
18554b0ead49Smrg				vendor=wrs
18564b0ead49Smrg				;;
1857c3e29c03Smrg			*-aux*)
18584b0ead49Smrg				vendor=apple
18594b0ead49Smrg				;;
1860c3e29c03Smrg			*-hms*)
18614b0ead49Smrg				vendor=hitachi
18624b0ead49Smrg				;;
1863c3e29c03Smrg			*-mpw* | *-macos*)
18644b0ead49Smrg				vendor=apple
18654b0ead49Smrg				;;
1866c3e29c03Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
18674b0ead49Smrg				vendor=atari
18684b0ead49Smrg				;;
1869c3e29c03Smrg			*-vos*)
18704b0ead49Smrg				vendor=stratus
18714b0ead49Smrg				;;
18724b0ead49Smrg		esac
18734b0ead49Smrg		;;
18744b0ead49Smrgesac
18754b0ead49Smrg
1876c3e29c03Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
18774b0ead49Smrgexit
18784b0ead49Smrg
18794b0ead49Smrg# Local variables:
1880c3e29c03Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
18814b0ead49Smrg# time-stamp-start: "timestamp='"
18824b0ead49Smrg# time-stamp-format: "%:y-%02m-%02d"
18834b0ead49Smrg# time-stamp-end: "'"
18844b0ead49Smrg# End:
1885