7848ad5
#! /bin/sh
7848ad5
# Configuration validation subroutine script.
7848ad5
#   Copyright 1992-2020 Free Software Foundation, Inc.
7848ad5
7848ad5
timestamp='2020-07-10'
7848ad5
7848ad5
# This file is free software; you can redistribute it and/or modify it
7848ad5
# under the terms of the GNU General Public License as published by
7848ad5
# the Free Software Foundation; either version 3 of the License, or
7848ad5
# (at your option) any later version.
7848ad5
#
7848ad5
# This program is distributed in the hope that it will be useful, but
7848ad5
# WITHOUT ANY WARRANTY; without even the implied warranty of
7848ad5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7848ad5
# General Public License for more details.
7848ad5
#
7848ad5
# You should have received a copy of the GNU General Public License
7848ad5
# along with this program; if not, see <https://www.gnu.org/licenses/>.
7848ad5
#
7848ad5
# As a special exception to the GNU General Public License, if you
7848ad5
# distribute this file as part of a program that contains a
7848ad5
# configuration script generated by Autoconf, you may include it under
7848ad5
# the same distribution terms that you use for the rest of that
7848ad5
# program.  This Exception is an additional permission under section 7
7848ad5
# of the GNU General Public License, version 3 ("GPLv3").
7848ad5
7848ad5
7848ad5
# Please send patches to <config-patches@gnu.org>.
7848ad5
#
7848ad5
# Configuration subroutine to validate and canonicalize a configuration type.
7848ad5
# Supply the specified configuration type as an argument.
7848ad5
# If it is invalid, we print an error message on stderr and exit with code 1.
7848ad5
# Otherwise, we print the canonical config type on stdout and succeed.
7848ad5
7848ad5
# You can get the latest version of this script from:
7848ad5
# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
7848ad5
7848ad5
# This file is supposed to be the same for all GNU packages
7848ad5
# and recognize all the CPU types, system types and aliases
7848ad5
# that are meaningful with *any* GNU software.
7848ad5
# Each package is responsible for reporting which valid configurations
7848ad5
# it does not support.  The user should be able to distinguish
7848ad5
# a failure to support a valid configuration from a meaningless
7848ad5
# configuration.
7848ad5
7848ad5
# The goal of this file is to map all the various variations of a given
7848ad5
# machine specification into a single specification in the form:
7848ad5
#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
7848ad5
# or in some cases, the newer four-part form:
7848ad5
#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
7848ad5
# It is wrong to echo any other type of specification.
7848ad5
7848ad5
me=`echo "$0" | sed -e 's,.*/,,'`
7848ad5
7848ad5
usage="\
7848ad5
Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
7848ad5
7848ad5
Canonicalize a configuration name.
7848ad5
7848ad5
Options:
7848ad5
  -h, --help         print this help, then exit
7848ad5
  -t, --time-stamp   print date of last modification, then exit
7848ad5
  -v, --version      print version number, then exit
7848ad5
7848ad5
Report bugs and patches to <config-patches@gnu.org>."
7848ad5
7848ad5
version="\
7848ad5
GNU config.sub ($timestamp)
7848ad5
7848ad5
Copyright 1992-2020 Free Software Foundation, Inc.
7848ad5
7848ad5
This is free software; see the source for copying conditions.  There is NO
7848ad5
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
7848ad5
7848ad5
help="
7848ad5
Try \`$me --help' for more information."
7848ad5
7848ad5
# Parse command line
7848ad5
while test $# -gt 0 ; do
7848ad5
  case $1 in
7848ad5
    --time-stamp | --time* | -t )
7848ad5
       echo "$timestamp" ; exit ;;
7848ad5
    --version | -v )
7848ad5
       echo "$version" ; exit ;;
7848ad5
    --help | --h* | -h )
7848ad5
       echo "$usage"; exit ;;
7848ad5
    -- )     # Stop option processing
7848ad5
       shift; break ;;
7848ad5
    - )	# Use stdin as input.
7848ad5
       break ;;
7848ad5
    -* )
7848ad5
       echo "$me: invalid option $1$help" >&2
7848ad5
       exit 1 ;;
7848ad5
7848ad5
    *local*)
7848ad5
       # First pass through any local machine types.
7848ad5
       echo "$1"
7848ad5
       exit ;;
7848ad5
7848ad5
    * )
7848ad5
       break ;;
7848ad5
  esac
7848ad5
done
7848ad5
7848ad5
case $# in
7848ad5
 0) echo "$me: missing argument$help" >&2
7848ad5
    exit 1;;
7848ad5
 1) ;;
7848ad5
 *) echo "$me: too many arguments$help" >&2
7848ad5
    exit 1;;
7848ad5
esac
7848ad5
7848ad5
# Split fields of configuration type
7848ad5
# shellcheck disable=SC2162
7848ad5
IFS="-" read field1 field2 field3 field4 <
7848ad5
$1
7848ad5
EOF
7848ad5
7848ad5
# Separate into logical components for further validation
7848ad5
case $1 in
7848ad5
	*-*-*-*-*)
7848ad5
		echo Invalid configuration \`"$1"\': more than four components >&2
7848ad5
		exit 1
7848ad5
		;;
7848ad5
	*-*-*-*)
7848ad5
		basic_machine=$field1-$field2
7848ad5
		basic_os=$field3-$field4
7848ad5
		;;
7848ad5
	*-*-*)
7848ad5
		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
7848ad5
		# parts
7848ad5
		maybe_os=$field2-$field3
7848ad5
		case $maybe_os in
7848ad5
			nto-qnx* | linux-* | uclinux-uclibc* \
7848ad5
			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
7848ad5
			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
7848ad5
			| storm-chaos* | os2-emx* | rtmk-nova*)
7848ad5
				basic_machine=$field1
7848ad5
				basic_os=$maybe_os
7848ad5
				;;
7848ad5
			android-linux)
7848ad5
				basic_machine=$field1-unknown
7848ad5
				basic_os=linux-android
7848ad5
				;;
7848ad5
			*)
7848ad5
				basic_machine=$field1-$field2
7848ad5
				basic_os=$field3
7848ad5
				;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	*-*)
7848ad5
		# A lone config we happen to match not fitting any pattern
7848ad5
		case $field1-$field2 in
7848ad5
			decstation-3100)
7848ad5
				basic_machine=mips-dec
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			*-*)
7848ad5
				# Second component is usually, but not always the OS
7848ad5
				case $field2 in
7848ad5
					# Prevent following clause from handling this valid os
7848ad5
					sun*os*)
7848ad5
						basic_machine=$field1
7848ad5
						basic_os=$field2
7848ad5
						;;
7848ad5
					# Manufacturers
7848ad5
					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
7848ad5
					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
7848ad5
					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
7848ad5
					| convergent* | ncr* | news | 32* | 3600* | 3100* \
7848ad5
					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
7848ad5
					| ultra | tti* | harris | dolphin | highlevel | gould \
7848ad5
					| cbm | ns | masscomp | apple | axis | knuth | cray \
7848ad5
					| microblaze* | sim | cisco \
7848ad5
					| oki | wec | wrs | winbond)
7848ad5
						basic_machine=$field1-$field2
7848ad5
						basic_os=
7848ad5
						;;
7848ad5
					*)
7848ad5
						basic_machine=$field1
7848ad5
						basic_os=$field2
7848ad5
						;;
7848ad5
				esac
7848ad5
			;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	*)
7848ad5
		# Convert single-component short-hands not valid as part of
7848ad5
		# multi-component configurations.
7848ad5
		case $field1 in
7848ad5
			386bsd)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			a29khif)
7848ad5
				basic_machine=a29k-amd
7848ad5
				basic_os=udi
7848ad5
				;;
7848ad5
			adobe68k)
7848ad5
				basic_machine=m68010-adobe
7848ad5
				basic_os=scout
7848ad5
				;;
7848ad5
			alliant)
7848ad5
				basic_machine=fx80-alliant
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			altos | altos3068)
7848ad5
				basic_machine=m68k-altos
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			am29k)
7848ad5
				basic_machine=a29k-none
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			amdahl)
7848ad5
				basic_machine=580-amdahl
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			amiga)
7848ad5
				basic_machine=m68k-unknown
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			amigaos | amigados)
7848ad5
				basic_machine=m68k-unknown
7848ad5
				basic_os=amigaos
7848ad5
				;;
7848ad5
			amigaunix | amix)
7848ad5
				basic_machine=m68k-unknown
7848ad5
				basic_os=sysv4
7848ad5
				;;
7848ad5
			apollo68)
7848ad5
				basic_machine=m68k-apollo
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			apollo68bsd)
7848ad5
				basic_machine=m68k-apollo
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			aros)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=aros
7848ad5
				;;
7848ad5
			aux)
7848ad5
				basic_machine=m68k-apple
7848ad5
				basic_os=aux
7848ad5
				;;
7848ad5
			balance)
7848ad5
				basic_machine=ns32k-sequent
7848ad5
				basic_os=dynix
7848ad5
				;;
7848ad5
			blackfin)
7848ad5
				basic_machine=bfin-unknown
7848ad5
				basic_os=linux
7848ad5
				;;
7848ad5
			cegcc)
7848ad5
				basic_machine=arm-unknown
7848ad5
				basic_os=cegcc
7848ad5
				;;
7848ad5
			convex-c1)
7848ad5
				basic_machine=c1-convex
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			convex-c2)
7848ad5
				basic_machine=c2-convex
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			convex-c32)
7848ad5
				basic_machine=c32-convex
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			convex-c34)
7848ad5
				basic_machine=c34-convex
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			convex-c38)
7848ad5
				basic_machine=c38-convex
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			cray)
7848ad5
				basic_machine=j90-cray
7848ad5
				basic_os=unicos
7848ad5
				;;
7848ad5
			crds | unos)
7848ad5
				basic_machine=m68k-crds
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			da30)
7848ad5
				basic_machine=m68k-da30
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			decstation | pmax | pmin | dec3100 | decstatn)
7848ad5
				basic_machine=mips-dec
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			delta88)
7848ad5
				basic_machine=m88k-motorola
7848ad5
				basic_os=sysv3
7848ad5
				;;
7848ad5
			dicos)
7848ad5
				basic_machine=i686-pc
7848ad5
				basic_os=dicos
7848ad5
				;;
7848ad5
			djgpp)
7848ad5
				basic_machine=i586-pc
7848ad5
				basic_os=msdosdjgpp
7848ad5
				;;
7848ad5
			ebmon29k)
7848ad5
				basic_machine=a29k-amd
7848ad5
				basic_os=ebmon
7848ad5
				;;
7848ad5
			es1800 | OSE68k | ose68k | ose | OSE)
7848ad5
				basic_machine=m68k-ericsson
7848ad5
				basic_os=ose
7848ad5
				;;
7848ad5
			gmicro)
7848ad5
				basic_machine=tron-gmicro
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			go32)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=go32
7848ad5
				;;
7848ad5
			h8300hms)
7848ad5
				basic_machine=h8300-hitachi
7848ad5
				basic_os=hms
7848ad5
				;;
7848ad5
			h8300xray)
7848ad5
				basic_machine=h8300-hitachi
7848ad5
				basic_os=xray
7848ad5
				;;
7848ad5
			h8500hms)
7848ad5
				basic_machine=h8500-hitachi
7848ad5
				basic_os=hms
7848ad5
				;;
7848ad5
			harris)
7848ad5
				basic_machine=m88k-harris
7848ad5
				basic_os=sysv3
7848ad5
				;;
7848ad5
			hp300 | hp300hpux)
7848ad5
				basic_machine=m68k-hp
7848ad5
				basic_os=hpux
7848ad5
				;;
7848ad5
			hp300bsd)
7848ad5
				basic_machine=m68k-hp
7848ad5
				basic_os=bsd
7848ad5
				;;
7848ad5
			hppaosf)
7848ad5
				basic_machine=hppa1.1-hp
7848ad5
				basic_os=osf
7848ad5
				;;
7848ad5
			hppro)
7848ad5
				basic_machine=hppa1.1-hp
7848ad5
				basic_os=proelf
7848ad5
				;;
7848ad5
			i386mach)
7848ad5
				basic_machine=i386-mach
7848ad5
				basic_os=mach
7848ad5
				;;
7848ad5
			isi68 | isi)
7848ad5
				basic_machine=m68k-isi
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			m68knommu)
7848ad5
				basic_machine=m68k-unknown
7848ad5
				basic_os=linux
7848ad5
				;;
7848ad5
			magnum | m3230)
7848ad5
				basic_machine=mips-mips
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			merlin)
7848ad5
				basic_machine=ns32k-utek
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			mingw64)
7848ad5
				basic_machine=x86_64-pc
7848ad5
				basic_os=mingw64
7848ad5
				;;
7848ad5
			mingw32)
7848ad5
				basic_machine=i686-pc
7848ad5
				basic_os=mingw32
7848ad5
				;;
7848ad5
			mingw32ce)
7848ad5
				basic_machine=arm-unknown
7848ad5
				basic_os=mingw32ce
7848ad5
				;;
7848ad5
			monitor)
7848ad5
				basic_machine=m68k-rom68k
7848ad5
				basic_os=coff
7848ad5
				;;
7848ad5
			morphos)
7848ad5
				basic_machine=powerpc-unknown
7848ad5
				basic_os=morphos
7848ad5
				;;
7848ad5
			moxiebox)
7848ad5
				basic_machine=moxie-unknown
7848ad5
				basic_os=moxiebox
7848ad5
				;;
7848ad5
			msdos)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=msdos
7848ad5
				;;
7848ad5
			msys)
7848ad5
				basic_machine=i686-pc
7848ad5
				basic_os=msys
7848ad5
				;;
7848ad5
			mvs)
7848ad5
				basic_machine=i370-ibm
7848ad5
				basic_os=mvs
7848ad5
				;;
7848ad5
			nacl)
7848ad5
				basic_machine=le32-unknown
7848ad5
				basic_os=nacl
7848ad5
				;;
7848ad5
			ncr3000)
7848ad5
				basic_machine=i486-ncr
7848ad5
				basic_os=sysv4
7848ad5
				;;
7848ad5
			netbsd386)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=netbsd
7848ad5
				;;
7848ad5
			netwinder)
7848ad5
				basic_machine=armv4l-rebel
7848ad5
				basic_os=linux
7848ad5
				;;
7848ad5
			news | news700 | news800 | news900)
7848ad5
				basic_machine=m68k-sony
7848ad5
				basic_os=newsos
7848ad5
				;;
7848ad5
			news1000)
7848ad5
				basic_machine=m68030-sony
7848ad5
				basic_os=newsos
7848ad5
				;;
7848ad5
			necv70)
7848ad5
				basic_machine=v70-nec
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			nh3000)
7848ad5
				basic_machine=m68k-harris
7848ad5
				basic_os=cxux
7848ad5
				;;
7848ad5
			nh[45]000)
7848ad5
				basic_machine=m88k-harris
7848ad5
				basic_os=cxux
7848ad5
				;;
7848ad5
			nindy960)
7848ad5
				basic_machine=i960-intel
7848ad5
				basic_os=nindy
7848ad5
				;;
7848ad5
			mon960)
7848ad5
				basic_machine=i960-intel
7848ad5
				basic_os=mon960
7848ad5
				;;
7848ad5
			nonstopux)
7848ad5
				basic_machine=mips-compaq
7848ad5
				basic_os=nonstopux
7848ad5
				;;
7848ad5
			os400)
7848ad5
				basic_machine=powerpc-ibm
7848ad5
				basic_os=os400
7848ad5
				;;
7848ad5
			OSE68000 | ose68000)
7848ad5
				basic_machine=m68000-ericsson
7848ad5
				basic_os=ose
7848ad5
				;;
7848ad5
			os68k)
7848ad5
				basic_machine=m68k-none
7848ad5
				basic_os=os68k
7848ad5
				;;
7848ad5
			paragon)
7848ad5
				basic_machine=i860-intel
7848ad5
				basic_os=osf
7848ad5
				;;
7848ad5
			parisc)
7848ad5
				basic_machine=hppa-unknown
7848ad5
				basic_os=linux
7848ad5
				;;
7848ad5
			psp)
7848ad5
				basic_machine=mipsallegrexel-sony
7848ad5
				basic_os=psp
7848ad5
				;;
7848ad5
			pw32)
7848ad5
				basic_machine=i586-unknown
7848ad5
				basic_os=pw32
7848ad5
				;;
7848ad5
			rdos | rdos64)
7848ad5
				basic_machine=x86_64-pc
7848ad5
				basic_os=rdos
7848ad5
				;;
7848ad5
			rdos32)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=rdos
7848ad5
				;;
7848ad5
			rom68k)
7848ad5
				basic_machine=m68k-rom68k
7848ad5
				basic_os=coff
7848ad5
				;;
7848ad5
			sa29200)
7848ad5
				basic_machine=a29k-amd
7848ad5
				basic_os=udi
7848ad5
				;;
7848ad5
			sei)
7848ad5
				basic_machine=mips-sei
7848ad5
				basic_os=seiux
7848ad5
				;;
7848ad5
			sequent)
7848ad5
				basic_machine=i386-sequent
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			sps7)
7848ad5
				basic_machine=m68k-bull
7848ad5
				basic_os=sysv2
7848ad5
				;;
7848ad5
			st2000)
7848ad5
				basic_machine=m68k-tandem
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			stratus)
7848ad5
				basic_machine=i860-stratus
7848ad5
				basic_os=sysv4
7848ad5
				;;
7848ad5
			sun2)
7848ad5
				basic_machine=m68000-sun
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			sun2os3)
7848ad5
				basic_machine=m68000-sun
7848ad5
				basic_os=sunos3
7848ad5
				;;
7848ad5
			sun2os4)
7848ad5
				basic_machine=m68000-sun
7848ad5
				basic_os=sunos4
7848ad5
				;;
7848ad5
			sun3)
7848ad5
				basic_machine=m68k-sun
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			sun3os3)
7848ad5
				basic_machine=m68k-sun
7848ad5
				basic_os=sunos3
7848ad5
				;;
7848ad5
			sun3os4)
7848ad5
				basic_machine=m68k-sun
7848ad5
				basic_os=sunos4
7848ad5
				;;
7848ad5
			sun4)
7848ad5
				basic_machine=sparc-sun
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			sun4os3)
7848ad5
				basic_machine=sparc-sun
7848ad5
				basic_os=sunos3
7848ad5
				;;
7848ad5
			sun4os4)
7848ad5
				basic_machine=sparc-sun
7848ad5
				basic_os=sunos4
7848ad5
				;;
7848ad5
			sun4sol2)
7848ad5
				basic_machine=sparc-sun
7848ad5
				basic_os=solaris2
7848ad5
				;;
7848ad5
			sun386 | sun386i | roadrunner)
7848ad5
				basic_machine=i386-sun
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
			sv1)
7848ad5
				basic_machine=sv1-cray
7848ad5
				basic_os=unicos
7848ad5
				;;
7848ad5
			symmetry)
7848ad5
				basic_machine=i386-sequent
7848ad5
				basic_os=dynix
7848ad5
				;;
7848ad5
			t3e)
7848ad5
				basic_machine=alphaev5-cray
7848ad5
				basic_os=unicos
7848ad5
				;;
7848ad5
			t90)
7848ad5
				basic_machine=t90-cray
7848ad5
				basic_os=unicos
7848ad5
				;;
7848ad5
			toad1)
7848ad5
				basic_machine=pdp10-xkl
7848ad5
				basic_os=tops20
7848ad5
				;;
7848ad5
			tpf)
7848ad5
				basic_machine=s390x-ibm
7848ad5
				basic_os=tpf
7848ad5
				;;
7848ad5
			udi29k)
7848ad5
				basic_machine=a29k-amd
7848ad5
				basic_os=udi
7848ad5
				;;
7848ad5
			ultra3)
7848ad5
				basic_machine=a29k-nyu
7848ad5
				basic_os=sym1
7848ad5
				;;
7848ad5
			v810 | necv810)
7848ad5
				basic_machine=v810-nec
7848ad5
				basic_os=none
7848ad5
				;;
7848ad5
			vaxv)
7848ad5
				basic_machine=vax-dec
7848ad5
				basic_os=sysv
7848ad5
				;;
7848ad5
			vms)
7848ad5
				basic_machine=vax-dec
7848ad5
				basic_os=vms
7848ad5
				;;
7848ad5
			vsta)
7848ad5
				basic_machine=i386-pc
7848ad5
				basic_os=vsta
7848ad5
				;;
7848ad5
			vxworks960)
7848ad5
				basic_machine=i960-wrs
7848ad5
				basic_os=vxworks
7848ad5
				;;
7848ad5
			vxworks68)
7848ad5
				basic_machine=m68k-wrs
7848ad5
				basic_os=vxworks
7848ad5
				;;
7848ad5
			vxworks29k)
7848ad5
				basic_machine=a29k-wrs
7848ad5
				basic_os=vxworks
7848ad5
				;;
7848ad5
			xbox)
7848ad5
				basic_machine=i686-pc
7848ad5
				basic_os=mingw32
7848ad5
				;;
7848ad5
			ymp)
7848ad5
				basic_machine=ymp-cray
7848ad5
				basic_os=unicos
7848ad5
				;;
7848ad5
			*)
7848ad5
				basic_machine=$1
7848ad5
				basic_os=
7848ad5
				;;
7848ad5
		esac
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# Decode 1-component or ad-hoc basic machines
7848ad5
case $basic_machine in
7848ad5
	# Here we handle the default manufacturer of certain CPU types.  It is in
7848ad5
	# some cases the only manufacturer, in others, it is the most popular.
7848ad5
	w89k)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=winbond
7848ad5
		;;
7848ad5
	op50n)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=oki
7848ad5
		;;
7848ad5
	op60c)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=oki
7848ad5
		;;
7848ad5
	ibm*)
7848ad5
		cpu=i370
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	orion105)
7848ad5
		cpu=clipper
7848ad5
		vendor=highlevel
7848ad5
		;;
7848ad5
	mac | mpw | mac-mpw)
7848ad5
		cpu=m68k
7848ad5
		vendor=apple
7848ad5
		;;
7848ad5
	pmac | pmac-mpw)
7848ad5
		cpu=powerpc
7848ad5
		vendor=apple
7848ad5
		;;
7848ad5
7848ad5
	# Recognize the various machine names and aliases which stand
7848ad5
	# for a CPU type and a company and sometimes even an OS.
7848ad5
	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
7848ad5
		cpu=m68000
7848ad5
		vendor=att
7848ad5
		;;
7848ad5
	3b*)
7848ad5
		cpu=we32k
7848ad5
		vendor=att
7848ad5
		;;
7848ad5
	bluegene*)
7848ad5
		cpu=powerpc
7848ad5
		vendor=ibm
7848ad5
		basic_os=cnk
7848ad5
		;;
7848ad5
	decsystem10* | dec10*)
7848ad5
		cpu=pdp10
7848ad5
		vendor=dec
7848ad5
		basic_os=tops10
7848ad5
		;;
7848ad5
	decsystem20* | dec20*)
7848ad5
		cpu=pdp10
7848ad5
		vendor=dec
7848ad5
		basic_os=tops20
7848ad5
		;;
7848ad5
	delta | 3300 | motorola-3300 | motorola-delta \
7848ad5
	      | 3300-motorola | delta-motorola)
7848ad5
		cpu=m68k
7848ad5
		vendor=motorola
7848ad5
		;;
7848ad5
	dpx2*)
7848ad5
		cpu=m68k
7848ad5
		vendor=bull
7848ad5
		basic_os=sysv3
7848ad5
		;;
7848ad5
	encore | umax | mmax)
7848ad5
		cpu=ns32k
7848ad5
		vendor=encore
7848ad5
		;;
7848ad5
	elxsi)
7848ad5
		cpu=elxsi
7848ad5
		vendor=elxsi
7848ad5
		basic_os=${basic_os:-bsd}
7848ad5
		;;
7848ad5
	fx2800)
7848ad5
		cpu=i860
7848ad5
		vendor=alliant
7848ad5
		;;
7848ad5
	genix)
7848ad5
		cpu=ns32k
7848ad5
		vendor=ns
7848ad5
		;;
7848ad5
	h3050r* | hiux*)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hitachi
7848ad5
		basic_os=hiuxwe2
7848ad5
		;;
7848ad5
	hp3k9[0-9][0-9] | hp9[0-9][0-9])
7848ad5
		cpu=hppa1.0
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k2[0-9][0-9] | hp9k31[0-9])
7848ad5
		cpu=m68000
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k3[2-9][0-9])
7848ad5
		cpu=m68k
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k6[0-9][0-9] | hp6[0-9][0-9])
7848ad5
		cpu=hppa1.0
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k7[0-79][0-9] | hp7[0-79][0-9])
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k78[0-9] | hp78[0-9])
7848ad5
		# FIXME: really hppa2.0-hp
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
7848ad5
		# FIXME: really hppa2.0-hp
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k8[0-9][13679] | hp8[0-9][13679])
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	hp9k8[0-9][0-9] | hp8[0-9][0-9])
7848ad5
		cpu=hppa1.0
7848ad5
		vendor=hp
7848ad5
		;;
7848ad5
	i*86v32)
7848ad5
		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7848ad5
		vendor=pc
7848ad5
		basic_os=sysv32
7848ad5
		;;
7848ad5
	i*86v4*)
7848ad5
		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7848ad5
		vendor=pc
7848ad5
		basic_os=sysv4
7848ad5
		;;
7848ad5
	i*86v)
7848ad5
		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7848ad5
		vendor=pc
7848ad5
		basic_os=sysv
7848ad5
		;;
7848ad5
	i*86sol2)
7848ad5
		cpu=`echo "$1" | sed -e 's/86.*/86/'`
7848ad5
		vendor=pc
7848ad5
		basic_os=solaris2
7848ad5
		;;
7848ad5
	j90 | j90-cray)
7848ad5
		cpu=j90
7848ad5
		vendor=cray
7848ad5
		basic_os=${basic_os:-unicos}
7848ad5
		;;
7848ad5
	iris | iris4d)
7848ad5
		cpu=mips
7848ad5
		vendor=sgi
7848ad5
		case $basic_os in
7848ad5
		    irix*)
7848ad5
			;;
7848ad5
		    *)
7848ad5
			basic_os=irix4
7848ad5
			;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	miniframe)
7848ad5
		cpu=m68000
7848ad5
		vendor=convergent
7848ad5
		;;
7848ad5
	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
7848ad5
		cpu=m68k
7848ad5
		vendor=atari
7848ad5
		basic_os=mint
7848ad5
		;;
7848ad5
	news-3600 | risc-news)
7848ad5
		cpu=mips
7848ad5
		vendor=sony
7848ad5
		basic_os=newsos
7848ad5
		;;
7848ad5
	next | m*-next)
7848ad5
		cpu=m68k
7848ad5
		vendor=next
7848ad5
		case $basic_os in
7848ad5
		    openstep*)
7848ad5
		        ;;
7848ad5
		    nextstep*)
7848ad5
			;;
7848ad5
		    ns2*)
7848ad5
		      basic_os=nextstep2
7848ad5
			;;
7848ad5
		    *)
7848ad5
		      basic_os=nextstep3
7848ad5
			;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	np1)
7848ad5
		cpu=np1
7848ad5
		vendor=gould
7848ad5
		;;
7848ad5
	op50n-* | op60c-*)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=oki
7848ad5
		basic_os=proelf
7848ad5
		;;
7848ad5
	pa-hitachi)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=hitachi
7848ad5
		basic_os=hiuxwe2
7848ad5
		;;
7848ad5
	pbd)
7848ad5
		cpu=sparc
7848ad5
		vendor=tti
7848ad5
		;;
7848ad5
	pbb)
7848ad5
		cpu=m68k
7848ad5
		vendor=tti
7848ad5
		;;
7848ad5
	pc532)
7848ad5
		cpu=ns32k
7848ad5
		vendor=pc532
7848ad5
		;;
7848ad5
	pn)
7848ad5
		cpu=pn
7848ad5
		vendor=gould
7848ad5
		;;
7848ad5
	power)
7848ad5
		cpu=power
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	ps2)
7848ad5
		cpu=i386
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	rm[46]00)
7848ad5
		cpu=mips
7848ad5
		vendor=siemens
7848ad5
		;;
7848ad5
	rtpc | rtpc-*)
7848ad5
		cpu=romp
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	sde)
7848ad5
		cpu=mipsisa32
7848ad5
		vendor=sde
7848ad5
		basic_os=${basic_os:-elf}
7848ad5
		;;
7848ad5
	simso-wrs)
7848ad5
		cpu=sparclite
7848ad5
		vendor=wrs
7848ad5
		basic_os=vxworks
7848ad5
		;;
7848ad5
	tower | tower-32)
7848ad5
		cpu=m68k
7848ad5
		vendor=ncr
7848ad5
		;;
7848ad5
	vpp*|vx|vx-*)
7848ad5
		cpu=f301
7848ad5
		vendor=fujitsu
7848ad5
		;;
7848ad5
	w65)
7848ad5
		cpu=w65
7848ad5
		vendor=wdc
7848ad5
		;;
7848ad5
	w89k-*)
7848ad5
		cpu=hppa1.1
7848ad5
		vendor=winbond
7848ad5
		basic_os=proelf
7848ad5
		;;
7848ad5
	none)
7848ad5
		cpu=none
7848ad5
		vendor=none
7848ad5
		;;
7848ad5
	leon|leon[3-9])
7848ad5
		cpu=sparc
7848ad5
		vendor=$basic_machine
7848ad5
		;;
7848ad5
	leon-*|leon[3-9]-*)
7848ad5
		cpu=sparc
7848ad5
		vendor=`echo "$basic_machine" | sed 's/-.*//'`
7848ad5
		;;
7848ad5
7848ad5
	*-*)
7848ad5
		# shellcheck disable=SC2162
7848ad5
		IFS="-" read cpu vendor <
7848ad5
$basic_machine
7848ad5
EOF
7848ad5
		;;
7848ad5
	# We use `pc' rather than `unknown'
7848ad5
	# because (1) that's what they normally are, and
7848ad5
	# (2) the word "unknown" tends to confuse beginning users.
7848ad5
	i*86 | x86_64)
7848ad5
		cpu=$basic_machine
7848ad5
		vendor=pc
7848ad5
		;;
7848ad5
	# These rules are duplicated from below for sake of the special case above;
7848ad5
	# i.e. things that normalized to x86 arches should also default to "pc"
7848ad5
	pc98)
7848ad5
		cpu=i386
7848ad5
		vendor=pc
7848ad5
		;;
7848ad5
	x64 | amd64)
7848ad5
		cpu=x86_64
7848ad5
		vendor=pc
7848ad5
		;;
7848ad5
	# Recognize the basic CPU types without company name.
7848ad5
	*)
7848ad5
		cpu=$basic_machine
7848ad5
		vendor=unknown
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
unset -v basic_machine
7848ad5
7848ad5
# Decode basic machines in the full and proper CPU-Company form.
7848ad5
case $cpu-$vendor in
7848ad5
	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
7848ad5
	# some cases the only manufacturer, in others, it is the most popular.
7848ad5
	craynv-unknown)
7848ad5
		vendor=cray
7848ad5
		basic_os=${basic_os:-unicosmp}
7848ad5
		;;
7848ad5
	c90-unknown | c90-cray)
7848ad5
		vendor=cray
7848ad5
		basic_os=${Basic_os:-unicos}
7848ad5
		;;
7848ad5
	fx80-unknown)
7848ad5
		vendor=alliant
7848ad5
		;;
7848ad5
	romp-unknown)
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	mmix-unknown)
7848ad5
		vendor=knuth
7848ad5
		;;
7848ad5
	microblaze-unknown | microblazeel-unknown)
7848ad5
		vendor=xilinx
7848ad5
		;;
7848ad5
	rs6000-unknown)
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	vax-unknown)
7848ad5
		vendor=dec
7848ad5
		;;
7848ad5
	pdp11-unknown)
7848ad5
		vendor=dec
7848ad5
		;;
7848ad5
	we32k-unknown)
7848ad5
		vendor=att
7848ad5
		;;
7848ad5
	cydra-unknown)
7848ad5
		vendor=cydrome
7848ad5
		;;
7848ad5
	i370-ibm*)
7848ad5
		vendor=ibm
7848ad5
		;;
7848ad5
	orion-unknown)
7848ad5
		vendor=highlevel
7848ad5
		;;
7848ad5
	xps-unknown | xps100-unknown)
7848ad5
		cpu=xps100
7848ad5
		vendor=honeywell
7848ad5
		;;
7848ad5
7848ad5
	# Here we normalize CPU types with a missing or matching vendor
7848ad5
	dpx20-unknown | dpx20-bull)
7848ad5
		cpu=rs6000
7848ad5
		vendor=bull
7848ad5
		basic_os=${basic_os:-bosx}
7848ad5
		;;
7848ad5
7848ad5
	# Here we normalize CPU types irrespective of the vendor
7848ad5
	amd64-*)
7848ad5
		cpu=x86_64
7848ad5
		;;
7848ad5
	blackfin-*)
7848ad5
		cpu=bfin
7848ad5
		basic_os=linux
7848ad5
		;;
7848ad5
	c54x-*)
7848ad5
		cpu=tic54x
7848ad5
		;;
7848ad5
	c55x-*)
7848ad5
		cpu=tic55x
7848ad5
		;;
7848ad5
	c6x-*)
7848ad5
		cpu=tic6x
7848ad5
		;;
7848ad5
	e500v[12]-*)
7848ad5
		cpu=powerpc
7848ad5
		basic_os=${basic_os}"spe"
7848ad5
		;;
7848ad5
	mips3*-*)
7848ad5
		cpu=mips64
7848ad5
		;;
7848ad5
	ms1-*)
7848ad5
		cpu=mt
7848ad5
		;;
7848ad5
	m68knommu-*)
7848ad5
		cpu=m68k
7848ad5
		basic_os=linux
7848ad5
		;;
7848ad5
	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
7848ad5
		cpu=s12z
7848ad5
		;;
7848ad5
	openrisc-*)
7848ad5
		cpu=or32
7848ad5
		;;
7848ad5
	parisc-*)
7848ad5
		cpu=hppa
7848ad5
		basic_os=linux
7848ad5
		;;
7848ad5
	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
7848ad5
		cpu=i586
7848ad5
		;;
7848ad5
	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
7848ad5
		cpu=i686
7848ad5
		;;
7848ad5
	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
7848ad5
		cpu=i686
7848ad5
		;;
7848ad5
	pentium4-*)
7848ad5
		cpu=i786
7848ad5
		;;
7848ad5
	pc98-*)
7848ad5
		cpu=i386
7848ad5
		;;
7848ad5
	ppc-* | ppcbe-*)
7848ad5
		cpu=powerpc
7848ad5
		;;
7848ad5
	ppcle-* | powerpclittle-*)
7848ad5
		cpu=powerpcle
7848ad5
		;;
7848ad5
	ppc64-*)
7848ad5
		cpu=powerpc64
7848ad5
		;;
7848ad5
	ppc64le-* | powerpc64little-*)
7848ad5
		cpu=powerpc64le
7848ad5
		;;
7848ad5
	sb1-*)
7848ad5
		cpu=mipsisa64sb1
7848ad5
		;;
7848ad5
	sb1el-*)
7848ad5
		cpu=mipsisa64sb1el
7848ad5
		;;
7848ad5
	sh5e[lb]-*)
7848ad5
		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
7848ad5
		;;
7848ad5
	spur-*)
7848ad5
		cpu=spur
7848ad5
		;;
7848ad5
	strongarm-* | thumb-*)
7848ad5
		cpu=arm
7848ad5
		;;
7848ad5
	tx39-*)
7848ad5
		cpu=mipstx39
7848ad5
		;;
7848ad5
	tx39el-*)
7848ad5
		cpu=mipstx39el
7848ad5
		;;
7848ad5
	x64-*)
7848ad5
		cpu=x86_64
7848ad5
		;;
7848ad5
	xscale-* | xscalee[bl]-*)
7848ad5
		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
7848ad5
		;;
7848ad5
	arm64-*)
7848ad5
		cpu=aarch64
7848ad5
		;;
7848ad5
7848ad5
	# Recognize the canonical CPU Types that limit and/or modify the
7848ad5
	# company names they are paired with.
7848ad5
	cr16-*)
7848ad5
		basic_os=${basic_os:-elf}
7848ad5
		;;
7848ad5
	crisv32-* | etraxfs*-*)
7848ad5
		cpu=crisv32
7848ad5
		vendor=axis
7848ad5
		;;
7848ad5
	cris-* | etrax*-*)
7848ad5
		cpu=cris
7848ad5
		vendor=axis
7848ad5
		;;
7848ad5
	crx-*)
7848ad5
		basic_os=${basic_os:-elf}
7848ad5
		;;
7848ad5
	neo-tandem)
7848ad5
		cpu=neo
7848ad5
		vendor=tandem
7848ad5
		;;
7848ad5
	nse-tandem)
7848ad5
		cpu=nse
7848ad5
		vendor=tandem
7848ad5
		;;
7848ad5
	nsr-tandem)
7848ad5
		cpu=nsr
7848ad5
		vendor=tandem
7848ad5
		;;
7848ad5
	nsv-tandem)
7848ad5
		cpu=nsv
7848ad5
		vendor=tandem
7848ad5
		;;
7848ad5
	nsx-tandem)
7848ad5
		cpu=nsx
7848ad5
		vendor=tandem
7848ad5
		;;
7848ad5
	mipsallegrexel-sony)
7848ad5
		cpu=mipsallegrexel
7848ad5
		vendor=sony
7848ad5
		;;
7848ad5
	tile*-*)
7848ad5
		basic_os=${basic_os:-linux-gnu}
7848ad5
		;;
7848ad5
7848ad5
	*)
7848ad5
		# Recognize the canonical CPU types that are allowed with any
7848ad5
		# company name.
7848ad5
		case $cpu in
7848ad5
			1750a | 580 \
7848ad5
			| a29k \
7848ad5
			| aarch64 | aarch64_be \
7848ad5
			| abacus \
7848ad5
			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
7848ad5
			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
7848ad5
			| alphapca5[67] | alpha64pca5[67] \
7848ad5
			| am33_2.0 \
7848ad5
			| amdgcn \
7848ad5
			| arc | arceb \
7848ad5
			| arm | arm[lb]e | arme[lb] | armv* \
7848ad5
			| avr | avr32 \
7848ad5
			| asmjs \
7848ad5
			| ba \
7848ad5
			| be32 | be64 \
7848ad5
			| bfin | bpf | bs2000 \
7848ad5
			| c[123]* | c30 | [cjt]90 | c4x \
7848ad5
			| c8051 | clipper | craynv | csky | cydra \
7848ad5
			| d10v | d30v | dlx | dsp16xx \
7848ad5
			| e2k | elxsi | epiphany \
7848ad5
			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
7848ad5
			| h8300 | h8500 \
7848ad5
			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
7848ad5
			| hexagon \
7848ad5
			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
7848ad5
			| ip2k | iq2000 \
7848ad5
			| k1om \
7848ad5
			| le32 | le64 \
7848ad5
			| lm32 \
7848ad5
			| m32c | m32r | m32rle \
7848ad5
			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
7848ad5
			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
7848ad5
			| m88110 | m88k | maxq | mb | mcore | mep | metag \
7848ad5
			| microblaze | microblazeel \
7848ad5
			| mips | mipsbe | mipseb | mipsel | mipsle \
7848ad5
			| mips16 \
7848ad5
			| mips64 | mips64eb | mips64el \
7848ad5
			| mips64octeon | mips64octeonel \
7848ad5
			| mips64orion | mips64orionel \
7848ad5
			| mips64r5900 | mips64r5900el \
7848ad5
			| mips64vr | mips64vrel \
7848ad5
			| mips64vr4100 | mips64vr4100el \
7848ad5
			| mips64vr4300 | mips64vr4300el \
7848ad5
			| mips64vr5000 | mips64vr5000el \
7848ad5
			| mips64vr5900 | mips64vr5900el \
7848ad5
			| mipsisa32 | mipsisa32el \
7848ad5
			| mipsisa32r2 | mipsisa32r2el \
7848ad5
			| mipsisa32r6 | mipsisa32r6el \
7848ad5
			| mipsisa64 | mipsisa64el \
7848ad5
			| mipsisa64r2 | mipsisa64r2el \
7848ad5
			| mipsisa64r6 | mipsisa64r6el \
7848ad5
			| mipsisa64sb1 | mipsisa64sb1el \
7848ad5
			| mipsisa64sr71k | mipsisa64sr71kel \
7848ad5
			| mipsr5900 | mipsr5900el \
7848ad5
			| mipstx39 | mipstx39el \
7848ad5
			| mmix \
7848ad5
			| mn10200 | mn10300 \
7848ad5
			| moxie \
7848ad5
			| mt \
7848ad5
			| msp430 \
7848ad5
			| nds32 | nds32le | nds32be \
7848ad5
			| nfp \
7848ad5
			| nios | nios2 | nios2eb | nios2el \
7848ad5
			| none | np1 | ns16k | ns32k | nvptx \
7848ad5
			| open8 \
7848ad5
			| or1k* \
7848ad5
			| or32 \
7848ad5
			| orion \
7848ad5
			| picochip \
7848ad5
			| pdp10 | pdp11 | pj | pjl | pn | power \
7848ad5
			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
7848ad5
			| pru \
7848ad5
			| pyramid \
7848ad5
			| riscv | riscv32 | riscv64 \
7848ad5
			| rl78 | romp | rs6000 | rx \
7848ad5
			| s390 | s390x \
7848ad5
			| score \
7848ad5
			| sh | shl \
7848ad5
			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
7848ad5
			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
7848ad5
			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
7848ad5
			| sparclite \
7848ad5
			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
7848ad5
			| spu \
7848ad5
			| tahoe \
7848ad5
			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
7848ad5
			| tron \
7848ad5
			| ubicom32 \
7848ad5
			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
7848ad5
			| vax \
7848ad5
			| visium \
7848ad5
			| w65 \
7848ad5
			| wasm32 | wasm64 \
7848ad5
			| we32k \
7848ad5
			| x86 | x86_64 | xc16x | xgate | xps100 \
7848ad5
			| xstormy16 | xtensa* \
7848ad5
			| ymp \
7848ad5
			| z8k | z80)
7848ad5
				;;
7848ad5
7848ad5
			*)
7848ad5
				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
7848ad5
				exit 1
7848ad5
				;;
7848ad5
		esac
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# Here we canonicalize certain aliases for manufacturers.
7848ad5
case $vendor in
7848ad5
	digital*)
7848ad5
		vendor=dec
7848ad5
		;;
7848ad5
	commodore*)
7848ad5
		vendor=cbm
7848ad5
		;;
7848ad5
	*)
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# Decode manufacturer-specific aliases for certain operating systems.
7848ad5
7848ad5
if [ x$basic_os != x ]
7848ad5
then
7848ad5
7848ad5
# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
7848ad5
# set os.
7848ad5
case $basic_os in
7848ad5
	gnu/linux*)
7848ad5
		kernel=linux
7848ad5
		os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'`
7848ad5
		;;
7848ad5
	nto-qnx*)
7848ad5
		kernel=nto
7848ad5
		os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'`
7848ad5
		;;
7848ad5
	*-*)
7848ad5
		# shellcheck disable=SC2162
7848ad5
		IFS="-" read kernel os <
7848ad5
$basic_os
7848ad5
EOF
7848ad5
		;;
7848ad5
	# Default OS when just kernel was specified
7848ad5
	nto*)
7848ad5
		kernel=nto
7848ad5
		os=`echo $basic_os | sed -e 's|nto|qnx|'`
7848ad5
		;;
7848ad5
	linux*)
7848ad5
		kernel=linux
7848ad5
		os=`echo $basic_os | sed -e 's|linux|gnu|'`
7848ad5
		;;
7848ad5
	*)
7848ad5
		kernel=
7848ad5
		os=$basic_os
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# Now, normalize the OS (knowing we just have one component, it's not a kernel,
7848ad5
# etc.)
7848ad5
case $os in
7848ad5
	# First match some system type aliases that might get confused
7848ad5
	# with valid system types.
7848ad5
	# solaris* is a basic system type, with this one exception.
7848ad5
	auroraux)
7848ad5
		os=auroraux
7848ad5
		;;
7848ad5
	bluegene*)
7848ad5
		os=cnk
7848ad5
		;;
7848ad5
	solaris1 | solaris1.*)
7848ad5
		os=`echo $os | sed -e 's|solaris1|sunos4|'`
7848ad5
		;;
7848ad5
	solaris)
7848ad5
		os=solaris2
7848ad5
		;;
7848ad5
	unixware*)
7848ad5
		os=sysv4.2uw
7848ad5
		;;
7848ad5
	# es1800 is here to avoid being matched by es* (a different OS)
7848ad5
	es1800*)
7848ad5
		os=ose
7848ad5
		;;
7848ad5
	# Some version numbers need modification
7848ad5
	chorusos*)
7848ad5
		os=chorusos
7848ad5
		;;
7848ad5
	isc)
7848ad5
		os=isc2.2
7848ad5
		;;
7848ad5
	sco6)
7848ad5
		os=sco5v6
7848ad5
		;;
7848ad5
	sco5)
7848ad5
		os=sco3.2v5
7848ad5
		;;
7848ad5
	sco4)
7848ad5
		os=sco3.2v4
7848ad5
		;;
7848ad5
	sco3.2.[4-9]*)
7848ad5
		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
7848ad5
		;;
7848ad5
	sco*v* | scout)
7848ad5
		# Don't match below
7848ad5
		;;
7848ad5
	sco*)
7848ad5
		os=sco3.2v2
7848ad5
		;;
7848ad5
	psos*)
7848ad5
		os=psos
7848ad5
		;;
7848ad5
	qnx*)
7848ad5
		case $cpu in
7848ad5
		    x86 | i*86)
7848ad5
			;;
7848ad5
		    *)
7848ad5
			os=nto-$os
7848ad5
			;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	hiux*)
7848ad5
		os=hiuxwe2
7848ad5
		;;
7848ad5
	lynx*178)
7848ad5
		os=lynxos178
7848ad5
		;;
7848ad5
	lynx*5)
7848ad5
		os=lynxos5
7848ad5
		;;
7848ad5
	lynxos*)
7848ad5
		# don't get caught up in next wildcard
7848ad5
		;;
7848ad5
	lynx*)
7848ad5
		os=lynxos
7848ad5
		;;
7848ad5
	mac[0-9]*)
7848ad5
		os=`echo "$os" | sed -e 's|mac|macos|'`
7848ad5
		;;
7848ad5
	opened*)
7848ad5
		os=openedition
7848ad5
		;;
7848ad5
	os400*)
7848ad5
		os=os400
7848ad5
		;;
7848ad5
	sunos5*)
7848ad5
		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
7848ad5
		;;
7848ad5
	sunos6*)
7848ad5
		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
7848ad5
		;;
7848ad5
	wince*)
7848ad5
		os=wince
7848ad5
		;;
7848ad5
	utek*)
7848ad5
		os=bsd
7848ad5
		;;
7848ad5
	dynix*)
7848ad5
		os=bsd
7848ad5
		;;
7848ad5
	acis*)
7848ad5
		os=aos
7848ad5
		;;
7848ad5
	atheos*)
7848ad5
		os=atheos
7848ad5
		;;
7848ad5
	syllable*)
7848ad5
		os=syllable
7848ad5
		;;
7848ad5
	386bsd)
7848ad5
		os=bsd
7848ad5
		;;
7848ad5
	ctix* | uts*)
7848ad5
		os=sysv
7848ad5
		;;
7848ad5
	nova*)
7848ad5
		os=rtmk-nova
7848ad5
		;;
7848ad5
	ns2)
7848ad5
		os=nextstep2
7848ad5
		;;
7848ad5
	# Preserve the version number of sinix5.
7848ad5
	sinix5.*)
7848ad5
		os=`echo $os | sed -e 's|sinix|sysv|'`
7848ad5
		;;
7848ad5
	sinix*)
7848ad5
		os=sysv4
7848ad5
		;;
7848ad5
	tpf*)
7848ad5
		os=tpf
7848ad5
		;;
7848ad5
	triton*)
7848ad5
		os=sysv3
7848ad5
		;;
7848ad5
	oss*)
7848ad5
		os=sysv3
7848ad5
		;;
7848ad5
	svr4*)
7848ad5
		os=sysv4
7848ad5
		;;
7848ad5
	svr3)
7848ad5
		os=sysv3
7848ad5
		;;
7848ad5
	sysvr4)
7848ad5
		os=sysv4
7848ad5
		;;
7848ad5
	ose*)
7848ad5
		os=ose
7848ad5
		;;
7848ad5
	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
7848ad5
		os=mint
7848ad5
		;;
7848ad5
	dicos*)
7848ad5
		os=dicos
7848ad5
		;;
7848ad5
	pikeos*)
7848ad5
		# Until real need of OS specific support for
7848ad5
		# particular features comes up, bare metal
7848ad5
		# configurations are quite functional.
7848ad5
		case $cpu in
7848ad5
		    arm*)
7848ad5
			os=eabi
7848ad5
			;;
7848ad5
		    *)
7848ad5
			os=elf
7848ad5
			;;
7848ad5
		esac
7848ad5
		;;
7848ad5
	*)
7848ad5
		# No normalization, but not necessarily accepted, that comes below.
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
else
7848ad5
7848ad5
# Here we handle the default operating systems that come with various machines.
7848ad5
# The value should be what the vendor currently ships out the door with their
7848ad5
# machine or put another way, the most popular os provided with the machine.
7848ad5
7848ad5
# Note that if you're going to try to match "-MANUFACTURER" here (say,
7848ad5
# "-sun"), then you have to tell the case statement up towards the top
7848ad5
# that MANUFACTURER isn't an operating system.  Otherwise, code above
7848ad5
# will signal an error saying that MANUFACTURER isn't an operating
7848ad5
# system, and we'll never get to this point.
7848ad5
7848ad5
kernel=
7848ad5
case $cpu-$vendor in
7848ad5
	score-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	spu-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	*-acorn)
7848ad5
		os=riscix1.2
7848ad5
		;;
7848ad5
	arm*-rebel)
7848ad5
		kernel=linux
7848ad5
		os=gnu
7848ad5
		;;
7848ad5
	arm*-semi)
7848ad5
		os=aout
7848ad5
		;;
7848ad5
	c4x-* | tic4x-*)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	c8051-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	clipper-intergraph)
7848ad5
		os=clix
7848ad5
		;;
7848ad5
	hexagon-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	tic54x-*)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	tic55x-*)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	tic6x-*)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	# This must come before the *-dec entry.
7848ad5
	pdp10-*)
7848ad5
		os=tops20
7848ad5
		;;
7848ad5
	pdp11-*)
7848ad5
		os=none
7848ad5
		;;
7848ad5
	*-dec | vax-*)
7848ad5
		os=ultrix4.2
7848ad5
		;;
7848ad5
	m68*-apollo)
7848ad5
		os=domain
7848ad5
		;;
7848ad5
	i386-sun)
7848ad5
		os=sunos4.0.2
7848ad5
		;;
7848ad5
	m68000-sun)
7848ad5
		os=sunos3
7848ad5
		;;
7848ad5
	m68*-cisco)
7848ad5
		os=aout
7848ad5
		;;
7848ad5
	mep-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	mips*-cisco)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	mips*-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	or32-*)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	*-tti)	# must be before sparc entry or we get the wrong os.
7848ad5
		os=sysv3
7848ad5
		;;
7848ad5
	sparc-* | *-sun)
7848ad5
		os=sunos4.1.1
7848ad5
		;;
7848ad5
	pru-*)
7848ad5
		os=elf
7848ad5
		;;
7848ad5
	*-be)
7848ad5
		os=beos
7848ad5
		;;
7848ad5
	*-ibm)
7848ad5
		os=aix
7848ad5
		;;
7848ad5
	*-knuth)
7848ad5
		os=mmixware
7848ad5
		;;
7848ad5
	*-wec)
7848ad5
		os=proelf
7848ad5
		;;
7848ad5
	*-winbond)
7848ad5
		os=proelf
7848ad5
		;;
7848ad5
	*-oki)
7848ad5
		os=proelf
7848ad5
		;;
7848ad5
	*-hp)
7848ad5
		os=hpux
7848ad5
		;;
7848ad5
	*-hitachi)
7848ad5
		os=hiux
7848ad5
		;;
7848ad5
	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
7848ad5
		os=sysv
7848ad5
		;;
7848ad5
	*-cbm)
7848ad5
		os=amigaos
7848ad5
		;;
7848ad5
	*-dg)
7848ad5
		os=dgux
7848ad5
		;;
7848ad5
	*-dolphin)
7848ad5
		os=sysv3
7848ad5
		;;
7848ad5
	m68k-ccur)
7848ad5
		os=rtu
7848ad5
		;;
7848ad5
	m88k-omron*)
7848ad5
		os=luna
7848ad5
		;;
7848ad5
	*-next)
7848ad5
		os=nextstep
7848ad5
		;;
7848ad5
	*-sequent)
7848ad5
		os=ptx
7848ad5
		;;
7848ad5
	*-crds)
7848ad5
		os=unos
7848ad5
		;;
7848ad5
	*-ns)
7848ad5
		os=genix
7848ad5
		;;
7848ad5
	i370-*)
7848ad5
		os=mvs
7848ad5
		;;
7848ad5
	*-gould)
7848ad5
		os=sysv
7848ad5
		;;
7848ad5
	*-highlevel)
7848ad5
		os=bsd
7848ad5
		;;
7848ad5
	*-encore)
7848ad5
		os=bsd
7848ad5
		;;
7848ad5
	*-sgi)
7848ad5
		os=irix
7848ad5
		;;
7848ad5
	*-siemens)
7848ad5
		os=sysv4
7848ad5
		;;
7848ad5
	*-masscomp)
7848ad5
		os=rtu
7848ad5
		;;
7848ad5
	f30[01]-fujitsu | f700-fujitsu)
7848ad5
		os=uxpv
7848ad5
		;;
7848ad5
	*-rom68k)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	*-*bug)
7848ad5
		os=coff
7848ad5
		;;
7848ad5
	*-apple)
7848ad5
		os=macos
7848ad5
		;;
7848ad5
	*-atari*)
7848ad5
		os=mint
7848ad5
		;;
7848ad5
	*-wrs)
7848ad5
		os=vxworks
7848ad5
		;;
7848ad5
	*)
7848ad5
		os=none
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
fi
7848ad5
7848ad5
# Now, validate our (potentially fixed-up) OS.
7848ad5
case $os in
7848ad5
	# Sometimes we do "kernel-abi", so those need to count as OSes.
7848ad5
	musl* | newlib* | uclibc*)
7848ad5
		;;
7848ad5
	# Likewise for "kernel-libc"
7848ad5
	eabi | eabihf | gnueabi | gnueabihf)
7848ad5
		;;
7848ad5
	# Now accept the basic system types.
7848ad5
	# The portable systems comes first.
7848ad5
	# Each alternative MUST end in a * to match a version number.
7848ad5
	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
7848ad5
	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
7848ad5
	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
7848ad5
	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
7848ad5
	     | hiux* | abug | nacl* | netware* | windows* \
7848ad5
	     | os9* | macos* | osx* | ios* \
7848ad5
	     | mpw* | magic* | mmixware* | mon960* | lnews* \
7848ad5
	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
7848ad5
	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
7848ad5
	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
7848ad5
	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
7848ad5
	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
7848ad5
	     | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
7848ad5
	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
7848ad5
	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
7848ad5
	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
7848ad5
	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
7848ad5
	     | chorusrdb* | cegcc* | glidix* \
7848ad5
	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
7848ad5
	     | midipix* | mingw32* | mingw64* | mint* \
7848ad5
	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
7848ad5
	     | interix* | uwin* | mks* | rhapsody* | darwin* \
7848ad5
	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
7848ad5
	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
7848ad5
	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
7848ad5
	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
7848ad5
	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
7848ad5
	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
7848ad5
	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
7848ad5
	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
7848ad5
	     | nsk* | powerunix* | genode* | zvmoe* )
7848ad5
		;;
7848ad5
	# This one is extra strict with allowed versions
7848ad5
	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
7848ad5
		# Don't forget version if it is 3.2v4 or newer.
7848ad5
		;;
7848ad5
	none)
7848ad5
		;;
7848ad5
	*)
7848ad5
		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
7848ad5
		exit 1
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# As a final step for OS-related things, validate the OS-kernel combination
7848ad5
# (given a valid OS), if there is a kernel.
7848ad5
case $kernel-$os in
7848ad5
	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
7848ad5
		;;
7848ad5
	-dietlibc* | -newlib* | -musl* | -uclibc* )
7848ad5
		# These are just libc implementations, not actual OSes, and thus
7848ad5
		# require a kernel.
7848ad5
		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
7848ad5
		exit 1
7848ad5
		;;
7848ad5
	kfreebsd*-gnu* | kopensolaris*-gnu*)
7848ad5
		;;
7848ad5
	nto-qnx*)
7848ad5
		;;
7848ad5
	*-eabi* | *-gnueabi*)
7848ad5
		;;
7848ad5
	-*)
7848ad5
		# Blank kernel with real OS is always fine.
7848ad5
		;;
7848ad5
	*-*)
7848ad5
		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
7848ad5
		exit 1
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
# Here we handle the case where we know the os, and the CPU type, but not the
7848ad5
# manufacturer.  We pick the logical manufacturer.
7848ad5
case $vendor in
7848ad5
	unknown)
7848ad5
		case $cpu-$os in
7848ad5
			*-riscix*)
7848ad5
				vendor=acorn
7848ad5
				;;
7848ad5
			*-sunos*)
7848ad5
				vendor=sun
7848ad5
				;;
7848ad5
			*-cnk* | *-aix*)
7848ad5
				vendor=ibm
7848ad5
				;;
7848ad5
			*-beos*)
7848ad5
				vendor=be
7848ad5
				;;
7848ad5
			*-hpux*)
7848ad5
				vendor=hp
7848ad5
				;;
7848ad5
			*-mpeix*)
7848ad5
				vendor=hp
7848ad5
				;;
7848ad5
			*-hiux*)
7848ad5
				vendor=hitachi
7848ad5
				;;
7848ad5
			*-unos*)
7848ad5
				vendor=crds
7848ad5
				;;
7848ad5
			*-dgux*)
7848ad5
				vendor=dg
7848ad5
				;;
7848ad5
			*-luna*)
7848ad5
				vendor=omron
7848ad5
				;;
7848ad5
			*-genix*)
7848ad5
				vendor=ns
7848ad5
				;;
7848ad5
			*-clix*)
7848ad5
				vendor=intergraph
7848ad5
				;;
7848ad5
			*-mvs* | *-opened*)
7848ad5
				vendor=ibm
7848ad5
				;;
7848ad5
			*-os400*)
7848ad5
				vendor=ibm
7848ad5
				;;
7848ad5
			s390-* | s390x-*)
7848ad5
				vendor=ibm
7848ad5
				;;
7848ad5
			*-ptx*)
7848ad5
				vendor=sequent
7848ad5
				;;
7848ad5
			*-tpf*)
7848ad5
				vendor=ibm
7848ad5
				;;
7848ad5
			*-vxsim* | *-vxworks* | *-windiss*)
7848ad5
				vendor=wrs
7848ad5
				;;
7848ad5
			*-aux*)
7848ad5
				vendor=apple
7848ad5
				;;
7848ad5
			*-hms*)
7848ad5
				vendor=hitachi
7848ad5
				;;
7848ad5
			*-mpw* | *-macos*)
7848ad5
				vendor=apple
7848ad5
				;;
7848ad5
			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
7848ad5
				vendor=atari
7848ad5
				;;
7848ad5
			*-vos*)
7848ad5
				vendor=stratus
7848ad5
				;;
7848ad5
		esac
7848ad5
		;;
7848ad5
esac
7848ad5
7848ad5
echo "$cpu-$vendor-${kernel:+$kernel-}$os"
7848ad5
exit
7848ad5
7848ad5
# Local variables:
7848ad5
# eval: (add-hook 'before-save-hook 'time-stamp)
7848ad5
# time-stamp-start: "timestamp='"
7848ad5
# time-stamp-format: "%:y-%02m-%02d"
7848ad5
# time-stamp-end: "'"
7848ad5
# End: