xref: /freebsd/contrib/tcpdump/config.sub (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
1#! /bin/sh
2# Configuration validation subroutine script.
3#   Copyright 1992-2023 Free Software Foundation, Inc.
4
5# shellcheck disable=SC2006,SC2268 # see below for rationale
6
7timestamp='2023-01-21'
8
9# This file is free software; you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17# General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, see <https://www.gnu.org/licenses/>.
21#
22# As a special exception to the GNU General Public License, if you
23# distribute this file as part of a program that contains a
24# configuration script generated by Autoconf, you may include it under
25# the same distribution terms that you use for the rest of that
26# program.  This Exception is an additional permission under section 7
27# of the GNU General Public License, version 3 ("GPLv3").
28
29
30# Please send patches to <config-patches@gnu.org>.
31#
32# Configuration subroutine to validate and canonicalize a configuration type.
33# Supply the specified configuration type as an argument.
34# If it is invalid, we print an error message on stderr and exit with code 1.
35# Otherwise, we print the canonical config type on stdout and succeed.
36
37# You can get the latest version of this script from:
38# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39
40# This file is supposed to be the same for all GNU packages
41# and recognize all the CPU types, system types and aliases
42# that are meaningful with *any* GNU software.
43# Each package is responsible for reporting which valid configurations
44# it does not support.  The user should be able to distinguish
45# a failure to support a valid configuration from a meaningless
46# configuration.
47
48# The goal of this file is to map all the various variations of a given
49# machine specification into a single specification in the form:
50#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51# or in some cases, the newer four-part form:
52#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53# It is wrong to echo any other type of specification.
54
55# The "shellcheck disable" line above the timestamp inhibits complaints
56# about features and limitations of the classic Bourne shell that were
57# superseded or lifted in POSIX.  However, this script identifies a wide
58# variety of pre-POSIX systems that do not have POSIX shells at all, and
59# even some reasonably current systems (Solaris 10 as case-in-point) still
60# have a pre-POSIX /bin/sh.
61
62me=`echo "$0" | sed -e 's,.*/,,'`
63
64usage="\
65Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66
67Canonicalize a configuration name.
68
69Options:
70  -h, --help         print this help, then exit
71  -t, --time-stamp   print date of last modification, then exit
72  -v, --version      print version number, then exit
73
74Report bugs and patches to <config-patches@gnu.org>."
75
76version="\
77GNU config.sub ($timestamp)
78
79Copyright 1992-2023 Free Software Foundation, Inc.
80
81This is free software; see the source for copying conditions.  There is NO
82warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83
84help="
85Try \`$me --help' for more information."
86
87# Parse command line
88while test $# -gt 0 ; do
89  case $1 in
90    --time-stamp | --time* | -t )
91       echo "$timestamp" ; exit ;;
92    --version | -v )
93       echo "$version" ; exit ;;
94    --help | --h* | -h )
95       echo "$usage"; exit ;;
96    -- )     # Stop option processing
97       shift; break ;;
98    - )	# Use stdin as input.
99       break ;;
100    -* )
101       echo "$me: invalid option $1$help" >&2
102       exit 1 ;;
103
104    *local*)
105       # First pass through any local machine types.
106       echo "$1"
107       exit ;;
108
109    * )
110       break ;;
111  esac
112done
113
114case $# in
115 0) echo "$me: missing argument$help" >&2
116    exit 1;;
117 1) ;;
118 *) echo "$me: too many arguments$help" >&2
119    exit 1;;
120esac
121
122# Split fields of configuration type
123# shellcheck disable=SC2162
124saved_IFS=$IFS
125IFS="-" read field1 field2 field3 field4 <<EOF
126$1
127EOF
128IFS=$saved_IFS
129
130# Separate into logical components for further validation
131case $1 in
132	*-*-*-*-*)
133		echo Invalid configuration \`"$1"\': more than four components >&2
134		exit 1
135		;;
136	*-*-*-*)
137		basic_machine=$field1-$field2
138		basic_os=$field3-$field4
139		;;
140	*-*-*)
141		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142		# parts
143		maybe_os=$field2-$field3
144		case $maybe_os in
145			nto-qnx* | linux-* | uclinux-uclibc* \
146			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
147			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
148			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
149				basic_machine=$field1
150				basic_os=$maybe_os
151				;;
152			android-linux)
153				basic_machine=$field1-unknown
154				basic_os=linux-android
155				;;
156			*)
157				basic_machine=$field1-$field2
158				basic_os=$field3
159				;;
160		esac
161		;;
162	*-*)
163		# A lone config we happen to match not fitting any pattern
164		case $field1-$field2 in
165			decstation-3100)
166				basic_machine=mips-dec
167				basic_os=
168				;;
169			*-*)
170				# Second component is usually, but not always the OS
171				case $field2 in
172					# Prevent following clause from handling this valid os
173					sun*os*)
174						basic_machine=$field1
175						basic_os=$field2
176						;;
177					zephyr*)
178						basic_machine=$field1-unknown
179						basic_os=$field2
180						;;
181					# Manufacturers
182					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
183					| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
184					| unicom* | ibm* | next | hp | isi* | apollo | altos* \
185					| convergent* | ncr* | news | 32* | 3600* | 3100* \
186					| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
187					| ultra | tti* | harris | dolphin | highlevel | gould \
188					| cbm | ns | masscomp | apple | axis | knuth | cray \
189					| microblaze* | sim | cisco \
190					| oki | wec | wrs | winbond)
191						basic_machine=$field1-$field2
192						basic_os=
193						;;
194					*)
195						basic_machine=$field1
196						basic_os=$field2
197						;;
198				esac
199			;;
200		esac
201		;;
202	*)
203		# Convert single-component short-hands not valid as part of
204		# multi-component configurations.
205		case $field1 in
206			386bsd)
207				basic_machine=i386-pc
208				basic_os=bsd
209				;;
210			a29khif)
211				basic_machine=a29k-amd
212				basic_os=udi
213				;;
214			adobe68k)
215				basic_machine=m68010-adobe
216				basic_os=scout
217				;;
218			alliant)
219				basic_machine=fx80-alliant
220				basic_os=
221				;;
222			altos | altos3068)
223				basic_machine=m68k-altos
224				basic_os=
225				;;
226			am29k)
227				basic_machine=a29k-none
228				basic_os=bsd
229				;;
230			amdahl)
231				basic_machine=580-amdahl
232				basic_os=sysv
233				;;
234			amiga)
235				basic_machine=m68k-unknown
236				basic_os=
237				;;
238			amigaos | amigados)
239				basic_machine=m68k-unknown
240				basic_os=amigaos
241				;;
242			amigaunix | amix)
243				basic_machine=m68k-unknown
244				basic_os=sysv4
245				;;
246			apollo68)
247				basic_machine=m68k-apollo
248				basic_os=sysv
249				;;
250			apollo68bsd)
251				basic_machine=m68k-apollo
252				basic_os=bsd
253				;;
254			aros)
255				basic_machine=i386-pc
256				basic_os=aros
257				;;
258			aux)
259				basic_machine=m68k-apple
260				basic_os=aux
261				;;
262			balance)
263				basic_machine=ns32k-sequent
264				basic_os=dynix
265				;;
266			blackfin)
267				basic_machine=bfin-unknown
268				basic_os=linux
269				;;
270			cegcc)
271				basic_machine=arm-unknown
272				basic_os=cegcc
273				;;
274			convex-c1)
275				basic_machine=c1-convex
276				basic_os=bsd
277				;;
278			convex-c2)
279				basic_machine=c2-convex
280				basic_os=bsd
281				;;
282			convex-c32)
283				basic_machine=c32-convex
284				basic_os=bsd
285				;;
286			convex-c34)
287				basic_machine=c34-convex
288				basic_os=bsd
289				;;
290			convex-c38)
291				basic_machine=c38-convex
292				basic_os=bsd
293				;;
294			cray)
295				basic_machine=j90-cray
296				basic_os=unicos
297				;;
298			crds | unos)
299				basic_machine=m68k-crds
300				basic_os=
301				;;
302			da30)
303				basic_machine=m68k-da30
304				basic_os=
305				;;
306			decstation | pmax | pmin | dec3100 | decstatn)
307				basic_machine=mips-dec
308				basic_os=
309				;;
310			delta88)
311				basic_machine=m88k-motorola
312				basic_os=sysv3
313				;;
314			dicos)
315				basic_machine=i686-pc
316				basic_os=dicos
317				;;
318			djgpp)
319				basic_machine=i586-pc
320				basic_os=msdosdjgpp
321				;;
322			ebmon29k)
323				basic_machine=a29k-amd
324				basic_os=ebmon
325				;;
326			es1800 | OSE68k | ose68k | ose | OSE)
327				basic_machine=m68k-ericsson
328				basic_os=ose
329				;;
330			gmicro)
331				basic_machine=tron-gmicro
332				basic_os=sysv
333				;;
334			go32)
335				basic_machine=i386-pc
336				basic_os=go32
337				;;
338			h8300hms)
339				basic_machine=h8300-hitachi
340				basic_os=hms
341				;;
342			h8300xray)
343				basic_machine=h8300-hitachi
344				basic_os=xray
345				;;
346			h8500hms)
347				basic_machine=h8500-hitachi
348				basic_os=hms
349				;;
350			harris)
351				basic_machine=m88k-harris
352				basic_os=sysv3
353				;;
354			hp300 | hp300hpux)
355				basic_machine=m68k-hp
356				basic_os=hpux
357				;;
358			hp300bsd)
359				basic_machine=m68k-hp
360				basic_os=bsd
361				;;
362			hppaosf)
363				basic_machine=hppa1.1-hp
364				basic_os=osf
365				;;
366			hppro)
367				basic_machine=hppa1.1-hp
368				basic_os=proelf
369				;;
370			i386mach)
371				basic_machine=i386-mach
372				basic_os=mach
373				;;
374			isi68 | isi)
375				basic_machine=m68k-isi
376				basic_os=sysv
377				;;
378			m68knommu)
379				basic_machine=m68k-unknown
380				basic_os=linux
381				;;
382			magnum | m3230)
383				basic_machine=mips-mips
384				basic_os=sysv
385				;;
386			merlin)
387				basic_machine=ns32k-utek
388				basic_os=sysv
389				;;
390			mingw64)
391				basic_machine=x86_64-pc
392				basic_os=mingw64
393				;;
394			mingw32)
395				basic_machine=i686-pc
396				basic_os=mingw32
397				;;
398			mingw32ce)
399				basic_machine=arm-unknown
400				basic_os=mingw32ce
401				;;
402			monitor)
403				basic_machine=m68k-rom68k
404				basic_os=coff
405				;;
406			morphos)
407				basic_machine=powerpc-unknown
408				basic_os=morphos
409				;;
410			moxiebox)
411				basic_machine=moxie-unknown
412				basic_os=moxiebox
413				;;
414			msdos)
415				basic_machine=i386-pc
416				basic_os=msdos
417				;;
418			msys)
419				basic_machine=i686-pc
420				basic_os=msys
421				;;
422			mvs)
423				basic_machine=i370-ibm
424				basic_os=mvs
425				;;
426			nacl)
427				basic_machine=le32-unknown
428				basic_os=nacl
429				;;
430			ncr3000)
431				basic_machine=i486-ncr
432				basic_os=sysv4
433				;;
434			netbsd386)
435				basic_machine=i386-pc
436				basic_os=netbsd
437				;;
438			netwinder)
439				basic_machine=armv4l-rebel
440				basic_os=linux
441				;;
442			news | news700 | news800 | news900)
443				basic_machine=m68k-sony
444				basic_os=newsos
445				;;
446			news1000)
447				basic_machine=m68030-sony
448				basic_os=newsos
449				;;
450			necv70)
451				basic_machine=v70-nec
452				basic_os=sysv
453				;;
454			nh3000)
455				basic_machine=m68k-harris
456				basic_os=cxux
457				;;
458			nh[45]000)
459				basic_machine=m88k-harris
460				basic_os=cxux
461				;;
462			nindy960)
463				basic_machine=i960-intel
464				basic_os=nindy
465				;;
466			mon960)
467				basic_machine=i960-intel
468				basic_os=mon960
469				;;
470			nonstopux)
471				basic_machine=mips-compaq
472				basic_os=nonstopux
473				;;
474			os400)
475				basic_machine=powerpc-ibm
476				basic_os=os400
477				;;
478			OSE68000 | ose68000)
479				basic_machine=m68000-ericsson
480				basic_os=ose
481				;;
482			os68k)
483				basic_machine=m68k-none
484				basic_os=os68k
485				;;
486			paragon)
487				basic_machine=i860-intel
488				basic_os=osf
489				;;
490			parisc)
491				basic_machine=hppa-unknown
492				basic_os=linux
493				;;
494			psp)
495				basic_machine=mipsallegrexel-sony
496				basic_os=psp
497				;;
498			pw32)
499				basic_machine=i586-unknown
500				basic_os=pw32
501				;;
502			rdos | rdos64)
503				basic_machine=x86_64-pc
504				basic_os=rdos
505				;;
506			rdos32)
507				basic_machine=i386-pc
508				basic_os=rdos
509				;;
510			rom68k)
511				basic_machine=m68k-rom68k
512				basic_os=coff
513				;;
514			sa29200)
515				basic_machine=a29k-amd
516				basic_os=udi
517				;;
518			sei)
519				basic_machine=mips-sei
520				basic_os=seiux
521				;;
522			sequent)
523				basic_machine=i386-sequent
524				basic_os=
525				;;
526			sps7)
527				basic_machine=m68k-bull
528				basic_os=sysv2
529				;;
530			st2000)
531				basic_machine=m68k-tandem
532				basic_os=
533				;;
534			stratus)
535				basic_machine=i860-stratus
536				basic_os=sysv4
537				;;
538			sun2)
539				basic_machine=m68000-sun
540				basic_os=
541				;;
542			sun2os3)
543				basic_machine=m68000-sun
544				basic_os=sunos3
545				;;
546			sun2os4)
547				basic_machine=m68000-sun
548				basic_os=sunos4
549				;;
550			sun3)
551				basic_machine=m68k-sun
552				basic_os=
553				;;
554			sun3os3)
555				basic_machine=m68k-sun
556				basic_os=sunos3
557				;;
558			sun3os4)
559				basic_machine=m68k-sun
560				basic_os=sunos4
561				;;
562			sun4)
563				basic_machine=sparc-sun
564				basic_os=
565				;;
566			sun4os3)
567				basic_machine=sparc-sun
568				basic_os=sunos3
569				;;
570			sun4os4)
571				basic_machine=sparc-sun
572				basic_os=sunos4
573				;;
574			sun4sol2)
575				basic_machine=sparc-sun
576				basic_os=solaris2
577				;;
578			sun386 | sun386i | roadrunner)
579				basic_machine=i386-sun
580				basic_os=
581				;;
582			sv1)
583				basic_machine=sv1-cray
584				basic_os=unicos
585				;;
586			symmetry)
587				basic_machine=i386-sequent
588				basic_os=dynix
589				;;
590			t3e)
591				basic_machine=alphaev5-cray
592				basic_os=unicos
593				;;
594			t90)
595				basic_machine=t90-cray
596				basic_os=unicos
597				;;
598			toad1)
599				basic_machine=pdp10-xkl
600				basic_os=tops20
601				;;
602			tpf)
603				basic_machine=s390x-ibm
604				basic_os=tpf
605				;;
606			udi29k)
607				basic_machine=a29k-amd
608				basic_os=udi
609				;;
610			ultra3)
611				basic_machine=a29k-nyu
612				basic_os=sym1
613				;;
614			v810 | necv810)
615				basic_machine=v810-nec
616				basic_os=none
617				;;
618			vaxv)
619				basic_machine=vax-dec
620				basic_os=sysv
621				;;
622			vms)
623				basic_machine=vax-dec
624				basic_os=vms
625				;;
626			vsta)
627				basic_machine=i386-pc
628				basic_os=vsta
629				;;
630			vxworks960)
631				basic_machine=i960-wrs
632				basic_os=vxworks
633				;;
634			vxworks68)
635				basic_machine=m68k-wrs
636				basic_os=vxworks
637				;;
638			vxworks29k)
639				basic_machine=a29k-wrs
640				basic_os=vxworks
641				;;
642			xbox)
643				basic_machine=i686-pc
644				basic_os=mingw32
645				;;
646			ymp)
647				basic_machine=ymp-cray
648				basic_os=unicos
649				;;
650			*)
651				basic_machine=$1
652				basic_os=
653				;;
654		esac
655		;;
656esac
657
658# Decode 1-component or ad-hoc basic machines
659case $basic_machine in
660	# Here we handle the default manufacturer of certain CPU types.  It is in
661	# some cases the only manufacturer, in others, it is the most popular.
662	w89k)
663		cpu=hppa1.1
664		vendor=winbond
665		;;
666	op50n)
667		cpu=hppa1.1
668		vendor=oki
669		;;
670	op60c)
671		cpu=hppa1.1
672		vendor=oki
673		;;
674	ibm*)
675		cpu=i370
676		vendor=ibm
677		;;
678	orion105)
679		cpu=clipper
680		vendor=highlevel
681		;;
682	mac | mpw | mac-mpw)
683		cpu=m68k
684		vendor=apple
685		;;
686	pmac | pmac-mpw)
687		cpu=powerpc
688		vendor=apple
689		;;
690
691	# Recognize the various machine names and aliases which stand
692	# for a CPU type and a company and sometimes even an OS.
693	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
694		cpu=m68000
695		vendor=att
696		;;
697	3b*)
698		cpu=we32k
699		vendor=att
700		;;
701	bluegene*)
702		cpu=powerpc
703		vendor=ibm
704		basic_os=cnk
705		;;
706	decsystem10* | dec10*)
707		cpu=pdp10
708		vendor=dec
709		basic_os=tops10
710		;;
711	decsystem20* | dec20*)
712		cpu=pdp10
713		vendor=dec
714		basic_os=tops20
715		;;
716	delta | 3300 | motorola-3300 | motorola-delta \
717	      | 3300-motorola | delta-motorola)
718		cpu=m68k
719		vendor=motorola
720		;;
721	dpx2*)
722		cpu=m68k
723		vendor=bull
724		basic_os=sysv3
725		;;
726	encore | umax | mmax)
727		cpu=ns32k
728		vendor=encore
729		;;
730	elxsi)
731		cpu=elxsi
732		vendor=elxsi
733		basic_os=${basic_os:-bsd}
734		;;
735	fx2800)
736		cpu=i860
737		vendor=alliant
738		;;
739	genix)
740		cpu=ns32k
741		vendor=ns
742		;;
743	h3050r* | hiux*)
744		cpu=hppa1.1
745		vendor=hitachi
746		basic_os=hiuxwe2
747		;;
748	hp3k9[0-9][0-9] | hp9[0-9][0-9])
749		cpu=hppa1.0
750		vendor=hp
751		;;
752	hp9k2[0-9][0-9] | hp9k31[0-9])
753		cpu=m68000
754		vendor=hp
755		;;
756	hp9k3[2-9][0-9])
757		cpu=m68k
758		vendor=hp
759		;;
760	hp9k6[0-9][0-9] | hp6[0-9][0-9])
761		cpu=hppa1.0
762		vendor=hp
763		;;
764	hp9k7[0-79][0-9] | hp7[0-79][0-9])
765		cpu=hppa1.1
766		vendor=hp
767		;;
768	hp9k78[0-9] | hp78[0-9])
769		# FIXME: really hppa2.0-hp
770		cpu=hppa1.1
771		vendor=hp
772		;;
773	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
774		# FIXME: really hppa2.0-hp
775		cpu=hppa1.1
776		vendor=hp
777		;;
778	hp9k8[0-9][13679] | hp8[0-9][13679])
779		cpu=hppa1.1
780		vendor=hp
781		;;
782	hp9k8[0-9][0-9] | hp8[0-9][0-9])
783		cpu=hppa1.0
784		vendor=hp
785		;;
786	i*86v32)
787		cpu=`echo "$1" | sed -e 's/86.*/86/'`
788		vendor=pc
789		basic_os=sysv32
790		;;
791	i*86v4*)
792		cpu=`echo "$1" | sed -e 's/86.*/86/'`
793		vendor=pc
794		basic_os=sysv4
795		;;
796	i*86v)
797		cpu=`echo "$1" | sed -e 's/86.*/86/'`
798		vendor=pc
799		basic_os=sysv
800		;;
801	i*86sol2)
802		cpu=`echo "$1" | sed -e 's/86.*/86/'`
803		vendor=pc
804		basic_os=solaris2
805		;;
806	j90 | j90-cray)
807		cpu=j90
808		vendor=cray
809		basic_os=${basic_os:-unicos}
810		;;
811	iris | iris4d)
812		cpu=mips
813		vendor=sgi
814		case $basic_os in
815		    irix*)
816			;;
817		    *)
818			basic_os=irix4
819			;;
820		esac
821		;;
822	miniframe)
823		cpu=m68000
824		vendor=convergent
825		;;
826	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
827		cpu=m68k
828		vendor=atari
829		basic_os=mint
830		;;
831	news-3600 | risc-news)
832		cpu=mips
833		vendor=sony
834		basic_os=newsos
835		;;
836	next | m*-next)
837		cpu=m68k
838		vendor=next
839		case $basic_os in
840		    openstep*)
841		        ;;
842		    nextstep*)
843			;;
844		    ns2*)
845		      basic_os=nextstep2
846			;;
847		    *)
848		      basic_os=nextstep3
849			;;
850		esac
851		;;
852	np1)
853		cpu=np1
854		vendor=gould
855		;;
856	op50n-* | op60c-*)
857		cpu=hppa1.1
858		vendor=oki
859		basic_os=proelf
860		;;
861	pa-hitachi)
862		cpu=hppa1.1
863		vendor=hitachi
864		basic_os=hiuxwe2
865		;;
866	pbd)
867		cpu=sparc
868		vendor=tti
869		;;
870	pbb)
871		cpu=m68k
872		vendor=tti
873		;;
874	pc532)
875		cpu=ns32k
876		vendor=pc532
877		;;
878	pn)
879		cpu=pn
880		vendor=gould
881		;;
882	power)
883		cpu=power
884		vendor=ibm
885		;;
886	ps2)
887		cpu=i386
888		vendor=ibm
889		;;
890	rm[46]00)
891		cpu=mips
892		vendor=siemens
893		;;
894	rtpc | rtpc-*)
895		cpu=romp
896		vendor=ibm
897		;;
898	sde)
899		cpu=mipsisa32
900		vendor=sde
901		basic_os=${basic_os:-elf}
902		;;
903	simso-wrs)
904		cpu=sparclite
905		vendor=wrs
906		basic_os=vxworks
907		;;
908	tower | tower-32)
909		cpu=m68k
910		vendor=ncr
911		;;
912	vpp*|vx|vx-*)
913		cpu=f301
914		vendor=fujitsu
915		;;
916	w65)
917		cpu=w65
918		vendor=wdc
919		;;
920	w89k-*)
921		cpu=hppa1.1
922		vendor=winbond
923		basic_os=proelf
924		;;
925	none)
926		cpu=none
927		vendor=none
928		;;
929	leon|leon[3-9])
930		cpu=sparc
931		vendor=$basic_machine
932		;;
933	leon-*|leon[3-9]-*)
934		cpu=sparc
935		vendor=`echo "$basic_machine" | sed 's/-.*//'`
936		;;
937
938	*-*)
939		# shellcheck disable=SC2162
940		saved_IFS=$IFS
941		IFS="-" read cpu vendor <<EOF
942$basic_machine
943EOF
944		IFS=$saved_IFS
945		;;
946	# We use `pc' rather than `unknown'
947	# because (1) that's what they normally are, and
948	# (2) the word "unknown" tends to confuse beginning users.
949	i*86 | x86_64)
950		cpu=$basic_machine
951		vendor=pc
952		;;
953	# These rules are duplicated from below for sake of the special case above;
954	# i.e. things that normalized to x86 arches should also default to "pc"
955	pc98)
956		cpu=i386
957		vendor=pc
958		;;
959	x64 | amd64)
960		cpu=x86_64
961		vendor=pc
962		;;
963	# Recognize the basic CPU types without company name.
964	*)
965		cpu=$basic_machine
966		vendor=unknown
967		;;
968esac
969
970unset -v basic_machine
971
972# Decode basic machines in the full and proper CPU-Company form.
973case $cpu-$vendor in
974	# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
975	# some cases the only manufacturer, in others, it is the most popular.
976	craynv-unknown)
977		vendor=cray
978		basic_os=${basic_os:-unicosmp}
979		;;
980	c90-unknown | c90-cray)
981		vendor=cray
982		basic_os=${Basic_os:-unicos}
983		;;
984	fx80-unknown)
985		vendor=alliant
986		;;
987	romp-unknown)
988		vendor=ibm
989		;;
990	mmix-unknown)
991		vendor=knuth
992		;;
993	microblaze-unknown | microblazeel-unknown)
994		vendor=xilinx
995		;;
996	rs6000-unknown)
997		vendor=ibm
998		;;
999	vax-unknown)
1000		vendor=dec
1001		;;
1002	pdp11-unknown)
1003		vendor=dec
1004		;;
1005	we32k-unknown)
1006		vendor=att
1007		;;
1008	cydra-unknown)
1009		vendor=cydrome
1010		;;
1011	i370-ibm*)
1012		vendor=ibm
1013		;;
1014	orion-unknown)
1015		vendor=highlevel
1016		;;
1017	xps-unknown | xps100-unknown)
1018		cpu=xps100
1019		vendor=honeywell
1020		;;
1021
1022	# Here we normalize CPU types with a missing or matching vendor
1023	armh-unknown | armh-alt)
1024		cpu=armv7l
1025		vendor=alt
1026		basic_os=${basic_os:-linux-gnueabihf}
1027		;;
1028	dpx20-unknown | dpx20-bull)
1029		cpu=rs6000
1030		vendor=bull
1031		basic_os=${basic_os:-bosx}
1032		;;
1033
1034	# Here we normalize CPU types irrespective of the vendor
1035	amd64-*)
1036		cpu=x86_64
1037		;;
1038	blackfin-*)
1039		cpu=bfin
1040		basic_os=linux
1041		;;
1042	c54x-*)
1043		cpu=tic54x
1044		;;
1045	c55x-*)
1046		cpu=tic55x
1047		;;
1048	c6x-*)
1049		cpu=tic6x
1050		;;
1051	e500v[12]-*)
1052		cpu=powerpc
1053		basic_os=${basic_os}"spe"
1054		;;
1055	mips3*-*)
1056		cpu=mips64
1057		;;
1058	ms1-*)
1059		cpu=mt
1060		;;
1061	m68knommu-*)
1062		cpu=m68k
1063		basic_os=linux
1064		;;
1065	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1066		cpu=s12z
1067		;;
1068	openrisc-*)
1069		cpu=or32
1070		;;
1071	parisc-*)
1072		cpu=hppa
1073		basic_os=linux
1074		;;
1075	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1076		cpu=i586
1077		;;
1078	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1079		cpu=i686
1080		;;
1081	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1082		cpu=i686
1083		;;
1084	pentium4-*)
1085		cpu=i786
1086		;;
1087	pc98-*)
1088		cpu=i386
1089		;;
1090	ppc-* | ppcbe-*)
1091		cpu=powerpc
1092		;;
1093	ppcle-* | powerpclittle-*)
1094		cpu=powerpcle
1095		;;
1096	ppc64-*)
1097		cpu=powerpc64
1098		;;
1099	ppc64le-* | powerpc64little-*)
1100		cpu=powerpc64le
1101		;;
1102	sb1-*)
1103		cpu=mipsisa64sb1
1104		;;
1105	sb1el-*)
1106		cpu=mipsisa64sb1el
1107		;;
1108	sh5e[lb]-*)
1109		cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1110		;;
1111	spur-*)
1112		cpu=spur
1113		;;
1114	strongarm-* | thumb-*)
1115		cpu=arm
1116		;;
1117	tx39-*)
1118		cpu=mipstx39
1119		;;
1120	tx39el-*)
1121		cpu=mipstx39el
1122		;;
1123	x64-*)
1124		cpu=x86_64
1125		;;
1126	xscale-* | xscalee[bl]-*)
1127		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1128		;;
1129	arm64-* | aarch64le-*)
1130		cpu=aarch64
1131		;;
1132
1133	# Recognize the canonical CPU Types that limit and/or modify the
1134	# company names they are paired with.
1135	cr16-*)
1136		basic_os=${basic_os:-elf}
1137		;;
1138	crisv32-* | etraxfs*-*)
1139		cpu=crisv32
1140		vendor=axis
1141		;;
1142	cris-* | etrax*-*)
1143		cpu=cris
1144		vendor=axis
1145		;;
1146	crx-*)
1147		basic_os=${basic_os:-elf}
1148		;;
1149	neo-tandem)
1150		cpu=neo
1151		vendor=tandem
1152		;;
1153	nse-tandem)
1154		cpu=nse
1155		vendor=tandem
1156		;;
1157	nsr-tandem)
1158		cpu=nsr
1159		vendor=tandem
1160		;;
1161	nsv-tandem)
1162		cpu=nsv
1163		vendor=tandem
1164		;;
1165	nsx-tandem)
1166		cpu=nsx
1167		vendor=tandem
1168		;;
1169	mipsallegrexel-sony)
1170		cpu=mipsallegrexel
1171		vendor=sony
1172		;;
1173	tile*-*)
1174		basic_os=${basic_os:-linux-gnu}
1175		;;
1176
1177	*)
1178		# Recognize the canonical CPU types that are allowed with any
1179		# company name.
1180		case $cpu in
1181			1750a | 580 \
1182			| a29k \
1183			| aarch64 | aarch64_be \
1184			| abacus \
1185			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1186			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1187			| alphapca5[67] | alpha64pca5[67] \
1188			| am33_2.0 \
1189			| amdgcn \
1190			| arc | arceb | arc32 | arc64 \
1191			| arm | arm[lb]e | arme[lb] | armv* \
1192			| avr | avr32 \
1193			| asmjs \
1194			| ba \
1195			| be32 | be64 \
1196			| bfin | bpf | bs2000 \
1197			| c[123]* | c30 | [cjt]90 | c4x \
1198			| c8051 | clipper | craynv | csky | cydra \
1199			| d10v | d30v | dlx | dsp16xx \
1200			| e2k | elxsi | epiphany \
1201			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1202			| h8300 | h8500 \
1203			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1204			| hexagon \
1205			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
1206			| ip2k | iq2000 \
1207			| k1om \
1208			| le32 | le64 \
1209			| lm32 \
1210			| loongarch32 | loongarch64 \
1211			| m32c | m32r | m32rle \
1212			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1213			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1214			| m88110 | m88k | maxq | mb | mcore | mep | metag \
1215			| microblaze | microblazeel \
1216			| mips | mipsbe | mipseb | mipsel | mipsle \
1217			| mips16 \
1218			| mips64 | mips64eb | mips64el \
1219			| mips64octeon | mips64octeonel \
1220			| mips64orion | mips64orionel \
1221			| mips64r5900 | mips64r5900el \
1222			| mips64vr | mips64vrel \
1223			| mips64vr4100 | mips64vr4100el \
1224			| mips64vr4300 | mips64vr4300el \
1225			| mips64vr5000 | mips64vr5000el \
1226			| mips64vr5900 | mips64vr5900el \
1227			| mipsisa32 | mipsisa32el \
1228			| mipsisa32r2 | mipsisa32r2el \
1229			| mipsisa32r3 | mipsisa32r3el \
1230			| mipsisa32r5 | mipsisa32r5el \
1231			| mipsisa32r6 | mipsisa32r6el \
1232			| mipsisa64 | mipsisa64el \
1233			| mipsisa64r2 | mipsisa64r2el \
1234			| mipsisa64r3 | mipsisa64r3el \
1235			| mipsisa64r5 | mipsisa64r5el \
1236			| mipsisa64r6 | mipsisa64r6el \
1237			| mipsisa64sb1 | mipsisa64sb1el \
1238			| mipsisa64sr71k | mipsisa64sr71kel \
1239			| mipsr5900 | mipsr5900el \
1240			| mipstx39 | mipstx39el \
1241			| mmix \
1242			| mn10200 | mn10300 \
1243			| moxie \
1244			| mt \
1245			| msp430 \
1246			| nds32 | nds32le | nds32be \
1247			| nfp \
1248			| nios | nios2 | nios2eb | nios2el \
1249			| none | np1 | ns16k | ns32k | nvptx \
1250			| open8 \
1251			| or1k* \
1252			| or32 \
1253			| orion \
1254			| picochip \
1255			| pdp10 | pdp11 | pj | pjl | pn | power \
1256			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1257			| pru \
1258			| pyramid \
1259			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1260			| rl78 | romp | rs6000 | rx \
1261			| s390 | s390x \
1262			| score \
1263			| sh | shl \
1264			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1265			| sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1266			| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1267			| sparclite \
1268			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1269			| spu \
1270			| tahoe \
1271			| thumbv7* \
1272			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1273			| tron \
1274			| ubicom32 \
1275			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1276			| vax \
1277			| visium \
1278			| w65 \
1279			| wasm32 | wasm64 \
1280			| we32k \
1281			| x86 | x86_64 | xc16x | xgate | xps100 \
1282			| xstormy16 | xtensa* \
1283			| ymp \
1284			| z8k | z80)
1285				;;
1286
1287			*)
1288				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1289				exit 1
1290				;;
1291		esac
1292		;;
1293esac
1294
1295# Here we canonicalize certain aliases for manufacturers.
1296case $vendor in
1297	digital*)
1298		vendor=dec
1299		;;
1300	commodore*)
1301		vendor=cbm
1302		;;
1303	*)
1304		;;
1305esac
1306
1307# Decode manufacturer-specific aliases for certain operating systems.
1308
1309if test x$basic_os != x
1310then
1311
1312# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1313# set os.
1314case $basic_os in
1315	gnu/linux*)
1316		kernel=linux
1317		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1318		;;
1319	os2-emx)
1320		kernel=os2
1321		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1322		;;
1323	nto-qnx*)
1324		kernel=nto
1325		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1326		;;
1327	*-*)
1328		# shellcheck disable=SC2162
1329		saved_IFS=$IFS
1330		IFS="-" read kernel os <<EOF
1331$basic_os
1332EOF
1333		IFS=$saved_IFS
1334		;;
1335	# Default OS when just kernel was specified
1336	nto*)
1337		kernel=nto
1338		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1339		;;
1340	linux*)
1341		kernel=linux
1342		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1343		;;
1344	managarm*)
1345		kernel=managarm
1346		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1347		;;
1348	*)
1349		kernel=
1350		os=$basic_os
1351		;;
1352esac
1353
1354# Now, normalize the OS (knowing we just have one component, it's not a kernel,
1355# etc.)
1356case $os in
1357	# First match some system type aliases that might get confused
1358	# with valid system types.
1359	# solaris* is a basic system type, with this one exception.
1360	auroraux)
1361		os=auroraux
1362		;;
1363	bluegene*)
1364		os=cnk
1365		;;
1366	solaris1 | solaris1.*)
1367		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1368		;;
1369	solaris)
1370		os=solaris2
1371		;;
1372	unixware*)
1373		os=sysv4.2uw
1374		;;
1375	# es1800 is here to avoid being matched by es* (a different OS)
1376	es1800*)
1377		os=ose
1378		;;
1379	# Some version numbers need modification
1380	chorusos*)
1381		os=chorusos
1382		;;
1383	isc)
1384		os=isc2.2
1385		;;
1386	sco6)
1387		os=sco5v6
1388		;;
1389	sco5)
1390		os=sco3.2v5
1391		;;
1392	sco4)
1393		os=sco3.2v4
1394		;;
1395	sco3.2.[4-9]*)
1396		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1397		;;
1398	sco*v* | scout)
1399		# Don't match below
1400		;;
1401	sco*)
1402		os=sco3.2v2
1403		;;
1404	psos*)
1405		os=psos
1406		;;
1407	qnx*)
1408		os=qnx
1409		;;
1410	hiux*)
1411		os=hiuxwe2
1412		;;
1413	lynx*178)
1414		os=lynxos178
1415		;;
1416	lynx*5)
1417		os=lynxos5
1418		;;
1419	lynxos*)
1420		# don't get caught up in next wildcard
1421		;;
1422	lynx*)
1423		os=lynxos
1424		;;
1425	mac[0-9]*)
1426		os=`echo "$os" | sed -e 's|mac|macos|'`
1427		;;
1428	opened*)
1429		os=openedition
1430		;;
1431	os400*)
1432		os=os400
1433		;;
1434	sunos5*)
1435		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1436		;;
1437	sunos6*)
1438		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1439		;;
1440	wince*)
1441		os=wince
1442		;;
1443	utek*)
1444		os=bsd
1445		;;
1446	dynix*)
1447		os=bsd
1448		;;
1449	acis*)
1450		os=aos
1451		;;
1452	atheos*)
1453		os=atheos
1454		;;
1455	syllable*)
1456		os=syllable
1457		;;
1458	386bsd)
1459		os=bsd
1460		;;
1461	ctix* | uts*)
1462		os=sysv
1463		;;
1464	nova*)
1465		os=rtmk-nova
1466		;;
1467	ns2)
1468		os=nextstep2
1469		;;
1470	# Preserve the version number of sinix5.
1471	sinix5.*)
1472		os=`echo "$os" | sed -e 's|sinix|sysv|'`
1473		;;
1474	sinix*)
1475		os=sysv4
1476		;;
1477	tpf*)
1478		os=tpf
1479		;;
1480	triton*)
1481		os=sysv3
1482		;;
1483	oss*)
1484		os=sysv3
1485		;;
1486	svr4*)
1487		os=sysv4
1488		;;
1489	svr3)
1490		os=sysv3
1491		;;
1492	sysvr4)
1493		os=sysv4
1494		;;
1495	ose*)
1496		os=ose
1497		;;
1498	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1499		os=mint
1500		;;
1501	dicos*)
1502		os=dicos
1503		;;
1504	pikeos*)
1505		# Until real need of OS specific support for
1506		# particular features comes up, bare metal
1507		# configurations are quite functional.
1508		case $cpu in
1509		    arm*)
1510			os=eabi
1511			;;
1512		    *)
1513			os=elf
1514			;;
1515		esac
1516		;;
1517	*)
1518		# No normalization, but not necessarily accepted, that comes below.
1519		;;
1520esac
1521
1522else
1523
1524# Here we handle the default operating systems that come with various machines.
1525# The value should be what the vendor currently ships out the door with their
1526# machine or put another way, the most popular os provided with the machine.
1527
1528# Note that if you're going to try to match "-MANUFACTURER" here (say,
1529# "-sun"), then you have to tell the case statement up towards the top
1530# that MANUFACTURER isn't an operating system.  Otherwise, code above
1531# will signal an error saying that MANUFACTURER isn't an operating
1532# system, and we'll never get to this point.
1533
1534kernel=
1535case $cpu-$vendor in
1536	score-*)
1537		os=elf
1538		;;
1539	spu-*)
1540		os=elf
1541		;;
1542	*-acorn)
1543		os=riscix1.2
1544		;;
1545	arm*-rebel)
1546		kernel=linux
1547		os=gnu
1548		;;
1549	arm*-semi)
1550		os=aout
1551		;;
1552	c4x-* | tic4x-*)
1553		os=coff
1554		;;
1555	c8051-*)
1556		os=elf
1557		;;
1558	clipper-intergraph)
1559		os=clix
1560		;;
1561	hexagon-*)
1562		os=elf
1563		;;
1564	tic54x-*)
1565		os=coff
1566		;;
1567	tic55x-*)
1568		os=coff
1569		;;
1570	tic6x-*)
1571		os=coff
1572		;;
1573	# This must come before the *-dec entry.
1574	pdp10-*)
1575		os=tops20
1576		;;
1577	pdp11-*)
1578		os=none
1579		;;
1580	*-dec | vax-*)
1581		os=ultrix4.2
1582		;;
1583	m68*-apollo)
1584		os=domain
1585		;;
1586	i386-sun)
1587		os=sunos4.0.2
1588		;;
1589	m68000-sun)
1590		os=sunos3
1591		;;
1592	m68*-cisco)
1593		os=aout
1594		;;
1595	mep-*)
1596		os=elf
1597		;;
1598	mips*-cisco)
1599		os=elf
1600		;;
1601	mips*-*)
1602		os=elf
1603		;;
1604	or32-*)
1605		os=coff
1606		;;
1607	*-tti)	# must be before sparc entry or we get the wrong os.
1608		os=sysv3
1609		;;
1610	sparc-* | *-sun)
1611		os=sunos4.1.1
1612		;;
1613	pru-*)
1614		os=elf
1615		;;
1616	*-be)
1617		os=beos
1618		;;
1619	*-ibm)
1620		os=aix
1621		;;
1622	*-knuth)
1623		os=mmixware
1624		;;
1625	*-wec)
1626		os=proelf
1627		;;
1628	*-winbond)
1629		os=proelf
1630		;;
1631	*-oki)
1632		os=proelf
1633		;;
1634	*-hp)
1635		os=hpux
1636		;;
1637	*-hitachi)
1638		os=hiux
1639		;;
1640	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1641		os=sysv
1642		;;
1643	*-cbm)
1644		os=amigaos
1645		;;
1646	*-dg)
1647		os=dgux
1648		;;
1649	*-dolphin)
1650		os=sysv3
1651		;;
1652	m68k-ccur)
1653		os=rtu
1654		;;
1655	m88k-omron*)
1656		os=luna
1657		;;
1658	*-next)
1659		os=nextstep
1660		;;
1661	*-sequent)
1662		os=ptx
1663		;;
1664	*-crds)
1665		os=unos
1666		;;
1667	*-ns)
1668		os=genix
1669		;;
1670	i370-*)
1671		os=mvs
1672		;;
1673	*-gould)
1674		os=sysv
1675		;;
1676	*-highlevel)
1677		os=bsd
1678		;;
1679	*-encore)
1680		os=bsd
1681		;;
1682	*-sgi)
1683		os=irix
1684		;;
1685	*-siemens)
1686		os=sysv4
1687		;;
1688	*-masscomp)
1689		os=rtu
1690		;;
1691	f30[01]-fujitsu | f700-fujitsu)
1692		os=uxpv
1693		;;
1694	*-rom68k)
1695		os=coff
1696		;;
1697	*-*bug)
1698		os=coff
1699		;;
1700	*-apple)
1701		os=macos
1702		;;
1703	*-atari*)
1704		os=mint
1705		;;
1706	*-wrs)
1707		os=vxworks
1708		;;
1709	*)
1710		os=none
1711		;;
1712esac
1713
1714fi
1715
1716# Now, validate our (potentially fixed-up) OS.
1717case $os in
1718	# Sometimes we do "kernel-libc", so those need to count as OSes.
1719	musl* | newlib* | relibc* | uclibc*)
1720		;;
1721	# Likewise for "kernel-abi"
1722	eabi* | gnueabi*)
1723		;;
1724	# VxWorks passes extra cpu info in the 4th filed.
1725	simlinux | simwindows | spe)
1726		;;
1727	# Now accept the basic system types.
1728	# The portable systems comes first.
1729	# Each alternative MUST end in a * to match a version number.
1730	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1731	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1732	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1733	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
1734	     | hiux* | abug | nacl* | netware* | windows* \
1735	     | os9* | macos* | osx* | ios* \
1736	     | mpw* | magic* | mmixware* | mon960* | lnews* \
1737	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1738	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
1739	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1740	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1741	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1742	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1743	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1744	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1745	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1746	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
1747	     | chorusrdb* | cegcc* | glidix* | serenity* \
1748	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1749	     | midipix* | mingw32* | mingw64* | mint* \
1750	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1751	     | interix* | uwin* | mks* | rhapsody* | darwin* \
1752	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
1753	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
1754	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1755	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1756	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1757	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1758	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1759	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1760	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761	     | fiwix* | mlibc* )
1762		;;
1763	# This one is extra strict with allowed versions
1764	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1765		# Don't forget version if it is 3.2v4 or newer.
1766		;;
1767	none)
1768		;;
1769	kernel* )
1770		# Restricted further below
1771		;;
1772	*)
1773		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
1774		exit 1
1775		;;
1776esac
1777
1778# As a final step for OS-related things, validate the OS-kernel combination
1779# (given a valid OS), if there is a kernel.
1780case $kernel-$os in
1781	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782		   | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
1783		;;
1784	uclinux-uclibc* )
1785		;;
1786	managarm-mlibc* | managarm-kernel* )
1787		;;
1788	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
1789		# These are just libc implementations, not actual OSes, and thus
1790		# require a kernel.
1791		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
1792		exit 1
1793		;;
1794	-kernel* )
1795		echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
1796		exit 1
1797		;;
1798	*-kernel* )
1799		echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
1800		exit 1
1801		;;
1802	kfreebsd*-gnu* | kopensolaris*-gnu*)
1803		;;
1804	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1805		;;
1806	nto-qnx*)
1807		;;
1808	os2-emx)
1809		;;
1810	*-eabi* | *-gnueabi*)
1811		;;
1812	-*)
1813		# Blank kernel with real OS is always fine.
1814		;;
1815	*-*)
1816		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
1817		exit 1
1818		;;
1819esac
1820
1821# Here we handle the case where we know the os, and the CPU type, but not the
1822# manufacturer.  We pick the logical manufacturer.
1823case $vendor in
1824	unknown)
1825		case $cpu-$os in
1826			*-riscix*)
1827				vendor=acorn
1828				;;
1829			*-sunos*)
1830				vendor=sun
1831				;;
1832			*-cnk* | *-aix*)
1833				vendor=ibm
1834				;;
1835			*-beos*)
1836				vendor=be
1837				;;
1838			*-hpux*)
1839				vendor=hp
1840				;;
1841			*-mpeix*)
1842				vendor=hp
1843				;;
1844			*-hiux*)
1845				vendor=hitachi
1846				;;
1847			*-unos*)
1848				vendor=crds
1849				;;
1850			*-dgux*)
1851				vendor=dg
1852				;;
1853			*-luna*)
1854				vendor=omron
1855				;;
1856			*-genix*)
1857				vendor=ns
1858				;;
1859			*-clix*)
1860				vendor=intergraph
1861				;;
1862			*-mvs* | *-opened*)
1863				vendor=ibm
1864				;;
1865			*-os400*)
1866				vendor=ibm
1867				;;
1868			s390-* | s390x-*)
1869				vendor=ibm
1870				;;
1871			*-ptx*)
1872				vendor=sequent
1873				;;
1874			*-tpf*)
1875				vendor=ibm
1876				;;
1877			*-vxsim* | *-vxworks* | *-windiss*)
1878				vendor=wrs
1879				;;
1880			*-aux*)
1881				vendor=apple
1882				;;
1883			*-hms*)
1884				vendor=hitachi
1885				;;
1886			*-mpw* | *-macos*)
1887				vendor=apple
1888				;;
1889			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
1890				vendor=atari
1891				;;
1892			*-vos*)
1893				vendor=stratus
1894				;;
1895		esac
1896		;;
1897esac
1898
1899echo "$cpu-$vendor-${kernel:+$kernel-}$os"
1900exit
1901
1902# Local variables:
1903# eval: (add-hook 'before-save-hook 'time-stamp)
1904# time-stamp-start: "timestamp='"
1905# time-stamp-format: "%:y-%02m-%02d"
1906# time-stamp-end: "'"
1907# End:
1908