]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/local.sys.mk
Rework META_TARGETS so that it automatically adds META_DEPS to the targets.
[FreeBSD/FreeBSD.git] / share / mk / local.sys.mk
1 # $FreeBSD$
2
3 .if ${MK_DIRDEPS_BUILD} == "yes"
4 MAKE_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
22 MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
23 .endif
24 .endif
25
26 .if !empty(.OBJDIR)
27 OBJTOP?= ${.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 META_COOKIE_COND=       empty(.TARGET:M${.OBJDIR})
41 META_COOKIE=            ${COOKIE.${.TARGET}:U${${META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}}
42 META_COOKIE_RM=         @rm -f ${META_COOKIE}
43 META_COOKIE_TOUCH=      @touch ${META_COOKIE}
44 CLEANFILES+=            ${META_TARGETS}
45 _meta_dep_before:       .USEBEFORE .NOTMAIN
46         ${META_COOKIE_RM}
47 _meta_dep_after:        .USE .NOTMAIN
48         ${META_COOKIE_TOUCH}
49 # Attach this to a target to allow it to benefit from meta mode's
50 # not rerunning a command if it doesn't need to be considering its
51 # metafile/filemon-tracked dependencies.
52 META_DEPS=      _meta_dep_before _meta_dep_after .META
53 .endif
54 .else
55 # some targets need to be .PHONY - but not in meta mode
56 META_NOPHONY=   .PHONY
57 .endif
58 META_NOPHONY?=
59 META_COOKIE_RM?=
60 META_COOKIE_TOUCH?=
61 META_DEPS+=     ${META_NOPHONY}