When using the DIRDEPS_BUILD (eg. in FreeBSD) many optional features can impact the tree's dependency graph.
This poses a challenge for automatic dependency maintenance since DIRDEPS in auto updated Makefile.depend files would churn as options are enabled/disabled.
The solution is for directories which are affected by options to have a Makefile.depend.options file, which lists the relevant options and includes dirdeps-options.mk. For example in sys/boot/userboot/userboot/Makefile.depend.options:
DIRDEPS_OPTIONS= LOADER_VERIEXEC DIRDEPS.LOADER_VERIEXEC.yes = lib/libbearssl lib/libve .include <dirdeps-options.mk>
If DIRDEPS.LOADER_VERIEXEC.yes is consistent and needed in several places, it could be defined in local.dirdeps-options.mk.
The above Makefile.depend.options file will be included by dirdeps.mk and if .MAKE.LEVEL == 0 dirdeps-options.mk will add ${DIRDEPS.LOADER_VERIEXEC.${MK_LOADER_VERIEXEC}} to DIRDEPS.
Later when .MAKE.LEVEL > 0 meta.autodep.mk will also include Makefile.depend.options and ${DIRDEPS.LOADER_VERIEXEC.yes} and ${DIRDEPS.LOADER_VERIEXEC.no} will be added to GENDIRDEPS_FILTER so as to prevent those directories being captured in Makefile.depend.
Ideally any option that is expected to impact the tree dependency graph needs to be set via sys.mk - before dirdeps.mk starts working. However is is also possible for local.dirdeps.mk to include whatever makefile handles setting those options not set during sys.mk. For example in FreeBSD:
.if !defined(MK_CLANG) .include "${SRCTOP}/share/mk/src.opts.mk" .endif
Author: | sjg@crufty.net |
---|---|
Revision: | $Id: dirdeps-options.txt,v fdb331aaa036 2018-12-01 17:12:07Z sjg $ |