Add a guard for broken SUBDIR.${MK_FOO} use

Check for the variable SUBDIR. and error as it usually means someone
forgot to include src.opts.mk.

This guard from CheriBSD found the bugs in r367655 and r367728.

Reviewed by:	bdrewery, arichardson
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27211
This commit is contained in:
Brooks Davis 2020-11-16 19:15:11 +00:00
parent a521f21164
commit 02e65672b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367735

View File

@ -127,6 +127,12 @@ SUBDIR:=${SUBDIR} ${SUBDIR.yes} ${SUBDIR.yes.yes}
SUBDIR:=${SUBDIR:u}
.endif
.if defined(SUBDIR.)
.error ${.CURDIR}: Found variable SUBDIR. with value "${SUBDIR.}". This was \
probably caused by using SUBDIR.$${MK_FOO} without including \
<src.opts.mk> or by using an invalid $${MK_FOO} option.
.endif
# Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL.
_SUBDIR_SH= \
if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \