aboutsummaryrefslogtreecommitdiff
path: root/share/mk/local.sys.mk
blob: 39605c05e129f01d5454e077af788039e349a6d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# $FreeBSD$

.if !target(_${_this}_)
_${_this}_: .NOTMAIN

.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

_ERROR_CMD_EXEC=	${sed -n '/^CMD/s,^CMD \(.*\),\1;,p' ${.ERROR_META_FILE}:L:sh}
_ERROR_CMD=		${!empty(.ERROR_META_FILE):?${_ERROR_CMD_EXEC}:.PHONY}
MAKE_PRINT_VAR_ON_ERROR+= \
	_ERROR_CMD \
	.CURDIR \
	.MAKE \
	.OBJDIR \
	.TARGETS \
	CPUTYPE \
	DESTDIR \
	LD_LIBRARY_PATH \
	MACHINE \
	MACHINE_ARCH \
	MACHINE_CPUARCH \
	MAKEOBJDIRPREFIX \
	MAKESYSPATH \
	MAKE_VERSION \
	PATH \
	SRCTOP \
	OBJTOP \
	${MAKE_PRINT_VAR_ON_ERROR_XTRAS}

# 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:

.if ${.MAKE.LEVEL} > 0
MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
.endif
.endif

.if !empty(.OBJDIR)
OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
.endif

.if !empty(LIBDIR)
_PREMK_LIBDIR:=	${LIBDIR}
.endif

.include "src.sys.mk"
.-include <site.sys.mk>

.if ${.MAKE.MODE:Mmeta*} != ""
# we can afford to use cookies to prevent some targets
# re-running needlessly but only when using filemon.
# 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.
.if ${.MAKE.MODE:Mnofilemon} == ""
# 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}}
META_COOKIE_RM=		@rm -f ${META_COOKIE}
META_COOKIE_TOUCH=	@touch ${META_COOKIE}
CLEANFILES+=		${META_TARGETS}
_meta_dep_before:	.USEBEFORE .NOTMAIN
	${META_COOKIE_RM}
_meta_dep_after:	.USE .NOTMAIN
	${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
.endif
.else
# some targets need to be .PHONY - but not in meta mode
META_NOPHONY=	.PHONY
.endif
META_NOPHONY?=
META_COOKIE_RM?=
META_COOKIE_TOUCH?=
META_DEPS+=	${META_NOPHONY}

.endif