git: 4ea5e107b1e7 - main - <bsd.progs.mk>: Allow using SRCS for common sources

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 28 Dec 2023 00:03:04 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4ea5e107b1e778321f2e5e5083cf4eee3888eca8

commit 4ea5e107b1e778321f2e5e5083cf4eee3888eca8
Author:     VexedUXR <ahmadkhalifa570@gmail.com>
AuthorDate: 2023-12-28 00:01:29 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-12-28 00:01:39 +0000

    <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
---
 share/mk/bsd.progs.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index fba617b12595..1551516dd6ea 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -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}}