<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.

</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/9ac63a30a2e316c766cf05f82babccd066866996">https://github.com/macports/macports-legacy-support/commit/9ac63a30a2e316c766cf05f82babccd066866996</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 9ac63a30a2e316c766cf05f82babccd066866996
</span>Author: Fred Wright <fw@fwright.net>
AuthorDate: Sat Jul 6 15:31:15 2024 -0700

<span style='display:block; white-space:pre;color:#404040;'>    sdkversion.h: Make ...MIN_REQUIRED hack optional.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    This makes the hack to handle "earlier" SDKs conditional on providing
</span><span style='display:block; white-space:pre;color:#404040;'>    MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED to specify the earliest such
</span><span style='display:block; white-space:pre;color:#404040;'>    SDK supported.  See the comments for more details.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Also adds code to ensure that the required version macros are defined
</span><span style='display:block; white-space:pre;color:#404040;'>    in 11.x+ SDKs, even with _POSIX_C_SOURCE defined.  See the comments
</span><span style='display:block; white-space:pre;color:#404040;'>    for more details.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Also adds another if/elif entry for the upcoming OS/SDK version.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    TESTED:
</span><span style='display:block; white-space:pre;color:#404040;'>    Builds and passes tests on all platforms, including allowable "later"
</span><span style='display:block; white-space:pre;color:#404040;'>    mismatched SDK cases.  The checksdkversion test passes in both
</span><span style='display:block; white-space:pre;color:#404040;'>    "earlier" and "later" cases, with "earlier" only being recognized when
</span><span style='display:block; white-space:pre;color:#404040;'>    allowed by the new option.
</span>---
 include/_macports_extras/sdkversion.h | 68 +++++++++++++++++++++++++++++------
 1 file changed, 58 insertions(+), 10 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/_macports_extras/sdkversion.h b/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;color:#808080;'>index ac765c6..2a45ade 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/_macports_extras/sdkversion.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -41,6 +41,15 @@
</span>  * 10.4, we just assume 10.4 in that case, rather than the more elaborate
  * logic in AvailabilityMacros.h that assumes 10.1 on ppc.
  *
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Also note that the fake ...MIN_REQUIRED will result in some of the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * availability macros being defined incorrectly for the actual target OS,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * but since the purpose of this package is to override Apple's notion of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * availability, that isn't necessarily inappropriate.  Nevertheless,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * we make accommodating "earlier" SDKs optional, by using the parameter
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED to specify the earliest "earlier"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SDK supported.  If this isn't both defined and earlier than the target OS,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * then the hack is disabled.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span>  * There's an additional complication if ...MAX_ALLOWED is already defined
  * initially.  That means that either it was explicitly defined in some
  * fashion, or AvailabilityMacros.h was already included before.  In this
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -50,8 +59,14 @@
</span>  * THUS: If supporting the "older SDK" case is important, this header should
  * be included before anything that might include AvailabilityMacros.h.
  *
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * In the non-Apple case, we avoid AvailabilityMacros.h, and just define our
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * flags for the "minimally hackish" case.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * A further complication is that ...MAX_ALLOWED is normally defined as
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * one of the MAC_OS_X_VERSION... macros, but those definitions may be
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * suppressed in some configurations in 11.x+ SDKs.  In such cases it's
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * impossible to detect the correct SDK version, with or without the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * "earlier SDK" hack.  To suppress that behavior, we define _DARWIN_C_SOURCE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * before #including AvailabilityMacros.h, and restore its definedness
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * afterward.  That may result in a small amount of additional namespace
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * pollution, but no worse than is always the case with pre-11.x SDKs.
</span>  *
  * It would be maximally flexible if we could directly derive an SDK version
  * parameter from the "honest" ...MAX_ALLOWED, but cpp has no way to do that
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -64,29 +79,58 @@
</span>  * NOTE: Some "mismatched SDK" configurations may produce compiler warnings.
  * These are not the fault of this header, and usually aren't fatal unless
  * treated as errors.
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * In the non-Apple case, we avoid AvailabilityMacros.h, and just define our
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * flags for the "minimally hackish" case.
</span>  */
 
 #if __APPLE__
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* First obtain MAC_OS_X_VERSION_MAX_ALLOWED, possibly unforced */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* First set up the condition for applying the "earlier SDK" hack. */
</span> 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef __MPLS_NEED_MIN_REQUIRED_FIXUP
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_MIN_SDK_ALLOWED 999999
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Minimum allowable value is 1000 (10.0) */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED < 1000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_MIN_SDK_ALLOWED 1000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_MIN_SDK_ALLOWED MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* MACPORTS_LEGACY_MIN_EARLY_SDK_ALLOWED defined */
</span> 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* If we already have ...MAX_ALLOWED, we can't do anything to get it. */
</span> #ifndef MAC_OS_X_VERSION_MAX_ALLOWED
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Otherwise, obtain it, possibly unforced */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    && __MPLS_MIN_SDK_ALLOWED < __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define MAC_OS_X_VERSION_MIN_REQUIRED __MPLS_MIN_SDK_ALLOWED
</span> #define __MPLS_NEED_MIN_REQUIRED_FIXUP 1
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span> 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Lowest allowable value is for 10.0 */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define MAC_OS_X_VERSION_MIN_REQUIRED 1000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Make sure version macros get defined in 11.x+ SDKs. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _DARWIN_C_SOURCE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _DARWIN_C_SOURCE 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_DARWIN_C_UNDEF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span> 
 #include <AvailabilityMacros.h>
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef __MPLS_DARWIN_C_UNDEF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef _DARWIN_C_SOURCE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef __MPLS_DARWIN_C_UNDEF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED undef */
</span> 
 /* Define the major SDK version via an if/elif chain. */
 /* Add new entries as needed. */
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#error Unsupported or incorrectly obtained SDK version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#elif MAC_OS_X_VERSION_MAX_ALLOWED < 1050
</span> #define __MPLS_SDK_MAJOR 1040
 #elif MAC_OS_X_VERSION_MAX_ALLOWED < 1060
 #define __MPLS_SDK_MAJOR 1050
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -118,11 +162,13 @@
</span> #define __MPLS_SDK_MAJOR 130000
 #elif MAC_OS_X_VERSION_MAX_ALLOWED < 150000
 #define __MPLS_SDK_MAJOR 140000
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#elif MAC_OS_X_VERSION_MAX_ALLOWED < 160000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MPLS_SDK_MAJOR 150000
</span> #else
 #error Unknown SDK version
 #endif
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Then correct our munging, if necessary */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Then correct our munging, if necessary. */
</span> 
 #ifdef __MPLS_NEED_MIN_REQUIRED_FIXUP
 
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -139,11 +185,13 @@
</span> #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_MIN_REQUIRED
 #endif
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#undef __MPLS_NEED_MIN_REQUIRED_FIXUP
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /* __MPLS_NEED_MIN_REQUIRED_FIXUP */
 
 #else /* !__APPLE__ */
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* If non-Apple, just assume an "infinitely late" SDK */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* If non-Apple, just assume an "infinitely late" SDK. */
</span> 
 #ifndef __MPLS_SDK_MAJOR
 #define __MPLS_SDK_MAJOR 999999
</pre><pre style='margin:0'>

</pre>