Subject: RFC addendum: Subpackage dependencies
To: None <>
From: Johnny C. Lam <>
List: tech-pkg
Date: 05/31/2004 22:18:54
Since both Eric and Julio want the ability to specify dependencies
separately for each subpackage, I'll outline a way to do this that
will be succinct and hopefully be easy for package maintainers to

The technical difficulty with listing dependencies for each subpackage
is that most packages pull in dependencies via files,
and that including some files don't add any dependencies,
e.g. if you include libiconv/ on a NetBSD-2.0 machine.
To work around this problem, I think we can make the following
modification to

	.for _subpkg_ in ${SUBPACKAGES}
			real-su-install-subpkg SUBPACKAGE=${_subpkg_}

and rename the current real-su-install to "real-su-install-subpkg" with
the appropriate modifications.  Then in the package Makefile, do:

	SUBDEPENDS.client=	lib

	.include "../../mk/"

	.if empty(SUBPACKAGE) || (${SUBPACKAGE} == "lib")
	.  include "../../graphics/imlib/"
	.if empty(SUBPACKAGE) || (${SUBPACKAGE} == "client")
	.  include "../../x11/gtk/"

	.include "../../mk/"

The idea is that SUBPACKAGE is empty during every phase except during
the "install" and "package" phases.  This lets the usual dependency
machinery see only the relevant dependencies in the files
for each subpackage.  It's possible to make it look nicer by doing
something like:

	SUBDEPENDS.client=	lib
	DEPENDS.lib=		imlib
	DEPENDS.client=		gtk

	.include "../../graphics/imlib/"
	.include "../../x11/gtk/"
	.include "../../mk/"

Here, SUBDEPENDS.* describes the internal dependency structure of the
subpackages, and DEPENDS.* describes the external dependencies of each
subpackage.  We would add some logic to to add the
correct dependencies to each subpackage.  The main package would still
depend on everything, but the subpackages would have individual lists
of dependencies.

The problem here is that this scheme only works with packages that use
buildlink3.  We could extend it by having DEPENDS.* also list dependencies
of the usual form "foo>=1.0:../../devel/foo", and for those elements listed
in DEPENDS.* that match "*:*", we just add them directly to the dependencies
for that subpackage.  So for non-buildlink3 packages, we have:

	SUBDEPENDS.client=	lib
	DEPENDS.lib=		imlib>=1.9.14nb5:../../graphics/imlib
	DEPENDS.client=		gtk+>=1.2.10:../../x11/gtk

	.include "../../mk/"

Can anyone see any problems or suggest refinements to doing it this way?
Again, please cc: me on all replies.


	-- Johnny Lam <>