<bsd.progs.mk>: Allow using SRCS for common sources

Instead of having to do:

PROGS=	program1 program2
SRCS.program1=	program1.c common.c
SRCS.program2=	program2.c common.c

This can now be done instead:

PROGS=	program1 program2
SRCS=	common.c
SRCS.program1=	program1.c
SRCS.program2=	program2.c

This shouldn't effect any existing projects using <bsd.progs.mk>.

Reviewed by: imp, sjg
Pull Request: https://github.com/freebsd/freebsd-src/pull/766
This commit is contained in:
VexedUXR 2023-12-27 17:01:29 -07:00 committed by Warner Losh
parent e21ebb4d2d
commit 4ea5e107b1

View file

@ -22,9 +22,9 @@ PROGS += ${PROGS_CXX}
.if defined(PROG)
# just one of many
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE CSTD CXXSTD DPSRCS MAN \
NO_SHARED MK_WERROR PROGNAME SRCS STRIP WARNS MK_ASAN MK_UBSAN
PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \
LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
NO_SHARED MK_WERROR PROGNAME STRIP WARNS MK_ASAN MK_UBSAN
PROG_VARS += SRCS CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD \
LIBADD LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
.for v in ${PROG_VARS:O:u}
.if empty(${PROG_OVERRIDE_VARS:M$v})
.if defined(${v}.${PROG})
@ -96,8 +96,8 @@ $v =
# 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= ${DPSRCS}
_PROGS_ALL_SRCS=
_PROGS_COMMON_SRCS= ${DPSRCS} ${SRCS}
_PROGS_ALL_SRCS= ${SRCS}
.for p in ${PROGS}
.for s in ${SRCS.${p}}
.if ${_PROGS_ALL_SRCS:M${s}} && !${_PROGS_COMMON_SRCS:M${s}}