tech-pkg archive

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

per-package MAKE_JOBS



I got tired of having to build qemu by hand to keep it from OOMing, so
the following patch allows MAKE_JOBS.pkg to override the global
MAKE_JOBS setting.

It uses PKGBASE as the key; is that right? Prior art is surprisingly
hard to find given how many ${FOO.bar} things we have.

Also, should it set some variable (say, PKG_MAKE_JOBS) to the resolved
jobs count for this package, so it can be interrogated elsewhere?

   ------

Index: mk/defaults/mk.conf
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defaults/mk.conf,v
retrieving revision 1.290
diff -u -r1.290 mk.conf
--- mk/defaults/mk.conf	2 Jan 2018 05:49:44 -0000	1.290
+++ mk/defaults/mk.conf	7 Jan 2018 20:51:03 -0000
@@ -51,19 +51,26 @@
 # Default: -9
 
 #MAKE_JOBS=	3
+#MAKE_JOBS.pkg=	2
 #	When defined, specifies the maximum number of jobs ("make -j")
 #	that are run in parallel when building packages with the default
 #	do-build action. MAKE_JOBS only affects the "build" target,
 #	neither "test" nor "install".
 #
+#	May be specified on a per-package basis; any package-specific
+#	value overrides the global setting.
+#
 #	Possible values: any positive integer. Useful values are around
 #	the number of processors on the machine.
 #
 #	Default value: (undefined)
 #
-#	Warning: This is experimental. Some packages will not build with
-#	this. Disabling this for an individual package can be done by
+#	Warning: Some packages will not build with this. Disabling
+#	parallel builds for an individual package can be done by
 #	setting MAKE_JOBS_SAFE=NO within the per package Makefile.
+#	When doing so, please include a comment indicating what went
+#	wrong so it can be crosschecked in the future after upstream
+#	changes.
 
 #OBJHOSTNAME=
 # use hostname-specific object directories, e.g.  work.amnesiac, work.localhost
Index: mk/build/build.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/build/build.mk,v
retrieving revision 1.22
diff -u -r1.22 build.mk
--- mk/build/build.mk	1 Jun 2017 02:15:10 -0000	1.22
+++ mk/build/build.mk	7 Jan 2018 20:51:03 -0000
@@ -53,6 +53,8 @@
 
 .if defined(MAKE_JOBS_SAFE) && !empty(MAKE_JOBS_SAFE:M[nN][oO])
 _MAKE_JOBS=	# nothing
+.elif defined(MAKE_JOBS.${PKGBASE})
+_MAKE_JOBS=	-j${MAKE_JOBS.${PKGBASE}}
 .elif defined(MAKE_JOBS)
 _MAKE_JOBS=	-j${MAKE_JOBS}
 .endif

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index