2 # $Id: meta.sys.mk,v 1.42 2021/12/13 05:50:55 sjg Exp $
5 # @(#) Copyright (c) 2010-2021, 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 .if ${MAKE_VERSION:U0} > 20130323 && empty(.MAKE.PATH_FILEMON)
35 # we do not support filemon
36 META_MODE += nofilemon
37 MKDEP_MK ?= auto.dep.mk
40 .MAKE.MODE ?= ${META_MODE}
42 _filemon := ${.MAKE.PATH_FILEMON:U/dev/filemon}
44 .if empty(UPDATE_DEPENDFILE)
45 _make_mode := ${.MAKE.MODE} ${META_MODE}
46 .if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
47 # tell everyone we are not updating Makefile.depend*
48 UPDATE_DEPENDFILE = NO
49 .export UPDATE_DEPENDFILE
51 .if ${_filemon:T:Mfilemon} == "filemon"
52 .if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(${_filemon})
53 # we should not get upset
54 META_MODE += nofilemon
60 .if !defined(NO_SILENT)
61 .if ${MAKE_VERSION} > 20110818
62 # only be silent when we have a .meta file
63 META_MODE += silent=yes
69 # we use the pseudo machine "host" for the build host.
70 # this should be taken care of before we get here
71 .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
75 .if !defined(MACHINE0)
76 # it can be handy to know which MACHINE kicked off the build
77 # for example, if using Makefild.depend for multiple machines,
78 # allowing only MACHINE0 to update can keep things simple.
79 MACHINE0 := ${MACHINE}
83 .if !defined(META2DEPS)
84 .if defined(PYTHON) && exists(${PYTHON})
85 # we prefer the python version of this - it is much faster
86 META2DEPS ?= ${.PARSEDIR}/meta2deps.py
88 META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
90 META2DEPS := ${META2DEPS}
94 MAKE_PRINT_VAR_ON_ERROR += \
101 .if !defined(SB) && defined(SRCTOP)
104 ERROR_LOGDIR ?= ${SB}/error
105 meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
107 # we are not interested in make telling us a failure happened elsewhere
109 _metaError: .NOMETA .NOTMAIN
110 -@[ "${.ERROR_META_FILE}" ] && { \
111 grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
112 mkdir -p ${meta_error_log:H}; \
113 cp ${.ERROR_META_FILE} ${meta_error_log}; \
114 echo "ERROR: log ${meta_error_log}" >&2; }; :
118 # Are we, after all, in meta mode?
119 .if ${.MAKE.MODE:Uno:Mmeta*} != ""
120 MKDEP_MK ?= meta.autodep.mk
122 .if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == ""
123 # this does all the smarts of setting .MAKE.DEPENDFILE
124 .-include <sys.dependfile.mk>
125 # check if we got anything sane
126 .if ${.MAKE.DEPENDFILE} == ".depend"
127 .undef .MAKE.DEPENDFILE
129 .MAKE.DEPENDFILE ?= Makefile.depend
132 # we can afford to use cookies to prevent some targets
133 # re-running needlessly
134 META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
138 # some targets involve old pre-built targets
139 # ignore mtime of shell
140 # and mtime of makefiles does not matter in meta mode
141 .MAKE.META.IGNORE_PATHS += \
148 .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
149 .if ${.MAKEFLAGS:Uno:M-k} != ""
150 # make this more obvious
151 .warning Setting UPDATE_DEPENDFILE=NO due to -k
152 UPDATE_DEPENDFILE= NO
153 .export UPDATE_DEPENDFILE
154 .elif ${_filemon:T} == "filemon" && !exists(${_filemon})
155 .error ${.newline}ERROR: The filemon module (${_filemon}) is not loaded.
159 .if ${.MAKE.LEVEL} == 0
160 .if ${MK_DIRDEPS_BUILD:Uyes} == "yes"
161 # make sure dirdeps target exists and do it first
166 .if defined(ALL_MACHINES)
167 # the first .MAIN: is what counts
168 # by default dirdeps is all we want at level0
176 # some targets need to be .PHONY in non-meta mode