aboutsummaryrefslogtreecommitdiff
path: root/share/mk/bsd.snmpmod.mk
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2019-07-19 00:15:25 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2019-07-19 00:15:25 +0000
commit000a2e7040cdd58f2e588b80934784a2d5fcbfa7 (patch)
treebbd7e5c831e7bd48612513b5e023ae053680be88 /share/mk/bsd.snmpmod.mk
parentc75bdc044d4dfc8d19954eac7e8a77fb256d58ba (diff)
downloadsrc-000a2e7040cdd58f2e588b80934784a2d5fcbfa7.tar.gz
src-000a2e7040cdd58f2e588b80934784a2d5fcbfa7.zip
Rework some multi-output target dependency handling.
This reworks my last commit in r301285 to more closely match what was in r241298 (but reverted in r294878). This is addressing "missing .meta file" rebuilds but also ensuring that files are always generated when needed in each case. Note that this is not a complete rework of the problem areas identified in r301285 as most are "good enough" right now as the new pattern is too verbose. It's only worth making this current change where headers may be generated in the INCS list; where missing .meta file rebuilds are spotted. --- Technical details follow --- Several attempts to deal with this problem of multi-output targets, with and without META MODE, were explained in r241298, r294878, and r301285. The general problem is with multi-output targets such as: foo.c foo.h: touch foo.c foo.h foo.c foo.h: touch foo.c touch foo.h foo.c foo.h: foo.in ./generator ${.ALLSRC} This pattern is problematic in jobs mode as both files end up being built concurrently and leads to races. With META MODE it is worse as both targets end up rebuilding if they lack a .meta file. So the generator is force built twice even though it is only needed once. There are also problems in that 'make foo.h' may be ran before 'make foo.c'; The order of make generating the targets is not guaranteed. An older attempted workaround to this (discussed in r294878) was: foo.h: foo.c foo.c: foo.in ./generator ${.ALLSRC} This appears fine except that if foo.h is missing and foo.c exists then foo.h will never be regenerated. This pattern is close to the solution in this commit though: foo.h: foo.c .NOMETA .if !exists(foo.h) foo.c: .PHONY .META .endif foo.c: foo.in ./generator ${.ALLSRC} There's 2 differences here: 1. foo.h will never expect to have a .meta file since the foo.c target will generate both and own the .meta file. 2. If foo.h does not exist then it needs to force foo.c to be rebuilt with .PHONY. That normally disables META MODE though so .META is given to tell bmake we do really expect a .meta file. This pattern cannot work with implicit suffix rules since the .c and .h files may be generated at different times (buildincludes vs depend/all). Sponsored by: Dell EMC MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=350119
Diffstat (limited to 'share/mk/bsd.snmpmod.mk')
-rw-r--r--share/mk/bsd.snmpmod.mk11
1 files changed, 8 insertions, 3 deletions
diff --git a/share/mk/bsd.snmpmod.mk b/share/mk/bsd.snmpmod.mk
index c45937cc82a7..6ecbbcf09bf7 100644
--- a/share/mk/bsd.snmpmod.mk
+++ b/share/mk/bsd.snmpmod.mk
@@ -12,9 +12,14 @@ GENSNMPTREEFLAGS+= -I${SHAREDIR}/snmpdefs
${MOD}_oid.h: ${MOD}_tree.def ${EXTRAMIBDEFS} ${EXTRAMIBSYMS}
cat ${.ALLSRC} | gensnmptree ${GENSNMPTREEFLAGS} -e ${XSYM} > ${.TARGET}
-.ORDER: ${MOD}_tree.c ${MOD}_tree.h
-${MOD}_tree.h: .NOMETA
-${MOD}_tree.c ${MOD}_tree.h: ${MOD}_tree.def ${EXTRAMIBDEFS}
+# Multi-output targets both expect a .meta file and will fight over it. Only
+# allow it on the .c file instead.
+${MOD}_tree.h: ${MOD}_tree.c .NOMETA
+# Force rebuild the .c file if any of its other outputs are missing.
+.if !exists(${MOD}_tree.h)
+${MOD}_tree.c: .PHONY .META
+.endif
+${MOD}_tree.c: ${MOD}_tree.def ${EXTRAMIBDEFS}
cat ${.ALLSRC} | gensnmptree -f ${GENSNMPTREEFLAGS} -p ${MOD}_
.if defined(DEFS)