[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] Rewrite logic handling n `-`-separated components
From: |
John Ericson |
Subject: |
[PATCH 3/4] Rewrite logic handling n `-`-separated components |
Date: |
Sat, 21 Apr 2018 22:58:24 -0400 |
The old logic was a bit hard to follow due to lots of sed and
unintuitive collapsing of cases. The code now works like this
- 4 components is always parsed as
CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
- 2 components is always parsed as
CPU_TYPE-OPERATING_SYSTEM
- 1 component is always parsed as
CPU_TYPE
- 3 components is ambiguous and parsed as either
CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
CPU_TYPE-KERNEL-OPERATING_SYSTEM
The old code differed semantically in that
- The 4-case was awkwardly folded into the 3-case disambiguation
- The "android-linux" ad-hoc fixdup did something different in the
non-3 cases, but isn't intended to apply in those cases.
---
ChangeLog | 4 ++++
config.sub | 43 ++++++++++++++++++++++++++++---------------
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 600658c..5a9b2a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-04-24 John Ericson <address@hidden>
+
+ * config.sub: Properly recognise configs with 4 components.
+
2018-04-24 John Ericson <address@hidden>
* config.sub (arm6m, armv[78][arm]): Recognise.
diff --git a/config.sub b/config.sub
index 18d0465..b0d1a74 100755
--- a/config.sub
+++ b/config.sub
@@ -110,33 +110,46 @@ case $# in
exit 1;;
esac
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
+c1=`echo "$1" | sed 's/^\([^-]*\).*$/\1/'`
+c2=`echo "$1" | sed 's/^[^-]*-\([^-]*\).*$/\1/'`
+c3=`echo "$1" | sed 's/^[^-]*-[^-]*-\([^-]*\).*$/\1/'`
+c4=`echo "$1" | sed 's/^[^-]*-[^-]*-[^-]*-\([^-]*\).*$/\1/'`
+
+case $1 in
+ *-*-*-*)
+ basic_machine=$c1-$c2
+ os=-$c3-$c4
+ ;;
+ *-*-*)
+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
parts
+ maybe_os=$c2-$c3
+ case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib*
| \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* |
kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*)
+ basic_machine=$c1
os=-$maybe_os
- basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
+ basic_machine=$c1-unknown
os=-linux-android
- basic_machine=`echo "$1" | sed
's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
- basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
- case $1 in
- *-*)
- os=`echo "$1" | sed 's/.*-/-/'`
- ;;
- *)
- os=
- ;;
- esac
+ basic_machine=$c1-$c2
+ os=-$c3
;;
+ esac
+ ;;
+ *-*)
+ basic_machine=$c1
+ os=-$c2
+ ;;
+ *)
+ basic_machine=$1
+ os=
+ ;;
esac
### Let's recognize common machines as not being operating systems so
--
2.16.2