xref: /freebsd/contrib/unbound/config.sub (revision b76ef9a7)
125039b37SCy Schubert#! /bin/sh
2b7579f77SDag-Erling Smørgrav# Configuration validation subroutine script.
3b76ef9a7SCy Schubert#   Copyright 1992-2024 Free Software Foundation, Inc.
4b7579f77SDag-Erling Smørgrav
55469a995SCy Schubert# shellcheck disable=SC2006,SC2268 # see below for rationale
65469a995SCy Schubert
7b76ef9a7SCy Schuberttimestamp='2024-01-01'
8b7579f77SDag-Erling Smørgrav
9ff825849SDag-Erling Smørgrav# This file is free software; you can redistribute it and/or modify it
10ff825849SDag-Erling Smørgrav# under the terms of the GNU General Public License as published by
119cf5bc93SCy Schubert# the Free Software Foundation, either version 3 of the License, or
12b7579f77SDag-Erling Smørgrav# (at your option) any later version.
13b7579f77SDag-Erling Smørgrav#
14ff825849SDag-Erling Smørgrav# This program is distributed in the hope that it will be useful, but
15ff825849SDag-Erling Smørgrav# WITHOUT ANY WARRANTY; without even the implied warranty of
16ff825849SDag-Erling Smørgrav# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17ff825849SDag-Erling Smørgrav# General Public License for more details.
18b7579f77SDag-Erling Smørgrav#
19b7579f77SDag-Erling Smørgrav# You should have received a copy of the GNU General Public License
2025039b37SCy Schubert# along with this program; if not, see <https://www.gnu.org/licenses/>.
21b7579f77SDag-Erling Smørgrav#
22b7579f77SDag-Erling Smørgrav# As a special exception to the GNU General Public License, if you
23b7579f77SDag-Erling Smørgrav# distribute this file as part of a program that contains a
24b7579f77SDag-Erling Smørgrav# configuration script generated by Autoconf, you may include it under
25ff825849SDag-Erling Smørgrav# the same distribution terms that you use for the rest of that
26ff825849SDag-Erling Smørgrav# program.  This Exception is an additional permission under section 7
27ff825849SDag-Erling Smørgrav# of the GNU General Public License, version 3 ("GPLv3").
28b7579f77SDag-Erling Smørgrav
29b7579f77SDag-Erling Smørgrav
308157cbabSDag-Erling Smørgrav# Please send patches to <config-patches@gnu.org>.
31b7579f77SDag-Erling Smørgrav#
32b7579f77SDag-Erling Smørgrav# Configuration subroutine to validate and canonicalize a configuration type.
33b7579f77SDag-Erling Smørgrav# Supply the specified configuration type as an argument.
34b7579f77SDag-Erling Smørgrav# If it is invalid, we print an error message on stderr and exit with code 1.
35b7579f77SDag-Erling Smørgrav# Otherwise, we print the canonical config type on stdout and succeed.
36b7579f77SDag-Erling Smørgrav
37b7579f77SDag-Erling Smørgrav# You can get the latest version of this script from:
38369c6923SCy Schubert# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39b7579f77SDag-Erling Smørgrav
40b7579f77SDag-Erling Smørgrav# This file is supposed to be the same for all GNU packages
41b7579f77SDag-Erling Smørgrav# and recognize all the CPU types, system types and aliases
42b7579f77SDag-Erling Smørgrav# that are meaningful with *any* GNU software.
43b7579f77SDag-Erling Smørgrav# Each package is responsible for reporting which valid configurations
44b7579f77SDag-Erling Smørgrav# it does not support.  The user should be able to distinguish
45b7579f77SDag-Erling Smørgrav# a failure to support a valid configuration from a meaningless
46b7579f77SDag-Erling Smørgrav# configuration.
47b7579f77SDag-Erling Smørgrav
48b7579f77SDag-Erling Smørgrav# The goal of this file is to map all the various variations of a given
49b7579f77SDag-Erling Smørgrav# machine specification into a single specification in the form:
50b7579f77SDag-Erling Smørgrav#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51b7579f77SDag-Erling Smørgrav# or in some cases, the newer four-part form:
52b7579f77SDag-Erling Smørgrav#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53b7579f77SDag-Erling Smørgrav# It is wrong to echo any other type of specification.
54b7579f77SDag-Erling Smørgrav
555469a995SCy Schubert# The "shellcheck disable" line above the timestamp inhibits complaints
565469a995SCy Schubert# about features and limitations of the classic Bourne shell that were
575469a995SCy Schubert# superseded or lifted in POSIX.  However, this script identifies a wide
585469a995SCy Schubert# variety of pre-POSIX systems that do not have POSIX shells at all, and
595469a995SCy Schubert# even some reasonably current systems (Solaris 10 as case-in-point) still
605469a995SCy Schubert# have a pre-POSIX /bin/sh.
615469a995SCy Schubert
625469a995SCy Schubertme=`echo "$0" | sed -e 's,.*/,,'`
63b7579f77SDag-Erling Smørgrav
64b7579f77SDag-Erling Smørgravusage="\
658157cbabSDag-Erling SmørgravUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66b7579f77SDag-Erling Smørgrav
67b7579f77SDag-Erling SmørgravCanonicalize a configuration name.
68b7579f77SDag-Erling Smørgrav
6925039b37SCy SchubertOptions:
70b7579f77SDag-Erling Smørgrav  -h, --help         print this help, then exit
71b7579f77SDag-Erling Smørgrav  -t, --time-stamp   print date of last modification, then exit
72b7579f77SDag-Erling Smørgrav  -v, --version      print version number, then exit
73b7579f77SDag-Erling Smørgrav
74b7579f77SDag-Erling SmørgravReport bugs and patches to <config-patches@gnu.org>."
75b7579f77SDag-Erling Smørgrav
76b7579f77SDag-Erling Smørgravversion="\
77b7579f77SDag-Erling SmørgravGNU config.sub ($timestamp)
78b7579f77SDag-Erling Smørgrav
79b76ef9a7SCy SchubertCopyright 1992-2024 Free Software Foundation, Inc.
80b7579f77SDag-Erling Smørgrav
81b7579f77SDag-Erling SmørgravThis is free software; see the source for copying conditions.  There is NO
82b7579f77SDag-Erling Smørgravwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83b7579f77SDag-Erling Smørgrav
84b7579f77SDag-Erling Smørgravhelp="
858f76bb7dSCy SchubertTry '$me --help' for more information."
86b7579f77SDag-Erling Smørgrav
87b7579f77SDag-Erling Smørgrav# Parse command line
88b7579f77SDag-Erling Smørgravwhile test $# -gt 0 ; do
89b7579f77SDag-Erling Smørgrav  case $1 in
90b7579f77SDag-Erling Smørgrav    --time-stamp | --time* | -t )
91b7579f77SDag-Erling Smørgrav       echo "$timestamp" ; exit ;;
92b7579f77SDag-Erling Smørgrav    --version | -v )
93b7579f77SDag-Erling Smørgrav       echo "$version" ; exit ;;
94b7579f77SDag-Erling Smørgrav    --help | --h* | -h )
95b7579f77SDag-Erling Smørgrav       echo "$usage"; exit ;;
96b7579f77SDag-Erling Smørgrav    -- )     # Stop option processing
97b7579f77SDag-Erling Smørgrav       shift; break ;;
98b7579f77SDag-Erling Smørgrav    - )	# Use stdin as input.
99b7579f77SDag-Erling Smørgrav       break ;;
100b7579f77SDag-Erling Smørgrav    -* )
10125039b37SCy Schubert       echo "$me: invalid option $1$help" >&2
102b7579f77SDag-Erling Smørgrav       exit 1 ;;
103b7579f77SDag-Erling Smørgrav
104b7579f77SDag-Erling Smørgrav    *local*)
105b7579f77SDag-Erling Smørgrav       # First pass through any local machine types.
10625039b37SCy Schubert       echo "$1"
107b7579f77SDag-Erling Smørgrav       exit ;;
108b7579f77SDag-Erling Smørgrav
109b7579f77SDag-Erling Smørgrav    * )
110b7579f77SDag-Erling Smørgrav       break ;;
111b7579f77SDag-Erling Smørgrav  esac
112b7579f77SDag-Erling Smørgravdone
113b7579f77SDag-Erling Smørgrav
114b7579f77SDag-Erling Smørgravcase $# in
115b7579f77SDag-Erling Smørgrav 0) echo "$me: missing argument$help" >&2
116b7579f77SDag-Erling Smørgrav    exit 1;;
117b7579f77SDag-Erling Smørgrav 1) ;;
118b7579f77SDag-Erling Smørgrav *) echo "$me: too many arguments$help" >&2
119b7579f77SDag-Erling Smørgrav    exit 1;;
120b7579f77SDag-Erling Smørgravesac
121b7579f77SDag-Erling Smørgrav
12225039b37SCy Schubert# Split fields of configuration type
12325039b37SCy Schubert# shellcheck disable=SC2162
12424e36522SCy Schubertsaved_IFS=$IFS
12525039b37SCy SchubertIFS="-" read field1 field2 field3 field4 <<EOF
12625039b37SCy Schubert$1
12725039b37SCy SchubertEOF
12824e36522SCy SchubertIFS=$saved_IFS
12925039b37SCy Schubert
13025039b37SCy Schubert# Separate into logical components for further validation
13125039b37SCy Schubertcase $1 in
13225039b37SCy Schubert	*-*-*-*-*)
1338f76bb7dSCy Schubert		echo "Invalid configuration '$1': more than four components" >&2
13425039b37SCy Schubert		exit 1
13525039b37SCy Schubert		;;
13625039b37SCy Schubert	*-*-*-*)
13725039b37SCy Schubert		basic_machine=$field1-$field2
13825039b37SCy Schubert		basic_os=$field3-$field4
13925039b37SCy Schubert		;;
14025039b37SCy Schubert	*-*-*)
14125039b37SCy Schubert		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
14225039b37SCy Schubert		# parts
14325039b37SCy Schubert		maybe_os=$field2-$field3
144b7579f77SDag-Erling Smørgrav		case $maybe_os in
14525039b37SCy Schubert			nto-qnx* | linux-* | uclinux-uclibc* \
14625039b37SCy Schubert			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
14725039b37SCy Schubert			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
1488f76bb7dSCy Schubert			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
1498f76bb7dSCy Schubert			| windows-* )
15025039b37SCy Schubert				basic_machine=$field1
15125039b37SCy Schubert				basic_os=$maybe_os
152b7579f77SDag-Erling Smørgrav				;;
1538ed2b524SDag-Erling Smørgrav			android-linux)
15425039b37SCy Schubert				basic_machine=$field1-unknown
15525039b37SCy Schubert				basic_os=linux-android
1568ed2b524SDag-Erling Smørgrav				;;
157b7579f77SDag-Erling Smørgrav			*)
15825039b37SCy Schubert				basic_machine=$field1-$field2
15925039b37SCy Schubert				basic_os=$field3
16025039b37SCy Schubert				;;
16125039b37SCy Schubert		esac
16225039b37SCy Schubert		;;
16325039b37SCy Schubert	*-*)
16425039b37SCy Schubert		# A lone config we happen to match not fitting any pattern
16525039b37SCy Schubert		case $field1-$field2 in
16625039b37SCy Schubert			decstation-3100)
16725039b37SCy Schubert				basic_machine=mips-dec
16825039b37SCy Schubert				basic_os=
16925039b37SCy Schubert				;;
17025039b37SCy Schubert			*-*)
17125039b37SCy Schubert				# Second component is usually, but not always the OS
17225039b37SCy Schubert				case $field2 in
17325039b37SCy Schubert					# Prevent following clause from handling this valid os
17425039b37SCy Schubert					sun*os*)
17525039b37SCy Schubert						basic_machine=$field1
17625039b37SCy Schubert						basic_os=$field2
17725039b37SCy Schubert						;;
17824e36522SCy Schubert					zephyr*)
17924e36522SCy Schubert						basic_machine=$field1-unknown
18024e36522SCy Schubert						basic_os=$field2
18124e36522SCy Schubert						;;
18225039b37SCy Schubert					# Manufacturers
18325039b37SCy Schubert					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
18425039b37SCy Schubert					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
18525039b37SCy Schubert					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
18625039b37SCy Schubert					| convergent* | ncr* | news | 32* | 3600* | 3100* \
18725039b37SCy Schubert					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
18825039b37SCy Schubert					| ultra | tti* | harris | dolphin | highlevel | gould \
18925039b37SCy Schubert					| cbm | ns | masscomp | apple | axis | knuth | cray \
19025039b37SCy Schubert					| microblaze* | sim | cisco \
19125039b37SCy Schubert					| oki | wec | wrs | winbond)
19225039b37SCy Schubert						basic_machine=$field1-$field2
19325039b37SCy Schubert						basic_os=
19425039b37SCy Schubert						;;
19525039b37SCy Schubert					*)
19625039b37SCy Schubert						basic_machine=$field1
19725039b37SCy Schubert						basic_os=$field2
19825039b37SCy Schubert						;;
19925039b37SCy Schubert				esac
20025039b37SCy Schubert			;;
20125039b37SCy Schubert		esac
20225039b37SCy Schubert		;;
20325039b37SCy Schubert	*)
20425039b37SCy Schubert		# Convert single-component short-hands not valid as part of
20525039b37SCy Schubert		# multi-component configurations.
20625039b37SCy Schubert		case $field1 in
20725039b37SCy Schubert			386bsd)
20825039b37SCy Schubert				basic_machine=i386-pc
20925039b37SCy Schubert				basic_os=bsd
21025039b37SCy Schubert				;;
21125039b37SCy Schubert			a29khif)
21225039b37SCy Schubert				basic_machine=a29k-amd
21325039b37SCy Schubert				basic_os=udi
21425039b37SCy Schubert				;;
21525039b37SCy Schubert			adobe68k)
21625039b37SCy Schubert				basic_machine=m68010-adobe
21725039b37SCy Schubert				basic_os=scout
21825039b37SCy Schubert				;;
21925039b37SCy Schubert			alliant)
22025039b37SCy Schubert				basic_machine=fx80-alliant
22125039b37SCy Schubert				basic_os=
22225039b37SCy Schubert				;;
22325039b37SCy Schubert			altos | altos3068)
22425039b37SCy Schubert				basic_machine=m68k-altos
22525039b37SCy Schubert				basic_os=
22625039b37SCy Schubert				;;
22725039b37SCy Schubert			am29k)
22825039b37SCy Schubert				basic_machine=a29k-none
22925039b37SCy Schubert				basic_os=bsd
23025039b37SCy Schubert				;;
23125039b37SCy Schubert			amdahl)
23225039b37SCy Schubert				basic_machine=580-amdahl
23325039b37SCy Schubert				basic_os=sysv
23425039b37SCy Schubert				;;
23525039b37SCy Schubert			amiga)
23625039b37SCy Schubert				basic_machine=m68k-unknown
23725039b37SCy Schubert				basic_os=
23825039b37SCy Schubert				;;
23925039b37SCy Schubert			amigaos | amigados)
24025039b37SCy Schubert				basic_machine=m68k-unknown
24125039b37SCy Schubert				basic_os=amigaos
24225039b37SCy Schubert				;;
24325039b37SCy Schubert			amigaunix | amix)
24425039b37SCy Schubert				basic_machine=m68k-unknown
24525039b37SCy Schubert				basic_os=sysv4
24625039b37SCy Schubert				;;
24725039b37SCy Schubert			apollo68)
24825039b37SCy Schubert				basic_machine=m68k-apollo
24925039b37SCy Schubert				basic_os=sysv
25025039b37SCy Schubert				;;
25125039b37SCy Schubert			apollo68bsd)
25225039b37SCy Schubert				basic_machine=m68k-apollo
25325039b37SCy Schubert				basic_os=bsd
25425039b37SCy Schubert				;;
25525039b37SCy Schubert			aros)
25625039b37SCy Schubert				basic_machine=i386-pc
25725039b37SCy Schubert				basic_os=aros
25825039b37SCy Schubert				;;
25925039b37SCy Schubert			aux)
26025039b37SCy Schubert				basic_machine=m68k-apple
26125039b37SCy Schubert				basic_os=aux
26225039b37SCy Schubert				;;
26325039b37SCy Schubert			balance)
26425039b37SCy Schubert				basic_machine=ns32k-sequent
26525039b37SCy Schubert				basic_os=dynix
26625039b37SCy Schubert				;;
26725039b37SCy Schubert			blackfin)
26825039b37SCy Schubert				basic_machine=bfin-unknown
26925039b37SCy Schubert				basic_os=linux
27025039b37SCy Schubert				;;
27125039b37SCy Schubert			cegcc)
27225039b37SCy Schubert				basic_machine=arm-unknown
27325039b37SCy Schubert				basic_os=cegcc
27425039b37SCy Schubert				;;
27525039b37SCy Schubert			convex-c1)
27625039b37SCy Schubert				basic_machine=c1-convex
27725039b37SCy Schubert				basic_os=bsd
27825039b37SCy Schubert				;;
27925039b37SCy Schubert			convex-c2)
28025039b37SCy Schubert				basic_machine=c2-convex
28125039b37SCy Schubert				basic_os=bsd
28225039b37SCy Schubert				;;
28325039b37SCy Schubert			convex-c32)
28425039b37SCy Schubert				basic_machine=c32-convex
28525039b37SCy Schubert				basic_os=bsd
28625039b37SCy Schubert				;;
28725039b37SCy Schubert			convex-c34)
28825039b37SCy Schubert				basic_machine=c34-convex
28925039b37SCy Schubert				basic_os=bsd
29025039b37SCy Schubert				;;
29125039b37SCy Schubert			convex-c38)
29225039b37SCy Schubert				basic_machine=c38-convex
29325039b37SCy Schubert				basic_os=bsd
29425039b37SCy Schubert				;;
29525039b37SCy Schubert			cray)
29625039b37SCy Schubert				basic_machine=j90-cray
29725039b37SCy Schubert				basic_os=unicos
29825039b37SCy Schubert				;;
29925039b37SCy Schubert			crds | unos)
30025039b37SCy Schubert				basic_machine=m68k-crds
30125039b37SCy Schubert				basic_os=
30225039b37SCy Schubert				;;
30325039b37SCy Schubert			da30)
30425039b37SCy Schubert				basic_machine=m68k-da30
30525039b37SCy Schubert				basic_os=
30625039b37SCy Schubert				;;
30725039b37SCy Schubert			decstation | pmax | pmin | dec3100 | decstatn)
30825039b37SCy Schubert				basic_machine=mips-dec
30925039b37SCy Schubert				basic_os=
31025039b37SCy Schubert				;;
31125039b37SCy Schubert			delta88)
31225039b37SCy Schubert				basic_machine=m88k-motorola
31325039b37SCy Schubert				basic_os=sysv3
31425039b37SCy Schubert				;;
31525039b37SCy Schubert			dicos)
31625039b37SCy Schubert				basic_machine=i686-pc
31725039b37SCy Schubert				basic_os=dicos
31825039b37SCy Schubert				;;
31925039b37SCy Schubert			djgpp)
32025039b37SCy Schubert				basic_machine=i586-pc
32125039b37SCy Schubert				basic_os=msdosdjgpp
32225039b37SCy Schubert				;;
32325039b37SCy Schubert			ebmon29k)
32425039b37SCy Schubert				basic_machine=a29k-amd
32525039b37SCy Schubert				basic_os=ebmon
32625039b37SCy Schubert				;;
32725039b37SCy Schubert			es1800 | OSE68k | ose68k | ose | OSE)
32825039b37SCy Schubert				basic_machine=m68k-ericsson
32925039b37SCy Schubert				basic_os=ose
33025039b37SCy Schubert				;;
33125039b37SCy Schubert			gmicro)
33225039b37SCy Schubert				basic_machine=tron-gmicro
33325039b37SCy Schubert				basic_os=sysv
33425039b37SCy Schubert				;;
33525039b37SCy Schubert			go32)
33625039b37SCy Schubert				basic_machine=i386-pc
33725039b37SCy Schubert				basic_os=go32
33825039b37SCy Schubert				;;
33925039b37SCy Schubert			h8300hms)
34025039b37SCy Schubert				basic_machine=h8300-hitachi
34125039b37SCy Schubert				basic_os=hms
34225039b37SCy Schubert				;;
34325039b37SCy Schubert			h8300xray)
34425039b37SCy Schubert				basic_machine=h8300-hitachi
34525039b37SCy Schubert				basic_os=xray
34625039b37SCy Schubert				;;
34725039b37SCy Schubert			h8500hms)
34825039b37SCy Schubert				basic_machine=h8500-hitachi
34925039b37SCy Schubert				basic_os=hms
35025039b37SCy Schubert				;;
35125039b37SCy Schubert			harris)
35225039b37SCy Schubert				basic_machine=m88k-harris
35325039b37SCy Schubert				basic_os=sysv3
35425039b37SCy Schubert				;;
35525039b37SCy Schubert			hp300 | hp300hpux)
35625039b37SCy Schubert				basic_machine=m68k-hp
35725039b37SCy Schubert				basic_os=hpux
35825039b37SCy Schubert				;;
35925039b37SCy Schubert			hp300bsd)
36025039b37SCy Schubert				basic_machine=m68k-hp
36125039b37SCy Schubert				basic_os=bsd
36225039b37SCy Schubert				;;
36325039b37SCy Schubert			hppaosf)
36425039b37SCy Schubert				basic_machine=hppa1.1-hp
36525039b37SCy Schubert				basic_os=osf
36625039b37SCy Schubert				;;
36725039b37SCy Schubert			hppro)
36825039b37SCy Schubert				basic_machine=hppa1.1-hp
36925039b37SCy Schubert				basic_os=proelf
37025039b37SCy Schubert				;;
37125039b37SCy Schubert			i386mach)
37225039b37SCy Schubert				basic_machine=i386-mach
37325039b37SCy Schubert				basic_os=mach
37425039b37SCy Schubert				;;
37525039b37SCy Schubert			isi68 | isi)
37625039b37SCy Schubert				basic_machine=m68k-isi
37725039b37SCy Schubert				basic_os=sysv
37825039b37SCy Schubert				;;
37925039b37SCy Schubert			m68knommu)
38025039b37SCy Schubert				basic_machine=m68k-unknown
38125039b37SCy Schubert				basic_os=linux
38225039b37SCy Schubert				;;
38325039b37SCy Schubert			magnum | m3230)
38425039b37SCy Schubert				basic_machine=mips-mips
38525039b37SCy Schubert				basic_os=sysv
38625039b37SCy Schubert				;;
38725039b37SCy Schubert			merlin)
38825039b37SCy Schubert				basic_machine=ns32k-utek
38925039b37SCy Schubert				basic_os=sysv
39025039b37SCy Schubert				;;
39125039b37SCy Schubert			mingw64)
39225039b37SCy Schubert				basic_machine=x86_64-pc
39325039b37SCy Schubert				basic_os=mingw64
39425039b37SCy Schubert				;;
39525039b37SCy Schubert			mingw32)
39625039b37SCy Schubert				basic_machine=i686-pc
39725039b37SCy Schubert				basic_os=mingw32
39825039b37SCy Schubert				;;
39925039b37SCy Schubert			mingw32ce)
40025039b37SCy Schubert				basic_machine=arm-unknown
40125039b37SCy Schubert				basic_os=mingw32ce
40225039b37SCy Schubert				;;
40325039b37SCy Schubert			monitor)
40425039b37SCy Schubert				basic_machine=m68k-rom68k
40525039b37SCy Schubert				basic_os=coff
40625039b37SCy Schubert				;;
40725039b37SCy Schubert			morphos)
40825039b37SCy Schubert				basic_machine=powerpc-unknown
40925039b37SCy Schubert				basic_os=morphos
41025039b37SCy Schubert				;;
41125039b37SCy Schubert			moxiebox)
41225039b37SCy Schubert				basic_machine=moxie-unknown
41325039b37SCy Schubert				basic_os=moxiebox
41425039b37SCy Schubert				;;
41525039b37SCy Schubert			msdos)
41625039b37SCy Schubert				basic_machine=i386-pc
41725039b37SCy Schubert				basic_os=msdos
41825039b37SCy Schubert				;;
41925039b37SCy Schubert			msys)
42025039b37SCy Schubert				basic_machine=i686-pc
42125039b37SCy Schubert				basic_os=msys
42225039b37SCy Schubert				;;
42325039b37SCy Schubert			mvs)
42425039b37SCy Schubert				basic_machine=i370-ibm
42525039b37SCy Schubert				basic_os=mvs
42625039b37SCy Schubert				;;
42725039b37SCy Schubert			nacl)
42825039b37SCy Schubert				basic_machine=le32-unknown
42925039b37SCy Schubert				basic_os=nacl
43025039b37SCy Schubert				;;
43125039b37SCy Schubert			ncr3000)
43225039b37SCy Schubert				basic_machine=i486-ncr
43325039b37SCy Schubert				basic_os=sysv4
43425039b37SCy Schubert				;;
43525039b37SCy Schubert			netbsd386)
43625039b37SCy Schubert				basic_machine=i386-pc
43725039b37SCy Schubert				basic_os=netbsd
43825039b37SCy Schubert				;;
43925039b37SCy Schubert			netwinder)
44025039b37SCy Schubert				basic_machine=armv4l-rebel
44125039b37SCy Schubert				basic_os=linux
44225039b37SCy Schubert				;;
44325039b37SCy Schubert			news | news700 | news800 | news900)
44425039b37SCy Schubert				basic_machine=m68k-sony
44525039b37SCy Schubert				basic_os=newsos
44625039b37SCy Schubert				;;
44725039b37SCy Schubert			news1000)
44825039b37SCy Schubert				basic_machine=m68030-sony
44925039b37SCy Schubert				basic_os=newsos
45025039b37SCy Schubert				;;
45125039b37SCy Schubert			necv70)
45225039b37SCy Schubert				basic_machine=v70-nec
45325039b37SCy Schubert				basic_os=sysv
45425039b37SCy Schubert				;;
45525039b37SCy Schubert			nh3000)
45625039b37SCy Schubert				basic_machine=m68k-harris
45725039b37SCy Schubert				basic_os=cxux
45825039b37SCy Schubert				;;
45925039b37SCy Schubert			nh[45]000)
46025039b37SCy Schubert				basic_machine=m88k-harris
46125039b37SCy Schubert				basic_os=cxux
46225039b37SCy Schubert				;;
46325039b37SCy Schubert			nindy960)
46425039b37SCy Schubert				basic_machine=i960-intel
46525039b37SCy Schubert				basic_os=nindy
46625039b37SCy Schubert				;;
46725039b37SCy Schubert			mon960)
46825039b37SCy Schubert				basic_machine=i960-intel
46925039b37SCy Schubert				basic_os=mon960
47025039b37SCy Schubert				;;
47125039b37SCy Schubert			nonstopux)
47225039b37SCy Schubert				basic_machine=mips-compaq
47325039b37SCy Schubert				basic_os=nonstopux
47425039b37SCy Schubert				;;
47525039b37SCy Schubert			os400)
47625039b37SCy Schubert				basic_machine=powerpc-ibm
47725039b37SCy Schubert				basic_os=os400
47825039b37SCy Schubert				;;
47925039b37SCy Schubert			OSE68000 | ose68000)
48025039b37SCy Schubert				basic_machine=m68000-ericsson
48125039b37SCy Schubert				basic_os=ose
48225039b37SCy Schubert				;;
48325039b37SCy Schubert			os68k)
48425039b37SCy Schubert				basic_machine=m68k-none
48525039b37SCy Schubert				basic_os=os68k
48625039b37SCy Schubert				;;
48725039b37SCy Schubert			paragon)
48825039b37SCy Schubert				basic_machine=i860-intel
48925039b37SCy Schubert				basic_os=osf
49025039b37SCy Schubert				;;
49125039b37SCy Schubert			parisc)
49225039b37SCy Schubert				basic_machine=hppa-unknown
49325039b37SCy Schubert				basic_os=linux
49425039b37SCy Schubert				;;
49525039b37SCy Schubert			psp)
49625039b37SCy Schubert				basic_machine=mipsallegrexel-sony
49725039b37SCy Schubert				basic_os=psp
49825039b37SCy Schubert				;;
49925039b37SCy Schubert			pw32)
50025039b37SCy Schubert				basic_machine=i586-unknown
50125039b37SCy Schubert				basic_os=pw32
50225039b37SCy Schubert				;;
50325039b37SCy Schubert			rdos | rdos64)
50425039b37SCy Schubert				basic_machine=x86_64-pc
50525039b37SCy Schubert				basic_os=rdos
50625039b37SCy Schubert				;;
50725039b37SCy Schubert			rdos32)
50825039b37SCy Schubert				basic_machine=i386-pc
50925039b37SCy Schubert				basic_os=rdos
51025039b37SCy Schubert				;;
51125039b37SCy Schubert			rom68k)
51225039b37SCy Schubert				basic_machine=m68k-rom68k
51325039b37SCy Schubert				basic_os=coff
51425039b37SCy Schubert				;;
51525039b37SCy Schubert			sa29200)
51625039b37SCy Schubert				basic_machine=a29k-amd
51725039b37SCy Schubert				basic_os=udi
51825039b37SCy Schubert				;;
51925039b37SCy Schubert			sei)
52025039b37SCy Schubert				basic_machine=mips-sei
52125039b37SCy Schubert				basic_os=seiux
52225039b37SCy Schubert				;;
52325039b37SCy Schubert			sequent)
52425039b37SCy Schubert				basic_machine=i386-sequent
52525039b37SCy Schubert				basic_os=
52625039b37SCy Schubert				;;
52725039b37SCy Schubert			sps7)
52825039b37SCy Schubert				basic_machine=m68k-bull
52925039b37SCy Schubert				basic_os=sysv2
53025039b37SCy Schubert				;;
53125039b37SCy Schubert			st2000)
53225039b37SCy Schubert				basic_machine=m68k-tandem
53325039b37SCy Schubert				basic_os=
53425039b37SCy Schubert				;;
53525039b37SCy Schubert			stratus)
53625039b37SCy Schubert				basic_machine=i860-stratus
53725039b37SCy Schubert				basic_os=sysv4
53825039b37SCy Schubert				;;
53925039b37SCy Schubert			sun2)
54025039b37SCy Schubert				basic_machine=m68000-sun
54125039b37SCy Schubert				basic_os=
54225039b37SCy Schubert				;;
54325039b37SCy Schubert			sun2os3)
54425039b37SCy Schubert				basic_machine=m68000-sun
54525039b37SCy Schubert				basic_os=sunos3
54625039b37SCy Schubert				;;
54725039b37SCy Schubert			sun2os4)
54825039b37SCy Schubert				basic_machine=m68000-sun
54925039b37SCy Schubert				basic_os=sunos4
55025039b37SCy Schubert				;;
55125039b37SCy Schubert			sun3)
55225039b37SCy Schubert				basic_machine=m68k-sun
55325039b37SCy Schubert				basic_os=
55425039b37SCy Schubert				;;
55525039b37SCy Schubert			sun3os3)
55625039b37SCy Schubert				basic_machine=m68k-sun
55725039b37SCy Schubert				basic_os=sunos3
55825039b37SCy Schubert				;;
55925039b37SCy Schubert			sun3os4)
56025039b37SCy Schubert				basic_machine=m68k-sun
56125039b37SCy Schubert				basic_os=sunos4
56225039b37SCy Schubert				;;
56325039b37SCy Schubert			sun4)
56425039b37SCy Schubert				basic_machine=sparc-sun
56525039b37SCy Schubert				basic_os=
56625039b37SCy Schubert				;;
56725039b37SCy Schubert			sun4os3)
56825039b37SCy Schubert				basic_machine=sparc-sun
56925039b37SCy Schubert				basic_os=sunos3
57025039b37SCy Schubert				;;
57125039b37SCy Schubert			sun4os4)
57225039b37SCy Schubert				basic_machine=sparc-sun
57325039b37SCy Schubert				basic_os=sunos4
57425039b37SCy Schubert				;;
57525039b37SCy Schubert			sun4sol2)
57625039b37SCy Schubert				basic_machine=sparc-sun
57725039b37SCy Schubert				basic_os=solaris2
57825039b37SCy Schubert				;;
57925039b37SCy Schubert			sun386 | sun386i | roadrunner)
58025039b37SCy Schubert				basic_machine=i386-sun
58125039b37SCy Schubert				basic_os=
58225039b37SCy Schubert				;;
58325039b37SCy Schubert			sv1)
58425039b37SCy Schubert				basic_machine=sv1-cray
58525039b37SCy Schubert				basic_os=unicos
58625039b37SCy Schubert				;;
58725039b37SCy Schubert			symmetry)
58825039b37SCy Schubert				basic_machine=i386-sequent
58925039b37SCy Schubert				basic_os=dynix
59025039b37SCy Schubert				;;
59125039b37SCy Schubert			t3e)
59225039b37SCy Schubert				basic_machine=alphaev5-cray
59325039b37SCy Schubert				basic_os=unicos
59425039b37SCy Schubert				;;
59525039b37SCy Schubert			t90)
59625039b37SCy Schubert				basic_machine=t90-cray
59725039b37SCy Schubert				basic_os=unicos
59825039b37SCy Schubert				;;
59925039b37SCy Schubert			toad1)
60025039b37SCy Schubert				basic_machine=pdp10-xkl
60125039b37SCy Schubert				basic_os=tops20
60225039b37SCy Schubert				;;
60325039b37SCy Schubert			tpf)
60425039b37SCy Schubert				basic_machine=s390x-ibm
60525039b37SCy Schubert				basic_os=tpf
60625039b37SCy Schubert				;;
60725039b37SCy Schubert			udi29k)
60825039b37SCy Schubert				basic_machine=a29k-amd
60925039b37SCy Schubert				basic_os=udi
61025039b37SCy Schubert				;;
61125039b37SCy Schubert			ultra3)
61225039b37SCy Schubert				basic_machine=a29k-nyu
61325039b37SCy Schubert				basic_os=sym1
61425039b37SCy Schubert				;;
61525039b37SCy Schubert			v810 | necv810)
61625039b37SCy Schubert				basic_machine=v810-nec
61725039b37SCy Schubert				basic_os=none
61825039b37SCy Schubert				;;
61925039b37SCy Schubert			vaxv)
62025039b37SCy Schubert				basic_machine=vax-dec
62125039b37SCy Schubert				basic_os=sysv
62225039b37SCy Schubert				;;
62325039b37SCy Schubert			vms)
62425039b37SCy Schubert				basic_machine=vax-dec
62525039b37SCy Schubert				basic_os=vms
62625039b37SCy Schubert				;;
62725039b37SCy Schubert			vsta)
62825039b37SCy Schubert				basic_machine=i386-pc
62925039b37SCy Schubert				basic_os=vsta
63025039b37SCy Schubert				;;
63125039b37SCy Schubert			vxworks960)
63225039b37SCy Schubert				basic_machine=i960-wrs
63325039b37SCy Schubert				basic_os=vxworks
63425039b37SCy Schubert				;;
63525039b37SCy Schubert			vxworks68)
63625039b37SCy Schubert				basic_machine=m68k-wrs
63725039b37SCy Schubert				basic_os=vxworks
63825039b37SCy Schubert				;;
63925039b37SCy Schubert			vxworks29k)
64025039b37SCy Schubert				basic_machine=a29k-wrs
64125039b37SCy Schubert				basic_os=vxworks
64225039b37SCy Schubert				;;
64325039b37SCy Schubert			xbox)
64425039b37SCy Schubert				basic_machine=i686-pc
64525039b37SCy Schubert				basic_os=mingw32
64625039b37SCy Schubert				;;
64725039b37SCy Schubert			ymp)
64825039b37SCy Schubert				basic_machine=ymp-cray
64925039b37SCy Schubert				basic_os=unicos
65025039b37SCy Schubert				;;
65125039b37SCy Schubert			*)
65225039b37SCy Schubert				basic_machine=$1
65325039b37SCy Schubert				basic_os=
65425039b37SCy Schubert				;;
65525039b37SCy Schubert		esac
656b7579f77SDag-Erling Smørgrav		;;
657b7579f77SDag-Erling Smørgravesac
658b7579f77SDag-Erling Smørgrav
65925039b37SCy Schubert# Decode 1-component or ad-hoc basic machines
660b7579f77SDag-Erling Smørgravcase $basic_machine in
66125039b37SCy Schubert	# Here we handle the default manufacturer of certain CPU types.  It is in
66225039b37SCy Schubert	# some cases the only manufacturer, in others, it is the most popular.
66325039b37SCy Schubert	w89k)
66425039b37SCy Schubert		cpu=hppa1.1
66525039b37SCy Schubert		vendor=winbond
66625039b37SCy Schubert		;;
66725039b37SCy Schubert	op50n)
66825039b37SCy Schubert		cpu=hppa1.1
66925039b37SCy Schubert		vendor=oki
67025039b37SCy Schubert		;;
67125039b37SCy Schubert	op60c)
67225039b37SCy Schubert		cpu=hppa1.1
67325039b37SCy Schubert		vendor=oki
67425039b37SCy Schubert		;;
67525039b37SCy Schubert	ibm*)
67625039b37SCy Schubert		cpu=i370
67725039b37SCy Schubert		vendor=ibm
67825039b37SCy Schubert		;;
67925039b37SCy Schubert	orion105)
68025039b37SCy Schubert		cpu=clipper
68125039b37SCy Schubert		vendor=highlevel
68225039b37SCy Schubert		;;
68325039b37SCy Schubert	mac | mpw | mac-mpw)
68425039b37SCy Schubert		cpu=m68k
68525039b37SCy Schubert		vendor=apple
68625039b37SCy Schubert		;;
68725039b37SCy Schubert	pmac | pmac-mpw)
68825039b37SCy Schubert		cpu=powerpc
68925039b37SCy Schubert		vendor=apple
69025039b37SCy Schubert		;;
69125039b37SCy Schubert
69225039b37SCy Schubert	# Recognize the various machine names and aliases which stand
69325039b37SCy Schubert	# for a CPU type and a company and sometimes even an OS.
69425039b37SCy Schubert	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
69525039b37SCy Schubert		cpu=m68000
69625039b37SCy Schubert		vendor=att
69725039b37SCy Schubert		;;
69825039b37SCy Schubert	3b*)
69925039b37SCy Schubert		cpu=we32k
70025039b37SCy Schubert		vendor=att
70125039b37SCy Schubert		;;
70225039b37SCy Schubert	bluegene*)
70325039b37SCy Schubert		cpu=powerpc
70425039b37SCy Schubert		vendor=ibm
70525039b37SCy Schubert		basic_os=cnk
70625039b37SCy Schubert		;;
70725039b37SCy Schubert	decsystem10* | dec10*)
70825039b37SCy Schubert		cpu=pdp10
70925039b37SCy Schubert		vendor=dec
71025039b37SCy Schubert		basic_os=tops10
71125039b37SCy Schubert		;;
71225039b37SCy Schubert	decsystem20* | dec20*)
71325039b37SCy Schubert		cpu=pdp10
71425039b37SCy Schubert		vendor=dec
71525039b37SCy Schubert		basic_os=tops20
71625039b37SCy Schubert		;;
71725039b37SCy Schubert	delta | 3300 | motorola-3300 | motorola-delta \
71825039b37SCy Schubert	      | 3300-motorola | delta-motorola)
71925039b37SCy Schubert		cpu=m68k
72025039b37SCy Schubert		vendor=motorola
72125039b37SCy Schubert		;;
72225039b37SCy Schubert	dpx2*)
72325039b37SCy Schubert		cpu=m68k
72425039b37SCy Schubert		vendor=bull
72525039b37SCy Schubert		basic_os=sysv3
72625039b37SCy Schubert		;;
72725039b37SCy Schubert	encore | umax | mmax)
72825039b37SCy Schubert		cpu=ns32k
72925039b37SCy Schubert		vendor=encore
73025039b37SCy Schubert		;;
73125039b37SCy Schubert	elxsi)
73225039b37SCy Schubert		cpu=elxsi
73325039b37SCy Schubert		vendor=elxsi
73425039b37SCy Schubert		basic_os=${basic_os:-bsd}
73525039b37SCy Schubert		;;
73625039b37SCy Schubert	fx2800)
73725039b37SCy Schubert		cpu=i860
73825039b37SCy Schubert		vendor=alliant
73925039b37SCy Schubert		;;
74025039b37SCy Schubert	genix)
74125039b37SCy Schubert		cpu=ns32k
74225039b37SCy Schubert		vendor=ns
74325039b37SCy Schubert		;;
74425039b37SCy Schubert	h3050r* | hiux*)
74525039b37SCy Schubert		cpu=hppa1.1
74625039b37SCy Schubert		vendor=hitachi
74725039b37SCy Schubert		basic_os=hiuxwe2
74825039b37SCy Schubert		;;
74925039b37SCy Schubert	hp3k9[0-9][0-9] | hp9[0-9][0-9])
75025039b37SCy Schubert		cpu=hppa1.0
75125039b37SCy Schubert		vendor=hp
75225039b37SCy Schubert		;;
75325039b37SCy Schubert	hp9k2[0-9][0-9] | hp9k31[0-9])
75425039b37SCy Schubert		cpu=m68000
75525039b37SCy Schubert		vendor=hp
75625039b37SCy Schubert		;;
75725039b37SCy Schubert	hp9k3[2-9][0-9])
75825039b37SCy Schubert		cpu=m68k
75925039b37SCy Schubert		vendor=hp
76025039b37SCy Schubert		;;
76125039b37SCy Schubert	hp9k6[0-9][0-9] | hp6[0-9][0-9])
76225039b37SCy Schubert		cpu=hppa1.0
76325039b37SCy Schubert		vendor=hp
76425039b37SCy Schubert		;;
76525039b37SCy Schubert	hp9k7[0-79][0-9] | hp7[0-79][0-9])
76625039b37SCy Schubert		cpu=hppa1.1
76725039b37SCy Schubert		vendor=hp
76825039b37SCy Schubert		;;
76925039b37SCy Schubert	hp9k78[0-9] | hp78[0-9])
77025039b37SCy Schubert		# FIXME: really hppa2.0-hp
77125039b37SCy Schubert		cpu=hppa1.1
77225039b37SCy Schubert		vendor=hp
77325039b37SCy Schubert		;;
77425039b37SCy Schubert	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
77525039b37SCy Schubert		# FIXME: really hppa2.0-hp
77625039b37SCy Schubert		cpu=hppa1.1
77725039b37SCy Schubert		vendor=hp
77825039b37SCy Schubert		;;
77925039b37SCy Schubert	hp9k8[0-9][13679] | hp8[0-9][13679])
78025039b37SCy Schubert		cpu=hppa1.1
78125039b37SCy Schubert		vendor=hp
78225039b37SCy Schubert		;;
78325039b37SCy Schubert	hp9k8[0-9][0-9] | hp8[0-9][0-9])
78425039b37SCy Schubert		cpu=hppa1.0
78525039b37SCy Schubert		vendor=hp
78625039b37SCy Schubert		;;
78725039b37SCy Schubert	i*86v32)
7885469a995SCy Schubert		cpu=`echo "$1" | sed -e 's/86.*/86/'`
78925039b37SCy Schubert		vendor=pc
79025039b37SCy Schubert		basic_os=sysv32
79125039b37SCy Schubert		;;
79225039b37SCy Schubert	i*86v4*)
7935469a995SCy Schubert		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79425039b37SCy Schubert		vendor=pc
79525039b37SCy Schubert		basic_os=sysv4
79625039b37SCy Schubert		;;
79725039b37SCy Schubert	i*86v)
7985469a995SCy Schubert		cpu=`echo "$1" | sed -e 's/86.*/86/'`
79925039b37SCy Schubert		vendor=pc
80025039b37SCy Schubert		basic_os=sysv
80125039b37SCy Schubert		;;
80225039b37SCy Schubert	i*86sol2)
8035469a995SCy Schubert		cpu=`echo "$1" | sed -e 's/86.*/86/'`
80425039b37SCy Schubert		vendor=pc
80525039b37SCy Schubert		basic_os=solaris2
80625039b37SCy Schubert		;;
80725039b37SCy Schubert	j90 | j90-cray)
80825039b37SCy Schubert		cpu=j90
80925039b37SCy Schubert		vendor=cray
81025039b37SCy Schubert		basic_os=${basic_os:-unicos}
81125039b37SCy Schubert		;;
81225039b37SCy Schubert	iris | iris4d)
81325039b37SCy Schubert		cpu=mips
81425039b37SCy Schubert		vendor=sgi
81525039b37SCy Schubert		case $basic_os in
81625039b37SCy Schubert		    irix*)
81725039b37SCy Schubert			;;
81825039b37SCy Schubert		    *)
81925039b37SCy Schubert			basic_os=irix4
82025039b37SCy Schubert			;;
82125039b37SCy Schubert		esac
82225039b37SCy Schubert		;;
82325039b37SCy Schubert	miniframe)
82425039b37SCy Schubert		cpu=m68000
82525039b37SCy Schubert		vendor=convergent
82625039b37SCy Schubert		;;
82725039b37SCy Schubert	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
82825039b37SCy Schubert		cpu=m68k
82925039b37SCy Schubert		vendor=atari
83025039b37SCy Schubert		basic_os=mint
83125039b37SCy Schubert		;;
83225039b37SCy Schubert	news-3600 | risc-news)
83325039b37SCy Schubert		cpu=mips
83425039b37SCy Schubert		vendor=sony
83525039b37SCy Schubert		basic_os=newsos
83625039b37SCy Schubert		;;
83725039b37SCy Schubert	next | m*-next)
83825039b37SCy Schubert		cpu=m68k
83925039b37SCy Schubert		vendor=next
84025039b37SCy Schubert		case $basic_os in
84125039b37SCy Schubert		    openstep*)
84225039b37SCy Schubert		        ;;
84325039b37SCy Schubert		    nextstep*)
84425039b37SCy Schubert			;;
84525039b37SCy Schubert		    ns2*)
84625039b37SCy Schubert		      basic_os=nextstep2
84725039b37SCy Schubert			;;
84825039b37SCy Schubert		    *)
84925039b37SCy Schubert		      basic_os=nextstep3
85025039b37SCy Schubert			;;
85125039b37SCy Schubert		esac
85225039b37SCy Schubert		;;
85325039b37SCy Schubert	np1)
85425039b37SCy Schubert		cpu=np1
85525039b37SCy Schubert		vendor=gould
85625039b37SCy Schubert		;;
85725039b37SCy Schubert	op50n-* | op60c-*)
85825039b37SCy Schubert		cpu=hppa1.1
85925039b37SCy Schubert		vendor=oki
86025039b37SCy Schubert		basic_os=proelf
86125039b37SCy Schubert		;;
86225039b37SCy Schubert	pa-hitachi)
86325039b37SCy Schubert		cpu=hppa1.1
86425039b37SCy Schubert		vendor=hitachi
86525039b37SCy Schubert		basic_os=hiuxwe2
86625039b37SCy Schubert		;;
86725039b37SCy Schubert	pbd)
86825039b37SCy Schubert		cpu=sparc
86925039b37SCy Schubert		vendor=tti
87025039b37SCy Schubert		;;
87125039b37SCy Schubert	pbb)
87225039b37SCy Schubert		cpu=m68k
87325039b37SCy Schubert		vendor=tti
87425039b37SCy Schubert		;;
87525039b37SCy Schubert	pc532)
87625039b37SCy Schubert		cpu=ns32k
87725039b37SCy Schubert		vendor=pc532
87825039b37SCy Schubert		;;
87925039b37SCy Schubert	pn)
88025039b37SCy Schubert		cpu=pn
88125039b37SCy Schubert		vendor=gould
88225039b37SCy Schubert		;;
88325039b37SCy Schubert	power)
88425039b37SCy Schubert		cpu=power
88525039b37SCy Schubert		vendor=ibm
88625039b37SCy Schubert		;;
88725039b37SCy Schubert	ps2)
88825039b37SCy Schubert		cpu=i386
88925039b37SCy Schubert		vendor=ibm
89025039b37SCy Schubert		;;
89125039b37SCy Schubert	rm[46]00)
89225039b37SCy Schubert		cpu=mips
89325039b37SCy Schubert		vendor=siemens
89425039b37SCy Schubert		;;
89525039b37SCy Schubert	rtpc | rtpc-*)
89625039b37SCy Schubert		cpu=romp
89725039b37SCy Schubert		vendor=ibm
89825039b37SCy Schubert		;;
89925039b37SCy Schubert	sde)
90025039b37SCy Schubert		cpu=mipsisa32
90125039b37SCy Schubert		vendor=sde
90225039b37SCy Schubert		basic_os=${basic_os:-elf}
90325039b37SCy Schubert		;;
90425039b37SCy Schubert	simso-wrs)
90525039b37SCy Schubert		cpu=sparclite
90625039b37SCy Schubert		vendor=wrs
90725039b37SCy Schubert		basic_os=vxworks
90825039b37SCy Schubert		;;
90925039b37SCy Schubert	tower | tower-32)
91025039b37SCy Schubert		cpu=m68k
91125039b37SCy Schubert		vendor=ncr
91225039b37SCy Schubert		;;
91325039b37SCy Schubert	vpp*|vx|vx-*)
91425039b37SCy Schubert		cpu=f301
91525039b37SCy Schubert		vendor=fujitsu
91625039b37SCy Schubert		;;
91725039b37SCy Schubert	w65)
91825039b37SCy Schubert		cpu=w65
91925039b37SCy Schubert		vendor=wdc
92025039b37SCy Schubert		;;
92125039b37SCy Schubert	w89k-*)
92225039b37SCy Schubert		cpu=hppa1.1
92325039b37SCy Schubert		vendor=winbond
92425039b37SCy Schubert		basic_os=proelf
92525039b37SCy Schubert		;;
92625039b37SCy Schubert	none)
92725039b37SCy Schubert		cpu=none
92825039b37SCy Schubert		vendor=none
92925039b37SCy Schubert		;;
93025039b37SCy Schubert	leon|leon[3-9])
93125039b37SCy Schubert		cpu=sparc
93225039b37SCy Schubert		vendor=$basic_machine
93325039b37SCy Schubert		;;
93425039b37SCy Schubert	leon-*|leon[3-9]-*)
93525039b37SCy Schubert		cpu=sparc
9365469a995SCy Schubert		vendor=`echo "$basic_machine" | sed 's/-.*//'`
93725039b37SCy Schubert		;;
93825039b37SCy Schubert
93925039b37SCy Schubert	*-*)
94025039b37SCy Schubert		# shellcheck disable=SC2162
94124e36522SCy Schubert		saved_IFS=$IFS
94225039b37SCy Schubert		IFS="-" read cpu vendor <<EOF
94325039b37SCy Schubert$basic_machine
94425039b37SCy SchubertEOF
94524e36522SCy Schubert		IFS=$saved_IFS
94625039b37SCy Schubert		;;
9478f76bb7dSCy Schubert	# We use 'pc' rather than 'unknown'
94825039b37SCy Schubert	# because (1) that's what they normally are, and
94925039b37SCy Schubert	# (2) the word "unknown" tends to confuse beginning users.
95025039b37SCy Schubert	i*86 | x86_64)
95125039b37SCy Schubert		cpu=$basic_machine
95225039b37SCy Schubert		vendor=pc
95325039b37SCy Schubert		;;
95425039b37SCy Schubert	# These rules are duplicated from below for sake of the special case above;
95525039b37SCy Schubert	# i.e. things that normalized to x86 arches should also default to "pc"
95625039b37SCy Schubert	pc98)
95725039b37SCy Schubert		cpu=i386
95825039b37SCy Schubert		vendor=pc
95925039b37SCy Schubert		;;
96025039b37SCy Schubert	x64 | amd64)
96125039b37SCy Schubert		cpu=x86_64
96225039b37SCy Schubert		vendor=pc
96325039b37SCy Schubert		;;
964b7579f77SDag-Erling Smørgrav	# Recognize the basic CPU types without company name.
96525039b37SCy Schubert	*)
96625039b37SCy Schubert		cpu=$basic_machine
96725039b37SCy Schubert		vendor=unknown
96825039b37SCy Schubert		;;
96925039b37SCy Schubertesac
97025039b37SCy Schubert
97125039b37SCy Schubertunset -v basic_machine
97225039b37SCy Schubert
97325039b37SCy Schubert# Decode basic machines in the full and proper CPU-Company form.
97425039b37SCy Schubertcase $cpu-$vendor in
97525039b37SCy Schubert	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
97625039b37SCy Schubert	# some cases the only manufacturer, in others, it is the most popular.
97725039b37SCy Schubert	craynv-unknown)
97825039b37SCy Schubert		vendor=cray
97925039b37SCy Schubert		basic_os=${basic_os:-unicosmp}
98025039b37SCy Schubert		;;
98125039b37SCy Schubert	c90-unknown | c90-cray)
98225039b37SCy Schubert		vendor=cray
98325039b37SCy Schubert		basic_os=${Basic_os:-unicos}
98425039b37SCy Schubert		;;
98525039b37SCy Schubert	fx80-unknown)
98625039b37SCy Schubert		vendor=alliant
98725039b37SCy Schubert		;;
98825039b37SCy Schubert	romp-unknown)
98925039b37SCy Schubert		vendor=ibm
99025039b37SCy Schubert		;;
99125039b37SCy Schubert	mmix-unknown)
99225039b37SCy Schubert		vendor=knuth
99325039b37SCy Schubert		;;
99425039b37SCy Schubert	microblaze-unknown | microblazeel-unknown)
99525039b37SCy Schubert		vendor=xilinx
99625039b37SCy Schubert		;;
99725039b37SCy Schubert	rs6000-unknown)
99825039b37SCy Schubert		vendor=ibm
99925039b37SCy Schubert		;;
100025039b37SCy Schubert	vax-unknown)
100125039b37SCy Schubert		vendor=dec
100225039b37SCy Schubert		;;
100325039b37SCy Schubert	pdp11-unknown)
100425039b37SCy Schubert		vendor=dec
100525039b37SCy Schubert		;;
100625039b37SCy Schubert	we32k-unknown)
100725039b37SCy Schubert		vendor=att
100825039b37SCy Schubert		;;
100925039b37SCy Schubert	cydra-unknown)
101025039b37SCy Schubert		vendor=cydrome
101125039b37SCy Schubert		;;
101225039b37SCy Schubert	i370-ibm*)
101325039b37SCy Schubert		vendor=ibm
101425039b37SCy Schubert		;;
101525039b37SCy Schubert	orion-unknown)
101625039b37SCy Schubert		vendor=highlevel
101725039b37SCy Schubert		;;
101825039b37SCy Schubert	xps-unknown | xps100-unknown)
101925039b37SCy Schubert		cpu=xps100
102025039b37SCy Schubert		vendor=honeywell
102125039b37SCy Schubert		;;
102225039b37SCy Schubert
102325039b37SCy Schubert	# Here we normalize CPU types with a missing or matching vendor
10249cf5bc93SCy Schubert	armh-unknown | armh-alt)
10259cf5bc93SCy Schubert		cpu=armv7l
10269cf5bc93SCy Schubert		vendor=alt
10279cf5bc93SCy Schubert		basic_os=${basic_os:-linux-gnueabihf}
10289cf5bc93SCy Schubert		;;
102925039b37SCy Schubert	dpx20-unknown | dpx20-bull)
103025039b37SCy Schubert		cpu=rs6000
103125039b37SCy Schubert		vendor=bull
103225039b37SCy Schubert		basic_os=${basic_os:-bosx}
103325039b37SCy Schubert		;;
103425039b37SCy Schubert
103525039b37SCy Schubert	# Here we normalize CPU types irrespective of the vendor
103625039b37SCy Schubert	amd64-*)
103725039b37SCy Schubert		cpu=x86_64
103825039b37SCy Schubert		;;
103925039b37SCy Schubert	blackfin-*)
104025039b37SCy Schubert		cpu=bfin
104125039b37SCy Schubert		basic_os=linux
104225039b37SCy Schubert		;;
104325039b37SCy Schubert	c54x-*)
104425039b37SCy Schubert		cpu=tic54x
104525039b37SCy Schubert		;;
104625039b37SCy Schubert	c55x-*)
104725039b37SCy Schubert		cpu=tic55x
104825039b37SCy Schubert		;;
104925039b37SCy Schubert	c6x-*)
105025039b37SCy Schubert		cpu=tic6x
105125039b37SCy Schubert		;;
105225039b37SCy Schubert	e500v[12]-*)
105325039b37SCy Schubert		cpu=powerpc
105425039b37SCy Schubert		basic_os=${basic_os}"spe"
105525039b37SCy Schubert		;;
105625039b37SCy Schubert	mips3*-*)
105725039b37SCy Schubert		cpu=mips64
105825039b37SCy Schubert		;;
105925039b37SCy Schubert	ms1-*)
106025039b37SCy Schubert		cpu=mt
106125039b37SCy Schubert		;;
106225039b37SCy Schubert	m68knommu-*)
106325039b37SCy Schubert		cpu=m68k
106425039b37SCy Schubert		basic_os=linux
106525039b37SCy Schubert		;;
106625039b37SCy Schubert	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
106725039b37SCy Schubert		cpu=s12z
106825039b37SCy Schubert		;;
106925039b37SCy Schubert	openrisc-*)
107025039b37SCy Schubert		cpu=or32
107125039b37SCy Schubert		;;
107225039b37SCy Schubert	parisc-*)
107325039b37SCy Schubert		cpu=hppa
107425039b37SCy Schubert		basic_os=linux
107525039b37SCy Schubert		;;
107625039b37SCy Schubert	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
107725039b37SCy Schubert		cpu=i586
107825039b37SCy Schubert		;;
10798f76bb7dSCy Schubert	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
108025039b37SCy Schubert		cpu=i686
108125039b37SCy Schubert		;;
108225039b37SCy Schubert	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
108325039b37SCy Schubert		cpu=i686
108425039b37SCy Schubert		;;
108525039b37SCy Schubert	pentium4-*)
108625039b37SCy Schubert		cpu=i786
108725039b37SCy Schubert		;;
108825039b37SCy Schubert	pc98-*)
108925039b37SCy Schubert		cpu=i386
109025039b37SCy Schubert		;;
109125039b37SCy Schubert	ppc-* | ppcbe-*)
109225039b37SCy Schubert		cpu=powerpc
109325039b37SCy Schubert		;;
109425039b37SCy Schubert	ppcle-* | powerpclittle-*)
109525039b37SCy Schubert		cpu=powerpcle
109625039b37SCy Schubert		;;
109725039b37SCy Schubert	ppc64-*)
109825039b37SCy Schubert		cpu=powerpc64
109925039b37SCy Schubert		;;
110025039b37SCy Schubert	ppc64le-* | powerpc64little-*)
110125039b37SCy Schubert		cpu=powerpc64le
110225039b37SCy Schubert		;;
110325039b37SCy Schubert	sb1-*)
110425039b37SCy Schubert		cpu=mipsisa64sb1
110525039b37SCy Schubert		;;
110625039b37SCy Schubert	sb1el-*)
110725039b37SCy Schubert		cpu=mipsisa64sb1el
110825039b37SCy Schubert		;;
110925039b37SCy Schubert	sh5e[lb]-*)
11105469a995SCy Schubert		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
111125039b37SCy Schubert		;;
111225039b37SCy Schubert	spur-*)
111325039b37SCy Schubert		cpu=spur
111425039b37SCy Schubert		;;
111525039b37SCy Schubert	strongarm-* | thumb-*)
111625039b37SCy Schubert		cpu=arm
111725039b37SCy Schubert		;;
111825039b37SCy Schubert	tx39-*)
111925039b37SCy Schubert		cpu=mipstx39
112025039b37SCy Schubert		;;
112125039b37SCy Schubert	tx39el-*)
112225039b37SCy Schubert		cpu=mipstx39el
112325039b37SCy Schubert		;;
112425039b37SCy Schubert	x64-*)
112525039b37SCy Schubert		cpu=x86_64
112625039b37SCy Schubert		;;
112725039b37SCy Schubert	xscale-* | xscalee[bl]-*)
11285469a995SCy Schubert		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
112925039b37SCy Schubert		;;
11309cf5bc93SCy Schubert	arm64-* | aarch64le-*)
113125039b37SCy Schubert		cpu=aarch64
113225039b37SCy Schubert		;;
113325039b37SCy Schubert
113425039b37SCy Schubert	# Recognize the canonical CPU Types that limit and/or modify the
113525039b37SCy Schubert	# company names they are paired with.
113625039b37SCy Schubert	cr16-*)
113725039b37SCy Schubert		basic_os=${basic_os:-elf}
113825039b37SCy Schubert		;;
113925039b37SCy Schubert	crisv32-* | etraxfs*-*)
114025039b37SCy Schubert		cpu=crisv32
114125039b37SCy Schubert		vendor=axis
114225039b37SCy Schubert		;;
114325039b37SCy Schubert	cris-* | etrax*-*)
114425039b37SCy Schubert		cpu=cris
114525039b37SCy Schubert		vendor=axis
114625039b37SCy Schubert		;;
114725039b37SCy Schubert	crx-*)
114825039b37SCy Schubert		basic_os=${basic_os:-elf}
114925039b37SCy Schubert		;;
115025039b37SCy Schubert	neo-tandem)
115125039b37SCy Schubert		cpu=neo
115225039b37SCy Schubert		vendor=tandem
115325039b37SCy Schubert		;;
115425039b37SCy Schubert	nse-tandem)
115525039b37SCy Schubert		cpu=nse
115625039b37SCy Schubert		vendor=tandem
115725039b37SCy Schubert		;;
115825039b37SCy Schubert	nsr-tandem)
115925039b37SCy Schubert		cpu=nsr
116025039b37SCy Schubert		vendor=tandem
116125039b37SCy Schubert		;;
116225039b37SCy Schubert	nsv-tandem)
116325039b37SCy Schubert		cpu=nsv
116425039b37SCy Schubert		vendor=tandem
116525039b37SCy Schubert		;;
116625039b37SCy Schubert	nsx-tandem)
116725039b37SCy Schubert		cpu=nsx
116825039b37SCy Schubert		vendor=tandem
116925039b37SCy Schubert		;;
117025039b37SCy Schubert	mipsallegrexel-sony)
117125039b37SCy Schubert		cpu=mipsallegrexel
117225039b37SCy Schubert		vendor=sony
117325039b37SCy Schubert		;;
117425039b37SCy Schubert	tile*-*)
117525039b37SCy Schubert		basic_os=${basic_os:-linux-gnu}
117625039b37SCy Schubert		;;
117725039b37SCy Schubert
117825039b37SCy Schubert	*)
117925039b37SCy Schubert		# Recognize the canonical CPU types that are allowed with any
118025039b37SCy Schubert		# company name.
118125039b37SCy Schubert		case $cpu in
1182b7579f77SDag-Erling Smørgrav			1750a | 580 \
1183b7579f77SDag-Erling Smørgrav			| a29k \
1184103ba509SCy Schubert			| aarch64 | aarch64_be | aarch64c | arm64ec \
118525039b37SCy Schubert			| abacus \
118625039b37SCy Schubert			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
118725039b37SCy Schubert			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
118825039b37SCy Schubert			| alphapca5[67] | alpha64pca5[67] \
1189b7579f77SDag-Erling Smørgrav			| am33_2.0 \
119025039b37SCy Schubert			| amdgcn \
11915469a995SCy Schubert			| arc | arceb | arc32 | arc64 \
119225039b37SCy Schubert			| arm | arm[lb]e | arme[lb] | armv* \
1193ff825849SDag-Erling Smørgrav			| avr | avr32 \
119425039b37SCy Schubert			| asmjs \
11958157cbabSDag-Erling Smørgrav			| ba \
11968ed2b524SDag-Erling Smørgrav			| be32 | be64 \
119725039b37SCy Schubert			| bfin | bpf | bs2000 \
119825039b37SCy Schubert			| c[123]* | c30 | [cjt]90 | c4x \
119925039b37SCy Schubert			| c8051 | clipper | craynv | csky | cydra \
1200b7579f77SDag-Erling Smørgrav			| d10v | d30v | dlx | dsp16xx \
120125039b37SCy Schubert			| e2k | elxsi | epiphany \
120225039b37SCy Schubert			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1203103ba509SCy Schubert			| javascript \
120425039b37SCy Schubert			| h8300 | h8500 \
120525039b37SCy Schubert			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12068ed2b524SDag-Erling Smørgrav			| hexagon \
120725039b37SCy Schubert			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1208b7579f77SDag-Erling Smørgrav			| ip2k | iq2000 \
12098157cbabSDag-Erling Smørgrav			| k1om \
12108f76bb7dSCy Schubert			| kvx \
12118ed2b524SDag-Erling Smørgrav			| le32 | le64 \
1212b7579f77SDag-Erling Smørgrav			| lm32 \
12134f5c8956SCy Schubert			| loongarch32 | loongarch64 \
121425039b37SCy Schubert			| m32c | m32r | m32rle \
121525039b37SCy Schubert			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
121625039b37SCy Schubert			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
121725039b37SCy Schubert			| m88110 | m88k | maxq | mb | mcore | mep | metag \
121825039b37SCy Schubert			| microblaze | microblazeel \
12198f76bb7dSCy Schubert			| mips* \
122025039b37SCy Schubert			| mmix \
1221b7579f77SDag-Erling Smørgrav			| mn10200 | mn10300 \
1222b7579f77SDag-Erling Smørgrav			| moxie \
1223b7579f77SDag-Erling Smørgrav			| mt \
1224b7579f77SDag-Erling Smørgrav			| msp430 \
1225b76ef9a7SCy Schubert			| nanomips* \
12268ed2b524SDag-Erling Smørgrav			| nds32 | nds32le | nds32be \
122725039b37SCy Schubert			| nfp \
1228ff825849SDag-Erling Smørgrav			| nios | nios2 | nios2eb | nios2el \
122925039b37SCy Schubert			| none | np1 | ns16k | ns32k | nvptx \
123025039b37SCy Schubert			| open8 \
123125039b37SCy Schubert			| or1k* \
123225039b37SCy Schubert			| or32 \
123325039b37SCy Schubert			| orion \
123425039b37SCy Schubert			| picochip \
123525039b37SCy Schubert			| pdp10 | pdp11 | pj | pjl | pn | power \
123625039b37SCy Schubert			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
123725039b37SCy Schubert			| pru \
1238b7579f77SDag-Erling Smørgrav			| pyramid \
1239f44e67d1SCy Schubert			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
124025039b37SCy Schubert			| rl78 | romp | rs6000 | rx \
124125039b37SCy Schubert			| s390 | s390x \
1242b7579f77SDag-Erling Smørgrav			| score \
124325039b37SCy Schubert			| sh | shl \
124425039b37SCy Schubert			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
124525039b37SCy Schubert			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
124625039b37SCy Schubert			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
124725039b37SCy Schubert			| sparclite \
124825039b37SCy Schubert			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12498ed2b524SDag-Erling Smørgrav			| spu \
125025039b37SCy Schubert			| tahoe \
1251369c6923SCy Schubert			| thumbv7* \
125225039b37SCy Schubert			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
125325039b37SCy Schubert			| tron \
1254b7579f77SDag-Erling Smørgrav			| ubicom32 \
125525039b37SCy Schubert			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
125625039b37SCy Schubert			| vax \
1257b76ef9a7SCy Schubert			| vc4 \
12588157cbabSDag-Erling Smørgrav			| visium \
125925039b37SCy Schubert			| w65 \
126025039b37SCy Schubert			| wasm32 | wasm64 \
1261091e9e46SCy Schubert			| we32k \
126225039b37SCy Schubert			| x86 | x86_64 | xc16x | xgate | xps100 \
126325039b37SCy Schubert			| xstormy16 | xtensa* \
126425039b37SCy Schubert			| ymp \
1265b7579f77SDag-Erling Smørgrav			| z8k | z80)
1266b7579f77SDag-Erling Smørgrav				;;
1267b7579f77SDag-Erling Smørgrav
126825039b37SCy Schubert			*)
12698f76bb7dSCy Schubert				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1270b7579f77SDag-Erling Smørgrav				exit 1
1271b7579f77SDag-Erling Smørgrav				;;
1272b7579f77SDag-Erling Smørgrav		esac
1273b7579f77SDag-Erling Smørgrav		;;
1274b7579f77SDag-Erling Smørgravesac
1275b7579f77SDag-Erling Smørgrav
1276b7579f77SDag-Erling Smørgrav# Here we canonicalize certain aliases for manufacturers.
127725039b37SCy Schubertcase $vendor in
127825039b37SCy Schubert	digital*)
127925039b37SCy Schubert		vendor=dec
1280b7579f77SDag-Erling Smørgrav		;;
128125039b37SCy Schubert	commodore*)
128225039b37SCy Schubert		vendor=cbm
1283b7579f77SDag-Erling Smørgrav		;;
1284b7579f77SDag-Erling Smørgrav	*)
1285b7579f77SDag-Erling Smørgrav		;;
1286b7579f77SDag-Erling Smørgravesac
1287b7579f77SDag-Erling Smørgrav
1288b7579f77SDag-Erling Smørgrav# Decode manufacturer-specific aliases for certain operating systems.
1289b7579f77SDag-Erling Smørgrav
1290103ba509SCy Schubertif test x"$basic_os" != x
1291b7579f77SDag-Erling Smørgravthen
129225039b37SCy Schubert
12939cf5bc93SCy Schubert# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
129425039b37SCy Schubert# set os.
1295103ba509SCy Schubertobj=
129625039b37SCy Schubertcase $basic_os in
129725039b37SCy Schubert	gnu/linux*)
129825039b37SCy Schubert		kernel=linux
12995469a995SCy Schubert		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1300369c6923SCy Schubert		;;
1301369c6923SCy Schubert	os2-emx)
1302369c6923SCy Schubert		kernel=os2
13035469a995SCy Schubert		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1304b7579f77SDag-Erling Smørgrav		;;
130525039b37SCy Schubert	nto-qnx*)
130625039b37SCy Schubert		kernel=nto
13075469a995SCy Schubert		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
130825039b37SCy Schubert		;;
130925039b37SCy Schubert	*-*)
131025039b37SCy Schubert		# shellcheck disable=SC2162
131124e36522SCy Schubert		saved_IFS=$IFS
131225039b37SCy Schubert		IFS="-" read kernel os <<EOF
131325039b37SCy Schubert$basic_os
131425039b37SCy SchubertEOF
131524e36522SCy Schubert		IFS=$saved_IFS
131625039b37SCy Schubert		;;
131725039b37SCy Schubert	# Default OS when just kernel was specified
131825039b37SCy Schubert	nto*)
131925039b37SCy Schubert		kernel=nto
13205469a995SCy Schubert		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
132125039b37SCy Schubert		;;
132225039b37SCy Schubert	linux*)
132325039b37SCy Schubert		kernel=linux
13245469a995SCy Schubert		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
132525039b37SCy Schubert		;;
1326865f46b2SCy Schubert	managarm*)
1327865f46b2SCy Schubert		kernel=managarm
1328865f46b2SCy Schubert		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1329865f46b2SCy Schubert		;;
133025039b37SCy Schubert	*)
133125039b37SCy Schubert		kernel=
133225039b37SCy Schubert		os=$basic_os
133325039b37SCy Schubert		;;
133425039b37SCy Schubertesac
133525039b37SCy Schubert
133625039b37SCy Schubert# Now, normalize the OS (knowing we just have one component, it's not a kernel,
133725039b37SCy Schubert# etc.)
133825039b37SCy Schubertcase $os in
133925039b37SCy Schubert	# First match some system type aliases that might get confused
134025039b37SCy Schubert	# with valid system types.
134125039b37SCy Schubert	# solaris* is a basic system type, with this one exception.
134225039b37SCy Schubert	auroraux)
134325039b37SCy Schubert		os=auroraux
134425039b37SCy Schubert		;;
134525039b37SCy Schubert	bluegene*)
134625039b37SCy Schubert		os=cnk
134725039b37SCy Schubert		;;
134825039b37SCy Schubert	solaris1 | solaris1.*)
13495469a995SCy Schubert		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1350b7579f77SDag-Erling Smørgrav		;;
135125039b37SCy Schubert	solaris)
135225039b37SCy Schubert		os=solaris2
1353b7579f77SDag-Erling Smørgrav		;;
135425039b37SCy Schubert	unixware*)
135525039b37SCy Schubert		os=sysv4.2uw
1356091e9e46SCy Schubert		;;
135725039b37SCy Schubert	# es1800 is here to avoid being matched by es* (a different OS)
135825039b37SCy Schubert	es1800*)
135925039b37SCy Schubert		os=ose
1360b7579f77SDag-Erling Smørgrav		;;
136125039b37SCy Schubert	# Some version numbers need modification
136225039b37SCy Schubert	chorusos*)
136325039b37SCy Schubert		os=chorusos
1364b7579f77SDag-Erling Smørgrav		;;
136525039b37SCy Schubert	isc)
136625039b37SCy Schubert		os=isc2.2
1367b7579f77SDag-Erling Smørgrav		;;
136825039b37SCy Schubert	sco6)
136925039b37SCy Schubert		os=sco5v6
137025039b37SCy Schubert		;;
137125039b37SCy Schubert	sco5)
137225039b37SCy Schubert		os=sco3.2v5
137325039b37SCy Schubert		;;
137425039b37SCy Schubert	sco4)
137525039b37SCy Schubert		os=sco3.2v4
137625039b37SCy Schubert		;;
137725039b37SCy Schubert	sco3.2.[4-9]*)
13785469a995SCy Schubert		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
137925039b37SCy Schubert		;;
138025039b37SCy Schubert	sco*v* | scout)
138125039b37SCy Schubert		# Don't match below
138225039b37SCy Schubert		;;
138325039b37SCy Schubert	sco*)
138425039b37SCy Schubert		os=sco3.2v2
138525039b37SCy Schubert		;;
138625039b37SCy Schubert	psos*)
138725039b37SCy Schubert		os=psos
138825039b37SCy Schubert		;;
138925039b37SCy Schubert	qnx*)
1390c0caa2e2SCy Schubert		os=qnx
1391b7579f77SDag-Erling Smørgrav		;;
139225039b37SCy Schubert	hiux*)
139325039b37SCy Schubert		os=hiuxwe2
1394b7579f77SDag-Erling Smørgrav		;;
139525039b37SCy Schubert	lynx*178)
139625039b37SCy Schubert		os=lynxos178
1397b7579f77SDag-Erling Smørgrav		;;
139825039b37SCy Schubert	lynx*5)
139925039b37SCy Schubert		os=lynxos5
1400b7579f77SDag-Erling Smørgrav		;;
140125039b37SCy Schubert	lynxos*)
140225039b37SCy Schubert		# don't get caught up in next wildcard
1403b7579f77SDag-Erling Smørgrav		;;
140425039b37SCy Schubert	lynx*)
140525039b37SCy Schubert		os=lynxos
1406b7579f77SDag-Erling Smørgrav		;;
140725039b37SCy Schubert	mac[0-9]*)
14085469a995SCy Schubert		os=`echo "$os" | sed -e 's|mac|macos|'`
1409b7579f77SDag-Erling Smørgrav		;;
141025039b37SCy Schubert	opened*)
141125039b37SCy Schubert		os=openedition
1412b7579f77SDag-Erling Smørgrav		;;
141325039b37SCy Schubert	os400*)
141425039b37SCy Schubert		os=os400
1415b7579f77SDag-Erling Smørgrav		;;
141625039b37SCy Schubert	sunos5*)
14175469a995SCy Schubert		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1418b7579f77SDag-Erling Smørgrav		;;
141925039b37SCy Schubert	sunos6*)
14205469a995SCy Schubert		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1421b7579f77SDag-Erling Smørgrav		;;
142225039b37SCy Schubert	wince*)
142325039b37SCy Schubert		os=wince
1424b7579f77SDag-Erling Smørgrav		;;
142525039b37SCy Schubert	utek*)
142625039b37SCy Schubert		os=bsd
1427091e9e46SCy Schubert		;;
142825039b37SCy Schubert	dynix*)
142925039b37SCy Schubert		os=bsd
1430091e9e46SCy Schubert		;;
143125039b37SCy Schubert	acis*)
143225039b37SCy Schubert		os=aos
1433b7579f77SDag-Erling Smørgrav		;;
143425039b37SCy Schubert	atheos*)
143525039b37SCy Schubert		os=atheos
1436b7579f77SDag-Erling Smørgrav		;;
143725039b37SCy Schubert	syllable*)
143825039b37SCy Schubert		os=syllable
1439b7579f77SDag-Erling Smørgrav		;;
144025039b37SCy Schubert	386bsd)
144125039b37SCy Schubert		os=bsd
1442b7579f77SDag-Erling Smørgrav		;;
144325039b37SCy Schubert	ctix* | uts*)
144425039b37SCy Schubert		os=sysv
1445b7579f77SDag-Erling Smørgrav		;;
144625039b37SCy Schubert	nova*)
144725039b37SCy Schubert		os=rtmk-nova
1448b7579f77SDag-Erling Smørgrav		;;
144925039b37SCy Schubert	ns2)
145025039b37SCy Schubert		os=nextstep2
1451b7579f77SDag-Erling Smørgrav		;;
1452b7579f77SDag-Erling Smørgrav	# Preserve the version number of sinix5.
145325039b37SCy Schubert	sinix5.*)
14545469a995SCy Schubert		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1455b7579f77SDag-Erling Smørgrav		;;
145625039b37SCy Schubert	sinix*)
145725039b37SCy Schubert		os=sysv4
1458b7579f77SDag-Erling Smørgrav		;;
145925039b37SCy Schubert	tpf*)
146025039b37SCy Schubert		os=tpf
1461b7579f77SDag-Erling Smørgrav		;;
146225039b37SCy Schubert	triton*)
146325039b37SCy Schubert		os=sysv3
1464b7579f77SDag-Erling Smørgrav		;;
146525039b37SCy Schubert	oss*)
146625039b37SCy Schubert		os=sysv3
1467b7579f77SDag-Erling Smørgrav		;;
146825039b37SCy Schubert	svr4*)
146925039b37SCy Schubert		os=sysv4
1470b7579f77SDag-Erling Smørgrav		;;
147125039b37SCy Schubert	svr3)
147225039b37SCy Schubert		os=sysv3
1473b7579f77SDag-Erling Smørgrav		;;
147425039b37SCy Schubert	sysvr4)
147525039b37SCy Schubert		os=sysv4
1476b7579f77SDag-Erling Smørgrav		;;
147725039b37SCy Schubert	ose*)
147825039b37SCy Schubert		os=ose
1479b7579f77SDag-Erling Smørgrav		;;
148025039b37SCy Schubert	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
148125039b37SCy Schubert		os=mint
1482b7579f77SDag-Erling Smørgrav		;;
148325039b37SCy Schubert	dicos*)
148425039b37SCy Schubert		os=dicos
1485091e9e46SCy Schubert		;;
148625039b37SCy Schubert	pikeos*)
148725039b37SCy Schubert		# Until real need of OS specific support for
148825039b37SCy Schubert		# particular features comes up, bare metal
148925039b37SCy Schubert		# configurations are quite functional.
149025039b37SCy Schubert		case $cpu in
149125039b37SCy Schubert		    arm*)
149225039b37SCy Schubert			os=eabi
1493b7579f77SDag-Erling Smørgrav			;;
1494b7579f77SDag-Erling Smørgrav		    *)
1495103ba509SCy Schubert			os=
1496103ba509SCy Schubert			obj=elf
1497b7579f77SDag-Erling Smørgrav			;;
1498b7579f77SDag-Erling Smørgrav		esac
149925039b37SCy Schubert		;;
1500103ba509SCy Schubert	aout* | coff* | elf* | pe*)
1501103ba509SCy Schubert		# These are machine code file formats, not OSes
1502103ba509SCy Schubert		obj=$os
1503103ba509SCy Schubert		os=
1504103ba509SCy Schubert		;;
150525039b37SCy Schubert	*)
150625039b37SCy Schubert		# No normalization, but not necessarily accepted, that comes below.
150725039b37SCy Schubert		;;
150825039b37SCy Schubertesac
150925039b37SCy Schubert
1510b7579f77SDag-Erling Smørgravelse
1511b7579f77SDag-Erling Smørgrav
1512b7579f77SDag-Erling Smørgrav# Here we handle the default operating systems that come with various machines.
1513b7579f77SDag-Erling Smørgrav# The value should be what the vendor currently ships out the door with their
1514b7579f77SDag-Erling Smørgrav# machine or put another way, the most popular os provided with the machine.
1515b7579f77SDag-Erling Smørgrav
1516b7579f77SDag-Erling Smørgrav# Note that if you're going to try to match "-MANUFACTURER" here (say,
1517b7579f77SDag-Erling Smørgrav# "-sun"), then you have to tell the case statement up towards the top
1518b7579f77SDag-Erling Smørgrav# that MANUFACTURER isn't an operating system.  Otherwise, code above
1519b7579f77SDag-Erling Smørgrav# will signal an error saying that MANUFACTURER isn't an operating
1520b7579f77SDag-Erling Smørgrav# system, and we'll never get to this point.
1521b7579f77SDag-Erling Smørgrav
152225039b37SCy Schubertkernel=
1523103ba509SCy Schubertobj=
152425039b37SCy Schubertcase $cpu-$vendor in
1525b7579f77SDag-Erling Smørgrav	score-*)
1526103ba509SCy Schubert		os=
1527103ba509SCy Schubert		obj=elf
1528b7579f77SDag-Erling Smørgrav		;;
1529b7579f77SDag-Erling Smørgrav	spu-*)
1530103ba509SCy Schubert		os=
1531103ba509SCy Schubert		obj=elf
1532b7579f77SDag-Erling Smørgrav		;;
1533b7579f77SDag-Erling Smørgrav	*-acorn)
153425039b37SCy Schubert		os=riscix1.2
1535b7579f77SDag-Erling Smørgrav		;;
1536b7579f77SDag-Erling Smørgrav	arm*-rebel)
153725039b37SCy Schubert		kernel=linux
153825039b37SCy Schubert		os=gnu
1539b7579f77SDag-Erling Smørgrav		;;
1540b7579f77SDag-Erling Smørgrav	arm*-semi)
1541103ba509SCy Schubert		os=
1542103ba509SCy Schubert		obj=aout
1543b7579f77SDag-Erling Smørgrav		;;
1544b7579f77SDag-Erling Smørgrav	c4x-* | tic4x-*)
1545103ba509SCy Schubert		os=
1546103ba509SCy Schubert		obj=coff
1547b7579f77SDag-Erling Smørgrav		;;
1548ff825849SDag-Erling Smørgrav	c8051-*)
1549103ba509SCy Schubert		os=
1550103ba509SCy Schubert		obj=elf
155125039b37SCy Schubert		;;
155225039b37SCy Schubert	clipper-intergraph)
155325039b37SCy Schubert		os=clix
1554ff825849SDag-Erling Smørgrav		;;
15558ed2b524SDag-Erling Smørgrav	hexagon-*)
1556103ba509SCy Schubert		os=
1557103ba509SCy Schubert		obj=elf
15588ed2b524SDag-Erling Smørgrav		;;
15598ed2b524SDag-Erling Smørgrav	tic54x-*)
1560103ba509SCy Schubert		os=
1561103ba509SCy Schubert		obj=coff
15628ed2b524SDag-Erling Smørgrav		;;
15638ed2b524SDag-Erling Smørgrav	tic55x-*)
1564103ba509SCy Schubert		os=
1565103ba509SCy Schubert		obj=coff
15668ed2b524SDag-Erling Smørgrav		;;
15678ed2b524SDag-Erling Smørgrav	tic6x-*)
1568103ba509SCy Schubert		os=
1569103ba509SCy Schubert		obj=coff
15708ed2b524SDag-Erling Smørgrav		;;
1571b7579f77SDag-Erling Smørgrav	# This must come before the *-dec entry.
1572b7579f77SDag-Erling Smørgrav	pdp10-*)
157325039b37SCy Schubert		os=tops20
1574b7579f77SDag-Erling Smørgrav		;;
1575b7579f77SDag-Erling Smørgrav	pdp11-*)
157625039b37SCy Schubert		os=none
1577b7579f77SDag-Erling Smørgrav		;;
1578b7579f77SDag-Erling Smørgrav	*-dec | vax-*)
157925039b37SCy Schubert		os=ultrix4.2
1580b7579f77SDag-Erling Smørgrav		;;
1581b7579f77SDag-Erling Smørgrav	m68*-apollo)
158225039b37SCy Schubert		os=domain
1583b7579f77SDag-Erling Smørgrav		;;
1584b7579f77SDag-Erling Smørgrav	i386-sun)
158525039b37SCy Schubert		os=sunos4.0.2
1586b7579f77SDag-Erling Smørgrav		;;
1587b7579f77SDag-Erling Smørgrav	m68000-sun)
158825039b37SCy Schubert		os=sunos3
1589b7579f77SDag-Erling Smørgrav		;;
1590b7579f77SDag-Erling Smørgrav	m68*-cisco)
1591103ba509SCy Schubert		os=
1592103ba509SCy Schubert		obj=aout
1593b7579f77SDag-Erling Smørgrav		;;
1594b7579f77SDag-Erling Smørgrav	mep-*)
1595103ba509SCy Schubert		os=
1596103ba509SCy Schubert		obj=elf
1597b7579f77SDag-Erling Smørgrav		;;
1598b7579f77SDag-Erling Smørgrav	mips*-cisco)
1599103ba509SCy Schubert		os=
1600103ba509SCy Schubert		obj=elf
1601b7579f77SDag-Erling Smørgrav		;;
1602b76ef9a7SCy Schubert	mips*-*|nanomips*-*)
1603103ba509SCy Schubert		os=
1604103ba509SCy Schubert		obj=elf
1605b7579f77SDag-Erling Smørgrav		;;
1606b7579f77SDag-Erling Smørgrav	or32-*)
1607103ba509SCy Schubert		os=
1608103ba509SCy Schubert		obj=coff
1609b7579f77SDag-Erling Smørgrav		;;
1610b7579f77SDag-Erling Smørgrav	*-tti)	# must be before sparc entry or we get the wrong os.
161125039b37SCy Schubert		os=sysv3
1612b7579f77SDag-Erling Smørgrav		;;
1613b7579f77SDag-Erling Smørgrav	sparc-* | *-sun)
161425039b37SCy Schubert		os=sunos4.1.1
161525039b37SCy Schubert		;;
161625039b37SCy Schubert	pru-*)
1617103ba509SCy Schubert		os=
1618103ba509SCy Schubert		obj=elf
1619b7579f77SDag-Erling Smørgrav		;;
1620b7579f77SDag-Erling Smørgrav	*-be)
162125039b37SCy Schubert		os=beos
1622091e9e46SCy Schubert		;;
1623b7579f77SDag-Erling Smørgrav	*-ibm)
162425039b37SCy Schubert		os=aix
1625b7579f77SDag-Erling Smørgrav		;;
1626b7579f77SDag-Erling Smørgrav	*-knuth)
162725039b37SCy Schubert		os=mmixware
1628b7579f77SDag-Erling Smørgrav		;;
1629b7579f77SDag-Erling Smørgrav	*-wec)
163025039b37SCy Schubert		os=proelf
1631b7579f77SDag-Erling Smørgrav		;;
1632b7579f77SDag-Erling Smørgrav	*-winbond)
163325039b37SCy Schubert		os=proelf
1634b7579f77SDag-Erling Smørgrav		;;
1635b7579f77SDag-Erling Smørgrav	*-oki)
163625039b37SCy Schubert		os=proelf
1637b7579f77SDag-Erling Smørgrav		;;
1638b7579f77SDag-Erling Smørgrav	*-hp)
163925039b37SCy Schubert		os=hpux
1640b7579f77SDag-Erling Smørgrav		;;
1641b7579f77SDag-Erling Smørgrav	*-hitachi)
164225039b37SCy Schubert		os=hiux
1643b7579f77SDag-Erling Smørgrav		;;
1644b7579f77SDag-Erling Smørgrav	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
164525039b37SCy Schubert		os=sysv
1646b7579f77SDag-Erling Smørgrav		;;
1647b7579f77SDag-Erling Smørgrav	*-cbm)
164825039b37SCy Schubert		os=amigaos
1649b7579f77SDag-Erling Smørgrav		;;
1650b7579f77SDag-Erling Smørgrav	*-dg)
165125039b37SCy Schubert		os=dgux
1652b7579f77SDag-Erling Smørgrav		;;
1653b7579f77SDag-Erling Smørgrav	*-dolphin)
165425039b37SCy Schubert		os=sysv3
1655b7579f77SDag-Erling Smørgrav		;;
1656b7579f77SDag-Erling Smørgrav	m68k-ccur)
165725039b37SCy Schubert		os=rtu
1658b7579f77SDag-Erling Smørgrav		;;
1659b7579f77SDag-Erling Smørgrav	m88k-omron*)
166025039b37SCy Schubert		os=luna
1661b7579f77SDag-Erling Smørgrav		;;
1662b7579f77SDag-Erling Smørgrav	*-next)
166325039b37SCy Schubert		os=nextstep
1664b7579f77SDag-Erling Smørgrav		;;
1665b7579f77SDag-Erling Smørgrav	*-sequent)
166625039b37SCy Schubert		os=ptx
1667b7579f77SDag-Erling Smørgrav		;;
1668b7579f77SDag-Erling Smørgrav	*-crds)
166925039b37SCy Schubert		os=unos
1670b7579f77SDag-Erling Smørgrav		;;
1671b7579f77SDag-Erling Smørgrav	*-ns)
167225039b37SCy Schubert		os=genix
1673b7579f77SDag-Erling Smørgrav		;;
1674b7579f77SDag-Erling Smørgrav	i370-*)
167525039b37SCy Schubert		os=mvs
1676091e9e46SCy Schubert		;;
1677b7579f77SDag-Erling Smørgrav	*-gould)
167825039b37SCy Schubert		os=sysv
1679b7579f77SDag-Erling Smørgrav		;;
1680b7579f77SDag-Erling Smørgrav	*-highlevel)
168125039b37SCy Schubert		os=bsd
1682b7579f77SDag-Erling Smørgrav		;;
1683b7579f77SDag-Erling Smørgrav	*-encore)
168425039b37SCy Schubert		os=bsd
1685b7579f77SDag-Erling Smørgrav		;;
1686b7579f77SDag-Erling Smørgrav	*-sgi)
168725039b37SCy Schubert		os=irix
1688b7579f77SDag-Erling Smørgrav		;;
1689b7579f77SDag-Erling Smørgrav	*-siemens)
169025039b37SCy Schubert		os=sysv4
1691b7579f77SDag-Erling Smørgrav		;;
1692b7579f77SDag-Erling Smørgrav	*-masscomp)
169325039b37SCy Schubert		os=rtu
1694b7579f77SDag-Erling Smørgrav		;;
1695b7579f77SDag-Erling Smørgrav	f30[01]-fujitsu | f700-fujitsu)
169625039b37SCy Schubert		os=uxpv
1697b7579f77SDag-Erling Smørgrav		;;
1698b7579f77SDag-Erling Smørgrav	*-rom68k)
1699103ba509SCy Schubert		os=
1700103ba509SCy Schubert		obj=coff
1701b7579f77SDag-Erling Smørgrav		;;
1702b7579f77SDag-Erling Smørgrav	*-*bug)
1703103ba509SCy Schubert		os=
1704103ba509SCy Schubert		obj=coff
1705b7579f77SDag-Erling Smørgrav		;;
1706b7579f77SDag-Erling Smørgrav	*-apple)
170725039b37SCy Schubert		os=macos
1708b7579f77SDag-Erling Smørgrav		;;
1709b7579f77SDag-Erling Smørgrav	*-atari*)
171025039b37SCy Schubert		os=mint
171125039b37SCy Schubert		;;
171225039b37SCy Schubert	*-wrs)
171325039b37SCy Schubert		os=vxworks
1714b7579f77SDag-Erling Smørgrav		;;
1715b7579f77SDag-Erling Smørgrav	*)
171625039b37SCy Schubert		os=none
1717b7579f77SDag-Erling Smørgrav		;;
1718b7579f77SDag-Erling Smørgravesac
171925039b37SCy Schubert
1720b7579f77SDag-Erling Smørgravfi
1721b7579f77SDag-Erling Smørgrav
1722103ba509SCy Schubert# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
1723103ba509SCy Schubert
172425039b37SCy Schubertcase $os in
1725f44e67d1SCy Schubert	# Sometimes we do "kernel-libc", so those need to count as OSes.
1726b76ef9a7SCy Schubert	llvm* | musl* | newlib* | relibc* | uclibc*)
172725039b37SCy Schubert		;;
1728f44e67d1SCy Schubert	# Likewise for "kernel-abi"
1729f44e67d1SCy Schubert	eabi* | gnueabi*)
1730f44e67d1SCy Schubert		;;
1731f44e67d1SCy Schubert	# VxWorks passes extra cpu info in the 4th filed.
1732f44e67d1SCy Schubert	simlinux | simwindows | spe)
173325039b37SCy Schubert		;;
1734103ba509SCy Schubert	# See `case $cpu-$os` validation below
1735103ba509SCy Schubert	ghcjs)
1736103ba509SCy Schubert		;;
173725039b37SCy Schubert	# Now accept the basic system types.
173825039b37SCy Schubert	# The portable systems comes first.
173925039b37SCy Schubert	# Each alternative MUST end in a * to match a version number.
174025039b37SCy Schubert	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
174125039b37SCy Schubert	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
174225039b37SCy Schubert	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
174325039b37SCy Schubert	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
174425039b37SCy Schubert	     | hiux* | abug | nacl* | netware* | windows* \
17458f76bb7dSCy Schubert	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
174625039b37SCy Schubert	     | mpw* | magic* | mmixware* | mon960* | lnews* \
174725039b37SCy Schubert	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
174825039b37SCy Schubert	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
174925039b37SCy Schubert	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
175025039b37SCy Schubert	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
175125039b37SCy Schubert	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17525469a995SCy Schubert	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
175325039b37SCy Schubert	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1754103ba509SCy Schubert	     | bosx* | nextstep* | cxux* | oabi* \
1755103ba509SCy Schubert	     | ptx* | ecoff* | winnt* | domain* | vsta* \
175625039b37SCy Schubert	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17575469a995SCy Schubert	     | chorusrdb* | cegcc* | glidix* | serenity* \
1758103ba509SCy Schubert	     | cygwin* | msys* | moss* | proelf* | rtems* \
175925039b37SCy Schubert	     | midipix* | mingw32* | mingw64* | mint* \
176025039b37SCy Schubert	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
176125039b37SCy Schubert	     | interix* | uwin* | mks* | rhapsody* | darwin* \
176225039b37SCy Schubert	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
176325039b37SCy Schubert	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
176425039b37SCy Schubert	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
176525039b37SCy Schubert	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
176625039b37SCy Schubert	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
176725039b37SCy Schubert	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
176825039b37SCy Schubert	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
176925039b37SCy Schubert	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
17709cf5bc93SCy Schubert	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1771b76ef9a7SCy Schubert	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
177225039b37SCy Schubert		;;
177325039b37SCy Schubert	# This one is extra strict with allowed versions
177425039b37SCy Schubert	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
177525039b37SCy Schubert		# Don't forget version if it is 3.2v4 or newer.
177625039b37SCy Schubert		;;
1777b76ef9a7SCy Schubert	# This refers to builds using the UEFI calling convention
1778b76ef9a7SCy Schubert	# (which depends on the architecture) and PE file format.
1779b76ef9a7SCy Schubert	# Note that this is both a different calling convention and
1780b76ef9a7SCy Schubert	# different file format than that of GNU-EFI
1781b76ef9a7SCy Schubert	# (x86_64-w64-mingw32).
1782b76ef9a7SCy Schubert	uefi)
1783b76ef9a7SCy Schubert		;;
178425039b37SCy Schubert	none)
178525039b37SCy Schubert		;;
17868f76bb7dSCy Schubert	kernel* | msvc* )
1787865f46b2SCy Schubert		# Restricted further below
1788865f46b2SCy Schubert		;;
1789103ba509SCy Schubert	'')
1790103ba509SCy Schubert		if test x"$obj" = x
1791103ba509SCy Schubert		then
1792103ba509SCy Schubert			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
1793103ba509SCy Schubert		fi
1794103ba509SCy Schubert		;;
179525039b37SCy Schubert	*)
17968f76bb7dSCy Schubert		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
179725039b37SCy Schubert		exit 1
179825039b37SCy Schubert		;;
179925039b37SCy Schubertesac
180025039b37SCy Schubert
1801103ba509SCy Schubertcase $obj in
1802103ba509SCy Schubert	aout* | coff* | elf* | pe*)
1803103ba509SCy Schubert		;;
1804103ba509SCy Schubert	'')
1805103ba509SCy Schubert		# empty is fine
1806103ba509SCy Schubert		;;
1807103ba509SCy Schubert	*)
1808103ba509SCy Schubert		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
1809103ba509SCy Schubert		exit 1
1810103ba509SCy Schubert		;;
1811103ba509SCy Schubertesac
1812103ba509SCy Schubert
1813103ba509SCy Schubert# Here we handle the constraint that a (synthetic) cpu and os are
1814103ba509SCy Schubert# valid only in combination with each other and nowhere else.
1815103ba509SCy Schubertcase $cpu-$os in
1816103ba509SCy Schubert	# The "javascript-unknown-ghcjs" triple is used by GHC; we
1817103ba509SCy Schubert	# accept it here in order to tolerate that, but reject any
1818103ba509SCy Schubert	# variations.
1819103ba509SCy Schubert	javascript-ghcjs)
1820103ba509SCy Schubert		;;
1821103ba509SCy Schubert	javascript-* | *-ghcjs)
1822103ba509SCy Schubert		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
1823103ba509SCy Schubert		exit 1
1824103ba509SCy Schubert		;;
1825103ba509SCy Schubertesac
1826103ba509SCy Schubert
182725039b37SCy Schubert# As a final step for OS-related things, validate the OS-kernel combination
182825039b37SCy Schubert# (given a valid OS), if there is a kernel.
1829103ba509SCy Schubertcase $kernel-$os-$obj in
1830b76ef9a7SCy Schubert	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
1831b76ef9a7SCy Schubert		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
1832b76ef9a7SCy Schubert		    | linux-relibc*- | linux-uclibc*- )
183325039b37SCy Schubert		;;
1834103ba509SCy Schubert	uclinux-uclibc*- )
1835c0caa2e2SCy Schubert		;;
1836103ba509SCy Schubert	managarm-mlibc*- | managarm-kernel*- )
1837865f46b2SCy Schubert		;;
1838103ba509SCy Schubert	windows*-msvc*-)
18398f76bb7dSCy Schubert		;;
1840b76ef9a7SCy Schubert	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
1841b76ef9a7SCy Schubert		    | -uclibc*- )
184225039b37SCy Schubert		# These are just libc implementations, not actual OSes, and thus
184325039b37SCy Schubert		# require a kernel.
18448f76bb7dSCy Schubert		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
184525039b37SCy Schubert		exit 1
184625039b37SCy Schubert		;;
1847103ba509SCy Schubert	-kernel*- )
18488f76bb7dSCy Schubert		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
1849865f46b2SCy Schubert		exit 1
1850865f46b2SCy Schubert		;;
1851103ba509SCy Schubert	*-kernel*- )
18528f76bb7dSCy Schubert		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
18538f76bb7dSCy Schubert		exit 1
18548f76bb7dSCy Schubert		;;
1855103ba509SCy Schubert	*-msvc*- )
18568f76bb7dSCy Schubert		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
1857865f46b2SCy Schubert		exit 1
1858865f46b2SCy Schubert		;;
1859103ba509SCy Schubert	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
186025039b37SCy Schubert		;;
1861103ba509SCy Schubert	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
1862f44e67d1SCy Schubert		;;
1863103ba509SCy Schubert	nto-qnx*-)
186425039b37SCy Schubert		;;
1865103ba509SCy Schubert	os2-emx-)
1866369c6923SCy Schubert		;;
1867103ba509SCy Schubert	*-eabi*- | *-gnueabi*-)
186825039b37SCy Schubert		;;
1869103ba509SCy Schubert	none--*)
18708f76bb7dSCy Schubert		# None (no kernel, i.e. freestanding / bare metal),
1871103ba509SCy Schubert		# can be paired with an machine code file format
18728f76bb7dSCy Schubert		;;
1873103ba509SCy Schubert	-*-)
187425039b37SCy Schubert		# Blank kernel with real OS is always fine.
187525039b37SCy Schubert		;;
1876103ba509SCy Schubert	--*)
1877103ba509SCy Schubert		# Blank kernel and OS with real machine code file format is always fine.
1878103ba509SCy Schubert		;;
1879103ba509SCy Schubert	*-*-*)
18808f76bb7dSCy Schubert		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
188125039b37SCy Schubert		exit 1
188225039b37SCy Schubert		;;
188325039b37SCy Schubertesac
188425039b37SCy Schubert
1885b7579f77SDag-Erling Smørgrav# Here we handle the case where we know the os, and the CPU type, but not the
1886b7579f77SDag-Erling Smørgrav# manufacturer.  We pick the logical manufacturer.
188725039b37SCy Schubertcase $vendor in
188825039b37SCy Schubert	unknown)
188925039b37SCy Schubert		case $cpu-$os in
189025039b37SCy Schubert			*-riscix*)
1891b7579f77SDag-Erling Smørgrav				vendor=acorn
1892b7579f77SDag-Erling Smørgrav				;;
189325039b37SCy Schubert			*-sunos*)
1894b7579f77SDag-Erling Smørgrav				vendor=sun
1895b7579f77SDag-Erling Smørgrav				;;
189625039b37SCy Schubert			*-cnk* | *-aix*)
1897b7579f77SDag-Erling Smørgrav				vendor=ibm
1898b7579f77SDag-Erling Smørgrav				;;
189925039b37SCy Schubert			*-beos*)
1900b7579f77SDag-Erling Smørgrav				vendor=be
1901b7579f77SDag-Erling Smørgrav				;;
190225039b37SCy Schubert			*-hpux*)
1903b7579f77SDag-Erling Smørgrav				vendor=hp
1904b7579f77SDag-Erling Smørgrav				;;
190525039b37SCy Schubert			*-mpeix*)
1906b7579f77SDag-Erling Smørgrav				vendor=hp
1907b7579f77SDag-Erling Smørgrav				;;
190825039b37SCy Schubert			*-hiux*)
1909b7579f77SDag-Erling Smørgrav				vendor=hitachi
1910b7579f77SDag-Erling Smørgrav				;;
191125039b37SCy Schubert			*-unos*)
1912b7579f77SDag-Erling Smørgrav				vendor=crds
1913b7579f77SDag-Erling Smørgrav				;;
191425039b37SCy Schubert			*-dgux*)
1915b7579f77SDag-Erling Smørgrav				vendor=dg
1916b7579f77SDag-Erling Smørgrav				;;
191725039b37SCy Schubert			*-luna*)
1918b7579f77SDag-Erling Smørgrav				vendor=omron
1919b7579f77SDag-Erling Smørgrav				;;
192025039b37SCy Schubert			*-genix*)
1921b7579f77SDag-Erling Smørgrav				vendor=ns
1922b7579f77SDag-Erling Smørgrav				;;
192325039b37SCy Schubert			*-clix*)
192425039b37SCy Schubert				vendor=intergraph
192525039b37SCy Schubert				;;
192625039b37SCy Schubert			*-mvs* | *-opened*)
1927b7579f77SDag-Erling Smørgrav				vendor=ibm
1928b7579f77SDag-Erling Smørgrav				;;
192925039b37SCy Schubert			*-os400*)
1930b7579f77SDag-Erling Smørgrav				vendor=ibm
1931b7579f77SDag-Erling Smørgrav				;;
193225039b37SCy Schubert			s390-* | s390x-*)
193325039b37SCy Schubert				vendor=ibm
193425039b37SCy Schubert				;;
193525039b37SCy Schubert			*-ptx*)
1936b7579f77SDag-Erling Smørgrav				vendor=sequent
1937b7579f77SDag-Erling Smørgrav				;;
193825039b37SCy Schubert			*-tpf*)
1939b7579f77SDag-Erling Smørgrav				vendor=ibm
1940b7579f77SDag-Erling Smørgrav				;;
194125039b37SCy Schubert			*-vxsim* | *-vxworks* | *-windiss*)
1942b7579f77SDag-Erling Smørgrav				vendor=wrs
1943b7579f77SDag-Erling Smørgrav				;;
194425039b37SCy Schubert			*-aux*)
1945b7579f77SDag-Erling Smørgrav				vendor=apple
1946b7579f77SDag-Erling Smørgrav				;;
194725039b37SCy Schubert			*-hms*)
1948b7579f77SDag-Erling Smørgrav				vendor=hitachi
1949b7579f77SDag-Erling Smørgrav				;;
195025039b37SCy Schubert			*-mpw* | *-macos*)
1951b7579f77SDag-Erling Smørgrav				vendor=apple
1952b7579f77SDag-Erling Smørgrav				;;
195325039b37SCy Schubert			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1954b7579f77SDag-Erling Smørgrav				vendor=atari
1955b7579f77SDag-Erling Smørgrav				;;
195625039b37SCy Schubert			*-vos*)
1957b7579f77SDag-Erling Smørgrav				vendor=stratus
1958b7579f77SDag-Erling Smørgrav				;;
1959b7579f77SDag-Erling Smørgrav		esac
1960b7579f77SDag-Erling Smørgrav		;;
1961b7579f77SDag-Erling Smørgravesac
1962b7579f77SDag-Erling Smørgrav
1963103ba509SCy Schubertecho "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
1964b7579f77SDag-Erling Smørgravexit
1965b7579f77SDag-Erling Smørgrav
1966b7579f77SDag-Erling Smørgrav# Local variables:
196725039b37SCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp)
1968b7579f77SDag-Erling Smørgrav# time-stamp-start: "timestamp='"
1969b7579f77SDag-Erling Smørgrav# time-stamp-format: "%:y-%02m-%02d"
1970b7579f77SDag-Erling Smørgrav# time-stamp-end: "'"
1971b7579f77SDag-Erling Smørgrav# End:
1972