xref: /freebsd/share/mk/local.sys.mk (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
1# $FreeBSD$
2
3.if ${MK_DIRDEPS_BUILD} == "yes"
4MAKE_PRINT_VAR_ON_ERROR+= \
5	.CURDIR \
6	.MAKE \
7	.OBJDIR \
8	.TARGETS \
9	DESTDIR \
10	LD_LIBRARY_PATH \
11	MACHINE \
12	MACHINE_ARCH \
13	MAKEOBJDIRPREFIX \
14	MAKESYSPATH \
15	MAKE_VERSION\
16	PATH \
17	SRCTOP \
18	OBJTOP \
19	${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
20
21.if ${.MAKE.LEVEL} > 0
22MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
23.endif
24.endif
25
26.if !empty(.OBJDIR)
27OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
28.endif
29
30.include "src.sys.mk"
31
32.if ${.MAKE.MODE:Mmeta*} != ""
33# we can afford to use cookies to prevent some targets
34# re-running needlessly but only when using filemon.
35# Targets that should support the meta mode cookie handling should just be
36# added to META_TARGETS.  If bsd.sys.mk cannot be included then ${META_DEPS}
37# should be added as a target dependency as well.  Otherwise the target
38# is added to in bsd.sys.mk since it comes last.
39.if ${.MAKE.MODE:Mnofilemon} == ""
40# Prepend .OBJDIR if not already there.
41_META_COOKIE_COND=	"${.TARGET:M${.OBJDIR}/*}" == ""
42_META_COOKIE_DEFAULT=	${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}
43# Use the default if COOKIE.${.TARGET} is not defined.
44META_COOKIE=		${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}}
45META_COOKIE_RM=		@rm -f ${META_COOKIE}
46META_COOKIE_TOUCH=	@touch ${META_COOKIE}
47CLEANFILES+=		${META_TARGETS}
48_meta_dep_before:	.USEBEFORE .NOTMAIN
49	${META_COOKIE_RM}
50_meta_dep_after:	.USE .NOTMAIN
51	${META_COOKIE_TOUCH}
52# Attach this to a target to allow it to benefit from meta mode's
53# not rerunning a command if it doesn't need to be considering its
54# metafile/filemon-tracked dependencies.
55META_DEPS=	_meta_dep_before _meta_dep_after .META
56.endif
57.else
58# some targets need to be .PHONY - but not in meta mode
59META_NOPHONY=	.PHONY
60.endif
61META_NOPHONY?=
62META_COOKIE_RM?=
63META_COOKIE_TOUCH?=
64META_DEPS+=	${META_NOPHONY}
65