2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2016-06-14 16:20:25 +00: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 21:48:42 +00:00
|
|
|
_ERROR_CMD_EXEC= ${sed -n '/^CMD/s,^CMD \(.*\),\1;,p' ${.ERROR_META_FILE}:L:sh}
|
2017-06-16 04:28:10 +00:00
|
|
|
_ERROR_CMD= ${!empty(.ERROR_META_FILE):?${_ERROR_CMD_EXEC}:.PHONY}
|
2012-08-22 19:25:57 +00:00
|
|
|
MAKE_PRINT_VAR_ON_ERROR+= \
|
2017-06-12 19:13:29 +00:00
|
|
|
_ERROR_CMD \
|
2012-08-22 19:25:57 +00:00
|
|
|
.CURDIR \
|
|
|
|
.MAKE \
|
|
|
|
.OBJDIR \
|
|
|
|
.TARGETS \
|
|
|
|
DESTDIR \
|
|
|
|
LD_LIBRARY_PATH \
|
|
|
|
MACHINE \
|
|
|
|
MACHINE_ARCH \
|
|
|
|
MAKEOBJDIRPREFIX \
|
2012-11-04 02:52:03 +00:00
|
|
|
MAKESYSPATH \
|
2016-06-14 16:20:25 +00:00
|
|
|
MAKE_VERSION \
|
2015-11-25 19:44:31 +00:00
|
|
|
PATH \
|
2015-05-26 21:44:15 +00:00
|
|
|
SRCTOP \
|
2012-08-22 19:25:57 +00:00
|
|
|
OBJTOP \
|
|
|
|
${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
|
|
|
|
|
2019-06-15 17:08:28 +00: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-16 01:19:18 +00:00
|
|
|
.if ${.MAKE.LEVEL} > 0
|
|
|
|
MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
|
|
|
|
.endif
|
2015-06-15 21:09:18 +00:00
|
|
|
.endif
|
2013-02-16 01:19:18 +00:00
|
|
|
|
2016-03-31 14:48:17 +00:00
|
|
|
.if !empty(.OBJDIR)
|
|
|
|
OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
|
|
|
|
.endif
|
|
|
|
|
2017-06-19 18:08:02 +00:00
|
|
|
.if !empty(LIBDIR)
|
|
|
|
_PREMK_LIBDIR:= ${LIBDIR}
|
|
|
|
.endif
|
|
|
|
|
2015-06-13 19:20:56 +00:00
|
|
|
.include "src.sys.mk"
|
2015-11-14 03:24:48 +00:00
|
|
|
|
2016-01-19 22:41:44 +00:00
|
|
|
.if ${.MAKE.MODE:Mmeta*} != ""
|
2015-11-14 03:24:48 +00:00
|
|
|
# we can afford to use cookies to prevent some targets
|
2016-03-11 23:45:32 +00:00
|
|
|
# re-running needlessly but only when using filemon.
|
2016-04-14 21:04:42 +00: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 23:45:32 +00:00
|
|
|
.if ${.MAKE.MODE:Mnofilemon} == ""
|
2016-04-14 21:04:45 +00: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 23:44:27 +00:00
|
|
|
META_COOKIE_RM= @rm -f ${META_COOKIE}
|
|
|
|
META_COOKIE_TOUCH= @touch ${META_COOKIE}
|
2016-03-11 23:45:28 +00:00
|
|
|
CLEANFILES+= ${META_TARGETS}
|
2016-03-13 20:51:45 +00:00
|
|
|
_meta_dep_before: .USEBEFORE .NOTMAIN
|
2016-03-11 23:45:28 +00:00
|
|
|
${META_COOKIE_RM}
|
2016-03-13 20:51:45 +00:00
|
|
|
_meta_dep_after: .USE .NOTMAIN
|
2016-03-11 23:45:28 +00: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 23:45:32 +00:00
|
|
|
.endif
|
2015-11-14 03:24:48 +00:00
|
|
|
.else
|
2016-03-11 23:45:32 +00:00
|
|
|
# some targets need to be .PHONY - but not in meta mode
|
2016-03-11 23:45:28 +00:00
|
|
|
META_NOPHONY= .PHONY
|
2015-11-14 03:24:48 +00:00
|
|
|
.endif
|
2016-03-11 23:45:32 +00:00
|
|
|
META_NOPHONY?=
|
|
|
|
META_COOKIE_RM?=
|
|
|
|
META_COOKIE_TOUCH?=
|
2016-03-11 23:45:28 +00:00
|
|
|
META_DEPS+= ${META_NOPHONY}
|