blob: 1104204dc8c9877e6bd51fd61bb198d6aa180258 (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: meta.sys.mk,v 1.56 2024/11/22 23:51:48 sjg Exp $
#
# @(#) Copyright (c) 2010-2023, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
# include this if you want to enable meta mode
# for maximum benefit, requires filemon(4) driver.
# absolute path to what we are reading.
_PARSEDIR ?= ${.PARSEDIR:tA}
.-include <local.meta.sys.env.mk>
.if !defined(SYS_MK_DIR)
SYS_MK_DIR := ${_PARSEDIR}
.endif
.if !target(.ERROR)
META_MODE += meta
.if empty(.MAKEFLAGS:M-s)
META_MODE += verbose
.endif
.if ${MAKE_VERSION:U0} > 20130323 && empty(.MAKE.PATH_FILEMON)
# we do not support filemon
META_MODE += nofilemon
MKDEP_MK ?= auto.dep.mk
.endif
# META_MODE_XTRAS makes it easier to add things like 'env'
# from the command line when debugging
# :U avoids problems from := below
META_MODE += ${META_MODE_XTRAS:U}
.MAKE.MODE ?= ${META_MODE}
_filemon := ${.MAKE.PATH_FILEMON:U/dev/filemon}
.if empty(UPDATE_DEPENDFILE)
_make_mode := ${.MAKE.MODE} ${META_MODE}
.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
# tell everyone we are not updating Makefile.depend*
UPDATE_DEPENDFILE = NO
.export UPDATE_DEPENDFILE
.endif
.if ${_filemon:T:Mfilemon} == "filemon"
.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(${_filemon})
# we should not get upset
META_MODE += nofilemon
.export META_MODE
.endif
.endif
.endif
.if !defined(NO_SILENT)
.if ${MAKE_VERSION} > 20110818
# only be silent when we have a .meta file
META_MODE += silent=yes
.else
.SILENT:
.endif
.endif
.if ${MK_DIRDEPS_BUILD:Uno} == "yes"
.if !defined(META2DEPS)
.if defined(PYTHON) && exists(${PYTHON})
# we prefer the python version of this - it is much faster
META2DEPS ?= ${.PARSEDIR}/meta2deps.py
.else
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
.endif
META2DEPS := ${META2DEPS}
.export META2DEPS
.endif
MAKE_PRINT_VAR_ON_ERROR += \
.ERROR_TARGET \
.ERROR_EXIT \
.ERROR_META_FILE \
.MAKE.LEVEL \
MAKEFILE \
.MAKE.MODE
MK_META_ERROR_TARGET = yes
.endif
.if ${MK_META_ERROR_TARGET:Uno} == "yes"
.if !defined(SB) && defined(SRCTOP)
SB = ${SRCTOP:H}
.endif
ERROR_LOGDIR ?= ${SB}/error
meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
.if ${.MAKE.LEVEL} == 0 && !empty(NEWLOG_SH) && exists(${ERROR_LOGDIR})
.BEGIN: _rotateErrorLog
_rotateErrorLog: .NOMETA .NOTMAIN
@${NEWLOG_SH} -d -S -n ${ERROR_LOG_GENS:U4} ${ERROR_LOGDIR}
.endif
.ERROR: _metaError
# We are interested here in the target(s) that caused the build to fail.
# We want to ignore targets that were "aborted" due to failure
# elsewhere per the message below or a sub-make may just exit 6.
_metaError: .NOMETA .NOTMAIN
-@[ ${.ERROR_EXIT:U0} = 6 ] && exit 0; \
[ "${.ERROR_META_FILE}" ] && { \
grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
mkdir -p ${meta_error_log:H}; \
cp ${.ERROR_META_FILE} ${meta_error_log}; \
echo "ERROR: log ${meta_error_log}" >&2; }; :
.endif
.endif
# Are we, after all, in meta mode?
.if ${.MAKE.MODE:Uno:Mmeta*} != ""
MKDEP_MK ?= meta.autodep.mk
# we can afford to use cookies to prevent some targets
# re-running needlessly
META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
META_NOPHONY=
META_NOECHO= :
# some targets involve old pre-built targets
# ignore mtime of shell
# and mtime of makefiles does not matter in meta mode
.MAKE.META.IGNORE_PATHS += \
${MAKEFILE} \
${MAKE_SHELL} \
${SHELL} \
${SYS_MK_DIR} \
.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
.if ${.MAKEFLAGS:Uno:M-k} != ""
# make this more obvious
.warning Setting UPDATE_DEPENDFILE=NO due to -k
UPDATE_DEPENDFILE= NO
.export UPDATE_DEPENDFILE
.elif ${_filemon:T} == "filemon" && !exists(${_filemon})
.error ${.newline}ERROR: The filemon module (${_filemon}) is not loaded.
.endif
.endif
.else # in meta mode?
META_COOKIE_TOUCH=
# some targets need to be .PHONY in non-meta mode
META_NOPHONY= .PHONY
META_NOECHO= echo
.endif # in meta mode?
.-include <local.meta.sys.mk>
|