1
2.if !target(_${_this}_)
3_${_this}_: .NOTMAIN
4
5.if ${MK_DIRDEPS_BUILD} == "yes" || ${MK_META_MODE} == "yes"
6
7# Not in the below list as it may make sense for non-meta mode
8# eventually.  meta.sys.mk (DIRDEPS_BUILD) also already adds these in.
9.if ${MK_DIRDEPS_BUILD} == "no" && ${MK_META_MODE} == "yes"
10MAKE_PRINT_VAR_ON_ERROR += \
11	.ERROR_TARGET \
12	.ERROR_META_FILE \
13	.MAKE.LEVEL \
14	MAKEFILE \
15	.MAKE.MODE
16.endif
17
18_ERROR_CMD_EXEC=	${sed -n '/^CMD/s,^CMD \(.*\),\1;,p' ${.ERROR_META_FILE}:L:sh}
19_ERROR_CMD=		${!empty(.ERROR_META_FILE):?${_ERROR_CMD_EXEC}:.PHONY}
20MAKE_PRINT_VAR_ON_ERROR+= \
21	_ERROR_CMD \
22	.CURDIR \
23	.MAKE \
24	.OBJDIR \
25	.TARGETS \
26	CPUTYPE \
27	DESTDIR \
28	LD_LIBRARY_PATH \
29	MACHINE \
30	MACHINE_ARCH \
31	MACHINE_CPUARCH \
32	MAKEOBJDIRPREFIX \
33	MAKESYSPATH \
34	MAKE_VERSION \
35	PATH \
36	SRCTOP \
37	OBJTOP \
38	${MAKE_PRINT_VAR_ON_ERROR_XTRAS}
39
40# Meta mode may rebuild targets that then fail. The next build won't detect
41# the meta mode change. Not all targets have a 'rm ${.TARGET}' in them
42# so force it.
43.DELETE_ON_ERROR:
44
45.if ${.MAKE.LEVEL} > 0
46MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
47.endif
48.endif
49
50.if !empty(.OBJDIR)
51OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
52.endif
53
54.if !empty(LIBDIR)
55_PREMK_LIBDIR:=	${LIBDIR}
56.endif
57
58.include "src.sys.mk"
59.-include <site.sys.mk>
60
61# this will be set via local.meta.sys.env.mk if appropriate
62MK_host_egacy?= no
63
64.if ${.MAKE.MODE:Mmeta*} != ""
65# we can afford to use cookies to prevent some targets
66# re-running needlessly but only when using filemon.
67# Targets that should support the meta mode cookie handling should just be
68# added to META_TARGETS.  If bsd.sys.mk cannot be included then ${META_DEPS}
69# should be added as a target dependency as well.  Otherwise the target
70# is added to in bsd.sys.mk since it comes last.
71.if ${.MAKE.MODE:Mnofilemon} == ""
72# Prepend .OBJDIR if not already there.
73_META_COOKIE_COND=	"${.TARGET:M${.OBJDIR}/*}" == ""
74_META_COOKIE_DEFAULT=	${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}
75# Use the default if COOKIE.${.TARGET} is not defined.
76META_COOKIE=		${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}}
77META_COOKIE_RM=		@rm -f ${META_COOKIE}
78META_COOKIE_TOUCH=	@touch ${META_COOKIE}
79CLEANFILES+=		${META_TARGETS}
80_meta_dep_before:	.USEBEFORE .NOTMAIN
81	${META_COOKIE_RM}
82_meta_dep_after:	.USE .NOTMAIN
83	${META_COOKIE_TOUCH}
84# Attach this to a target to allow it to benefit from meta mode's
85# not rerunning a command if it doesn't need to be considering its
86# metafile/filemon-tracked dependencies.
87META_DEPS=	_meta_dep_before _meta_dep_after .META
88.endif
89.else
90# some targets need to be .PHONY - but not in meta mode
91META_NOPHONY=	.PHONY
92.endif
93META_NOPHONY?=
94META_COOKIE_RM?=
95META_COOKIE_TOUCH?=
96META_DEPS+=	${META_NOPHONY}
97
98.if ${MK_DIRDEPS_BUILD} == "yes"
99.if ${MACHINE:Nhost*:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE}
100# cross-building
101CROSS_TARGET_FLAGS?= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION}
102CFLAGS+= ${CROSS_TARGET_FLAGS}
103ACFLAGS+= ${CROSS_TARGET_FLAGS}
104.endif
105.endif
106
107.endif
108