11#! /bin/sh
22# Configuration validation subroutine script.
3- # Copyright 1992-2021 Free Software Foundation, Inc.
3+ # Copyright 1992-2023 Free Software Foundation, Inc.
44
5- timestamp=' 2021-04-30'
5+ # shellcheck disable=SC2006,SC2268 # see below for rationale
6+
7+ timestamp=' 2023-01-21'
68
79# This file is free software; you can redistribute it and/or modify it
810# under the terms of the GNU General Public License as published by
9- # the Free Software Foundation; either version 3 of the License, or
11+ # the Free Software Foundation, either version 3 of the License, or
1012# (at your option) any later version.
1113#
1214# This program is distributed in the hope that it will be useful, but
@@ -50,7 +52,14 @@ timestamp='2021-04-30'
5052# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
5153# It is wrong to echo any other type of specification.
5254
53- me=$( echo " $0 " | sed -e ' s,.*/,,' )
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+
62+ me=` echo " $0 " | sed -e ' s,.*/,,' `
5463
5564usage=" \
5665Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
6776version=" \
6877GNU config.sub ($timestamp )
6978
70- Copyright 1992-2021 Free Software Foundation, Inc.
79+ Copyright 1992-2023 Free Software Foundation, Inc.
7180
7281This is free software; see the source for copying conditions. There is NO
7382warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -112,9 +121,11 @@ esac
112121
113122# Split fields of configuration type
114123# shellcheck disable=SC2162
124+ saved_IFS=$IFS
115125IFS=" -" read field1 field2 field3 field4 << EOF
116126$1
117127EOF
128+ IFS=$saved_IFS
118129
119130# Separate into logical components for further validation
120131case $1 in
@@ -134,7 +145,7 @@ case $1 in
134145 nto-qnx* | linux-* | uclinux-uclibc* \
135146 | uclinux-gnu* | kfreebsd* -gnu* | knetbsd* -gnu* | netbsd* -gnu* \
136147 | netbsd* -eabi* | kopensolaris* -gnu* | cloudabi* -eabi* \
137- | storm-chaos* | os2-emx* | rtmk-nova* )
148+ | storm-chaos* | os2-emx* | rtmk-nova* | managarm- * )
138149 basic_machine=$field1
139150 basic_os=$maybe_os
140151 ;;
@@ -163,6 +174,10 @@ case $1 in
163174 basic_machine=$field1
164175 basic_os=$field2
165176 ;;
177+ zephyr* )
178+ basic_machine=$field1 -unknown
179+ basic_os=$field2
180+ ;;
166181 # Manufacturers
167182 dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
168183 | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
@@ -769,22 +784,22 @@ case $basic_machine in
769784 vendor=hp
770785 ;;
771786 i* 86v32)
772- cpu=$( echo " $1 " | sed -e ' s/86.*/86/' )
787+ cpu=` echo " $1 " | sed -e ' s/86.*/86/' `
773788 vendor=pc
774789 basic_os=sysv32
775790 ;;
776791 i* 86v4* )
777- cpu=$( echo " $1 " | sed -e ' s/86.*/86/' )
792+ cpu=` echo " $1 " | sed -e ' s/86.*/86/' `
778793 vendor=pc
779794 basic_os=sysv4
780795 ;;
781796 i* 86v)
782- cpu=$( echo " $1 " | sed -e ' s/86.*/86/' )
797+ cpu=` echo " $1 " | sed -e ' s/86.*/86/' `
783798 vendor=pc
784799 basic_os=sysv
785800 ;;
786801 i* 86sol2)
787- cpu=$( echo " $1 " | sed -e ' s/86.*/86/' )
802+ cpu=` echo " $1 " | sed -e ' s/86.*/86/' `
788803 vendor=pc
789804 basic_os=solaris2
790805 ;;
@@ -917,14 +932,16 @@ case $basic_machine in
917932 ;;
918933 leon-* |leon[3-9]-* )
919934 cpu=sparc
920- vendor=$( echo " $basic_machine " | sed ' s/-.*//' )
935+ vendor=` echo " $basic_machine " | sed ' s/-.*//' `
921936 ;;
922937
923938 * -* )
924939 # shellcheck disable=SC2162
940+ saved_IFS=$IFS
925941 IFS=" -" read cpu vendor << EOF
926942$basic_machine
927943EOF
944+ IFS=$saved_IFS
928945 ;;
929946 # We use `pc' rather than `unknown'
930947 # because (1) that's what they normally are, and
@@ -1003,6 +1020,11 @@ case $cpu-$vendor in
10031020 ;;
10041021
10051022 # 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+ ;;
10061028 dpx20-unknown | dpx20-bull)
10071029 cpu=rs6000
10081030 vendor=bull
@@ -1053,7 +1075,7 @@ case $cpu-$vendor in
10531075 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-* )
10541076 cpu=i586
10551077 ;;
1056- pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_ * -* )
1078+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_ * -* )
10571079 cpu=i686
10581080 ;;
10591081 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-* )
@@ -1084,7 +1106,7 @@ case $cpu-$vendor in
10841106 cpu=mipsisa64sb1el
10851107 ;;
10861108 sh5e[lb]-* )
1087- cpu=$( echo " $cpu " | sed ' s/^\(sh.\)e\(.\)$/\1\2e/' )
1109+ cpu=` echo " $cpu " | sed ' s/^\(sh.\)e\(.\)$/\1\2e/' `
10881110 ;;
10891111 spur-* )
10901112 cpu=spur
@@ -1102,9 +1124,9 @@ case $cpu-$vendor in
11021124 cpu=x86_64
11031125 ;;
11041126 xscale-* | xscalee[bl]-* )
1105- cpu=$( echo " $cpu " | sed ' s/^xscale/arm/' )
1127+ cpu=` echo " $cpu " | sed ' s/^xscale/arm/' `
11061128 ;;
1107- arm64-* )
1129+ arm64-* | aarch64le- * )
11081130 cpu=aarch64
11091131 ;;
11101132
@@ -1165,7 +1187,7 @@ case $cpu-$vendor in
11651187 | alphapca5[67] | alpha64pca5[67] \
11661188 | am33_2.0 \
11671189 | amdgcn \
1168- | arc | arceb | arc64 \
1190+ | arc | arceb | arc32 | arc64 \
11691191 | arm | arm[lb]e | arme[lb] | armv* \
11701192 | avr | avr32 \
11711193 | asmjs \
@@ -1185,7 +1207,7 @@ case $cpu-$vendor in
11851207 | k1om \
11861208 | le32 | le64 \
11871209 | lm32 \
1188- | loongarch32 | loongarch64 | loongarchx32 \
1210+ | loongarch32 | loongarch64 \
11891211 | m32c | m32r | m32rle \
11901212 | m5200 | m68000 | m680[012346]0 | m68360 | m683? 2 | m68k \
11911213 | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
@@ -1287,35 +1309,41 @@ esac
12871309if test x$basic_os ! = x
12881310then
12891311
1290- # First recognize some ad-hoc caes , or perhaps split kernel-os, or else just
1312+ # First recognize some ad-hoc cases , or perhaps split kernel-os, or else just
12911313# set os.
12921314case $basic_os in
12931315 gnu/linux* )
12941316 kernel=linux
1295- os=$( echo $basic_os | sed -e ' s|gnu/linux|gnu|' )
1317+ os=` echo " $basic_os " | sed -e ' s|gnu/linux|gnu|' `
12961318 ;;
12971319 os2-emx)
12981320 kernel=os2
1299- os=$( echo $basic_os | sed -e ' s|os2-emx|emx|' )
1321+ os=` echo " $basic_os " | sed -e ' s|os2-emx|emx|' `
13001322 ;;
13011323 nto-qnx* )
13021324 kernel=nto
1303- os=$( echo $basic_os | sed -e ' s|nto-qnx|qnx|' )
1325+ os=` echo " $basic_os " | sed -e ' s|nto-qnx|qnx|' `
13041326 ;;
13051327 * -* )
13061328 # shellcheck disable=SC2162
1329+ saved_IFS=$IFS
13071330 IFS=" -" read kernel os << EOF
13081331$basic_os
13091332EOF
1333+ IFS=$saved_IFS
13101334 ;;
13111335 # Default OS when just kernel was specified
13121336 nto* )
13131337 kernel=nto
1314- os=$( echo $basic_os | sed -e ' s|nto|qnx|' )
1338+ os=` echo " $basic_os " | sed -e ' s|nto|qnx|' `
13151339 ;;
13161340 linux* )
13171341 kernel=linux
1318- os=$( echo $basic_os | sed -e ' s|linux|gnu|' )
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|' `
13191347 ;;
13201348 * )
13211349 kernel=
@@ -1336,7 +1364,7 @@ case $os in
13361364 os=cnk
13371365 ;;
13381366 solaris1 | solaris1.* )
1339- os=$( echo $os | sed -e ' s|solaris1|sunos4|' )
1367+ os=` echo " $os " | sed -e ' s|solaris1|sunos4|' `
13401368 ;;
13411369 solaris)
13421370 os=solaris2
@@ -1365,7 +1393,7 @@ case $os in
13651393 os=sco3.2v4
13661394 ;;
13671395 sco3.2.[4-9]* )
1368- os=$( echo $os | sed -e ' s/sco3.2./sco3.2v/' )
1396+ os=` echo " $os " | sed -e ' s/sco3.2./sco3.2v/' `
13691397 ;;
13701398 sco* v* | scout)
13711399 # Don't match below
@@ -1395,7 +1423,7 @@ case $os in
13951423 os=lynxos
13961424 ;;
13971425 mac[0-9]* )
1398- os=$( echo " $os " | sed -e ' s|mac|macos|' )
1426+ os=` echo " $os " | sed -e ' s|mac|macos|' `
13991427 ;;
14001428 opened* )
14011429 os=openedition
@@ -1404,10 +1432,10 @@ case $os in
14041432 os=os400
14051433 ;;
14061434 sunos5* )
1407- os=$( echo " $os " | sed -e ' s|sunos5|solaris2|' )
1435+ os=` echo " $os " | sed -e ' s|sunos5|solaris2|' `
14081436 ;;
14091437 sunos6* )
1410- os=$( echo " $os " | sed -e ' s|sunos6|solaris3|' )
1438+ os=` echo " $os " | sed -e ' s|sunos6|solaris3|' `
14111439 ;;
14121440 wince* )
14131441 os=wince
@@ -1441,7 +1469,7 @@ case $os in
14411469 ;;
14421470 # Preserve the version number of sinix5.
14431471 sinix5.* )
1444- os=$( echo $os | sed -e ' s|sinix|sysv|' )
1472+ os=` echo " $os " | sed -e ' s|sinix|sysv|' `
14451473 ;;
14461474 sinix* )
14471475 os=sysv4
16881716# Now, validate our (potentially fixed-up) OS.
16891717case $os in
16901718 # Sometimes we do "kernel-libc", so those need to count as OSes.
1691- musl* | newlib* | uclibc* )
1719+ musl* | newlib* | relibc * | uclibc* )
16921720 ;;
16931721 # Likewise for "kernel-abi"
16941722 eabi* | gnueabi* )
@@ -1729,14 +1757,18 @@ case $os in
17291757 | skyos* | haiku* | rdos* | toppers* | drops* | es* \
17301758 | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
17311759 | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1732- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* )
1760+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
1761+ | fiwix* | mlibc* )
17331762 ;;
17341763 # This one is extra strict with allowed versions
17351764 sco3.2v2 | sco3.2v[4-9]* | sco5v6* )
17361765 # Don't forget version if it is 3.2v4 or newer.
17371766 ;;
17381767 none)
17391768 ;;
1769+ kernel* )
1770+ # Restricted further below
1771+ ;;
17401772 * )
17411773 echo Invalid configuration \` " $1 " \' : OS \` " $os " \' not recognized 1>&2
17421774 exit 1
@@ -1746,16 +1778,27 @@ esac
17461778# As a final step for OS-related things, validate the OS-kernel combination
17471779# (given a valid OS), if there is a kernel.
17481780case $kernel -$os in
1749- linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
1781+ linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
1782+ | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
17501783 ;;
17511784 uclinux-uclibc* )
17521785 ;;
1753- -dietlibc* | -newlib* | -musl* | -uclibc* )
1786+ managarm-mlibc* | managarm-kernel* )
1787+ ;;
1788+ -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
17541789 # These are just libc implementations, not actual OSes, and thus
17551790 # require a kernel.
17561791 echo " Invalid configuration \` $1 ': libc \` $os ' needs explicit kernel." 1>&2
17571792 exit 1
17581793 ;;
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+ ;;
17591802 kfreebsd* -gnu* | kopensolaris* -gnu* )
17601803 ;;
17611804 vxworks-simlinux | vxworks-simwindows | vxworks-spe)
0 commit comments