--- hints/darwin.sh.orig	2021-04-30 11:34:02.000000000 -0700
+++ hints/darwin.sh	2021-04-30 11:39:22.000000000 -0700
@@ -301,7 +301,7 @@
    # We now use MACOSX_DEPLOYMENT_TARGET, if set, as an override by
    # capturing its value and adding it to the flags.
     case "$MACOSX_DEPLOYMENT_TARGET" in
-    10.*)
+    [1-9][0-9].*)
       add_macosx_version_min ccflags $MACOSX_DEPLOYMENT_TARGET
       add_macosx_version_min ldflags $MACOSX_DEPLOYMENT_TARGET
       ;;
@@ -313,7 +313,7 @@
 
 *** Unexpected MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET
 ***
-*** Please either set it to 10.something, or to empty.
+*** Please either set it to a valid macOS version number (e.g., 10.15) or to empty.
 
 EOM
       exit 1
@@ -327,7 +327,7 @@
     # "ProductVersion:    10.11"     "10.11"
         prodvers=`sw_vers|awk '/^ProductVersion:/{print $2}'|awk -F. '{print $1"."$2}'`
     case "$prodvers" in
-    10.*)
+    [1-9][0-9].*)
       add_macosx_version_min ccflags $prodvers
       add_macosx_version_min ldflags $prodvers
       ;;
@@ -344,14 +344,20 @@
 
     # The X in 10.X
     prodvers_minor=$(echo $prodvers|awk -F. '{print $2}')
+    darwin_major=$(echo $osvers|awk -F. '{print $1}')
 
-    # macOS (10.12) deprecated syscall().
-    # but it's still available on both macOS 10.12 and 10.13
-    # for compatibility with perl5.24 allow syscall() configuration on Sierra and later
-    # will auto-configure without syscall() if and when it's actually removed
-    # if [ "$prodvers_minor" -ge 12 ]; then
-    #     d_syscall='undef'
-    # fi
+    # macOS 10.12 (darwin 16.0.0) deprecated syscall().
+    if [ "$darwin_major" -ge 16 ]; then
+        d_syscall='undef'
+        # If deploying to pre-10.12, suppress Time::HiRes's detection of the system clock_gettime()
+        case "$MACOSX_DEPLOYMENT_TARGET" in
+          10.[6-9]|10.10|10.11)
+          ccflags="$ccflags -Werror=partial-availability -D_DARWIN_FEATURE_CLOCK_GETTIME=0"
+          ;;
+        *)
+          ;;
+        esac
+    fi
 
    lddlflags="${ldflags} -bundle -undefined dynamic_lookup"
    ;;
