195b296d0Smrg#! /bin/sh
295b296d0Smrg# Configuration validation subroutine script.
3d87a3195Smrg#   Copyright 1992-2021 Free Software Foundation, Inc.
495b296d0Smrg
5d87a3195Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6d87a3195Smrg
7d87a3195Smrgtimestamp='2021-08-14'
895b296d0Smrg
9eca46af7Smrg# This file is free software; you can redistribute it and/or modify it
10eca46af7Smrg# under the terms of the GNU General Public License as published by
11eca46af7Smrg# the Free Software Foundation; either version 3 of the License, or
1295b296d0Smrg# (at your option) any later version.
1395b296d0Smrg#
14eca46af7Smrg# This program is distributed in the hope that it will be useful, but
15eca46af7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16eca46af7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17eca46af7Smrg# General Public License for more details.
1895b296d0Smrg#
1995b296d0Smrg# You should have received a copy of the GNU General Public License
20d87a3195Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2195b296d0Smrg#
2295b296d0Smrg# As a special exception to the GNU General Public License, if you
2395b296d0Smrg# distribute this file as part of a program that contains a
2495b296d0Smrg# configuration script generated by Autoconf, you may include it under
25eca46af7Smrg# the same distribution terms that you use for the rest of that
26eca46af7Smrg# program.  This Exception is an additional permission under section 7
27eca46af7Smrg# of the GNU General Public License, version 3 ("GPLv3").
2895b296d0Smrg
2995b296d0Smrg
3089b0dc75Smrg# Please send patches to <config-patches@gnu.org>.
3195b296d0Smrg#
3295b296d0Smrg# Configuration subroutine to validate and canonicalize a configuration type.
3395b296d0Smrg# Supply the specified configuration type as an argument.
3495b296d0Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
3595b296d0Smrg# Otherwise, we print the canonical config type on stdout and succeed.
3695b296d0Smrg
3714330f12Smrg# You can get the latest version of this script from:
38d87a3195Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
3914330f12Smrg
4095b296d0Smrg# This file is supposed to be the same for all GNU packages
4195b296d0Smrg# and recognize all the CPU types, system types and aliases
4295b296d0Smrg# that are meaningful with *any* GNU software.
4395b296d0Smrg# Each package is responsible for reporting which valid configurations
4495b296d0Smrg# it does not support.  The user should be able to distinguish
4595b296d0Smrg# a failure to support a valid configuration from a meaningless
4695b296d0Smrg# configuration.
4795b296d0Smrg
4895b296d0Smrg# The goal of this file is to map all the various variations of a given
4995b296d0Smrg# machine specification into a single specification in the form:
5095b296d0Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
5195b296d0Smrg# or in some cases, the newer four-part form:
5295b296d0Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
5395b296d0Smrg# It is wrong to echo any other type of specification.
5495b296d0Smrg
55d87a3195Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
56d87a3195Smrg# about features and limitations of the classic Bourne shell that were
57d87a3195Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
58d87a3195Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
59d87a3195Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
60d87a3195Smrg# have a pre-POSIX /bin/sh.
61d87a3195Smrg
6295b296d0Smrgme=`echo "$0" | sed -e 's,.*/,,'`
6395b296d0Smrg
6495b296d0Smrgusage="\
6589b0dc75SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
6695b296d0Smrg
6795b296d0SmrgCanonicalize a configuration name.
6895b296d0Smrg
69d87a3195SmrgOptions:
7095b296d0Smrg  -h, --help         print this help, then exit
7195b296d0Smrg  -t, --time-stamp   print date of last modification, then exit
7295b296d0Smrg  -v, --version      print version number, then exit
7395b296d0Smrg
7495b296d0SmrgReport bugs and patches to <config-patches@gnu.org>."
7595b296d0Smrg
7695b296d0Smrgversion="\
7795b296d0SmrgGNU config.sub ($timestamp)
7895b296d0Smrg
79d87a3195SmrgCopyright 1992-2021 Free Software Foundation, Inc.
8095b296d0Smrg
8195b296d0SmrgThis is free software; see the source for copying conditions.  There is NO
8295b296d0Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
8395b296d0Smrg
8495b296d0Smrghelp="
8595b296d0SmrgTry \`$me --help' for more information."
8695b296d0Smrg
8795b296d0Smrg# Parse command line
8895b296d0Smrgwhile test $# -gt 0 ; do
8995b296d0Smrg  case $1 in
9095b296d0Smrg    --time-stamp | --time* | -t )
9195b296d0Smrg       echo "$timestamp" ; exit ;;
9295b296d0Smrg    --version | -v )
9395b296d0Smrg       echo "$version" ; exit ;;
9495b296d0Smrg    --help | --h* | -h )
9595b296d0Smrg       echo "$usage"; exit ;;
9695b296d0Smrg    -- )     # Stop option processing
9795b296d0Smrg       shift; break ;;
9895b296d0Smrg    - )	# Use stdin as input.
9995b296d0Smrg       break ;;
10095b296d0Smrg    -* )
101d87a3195Smrg       echo "$me: invalid option $1$help" >&2
10295b296d0Smrg       exit 1 ;;
10395b296d0Smrg
10495b296d0Smrg    *local*)
10595b296d0Smrg       # First pass through any local machine types.
106d87a3195Smrg       echo "$1"
10795b296d0Smrg       exit ;;
10895b296d0Smrg
10995b296d0Smrg    * )
11095b296d0Smrg       break ;;
11195b296d0Smrg  esac
11295b296d0Smrgdone
11395b296d0Smrg
11495b296d0Smrgcase $# in
11595b296d0Smrg 0) echo "$me: missing argument$help" >&2
11695b296d0Smrg    exit 1;;
11795b296d0Smrg 1) ;;
11895b296d0Smrg *) echo "$me: too many arguments$help" >&2
11995b296d0Smrg    exit 1;;
12095b296d0Smrgesac
12195b296d0Smrg
122d87a3195Smrg# Split fields of configuration type
123d87a3195Smrg# shellcheck disable=SC2162
124d87a3195Smrgsaved_IFS=$IFS
125d87a3195SmrgIFS="-" read field1 field2 field3 field4 <<EOF
126d87a3195Smrg$1
127d87a3195SmrgEOF
128d87a3195SmrgIFS=$saved_IFS
12995b296d0Smrg
130d87a3195Smrg# Separate into logical components for further validation
131d87a3195Smrgcase $1 in
132d87a3195Smrg	*-*-*-*-*)
133d87a3195Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
134d87a3195Smrg		exit 1
13595b296d0Smrg		;;
136d87a3195Smrg	*-*-*-*)
137d87a3195Smrg		basic_machine=$field1-$field2
138d87a3195Smrg		basic_os=$field3-$field4
13995b296d0Smrg		;;
140d87a3195Smrg	*-*-*)
141d87a3195Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142d87a3195Smrg		# parts
143d87a3195Smrg		maybe_os=$field2-$field3
144d87a3195Smrg		case $maybe_os in
145d87a3195Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
146d87a3195Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147d87a3195Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148d87a3195Smrg			| storm-chaos* | os2-emx* | rtmk-nova*)
149d87a3195Smrg				basic_machine=$field1
150d87a3195Smrg				basic_os=$maybe_os
151d87a3195Smrg				;;
152d87a3195Smrg			android-linux)
153d87a3195Smrg				basic_machine=$field1-unknown
154d87a3195Smrg				basic_os=linux-android
155d87a3195Smrg				;;
156d87a3195Smrg			*)
157d87a3195Smrg				basic_machine=$field1-$field2
158d87a3195Smrg				basic_os=$field3
159d87a3195Smrg				;;
160d87a3195Smrg		esac
16195b296d0Smrg		;;
162d87a3195Smrg	*-*)
163d87a3195Smrg		# A lone config we happen to match not fitting any pattern
164d87a3195Smrg		case $field1-$field2 in
165d87a3195Smrg			decstation-3100)
166d87a3195Smrg				basic_machine=mips-dec
167d87a3195Smrg				basic_os=
168d87a3195Smrg				;;
169d87a3195Smrg			*-*)
170d87a3195Smrg				# Second component is usually, but not always the OS
171d87a3195Smrg				case $field2 in
172d87a3195Smrg					# Prevent following clause from handling this valid os
173d87a3195Smrg					sun*os*)
174d87a3195Smrg						basic_machine=$field1
175d87a3195Smrg						basic_os=$field2
176d87a3195Smrg						;;
177d87a3195Smrg					zephyr*)
178d87a3195Smrg						basic_machine=$field1-unknown
179d87a3195Smrg						basic_os=$field2
180d87a3195Smrg						;;
181d87a3195Smrg					# Manufacturers
182d87a3195Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183d87a3195Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184d87a3195Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185d87a3195Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186d87a3195Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187d87a3195Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
188d87a3195Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
189d87a3195Smrg					| microblaze* | sim | cisco \
190d87a3195Smrg					| oki | wec | wrs | winbond)
191d87a3195Smrg						basic_machine=$field1-$field2
192d87a3195Smrg						basic_os=
193d87a3195Smrg						;;
194d87a3195Smrg					*)
195d87a3195Smrg						basic_machine=$field1
196d87a3195Smrg						basic_os=$field2
197d87a3195Smrg						;;
198d87a3195Smrg				esac
199d87a3195Smrg			;;
200d87a3195Smrg		esac
20195b296d0Smrg		;;
202d87a3195Smrg	*)
203d87a3195Smrg		# Convert single-component short-hands not valid as part of
204d87a3195Smrg		# multi-component configurations.
205d87a3195Smrg		case $field1 in
206d87a3195Smrg			386bsd)
207d87a3195Smrg				basic_machine=i386-pc
208d87a3195Smrg				basic_os=bsd
209d87a3195Smrg				;;
210d87a3195Smrg			a29khif)
211d87a3195Smrg				basic_machine=a29k-amd
212d87a3195Smrg				basic_os=udi
213d87a3195Smrg				;;
214d87a3195Smrg			adobe68k)
215d87a3195Smrg				basic_machine=m68010-adobe
216d87a3195Smrg				basic_os=scout
217d87a3195Smrg				;;
218d87a3195Smrg			alliant)
219d87a3195Smrg				basic_machine=fx80-alliant
220d87a3195Smrg				basic_os=
221d87a3195Smrg				;;
222d87a3195Smrg			altos | altos3068)
223d87a3195Smrg				basic_machine=m68k-altos
224d87a3195Smrg				basic_os=
225d87a3195Smrg				;;
226d87a3195Smrg			am29k)
227d87a3195Smrg				basic_machine=a29k-none
228d87a3195Smrg				basic_os=bsd
229d87a3195Smrg				;;
230d87a3195Smrg			amdahl)
231d87a3195Smrg				basic_machine=580-amdahl
232d87a3195Smrg				basic_os=sysv
233d87a3195Smrg				;;
234d87a3195Smrg			amiga)
235d87a3195Smrg				basic_machine=m68k-unknown
236d87a3195Smrg				basic_os=
237d87a3195Smrg				;;
238d87a3195Smrg			amigaos | amigados)
239d87a3195Smrg				basic_machine=m68k-unknown
240d87a3195Smrg				basic_os=amigaos
241d87a3195Smrg				;;
242d87a3195Smrg			amigaunix | amix)
243d87a3195Smrg				basic_machine=m68k-unknown
244d87a3195Smrg				basic_os=sysv4
245d87a3195Smrg				;;
246d87a3195Smrg			apollo68)
247d87a3195Smrg				basic_machine=m68k-apollo
248d87a3195Smrg				basic_os=sysv
249d87a3195Smrg				;;
250d87a3195Smrg			apollo68bsd)
251d87a3195Smrg				basic_machine=m68k-apollo
252d87a3195Smrg				basic_os=bsd
253d87a3195Smrg				;;
254d87a3195Smrg			aros)
255d87a3195Smrg				basic_machine=i386-pc
256d87a3195Smrg				basic_os=aros
257d87a3195Smrg				;;
258d87a3195Smrg			aux)
259d87a3195Smrg				basic_machine=m68k-apple
260d87a3195Smrg				basic_os=aux
261d87a3195Smrg				;;
262d87a3195Smrg			balance)
263d87a3195Smrg				basic_machine=ns32k-sequent
264d87a3195Smrg				basic_os=dynix
265d87a3195Smrg				;;
266d87a3195Smrg			blackfin)
267d87a3195Smrg				basic_machine=bfin-unknown
268d87a3195Smrg				basic_os=linux
269d87a3195Smrg				;;
270d87a3195Smrg			cegcc)
271d87a3195Smrg				basic_machine=arm-unknown
272d87a3195Smrg				basic_os=cegcc
273d87a3195Smrg				;;
274d87a3195Smrg			convex-c1)
275d87a3195Smrg				basic_machine=c1-convex
276d87a3195Smrg				basic_os=bsd
277d87a3195Smrg				;;
278d87a3195Smrg			convex-c2)
279d87a3195Smrg				basic_machine=c2-convex
280d87a3195Smrg				basic_os=bsd
281d87a3195Smrg				;;
282d87a3195Smrg			convex-c32)
283d87a3195Smrg				basic_machine=c32-convex
284d87a3195Smrg				basic_os=bsd
285d87a3195Smrg				;;
286d87a3195Smrg			convex-c34)
287d87a3195Smrg				basic_machine=c34-convex
288d87a3195Smrg				basic_os=bsd
289d87a3195Smrg				;;
290d87a3195Smrg			convex-c38)
291d87a3195Smrg				basic_machine=c38-convex
292d87a3195Smrg				basic_os=bsd
293d87a3195Smrg				;;
294d87a3195Smrg			cray)
295d87a3195Smrg				basic_machine=j90-cray
296d87a3195Smrg				basic_os=unicos
297d87a3195Smrg				;;
298d87a3195Smrg			crds | unos)
299d87a3195Smrg				basic_machine=m68k-crds
300d87a3195Smrg				basic_os=
301d87a3195Smrg				;;
302d87a3195Smrg			da30)
303d87a3195Smrg				basic_machine=m68k-da30
304d87a3195Smrg				basic_os=
305d87a3195Smrg				;;
306d87a3195Smrg			decstation | pmax | pmin | dec3100 | decstatn)
307d87a3195Smrg				basic_machine=mips-dec
308d87a3195Smrg				basic_os=
309d87a3195Smrg				;;
310d87a3195Smrg			delta88)
311d87a3195Smrg				basic_machine=m88k-motorola
312d87a3195Smrg				basic_os=sysv3
313d87a3195Smrg				;;
314d87a3195Smrg			dicos)
315d87a3195Smrg				basic_machine=i686-pc
316d87a3195Smrg				basic_os=dicos
317d87a3195Smrg				;;
318d87a3195Smrg			djgpp)
319d87a3195Smrg				basic_machine=i586-pc
320d87a3195Smrg				basic_os=msdosdjgpp
321d87a3195Smrg				;;
322d87a3195Smrg			ebmon29k)
323d87a3195Smrg				basic_machine=a29k-amd
324d87a3195Smrg				basic_os=ebmon
325d87a3195Smrg				;;
326d87a3195Smrg			es1800 | OSE68k | ose68k | ose | OSE)
327d87a3195Smrg				basic_machine=m68k-ericsson
328d87a3195Smrg				basic_os=ose
329d87a3195Smrg				;;
330d87a3195Smrg			gmicro)
331d87a3195Smrg				basic_machine=tron-gmicro
332d87a3195Smrg				basic_os=sysv
333d87a3195Smrg				;;
334d87a3195Smrg			go32)
335d87a3195Smrg				basic_machine=i386-pc
336d87a3195Smrg				basic_os=go32
337d87a3195Smrg				;;
338d87a3195Smrg			h8300hms)
339d87a3195Smrg				basic_machine=h8300-hitachi
340d87a3195Smrg				basic_os=hms
341d87a3195Smrg				;;
342d87a3195Smrg			h8300xray)
343d87a3195Smrg				basic_machine=h8300-hitachi
344d87a3195Smrg				basic_os=xray
345d87a3195Smrg				;;
346d87a3195Smrg			h8500hms)
347d87a3195Smrg				basic_machine=h8500-hitachi
348d87a3195Smrg				basic_os=hms
349d87a3195Smrg				;;
350d87a3195Smrg			harris)
351d87a3195Smrg				basic_machine=m88k-harris
352d87a3195Smrg				basic_os=sysv3
353d87a3195Smrg				;;
354d87a3195Smrg			hp300 | hp300hpux)
355d87a3195Smrg				basic_machine=m68k-hp
356d87a3195Smrg				basic_os=hpux
357d87a3195Smrg				;;
358d87a3195Smrg			hp300bsd)
359d87a3195Smrg				basic_machine=m68k-hp
360d87a3195Smrg				basic_os=bsd
361d87a3195Smrg				;;
362d87a3195Smrg			hppaosf)
363d87a3195Smrg				basic_machine=hppa1.1-hp
364d87a3195Smrg				basic_os=osf
365d87a3195Smrg				;;
366d87a3195Smrg			hppro)
367d87a3195Smrg				basic_machine=hppa1.1-hp
368d87a3195Smrg				basic_os=proelf
369d87a3195Smrg				;;
370d87a3195Smrg			i386mach)
371d87a3195Smrg				basic_machine=i386-mach
372d87a3195Smrg				basic_os=mach
373d87a3195Smrg				;;
374d87a3195Smrg			isi68 | isi)
375d87a3195Smrg				basic_machine=m68k-isi
376d87a3195Smrg				basic_os=sysv
377d87a3195Smrg				;;
378d87a3195Smrg			m68knommu)
379d87a3195Smrg				basic_machine=m68k-unknown
380d87a3195Smrg				basic_os=linux
381d87a3195Smrg				;;
382d87a3195Smrg			magnum | m3230)
383d87a3195Smrg				basic_machine=mips-mips
384d87a3195Smrg				basic_os=sysv
385d87a3195Smrg				;;
386d87a3195Smrg			merlin)
387d87a3195Smrg				basic_machine=ns32k-utek
388d87a3195Smrg				basic_os=sysv
389d87a3195Smrg				;;
390d87a3195Smrg			mingw64)
391d87a3195Smrg				basic_machine=x86_64-pc
392d87a3195Smrg				basic_os=mingw64
393d87a3195Smrg				;;
394d87a3195Smrg			mingw32)
395d87a3195Smrg				basic_machine=i686-pc
396d87a3195Smrg				basic_os=mingw32
397d87a3195Smrg				;;
398d87a3195Smrg			mingw32ce)
399d87a3195Smrg				basic_machine=arm-unknown
400d87a3195Smrg				basic_os=mingw32ce
401d87a3195Smrg				;;
402d87a3195Smrg			monitor)
403d87a3195Smrg				basic_machine=m68k-rom68k
404d87a3195Smrg				basic_os=coff
405d87a3195Smrg				;;
406d87a3195Smrg			morphos)
407d87a3195Smrg				basic_machine=powerpc-unknown
408d87a3195Smrg				basic_os=morphos
409d87a3195Smrg				;;
410d87a3195Smrg			moxiebox)
411d87a3195Smrg				basic_machine=moxie-unknown
412d87a3195Smrg				basic_os=moxiebox
413d87a3195Smrg				;;
414d87a3195Smrg			msdos)
415d87a3195Smrg				basic_machine=i386-pc
416d87a3195Smrg				basic_os=msdos
417d87a3195Smrg				;;
418d87a3195Smrg			msys)
419d87a3195Smrg				basic_machine=i686-pc
420d87a3195Smrg				basic_os=msys
421d87a3195Smrg				;;
422d87a3195Smrg			mvs)
423d87a3195Smrg				basic_machine=i370-ibm
424d87a3195Smrg				basic_os=mvs
425d87a3195Smrg				;;
426d87a3195Smrg			nacl)
427d87a3195Smrg				basic_machine=le32-unknown
428d87a3195Smrg				basic_os=nacl
429d87a3195Smrg				;;
430d87a3195Smrg			ncr3000)
431d87a3195Smrg				basic_machine=i486-ncr
432d87a3195Smrg				basic_os=sysv4
433d87a3195Smrg				;;
434d87a3195Smrg			netbsd386)
435d87a3195Smrg				basic_machine=i386-pc
436d87a3195Smrg				basic_os=netbsd
437d87a3195Smrg				;;
438d87a3195Smrg			netwinder)
439d87a3195Smrg				basic_machine=armv4l-rebel
440d87a3195Smrg				basic_os=linux
441d87a3195Smrg				;;
442d87a3195Smrg			news | news700 | news800 | news900)
443d87a3195Smrg				basic_machine=m68k-sony
444d87a3195Smrg				basic_os=newsos
445d87a3195Smrg				;;
446d87a3195Smrg			news1000)
447d87a3195Smrg				basic_machine=m68030-sony
448d87a3195Smrg				basic_os=newsos
449d87a3195Smrg				;;
450d87a3195Smrg			necv70)
451d87a3195Smrg				basic_machine=v70-nec
452d87a3195Smrg				basic_os=sysv
453d87a3195Smrg				;;
454d87a3195Smrg			nh3000)
455d87a3195Smrg				basic_machine=m68k-harris
456d87a3195Smrg				basic_os=cxux
457d87a3195Smrg				;;
458d87a3195Smrg			nh[45]000)
459d87a3195Smrg				basic_machine=m88k-harris
460d87a3195Smrg				basic_os=cxux
461d87a3195Smrg				;;
462d87a3195Smrg			nindy960)
463d87a3195Smrg				basic_machine=i960-intel
464d87a3195Smrg				basic_os=nindy
465d87a3195Smrg				;;
466d87a3195Smrg			mon960)
467d87a3195Smrg				basic_machine=i960-intel
468d87a3195Smrg				basic_os=mon960
469d87a3195Smrg				;;
470d87a3195Smrg			nonstopux)
471d87a3195Smrg				basic_machine=mips-compaq
472d87a3195Smrg				basic_os=nonstopux
473d87a3195Smrg				;;
474d87a3195Smrg			os400)
475d87a3195Smrg				basic_machine=powerpc-ibm
476d87a3195Smrg				basic_os=os400
477d87a3195Smrg				;;
478d87a3195Smrg			OSE68000 | ose68000)
479d87a3195Smrg				basic_machine=m68000-ericsson
480d87a3195Smrg				basic_os=ose
481d87a3195Smrg				;;
482d87a3195Smrg			os68k)
483d87a3195Smrg				basic_machine=m68k-none
484d87a3195Smrg				basic_os=os68k
485d87a3195Smrg				;;
486d87a3195Smrg			paragon)
487d87a3195Smrg				basic_machine=i860-intel
488d87a3195Smrg				basic_os=osf
489d87a3195Smrg				;;
490d87a3195Smrg			parisc)
491d87a3195Smrg				basic_machine=hppa-unknown
492d87a3195Smrg				basic_os=linux
493d87a3195Smrg				;;
494d87a3195Smrg			psp)
495d87a3195Smrg				basic_machine=mipsallegrexel-sony
496d87a3195Smrg				basic_os=psp
497d87a3195Smrg				;;
498d87a3195Smrg			pw32)
499d87a3195Smrg				basic_machine=i586-unknown
500d87a3195Smrg				basic_os=pw32
501d87a3195Smrg				;;
502d87a3195Smrg			rdos | rdos64)
503d87a3195Smrg				basic_machine=x86_64-pc
504d87a3195Smrg				basic_os=rdos
505d87a3195Smrg				;;
506d87a3195Smrg			rdos32)
507d87a3195Smrg				basic_machine=i386-pc
508d87a3195Smrg				basic_os=rdos
509d87a3195Smrg				;;
510d87a3195Smrg			rom68k)
511d87a3195Smrg				basic_machine=m68k-rom68k
512d87a3195Smrg				basic_os=coff
513d87a3195Smrg				;;
514d87a3195Smrg			sa29200)
515d87a3195Smrg				basic_machine=a29k-amd
516d87a3195Smrg				basic_os=udi
517d87a3195Smrg				;;
518d87a3195Smrg			sei)
519d87a3195Smrg				basic_machine=mips-sei
520d87a3195Smrg				basic_os=seiux
521d87a3195Smrg				;;
522d87a3195Smrg			sequent)
523d87a3195Smrg				basic_machine=i386-sequent
524d87a3195Smrg				basic_os=
525d87a3195Smrg				;;
526d87a3195Smrg			sps7)
527d87a3195Smrg				basic_machine=m68k-bull
528d87a3195Smrg				basic_os=sysv2
529d87a3195Smrg				;;
530d87a3195Smrg			st2000)
531d87a3195Smrg				basic_machine=m68k-tandem
532d87a3195Smrg				basic_os=
533d87a3195Smrg				;;
534d87a3195Smrg			stratus)
535d87a3195Smrg				basic_machine=i860-stratus
536d87a3195Smrg				basic_os=sysv4
537d87a3195Smrg				;;
538d87a3195Smrg			sun2)
539d87a3195Smrg				basic_machine=m68000-sun
540d87a3195Smrg				basic_os=
541d87a3195Smrg				;;
542d87a3195Smrg			sun2os3)
543d87a3195Smrg				basic_machine=m68000-sun
544d87a3195Smrg				basic_os=sunos3
545d87a3195Smrg				;;
546d87a3195Smrg			sun2os4)
547d87a3195Smrg				basic_machine=m68000-sun
548d87a3195Smrg				basic_os=sunos4
549d87a3195Smrg				;;
550d87a3195Smrg			sun3)
551d87a3195Smrg				basic_machine=m68k-sun
552d87a3195Smrg				basic_os=
553d87a3195Smrg				;;
554d87a3195Smrg			sun3os3)
555d87a3195Smrg				basic_machine=m68k-sun
556d87a3195Smrg				basic_os=sunos3
557d87a3195Smrg				;;
558d87a3195Smrg			sun3os4)
559d87a3195Smrg				basic_machine=m68k-sun
560d87a3195Smrg				basic_os=sunos4
561d87a3195Smrg				;;
562d87a3195Smrg			sun4)
563d87a3195Smrg				basic_machine=sparc-sun
564d87a3195Smrg				basic_os=
565d87a3195Smrg				;;
566d87a3195Smrg			sun4os3)
567d87a3195Smrg				basic_machine=sparc-sun
568d87a3195Smrg				basic_os=sunos3
569d87a3195Smrg				;;
570d87a3195Smrg			sun4os4)
571d87a3195Smrg				basic_machine=sparc-sun
572d87a3195Smrg				basic_os=sunos4
573d87a3195Smrg				;;
574d87a3195Smrg			sun4sol2)
575d87a3195Smrg				basic_machine=sparc-sun
576d87a3195Smrg				basic_os=solaris2
577d87a3195Smrg				;;
578d87a3195Smrg			sun386 | sun386i | roadrunner)
579d87a3195Smrg				basic_machine=i386-sun
580d87a3195Smrg				basic_os=
581d87a3195Smrg				;;
582d87a3195Smrg			sv1)
583d87a3195Smrg				basic_machine=sv1-cray
584d87a3195Smrg				basic_os=unicos
585d87a3195Smrg				;;
586d87a3195Smrg			symmetry)
587d87a3195Smrg				basic_machine=i386-sequent
588d87a3195Smrg				basic_os=dynix
589d87a3195Smrg				;;
590d87a3195Smrg			t3e)
591d87a3195Smrg				basic_machine=alphaev5-cray
592d87a3195Smrg				basic_os=unicos
593d87a3195Smrg				;;
594d87a3195Smrg			t90)
595d87a3195Smrg				basic_machine=t90-cray
596d87a3195Smrg				basic_os=unicos
597d87a3195Smrg				;;
598d87a3195Smrg			toad1)
599d87a3195Smrg				basic_machine=pdp10-xkl
600d87a3195Smrg				basic_os=tops20
601d87a3195Smrg				;;
602d87a3195Smrg			tpf)
603d87a3195Smrg				basic_machine=s390x-ibm
604d87a3195Smrg				basic_os=tpf
605d87a3195Smrg				;;
606d87a3195Smrg			udi29k)
607d87a3195Smrg				basic_machine=a29k-amd
608d87a3195Smrg				basic_os=udi
609d87a3195Smrg				;;
610d87a3195Smrg			ultra3)
611d87a3195Smrg				basic_machine=a29k-nyu
612d87a3195Smrg				basic_os=sym1
613d87a3195Smrg				;;
614d87a3195Smrg			v810 | necv810)
615d87a3195Smrg				basic_machine=v810-nec
616d87a3195Smrg				basic_os=none
617d87a3195Smrg				;;
618d87a3195Smrg			vaxv)
619d87a3195Smrg				basic_machine=vax-dec
620d87a3195Smrg				basic_os=sysv
621d87a3195Smrg				;;
622d87a3195Smrg			vms)
623d87a3195Smrg				basic_machine=vax-dec
624d87a3195Smrg				basic_os=vms
625d87a3195Smrg				;;
626d87a3195Smrg			vsta)
627d87a3195Smrg				basic_machine=i386-pc
628d87a3195Smrg				basic_os=vsta
629d87a3195Smrg				;;
630d87a3195Smrg			vxworks960)
631d87a3195Smrg				basic_machine=i960-wrs
632d87a3195Smrg				basic_os=vxworks
633d87a3195Smrg				;;
634d87a3195Smrg			vxworks68)
635d87a3195Smrg				basic_machine=m68k-wrs
636d87a3195Smrg				basic_os=vxworks
637d87a3195Smrg				;;
638d87a3195Smrg			vxworks29k)
639d87a3195Smrg				basic_machine=a29k-wrs
640d87a3195Smrg				basic_os=vxworks
641d87a3195Smrg				;;
642d87a3195Smrg			xbox)
643d87a3195Smrg				basic_machine=i686-pc
644d87a3195Smrg				basic_os=mingw32
645d87a3195Smrg				;;
646d87a3195Smrg			ymp)
647d87a3195Smrg				basic_machine=ymp-cray
648d87a3195Smrg				basic_os=unicos
649d87a3195Smrg				;;
650d87a3195Smrg			*)
651d87a3195Smrg				basic_machine=$1
652d87a3195Smrg				basic_os=
653d87a3195Smrg				;;
654d87a3195Smrg		esac
65595b296d0Smrg		;;
65695b296d0Smrgesac
65795b296d0Smrg
658d87a3195Smrg# Decode 1-component or ad-hoc basic machines
65995b296d0Smrgcase $basic_machine in
660d87a3195Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
661d87a3195Smrg	# some cases the only manufacturer, in others, it is the most popular.
662d87a3195Smrg	w89k)
663d87a3195Smrg		cpu=hppa1.1
664d87a3195Smrg		vendor=winbond
66595b296d0Smrg		;;
666d87a3195Smrg	op50n)
667d87a3195Smrg		cpu=hppa1.1
668d87a3195Smrg		vendor=oki
66995b296d0Smrg		;;
670d87a3195Smrg	op60c)
671d87a3195Smrg		cpu=hppa1.1
672d87a3195Smrg		vendor=oki
67395b296d0Smrg		;;
674d87a3195Smrg	ibm*)
675d87a3195Smrg		cpu=i370
676d87a3195Smrg		vendor=ibm
677eca46af7Smrg		;;
678d87a3195Smrg	orion105)
679d87a3195Smrg		cpu=clipper
680d87a3195Smrg		vendor=highlevel
681eca46af7Smrg		;;
682d87a3195Smrg	mac | mpw | mac-mpw)
683d87a3195Smrg		cpu=m68k
684d87a3195Smrg		vendor=apple
685eca46af7Smrg		;;
686d87a3195Smrg	pmac | pmac-mpw)
687d87a3195Smrg		cpu=powerpc
688d87a3195Smrg		vendor=apple
689eca46af7Smrg		;;
690eca46af7Smrg
69195b296d0Smrg	# Recognize the various machine names and aliases which stand
69295b296d0Smrg	# for a CPU type and a company and sometimes even an OS.
69395b296d0Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694d87a3195Smrg		cpu=m68000
695d87a3195Smrg		vendor=att
69695b296d0Smrg		;;
69795b296d0Smrg	3b*)
698d87a3195Smrg		cpu=we32k
699d87a3195Smrg		vendor=att
700ff89ac2bSmrg		;;
70114330f12Smrg	bluegene*)
702d87a3195Smrg		cpu=powerpc
703d87a3195Smrg		vendor=ibm
704d87a3195Smrg		basic_os=cnk
70595b296d0Smrg		;;
70695b296d0Smrg	decsystem10* | dec10*)
707d87a3195Smrg		cpu=pdp10
708d87a3195Smrg		vendor=dec
709d87a3195Smrg		basic_os=tops10
71095b296d0Smrg		;;
71195b296d0Smrg	decsystem20* | dec20*)
712d87a3195Smrg		cpu=pdp10
713d87a3195Smrg		vendor=dec
714d87a3195Smrg		basic_os=tops20
71595b296d0Smrg		;;
71695b296d0Smrg	delta | 3300 | motorola-3300 | motorola-delta \
71795b296d0Smrg	      | 3300-motorola | delta-motorola)
718d87a3195Smrg		cpu=m68k
719d87a3195Smrg		vendor=motorola
72095b296d0Smrg		;;
721d87a3195Smrg	dpx2*)
722d87a3195Smrg		cpu=m68k
723d87a3195Smrg		vendor=bull
724d87a3195Smrg		basic_os=sysv3
72595b296d0Smrg		;;
72695b296d0Smrg	encore | umax | mmax)
727d87a3195Smrg		cpu=ns32k
728d87a3195Smrg		vendor=encore
72995b296d0Smrg		;;
730d87a3195Smrg	elxsi)
731d87a3195Smrg		cpu=elxsi
732d87a3195Smrg		vendor=elxsi
733d87a3195Smrg		basic_os=${basic_os:-bsd}
73495b296d0Smrg		;;
73595b296d0Smrg	fx2800)
736d87a3195Smrg		cpu=i860
737d87a3195Smrg		vendor=alliant
73895b296d0Smrg		;;
73995b296d0Smrg	genix)
740d87a3195Smrg		cpu=ns32k
741d87a3195Smrg		vendor=ns
74295b296d0Smrg		;;
74395b296d0Smrg	h3050r* | hiux*)
744d87a3195Smrg		cpu=hppa1.1
745d87a3195Smrg		vendor=hitachi
746d87a3195Smrg		basic_os=hiuxwe2
74795b296d0Smrg		;;
74895b296d0Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749d87a3195Smrg		cpu=hppa1.0
750d87a3195Smrg		vendor=hp
75195b296d0Smrg		;;
75295b296d0Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
753d87a3195Smrg		cpu=m68000
754d87a3195Smrg		vendor=hp
75595b296d0Smrg		;;
75695b296d0Smrg	hp9k3[2-9][0-9])
757d87a3195Smrg		cpu=m68k
758d87a3195Smrg		vendor=hp
75995b296d0Smrg		;;
76095b296d0Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761d87a3195Smrg		cpu=hppa1.0
762d87a3195Smrg		vendor=hp
76395b296d0Smrg		;;
76495b296d0Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765d87a3195Smrg		cpu=hppa1.1
766d87a3195Smrg		vendor=hp
76795b296d0Smrg		;;
76895b296d0Smrg	hp9k78[0-9] | hp78[0-9])
76995b296d0Smrg		# FIXME: really hppa2.0-hp
770d87a3195Smrg		cpu=hppa1.1
771d87a3195Smrg		vendor=hp
77295b296d0Smrg		;;
77395b296d0Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
77495b296d0Smrg		# FIXME: really hppa2.0-hp
775d87a3195Smrg		cpu=hppa1.1
776d87a3195Smrg		vendor=hp
77795b296d0Smrg		;;
77895b296d0Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
779d87a3195Smrg		cpu=hppa1.1
780d87a3195Smrg		vendor=hp
78195b296d0Smrg		;;
78295b296d0Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783d87a3195Smrg		cpu=hppa1.0
784d87a3195Smrg		vendor=hp
78595b296d0Smrg		;;
78695b296d0Smrg	i*86v32)
787d87a3195Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788d87a3195Smrg		vendor=pc
789d87a3195Smrg		basic_os=sysv32
79095b296d0Smrg		;;
79195b296d0Smrg	i*86v4*)
792d87a3195Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793d87a3195Smrg		vendor=pc
794d87a3195Smrg		basic_os=sysv4
79595b296d0Smrg		;;
79695b296d0Smrg	i*86v)
797d87a3195Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798d87a3195Smrg		vendor=pc
799d87a3195Smrg		basic_os=sysv
80095b296d0Smrg		;;
80195b296d0Smrg	i*86sol2)
802d87a3195Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803d87a3195Smrg		vendor=pc
804d87a3195Smrg		basic_os=solaris2
80595b296d0Smrg		;;
806d87a3195Smrg	j90 | j90-cray)
807d87a3195Smrg		cpu=j90
808d87a3195Smrg		vendor=cray
809d87a3195Smrg		basic_os=${basic_os:-unicos}
81095b296d0Smrg		;;
81195b296d0Smrg	iris | iris4d)
812d87a3195Smrg		cpu=mips
813d87a3195Smrg		vendor=sgi
814d87a3195Smrg		case $basic_os in
815d87a3195Smrg		    irix*)
81695b296d0Smrg			;;
81795b296d0Smrg		    *)
818d87a3195Smrg			basic_os=irix4
81995b296d0Smrg			;;
82095b296d0Smrg		esac
82195b296d0Smrg		;;
82295b296d0Smrg	miniframe)
823d87a3195Smrg		cpu=m68000
824d87a3195Smrg		vendor=convergent
82595b296d0Smrg		;;
826d87a3195Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827d87a3195Smrg		cpu=m68k
828d87a3195Smrg		vendor=atari
829d87a3195Smrg		basic_os=mint
83095b296d0Smrg		;;
83195b296d0Smrg	news-3600 | risc-news)
832d87a3195Smrg		cpu=mips
833d87a3195Smrg		vendor=sony
834d87a3195Smrg		basic_os=newsos
835d87a3195Smrg		;;
836d87a3195Smrg	next | m*-next)
837d87a3195Smrg		cpu=m68k
838d87a3195Smrg		vendor=next
839d87a3195Smrg		case $basic_os in
840d87a3195Smrg		    openstep*)
841d87a3195Smrg		        ;;
842d87a3195Smrg		    nextstep*)
84395b296d0Smrg			;;
844d87a3195Smrg		    ns2*)
845d87a3195Smrg		      basic_os=nextstep2
84695b296d0Smrg			;;
84795b296d0Smrg		    *)
848d87a3195Smrg		      basic_os=nextstep3
84995b296d0Smrg			;;
85095b296d0Smrg		esac
85195b296d0Smrg		;;
85295b296d0Smrg	np1)
853d87a3195Smrg		cpu=np1
854d87a3195Smrg		vendor=gould
85595b296d0Smrg		;;
85695b296d0Smrg	op50n-* | op60c-*)
857d87a3195Smrg		cpu=hppa1.1
858d87a3195Smrg		vendor=oki
859d87a3195Smrg		basic_os=proelf
86095b296d0Smrg		;;
86195b296d0Smrg	pa-hitachi)
862d87a3195Smrg		cpu=hppa1.1
863d87a3195Smrg		vendor=hitachi
864d87a3195Smrg		basic_os=hiuxwe2
865ff89ac2bSmrg		;;
86695b296d0Smrg	pbd)
867d87a3195Smrg		cpu=sparc
868d87a3195Smrg		vendor=tti
86995b296d0Smrg		;;
87095b296d0Smrg	pbb)
871d87a3195Smrg		cpu=m68k
872d87a3195Smrg		vendor=tti
87395b296d0Smrg		;;
874d87a3195Smrg	pc532)
875d87a3195Smrg		cpu=ns32k
876d87a3195Smrg		vendor=pc532
87795b296d0Smrg		;;
87895b296d0Smrg	pn)
879d87a3195Smrg		cpu=pn
880d87a3195Smrg		vendor=gould
88195b296d0Smrg		;;
882d87a3195Smrg	power)
883d87a3195Smrg		cpu=power
884d87a3195Smrg		vendor=ibm
88595b296d0Smrg		;;
88695b296d0Smrg	ps2)
887d87a3195Smrg		cpu=i386
888d87a3195Smrg		vendor=ibm
88995b296d0Smrg		;;
89095b296d0Smrg	rm[46]00)
891d87a3195Smrg		cpu=mips
892d87a3195Smrg		vendor=siemens
89395b296d0Smrg		;;
89495b296d0Smrg	rtpc | rtpc-*)
895d87a3195Smrg		cpu=romp
896d87a3195Smrg		vendor=ibm
89795b296d0Smrg		;;
898d87a3195Smrg	sde)
899d87a3195Smrg		cpu=mipsisa32
900d87a3195Smrg		vendor=sde
901d87a3195Smrg		basic_os=${basic_os:-elf}
90295b296d0Smrg		;;
903d87a3195Smrg	simso-wrs)
904d87a3195Smrg		cpu=sparclite
905d87a3195Smrg		vendor=wrs
906d87a3195Smrg		basic_os=vxworks
90795b296d0Smrg		;;
908d87a3195Smrg	tower | tower-32)
909d87a3195Smrg		cpu=m68k
910d87a3195Smrg		vendor=ncr
911ff89ac2bSmrg		;;
912d87a3195Smrg	vpp*|vx|vx-*)
913d87a3195Smrg		cpu=f301
914d87a3195Smrg		vendor=fujitsu
91595b296d0Smrg		;;
916d87a3195Smrg	w65)
917d87a3195Smrg		cpu=w65
918d87a3195Smrg		vendor=wdc
91995b296d0Smrg		;;
920d87a3195Smrg	w89k-*)
921d87a3195Smrg		cpu=hppa1.1
922d87a3195Smrg		vendor=winbond
923d87a3195Smrg		basic_os=proelf
92495b296d0Smrg		;;
925d87a3195Smrg	none)
926d87a3195Smrg		cpu=none
927d87a3195Smrg		vendor=none
928ff89ac2bSmrg		;;
929d87a3195Smrg	leon|leon[3-9])
930d87a3195Smrg		cpu=sparc
931d87a3195Smrg		vendor=$basic_machine
93295b296d0Smrg		;;
933d87a3195Smrg	leon-*|leon[3-9]-*)
934d87a3195Smrg		cpu=sparc
935d87a3195Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93695b296d0Smrg		;;
937d87a3195Smrg
938d87a3195Smrg	*-*)
939d87a3195Smrg		# shellcheck disable=SC2162
940d87a3195Smrg		saved_IFS=$IFS
941d87a3195Smrg		IFS="-" read cpu vendor <<EOF
942d87a3195Smrg$basic_machine
943d87a3195SmrgEOF
944d87a3195Smrg		IFS=$saved_IFS
94595b296d0Smrg		;;
946d87a3195Smrg	# We use `pc' rather than `unknown'
947d87a3195Smrg	# because (1) that's what they normally are, and
948d87a3195Smrg	# (2) the word "unknown" tends to confuse beginning users.
949d87a3195Smrg	i*86 | x86_64)
950d87a3195Smrg		cpu=$basic_machine
951d87a3195Smrg		vendor=pc
95295b296d0Smrg		;;
953d87a3195Smrg	# These rules are duplicated from below for sake of the special case above;
954d87a3195Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
955d87a3195Smrg	pc98)
956d87a3195Smrg		cpu=i386
957d87a3195Smrg		vendor=pc
95895b296d0Smrg		;;
959d87a3195Smrg	x64 | amd64)
960d87a3195Smrg		cpu=x86_64
961d87a3195Smrg		vendor=pc
96295b296d0Smrg		;;
963d87a3195Smrg	# Recognize the basic CPU types without company name.
964d87a3195Smrg	*)
965d87a3195Smrg		cpu=$basic_machine
966d87a3195Smrg		vendor=unknown
967eca46af7Smrg		;;
968d87a3195Smrgesac
969d87a3195Smrg
970d87a3195Smrgunset -v basic_machine
971d87a3195Smrg
972d87a3195Smrg# Decode basic machines in the full and proper CPU-Company form.
973d87a3195Smrgcase $cpu-$vendor in
974d87a3195Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975d87a3195Smrg	# some cases the only manufacturer, in others, it is the most popular.
976d87a3195Smrg	craynv-unknown)
977d87a3195Smrg		vendor=cray
978d87a3195Smrg		basic_os=${basic_os:-unicosmp}
97995b296d0Smrg		;;
980d87a3195Smrg	c90-unknown | c90-cray)
981d87a3195Smrg		vendor=cray
982d87a3195Smrg		basic_os=${Basic_os:-unicos}
98395b296d0Smrg		;;
984d87a3195Smrg	fx80-unknown)
985d87a3195Smrg		vendor=alliant
98695b296d0Smrg		;;
987d87a3195Smrg	romp-unknown)
988d87a3195Smrg		vendor=ibm
98995b296d0Smrg		;;
990d87a3195Smrg	mmix-unknown)
991d87a3195Smrg		vendor=knuth
99295b296d0Smrg		;;
993d87a3195Smrg	microblaze-unknown | microblazeel-unknown)
994d87a3195Smrg		vendor=xilinx
99595b296d0Smrg		;;
996d87a3195Smrg	rs6000-unknown)
997d87a3195Smrg		vendor=ibm
99895b296d0Smrg		;;
999d87a3195Smrg	vax-unknown)
1000d87a3195Smrg		vendor=dec
100195b296d0Smrg		;;
1002d87a3195Smrg	pdp11-unknown)
1003d87a3195Smrg		vendor=dec
100495b296d0Smrg		;;
1005d87a3195Smrg	we32k-unknown)
1006d87a3195Smrg		vendor=att
100795b296d0Smrg		;;
1008d87a3195Smrg	cydra-unknown)
1009d87a3195Smrg		vendor=cydrome
101095b296d0Smrg		;;
1011d87a3195Smrg	i370-ibm*)
1012d87a3195Smrg		vendor=ibm
101395b296d0Smrg		;;
1014d87a3195Smrg	orion-unknown)
1015d87a3195Smrg		vendor=highlevel
101695b296d0Smrg		;;
1017d87a3195Smrg	xps-unknown | xps100-unknown)
1018d87a3195Smrg		cpu=xps100
1019d87a3195Smrg		vendor=honeywell
102095b296d0Smrg		;;
1021d87a3195Smrg
1022d87a3195Smrg	# Here we normalize CPU types with a missing or matching vendor
1023d87a3195Smrg	dpx20-unknown | dpx20-bull)
1024d87a3195Smrg		cpu=rs6000
1025d87a3195Smrg		vendor=bull
1026d87a3195Smrg		basic_os=${basic_os:-bosx}
102795b296d0Smrg		;;
1028d87a3195Smrg
1029d87a3195Smrg	# Here we normalize CPU types irrespective of the vendor
1030d87a3195Smrg	amd64-*)
1031d87a3195Smrg		cpu=x86_64
1032ff89ac2bSmrg		;;
1033d87a3195Smrg	blackfin-*)
1034d87a3195Smrg		cpu=bfin
1035d87a3195Smrg		basic_os=linux
103695b296d0Smrg		;;
1037d87a3195Smrg	c54x-*)
1038d87a3195Smrg		cpu=tic54x
103995b296d0Smrg		;;
1040d87a3195Smrg	c55x-*)
1041d87a3195Smrg		cpu=tic55x
104295b296d0Smrg		;;
1043d87a3195Smrg	c6x-*)
1044d87a3195Smrg		cpu=tic6x
104595b296d0Smrg		;;
1046d87a3195Smrg	e500v[12]-*)
1047d87a3195Smrg		cpu=powerpc
1048d87a3195Smrg		basic_os=${basic_os}"spe"
104995b296d0Smrg		;;
1050d87a3195Smrg	mips3*-*)
1051d87a3195Smrg		cpu=mips64
105295b296d0Smrg		;;
1053d87a3195Smrg	ms1-*)
1054d87a3195Smrg		cpu=mt
105595b296d0Smrg		;;
1056d87a3195Smrg	m68knommu-*)
1057d87a3195Smrg		cpu=m68k
1058d87a3195Smrg		basic_os=linux
105995b296d0Smrg		;;
1060d87a3195Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1061d87a3195Smrg		cpu=s12z
106295b296d0Smrg		;;
1063d87a3195Smrg	openrisc-*)
1064d87a3195Smrg		cpu=or32
106595b296d0Smrg		;;
1066d87a3195Smrg	parisc-*)
1067d87a3195Smrg		cpu=hppa
1068d87a3195Smrg		basic_os=linux
106995b296d0Smrg		;;
1070d87a3195Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1071d87a3195Smrg		cpu=i586
107295b296d0Smrg		;;
1073d87a3195Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1074d87a3195Smrg		cpu=i686
107595b296d0Smrg		;;
1076d87a3195Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1077d87a3195Smrg		cpu=i686
107895b296d0Smrg		;;
1079d87a3195Smrg	pentium4-*)
1080d87a3195Smrg		cpu=i786
108195b296d0Smrg		;;
1082d87a3195Smrg	pc98-*)
1083d87a3195Smrg		cpu=i386
108495b296d0Smrg		;;
1085d87a3195Smrg	ppc-* | ppcbe-*)
1086d87a3195Smrg		cpu=powerpc
108795b296d0Smrg		;;
1088d87a3195Smrg	ppcle-* | powerpclittle-*)
1089d87a3195Smrg		cpu=powerpcle
109095b296d0Smrg		;;
1091d87a3195Smrg	ppc64-*)
1092d87a3195Smrg		cpu=powerpc64
1093eca46af7Smrg		;;
1094d87a3195Smrg	ppc64le-* | powerpc64little-*)
1095d87a3195Smrg		cpu=powerpc64le
109695b296d0Smrg		;;
1097d87a3195Smrg	sb1-*)
1098d87a3195Smrg		cpu=mipsisa64sb1
109995b296d0Smrg		;;
1100d87a3195Smrg	sb1el-*)
1101d87a3195Smrg		cpu=mipsisa64sb1el
110214330f12Smrg		;;
1103d87a3195Smrg	sh5e[lb]-*)
1104d87a3195Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
110595b296d0Smrg		;;
1106d87a3195Smrg	spur-*)
1107d87a3195Smrg		cpu=spur
110895b296d0Smrg		;;
1109d87a3195Smrg	strongarm-* | thumb-*)
1110d87a3195Smrg		cpu=arm
111195b296d0Smrg		;;
1112d87a3195Smrg	tx39-*)
1113d87a3195Smrg		cpu=mipstx39
111495b296d0Smrg		;;
1115d87a3195Smrg	tx39el-*)
1116d87a3195Smrg		cpu=mipstx39el
111795b296d0Smrg		;;
1118d87a3195Smrg	x64-*)
1119d87a3195Smrg		cpu=x86_64
112095b296d0Smrg		;;
1121d87a3195Smrg	xscale-* | xscalee[bl]-*)
1122d87a3195Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112395b296d0Smrg		;;
1124d87a3195Smrg	arm64-*)
1125d87a3195Smrg		cpu=aarch64
112695b296d0Smrg		;;
1127d87a3195Smrg
1128d87a3195Smrg	# Recognize the canonical CPU Types that limit and/or modify the
1129d87a3195Smrg	# company names they are paired with.
1130d87a3195Smrg	cr16-*)
1131d87a3195Smrg		basic_os=${basic_os:-elf}
113295b296d0Smrg		;;
1133d87a3195Smrg	crisv32-* | etraxfs*-*)
1134d87a3195Smrg		cpu=crisv32
1135d87a3195Smrg		vendor=axis
113695b296d0Smrg		;;
1137d87a3195Smrg	cris-* | etrax*-*)
1138d87a3195Smrg		cpu=cris
1139d87a3195Smrg		vendor=axis
114095b296d0Smrg		;;
1141d87a3195Smrg	crx-*)
1142d87a3195Smrg		basic_os=${basic_os:-elf}
114395b296d0Smrg		;;
1144d87a3195Smrg	neo-tandem)
1145d87a3195Smrg		cpu=neo
1146d87a3195Smrg		vendor=tandem
114795b296d0Smrg		;;
1148d87a3195Smrg	nse-tandem)
1149d87a3195Smrg		cpu=nse
1150d87a3195Smrg		vendor=tandem
115195b296d0Smrg		;;
1152d87a3195Smrg	nsr-tandem)
1153d87a3195Smrg		cpu=nsr
1154d87a3195Smrg		vendor=tandem
115595b296d0Smrg		;;
1156d87a3195Smrg	nsv-tandem)
1157d87a3195Smrg		cpu=nsv
1158d87a3195Smrg		vendor=tandem
115995b296d0Smrg		;;
1160d87a3195Smrg	nsx-tandem)
1161d87a3195Smrg		cpu=nsx
1162d87a3195Smrg		vendor=tandem
116395b296d0Smrg		;;
1164d87a3195Smrg	mipsallegrexel-sony)
1165d87a3195Smrg		cpu=mipsallegrexel
1166d87a3195Smrg		vendor=sony
116795b296d0Smrg		;;
1168d87a3195Smrg	tile*-*)
1169d87a3195Smrg		basic_os=${basic_os:-linux-gnu}
117095b296d0Smrg		;;
1171d87a3195Smrg
117295b296d0Smrg	*)
1173d87a3195Smrg		# Recognize the canonical CPU types that are allowed with any
1174d87a3195Smrg		# company name.
1175d87a3195Smrg		case $cpu in
1176d87a3195Smrg			1750a | 580 \
1177d87a3195Smrg			| a29k \
1178d87a3195Smrg			| aarch64 | aarch64_be \
1179d87a3195Smrg			| abacus \
1180d87a3195Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1181d87a3195Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1182d87a3195Smrg			| alphapca5[67] | alpha64pca5[67] \
1183d87a3195Smrg			| am33_2.0 \
1184d87a3195Smrg			| amdgcn \
1185d87a3195Smrg			| arc | arceb | arc32 | arc64 \
1186d87a3195Smrg			| arm | arm[lb]e | arme[lb] | armv* \
1187d87a3195Smrg			| avr | avr32 \
1188d87a3195Smrg			| asmjs \
1189d87a3195Smrg			| ba \
1190d87a3195Smrg			| be32 | be64 \
1191d87a3195Smrg			| bfin | bpf | bs2000 \
1192d87a3195Smrg			| c[123]* | c30 | [cjt]90 | c4x \
1193d87a3195Smrg			| c8051 | clipper | craynv | csky | cydra \
1194d87a3195Smrg			| d10v | d30v | dlx | dsp16xx \
1195d87a3195Smrg			| e2k | elxsi | epiphany \
1196d87a3195Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1197d87a3195Smrg			| h8300 | h8500 \
1198d87a3195Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1199d87a3195Smrg			| hexagon \
1200d87a3195Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1201d87a3195Smrg			| ip2k | iq2000 \
1202d87a3195Smrg			| k1om \
1203d87a3195Smrg			| le32 | le64 \
1204d87a3195Smrg			| lm32 \
1205d87a3195Smrg			| loongarch32 | loongarch64 | loongarchx32 \
1206d87a3195Smrg			| m32c | m32r | m32rle \
1207d87a3195Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1208d87a3195Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1209d87a3195Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1210d87a3195Smrg			| microblaze | microblazeel \
1211d87a3195Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
1212d87a3195Smrg			| mips16 \
1213d87a3195Smrg			| mips64 | mips64eb | mips64el \
1214d87a3195Smrg			| mips64octeon | mips64octeonel \
1215d87a3195Smrg			| mips64orion | mips64orionel \
1216d87a3195Smrg			| mips64r5900 | mips64r5900el \
1217d87a3195Smrg			| mips64vr | mips64vrel \
1218d87a3195Smrg			| mips64vr4100 | mips64vr4100el \
1219d87a3195Smrg			| mips64vr4300 | mips64vr4300el \
1220d87a3195Smrg			| mips64vr5000 | mips64vr5000el \
1221d87a3195Smrg			| mips64vr5900 | mips64vr5900el \
1222d87a3195Smrg			| mipsisa32 | mipsisa32el \
1223d87a3195Smrg			| mipsisa32r2 | mipsisa32r2el \
1224d87a3195Smrg			| mipsisa32r3 | mipsisa32r3el \
1225d87a3195Smrg			| mipsisa32r5 | mipsisa32r5el \
1226d87a3195Smrg			| mipsisa32r6 | mipsisa32r6el \
1227d87a3195Smrg			| mipsisa64 | mipsisa64el \
1228d87a3195Smrg			| mipsisa64r2 | mipsisa64r2el \
1229d87a3195Smrg			| mipsisa64r3 | mipsisa64r3el \
1230d87a3195Smrg			| mipsisa64r5 | mipsisa64r5el \
1231d87a3195Smrg			| mipsisa64r6 | mipsisa64r6el \
1232d87a3195Smrg			| mipsisa64sb1 | mipsisa64sb1el \
1233d87a3195Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
1234d87a3195Smrg			| mipsr5900 | mipsr5900el \
1235d87a3195Smrg			| mipstx39 | mipstx39el \
1236d87a3195Smrg			| mmix \
1237d87a3195Smrg			| mn10200 | mn10300 \
1238d87a3195Smrg			| moxie \
1239d87a3195Smrg			| mt \
1240d87a3195Smrg			| msp430 \
1241d87a3195Smrg			| nds32 | nds32le | nds32be \
1242d87a3195Smrg			| nfp \
1243d87a3195Smrg			| nios | nios2 | nios2eb | nios2el \
1244d87a3195Smrg			| none | np1 | ns16k | ns32k | nvptx \
1245d87a3195Smrg			| open8 \
1246d87a3195Smrg			| or1k* \
1247d87a3195Smrg			| or32 \
1248d87a3195Smrg			| orion \
1249d87a3195Smrg			| picochip \
1250d87a3195Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
1251d87a3195Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1252d87a3195Smrg			| pru \
1253d87a3195Smrg			| pyramid \
1254d87a3195Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1255d87a3195Smrg			| rl78 | romp | rs6000 | rx \
1256d87a3195Smrg			| s390 | s390x \
1257d87a3195Smrg			| score \
1258d87a3195Smrg			| sh | shl \
1259d87a3195Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1260d87a3195Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1261d87a3195Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1262d87a3195Smrg			| sparclite \
1263d87a3195Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1264d87a3195Smrg			| spu \
1265d87a3195Smrg			| tahoe \
1266d87a3195Smrg			| thumbv7* \
1267d87a3195Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1268d87a3195Smrg			| tron \
1269d87a3195Smrg			| ubicom32 \
1270d87a3195Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1271d87a3195Smrg			| vax \
1272d87a3195Smrg			| visium \
1273d87a3195Smrg			| w65 \
1274d87a3195Smrg			| wasm32 | wasm64 \
1275d87a3195Smrg			| we32k \
1276d87a3195Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
1277d87a3195Smrg			| xstormy16 | xtensa* \
1278d87a3195Smrg			| ymp \
1279d87a3195Smrg			| z8k | z80)
1280d87a3195Smrg				;;
1281d87a3195Smrg
1282d87a3195Smrg			*)
1283d87a3195Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1284d87a3195Smrg				exit 1
1285d87a3195Smrg				;;
1286d87a3195Smrg		esac
128795b296d0Smrg		;;
128895b296d0Smrgesac
128995b296d0Smrg
129095b296d0Smrg# Here we canonicalize certain aliases for manufacturers.
1291d87a3195Smrgcase $vendor in
1292d87a3195Smrg	digital*)
1293d87a3195Smrg		vendor=dec
129495b296d0Smrg		;;
1295d87a3195Smrg	commodore*)
1296d87a3195Smrg		vendor=cbm
129795b296d0Smrg		;;
129895b296d0Smrg	*)
129995b296d0Smrg		;;
130095b296d0Smrgesac
130195b296d0Smrg
130295b296d0Smrg# Decode manufacturer-specific aliases for certain operating systems.
130395b296d0Smrg
1304d87a3195Smrgif test x$basic_os != x
130595b296d0Smrgthen
1306d87a3195Smrg
1307d87a3195Smrg# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1308d87a3195Smrg# set os.
1309d87a3195Smrgcase $basic_os in
1310d87a3195Smrg	gnu/linux*)
1311d87a3195Smrg		kernel=linux
1312d87a3195Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1313d87a3195Smrg		;;
1314d87a3195Smrg	os2-emx)
1315d87a3195Smrg		kernel=os2
1316d87a3195Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1317d87a3195Smrg		;;
1318d87a3195Smrg	nto-qnx*)
1319d87a3195Smrg		kernel=nto
1320d87a3195Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1321d87a3195Smrg		;;
1322d87a3195Smrg	*-*)
1323d87a3195Smrg		# shellcheck disable=SC2162
1324d87a3195Smrg		saved_IFS=$IFS
1325d87a3195Smrg		IFS="-" read kernel os <<EOF
1326d87a3195Smrg$basic_os
1327d87a3195SmrgEOF
1328d87a3195Smrg		IFS=$saved_IFS
1329d87a3195Smrg		;;
1330d87a3195Smrg	# Default OS when just kernel was specified
1331d87a3195Smrg	nto*)
1332d87a3195Smrg		kernel=nto
1333d87a3195Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1334d87a3195Smrg		;;
1335d87a3195Smrg	linux*)
1336d87a3195Smrg		kernel=linux
1337d87a3195Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
133814330f12Smrg		;;
1339d87a3195Smrg	*)
1340d87a3195Smrg		kernel=
1341d87a3195Smrg		os=$basic_os
134295b296d0Smrg		;;
1343d87a3195Smrgesac
1344d87a3195Smrg
1345d87a3195Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1346d87a3195Smrg# etc.)
1347d87a3195Smrgcase $os in
1348d87a3195Smrg	# First match some system type aliases that might get confused
1349d87a3195Smrg	# with valid system types.
1350d87a3195Smrg	# solaris* is a basic system type, with this one exception.
1351d87a3195Smrg	auroraux)
1352d87a3195Smrg		os=auroraux
135395b296d0Smrg		;;
1354d87a3195Smrg	bluegene*)
1355d87a3195Smrg		os=cnk
135695b296d0Smrg		;;
1357d87a3195Smrg	solaris1 | solaris1.*)
1358d87a3195Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
135995b296d0Smrg		;;
1360d87a3195Smrg	solaris)
1361d87a3195Smrg		os=solaris2
136295b296d0Smrg		;;
1363d87a3195Smrg	unixware*)
1364d87a3195Smrg		os=sysv4.2uw
136595b296d0Smrg		;;
1366d87a3195Smrg	# es1800 is here to avoid being matched by es* (a different OS)
1367d87a3195Smrg	es1800*)
1368d87a3195Smrg		os=ose
136995b296d0Smrg		;;
1370d87a3195Smrg	# Some version numbers need modification
1371d87a3195Smrg	chorusos*)
1372d87a3195Smrg		os=chorusos
137395b296d0Smrg		;;
1374d87a3195Smrg	isc)
1375d87a3195Smrg		os=isc2.2
137695b296d0Smrg		;;
1377d87a3195Smrg	sco6)
1378d87a3195Smrg		os=sco5v6
137995b296d0Smrg		;;
1380d87a3195Smrg	sco5)
1381d87a3195Smrg		os=sco3.2v5
138295b296d0Smrg		;;
1383d87a3195Smrg	sco4)
1384d87a3195Smrg		os=sco3.2v4
138595b296d0Smrg		;;
1386d87a3195Smrg	sco3.2.[4-9]*)
1387d87a3195Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
138895b296d0Smrg		;;
1389d87a3195Smrg	sco*v* | scout)
1390d87a3195Smrg		# Don't match below
139195b296d0Smrg		;;
1392d87a3195Smrg	sco*)
1393d87a3195Smrg		os=sco3.2v2
139495b296d0Smrg		;;
1395d87a3195Smrg	psos*)
1396d87a3195Smrg		os=psos
139795b296d0Smrg		;;
1398d87a3195Smrg	qnx*)
1399d87a3195Smrg		os=qnx
140095b296d0Smrg		;;
1401d87a3195Smrg	hiux*)
1402d87a3195Smrg		os=hiuxwe2
140395b296d0Smrg		;;
1404d87a3195Smrg	lynx*178)
1405d87a3195Smrg		os=lynxos178
140695b296d0Smrg		;;
1407d87a3195Smrg	lynx*5)
1408d87a3195Smrg		os=lynxos5
140995b296d0Smrg		;;
1410d87a3195Smrg	lynxos*)
1411d87a3195Smrg		# don't get caught up in next wildcard
141295b296d0Smrg		;;
1413d87a3195Smrg	lynx*)
1414d87a3195Smrg		os=lynxos
141595b296d0Smrg		;;
1416d87a3195Smrg	mac[0-9]*)
1417d87a3195Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
141895b296d0Smrg		;;
1419d87a3195Smrg	opened*)
1420d87a3195Smrg		os=openedition
142195b296d0Smrg		;;
1422d87a3195Smrg	os400*)
1423d87a3195Smrg		os=os400
142495b296d0Smrg		;;
1425d87a3195Smrg	sunos5*)
1426d87a3195Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
142795b296d0Smrg		;;
1428d87a3195Smrg	sunos6*)
1429d87a3195Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
143095b296d0Smrg		;;
1431d87a3195Smrg	wince*)
1432d87a3195Smrg		os=wince
143395b296d0Smrg		;;
1434d87a3195Smrg	utek*)
1435d87a3195Smrg		os=bsd
143695b296d0Smrg		;;
1437d87a3195Smrg	dynix*)
1438d87a3195Smrg		os=bsd
1439d87a3195Smrg		;;
1440d87a3195Smrg	acis*)
1441d87a3195Smrg		os=aos
144295b296d0Smrg		;;
1443d87a3195Smrg	atheos*)
1444d87a3195Smrg		os=atheos
144595b296d0Smrg		;;
1446d87a3195Smrg	syllable*)
1447d87a3195Smrg		os=syllable
144895b296d0Smrg		;;
1449d87a3195Smrg	386bsd)
1450d87a3195Smrg		os=bsd
145195b296d0Smrg		;;
1452d87a3195Smrg	ctix* | uts*)
1453d87a3195Smrg		os=sysv
145495b296d0Smrg		;;
1455d87a3195Smrg	nova*)
1456d87a3195Smrg		os=rtmk-nova
145795b296d0Smrg		;;
1458d87a3195Smrg	ns2)
1459d87a3195Smrg		os=nextstep2
146095b296d0Smrg		;;
1461d87a3195Smrg	# Preserve the version number of sinix5.
1462d87a3195Smrg	sinix5.*)
1463d87a3195Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
146495b296d0Smrg		;;
1465d87a3195Smrg	sinix*)
1466d87a3195Smrg		os=sysv4
146795b296d0Smrg		;;
1468d87a3195Smrg	tpf*)
1469d87a3195Smrg		os=tpf
147095b296d0Smrg		;;
1471d87a3195Smrg	triton*)
1472d87a3195Smrg		os=sysv3
147395b296d0Smrg		;;
1474d87a3195Smrg	oss*)
1475d87a3195Smrg		os=sysv3
147695b296d0Smrg		;;
1477d87a3195Smrg	svr4*)
1478d87a3195Smrg		os=sysv4
147995b296d0Smrg		;;
1480d87a3195Smrg	svr3)
1481d87a3195Smrg		os=sysv3
148295b296d0Smrg		;;
1483d87a3195Smrg	sysvr4)
1484d87a3195Smrg		os=sysv4
148595b296d0Smrg		;;
1486d87a3195Smrg	ose*)
1487d87a3195Smrg		os=ose
148814330f12Smrg		;;
1489d87a3195Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1490d87a3195Smrg		os=mint
1491eca46af7Smrg		;;
1492d87a3195Smrg	dicos*)
1493d87a3195Smrg		os=dicos
149489b0dc75Smrg		;;
1495d87a3195Smrg	pikeos*)
1496d87a3195Smrg		# Until real need of OS specific support for
1497d87a3195Smrg		# particular features comes up, bare metal
1498d87a3195Smrg		# configurations are quite functional.
1499d87a3195Smrg		case $cpu in
1500d87a3195Smrg		    arm*)
1501d87a3195Smrg			os=eabi
1502d87a3195Smrg			;;
1503d87a3195Smrg		    *)
1504d87a3195Smrg			os=elf
1505d87a3195Smrg			;;
1506d87a3195Smrg		esac
150795b296d0Smrg		;;
150895b296d0Smrg	*)
1509d87a3195Smrg		# No normalization, but not necessarily accepted, that comes below.
151095b296d0Smrg		;;
151195b296d0Smrgesac
1512d87a3195Smrg
151395b296d0Smrgelse
151495b296d0Smrg
151595b296d0Smrg# Here we handle the default operating systems that come with various machines.
151695b296d0Smrg# The value should be what the vendor currently ships out the door with their
151795b296d0Smrg# machine or put another way, the most popular os provided with the machine.
151895b296d0Smrg
151995b296d0Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
152095b296d0Smrg# "-sun"), then you have to tell the case statement up towards the top
152195b296d0Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
152295b296d0Smrg# will signal an error saying that MANUFACTURER isn't an operating
152395b296d0Smrg# system, and we'll never get to this point.
152495b296d0Smrg
1525d87a3195Smrgkernel=
1526d87a3195Smrgcase $cpu-$vendor in
1527eca46af7Smrg	score-*)
1528d87a3195Smrg		os=elf
1529ff89ac2bSmrg		;;
1530eca46af7Smrg	spu-*)
1531d87a3195Smrg		os=elf
153295b296d0Smrg		;;
153395b296d0Smrg	*-acorn)
1534d87a3195Smrg		os=riscix1.2
153595b296d0Smrg		;;
153695b296d0Smrg	arm*-rebel)
1537d87a3195Smrg		kernel=linux
1538d87a3195Smrg		os=gnu
153995b296d0Smrg		;;
154095b296d0Smrg	arm*-semi)
1541d87a3195Smrg		os=aout
154295b296d0Smrg		;;
1543eca46af7Smrg	c4x-* | tic4x-*)
1544d87a3195Smrg		os=coff
1545eca46af7Smrg		;;
1546eca46af7Smrg	c8051-*)
1547d87a3195Smrg		os=elf
1548d87a3195Smrg		;;
1549d87a3195Smrg	clipper-intergraph)
1550d87a3195Smrg		os=clix
1551eca46af7Smrg		;;
1552eca46af7Smrg	hexagon-*)
1553d87a3195Smrg		os=elf
155495b296d0Smrg		;;
155514330f12Smrg	tic54x-*)
1556d87a3195Smrg		os=coff
155714330f12Smrg		;;
155814330f12Smrg	tic55x-*)
1559d87a3195Smrg		os=coff
156014330f12Smrg		;;
156114330f12Smrg	tic6x-*)
1562d87a3195Smrg		os=coff
156314330f12Smrg		;;
156495b296d0Smrg	# This must come before the *-dec entry.
156595b296d0Smrg	pdp10-*)
1566d87a3195Smrg		os=tops20
156795b296d0Smrg		;;
156895b296d0Smrg	pdp11-*)
1569d87a3195Smrg		os=none
157095b296d0Smrg		;;
157195b296d0Smrg	*-dec | vax-*)
1572d87a3195Smrg		os=ultrix4.2
157395b296d0Smrg		;;
157495b296d0Smrg	m68*-apollo)
1575d87a3195Smrg		os=domain
157695b296d0Smrg		;;
157795b296d0Smrg	i386-sun)
1578d87a3195Smrg		os=sunos4.0.2
157995b296d0Smrg		;;
158095b296d0Smrg	m68000-sun)
1581d87a3195Smrg		os=sunos3
158295b296d0Smrg		;;
158395b296d0Smrg	m68*-cisco)
1584d87a3195Smrg		os=aout
158595b296d0Smrg		;;
1586eca46af7Smrg	mep-*)
1587d87a3195Smrg		os=elf
1588ff89ac2bSmrg		;;
158995b296d0Smrg	mips*-cisco)
1590d87a3195Smrg		os=elf
159195b296d0Smrg		;;
159295b296d0Smrg	mips*-*)
1593d87a3195Smrg		os=elf
159495b296d0Smrg		;;
159595b296d0Smrg	or32-*)
1596d87a3195Smrg		os=coff
159795b296d0Smrg		;;
159895b296d0Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
1599d87a3195Smrg		os=sysv3
160095b296d0Smrg		;;
160195b296d0Smrg	sparc-* | *-sun)
1602d87a3195Smrg		os=sunos4.1.1
160395b296d0Smrg		;;
1604d87a3195Smrg	pru-*)
1605d87a3195Smrg		os=elf
160695b296d0Smrg		;;
1607d87a3195Smrg	*-be)
1608d87a3195Smrg		os=beos
160995b296d0Smrg		;;
161095b296d0Smrg	*-ibm)
1611d87a3195Smrg		os=aix
161295b296d0Smrg		;;
1613eca46af7Smrg	*-knuth)
1614d87a3195Smrg		os=mmixware
161595b296d0Smrg		;;
161695b296d0Smrg	*-wec)
1617d87a3195Smrg		os=proelf
161895b296d0Smrg		;;
161995b296d0Smrg	*-winbond)
1620d87a3195Smrg		os=proelf
162195b296d0Smrg		;;
162295b296d0Smrg	*-oki)
1623d87a3195Smrg		os=proelf
162495b296d0Smrg		;;
162595b296d0Smrg	*-hp)
1626d87a3195Smrg		os=hpux
162795b296d0Smrg		;;
162895b296d0Smrg	*-hitachi)
1629d87a3195Smrg		os=hiux
163095b296d0Smrg		;;
163195b296d0Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1632d87a3195Smrg		os=sysv
163395b296d0Smrg		;;
163495b296d0Smrg	*-cbm)
1635d87a3195Smrg		os=amigaos
163695b296d0Smrg		;;
163795b296d0Smrg	*-dg)
1638d87a3195Smrg		os=dgux
163995b296d0Smrg		;;
164095b296d0Smrg	*-dolphin)
1641d87a3195Smrg		os=sysv3
164295b296d0Smrg		;;
164395b296d0Smrg	m68k-ccur)
1644d87a3195Smrg		os=rtu
164595b296d0Smrg		;;
164695b296d0Smrg	m88k-omron*)
1647d87a3195Smrg		os=luna
164895b296d0Smrg		;;
1649d87a3195Smrg	*-next)
1650d87a3195Smrg		os=nextstep
165195b296d0Smrg		;;
165295b296d0Smrg	*-sequent)
1653d87a3195Smrg		os=ptx
165495b296d0Smrg		;;
165595b296d0Smrg	*-crds)
1656d87a3195Smrg		os=unos
165795b296d0Smrg		;;
165895b296d0Smrg	*-ns)
1659d87a3195Smrg		os=genix
166095b296d0Smrg		;;
166195b296d0Smrg	i370-*)
1662d87a3195Smrg		os=mvs
166395b296d0Smrg		;;
166495b296d0Smrg	*-gould)
1665d87a3195Smrg		os=sysv
166695b296d0Smrg		;;
166795b296d0Smrg	*-highlevel)
1668d87a3195Smrg		os=bsd
166995b296d0Smrg		;;
167095b296d0Smrg	*-encore)
1671d87a3195Smrg		os=bsd
167295b296d0Smrg		;;
167395b296d0Smrg	*-sgi)
1674d87a3195Smrg		os=irix
167595b296d0Smrg		;;
167695b296d0Smrg	*-siemens)
1677d87a3195Smrg		os=sysv4
167895b296d0Smrg		;;
167995b296d0Smrg	*-masscomp)
1680d87a3195Smrg		os=rtu
168195b296d0Smrg		;;
168295b296d0Smrg	f30[01]-fujitsu | f700-fujitsu)
1683d87a3195Smrg		os=uxpv
168495b296d0Smrg		;;
168595b296d0Smrg	*-rom68k)
1686d87a3195Smrg		os=coff
168795b296d0Smrg		;;
168895b296d0Smrg	*-*bug)
1689d87a3195Smrg		os=coff
169095b296d0Smrg		;;
169195b296d0Smrg	*-apple)
1692d87a3195Smrg		os=macos
169395b296d0Smrg		;;
169495b296d0Smrg	*-atari*)
1695d87a3195Smrg		os=mint
1696d87a3195Smrg		;;
1697d87a3195Smrg	*-wrs)
1698d87a3195Smrg		os=vxworks
169995b296d0Smrg		;;
170095b296d0Smrg	*)
1701d87a3195Smrg		os=none
170295b296d0Smrg		;;
170395b296d0Smrgesac
1704d87a3195Smrg
170595b296d0Smrgfi
170695b296d0Smrg
1707d87a3195Smrg# Now, validate our (potentially fixed-up) OS.
1708d87a3195Smrgcase $os in
1709d87a3195Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
1710d87a3195Smrg	musl* | newlib* | relibc* | uclibc*)
1711d87a3195Smrg		;;
1712d87a3195Smrg	# Likewise for "kernel-abi"
1713d87a3195Smrg	eabi* | gnueabi*)
1714d87a3195Smrg		;;
1715d87a3195Smrg	# VxWorks passes extra cpu info in the 4th filed.
1716d87a3195Smrg	simlinux | simwindows | spe)
1717d87a3195Smrg		;;
1718d87a3195Smrg	# Now accept the basic system types.
1719d87a3195Smrg	# The portable systems comes first.
1720d87a3195Smrg	# Each alternative MUST end in a * to match a version number.
1721d87a3195Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1722d87a3195Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1723d87a3195Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1724d87a3195Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1725d87a3195Smrg	     | hiux* | abug | nacl* | netware* | windows* \
1726d87a3195Smrg	     | os9* | macos* | osx* | ios* \
1727d87a3195Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1728d87a3195Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1729d87a3195Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1730d87a3195Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1731d87a3195Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1732d87a3195Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1733d87a3195Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1734d87a3195Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1735d87a3195Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1736d87a3195Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1737d87a3195Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1738d87a3195Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
1739d87a3195Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1740d87a3195Smrg	     | midipix* | mingw32* | mingw64* | mint* \
1741d87a3195Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1742d87a3195Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1743d87a3195Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1744d87a3195Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1745d87a3195Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1746d87a3195Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1747d87a3195Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1748d87a3195Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1749d87a3195Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1750d87a3195Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1751d87a3195Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
1752d87a3195Smrg		;;
1753d87a3195Smrg	# This one is extra strict with allowed versions
1754d87a3195Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1755d87a3195Smrg		# Don't forget version if it is 3.2v4 or newer.
1756d87a3195Smrg		;;
1757d87a3195Smrg	none)
1758d87a3195Smrg		;;
1759d87a3195Smrg	*)
1760d87a3195Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1761d87a3195Smrg		exit 1
1762d87a3195Smrg		;;
1763d87a3195Smrgesac
1764d87a3195Smrg
1765d87a3195Smrg# As a final step for OS-related things, validate the OS-kernel combination
1766d87a3195Smrg# (given a valid OS), if there is a kernel.
1767d87a3195Smrgcase $kernel-$os in
1768d87a3195Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1769d87a3195Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* )
1770d87a3195Smrg		;;
1771d87a3195Smrg	uclinux-uclibc* )
1772d87a3195Smrg		;;
1773d87a3195Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
1774d87a3195Smrg		# These are just libc implementations, not actual OSes, and thus
1775d87a3195Smrg		# require a kernel.
1776d87a3195Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1777d87a3195Smrg		exit 1
1778d87a3195Smrg		;;
1779d87a3195Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
1780d87a3195Smrg		;;
1781d87a3195Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1782d87a3195Smrg		;;
1783d87a3195Smrg	nto-qnx*)
1784d87a3195Smrg		;;
1785d87a3195Smrg	os2-emx)
1786d87a3195Smrg		;;
1787d87a3195Smrg	*-eabi* | *-gnueabi*)
1788d87a3195Smrg		;;
1789d87a3195Smrg	-*)
1790d87a3195Smrg		# Blank kernel with real OS is always fine.
1791d87a3195Smrg		;;
1792d87a3195Smrg	*-*)
1793d87a3195Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1794d87a3195Smrg		exit 1
1795d87a3195Smrg		;;
1796d87a3195Smrgesac
1797d87a3195Smrg
179895b296d0Smrg# Here we handle the case where we know the os, and the CPU type, but not the
179995b296d0Smrg# manufacturer.  We pick the logical manufacturer.
1800d87a3195Smrgcase $vendor in
1801d87a3195Smrg	unknown)
1802d87a3195Smrg		case $cpu-$os in
1803d87a3195Smrg			*-riscix*)
180495b296d0Smrg				vendor=acorn
180595b296d0Smrg				;;
1806d87a3195Smrg			*-sunos*)
180795b296d0Smrg				vendor=sun
180895b296d0Smrg				;;
1809d87a3195Smrg			*-cnk* | *-aix*)
181095b296d0Smrg				vendor=ibm
181195b296d0Smrg				;;
1812d87a3195Smrg			*-beos*)
181395b296d0Smrg				vendor=be
181495b296d0Smrg				;;
1815d87a3195Smrg			*-hpux*)
181695b296d0Smrg				vendor=hp
181795b296d0Smrg				;;
1818d87a3195Smrg			*-mpeix*)
181995b296d0Smrg				vendor=hp
182095b296d0Smrg				;;
1821d87a3195Smrg			*-hiux*)
182295b296d0Smrg				vendor=hitachi
182395b296d0Smrg				;;
1824d87a3195Smrg			*-unos*)
182595b296d0Smrg				vendor=crds
182695b296d0Smrg				;;
1827d87a3195Smrg			*-dgux*)
182895b296d0Smrg				vendor=dg
182995b296d0Smrg				;;
1830d87a3195Smrg			*-luna*)
183195b296d0Smrg				vendor=omron
183295b296d0Smrg				;;
1833d87a3195Smrg			*-genix*)
183495b296d0Smrg				vendor=ns
183595b296d0Smrg				;;
1836d87a3195Smrg			*-clix*)
1837d87a3195Smrg				vendor=intergraph
1838d87a3195Smrg				;;
1839d87a3195Smrg			*-mvs* | *-opened*)
1840d87a3195Smrg				vendor=ibm
1841d87a3195Smrg				;;
1842d87a3195Smrg			*-os400*)
184395b296d0Smrg				vendor=ibm
184495b296d0Smrg				;;
1845d87a3195Smrg			s390-* | s390x-*)
184695b296d0Smrg				vendor=ibm
184795b296d0Smrg				;;
1848d87a3195Smrg			*-ptx*)
184995b296d0Smrg				vendor=sequent
185095b296d0Smrg				;;
1851d87a3195Smrg			*-tpf*)
185295b296d0Smrg				vendor=ibm
185395b296d0Smrg				;;
1854d87a3195Smrg			*-vxsim* | *-vxworks* | *-windiss*)
185595b296d0Smrg				vendor=wrs
185695b296d0Smrg				;;
1857d87a3195Smrg			*-aux*)
185895b296d0Smrg				vendor=apple
185995b296d0Smrg				;;
1860d87a3195Smrg			*-hms*)
186195b296d0Smrg				vendor=hitachi
186295b296d0Smrg				;;
1863d87a3195Smrg			*-mpw* | *-macos*)
186495b296d0Smrg				vendor=apple
186595b296d0Smrg				;;
1866d87a3195Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
186795b296d0Smrg				vendor=atari
186895b296d0Smrg				;;
1869d87a3195Smrg			*-vos*)
187095b296d0Smrg				vendor=stratus
187195b296d0Smrg				;;
187295b296d0Smrg		esac
187395b296d0Smrg		;;
187495b296d0Smrgesac
187595b296d0Smrg
1876d87a3195Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
187795b296d0Smrgexit
187895b296d0Smrg
187995b296d0Smrg# Local variables:
1880d87a3195Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
188195b296d0Smrg# time-stamp-start: "timestamp='"
188295b296d0Smrg# time-stamp-format: "%:y-%02m-%02d"
188395b296d0Smrg# time-stamp-end: "'"
188495b296d0Smrg# End:
1885