aboutsummaryrefslogtreecommitdiffstats
path: root/tools/macos-setup.sh
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2020-11-25 18:23:06 -0800
committerGuy Harris <gharris@sonic.net>2020-11-25 18:23:28 -0800
commit8e2815bfc0aa08a5e9ab83de8b8b2ed56e698cf9 (patch)
tree980bdb549c2a9a9f84393207297d6cdcce24e5f9 /tools/macos-setup.sh
parentde99214e431bc693034253654665d6d1a9b829dd (diff)
Don't assume macOS version numbers are of the form 10.N.
Big Sur goes to 11, and it appears that next year's (San Juan Capistrano?) will go to 12, and so on. Split version numbers into major and minor, and do version-number comparison (alas, whilst CMake has that built in, the Bourne shell doesn't, and neither does the Bourne-again shell). This should fix issue #17043.
Diffstat (limited to 'tools/macos-setup.sh')
-rwxr-xr-xtools/macos-setup.sh42
1 files changed, 35 insertions, 7 deletions
diff --git a/tools/macos-setup.sh b/tools/macos-setup.sh
index cc8183c646..c832b40618 100755
--- a/tools/macos-setup.sh
+++ b/tools/macos-setup.sh
@@ -2809,9 +2809,33 @@ fi
if [ ! -z "$min_osx_target" ]
then
#
- # Get the real version - strip off the "10.".
+ # Get the major and minor version of the target release.
+ # We assume it'll be a while before there's a macOS 100. :-)
#
- deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
+ case "$min_osx_target" in
+
+ [1-9][0-9].*)
+ #
+ # major.minor.
+ #
+ min_osx_target_major=`echo "$min_osx_target" | sed -n 's/\([1-9][0-9]*\)\..*/\1/p'`
+ min_osx_target_minor=`echo "$min_osx_target" | sed -n 's/[1-9][0-9]*\.\(.*\)/\1/p'`
+ ;;
+
+ [1-9][0-9])
+ #
+ # Just a major version number was specified; make the minor
+ # version 0.
+ #
+ min_osx_target_major="$min_osx_target"
+ min_osx_target_minor=0
+ ;;
+
+ *)
+ echo "macosx-setup.sh: Invalid target release $min_osx_target" 1>&2
+ exit 1
+ ;;
+ esac
#
# Search each directory that might contain SDKs.
@@ -2835,20 +2859,24 @@ then
#
# Get a list of all the SDKs in that directory, if any.
+ # We assume it'll be a while before there's a macOS 100. :-)
#
- sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
+ sdklist=`(cd "$sdksdir"; ls -d MacOSX[1-9][0-9].[0-9]*.sdk 2>/dev/null)`
for sdk in $sdklist
do
#
- # Get the real version for this SDK.
+ # Get the major and minor version for this SDK.
#
- sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
+ sdk_major=`echo "$sdk" | sed -n 's/MacOSX\([1-9][0-9]*\)\..*\.sdk/\1/p'`
+ sdk_minor=`echo "$sdk" | sed -n 's/MacOSX[1-9][0-9]*\.\(.*\)\.sdk/\1/p'`
#
# Is it for the deployment target or some later release?
#
- if test "$sdk_real_version" -ge "$deploy_real_version"
+ if test "$sdk_major" -gt "$min_osx_target_major" -o \
+ \( "$sdk_major" -eq "$min_osx_target_major" -a \
+ "$sdk_minor" -ge "$min_osx_target_minor" \)
then
#
# Yes, use it.
@@ -2866,7 +2894,7 @@ then
fi
SDKPATH="$sdkpath"
- echo "Using the 10.$sdk_real_version SDK"
+ echo "Using the $sdk_major.$sdk_minor SDK"
#
# Make sure there are links to /usr/local/include and /usr/local/lib