Use OBJS_SRCS_FILTER to control setting OBJS from SRCS

Some makefiles do reachover builds.
In some cases it is convenient to list subdirs of the distribution
in SRCS.

It is not very convenient, or always even desirable to have corresponding
subdirs in .OBJDIR, so OBJS_SRCS_FILTER allows the makefile to choose.
The default value 'R' matches existing practice.

But a makefile can set OBJS_SRCS_FILTER= T (the R gets added by
bsd.init.mk) to avoid the need for subdirs in .OBJDIR

Differential Revision:	https://reviews.freebsd.org/D12218
Reviewed by:	bdrewery
This commit is contained in:
sjg 2017-09-16 05:42:27 +00:00
parent acad431d06
commit 8425f75b1c
4 changed files with 10 additions and 6 deletions

View File

@ -101,7 +101,7 @@ _SKIP_DEPEND= 1
CLEANFILES?=
.for _S in ${SRCS:N*.[dhly]}
OBJS_DEPEND_GUESS.${_S:R}.o+= ${_S}
OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.o+= ${_S}
.endfor
# Lexical analyzers
@ -180,7 +180,7 @@ DEPEND_MP?= -MP
DEPEND_FILTER= C,/,_,g
DEPENDSRCS= ${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc}
.if !empty(DEPENDSRCS)
DEPENDOBJS+= ${DEPENDSRCS:R:S,$,.o,}
DEPENDOBJS+= ${DEPENDSRCS:${OBJS_SRCS_FILTER:ts:}:S,$,.o,}
.endif
DEPENDFILES_OBJS= ${DEPENDOBJS:O:u:${DEPEND_FILTER}:C/^/${DEPENDFILE}./}
.if defined(_SKIP_DEPEND)

View File

@ -16,6 +16,10 @@ __<bsd.init.mk>__:
.include <bsd.own.mk>
.MAIN: all
# This is used in bsd.{dep,lib,prog}.mk as ${OBJS_SRCS_FILTER:ts:}
# Some makefiles may want T as well to avoid nested objdirs.
OBJS_SRCS_FILTER+= R
# Handle INSTALL_AS_USER here to maximize the chance that
# it has final authority over fooOWN and fooGRP.
.if ${MK_INSTALL_AS_USER} != "no"

View File

@ -168,7 +168,7 @@ LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
.endif
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/}
CLEANFILES+= ${OBJS} ${STATICOBJS}
.endif
@ -437,13 +437,13 @@ lint: ${SRCS:M*.c}
.if defined(LIB) && !empty(LIB)
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.for _S in ${SRCS:N*.[hly]}
OBJS_DEPEND_GUESS.${_S:R}.po+= ${_S}
OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+= ${_S}
.endfor
.endif
.if defined(SHLIB_NAME) || \
defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
.for _S in ${SRCS:N*.[hly]}
OBJS_DEPEND_GUESS.${_S:R}.pico+= ${_S}
OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+= ${_S}
.endfor
.endif

View File

@ -85,7 +85,7 @@ PROGNAME?= ${PROG}
.if defined(SRCS)
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g}
.if target(beforelinking)
beforelinking: ${OBJS}