pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Mon Sep 12 12:32:31 UTC 2022

Modified Files:
        pkgsrc/bootstrap: README.macOS bootstrap
        pkgsrc/mk/platform: Darwin.mk

Log Message:
macOS: Support MACOSX_DEPLOYMENT_TARGET.

This allows the user to specify an exact SDK to use, and can be used to build
packages for an older release of macOS than the host.  The user should ideally
set this via environment variable at bootstrap time, and pkgsrc will then
encode that into mk.conf and use it for all builds.

Tested on macOS 12.x building against an 11.3 SDK for both arm64 and x86_64.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 pkgsrc/bootstrap/README.macOS
cvs rdiff -u -r1.313 -r1.314 pkgsrc/bootstrap/bootstrap
cvs rdiff -u -r1.115 -r1.116 pkgsrc/mk/platform/Darwin.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/bootstrap/README.macOS
diff -u pkgsrc/bootstrap/README.macOS:1.9 pkgsrc/bootstrap/README.macOS:1.10
--- pkgsrc/bootstrap/README.macOS:1.9   Mon Aug  1 14:49:09 2022
+++ pkgsrc/bootstrap/README.macOS       Mon Sep 12 12:32:30 2022
@@ -1,4 +1,4 @@
-$NetBSD: README.macOS,v 1.9 2022/08/01 14:49:09 jperkin Exp $
+$NetBSD: README.macOS,v 1.10 2022/09/12 12:32:30 jperkin Exp $
 
 Please read the general README file as well.
 
@@ -36,6 +36,11 @@ see "No suitable Xcode SDK or Command Li
 usually means a pkgsrc developer needs to add another `OSX_SDK_MAP`
 entry to `mk/platform/Darwin.mk`.
 
+If you wish to build for a specific SDK, first ensure is is available in the
+correct location, and then you can set the regular MACOSX_DEPLOYMENT_TARGET
+variable during bootstrap and pkgsrc will ensure that SDK is used for both
+the bootstrap build as well as all packages built by those tools.
+
 -----
 
 Additional historical details, likely useful with older systems:

Index: pkgsrc/bootstrap/bootstrap
diff -u pkgsrc/bootstrap/bootstrap:1.313 pkgsrc/bootstrap/bootstrap:1.314
--- pkgsrc/bootstrap/bootstrap:1.313    Fri Sep  9 10:58:15 2022
+++ pkgsrc/bootstrap/bootstrap  Mon Sep 12 12:32:30 2022
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: bootstrap,v 1.313 2022/09/09 10:58:15 jperkin Exp $
+# $NetBSD: bootstrap,v 1.314 2022/09/12 12:32:30 jperkin Exp $
 #
 # Copyright (c) 2001-2011 Alistair Crooks <agc%NetBSD.org@localhost>
 # All rights reserved.
@@ -589,6 +589,14 @@ Darwin)
        machine_arch=`get_machine_arch_darwin`
        check_compiler=yes
 
+       if [ -n "${MACOSX_DEPLOYMENT_TARGET}" ]; then
+               SDK_PATH=`/usr/bin/xcrun \
+                       --sdk macosx${MACOSX_DEPLOYMENT_TARGET} \
+                       --show-sdk-path 2>/dev/null || echo /nonexistent`
+               CFLAGS="-isysroot ${SDK_PATH} ${CFLAGS}"
+               export CFLAGS
+       fi
+
        # Combine major.minor product version for simpler numerical tests.
        macos_version=`sw_vers -productVersion | \
            awk -F. '{ printf("%02d%02d", $1, $2) }'`
@@ -1393,6 +1401,10 @@ fi
 if test -n "$LIBS"; then
        echo "LIBS+=            $LIBS" >> ${TARGET_MKCONF}
 fi
+if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
+       echo "MACOSX_DEPLOYMENT_TARGET= $MACOSX_DEPLOYMENT_TARGET" >>${TARGET_MKCONF}
+       echo "MACOSX_DEPLOYMENT_TARGET= $MACOSX_DEPLOYMENT_TARGET" >>${BOOTSTRAP_MKCONF}
+fi
 
 # opsys specific fiddling
 opsys_finish

Index: pkgsrc/mk/platform/Darwin.mk
diff -u pkgsrc/mk/platform/Darwin.mk:1.115 pkgsrc/mk/platform/Darwin.mk:1.116
--- pkgsrc/mk/platform/Darwin.mk:1.115  Fri Jul 22 00:53:58 2022
+++ pkgsrc/mk/platform/Darwin.mk        Mon Sep 12 12:32:31 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Darwin.mk,v 1.115 2022/07/22 00:53:58 schmonz Exp $
+# $NetBSD: Darwin.mk,v 1.116 2022/09/12 12:32:31 jperkin Exp $
 #
 # Variable definitions for the Darwin operating system.
 
@@ -101,13 +101,6 @@ MAKEFLAGS+=                OSX_VERSION=${OSX_VERSION:Q
 # into /usr/include, so we need to query their location if /usr/include is
 # not available.
 #
-# Use current system version SDK (avoid newer SDKs).
-#
-.if exists(/usr/include/stdio.h)
-_OPSYS_INCLUDE_DIRS?=  /usr/include
-.elif exists(/usr/bin/xcrun)
-.  if !defined(OSX_SDK_PATH)
-#
 # Apple do not always keep the SDK version in step with the OS version.  When
 # that happens add a mapping below, but only within the same OS release major.
 #
@@ -119,6 +112,25 @@ OSX_SDK_MAP.12.2=  12.1
 OSX_SDK_MAP.12.4=      12.3
 OSX_SDK_MAP.12.5=      12.3
 #
+# If the user has set MACOSX_DEPLOYMENT_TARGET (ideally at bootstrap time) to
+# select a specific SDK then we prefer that.
+#
+.if defined(MACOSX_DEPLOYMENT_TARGET)
+.  if !defined(OSX_SDK_PATH)
+OSX_SDK_PATH!= /usr/bin/xcrun --sdk macosx${MACOSX_DEPLOYMENT_TARGET} \
+                   --show-sdk-path 2>/dev/null || echo /nonexistent
+.  endif
+ALL_ENV+=              MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
+MAKEFLAGS+=            OSX_SDK_PATH=${OSX_SDK_PATH:Q}
+_OPSYS_INCLUDE_DIRS?=  ${OSX_SDK_PATH}/usr/include
+CWRAPPERS_APPEND.cc+=  -isysroot ${OSX_SDK_PATH}
+CWRAPPERS_APPEND.cxx+= -isysroot ${OSX_SDK_PATH}
+_WRAP_EXTRA_ARGS.CC+=  -isysroot ${OSX_SDK_PATH}
+_WRAP_EXTRA_ARGS.CXX+= -isysroot ${OSX_SDK_PATH}
+.elif exists(/usr/include/stdio.h)
+_OPSYS_INCLUDE_DIRS?=  /usr/include
+.elif exists(/usr/bin/xcrun)
+.  if !defined(OSX_SDK_PATH)
 OSX_SDK_PATH!= /usr/bin/xcrun \
                    --sdk macosx${OSX_SDK_MAP.${OSX_VERSION}:U${OSX_VERSION}} \
                    --show-sdk-path 2>/dev/null || echo /nonexistent



Home | Main Index | Thread Index | Old Index