2 # $Id: meta.sys.mk,v 1.38 2020/08/19 17:51:53 sjg Exp $
5 # @(#) Copyright (c) 2010-2020, Simon J. Gerraty
7 # This file is provided in the hope that it will
8 # be of use. There is absolutely NO WARRANTY.
9 # Permission to copy, redistribute or otherwise
10 # use this file is hereby granted provided that
11 # the above copyright notice and this notice are
14 # Please send copies of changes and bug-fixes to:
18 # include this if you want to enable meta mode
19 # for maximum benefit, requires filemon(4) driver.
21 .if ${MAKE_VERSION:U0} > 20100901
24 .-include <local.meta.sys.mk>
26 # absolute path to what we are reading.
27 _PARSEDIR = ${.PARSEDIR:tA}
29 .if !defined(SYS_MK_DIR)
30 SYS_MK_DIR := ${_PARSEDIR}
33 META_MODE += meta verbose
34 .MAKE.MODE ?= ${META_MODE}
36 .if ${.MAKE.LEVEL} == 0
37 _make_mode := ${.MAKE.MODE} ${META_MODE}
38 .if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
39 # tell everyone we are not updating Makefile.depend*
40 UPDATE_DEPENDFILE = NO
41 .export UPDATE_DEPENDFILE
43 .if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon)
44 # we should not get upset
45 META_MODE += nofilemon
50 .if !defined(NO_SILENT)
51 .if ${MAKE_VERSION} > 20110818
52 # only be silent when we have a .meta file
53 META_MODE += silent=yes
59 # we use the pseudo machine "host" for the build host.
60 # this should be taken care of before we get here
61 .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
65 .if !defined(MACHINE0)
66 # it can be handy to know which MACHINE kicked off the build
67 # for example, if using Makefild.depend for multiple machines,
68 # allowing only MACHINE0 to update can keep things simple.
69 MACHINE0 := ${MACHINE}
73 .if !defined(META2DEPS)
74 .if defined(PYTHON) && exists(${PYTHON})
75 # we prefer the python version of this - it is much faster
76 META2DEPS ?= ${.PARSEDIR}/meta2deps.py
78 META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
80 META2DEPS := ${META2DEPS}
84 MAKE_PRINT_VAR_ON_ERROR += \
91 .if !defined(SB) && defined(SRCTOP)
94 ERROR_LOGDIR ?= ${SB}/error
95 meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
97 # we are not interested in make telling us a failure happened elsewhere
99 _metaError: .NOMETA .NOTMAIN
100 -@[ "${.ERROR_META_FILE}" ] && { \
101 grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
102 mkdir -p ${meta_error_log:H}; \
103 cp ${.ERROR_META_FILE} ${meta_error_log}; \
104 echo "ERROR: log ${meta_error_log}" >&2; }; :
108 # Are we, after all, in meta mode?
109 .if ${.MAKE.MODE:Uno:Mmeta*} != ""
110 MKDEP_MK = meta.autodep.mk
112 .if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == ""
113 # this does all the smarts of setting .MAKE.DEPENDFILE
114 .-include <sys.dependfile.mk>
115 # check if we got anything sane
116 .if ${.MAKE.DEPENDFILE} == ".depend"
117 .undef .MAKE.DEPENDFILE
119 .MAKE.DEPENDFILE ?= Makefile.depend
122 # we can afford to use cookies to prevent some targets
123 # re-running needlessly
124 META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
128 # some targets involve old pre-built targets
129 # ignore mtime of shell
130 # and mtime of makefiles does not matter in meta mode
131 .MAKE.META.IGNORE_PATHS += \
138 .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
139 .if ${.MAKEFLAGS:Uno:M-k} != ""
140 # make this more obvious
141 .warning Setting UPDATE_DEPENDFILE=NO due to -k
142 UPDATE_DEPENDFILE= NO
143 .export UPDATE_DEPENDFILE
144 .elif !exists(/dev/filemon)
145 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
149 .if ${.MAKE.LEVEL} == 0
150 # make sure dirdeps target exists and do it first
155 .if defined(ALL_MACHINES)
156 # the first .MAIN: is what counts
157 # by default dirdeps is all we want at level0
164 # some targets need to be .PHONY in non-meta mode