Ignore MAKEOBJDIRPREFIX from src-env.conf in sub-makes.

A sub-make, such as in 'make buildworld', may want to override MAKEOBJDIRPREFIX
but is unable to do so if src-env.conf is forcing it to another value.  Without
using '?=' the sub-make may use the wrong .OBJDIR.

Reported by:	eadler
Sponsored by:	Dell EMC
This commit is contained in:
Bryan Drewery 2018-03-03 23:23:01 +00:00
parent f0fb0d583a
commit 743ab0187f

View File

@ -24,12 +24,40 @@ RELOBJTOP?= ${RELTOP}
RELSRCTOP?= ${RELTOP}
# site customizations that do not depend on anything!
# Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.
# MAKEOBJDIRPREFIX is only needed in MAKELEVEL=0. In sub-makes it will
# either be read from environment or OBJDIR/MAKEOBJDIR according to
# src.sys.obj.mk.
.if !(${.MAKE.LEVEL} == 0 || empty(OBJROOT))
.if defined(MAKEOBJDIRPREFIX)
_saveMAKEOBJDIRPREFIX:= ${MAKEOBJDIRPREFIX}
.else
_undefMAKEOBJDIRPREFIX= t
.endif
.endif
SRC_ENV_CONF?= /etc/src-env.conf
.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
.-include "${SRC_ENV_CONF}"
_src_env_conf_included_: .NOTMAIN
.endif
.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
defined(_undefMAKEOBJDIRPREFIX))
.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make. Use '?=' to avoid this warning.
.endif
.if defined(_saveMAKEOBJDIRPREFIX)
MAKEOBJDIRPREFIX:= ${_saveMAKEOBJDIRPREFIX}
.undef _saveMAKEOBJDIRPREFIX
.elif defined(_undefMAKEOBJDIRPREFIX)
.undef MAKEOBJDIRPREFIX
.undef _undefMAKEOBJDIRPREFIX
.endif
.endif
.include <bsd.mkopt.mk>
# Top-level installs should not use meta mode as it may prevent installing