2015-06-13 15:20:56 -04:00
|
|
|
# $FreeBSD$
|
2012-08-22 15:25:57 -04:00
|
|
|
|
2016-06-14 12:20:25 -04:00
|
|
|
.if ${MK_DIRDEPS_BUILD} == "yes" || ${MK_META_MODE} == "yes"
|
|
|
|
|
|
|
|
|
|
# Not in the below list as it may make sense for non-meta mode
|
|
|
|
|
# eventually. meta.sys.mk (DIRDEPS_BUILD) also already adds these in.
|
|
|
|
|
.if ${MK_DIRDEPS_BUILD} == "no" && ${MK_META_MODE} == "yes"
|
|
|
|
|
MAKE_PRINT_VAR_ON_ERROR += \
|
|
|
|
|
.ERROR_TARGET \
|
|
|
|
|
.ERROR_META_FILE \
|
|
|
|
|
.MAKE.LEVEL \
|
|
|
|
|
MAKEFILE \
|
|
|
|
|
.MAKE.MODE
|
|
|
|
|
.endif
|
|
|
|
|
|
2017-06-16 17:48:42 -04:00
|
|
|
_ERROR_CMD_EXEC= ${sed -n '/^CMD/s,^CMD \(.*\),\1;,p' ${.ERROR_META_FILE}:L:sh}
|
2017-06-16 00:28:10 -04:00
|
|
|
_ERROR_CMD= ${!empty(.ERROR_META_FILE):?${_ERROR_CMD_EXEC}:.PHONY}
|
2012-08-22 15:25:57 -04:00
|
|
|
MAKE_PRINT_VAR_ON_ERROR+= \
|
2017-06-12 15:13:29 -04:00
|
|
|
_ERROR_CMD \
|
2012-08-22 15:25:57 -04:00
|
|
|
.CURDIR \
|
|
|
|
|
.MAKE \
|
|
|
|
|
.OBJDIR \
|
|
|
|
|
.TARGETS \
|
|
|
|
|
DESTDIR \
|
|
|
|
|
LD_LIBRARY_PATH \
|
|
|
|
|
MACHINE \
|
|
|
|
|
MACHINE_ARCH \
|
|
|
|
|
MAKEOBJDIRPREFIX \
|
2012-11-03 22:52:03 -04:00
|
|
|
MAKESYSPATH \
|
2016-06-14 12:20:25 -04:00
|
|
|
MAKE_VERSION \
|
2015-11-25 14:44:31 -05:00
|
|
|
PATH \
|
2015-05-26 17:44:15 -04:00
|
|
|
SRCTOP \
|
2012-08-22 15:25:57 -04:00
|
|
|
OBJTOP \
|
|
|
|
|
${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
|
|
|
|
|
|
2019-06-15 13:08:28 -04:00
|
|
|
# Meta mode may rebuild targets that then fail. The next build won't detect
|
|
|
|
|
# the meta mode change. Not all targets have a 'rm ${.TARGET}' in them
|
|
|
|
|
# so force it.
|
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
|
|
2013-02-15 20:19:18 -05:00
|
|
|
.if ${.MAKE.LEVEL} > 0
|
|
|
|
|
MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
|
|
|
|
|
.endif
|
2015-06-15 17:09:18 -04:00
|
|
|
.endif
|
2013-02-15 20:19:18 -05:00
|
|
|
|
2016-03-31 10:48:17 -04:00
|
|
|
.if !empty(.OBJDIR)
|
|
|
|
|
OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
|
|
|
|
|
.endif
|
|
|
|
|
|
2017-06-19 14:08:02 -04:00
|
|
|
.if !empty(LIBDIR)
|
|
|
|
|
_PREMK_LIBDIR:= ${LIBDIR}
|
|
|
|
|
.endif
|
|
|
|
|
|
2015-06-13 15:20:56 -04:00
|
|
|
.include "src.sys.mk"
|
2015-11-13 22:24:48 -05:00
|
|
|
|
2016-01-19 17:41:44 -05:00
|
|
|
.if ${.MAKE.MODE:Mmeta*} != ""
|
2015-11-13 22:24:48 -05:00
|
|
|
# we can afford to use cookies to prevent some targets
|
2016-03-11 18:45:32 -05:00
|
|
|
# re-running needlessly but only when using filemon.
|
2016-04-14 17:04:42 -04:00
|
|
|
# Targets that should support the meta mode cookie handling should just be
|
|
|
|
|
# added to META_TARGETS. If bsd.sys.mk cannot be included then ${META_DEPS}
|
|
|
|
|
# should be added as a target dependency as well. Otherwise the target
|
|
|
|
|
# is added to in bsd.sys.mk since it comes last.
|
2016-03-11 18:45:32 -05:00
|
|
|
.if ${.MAKE.MODE:Mnofilemon} == ""
|
2016-04-14 17:04:45 -04:00
|
|
|
# Prepend .OBJDIR if not already there.
|
|
|
|
|
_META_COOKIE_COND= "${.TARGET:M${.OBJDIR}/*}" == ""
|
|
|
|
|
_META_COOKIE_DEFAULT= ${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}
|
|
|
|
|
# Use the default if COOKIE.${.TARGET} is not defined.
|
|
|
|
|
META_COOKIE= ${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}}
|
2016-03-11 18:44:27 -05:00
|
|
|
META_COOKIE_RM= @rm -f ${META_COOKIE}
|
|
|
|
|
META_COOKIE_TOUCH= @touch ${META_COOKIE}
|
2016-03-11 18:45:28 -05:00
|
|
|
CLEANFILES+= ${META_TARGETS}
|
2016-03-13 16:51:45 -04:00
|
|
|
_meta_dep_before: .USEBEFORE .NOTMAIN
|
2016-03-11 18:45:28 -05:00
|
|
|
${META_COOKIE_RM}
|
2016-03-13 16:51:45 -04:00
|
|
|
_meta_dep_after: .USE .NOTMAIN
|
2016-03-11 18:45:28 -05:00
|
|
|
${META_COOKIE_TOUCH}
|
|
|
|
|
# Attach this to a target to allow it to benefit from meta mode's
|
|
|
|
|
# not rerunning a command if it doesn't need to be considering its
|
|
|
|
|
# metafile/filemon-tracked dependencies.
|
|
|
|
|
META_DEPS= _meta_dep_before _meta_dep_after .META
|
2016-03-11 18:45:32 -05:00
|
|
|
.endif
|
2015-11-13 22:24:48 -05:00
|
|
|
.else
|
2016-03-11 18:45:32 -05:00
|
|
|
# some targets need to be .PHONY - but not in meta mode
|
2016-03-11 18:45:28 -05:00
|
|
|
META_NOPHONY= .PHONY
|
2015-11-13 22:24:48 -05:00
|
|
|
.endif
|
2016-03-11 18:45:32 -05:00
|
|
|
META_NOPHONY?=
|
|
|
|
|
META_COOKIE_RM?=
|
|
|
|
|
META_COOKIE_TOUCH?=
|
2016-03-11 18:45:28 -05:00
|
|
|
META_DEPS+= ${META_NOPHONY}
|