[m-rev.] for review: Use value of MACOSX_DEPLOYMENT_TARGET by default.

Peter Wang novalazy at gmail.com
Tue Nov 29 11:08:22 AEDT 2022


I haven't tested this.

---

On MacOS, make configure use the value of MACOSX_DEPLOYMENT_TARGET as
the default deployment target (if set), otherwise falling back to the
host system version.

configure.ac:
    As above.

README.MacOS:
NEWS:
    Document the change.

diff --git a/NEWS b/NEWS
index d5b72245e..19ce26872 100644
--- a/NEWS
+++ b/NEWS
@@ -752,6 +752,10 @@ Changes to the Mercury compiler
   batch files generated by the compiler when creating executables in the `java`
   grade.
 
+* On MacOS systems, the configure script now uses the value of the
+  `MACOSX_DEPLOYMENT_TARGET` environment variable as the default value for the
+  deployment target, if set.
+
 Changes to the Mercury debugger
 -------------------------------
 
diff --git a/README.MacOS b/README.MacOS
index f3e080605..4744f8b25 100644
--- a/README.MacOS
+++ b/README.MacOS
@@ -60,7 +60,7 @@ that *cannot* be used to compile Mercury.  The `configure` script will print
 a warning if it detects that you are using the broken version.
 
 A discussion of this issue can be found at
-<https://forums.developer.apple.com/thread/121887>.    
+<https://forums.developer.apple.com/thread/121887>.
 The github post
 <https://github.com/Mercury-Language/mercury/issues/88#issuecomment-624329679>
 describes a way that has been found to fix the problem.
@@ -69,9 +69,9 @@ Deployment Target Settings
 --------------------------
 
 By default, the Mercury compiler is configured so that the Mac OS X deployment
-target (i.e. the value of the `MACOSX_DEPLOYMENT_TARGET` environment variable)
-for code generated by the Mercury compiler is set to the same version as that
-of the host system.
+target for code generated by the Mercury compiler is set the value of the
+`MACOSX_DEPLOYMENT_TARGET` environment variable (if set), or else to the
+MacOS version of the host system.
 
 You can specify a different deployment target at configuration time using
 the `configure` script's `--with-macosx-deployment-target` option.
diff --git a/configure.ac b/configure.ac
index 57ac49c0f..0ac0ef701 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4087,13 +4087,17 @@ DEPLOYMENT_TARGET="no"
 case "$host" in
     *apple*darwin*)
         case "$mercury_cv_macosx_deployment_target" in
-            # NOTE: the sw_vers utility tells us which version of Mac OS X
-            # we are using as opposed to which version of Darwin we are using.
-            # uname only reports the latter.
             auto)
-                DEPLOYMENT_TARGET=`sw_vers -productVersion | cut -d \. -f 1 -f 2`
+                if test -n "${MACOSX_DEPLOYMENT_TARGET:-}"
+                then
+                    DEPLOYMENT_TARGET="$MACOSX_DEPLOYMENT_TARGET"
+                else
+                    # NOTE: the sw_vers utility tells us which version of
+                    # Mac OS X we are using as opposed to which version of
+                    # Darwin we are using. uname only reports the latter.
+                    DEPLOYMENT_TARGET=`sw_vers -productVersion | cut -d \. -f 1 -f 2`
+                fi
                 ;;
-
             *)
                 DEPLOYMENT_TARGET="$mercury_cv_macosx_deployment_target"
                 ;;
-- 
2.38.0



More information about the reviews mailing list