PROGS+META_MODE: Avoid rebuilding common sources when recursing.

This could be seen in lib/libkvm/tests where kvm_test_common.o was
a common dependency, but one of the recursed progs had a special
CFLAGS+= -I that changed the build command.  This would cause
all recursed builds to rebuild while fighting over the meta file
and object file.

Reported by:	Mark Millard
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Bryan Drewery 2017-05-09 18:45:34 +00:00
parent 1404daa76c
commit f59d3d55b6

View File

@ -87,11 +87,7 @@ $v =
# handle being called [bsd.]progs.mk
.include <bsd.prog.mk>
.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
# tell progs.mk we might want to install things
PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
# Find common sources among the PROGS and depend on them before building
# Find common sources among the PROGS to depend on them before building
# anything. This allows parallelization without them each fighting over
# the same objects.
_PROGS_COMMON_SRCS=
@ -110,6 +106,20 @@ _PROGS_COMMON_OBJS= ${_PROGS_COMMON_SRCS:M*.[dhly]}
.if !empty(_PROGS_COMMON_SRCS:N*.[dhly])
_PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:R:S/$/.o/g}
.endif
.endif
# When recursing, ensure common sources are not rebuilt in META_MODE.
.if defined(_RECURSING_PROGS) && !empty(_PROGS_COMMON_OBJS) && \
!empty(.MAKE.MODE:Mmeta)
${_PROGS_COMMON_OBJS}: .NOMETA
.endif
.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
# tell progs.mk we might want to install things
PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
# Ensure common objects are built before recursing.
.if !empty(_PROGS_COMMON_OBJS)
${PROGS}: ${_PROGS_COMMON_OBJS}
.endif