18255a313Smrg#! /bin/sh
28255a313Smrg# Configuration validation subroutine script.
322138c50Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
48255a313Smrg
53d13e800Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
63d13e800Smrg
722138c50Smrgtimestamp='2023-01-21'
88255a313Smrg
901395c31Smrg# This file is free software; you can redistribute it and/or modify it
1001395c31Smrg# under the terms of the GNU General Public License as published by
1122138c50Smrg# the Free Software Foundation, either version 3 of the License, or
128255a313Smrg# (at your option) any later version.
138255a313Smrg#
1401395c31Smrg# This program is distributed in the hope that it will be useful, but
1501395c31Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1601395c31Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1701395c31Smrg# General Public License for more details.
188255a313Smrg#
198255a313Smrg# You should have received a copy of the GNU General Public License
203d13e800Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
218255a313Smrg#
228255a313Smrg# As a special exception to the GNU General Public License, if you
238255a313Smrg# distribute this file as part of a program that contains a
248255a313Smrg# configuration script generated by Autoconf, you may include it under
2501395c31Smrg# the same distribution terms that you use for the rest of that
2601395c31Smrg# program.  This Exception is an additional permission under section 7
2701395c31Smrg# of the GNU General Public License, version 3 ("GPLv3").
288255a313Smrg
298255a313Smrg
3001395c31Smrg# Please send patches to <config-patches@gnu.org>.
318255a313Smrg#
328255a313Smrg# Configuration subroutine to validate and canonicalize a configuration type.
338255a313Smrg# Supply the specified configuration type as an argument.
348255a313Smrg# If it is invalid, we print an error message on stderr and exit with code 1.
358255a313Smrg# Otherwise, we print the canonical config type on stdout and succeed.
368255a313Smrg
37de7ed6e8Smrg# You can get the latest version of this script from:
383d13e800Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39de7ed6e8Smrg
408255a313Smrg# This file is supposed to be the same for all GNU packages
418255a313Smrg# and recognize all the CPU types, system types and aliases
428255a313Smrg# that are meaningful with *any* GNU software.
438255a313Smrg# Each package is responsible for reporting which valid configurations
448255a313Smrg# it does not support.  The user should be able to distinguish
458255a313Smrg# a failure to support a valid configuration from a meaningless
468255a313Smrg# configuration.
478255a313Smrg
488255a313Smrg# The goal of this file is to map all the various variations of a given
498255a313Smrg# machine specification into a single specification in the form:
508255a313Smrg#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
518255a313Smrg# or in some cases, the newer four-part form:
528255a313Smrg#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
538255a313Smrg# It is wrong to echo any other type of specification.
548255a313Smrg
553d13e800Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
563d13e800Smrg# about features and limitations of the classic Bourne shell that were
573d13e800Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
583d13e800Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
593d13e800Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
603d13e800Smrg# have a pre-POSIX /bin/sh.
613d13e800Smrg
628255a313Smrgme=`echo "$0" | sed -e 's,.*/,,'`
638255a313Smrg
648255a313Smrgusage="\
6501395c31SmrgUsage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
668255a313Smrg
678255a313SmrgCanonicalize a configuration name.
688255a313Smrg
693d13e800SmrgOptions:
708255a313Smrg  -h, --help         print this help, then exit
718255a313Smrg  -t, --time-stamp   print date of last modification, then exit
728255a313Smrg  -v, --version      print version number, then exit
738255a313Smrg
748255a313SmrgReport bugs and patches to <config-patches@gnu.org>."
758255a313Smrg
768255a313Smrgversion="\
778255a313SmrgGNU config.sub ($timestamp)
788255a313Smrg
7922138c50SmrgCopyright 1992-2023 Free Software Foundation, Inc.
808255a313Smrg
818255a313SmrgThis is free software; see the source for copying conditions.  There is NO
828255a313Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
838255a313Smrg
848255a313Smrghelp="
858255a313SmrgTry \`$me --help' for more information."
868255a313Smrg
878255a313Smrg# Parse command line
888255a313Smrgwhile test $# -gt 0 ; do
898255a313Smrg  case $1 in
908255a313Smrg    --time-stamp | --time* | -t )
918255a313Smrg       echo "$timestamp" ; exit ;;
928255a313Smrg    --version | -v )
938255a313Smrg       echo "$version" ; exit ;;
948255a313Smrg    --help | --h* | -h )
958255a313Smrg       echo "$usage"; exit ;;
968255a313Smrg    -- )     # Stop option processing
978255a313Smrg       shift; break ;;
988255a313Smrg    - )	# Use stdin as input.
998255a313Smrg       break ;;
1008255a313Smrg    -* )
1013d13e800Smrg       echo "$me: invalid option $1$help" >&2
1028255a313Smrg       exit 1 ;;
1038255a313Smrg
1048255a313Smrg    *local*)
1058255a313Smrg       # First pass through any local machine types.
1063d13e800Smrg       echo "$1"
1078255a313Smrg       exit ;;
1088255a313Smrg
1098255a313Smrg    * )
1108255a313Smrg       break ;;
1118255a313Smrg  esac
1128255a313Smrgdone
1138255a313Smrg
1148255a313Smrgcase $# in
1158255a313Smrg 0) echo "$me: missing argument$help" >&2
1168255a313Smrg    exit 1;;
1178255a313Smrg 1) ;;
1188255a313Smrg *) echo "$me: too many arguments$help" >&2
1198255a313Smrg    exit 1;;
1208255a313Smrgesac
1218255a313Smrg
1223d13e800Smrg# Split fields of configuration type
1233d13e800Smrg# shellcheck disable=SC2162
1243d13e800Smrgsaved_IFS=$IFS
1253d13e800SmrgIFS="-" read field1 field2 field3 field4 <<EOF
1263d13e800Smrg$1
1273d13e800SmrgEOF
1283d13e800SmrgIFS=$saved_IFS
1298255a313Smrg
1303d13e800Smrg# Separate into logical components for further validation
1313d13e800Smrgcase $1 in
1323d13e800Smrg	*-*-*-*-*)
1333d13e800Smrg		echo Invalid configuration \`"$1"\': more than four components >&2
1343d13e800Smrg		exit 1
1358255a313Smrg		;;
1363d13e800Smrg	*-*-*-*)
1373d13e800Smrg		basic_machine=$field1-$field2
1383d13e800Smrg		basic_os=$field3-$field4
1398255a313Smrg		;;
1403d13e800Smrg	*-*-*)
1413d13e800Smrg		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
1423d13e800Smrg		# parts
1433d13e800Smrg		maybe_os=$field2-$field3
1443d13e800Smrg		case $maybe_os in
1453d13e800Smrg			nto-qnx* | linux-* | uclinux-uclibc* \
1463d13e800Smrg			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
1473d13e800Smrg			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
14822138c50Smrg			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
1493d13e800Smrg				basic_machine=$field1
1503d13e800Smrg				basic_os=$maybe_os
1513d13e800Smrg				;;
1523d13e800Smrg			android-linux)
1533d13e800Smrg				basic_machine=$field1-unknown
1543d13e800Smrg				basic_os=linux-android
1553d13e800Smrg				;;
1563d13e800Smrg			*)
1573d13e800Smrg				basic_machine=$field1-$field2
1583d13e800Smrg				basic_os=$field3
1593d13e800Smrg				;;
1603d13e800Smrg		esac
1618255a313Smrg		;;
1623d13e800Smrg	*-*)
1633d13e800Smrg		# A lone config we happen to match not fitting any pattern
1643d13e800Smrg		case $field1-$field2 in
1653d13e800Smrg			decstation-3100)
1663d13e800Smrg				basic_machine=mips-dec
1673d13e800Smrg				basic_os=
1683d13e800Smrg				;;
1693d13e800Smrg			*-*)
1703d13e800Smrg				# Second component is usually, but not always the OS
1713d13e800Smrg				case $field2 in
1723d13e800Smrg					# Prevent following clause from handling this valid os
1733d13e800Smrg					sun*os*)
1743d13e800Smrg						basic_machine=$field1
1753d13e800Smrg						basic_os=$field2
1763d13e800Smrg						;;
1773d13e800Smrg					zephyr*)
1783d13e800Smrg						basic_machine=$field1-unknown
1793d13e800Smrg						basic_os=$field2
1803d13e800Smrg						;;
1813d13e800Smrg					# Manufacturers
1823d13e800Smrg					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
1833d13e800Smrg					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
1843d13e800Smrg					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
1853d13e800Smrg					| convergent* | ncr* | news | 32* | 3600* | 3100* \
1863d13e800Smrg					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
1873d13e800Smrg					| ultra | tti* | harris | dolphin | highlevel | gould \
1883d13e800Smrg					| cbm | ns | masscomp | apple | axis | knuth | cray \
1893d13e800Smrg					| microblaze* | sim | cisco \
1903d13e800Smrg					| oki | wec | wrs | winbond)
1913d13e800Smrg						basic_machine=$field1-$field2
1923d13e800Smrg						basic_os=
1933d13e800Smrg						;;
1943d13e800Smrg					*)
1953d13e800Smrg						basic_machine=$field1
1963d13e800Smrg						basic_os=$field2
1973d13e800Smrg						;;
1983d13e800Smrg				esac
1993d13e800Smrg			;;
2003d13e800Smrg		esac
2018255a313Smrg		;;
2023d13e800Smrg	*)
2033d13e800Smrg		# Convert single-component short-hands not valid as part of
2043d13e800Smrg		# multi-component configurations.
2053d13e800Smrg		case $field1 in
2063d13e800Smrg			386bsd)
2073d13e800Smrg				basic_machine=i386-pc
2083d13e800Smrg				basic_os=bsd
2093d13e800Smrg				;;
2103d13e800Smrg			a29khif)
2113d13e800Smrg				basic_machine=a29k-amd
2123d13e800Smrg				basic_os=udi
2133d13e800Smrg				;;
2143d13e800Smrg			adobe68k)
2153d13e800Smrg				basic_machine=m68010-adobe
2163d13e800Smrg				basic_os=scout
2173d13e800Smrg				;;
2183d13e800Smrg			alliant)
2193d13e800Smrg				basic_machine=fx80-alliant
2203d13e800Smrg				basic_os=
2213d13e800Smrg				;;
2223d13e800Smrg			altos | altos3068)
2233d13e800Smrg				basic_machine=m68k-altos
2243d13e800Smrg				basic_os=
2253d13e800Smrg				;;
2263d13e800Smrg			am29k)
2273d13e800Smrg				basic_machine=a29k-none
2283d13e800Smrg				basic_os=bsd
2293d13e800Smrg				;;
2303d13e800Smrg			amdahl)
2313d13e800Smrg				basic_machine=580-amdahl
2323d13e800Smrg				basic_os=sysv
2333d13e800Smrg				;;
2343d13e800Smrg			amiga)
2353d13e800Smrg				basic_machine=m68k-unknown
2363d13e800Smrg				basic_os=
2373d13e800Smrg				;;
2383d13e800Smrg			amigaos | amigados)
2393d13e800Smrg				basic_machine=m68k-unknown
2403d13e800Smrg				basic_os=amigaos
2413d13e800Smrg				;;
2423d13e800Smrg			amigaunix | amix)
2433d13e800Smrg				basic_machine=m68k-unknown
2443d13e800Smrg				basic_os=sysv4
2453d13e800Smrg				;;
2463d13e800Smrg			apollo68)
2473d13e800Smrg				basic_machine=m68k-apollo
2483d13e800Smrg				basic_os=sysv
2493d13e800Smrg				;;
2503d13e800Smrg			apollo68bsd)
2513d13e800Smrg				basic_machine=m68k-apollo
2523d13e800Smrg				basic_os=bsd
2533d13e800Smrg				;;
2543d13e800Smrg			aros)
2553d13e800Smrg				basic_machine=i386-pc
2563d13e800Smrg				basic_os=aros
2573d13e800Smrg				;;
2583d13e800Smrg			aux)
2593d13e800Smrg				basic_machine=m68k-apple
2603d13e800Smrg				basic_os=aux
2613d13e800Smrg				;;
2623d13e800Smrg			balance)
2633d13e800Smrg				basic_machine=ns32k-sequent
2643d13e800Smrg				basic_os=dynix
2653d13e800Smrg				;;
2663d13e800Smrg			blackfin)
2673d13e800Smrg				basic_machine=bfin-unknown
2683d13e800Smrg				basic_os=linux
2693d13e800Smrg				;;
2703d13e800Smrg			cegcc)
2713d13e800Smrg				basic_machine=arm-unknown
2723d13e800Smrg				basic_os=cegcc
2733d13e800Smrg				;;
2743d13e800Smrg			convex-c1)
2753d13e800Smrg				basic_machine=c1-convex
2763d13e800Smrg				basic_os=bsd
2773d13e800Smrg				;;
2783d13e800Smrg			convex-c2)
2793d13e800Smrg				basic_machine=c2-convex
2803d13e800Smrg				basic_os=bsd
2813d13e800Smrg				;;
2823d13e800Smrg			convex-c32)
2833d13e800Smrg				basic_machine=c32-convex
2843d13e800Smrg				basic_os=bsd
2853d13e800Smrg				;;
2863d13e800Smrg			convex-c34)
2873d13e800Smrg				basic_machine=c34-convex
2883d13e800Smrg				basic_os=bsd
2893d13e800Smrg				;;
2903d13e800Smrg			convex-c38)
2913d13e800Smrg				basic_machine=c38-convex
2923d13e800Smrg				basic_os=bsd
2933d13e800Smrg				;;
2943d13e800Smrg			cray)
2953d13e800Smrg				basic_machine=j90-cray
2963d13e800Smrg				basic_os=unicos
2973d13e800Smrg				;;
2983d13e800Smrg			crds | unos)
2993d13e800Smrg				basic_machine=m68k-crds
3003d13e800Smrg				basic_os=
3013d13e800Smrg				;;
3023d13e800Smrg			da30)
3033d13e800Smrg				basic_machine=m68k-da30
3043d13e800Smrg				basic_os=
3053d13e800Smrg				;;
3063d13e800Smrg			decstation | pmax | pmin | dec3100 | decstatn)
3073d13e800Smrg				basic_machine=mips-dec
3083d13e800Smrg				basic_os=
3093d13e800Smrg				;;
3103d13e800Smrg			delta88)
3113d13e800Smrg				basic_machine=m88k-motorola
3123d13e800Smrg				basic_os=sysv3
3133d13e800Smrg				;;
3143d13e800Smrg			dicos)
3153d13e800Smrg				basic_machine=i686-pc
3163d13e800Smrg				basic_os=dicos
3173d13e800Smrg				;;
3183d13e800Smrg			djgpp)
3193d13e800Smrg				basic_machine=i586-pc
3203d13e800Smrg				basic_os=msdosdjgpp
3213d13e800Smrg				;;
3223d13e800Smrg			ebmon29k)
3233d13e800Smrg				basic_machine=a29k-amd
3243d13e800Smrg				basic_os=ebmon
3253d13e800Smrg				;;
3263d13e800Smrg			es1800 | OSE68k | ose68k | ose | OSE)
3273d13e800Smrg				basic_machine=m68k-ericsson
3283d13e800Smrg				basic_os=ose
3293d13e800Smrg				;;
3303d13e800Smrg			gmicro)
3313d13e800Smrg				basic_machine=tron-gmicro
3323d13e800Smrg				basic_os=sysv
3333d13e800Smrg				;;
3343d13e800Smrg			go32)
3353d13e800Smrg				basic_machine=i386-pc
3363d13e800Smrg				basic_os=go32
3373d13e800Smrg				;;
3383d13e800Smrg			h8300hms)
3393d13e800Smrg				basic_machine=h8300-hitachi
3403d13e800Smrg				basic_os=hms
3413d13e800Smrg				;;
3423d13e800Smrg			h8300xray)
3433d13e800Smrg				basic_machine=h8300-hitachi
3443d13e800Smrg				basic_os=xray
3453d13e800Smrg				;;
3463d13e800Smrg			h8500hms)
3473d13e800Smrg				basic_machine=h8500-hitachi
3483d13e800Smrg				basic_os=hms
3493d13e800Smrg				;;
3503d13e800Smrg			harris)
3513d13e800Smrg				basic_machine=m88k-harris
3523d13e800Smrg				basic_os=sysv3
3533d13e800Smrg				;;
3543d13e800Smrg			hp300 | hp300hpux)
3553d13e800Smrg				basic_machine=m68k-hp
3563d13e800Smrg				basic_os=hpux
3573d13e800Smrg				;;
3583d13e800Smrg			hp300bsd)
3593d13e800Smrg				basic_machine=m68k-hp
3603d13e800Smrg				basic_os=bsd
3613d13e800Smrg				;;
3623d13e800Smrg			hppaosf)
3633d13e800Smrg				basic_machine=hppa1.1-hp
3643d13e800Smrg				basic_os=osf
3653d13e800Smrg				;;
3663d13e800Smrg			hppro)
3673d13e800Smrg				basic_machine=hppa1.1-hp
3683d13e800Smrg				basic_os=proelf
3693d13e800Smrg				;;
3703d13e800Smrg			i386mach)
3713d13e800Smrg				basic_machine=i386-mach
3723d13e800Smrg				basic_os=mach
3733d13e800Smrg				;;
3743d13e800Smrg			isi68 | isi)
3753d13e800Smrg				basic_machine=m68k-isi
3763d13e800Smrg				basic_os=sysv
3773d13e800Smrg				;;
3783d13e800Smrg			m68knommu)
3793d13e800Smrg				basic_machine=m68k-unknown
3803d13e800Smrg				basic_os=linux
3813d13e800Smrg				;;
3823d13e800Smrg			magnum | m3230)
3833d13e800Smrg				basic_machine=mips-mips
3843d13e800Smrg				basic_os=sysv
3853d13e800Smrg				;;
3863d13e800Smrg			merlin)
3873d13e800Smrg				basic_machine=ns32k-utek
3883d13e800Smrg				basic_os=sysv
3893d13e800Smrg				;;
3903d13e800Smrg			mingw64)
3913d13e800Smrg				basic_machine=x86_64-pc
3923d13e800Smrg				basic_os=mingw64
3933d13e800Smrg				;;
3943d13e800Smrg			mingw32)
3953d13e800Smrg				basic_machine=i686-pc
3963d13e800Smrg				basic_os=mingw32
3973d13e800Smrg				;;
3983d13e800Smrg			mingw32ce)
3993d13e800Smrg				basic_machine=arm-unknown
4003d13e800Smrg				basic_os=mingw32ce
4013d13e800Smrg				;;
4023d13e800Smrg			monitor)
4033d13e800Smrg				basic_machine=m68k-rom68k
4043d13e800Smrg				basic_os=coff
4053d13e800Smrg				;;
4063d13e800Smrg			morphos)
4073d13e800Smrg				basic_machine=powerpc-unknown
4083d13e800Smrg				basic_os=morphos
4093d13e800Smrg				;;
4103d13e800Smrg			moxiebox)
4113d13e800Smrg				basic_machine=moxie-unknown
4123d13e800Smrg				basic_os=moxiebox
4133d13e800Smrg				;;
4143d13e800Smrg			msdos)
4153d13e800Smrg				basic_machine=i386-pc
4163d13e800Smrg				basic_os=msdos
4173d13e800Smrg				;;
4183d13e800Smrg			msys)
4193d13e800Smrg				basic_machine=i686-pc
4203d13e800Smrg				basic_os=msys
4213d13e800Smrg				;;
4223d13e800Smrg			mvs)
4233d13e800Smrg				basic_machine=i370-ibm
4243d13e800Smrg				basic_os=mvs
4253d13e800Smrg				;;
4263d13e800Smrg			nacl)
4273d13e800Smrg				basic_machine=le32-unknown
4283d13e800Smrg				basic_os=nacl
4293d13e800Smrg				;;
4303d13e800Smrg			ncr3000)
4313d13e800Smrg				basic_machine=i486-ncr
4323d13e800Smrg				basic_os=sysv4
4333d13e800Smrg				;;
4343d13e800Smrg			netbsd386)
4353d13e800Smrg				basic_machine=i386-pc
4363d13e800Smrg				basic_os=netbsd
4373d13e800Smrg				;;
4383d13e800Smrg			netwinder)
4393d13e800Smrg				basic_machine=armv4l-rebel
4403d13e800Smrg				basic_os=linux
4413d13e800Smrg				;;
4423d13e800Smrg			news | news700 | news800 | news900)
4433d13e800Smrg				basic_machine=m68k-sony
4443d13e800Smrg				basic_os=newsos
4453d13e800Smrg				;;
4463d13e800Smrg			news1000)
4473d13e800Smrg				basic_machine=m68030-sony
4483d13e800Smrg				basic_os=newsos
4493d13e800Smrg				;;
4503d13e800Smrg			necv70)
4513d13e800Smrg				basic_machine=v70-nec
4523d13e800Smrg				basic_os=sysv
4533d13e800Smrg				;;
4543d13e800Smrg			nh3000)
4553d13e800Smrg				basic_machine=m68k-harris
4563d13e800Smrg				basic_os=cxux
4573d13e800Smrg				;;
4583d13e800Smrg			nh[45]000)
4593d13e800Smrg				basic_machine=m88k-harris
4603d13e800Smrg				basic_os=cxux
4613d13e800Smrg				;;
4623d13e800Smrg			nindy960)
4633d13e800Smrg				basic_machine=i960-intel
4643d13e800Smrg				basic_os=nindy
4653d13e800Smrg				;;
4663d13e800Smrg			mon960)
4673d13e800Smrg				basic_machine=i960-intel
4683d13e800Smrg				basic_os=mon960
4693d13e800Smrg				;;
4703d13e800Smrg			nonstopux)
4713d13e800Smrg				basic_machine=mips-compaq
4723d13e800Smrg				basic_os=nonstopux
4733d13e800Smrg				;;
4743d13e800Smrg			os400)
4753d13e800Smrg				basic_machine=powerpc-ibm
4763d13e800Smrg				basic_os=os400
4773d13e800Smrg				;;
4783d13e800Smrg			OSE68000 | ose68000)
4793d13e800Smrg				basic_machine=m68000-ericsson
4803d13e800Smrg				basic_os=ose
4813d13e800Smrg				;;
4823d13e800Smrg			os68k)
4833d13e800Smrg				basic_machine=m68k-none
4843d13e800Smrg				basic_os=os68k
4853d13e800Smrg				;;
4863d13e800Smrg			paragon)
4873d13e800Smrg				basic_machine=i860-intel
4883d13e800Smrg				basic_os=osf
4893d13e800Smrg				;;
4903d13e800Smrg			parisc)
4913d13e800Smrg				basic_machine=hppa-unknown
4923d13e800Smrg				basic_os=linux
4933d13e800Smrg				;;
4943d13e800Smrg			psp)
4953d13e800Smrg				basic_machine=mipsallegrexel-sony
4963d13e800Smrg				basic_os=psp
4973d13e800Smrg				;;
4983d13e800Smrg			pw32)
4993d13e800Smrg				basic_machine=i586-unknown
5003d13e800Smrg				basic_os=pw32
5013d13e800Smrg				;;
5023d13e800Smrg			rdos | rdos64)
5033d13e800Smrg				basic_machine=x86_64-pc
5043d13e800Smrg				basic_os=rdos
5053d13e800Smrg				;;
5063d13e800Smrg			rdos32)
5073d13e800Smrg				basic_machine=i386-pc
5083d13e800Smrg				basic_os=rdos
5093d13e800Smrg				;;
5103d13e800Smrg			rom68k)
5113d13e800Smrg				basic_machine=m68k-rom68k
5123d13e800Smrg				basic_os=coff
5133d13e800Smrg				;;
5143d13e800Smrg			sa29200)
5153d13e800Smrg				basic_machine=a29k-amd
5163d13e800Smrg				basic_os=udi
5173d13e800Smrg				;;
5183d13e800Smrg			sei)
5193d13e800Smrg				basic_machine=mips-sei
5203d13e800Smrg				basic_os=seiux
5213d13e800Smrg				;;
5223d13e800Smrg			sequent)
5233d13e800Smrg				basic_machine=i386-sequent
5243d13e800Smrg				basic_os=
5253d13e800Smrg				;;
5263d13e800Smrg			sps7)
5273d13e800Smrg				basic_machine=m68k-bull
5283d13e800Smrg				basic_os=sysv2
5293d13e800Smrg				;;
5303d13e800Smrg			st2000)
5313d13e800Smrg				basic_machine=m68k-tandem
5323d13e800Smrg				basic_os=
5333d13e800Smrg				;;
5343d13e800Smrg			stratus)
5353d13e800Smrg				basic_machine=i860-stratus
5363d13e800Smrg				basic_os=sysv4
5373d13e800Smrg				;;
5383d13e800Smrg			sun2)
5393d13e800Smrg				basic_machine=m68000-sun
5403d13e800Smrg				basic_os=
5413d13e800Smrg				;;
5423d13e800Smrg			sun2os3)
5433d13e800Smrg				basic_machine=m68000-sun
5443d13e800Smrg				basic_os=sunos3
5453d13e800Smrg				;;
5463d13e800Smrg			sun2os4)
5473d13e800Smrg				basic_machine=m68000-sun
5483d13e800Smrg				basic_os=sunos4
5493d13e800Smrg				;;
5503d13e800Smrg			sun3)
5513d13e800Smrg				basic_machine=m68k-sun
5523d13e800Smrg				basic_os=
5533d13e800Smrg				;;
5543d13e800Smrg			sun3os3)
5553d13e800Smrg				basic_machine=m68k-sun
5563d13e800Smrg				basic_os=sunos3
5573d13e800Smrg				;;
5583d13e800Smrg			sun3os4)
5593d13e800Smrg				basic_machine=m68k-sun
5603d13e800Smrg				basic_os=sunos4
5613d13e800Smrg				;;
5623d13e800Smrg			sun4)
5633d13e800Smrg				basic_machine=sparc-sun
5643d13e800Smrg				basic_os=
5653d13e800Smrg				;;
5663d13e800Smrg			sun4os3)
5673d13e800Smrg				basic_machine=sparc-sun
5683d13e800Smrg				basic_os=sunos3
5693d13e800Smrg				;;
5703d13e800Smrg			sun4os4)
5713d13e800Smrg				basic_machine=sparc-sun
5723d13e800Smrg				basic_os=sunos4
5733d13e800Smrg				;;
5743d13e800Smrg			sun4sol2)
5753d13e800Smrg				basic_machine=sparc-sun
5763d13e800Smrg				basic_os=solaris2
5773d13e800Smrg				;;
5783d13e800Smrg			sun386 | sun386i | roadrunner)
5793d13e800Smrg				basic_machine=i386-sun
5803d13e800Smrg				basic_os=
5813d13e800Smrg				;;
5823d13e800Smrg			sv1)
5833d13e800Smrg				basic_machine=sv1-cray
5843d13e800Smrg				basic_os=unicos
5853d13e800Smrg				;;
5863d13e800Smrg			symmetry)
5873d13e800Smrg				basic_machine=i386-sequent
5883d13e800Smrg				basic_os=dynix
5893d13e800Smrg				;;
5903d13e800Smrg			t3e)
5913d13e800Smrg				basic_machine=alphaev5-cray
5923d13e800Smrg				basic_os=unicos
5933d13e800Smrg				;;
5943d13e800Smrg			t90)
5953d13e800Smrg				basic_machine=t90-cray
5963d13e800Smrg				basic_os=unicos
5973d13e800Smrg				;;
5983d13e800Smrg			toad1)
5993d13e800Smrg				basic_machine=pdp10-xkl
6003d13e800Smrg				basic_os=tops20
6013d13e800Smrg				;;
6023d13e800Smrg			tpf)
6033d13e800Smrg				basic_machine=s390x-ibm
6043d13e800Smrg				basic_os=tpf
6053d13e800Smrg				;;
6063d13e800Smrg			udi29k)
6073d13e800Smrg				basic_machine=a29k-amd
6083d13e800Smrg				basic_os=udi
6093d13e800Smrg				;;
6103d13e800Smrg			ultra3)
6113d13e800Smrg				basic_machine=a29k-nyu
6123d13e800Smrg				basic_os=sym1
6133d13e800Smrg				;;
6143d13e800Smrg			v810 | necv810)
6153d13e800Smrg				basic_machine=v810-nec
6163d13e800Smrg				basic_os=none
6173d13e800Smrg				;;
6183d13e800Smrg			vaxv)
6193d13e800Smrg				basic_machine=vax-dec
6203d13e800Smrg				basic_os=sysv
6213d13e800Smrg				;;
6223d13e800Smrg			vms)
6233d13e800Smrg				basic_machine=vax-dec
6243d13e800Smrg				basic_os=vms
6253d13e800Smrg				;;
6263d13e800Smrg			vsta)
6273d13e800Smrg				basic_machine=i386-pc
6283d13e800Smrg				basic_os=vsta
6293d13e800Smrg				;;
6303d13e800Smrg			vxworks960)
6313d13e800Smrg				basic_machine=i960-wrs
6323d13e800Smrg				basic_os=vxworks
6333d13e800Smrg				;;
6343d13e800Smrg			vxworks68)
6353d13e800Smrg				basic_machine=m68k-wrs
6363d13e800Smrg				basic_os=vxworks
6373d13e800Smrg				;;
6383d13e800Smrg			vxworks29k)
6393d13e800Smrg				basic_machine=a29k-wrs
6403d13e800Smrg				basic_os=vxworks
6413d13e800Smrg				;;
6423d13e800Smrg			xbox)
6433d13e800Smrg				basic_machine=i686-pc
6443d13e800Smrg				basic_os=mingw32
6453d13e800Smrg				;;
6463d13e800Smrg			ymp)
6473d13e800Smrg				basic_machine=ymp-cray
6483d13e800Smrg				basic_os=unicos
6493d13e800Smrg				;;
6503d13e800Smrg			*)
6513d13e800Smrg				basic_machine=$1
6523d13e800Smrg				basic_os=
6533d13e800Smrg				;;
6543d13e800Smrg		esac
6558255a313Smrg		;;
6568255a313Smrgesac
6578255a313Smrg
6583d13e800Smrg# Decode 1-component or ad-hoc basic machines
6598255a313Smrgcase $basic_machine in
6603d13e800Smrg	# Here we handle the default manufacturer of certain CPU types.  It is in
6613d13e800Smrg	# some cases the only manufacturer, in others, it is the most popular.
6623d13e800Smrg	w89k)
6633d13e800Smrg		cpu=hppa1.1
6643d13e800Smrg		vendor=winbond
6658255a313Smrg		;;
6663d13e800Smrg	op50n)
6673d13e800Smrg		cpu=hppa1.1
6683d13e800Smrg		vendor=oki
6698255a313Smrg		;;
6703d13e800Smrg	op60c)
6713d13e800Smrg		cpu=hppa1.1
6723d13e800Smrg		vendor=oki
6738255a313Smrg		;;
6743d13e800Smrg	ibm*)
6753d13e800Smrg		cpu=i370
6763d13e800Smrg		vendor=ibm
67701395c31Smrg		;;
6783d13e800Smrg	orion105)
6793d13e800Smrg		cpu=clipper
6803d13e800Smrg		vendor=highlevel
68101395c31Smrg		;;
6823d13e800Smrg	mac | mpw | mac-mpw)
6833d13e800Smrg		cpu=m68k
6843d13e800Smrg		vendor=apple
68501395c31Smrg		;;
6863d13e800Smrg	pmac | pmac-mpw)
6873d13e800Smrg		cpu=powerpc
6883d13e800Smrg		vendor=apple
68901395c31Smrg		;;
69001395c31Smrg
6918255a313Smrg	# Recognize the various machine names and aliases which stand
6928255a313Smrg	# for a CPU type and a company and sometimes even an OS.
6938255a313Smrg	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
6943d13e800Smrg		cpu=m68000
6953d13e800Smrg		vendor=att
6968255a313Smrg		;;
6978255a313Smrg	3b*)
6983d13e800Smrg		cpu=we32k
6993d13e800Smrg		vendor=att
7008255a313Smrg		;;
701de7ed6e8Smrg	bluegene*)
7023d13e800Smrg		cpu=powerpc
7033d13e800Smrg		vendor=ibm
7043d13e800Smrg		basic_os=cnk
7058255a313Smrg		;;
7068255a313Smrg	decsystem10* | dec10*)
7073d13e800Smrg		cpu=pdp10
7083d13e800Smrg		vendor=dec
7093d13e800Smrg		basic_os=tops10
7108255a313Smrg		;;
7118255a313Smrg	decsystem20* | dec20*)
7123d13e800Smrg		cpu=pdp10
7133d13e800Smrg		vendor=dec
7143d13e800Smrg		basic_os=tops20
7158255a313Smrg		;;
7168255a313Smrg	delta | 3300 | motorola-3300 | motorola-delta \
7178255a313Smrg	      | 3300-motorola | delta-motorola)
7183d13e800Smrg		cpu=m68k
7193d13e800Smrg		vendor=motorola
7208255a313Smrg		;;
7213d13e800Smrg	dpx2*)
7223d13e800Smrg		cpu=m68k
7233d13e800Smrg		vendor=bull
7243d13e800Smrg		basic_os=sysv3
7258255a313Smrg		;;
7268255a313Smrg	encore | umax | mmax)
7273d13e800Smrg		cpu=ns32k
7283d13e800Smrg		vendor=encore
7298255a313Smrg		;;
7303d13e800Smrg	elxsi)
7313d13e800Smrg		cpu=elxsi
7323d13e800Smrg		vendor=elxsi
7333d13e800Smrg		basic_os=${basic_os:-bsd}
7348255a313Smrg		;;
7358255a313Smrg	fx2800)
7363d13e800Smrg		cpu=i860
7373d13e800Smrg		vendor=alliant
7388255a313Smrg		;;
7398255a313Smrg	genix)
7403d13e800Smrg		cpu=ns32k
7413d13e800Smrg		vendor=ns
7428255a313Smrg		;;
7438255a313Smrg	h3050r* | hiux*)
7443d13e800Smrg		cpu=hppa1.1
7453d13e800Smrg		vendor=hitachi
7463d13e800Smrg		basic_os=hiuxwe2
7478255a313Smrg		;;
7488255a313Smrg	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7493d13e800Smrg		cpu=hppa1.0
7503d13e800Smrg		vendor=hp
7518255a313Smrg		;;
7528255a313Smrg	hp9k2[0-9][0-9] | hp9k31[0-9])
7533d13e800Smrg		cpu=m68000
7543d13e800Smrg		vendor=hp
7558255a313Smrg		;;
7568255a313Smrg	hp9k3[2-9][0-9])
7573d13e800Smrg		cpu=m68k
7583d13e800Smrg		vendor=hp
7598255a313Smrg		;;
7608255a313Smrg	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7613d13e800Smrg		cpu=hppa1.0
7623d13e800Smrg		vendor=hp
7638255a313Smrg		;;
7648255a313Smrg	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7653d13e800Smrg		cpu=hppa1.1
7663d13e800Smrg		vendor=hp
7678255a313Smrg		;;
7688255a313Smrg	hp9k78[0-9] | hp78[0-9])
7698255a313Smrg		# FIXME: really hppa2.0-hp
7703d13e800Smrg		cpu=hppa1.1
7713d13e800Smrg		vendor=hp
7728255a313Smrg		;;
7738255a313Smrg	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7748255a313Smrg		# FIXME: really hppa2.0-hp
7753d13e800Smrg		cpu=hppa1.1
7763d13e800Smrg		vendor=hp
7778255a313Smrg		;;
7788255a313Smrg	hp9k8[0-9][13679] | hp8[0-9][13679])
7793d13e800Smrg		cpu=hppa1.1
7803d13e800Smrg		vendor=hp
7818255a313Smrg		;;
7828255a313Smrg	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7833d13e800Smrg		cpu=hppa1.0
7843d13e800Smrg		vendor=hp
7858255a313Smrg		;;
7868255a313Smrg	i*86v32)
7873d13e800Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7883d13e800Smrg		vendor=pc
7893d13e800Smrg		basic_os=sysv32
7908255a313Smrg		;;
7918255a313Smrg	i*86v4*)
7923d13e800Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7933d13e800Smrg		vendor=pc
7943d13e800Smrg		basic_os=sysv4
7958255a313Smrg		;;
7968255a313Smrg	i*86v)
7973d13e800Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7983d13e800Smrg		vendor=pc
7993d13e800Smrg		basic_os=sysv
8008255a313Smrg		;;
8018255a313Smrg	i*86sol2)
8023d13e800Smrg		cpu=`echo "$1" | sed -e 's/86.*/86/'`
8033d13e800Smrg		vendor=pc
8043d13e800Smrg		basic_os=solaris2
8058255a313Smrg		;;
8063d13e800Smrg	j90 | j90-cray)
8073d13e800Smrg		cpu=j90
8083d13e800Smrg		vendor=cray
8093d13e800Smrg		basic_os=${basic_os:-unicos}
8108255a313Smrg		;;
8118255a313Smrg	iris | iris4d)
8123d13e800Smrg		cpu=mips
8133d13e800Smrg		vendor=sgi
8143d13e800Smrg		case $basic_os in
8153d13e800Smrg		    irix*)
8168255a313Smrg			;;
8178255a313Smrg		    *)
8183d13e800Smrg			basic_os=irix4
8198255a313Smrg			;;
8208255a313Smrg		esac
8218255a313Smrg		;;
8228255a313Smrg	miniframe)
8233d13e800Smrg		cpu=m68000
8243d13e800Smrg		vendor=convergent
8258255a313Smrg		;;
8263d13e800Smrg	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
8273d13e800Smrg		cpu=m68k
8283d13e800Smrg		vendor=atari
8293d13e800Smrg		basic_os=mint
8308255a313Smrg		;;
8318255a313Smrg	news-3600 | risc-news)
8323d13e800Smrg		cpu=mips
8333d13e800Smrg		vendor=sony
8343d13e800Smrg		basic_os=newsos
8353d13e800Smrg		;;
8363d13e800Smrg	next | m*-next)
8373d13e800Smrg		cpu=m68k
8383d13e800Smrg		vendor=next
8393d13e800Smrg		case $basic_os in
8403d13e800Smrg		    openstep*)
8413d13e800Smrg		        ;;
8423d13e800Smrg		    nextstep*)
8438255a313Smrg			;;
8443d13e800Smrg		    ns2*)
8453d13e800Smrg		      basic_os=nextstep2
8468255a313Smrg			;;
8478255a313Smrg		    *)
8483d13e800Smrg		      basic_os=nextstep3
8498255a313Smrg			;;
8508255a313Smrg		esac
8518255a313Smrg		;;
8528255a313Smrg	np1)
8533d13e800Smrg		cpu=np1
8543d13e800Smrg		vendor=gould
8558255a313Smrg		;;
8568255a313Smrg	op50n-* | op60c-*)
8573d13e800Smrg		cpu=hppa1.1
8583d13e800Smrg		vendor=oki
8593d13e800Smrg		basic_os=proelf
8608255a313Smrg		;;
8618255a313Smrg	pa-hitachi)
8623d13e800Smrg		cpu=hppa1.1
8633d13e800Smrg		vendor=hitachi
8643d13e800Smrg		basic_os=hiuxwe2
8658255a313Smrg		;;
8668255a313Smrg	pbd)
8673d13e800Smrg		cpu=sparc
8683d13e800Smrg		vendor=tti
8698255a313Smrg		;;
8708255a313Smrg	pbb)
8713d13e800Smrg		cpu=m68k
8723d13e800Smrg		vendor=tti
8738255a313Smrg		;;
8743d13e800Smrg	pc532)
8753d13e800Smrg		cpu=ns32k
8763d13e800Smrg		vendor=pc532
8778255a313Smrg		;;
8788255a313Smrg	pn)
8793d13e800Smrg		cpu=pn
8803d13e800Smrg		vendor=gould
8818255a313Smrg		;;
8823d13e800Smrg	power)
8833d13e800Smrg		cpu=power
8843d13e800Smrg		vendor=ibm
8858255a313Smrg		;;
8868255a313Smrg	ps2)
8873d13e800Smrg		cpu=i386
8883d13e800Smrg		vendor=ibm
8898255a313Smrg		;;
8908255a313Smrg	rm[46]00)
8913d13e800Smrg		cpu=mips
8923d13e800Smrg		vendor=siemens
8938255a313Smrg		;;
8948255a313Smrg	rtpc | rtpc-*)
8953d13e800Smrg		cpu=romp
8963d13e800Smrg		vendor=ibm
8978255a313Smrg		;;
8983d13e800Smrg	sde)
8993d13e800Smrg		cpu=mipsisa32
9003d13e800Smrg		vendor=sde
9013d13e800Smrg		basic_os=${basic_os:-elf}
9028255a313Smrg		;;
9033d13e800Smrg	simso-wrs)
9043d13e800Smrg		cpu=sparclite
9053d13e800Smrg		vendor=wrs
9063d13e800Smrg		basic_os=vxworks
9078255a313Smrg		;;
9083d13e800Smrg	tower | tower-32)
9093d13e800Smrg		cpu=m68k
9103d13e800Smrg		vendor=ncr
9118255a313Smrg		;;
9123d13e800Smrg	vpp*|vx|vx-*)
9133d13e800Smrg		cpu=f301
9143d13e800Smrg		vendor=fujitsu
9158255a313Smrg		;;
9163d13e800Smrg	w65)
9173d13e800Smrg		cpu=w65
9183d13e800Smrg		vendor=wdc
9198255a313Smrg		;;
9203d13e800Smrg	w89k-*)
9213d13e800Smrg		cpu=hppa1.1
9223d13e800Smrg		vendor=winbond
9233d13e800Smrg		basic_os=proelf
9248255a313Smrg		;;
9253d13e800Smrg	none)
9263d13e800Smrg		cpu=none
9273d13e800Smrg		vendor=none
9288255a313Smrg		;;
9293d13e800Smrg	leon|leon[3-9])
9303d13e800Smrg		cpu=sparc
9313d13e800Smrg		vendor=$basic_machine
9328255a313Smrg		;;
9333d13e800Smrg	leon-*|leon[3-9]-*)
9343d13e800Smrg		cpu=sparc
9353d13e800Smrg		vendor=`echo "$basic_machine" | sed 's/-.*//'`
9368255a313Smrg		;;
9373d13e800Smrg
9383d13e800Smrg	*-*)
9393d13e800Smrg		# shellcheck disable=SC2162
9403d13e800Smrg		saved_IFS=$IFS
9413d13e800Smrg		IFS="-" read cpu vendor <<EOF
9423d13e800Smrg$basic_machine
9433d13e800SmrgEOF
9443d13e800Smrg		IFS=$saved_IFS
9458255a313Smrg		;;
9463d13e800Smrg	# We use `pc' rather than `unknown'
9473d13e800Smrg	# because (1) that's what they normally are, and
9483d13e800Smrg	# (2) the word "unknown" tends to confuse beginning users.
9493d13e800Smrg	i*86 | x86_64)
9503d13e800Smrg		cpu=$basic_machine
9513d13e800Smrg		vendor=pc
9528255a313Smrg		;;
9533d13e800Smrg	# These rules are duplicated from below for sake of the special case above;
9543d13e800Smrg	# i.e. things that normalized to x86 arches should also default to "pc"
9553d13e800Smrg	pc98)
9563d13e800Smrg		cpu=i386
9573d13e800Smrg		vendor=pc
9588255a313Smrg		;;
9593d13e800Smrg	x64 | amd64)
9603d13e800Smrg		cpu=x86_64
9613d13e800Smrg		vendor=pc
9628255a313Smrg		;;
9633d13e800Smrg	# Recognize the basic CPU types without company name.
9643d13e800Smrg	*)
9653d13e800Smrg		cpu=$basic_machine
9663d13e800Smrg		vendor=unknown
96701395c31Smrg		;;
9683d13e800Smrgesac
9693d13e800Smrg
9703d13e800Smrgunset -v basic_machine
9713d13e800Smrg
9723d13e800Smrg# Decode basic machines in the full and proper CPU-Company form.
9733d13e800Smrgcase $cpu-$vendor in
9743d13e800Smrg	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
9753d13e800Smrg	# some cases the only manufacturer, in others, it is the most popular.
9763d13e800Smrg	craynv-unknown)
9773d13e800Smrg		vendor=cray
9783d13e800Smrg		basic_os=${basic_os:-unicosmp}
9798255a313Smrg		;;
9803d13e800Smrg	c90-unknown | c90-cray)
9813d13e800Smrg		vendor=cray
9823d13e800Smrg		basic_os=${Basic_os:-unicos}
9838255a313Smrg		;;
9843d13e800Smrg	fx80-unknown)
9853d13e800Smrg		vendor=alliant
9868255a313Smrg		;;
9873d13e800Smrg	romp-unknown)
9883d13e800Smrg		vendor=ibm
9898255a313Smrg		;;
9903d13e800Smrg	mmix-unknown)
9913d13e800Smrg		vendor=knuth
9928255a313Smrg		;;
9933d13e800Smrg	microblaze-unknown | microblazeel-unknown)
9943d13e800Smrg		vendor=xilinx
9958255a313Smrg		;;
9963d13e800Smrg	rs6000-unknown)
9973d13e800Smrg		vendor=ibm
9988255a313Smrg		;;
9993d13e800Smrg	vax-unknown)
10003d13e800Smrg		vendor=dec
10018255a313Smrg		;;
10023d13e800Smrg	pdp11-unknown)
10033d13e800Smrg		vendor=dec
10048255a313Smrg		;;
10053d13e800Smrg	we32k-unknown)
10063d13e800Smrg		vendor=att
10078255a313Smrg		;;
10083d13e800Smrg	cydra-unknown)
10093d13e800Smrg		vendor=cydrome
10108255a313Smrg		;;
10113d13e800Smrg	i370-ibm*)
10123d13e800Smrg		vendor=ibm
10138255a313Smrg		;;
10143d13e800Smrg	orion-unknown)
10153d13e800Smrg		vendor=highlevel
10168255a313Smrg		;;
10173d13e800Smrg	xps-unknown | xps100-unknown)
10183d13e800Smrg		cpu=xps100
10193d13e800Smrg		vendor=honeywell
10208255a313Smrg		;;
10213d13e800Smrg
10223d13e800Smrg	# Here we normalize CPU types with a missing or matching vendor
102322138c50Smrg	armh-unknown | armh-alt)
102422138c50Smrg		cpu=armv7l
102522138c50Smrg		vendor=alt
102622138c50Smrg		basic_os=${basic_os:-linux-gnueabihf}
102722138c50Smrg		;;
10283d13e800Smrg	dpx20-unknown | dpx20-bull)
10293d13e800Smrg		cpu=rs6000
10303d13e800Smrg		vendor=bull
10313d13e800Smrg		basic_os=${basic_os:-bosx}
10328255a313Smrg		;;
10333d13e800Smrg
10343d13e800Smrg	# Here we normalize CPU types irrespective of the vendor
10353d13e800Smrg	amd64-*)
10363d13e800Smrg		cpu=x86_64
10378255a313Smrg		;;
10383d13e800Smrg	blackfin-*)
10393d13e800Smrg		cpu=bfin
10403d13e800Smrg		basic_os=linux
10418255a313Smrg		;;
10423d13e800Smrg	c54x-*)
10433d13e800Smrg		cpu=tic54x
10448255a313Smrg		;;
10453d13e800Smrg	c55x-*)
10463d13e800Smrg		cpu=tic55x
10478255a313Smrg		;;
10483d13e800Smrg	c6x-*)
10493d13e800Smrg		cpu=tic6x
10508255a313Smrg		;;
10513d13e800Smrg	e500v[12]-*)
10523d13e800Smrg		cpu=powerpc
10533d13e800Smrg		basic_os=${basic_os}"spe"
10548255a313Smrg		;;
10553d13e800Smrg	mips3*-*)
10563d13e800Smrg		cpu=mips64
10578255a313Smrg		;;
10583d13e800Smrg	ms1-*)
10593d13e800Smrg		cpu=mt
10608255a313Smrg		;;
10613d13e800Smrg	m68knommu-*)
10623d13e800Smrg		cpu=m68k
10633d13e800Smrg		basic_os=linux
10648255a313Smrg		;;
10653d13e800Smrg	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10663d13e800Smrg		cpu=s12z
10678255a313Smrg		;;
10683d13e800Smrg	openrisc-*)
10693d13e800Smrg		cpu=or32
10708255a313Smrg		;;
10713d13e800Smrg	parisc-*)
10723d13e800Smrg		cpu=hppa
10733d13e800Smrg		basic_os=linux
10748255a313Smrg		;;
10753d13e800Smrg	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10763d13e800Smrg		cpu=i586
10778255a313Smrg		;;
107822138c50Smrg	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10793d13e800Smrg		cpu=i686
10808255a313Smrg		;;
10813d13e800Smrg	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10823d13e800Smrg		cpu=i686
10838255a313Smrg		;;
10843d13e800Smrg	pentium4-*)
10853d13e800Smrg		cpu=i786
10868255a313Smrg		;;
10873d13e800Smrg	pc98-*)
10883d13e800Smrg		cpu=i386
10898255a313Smrg		;;
10903d13e800Smrg	ppc-* | ppcbe-*)
10913d13e800Smrg		cpu=powerpc
10928255a313Smrg		;;
10933d13e800Smrg	ppcle-* | powerpclittle-*)
10943d13e800Smrg		cpu=powerpcle
10958255a313Smrg		;;
10963d13e800Smrg	ppc64-*)
10973d13e800Smrg		cpu=powerpc64
109801395c31Smrg		;;
10993d13e800Smrg	ppc64le-* | powerpc64little-*)
11003d13e800Smrg		cpu=powerpc64le
11018255a313Smrg		;;
11023d13e800Smrg	sb1-*)
11033d13e800Smrg		cpu=mipsisa64sb1
11048255a313Smrg		;;
11053d13e800Smrg	sb1el-*)
11063d13e800Smrg		cpu=mipsisa64sb1el
11078255a313Smrg		;;
11083d13e800Smrg	sh5e[lb]-*)
11093d13e800Smrg		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
11108255a313Smrg		;;
11113d13e800Smrg	spur-*)
11123d13e800Smrg		cpu=spur
11138255a313Smrg		;;
11143d13e800Smrg	strongarm-* | thumb-*)
11153d13e800Smrg		cpu=arm
11168255a313Smrg		;;
11173d13e800Smrg	tx39-*)
11183d13e800Smrg		cpu=mipstx39
11198255a313Smrg		;;
11203d13e800Smrg	tx39el-*)
11213d13e800Smrg		cpu=mipstx39el
11228255a313Smrg		;;
11233d13e800Smrg	x64-*)
11243d13e800Smrg		cpu=x86_64
11258255a313Smrg		;;
11263d13e800Smrg	xscale-* | xscalee[bl]-*)
11273d13e800Smrg		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11288255a313Smrg		;;
112922138c50Smrg	arm64-* | aarch64le-*)
11303d13e800Smrg		cpu=aarch64
11318255a313Smrg		;;
11323d13e800Smrg
11333d13e800Smrg	# Recognize the canonical CPU Types that limit and/or modify the
11343d13e800Smrg	# company names they are paired with.
11353d13e800Smrg	cr16-*)
11363d13e800Smrg		basic_os=${basic_os:-elf}
11378255a313Smrg		;;
11383d13e800Smrg	crisv32-* | etraxfs*-*)
11393d13e800Smrg		cpu=crisv32
11403d13e800Smrg		vendor=axis
11418255a313Smrg		;;
11423d13e800Smrg	cris-* | etrax*-*)
11433d13e800Smrg		cpu=cris
11443d13e800Smrg		vendor=axis
11458255a313Smrg		;;
11463d13e800Smrg	crx-*)
11473d13e800Smrg		basic_os=${basic_os:-elf}
11488255a313Smrg		;;
11493d13e800Smrg	neo-tandem)
11503d13e800Smrg		cpu=neo
11513d13e800Smrg		vendor=tandem
11528255a313Smrg		;;
11533d13e800Smrg	nse-tandem)
11543d13e800Smrg		cpu=nse
11553d13e800Smrg		vendor=tandem
11568255a313Smrg		;;
11573d13e800Smrg	nsr-tandem)
11583d13e800Smrg		cpu=nsr
11593d13e800Smrg		vendor=tandem
11608255a313Smrg		;;
11613d13e800Smrg	nsv-tandem)
11623d13e800Smrg		cpu=nsv
11633d13e800Smrg		vendor=tandem
11648255a313Smrg		;;
11653d13e800Smrg	nsx-tandem)
11663d13e800Smrg		cpu=nsx
11673d13e800Smrg		vendor=tandem
11688255a313Smrg		;;
11693d13e800Smrg	mipsallegrexel-sony)
11703d13e800Smrg		cpu=mipsallegrexel
11713d13e800Smrg		vendor=sony
11728255a313Smrg		;;
11733d13e800Smrg	tile*-*)
11743d13e800Smrg		basic_os=${basic_os:-linux-gnu}
11758255a313Smrg		;;
11763d13e800Smrg
11778255a313Smrg	*)
11783d13e800Smrg		# Recognize the canonical CPU types that are allowed with any
11793d13e800Smrg		# company name.
11803d13e800Smrg		case $cpu in
11813d13e800Smrg			1750a | 580 \
11823d13e800Smrg			| a29k \
11833d13e800Smrg			| aarch64 | aarch64_be \
11843d13e800Smrg			| abacus \
11853d13e800Smrg			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
11863d13e800Smrg			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
11873d13e800Smrg			| alphapca5[67] | alpha64pca5[67] \
11883d13e800Smrg			| am33_2.0 \
11893d13e800Smrg			| amdgcn \
11903d13e800Smrg			| arc | arceb | arc32 | arc64 \
11913d13e800Smrg			| arm | arm[lb]e | arme[lb] | armv* \
11923d13e800Smrg			| avr | avr32 \
11933d13e800Smrg			| asmjs \
11943d13e800Smrg			| ba \
11953d13e800Smrg			| be32 | be64 \
11963d13e800Smrg			| bfin | bpf | bs2000 \
11973d13e800Smrg			| c[123]* | c30 | [cjt]90 | c4x \
11983d13e800Smrg			| c8051 | clipper | craynv | csky | cydra \
11993d13e800Smrg			| d10v | d30v | dlx | dsp16xx \
12003d13e800Smrg			| e2k | elxsi | epiphany \
12013d13e800Smrg			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
12023d13e800Smrg			| h8300 | h8500 \
12033d13e800Smrg			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
12043d13e800Smrg			| hexagon \
12053d13e800Smrg			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
12063d13e800Smrg			| ip2k | iq2000 \
12073d13e800Smrg			| k1om \
12083d13e800Smrg			| le32 | le64 \
12093d13e800Smrg			| lm32 \
121022138c50Smrg			| loongarch32 | loongarch64 \
12113d13e800Smrg			| m32c | m32r | m32rle \
12123d13e800Smrg			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
12133d13e800Smrg			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
12143d13e800Smrg			| m88110 | m88k | maxq | mb | mcore | mep | metag \
12153d13e800Smrg			| microblaze | microblazeel \
12163d13e800Smrg			| mips | mipsbe | mipseb | mipsel | mipsle \
12173d13e800Smrg			| mips16 \
12183d13e800Smrg			| mips64 | mips64eb | mips64el \
12193d13e800Smrg			| mips64octeon | mips64octeonel \
12203d13e800Smrg			| mips64orion | mips64orionel \
12213d13e800Smrg			| mips64r5900 | mips64r5900el \
12223d13e800Smrg			| mips64vr | mips64vrel \
12233d13e800Smrg			| mips64vr4100 | mips64vr4100el \
12243d13e800Smrg			| mips64vr4300 | mips64vr4300el \
12253d13e800Smrg			| mips64vr5000 | mips64vr5000el \
12263d13e800Smrg			| mips64vr5900 | mips64vr5900el \
12273d13e800Smrg			| mipsisa32 | mipsisa32el \
12283d13e800Smrg			| mipsisa32r2 | mipsisa32r2el \
12293d13e800Smrg			| mipsisa32r3 | mipsisa32r3el \
12303d13e800Smrg			| mipsisa32r5 | mipsisa32r5el \
12313d13e800Smrg			| mipsisa32r6 | mipsisa32r6el \
12323d13e800Smrg			| mipsisa64 | mipsisa64el \
12333d13e800Smrg			| mipsisa64r2 | mipsisa64r2el \
12343d13e800Smrg			| mipsisa64r3 | mipsisa64r3el \
12353d13e800Smrg			| mipsisa64r5 | mipsisa64r5el \
12363d13e800Smrg			| mipsisa64r6 | mipsisa64r6el \
12373d13e800Smrg			| mipsisa64sb1 | mipsisa64sb1el \
12383d13e800Smrg			| mipsisa64sr71k | mipsisa64sr71kel \
12393d13e800Smrg			| mipsr5900 | mipsr5900el \
12403d13e800Smrg			| mipstx39 | mipstx39el \
12413d13e800Smrg			| mmix \
12423d13e800Smrg			| mn10200 | mn10300 \
12433d13e800Smrg			| moxie \
12443d13e800Smrg			| mt \
12453d13e800Smrg			| msp430 \
12463d13e800Smrg			| nds32 | nds32le | nds32be \
12473d13e800Smrg			| nfp \
12483d13e800Smrg			| nios | nios2 | nios2eb | nios2el \
12493d13e800Smrg			| none | np1 | ns16k | ns32k | nvptx \
12503d13e800Smrg			| open8 \
12513d13e800Smrg			| or1k* \
12523d13e800Smrg			| or32 \
12533d13e800Smrg			| orion \
12543d13e800Smrg			| picochip \
12553d13e800Smrg			| pdp10 | pdp11 | pj | pjl | pn | power \
12563d13e800Smrg			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
12573d13e800Smrg			| pru \
12583d13e800Smrg			| pyramid \
12593d13e800Smrg			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
12603d13e800Smrg			| rl78 | romp | rs6000 | rx \
12613d13e800Smrg			| s390 | s390x \
12623d13e800Smrg			| score \
12633d13e800Smrg			| sh | shl \
12643d13e800Smrg			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
12653d13e800Smrg			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
12663d13e800Smrg			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
12673d13e800Smrg			| sparclite \
12683d13e800Smrg			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
12693d13e800Smrg			| spu \
12703d13e800Smrg			| tahoe \
12713d13e800Smrg			| thumbv7* \
12723d13e800Smrg			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
12733d13e800Smrg			| tron \
12743d13e800Smrg			| ubicom32 \
12753d13e800Smrg			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
12763d13e800Smrg			| vax \
12773d13e800Smrg			| visium \
12783d13e800Smrg			| w65 \
12793d13e800Smrg			| wasm32 | wasm64 \
12803d13e800Smrg			| we32k \
12813d13e800Smrg			| x86 | x86_64 | xc16x | xgate | xps100 \
12823d13e800Smrg			| xstormy16 | xtensa* \
12833d13e800Smrg			| ymp \
12843d13e800Smrg			| z8k | z80)
12853d13e800Smrg				;;
12863d13e800Smrg
12873d13e800Smrg			*)
12883d13e800Smrg				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
12893d13e800Smrg				exit 1
12903d13e800Smrg				;;
12913d13e800Smrg		esac
12928255a313Smrg		;;
12938255a313Smrgesac
12948255a313Smrg
12958255a313Smrg# Here we canonicalize certain aliases for manufacturers.
12963d13e800Smrgcase $vendor in
12973d13e800Smrg	digital*)
12983d13e800Smrg		vendor=dec
12998255a313Smrg		;;
13003d13e800Smrg	commodore*)
13013d13e800Smrg		vendor=cbm
13028255a313Smrg		;;
13038255a313Smrg	*)
13048255a313Smrg		;;
13058255a313Smrgesac
13068255a313Smrg
13078255a313Smrg# Decode manufacturer-specific aliases for certain operating systems.
13088255a313Smrg
13093d13e800Smrgif test x$basic_os != x
13108255a313Smrgthen
13113d13e800Smrg
131222138c50Smrg# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13133d13e800Smrg# set os.
13143d13e800Smrgcase $basic_os in
13153d13e800Smrg	gnu/linux*)
13163d13e800Smrg		kernel=linux
13173d13e800Smrg		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13183d13e800Smrg		;;
13193d13e800Smrg	os2-emx)
13203d13e800Smrg		kernel=os2
13213d13e800Smrg		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
13223d13e800Smrg		;;
13233d13e800Smrg	nto-qnx*)
13243d13e800Smrg		kernel=nto
13253d13e800Smrg		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13263d13e800Smrg		;;
13273d13e800Smrg	*-*)
13283d13e800Smrg		# shellcheck disable=SC2162
13293d13e800Smrg		saved_IFS=$IFS
13303d13e800Smrg		IFS="-" read kernel os <<EOF
13313d13e800Smrg$basic_os
13323d13e800SmrgEOF
13333d13e800Smrg		IFS=$saved_IFS
13343d13e800Smrg		;;
13353d13e800Smrg	# Default OS when just kernel was specified
13363d13e800Smrg	nto*)
13373d13e800Smrg		kernel=nto
13383d13e800Smrg		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
13393d13e800Smrg		;;
13403d13e800Smrg	linux*)
13413d13e800Smrg		kernel=linux
13423d13e800Smrg		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13433d13e800Smrg		;;
134422138c50Smrg	managarm*)
134522138c50Smrg		kernel=managarm
134622138c50Smrg		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
134722138c50Smrg		;;
13483d13e800Smrg	*)
13493d13e800Smrg		kernel=
13503d13e800Smrg		os=$basic_os
1351de7ed6e8Smrg		;;
13523d13e800Smrgesac
13533d13e800Smrg
13543d13e800Smrg# Now, normalize the OS (knowing we just have one component, it's not a kernel,
13553d13e800Smrg# etc.)
13563d13e800Smrgcase $os in
13573d13e800Smrg	# First match some system type aliases that might get confused
13583d13e800Smrg	# with valid system types.
13593d13e800Smrg	# solaris* is a basic system type, with this one exception.
13603d13e800Smrg	auroraux)
13613d13e800Smrg		os=auroraux
13628255a313Smrg		;;
13633d13e800Smrg	bluegene*)
13643d13e800Smrg		os=cnk
13658255a313Smrg		;;
13663d13e800Smrg	solaris1 | solaris1.*)
13673d13e800Smrg		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
13688255a313Smrg		;;
13693d13e800Smrg	solaris)
13703d13e800Smrg		os=solaris2
13718255a313Smrg		;;
13723d13e800Smrg	unixware*)
13733d13e800Smrg		os=sysv4.2uw
13748255a313Smrg		;;
13753d13e800Smrg	# es1800 is here to avoid being matched by es* (a different OS)
13763d13e800Smrg	es1800*)
13773d13e800Smrg		os=ose
13788255a313Smrg		;;
13793d13e800Smrg	# Some version numbers need modification
13803d13e800Smrg	chorusos*)
13813d13e800Smrg		os=chorusos
13828255a313Smrg		;;
13833d13e800Smrg	isc)
13843d13e800Smrg		os=isc2.2
13858255a313Smrg		;;
13863d13e800Smrg	sco6)
13873d13e800Smrg		os=sco5v6
13888255a313Smrg		;;
13893d13e800Smrg	sco5)
13903d13e800Smrg		os=sco3.2v5
13918255a313Smrg		;;
13923d13e800Smrg	sco4)
13933d13e800Smrg		os=sco3.2v4
13948255a313Smrg		;;
13953d13e800Smrg	sco3.2.[4-9]*)
13963d13e800Smrg		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
13978255a313Smrg		;;
13983d13e800Smrg	sco*v* | scout)
13993d13e800Smrg		# Don't match below
14008255a313Smrg		;;
14013d13e800Smrg	sco*)
14023d13e800Smrg		os=sco3.2v2
14038255a313Smrg		;;
14043d13e800Smrg	psos*)
14053d13e800Smrg		os=psos
14068255a313Smrg		;;
14073d13e800Smrg	qnx*)
14083d13e800Smrg		os=qnx
14098255a313Smrg		;;
14103d13e800Smrg	hiux*)
14113d13e800Smrg		os=hiuxwe2
14128255a313Smrg		;;
14133d13e800Smrg	lynx*178)
14143d13e800Smrg		os=lynxos178
14158255a313Smrg		;;
14163d13e800Smrg	lynx*5)
14173d13e800Smrg		os=lynxos5
14188255a313Smrg		;;
14193d13e800Smrg	lynxos*)
14203d13e800Smrg		# don't get caught up in next wildcard
14218255a313Smrg		;;
14223d13e800Smrg	lynx*)
14233d13e800Smrg		os=lynxos
14248255a313Smrg		;;
14253d13e800Smrg	mac[0-9]*)
14263d13e800Smrg		os=`echo "$os" | sed -e 's|mac|macos|'`
14278255a313Smrg		;;
14283d13e800Smrg	opened*)
14293d13e800Smrg		os=openedition
14308255a313Smrg		;;
14313d13e800Smrg	os400*)
14323d13e800Smrg		os=os400
14338255a313Smrg		;;
14343d13e800Smrg	sunos5*)
14353d13e800Smrg		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
14368255a313Smrg		;;
14373d13e800Smrg	sunos6*)
14383d13e800Smrg		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
14398255a313Smrg		;;
14403d13e800Smrg	wince*)
14413d13e800Smrg		os=wince
14428255a313Smrg		;;
14433d13e800Smrg	utek*)
14443d13e800Smrg		os=bsd
14458255a313Smrg		;;
14463d13e800Smrg	dynix*)
14473d13e800Smrg		os=bsd
14488255a313Smrg		;;
14493d13e800Smrg	acis*)
14503d13e800Smrg		os=aos
14518255a313Smrg		;;
14523d13e800Smrg	atheos*)
14533d13e800Smrg		os=atheos
14548255a313Smrg		;;
14553d13e800Smrg	syllable*)
14563d13e800Smrg		os=syllable
14578255a313Smrg		;;
14583d13e800Smrg	386bsd)
14593d13e800Smrg		os=bsd
14608255a313Smrg		;;
14613d13e800Smrg	ctix* | uts*)
14623d13e800Smrg		os=sysv
14638255a313Smrg		;;
14643d13e800Smrg	nova*)
14653d13e800Smrg		os=rtmk-nova
14668255a313Smrg		;;
14673d13e800Smrg	ns2)
14683d13e800Smrg		os=nextstep2
14698255a313Smrg		;;
14703d13e800Smrg	# Preserve the version number of sinix5.
14713d13e800Smrg	sinix5.*)
14723d13e800Smrg		os=`echo "$os" | sed -e 's|sinix|sysv|'`
14738255a313Smrg		;;
14743d13e800Smrg	sinix*)
14753d13e800Smrg		os=sysv4
14768255a313Smrg		;;
14773d13e800Smrg	tpf*)
14783d13e800Smrg		os=tpf
14798255a313Smrg		;;
14803d13e800Smrg	triton*)
14813d13e800Smrg		os=sysv3
14828255a313Smrg		;;
14833d13e800Smrg	oss*)
14843d13e800Smrg		os=sysv3
14858255a313Smrg		;;
14863d13e800Smrg	svr4*)
14873d13e800Smrg		os=sysv4
14888255a313Smrg		;;
14893d13e800Smrg	svr3)
14903d13e800Smrg		os=sysv3
14918255a313Smrg		;;
14923d13e800Smrg	sysvr4)
14933d13e800Smrg		os=sysv4
14948255a313Smrg		;;
14953d13e800Smrg	ose*)
14963d13e800Smrg		os=ose
14978255a313Smrg		;;
14983d13e800Smrg	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
14993d13e800Smrg		os=mint
150001395c31Smrg		;;
15013d13e800Smrg	dicos*)
15023d13e800Smrg		os=dicos
150301395c31Smrg		;;
15043d13e800Smrg	pikeos*)
15053d13e800Smrg		# Until real need of OS specific support for
15063d13e800Smrg		# particular features comes up, bare metal
15073d13e800Smrg		# configurations are quite functional.
15083d13e800Smrg		case $cpu in
15093d13e800Smrg		    arm*)
15103d13e800Smrg			os=eabi
15113d13e800Smrg			;;
15123d13e800Smrg		    *)
15133d13e800Smrg			os=elf
15143d13e800Smrg			;;
15153d13e800Smrg		esac
15168255a313Smrg		;;
15178255a313Smrg	*)
15183d13e800Smrg		# No normalization, but not necessarily accepted, that comes below.
15198255a313Smrg		;;
15208255a313Smrgesac
15213d13e800Smrg
15228255a313Smrgelse
15238255a313Smrg
15248255a313Smrg# Here we handle the default operating systems that come with various machines.
15258255a313Smrg# The value should be what the vendor currently ships out the door with their
15268255a313Smrg# machine or put another way, the most popular os provided with the machine.
15278255a313Smrg
15288255a313Smrg# Note that if you're going to try to match "-MANUFACTURER" here (say,
15298255a313Smrg# "-sun"), then you have to tell the case statement up towards the top
15308255a313Smrg# that MANUFACTURER isn't an operating system.  Otherwise, code above
15318255a313Smrg# will signal an error saying that MANUFACTURER isn't an operating
15328255a313Smrg# system, and we'll never get to this point.
15338255a313Smrg
15343d13e800Smrgkernel=
15353d13e800Smrgcase $cpu-$vendor in
153601395c31Smrg	score-*)
15373d13e800Smrg		os=elf
15388255a313Smrg		;;
153901395c31Smrg	spu-*)
15403d13e800Smrg		os=elf
15418255a313Smrg		;;
15428255a313Smrg	*-acorn)
15433d13e800Smrg		os=riscix1.2
15448255a313Smrg		;;
15458255a313Smrg	arm*-rebel)
15463d13e800Smrg		kernel=linux
15473d13e800Smrg		os=gnu
15488255a313Smrg		;;
15498255a313Smrg	arm*-semi)
15503d13e800Smrg		os=aout
15518255a313Smrg		;;
155201395c31Smrg	c4x-* | tic4x-*)
15533d13e800Smrg		os=coff
155401395c31Smrg		;;
155501395c31Smrg	c8051-*)
15563d13e800Smrg		os=elf
15573d13e800Smrg		;;
15583d13e800Smrg	clipper-intergraph)
15593d13e800Smrg		os=clix
156001395c31Smrg		;;
156101395c31Smrg	hexagon-*)
15623d13e800Smrg		os=elf
15638255a313Smrg		;;
1564de7ed6e8Smrg	tic54x-*)
15653d13e800Smrg		os=coff
1566de7ed6e8Smrg		;;
1567de7ed6e8Smrg	tic55x-*)
15683d13e800Smrg		os=coff
1569de7ed6e8Smrg		;;
1570de7ed6e8Smrg	tic6x-*)
15713d13e800Smrg		os=coff
1572de7ed6e8Smrg		;;
15738255a313Smrg	# This must come before the *-dec entry.
15748255a313Smrg	pdp10-*)
15753d13e800Smrg		os=tops20
15768255a313Smrg		;;
15778255a313Smrg	pdp11-*)
15783d13e800Smrg		os=none
15798255a313Smrg		;;
15808255a313Smrg	*-dec | vax-*)
15813d13e800Smrg		os=ultrix4.2
15828255a313Smrg		;;
15838255a313Smrg	m68*-apollo)
15843d13e800Smrg		os=domain
15858255a313Smrg		;;
15868255a313Smrg	i386-sun)
15873d13e800Smrg		os=sunos4.0.2
15888255a313Smrg		;;
15898255a313Smrg	m68000-sun)
15903d13e800Smrg		os=sunos3
15918255a313Smrg		;;
15928255a313Smrg	m68*-cisco)
15933d13e800Smrg		os=aout
15948255a313Smrg		;;
159501395c31Smrg	mep-*)
15963d13e800Smrg		os=elf
15978255a313Smrg		;;
15988255a313Smrg	mips*-cisco)
15993d13e800Smrg		os=elf
16008255a313Smrg		;;
16018255a313Smrg	mips*-*)
16023d13e800Smrg		os=elf
16038255a313Smrg		;;
16048255a313Smrg	or32-*)
16053d13e800Smrg		os=coff
16068255a313Smrg		;;
16078255a313Smrg	*-tti)	# must be before sparc entry or we get the wrong os.
16083d13e800Smrg		os=sysv3
16098255a313Smrg		;;
16108255a313Smrg	sparc-* | *-sun)
16113d13e800Smrg		os=sunos4.1.1
16128255a313Smrg		;;
161301395c31Smrg	pru-*)
16143d13e800Smrg		os=elf
161501395c31Smrg		;;
16168255a313Smrg	*-be)
16173d13e800Smrg		os=beos
16188255a313Smrg		;;
16198255a313Smrg	*-ibm)
16203d13e800Smrg		os=aix
16218255a313Smrg		;;
162201395c31Smrg	*-knuth)
16233d13e800Smrg		os=mmixware
16248255a313Smrg		;;
16258255a313Smrg	*-wec)
16263d13e800Smrg		os=proelf
16278255a313Smrg		;;
16288255a313Smrg	*-winbond)
16293d13e800Smrg		os=proelf
16308255a313Smrg		;;
16318255a313Smrg	*-oki)
16323d13e800Smrg		os=proelf
16338255a313Smrg		;;
16348255a313Smrg	*-hp)
16353d13e800Smrg		os=hpux
16368255a313Smrg		;;
16378255a313Smrg	*-hitachi)
16383d13e800Smrg		os=hiux
16398255a313Smrg		;;
16408255a313Smrg	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16413d13e800Smrg		os=sysv
16428255a313Smrg		;;
16438255a313Smrg	*-cbm)
16443d13e800Smrg		os=amigaos
16458255a313Smrg		;;
16468255a313Smrg	*-dg)
16473d13e800Smrg		os=dgux
16488255a313Smrg		;;
16498255a313Smrg	*-dolphin)
16503d13e800Smrg		os=sysv3
16518255a313Smrg		;;
16528255a313Smrg	m68k-ccur)
16533d13e800Smrg		os=rtu
16548255a313Smrg		;;
16558255a313Smrg	m88k-omron*)
16563d13e800Smrg		os=luna
16578255a313Smrg		;;
16583d13e800Smrg	*-next)
16593d13e800Smrg		os=nextstep
16608255a313Smrg		;;
16618255a313Smrg	*-sequent)
16623d13e800Smrg		os=ptx
16638255a313Smrg		;;
16648255a313Smrg	*-crds)
16653d13e800Smrg		os=unos
16668255a313Smrg		;;
16678255a313Smrg	*-ns)
16683d13e800Smrg		os=genix
16698255a313Smrg		;;
16708255a313Smrg	i370-*)
16713d13e800Smrg		os=mvs
16728255a313Smrg		;;
16738255a313Smrg	*-gould)
16743d13e800Smrg		os=sysv
16758255a313Smrg		;;
16768255a313Smrg	*-highlevel)
16773d13e800Smrg		os=bsd
16788255a313Smrg		;;
16798255a313Smrg	*-encore)
16803d13e800Smrg		os=bsd
16818255a313Smrg		;;
16828255a313Smrg	*-sgi)
16833d13e800Smrg		os=irix
16848255a313Smrg		;;
16858255a313Smrg	*-siemens)
16863d13e800Smrg		os=sysv4
16878255a313Smrg		;;
16888255a313Smrg	*-masscomp)
16893d13e800Smrg		os=rtu
16908255a313Smrg		;;
16918255a313Smrg	f30[01]-fujitsu | f700-fujitsu)
16923d13e800Smrg		os=uxpv
16938255a313Smrg		;;
16948255a313Smrg	*-rom68k)
16953d13e800Smrg		os=coff
16968255a313Smrg		;;
16978255a313Smrg	*-*bug)
16983d13e800Smrg		os=coff
16998255a313Smrg		;;
17008255a313Smrg	*-apple)
17013d13e800Smrg		os=macos
17028255a313Smrg		;;
17038255a313Smrg	*-atari*)
17043d13e800Smrg		os=mint
17053d13e800Smrg		;;
17063d13e800Smrg	*-wrs)
17073d13e800Smrg		os=vxworks
17088255a313Smrg		;;
17098255a313Smrg	*)
17103d13e800Smrg		os=none
17118255a313Smrg		;;
17128255a313Smrgesac
17133d13e800Smrg
17148255a313Smrgfi
17158255a313Smrg
17163d13e800Smrg# Now, validate our (potentially fixed-up) OS.
17173d13e800Smrgcase $os in
17183d13e800Smrg	# Sometimes we do "kernel-libc", so those need to count as OSes.
17193d13e800Smrg	musl* | newlib* | relibc* | uclibc*)
17203d13e800Smrg		;;
17213d13e800Smrg	# Likewise for "kernel-abi"
17223d13e800Smrg	eabi* | gnueabi*)
17233d13e800Smrg		;;
17243d13e800Smrg	# VxWorks passes extra cpu info in the 4th filed.
17253d13e800Smrg	simlinux | simwindows | spe)
17263d13e800Smrg		;;
17273d13e800Smrg	# Now accept the basic system types.
17283d13e800Smrg	# The portable systems comes first.
17293d13e800Smrg	# Each alternative MUST end in a * to match a version number.
17303d13e800Smrg	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
17313d13e800Smrg	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
17323d13e800Smrg	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
17333d13e800Smrg	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
17343d13e800Smrg	     | hiux* | abug | nacl* | netware* | windows* \
17353d13e800Smrg	     | os9* | macos* | osx* | ios* \
17363d13e800Smrg	     | mpw* | magic* | mmixware* | mon960* | lnews* \
17373d13e800Smrg	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
17383d13e800Smrg	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
17393d13e800Smrg	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
17403d13e800Smrg	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
17413d13e800Smrg	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
17423d13e800Smrg	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
17433d13e800Smrg	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
17443d13e800Smrg	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
17453d13e800Smrg	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
17463d13e800Smrg	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
17473d13e800Smrg	     | chorusrdb* | cegcc* | glidix* | serenity* \
17483d13e800Smrg	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
17493d13e800Smrg	     | midipix* | mingw32* | mingw64* | mint* \
17503d13e800Smrg	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
17513d13e800Smrg	     | interix* | uwin* | mks* | rhapsody* | darwin* \
17523d13e800Smrg	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
17533d13e800Smrg	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
17543d13e800Smrg	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
17553d13e800Smrg	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
17563d13e800Smrg	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
17573d13e800Smrg	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17583d13e800Smrg	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17593d13e800Smrg	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
176022138c50Smrg	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
176122138c50Smrg	     | fiwix* | mlibc* )
17623d13e800Smrg		;;
17633d13e800Smrg	# This one is extra strict with allowed versions
17643d13e800Smrg	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17653d13e800Smrg		# Don't forget version if it is 3.2v4 or newer.
17663d13e800Smrg		;;
17673d13e800Smrg	none)
17683d13e800Smrg		;;
176922138c50Smrg	kernel* )
177022138c50Smrg		# Restricted further below
177122138c50Smrg		;;
17723d13e800Smrg	*)
17733d13e800Smrg		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
17743d13e800Smrg		exit 1
17753d13e800Smrg		;;
17763d13e800Smrgesac
17773d13e800Smrg
17783d13e800Smrg# As a final step for OS-related things, validate the OS-kernel combination
17793d13e800Smrg# (given a valid OS), if there is a kernel.
17803d13e800Smrgcase $kernel-$os in
17813d13e800Smrg	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
178222138c50Smrg		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17833d13e800Smrg		;;
17843d13e800Smrg	uclinux-uclibc* )
17853d13e800Smrg		;;
178622138c50Smrg	managarm-mlibc* | managarm-kernel* )
178722138c50Smrg		;;
178822138c50Smrg	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17893d13e800Smrg		# These are just libc implementations, not actual OSes, and thus
17903d13e800Smrg		# require a kernel.
17913d13e800Smrg		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
17923d13e800Smrg		exit 1
17933d13e800Smrg		;;
179422138c50Smrg	-kernel* )
179522138c50Smrg		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
179622138c50Smrg		exit 1
179722138c50Smrg		;;
179822138c50Smrg	*-kernel* )
179922138c50Smrg		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
180022138c50Smrg		exit 1
180122138c50Smrg		;;
18023d13e800Smrg	kfreebsd*-gnu* | kopensolaris*-gnu*)
18033d13e800Smrg		;;
18043d13e800Smrg	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
18053d13e800Smrg		;;
18063d13e800Smrg	nto-qnx*)
18073d13e800Smrg		;;
18083d13e800Smrg	os2-emx)
18093d13e800Smrg		;;
18103d13e800Smrg	*-eabi* | *-gnueabi*)
18113d13e800Smrg		;;
18123d13e800Smrg	-*)
18133d13e800Smrg		# Blank kernel with real OS is always fine.
18143d13e800Smrg		;;
18153d13e800Smrg	*-*)
18163d13e800Smrg		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
18173d13e800Smrg		exit 1
18183d13e800Smrg		;;
18193d13e800Smrgesac
18203d13e800Smrg
18218255a313Smrg# Here we handle the case where we know the os, and the CPU type, but not the
18228255a313Smrg# manufacturer.  We pick the logical manufacturer.
18233d13e800Smrgcase $vendor in
18243d13e800Smrg	unknown)
18253d13e800Smrg		case $cpu-$os in
18263d13e800Smrg			*-riscix*)
18278255a313Smrg				vendor=acorn
18288255a313Smrg				;;
18293d13e800Smrg			*-sunos*)
18308255a313Smrg				vendor=sun
18318255a313Smrg				;;
18323d13e800Smrg			*-cnk* | *-aix*)
18338255a313Smrg				vendor=ibm
18348255a313Smrg				;;
18353d13e800Smrg			*-beos*)
18368255a313Smrg				vendor=be
18378255a313Smrg				;;
18383d13e800Smrg			*-hpux*)
18398255a313Smrg				vendor=hp
18408255a313Smrg				;;
18413d13e800Smrg			*-mpeix*)
18428255a313Smrg				vendor=hp
18438255a313Smrg				;;
18443d13e800Smrg			*-hiux*)
18458255a313Smrg				vendor=hitachi
18468255a313Smrg				;;
18473d13e800Smrg			*-unos*)
18488255a313Smrg				vendor=crds
18498255a313Smrg				;;
18503d13e800Smrg			*-dgux*)
18518255a313Smrg				vendor=dg
18528255a313Smrg				;;
18533d13e800Smrg			*-luna*)
18548255a313Smrg				vendor=omron
18558255a313Smrg				;;
18563d13e800Smrg			*-genix*)
18578255a313Smrg				vendor=ns
18588255a313Smrg				;;
18593d13e800Smrg			*-clix*)
18603d13e800Smrg				vendor=intergraph
18613d13e800Smrg				;;
18623d13e800Smrg			*-mvs* | *-opened*)
18633d13e800Smrg				vendor=ibm
18643d13e800Smrg				;;
18653d13e800Smrg			*-os400*)
18668255a313Smrg				vendor=ibm
18678255a313Smrg				;;
18683d13e800Smrg			s390-* | s390x-*)
18698255a313Smrg				vendor=ibm
18708255a313Smrg				;;
18713d13e800Smrg			*-ptx*)
18728255a313Smrg				vendor=sequent
18738255a313Smrg				;;
18743d13e800Smrg			*-tpf*)
18758255a313Smrg				vendor=ibm
18768255a313Smrg				;;
18773d13e800Smrg			*-vxsim* | *-vxworks* | *-windiss*)
18788255a313Smrg				vendor=wrs
18798255a313Smrg				;;
18803d13e800Smrg			*-aux*)
18818255a313Smrg				vendor=apple
18828255a313Smrg				;;
18833d13e800Smrg			*-hms*)
18848255a313Smrg				vendor=hitachi
18858255a313Smrg				;;
18863d13e800Smrg			*-mpw* | *-macos*)
18878255a313Smrg				vendor=apple
18888255a313Smrg				;;
18893d13e800Smrg			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
18908255a313Smrg				vendor=atari
18918255a313Smrg				;;
18923d13e800Smrg			*-vos*)
18938255a313Smrg				vendor=stratus
18948255a313Smrg				;;
18958255a313Smrg		esac
18968255a313Smrg		;;
18978255a313Smrgesac
18988255a313Smrg
18993d13e800Smrgecho "$cpu-$vendor-${kernel:+$kernel-}$os"
19008255a313Smrgexit
19018255a313Smrg
19028255a313Smrg# Local variables:
19033d13e800Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
19048255a313Smrg# time-stamp-start: "timestamp='"
19058255a313Smrg# time-stamp-format: "%:y-%02m-%02d"
19068255a313Smrg# time-stamp-end: "'"
19078255a313Smrg# End:
1908