]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/local.sys.mk
META_MODE: Show .ERROR_CMD in error.
[FreeBSD/FreeBSD.git] / share / mk / local.sys.mk
1 # $FreeBSD$
2
3 .if ${MK_DIRDEPS_BUILD} == "yes" || ${MK_META_MODE} == "yes"
4
5 # Not in the below list as it may make sense for non-meta mode
6 # eventually.  meta.sys.mk (DIRDEPS_BUILD) also already adds these in.
7 .if ${MK_DIRDEPS_BUILD} == "no" && ${MK_META_MODE} == "yes"
8 MAKE_PRINT_VAR_ON_ERROR += \
9         .ERROR_TARGET \
10         .ERROR_META_FILE \
11         .MAKE.LEVEL \
12         MAKEFILE \
13         .MAKE.MODE
14 .endif
15
16 _ERROR_CMD=${sed -n '/^CMD/s,^CMD ,,p' ${.ERROR_META_FILE}:L:sh}
17 MAKE_PRINT_VAR_ON_ERROR+= \
18         _ERROR_CMD \
19         .CURDIR \
20         .MAKE \
21         .OBJDIR \
22         .TARGETS \
23         DESTDIR \
24         LD_LIBRARY_PATH \
25         MACHINE \
26         MACHINE_ARCH \
27         MAKEOBJDIRPREFIX \
28         MAKESYSPATH \
29         MAKE_VERSION \
30         PATH \
31         SRCTOP \
32         OBJTOP \
33         ${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
34
35 .if ${.MAKE.LEVEL} > 0
36 MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
37 .endif
38 .endif
39
40 .if !empty(.OBJDIR)
41 OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
42 .endif
43
44 .include "src.sys.mk"
45
46 .if ${.MAKE.MODE:Mmeta*} != ""
47 # we can afford to use cookies to prevent some targets
48 # re-running needlessly but only when using filemon.
49 # Targets that should support the meta mode cookie handling should just be
50 # added to META_TARGETS.  If bsd.sys.mk cannot be included then ${META_DEPS}
51 # should be added as a target dependency as well.  Otherwise the target
52 # is added to in bsd.sys.mk since it comes last.
53 .if ${.MAKE.MODE:Mnofilemon} == ""
54 # Prepend .OBJDIR if not already there.
55 _META_COOKIE_COND=      "${.TARGET:M${.OBJDIR}/*}" == ""
56 _META_COOKIE_DEFAULT=   ${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}
57 # Use the default if COOKIE.${.TARGET} is not defined.
58 META_COOKIE=            ${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}}
59 META_COOKIE_RM=         @rm -f ${META_COOKIE}
60 META_COOKIE_TOUCH=      @touch ${META_COOKIE}
61 CLEANFILES+=            ${META_TARGETS}
62 _meta_dep_before:       .USEBEFORE .NOTMAIN
63         ${META_COOKIE_RM}
64 _meta_dep_after:        .USE .NOTMAIN
65         ${META_COOKIE_TOUCH}
66 # Attach this to a target to allow it to benefit from meta mode's
67 # not rerunning a command if it doesn't need to be considering its
68 # metafile/filemon-tracked dependencies.
69 META_DEPS=      _meta_dep_before _meta_dep_after .META
70 .endif
71 .else
72 # some targets need to be .PHONY - but not in meta mode
73 META_NOPHONY=   .PHONY
74 .endif
75 META_NOPHONY?=
76 META_COOKIE_RM?=
77 META_COOKIE_TOUCH?=
78 META_DEPS+=     ${META_NOPHONY}