2 # Configuration validation subroutine script.
3 # Copyright 1992-2024 Free Software Foundation, Inc.
5 # shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
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.
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.
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/>.
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").
30 # Please send patches to <config-patches@gnu.org>.
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.
37 # You can get the latest version of this script from:
38 # https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
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
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.
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.
62 me
=`echo "$0" | sed -e 's,.*/,,'`
65 Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
67 Canonicalize a configuration name.
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
74 Report bugs and patches to <config-patches@gnu.org>."
77 GNU config.sub ($timestamp)
79 Copyright 1992-2024 Free Software Foundation, Inc.
81 This is free software; see the source for copying conditions. There is NO
82 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
85 Try '$me --help' for more information."
88 while test $# -gt 0 ; do
90 --time-stamp |
--time* |
-t )
91 echo "$timestamp" ; exit ;;
93 echo "$version" ; exit ;;
95 echo "$usage"; exit ;;
96 -- ) # Stop option processing
98 - ) # Use stdin as input.
101 echo "$me: invalid option $1$help" >&2
105 # First pass through any local machine types.
115 0) echo "$me: missing argument$help" >&2
118 *) echo "$me: too many arguments$help" >&2
122 # Split fields of configuration type
124 IFS
="-" read field1 field2 field3 field4
<<EOF
129 # Separate into logical components for further validation
132 echo "Invalid configuration '$1': more than four components" >&2
136 basic_machine
=$field1-$field2
137 basic_os
=$field3-$field4
140 # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
142 maybe_os
=$field2-$field3
147 | kopensolaris
*-gnu* \
159 basic_machine
=$field1
163 basic_machine
=$field1-unknown
164 basic_os
=linux-android
167 basic_machine
=$field1-$field2
173 case $field1-$field2 in
174 # Shorthands that happen to contain a single dash
175 convex-c
[12] | convex-c3
[248])
176 basic_machine
=$field2-convex
180 basic_machine
=mips-dec
184 # Second component is usually, but not always the OS
186 # Do not treat sunos as a manufacturer
188 basic_machine
=$field1
261 basic_machine
=$field1-$field2
265 basic_machine
=$field1-unknown
269 basic_machine
=$field1
277 # Convert single-component short-hands not valid as part of
278 # multi-component configurations.
281 basic_machine
=i386-pc
285 basic_machine
=a29k-amd
289 basic_machine
=m68010-adobe
293 basic_machine
=fx80-alliant
297 basic_machine
=m68k-altos
301 basic_machine
=a29k-none
305 basic_machine
=580-amdahl
309 basic_machine
=m68k-unknown
313 basic_machine
=m68k-unknown
317 basic_machine
=m68k-unknown
321 basic_machine
=m68k-apollo
325 basic_machine
=m68k-apollo
329 basic_machine
=i386-pc
333 basic_machine
=m68k-apple
337 basic_machine
=ns32k-sequent
341 basic_machine
=bfin-unknown
345 basic_machine
=arm-unknown
349 basic_machine
=j90-cray
353 basic_machine
=m68k-crds
357 basic_machine
=m68k-da30
360 decstation | pmax | pmin | dec3100 | decstatn
)
361 basic_machine
=mips-dec
365 basic_machine
=m88k-motorola
369 basic_machine
=i686-pc
373 basic_machine
=i586-pc
377 basic_machine
=a29k-amd
380 es1800 | OSE68k | ose68k | ose | OSE
)
381 basic_machine
=m68k-ericsson
385 basic_machine
=tron-gmicro
389 basic_machine
=i386-pc
393 basic_machine
=h8300-hitachi
397 basic_machine
=h8300-hitachi
401 basic_machine
=h8500-hitachi
405 basic_machine
=m88k-harris
409 basic_machine
=m68k-hp
413 basic_machine
=m68k-hp
417 basic_machine
=hppa1.1
-hp
421 basic_machine
=hppa1.1
-hp
425 basic_machine
=i386-mach
429 basic_machine
=m68k-isi
433 basic_machine
=m68k-unknown
437 basic_machine
=mips-mips
441 basic_machine
=ns32k-utek
445 basic_machine
=x86_64-pc
449 basic_machine
=i686-pc
453 basic_machine
=arm-unknown
457 basic_machine
=m68k-rom68k
461 basic_machine
=powerpc-unknown
465 basic_machine
=moxie-unknown
469 basic_machine
=i386-pc
473 basic_machine
=i686-pc
477 basic_machine
=i370-ibm
481 basic_machine
=le32-unknown
485 basic_machine
=i486-ncr
489 basic_machine
=i386-pc
493 basic_machine
=armv4l-rebel
496 news | news700 | news800 | news900
)
497 basic_machine
=m68k-sony
501 basic_machine
=m68030-sony
505 basic_machine
=v70-nec
509 basic_machine
=m68k-harris
513 basic_machine
=m88k-harris
517 basic_machine
=i960-intel
521 basic_machine
=i960-intel
525 basic_machine
=mips-compaq
529 basic_machine
=powerpc-ibm
533 basic_machine
=m68000-ericsson
537 basic_machine
=m68k-none
541 basic_machine
=i860-intel
545 basic_machine
=hppa-unknown
549 basic_machine
=mipsallegrexel-sony
553 basic_machine
=i586-unknown
557 basic_machine
=x86_64-pc
561 basic_machine
=i386-pc
565 basic_machine
=m68k-rom68k
569 basic_machine
=a29k-amd
573 basic_machine
=mips-sei
577 basic_machine
=i386-sequent
581 basic_machine
=m68k-bull
585 basic_machine
=m68k-tandem
589 basic_machine
=i860-stratus
593 basic_machine
=m68000-sun
597 basic_machine
=m68000-sun
601 basic_machine
=m68000-sun
605 basic_machine
=m68k-sun
609 basic_machine
=m68k-sun
613 basic_machine
=m68k-sun
617 basic_machine
=sparc-sun
621 basic_machine
=sparc-sun
625 basic_machine
=sparc-sun
629 basic_machine
=sparc-sun
632 sun386 | sun386i | roadrunner
)
633 basic_machine
=i386-sun
637 basic_machine
=sv1-cray
641 basic_machine
=i386-sequent
645 basic_machine
=alphaev5-cray
649 basic_machine
=t90-cray
653 basic_machine
=pdp10-xkl
657 basic_machine
=s390x-ibm
661 basic_machine
=a29k-amd
665 basic_machine
=a29k-nyu
669 basic_machine
=v810-nec
673 basic_machine
=vax-dec
677 basic_machine
=vax-dec
681 basic_machine
=i386-pc
685 basic_machine
=i960-wrs
689 basic_machine
=m68k-wrs
693 basic_machine
=a29k-wrs
697 basic_machine
=i686-pc
701 basic_machine
=ymp-cray
712 # Decode 1-component or ad-hoc basic machines
713 case $basic_machine in
714 # Here we handle the default manufacturer of certain CPU types. It is in
715 # some cases the only manufacturer, in others, it is the most popular.
745 # Recognize the various machine names and aliases which stand
746 # for a CPU type and a company and sometimes even an OS.
747 3b1 |
7300 |
7300-att | att-7300 | pc7300 | safari | unixpc
)
760 decsystem10
* | dec10
*)
765 decsystem20
* | dec20
*)
770 delta |
3300 | delta-motorola |
3300-motorola | motorola-delta | motorola-3300
)
774 # This used to be dpx2*, but that gets the RS6000-based
775 # DPX/20 and the x86-based DPX/2-100 wrong. See
776 # https://oldskool.silicium.org/stations/bull_dpx20.htm
777 # https://www.feb-patrimoine.com/english/bull_dpx2.htm
778 # https://www.feb-patrimoine.com/english/unix_and_bull.htm
779 dpx2 | dpx2
[23]00 | dpx2
[23]xx
)
791 encore | umax | mmax
)
798 basic_os
=${basic_os:-bsd}
813 hp3k9
[0-9][0-9] | hp9
[0-9][0-9])
817 hp9k2
[0-9][0-9] | hp9k31
[0-9])
825 hp9k6
[0-9][0-9] | hp6
[0-9][0-9])
829 hp9k7
[0-79][0-9] | hp7
[0-79][0-9])
833 hp9k78
[0-9] | hp78
[0-9])
834 # FIXME: really hppa2.0-hp
838 hp9k8
[67]1 | hp8
[67]1 | hp9k80
[24] | hp80
[24] | hp9k8
[78]9 | hp8
[78]9 | hp9k893 | hp893
)
839 # FIXME: really hppa2.0-hp
843 hp9k8
[0-9][13679] | hp8
[0-9][13679])
847 hp9k8
[0-9][0-9] | hp8
[0-9][0-9])
852 cpu
=`echo "$1" | sed -e 's/86.*/86/'`
857 cpu
=`echo "$1" | sed -e 's/86.*/86/'`
862 cpu
=`echo "$1" | sed -e 's/86.*/86/'`
867 cpu
=`echo "$1" | sed -e 's/86.*/86/'`
874 basic_os
=${basic_os:-unicos}
891 *mint | mint
[0-9]* |
*MiNT |
*MiNT
[0-9]*)
896 news-3600 | risc-news
)
954 basic_os
=${basic_os:-elf}
984 vendor
=$basic_machine
988 vendor
=`echo "$basic_machine" | sed 's/-.*//'`
993 IFS
="-" read cpu vendor
<<EOF
998 # We use 'pc' rather than 'unknown'
999 # because (1) that's what they normally are, and
1000 # (2) the word "unknown" tends to confuse beginning users.
1005 # These rules are duplicated from below for sake of the special case above;
1006 # i.e. things that normalized to x86 arches should also default to "pc"
1015 # Recognize the basic CPU types without company name.
1022 unset -v basic_machine
1024 # Decode basic machines in the full and proper CPU-Company form.
1025 case $cpu-$vendor in
1026 # Here we handle the default manufacturer of certain CPU types in canonical form.
1027 # It is in some cases the only manufacturer, in others, it is the most popular.
1028 c
[12]-convex | c
[12]-unknown | c3
[248]-convex | c3
[248]-unknown)
1030 basic_os
=${basic_os:-bsd}
1034 basic_os
=${basic_os:-unicosmp}
1036 c90-unknown | c90-cray
)
1038 basic_os
=${basic_os:-unicos}
1049 microblaze-unknown | microblazeel-unknown
)
1073 xps-unknown | xps100-unknown
)
1078 # Here we normalize CPU types with a missing or matching vendor
1079 armh-unknown | armh-alt
)
1082 basic_os
=${basic_os:-linux-gnueabihf}
1085 # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
1087 basic_os
=${basic_os:-sysv}
1090 basic_os
=${basic_os:-newsos}
1093 basic_os
=${basic_os:-bsd}
1096 basic_os
=${basic_os:-sysv3}
1098 i386-bull | m68k-bull
)
1099 basic_os
=${basic_os:-sysv3}
1102 basic_os
=${basic_os:-bosx}
1105 basic_os
=${basic_os:-sysv4}
1108 # Here we normalize CPU types irrespective of the vendor
1114 basic_os
=${basic_os:-linux}
1127 basic_os
=${basic_os}"spe"
1137 basic_os
=${basic_os:-linux}
1139 m9s12z-
* | m68hcs12z-
* | hcs12z-
* | s12z-
*)
1147 basic_os
=${basic_os:-linux}
1149 pentium-
* | p5-
* | k5-
* | k6-
* | nexgen-
* | viac3-
*)
1152 pentiumpro-
* | p6-
* |
6x86-
* | athlon-
* | athlon_
*-*)
1155 pentiumii-
* | pentium2-
* | pentiumiii-
* | pentium3-
*)
1164 ppcle-
* | powerpclittle-
*)
1170 ppc64le-
* | powerpc64little-
*)
1180 cpu
=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1185 strongarm-
* | thumb-
*)
1194 xscale-
* | xscalee
[bl
]-*)
1195 cpu
=`echo "$cpu" | sed 's/^xscale/arm/'`
1197 arm64-
* | aarch64le-
*)
1201 # Recognize the canonical CPU Types that limit and/or modify the
1202 # company names they are paired with.
1204 basic_os
=${basic_os:-elf}
1206 crisv32-
* | etraxfs
*-*)
1215 basic_os
=${basic_os:-elf}
1237 mipsallegrexel-sony
)
1242 basic_os
=${basic_os:-linux-gnu}
1246 # Recognize the canonical CPU types that are allowed with any
1473 echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1480 # Here we canonicalize certain aliases for manufacturers.
1492 # Decode manufacturer-specific aliases for certain operating systems.
1494 if test x
"$basic_os" != x
1497 # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1503 os
=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1507 os
=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1511 os
=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1515 IFS
="-" read kernel os
<<EOF
1520 # Default OS when just kernel was specified
1523 os
=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1527 os
=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1531 os
=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1539 # Now, normalize the OS (knowing we just have one component, it's not a kernel,
1542 # First match some system type aliases that might get confused
1543 # with valid system types.
1544 # solaris* is a basic system type, with this one exception.
1551 solaris1 | solaris1.
*)
1552 os
=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1560 # The marketing names for NeXT's operating systems were
1561 # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
1562 # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
1563 # mapped to 'nextstep' and 'nextstep2', consistent with the
1564 # treatment of SunOS/Solaris.
1565 ns | ns1 | nextstep | nextstep1 | openstep1
)
1568 ns2 | nextstep2 | openstep2
)
1571 ns3 | nextstep3 | openstep | openstep3
)
1574 ns4 | nextstep4 | openstep4
)
1577 # es1800 is here to avoid being matched by es* (a different OS)
1581 # Some version numbers need modification
1598 os
=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1622 # don't get caught up in next wildcard
1628 os
=`echo "$os" | sed -e 's|mac|macos|'`
1637 os
=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1640 os
=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1647 vendor
=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
1666 vendor
=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
1675 # Preserve the version number of sinix5.
1677 os
=`echo "$os" | sed -e 's|sinix|sysv|'`
1678 vendor
=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1682 vendor
=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1705 *mint | mint
[0-9]* |
*MiNT | MiNT
[0-9]*)
1712 # Until real need of OS specific support for
1713 # particular features comes up, bare metal
1714 # configurations are quite functional.
1725 aout
* | coff
* | elf
* | pe
*)
1726 # These are machine code file formats, not OSes
1731 # No normalization, but not necessarily accepted, that comes below.
1737 # Here we handle the default operating systems that come with various machines.
1738 # The value should be what the vendor currently ships out the door with their
1739 # machine or put another way, the most popular os provided with the machine.
1741 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1742 # "-sun"), then you have to tell the case statement up towards the top
1743 # that MANUFACTURER isn't an operating system. Otherwise, code above
1744 # will signal an error saying that MANUFACTURER isn't an operating
1745 # system, and we'll never get to this point.
1749 case $cpu-$vendor in
1796 # This must come before the *-dec entry.
1823 # The -sgi and -siemens entries must be before the mips- entry
1824 # or we get the wrong os.
1835 mips
*-*|nanomips
*-*)
1843 # This must be before the sparc-* entry or we get the wrong os.
1878 i860-
* |
*-att |
*-ncr |
*-altos |
*-motorola |
*-convergent)
1923 f30
[01]-fujitsu | f700-fujitsu
)
1950 # Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
1953 # Sometimes we do "kernel-libc", so those need to count as OSes.
1954 llvm
* | musl
* | newlib
* | relibc
* | uclibc
*)
1956 # Likewise for "kernel-abi"
1959 # VxWorks passes extra cpu info in the 4th filed.
1960 simlinux | simwindows | spe
)
1962 # See `case $cpu-$os` validation below
1965 # Now accept the basic system types.
1966 # Each alternative MUST end in a * to match a version number.
2154 # This one is extra strict with allowed versions
2155 sco3.2v2 | sco3.2v
[4-9]* | sco5v6
*)
2156 # Don't forget version if it is 3.2v4 or newer.
2158 # This refers to builds using the UEFI calling convention
2159 # (which depends on the architecture) and PE file format.
2160 # Note that this is both a different calling convention and
2161 # different file format than that of GNU-EFI
2162 # (x86_64-w64-mingw32).
2168 # Restricted further below
2173 echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
2177 echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
2183 aout
* | coff
* | elf
* | pe
*)
2189 echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
2194 # Here we handle the constraint that a (synthetic) cpu and os are
2195 # valid only in combination with each other and nowhere else.
2197 # The "javascript-unknown-ghcjs" triple is used by GHC; we
2198 # accept it here in order to tolerate that, but reject any
2202 javascript-
* |
*-ghcjs)
2203 echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
2208 # As a final step for OS-related things, validate the OS-kernel combination
2209 # (given a valid OS), if there is a kernel.
2210 case $kernel-$os-$obj in
2211 linux-gnu
*- | linux-android
*- | linux-dietlibc
*- | linux-llvm
*- \
2212 | linux-mlibc
*- | linux-musl
*- | linux-newlib
*- \
2213 | linux-relibc
*- | linux-uclibc
*- | linux-ohos
*- )
2215 uclinux-uclibc
*- | uclinux-gnu
*- )
2217 managarm-mlibc
*- | managarm-kernel
*- )
2221 -dietlibc*- |
-llvm*- |
-mlibc*- |
-musl*- |
-newlib*- |
-relibc*- \
2223 # These are just libc implementations, not actual OSes, and thus
2225 echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
2229 echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
2233 echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
2237 echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
2240 kfreebsd
*-gnu*- | knetbsd
*-gnu*- | netbsd
*-gnu*- | kopensolaris
*-gnu*-)
2242 vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-
)
2250 *-eabi*- |
*-gnueabi*-)
2253 # None (no kernel, i.e. freestanding / bare metal),
2254 # can be paired with an machine code file format
2257 # Blank kernel with real OS is always fine.
2260 # Blank kernel and OS with real machine code file format is always fine.
2263 echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
2268 # Here we handle the case where we know the os, and the CPU type, but not the
2269 # manufacturer. We pick the logical manufacturer.
2276 *-sunos* |
*-solaris*)
2324 *-vxsim* |
*-vxworks* |
*-windiss*)
2336 *-*mint |
*-mint[0-9]* |
*-*MiNT |
*-MiNT[0-9]*)
2346 echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
2350 # eval: (add-hook 'before-save-hook 'time-stamp)
2351 # time-stamp-start: "timestamp='"
2352 # time-stamp-format: "%:y-%02m-%02d"
2353 # time-stamp-end: "'"