freebsd-skq/share/mk/src.sys.env.mk
bdrewery 6705e6a35e Deal with bmake-20170301 no longer resolving -C like it used to.
Several checks assume .CURDIR is resolved, such as for determining RELDIR from
SRCTOP/.CURDIR.  If -C is used then the path is no longer resolved like it was
before which is problematic for symlinked source trees.  A similar change was
also made to ports post bmake-20170301.

This fixes 'make -C <symlinked path> buildworld' using the wrong OBJDIR.

Reported by:	rstone
Sponsored by:	Dell EMC
2017-12-05 21:30:22 +00:00

61 lines
1.6 KiB
Makefile

# $FreeBSD$
# early setup only see also src.sys.mk
# bmake-20170301 started taking '-C' "as is" for some cases, notably absolute
# paths. Some later comparisons will assume .CURDIR is resolved and matches
# what we would get with 'cd'. So just force resolve it now if it is an
# absolute path.
.if ${MAKE_VERSION} >= 20170301 && !empty(.CURDIR:M/*)
.CURDIR:= ${.CURDIR:tA}
.endif
# make sure this is defined in a consistent manner
SRCTOP:= ${.PARSEDIR:tA:H:H}
.if ${.CURDIR} == ${SRCTOP}
RELDIR= .
RELTOP= .
.elif ${.CURDIR:M${SRCTOP}/*}
RELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
.endif
RELTOP?= ${RELDIR:C,[^/]+,..,g}
RELOBJTOP?= ${RELTOP}
RELSRCTOP?= ${RELTOP}
# site customizations that do not depend on anything!
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
.include <bsd.mkopt.mk>
# Top-level installs should not use meta mode as it may prevent installing
# based on cookies.
.if make(*install*) && ${.MAKE.LEVEL} == 0
META_MODE= normal
MK_META_MODE= no
.export MK_META_MODE
.endif
# If we were found via .../share/mk we need to replace that
# with ${.PARSEDIR:tA} so that we can be found by
# sub-makes launched from objdir.
.if ${.MAKEFLAGS:M.../share/mk} != ""
.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
.endif
.if ${MAKESYSPATH:Uno:M*.../*} != ""
MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
.export MAKESYSPATH
.elif empty(MAKESYSPATH)
MAKESYSPATH:= ${.PARSEDIR:tA}
.export MAKESYSPATH
.endif
.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
.sinclude "${.CURDIR}/Makefile.sys.inc"
.endif
.include <src.sys.obj.mk>