CVS commit: pkgsrc/mk/build

"Jonathan Perkin" <[email protected]> Thu, 30 Jul 2026 16:16:31 +0000
Newsgroups gmane.os.netbsd.devel.pkgsrc.cvs
Message-ID <[email protected]>
Module Name:	pkgsrc
Committed By:	jperkin
Date:		Thu Jul 30 16:16:31 UTC 2026

Modified Files:
	pkgsrc/mk/build: build.mk

Log Message:
mk: Add support for MAKE_JOBS_METHOD.

Currently lang/openjdk* have to set MAKE_JOBS_SAFE=no to avoid getting -j added
to the default make command line, which according to their documentation is
unsafe.  Assuming that MAKE_JOBS will still be set to a value >1 in this
situation is unreliable, and is clearly a mis-use of the intended design for
this variable.

Instead they can now set MAKE_JOBS_METHOD=manual (the recommended value for
packages which perform their own custom MAKE_JOBS handling) which will avoid -j
being passed.

The variable is left deliberately open-ended in order to easily support other
build systems, should we wish to in the future.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 pkgsrc/mk/build/build.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(unnamed) (text/x-diff, 2.2 KB)
Modified files:

Index: pkgsrc/mk/build/build.mk
diff -u pkgsrc/mk/build/build.mk:1.34 pkgsrc/mk/build/build.mk:1.35
--- pkgsrc/mk/build/build.mk:1.34	Fri Jun 12 17:33:23 2020
+++ pkgsrc/mk/build/build.mk	Thu Jul 30 16:16:31 2026
@@ -1,4 +1,4 @@
-# $NetBSD: build.mk,v 1.34 2020/06/12 17:33:23 rillig Exp $
+# $NetBSD: build.mk,v 1.35 2026/07/30 16:16:31 jperkin Exp $
 #
 # This file defines what happens in the build phase, excluding the
 # self-test, which is defined in test.mk.
@@ -17,6 +17,15 @@
 # BUILD_TARGET is the target from ${MAKE_FILE} that should be invoked
 #	to build the sources.
 #
+# MAKE_JOBS_METHOD
+#	How the MAKE_JOBS value should be passed to the build.  The vast
+#	majority of packages use the "-j" argument to make, and so the
+#	default is "make-j".  This variable is left deliberately open-ended
+#	to allow for future build system support.  If a package has its own
+#	method for using MAKE_JOBS, it should set this value to "manual".
+#
+#	Keywords: parallel
+#
 # MAKE_JOBS_SAFE
 #	Whether the package supports parallel builds. If set to yes,
 #	at most MAKE_JOBS jobs are carried out in parallel. The default
@@ -40,13 +49,15 @@
 _VARGROUPS+=		build
 _DEF_VARS.build=	_MAKE_JOBS_N
 _USER_VARS.build=	MAKE_JOBS BUILD_ENV_SHELL
-_PKG_VARS.build=	MAKE_ENV MAKE_FLAGS BUILD_MAKE_FLAGS BUILD_TARGET MAKE_JOBS_SAFE
+_PKG_VARS.build=	MAKE_ENV MAKE_FLAGS BUILD_MAKE_FLAGS BUILD_TARGET
+_PKG_VARS.build+=	MAKE_JOBS_METHOD MAKE_JOBS_SAFE
 _SYS_VARS.build=	BUILD_MAKE_CMD
 _SORTED_VARS.build=	*_ENV
 _LISTED_VARS.build=	*_FLAGS *_CMD
 
 BUILD_MAKE_FLAGS?=	# none
 BUILD_TARGET?=		all
+MAKE_JOBS_METHOD?=	make-j
 
 BUILD_MAKE_CMD= \
 	${PKGSRC_SETENV} ${MAKE_ENV}					\
@@ -54,14 +65,18 @@ BUILD_MAKE_CMD= \
 			${MAKE_FLAGS} ${BUILD_MAKE_FLAGS}		\
 			-f ${MAKE_FILE}
 
-.if defined(MAKE_JOBS_SAFE) && !empty(MAKE_JOBS_SAFE:M[nN][oO])
+.if ${MAKE_JOBS_SAFE:U:tl} == no
 _MAKE_JOBS=	# nothing
 _MAKE_JOBS_N=	1
 .elif defined(MAKE_JOBS.${PKGPATH})
+.  if ${MAKE_JOBS_METHOD} == "make-j"
 _MAKE_JOBS=	-j${MAKE_JOBS.${PKGPATH}}
+.  endif
 _MAKE_JOBS_N=	${MAKE_JOBS.${PKGPATH}}
 .elif defined(MAKE_JOBS)
+.  if ${MAKE_JOBS_METHOD} == "make-j"
 _MAKE_JOBS=	-j${MAKE_JOBS}
+.  endif
 _MAKE_JOBS_N=	${MAKE_JOBS}
 .else
 _MAKE_JOBS_N=	1