Skip to content

Instantly share code, notes, and snippets.

@jperkin
Last active November 20, 2023 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperkin/ed7ef4c3f5f869554d80f93ec8d136e0 to your computer and use it in GitHub Desktop.
Save jperkin/ed7ef4c3f5f869554d80f93ec8d136e0 to your computer and use it in GitHub Desktop.
Index: mk/buildlink3/bsd.buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/buildlink3/bsd.buildlink3.mk,v
retrieving revision 1.261
diff -u -r1.261 bsd.buildlink3.mk
--- mk/buildlink3/bsd.buildlink3.mk 27 Jun 2023 10:40:09 -0000 1.261
+++ mk/buildlink3/bsd.buildlink3.mk 20 Nov 2023 13:02:42 -0000
@@ -226,9 +226,41 @@
. endfor
.endfor
-# By default, every package receives a full dependency.
+# Set BUILDLINK_DEFAULT_DEPMETHOD for each package. Iterate through the tree,
+# and if a package has explicitly set BUILDLINK_DEPMETHOD then use it as the
+# default for its dependencies, otherwise default to "full".
+#
+# If a package was previously marked "build" but is later encountered inside a
+# "full" stack then "full" must take precedence.
+#
+_stack_:= bottom
+.for _pkg_ in ${BUILDLINK_TREE}
+. if !${_pkg_:M-*}
+. if defined(BUILDLINK_DEPMETHOD.${_pkg_})
+_stack_:= ${BUILDLINK_DEPMETHOD.${_pkg_}} ${_stack_}
+. elif ${_stack_} == "bottom"
+_stack_:= full ${_stack_}
+. else
+_stack_:= ${_stack_:[1]} ${_stack_}
+. endif
+. else
+. if !defined(BUILDLINK_DEFAULT_DEPMETHOD.${_pkg_:S/^-//}) || \
+ (${BUILDLINK_DEFAULT_DEPMETHOD.${_pkg_:S/^-//}} == "build" && ${_stack_:[1]} == full)
+BUILDLINK_DEFAULT_DEPMETHOD.${_pkg_:S/^-//}:= ${_stack_:[1]}
+. endif
+_stack_:= ${_stack_:[2..-1]}
+. endif
+.endfor
+.if ${_stack_} != "bottom"
+. error "The above loop through BUILDLINK_TREE failed to balance"
+.endif
+
+# Now set BUILDLINK_DEPMETHOD for each package based on its default. Note that
+# we can't do this in one loop above because we need to detect when
+# BUILDLINK_DEPMETHOD has been set by a package and not as part of the loop.
+#
.for _pkg_ in ${_BLNK_PACKAGES}
-BUILDLINK_DEPMETHOD.${_pkg_}?= full
+BUILDLINK_DEPMETHOD.${_pkg_}?= ${BUILDLINK_DEFAULT_DEPMETHOD.${_pkg_}}
.endfor
# _BLNK_DEPENDS contains all of the elements of _BLNK_PACKAGES for which
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment