1 # $Id: meta.sys.mk,v 1.29 2016/08/13 17:51:45 sjg Exp $
4 # @(#) Copyright (c) 2010, Simon J. Gerraty
6 # This file is provided in the hope that it will
7 # be of use. There is absolutely NO WARRANTY.
8 # Permission to copy, redistribute or otherwise
9 # use this file is hereby granted provided that
10 # the above copyright notice and this notice are
13 # Please send copies of changes and bug-fixes to:
17 # include this if you want to enable meta mode
18 # for maximum benefit, requires filemon(4) driver.
20 .if
${MAKE_VERSION
:U0
} > 20100901
23 .
-include <local.meta.sys.mk
>
25 # absoulte path to what we are reading.
26 _PARSEDIR
= ${.PARSEDIR
:tA
}
28 .if
!defined
(SYS_MK_DIR
)
29 SYS_MK_DIR
:= ${_PARSEDIR}
32 META_MODE
+= meta verbose
33 .MAKE.MODE ?
= ${META_MODE}
35 .if
${.MAKE.LEVEL
} == 0
36 _make_mode
:= ${.MAKE.MODE
} ${META_MODE}
37 .if
${_make_mode
:M
*read
*} != "" ||
${_make_mode
:M
*nofilemon
*} != ""
38 # tell everyone we are not updating Makefile.depend*
39 UPDATE_DEPENDFILE
= NO
40 .
export UPDATE_DEPENDFILE
42 .if
${UPDATE_DEPENDFILE
:Uyes
:tl
} == "no" && !exists
(/dev
/filemon
)
43 # we should not get upset
44 META_MODE
+= nofilemon
49 .if
!defined
(NO_SILENT
)
50 .if
${MAKE_VERSION} > 20110818
51 # only be silent when we have a .meta file
52 META_MODE
+= silent
=yes
58 # we use the pseudo machine "host" for the build host.
59 # this should be taken care of before we get here
60 .if
${OBJTOP
:Ua
} == ${HOST_OBJTOP
:Ub
}
64 .if
${.MAKE.LEVEL
} == 0
65 # it can be handy to know which MACHINE kicked off the build
66 # for example, if using Makefild.depend for multiple machines,
67 # allowing only MACHINE0 to update can keep things simple.
68 MACHINE0
:= ${MACHINE}
71 .if defined
(PYTHON
) && exists
(${PYTHON})
72 # we prefer the python version of this - it is much faster
73 META2DEPS ?
= ${.PARSEDIR
}/meta2deps.py
75 META2DEPS ?
= ${.PARSEDIR
}/meta2deps.sh
77 META2DEPS
:= ${META2DEPS}
81 MAKE_PRINT_VAR_ON_ERROR
+= \
88 .if
!defined
(SB
) && defined
(SRCTOP
)
91 ERROR_LOGDIR ?
= ${SB}/error
92 meta_error_log
= ${ERROR_LOGDIR}/meta-
${.MAKE.PID
}.log
94 # we are not interested in make telling us a failure happened elsewhere
96 _metaError
: .NOMETA .NOTMAIN
97 -@
[ "${.ERROR_META_FILE}" ] && { \
98 grep
-q
'failure has been detected in another branch' ${.ERROR_META_FILE
} && exit
0; \
99 mkdir
-p
${meta_error_log
:H
}; \
100 cp
${.ERROR_META_FILE
} ${meta_error_log}; \
101 echo
"ERROR: log ${meta_error_log}" >&2; }; :
106 # some targets need to be .PHONY in non-meta mode
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
}}
127 # some targets involve old pre-built targets
128 # ignore mtime of shell
129 # and mtime of makefiles does not matter in meta mode
130 .MAKE.META.IGNORE_PATHS
+= \
135 .if
${UPDATE_DEPENDFILE
:Uyes
:tl
} != "no"
136 .if
${.MAKEFLAGS
:Uno
:M-k
} != ""
137 # make this more obvious
138 .warning Setting UPDATE_DEPENDFILE
=NO due to
-k
139 UPDATE_DEPENDFILE
= NO
140 .
export UPDATE_DEPENDFILE
141 .elif
!exists
(/dev
/filemon
)
142 .error
${.newline
}ERROR
: The filemon module
(/dev
/filemon
) is not loaded.
146 .if
${.MAKE.LEVEL
} == 0
147 # make sure dirdeps target exists and do it first
152 .if defined
(ALL_MACHINES
)
153 # the first .MAIN: is what counts
154 # by default dirdeps is all we want at level0
156 # tell dirdeps.mk what we want
159 .if
${.TARGETS
:Nall
} == ""
160 # it works best if we do everything via sub-makes
161 BUILD_AT_LEVEL0 ?
= no