2 # $Id: meta.sys.mk,v 1.19 2014/08/02 23:16:02 sjg Exp $
5 # @(#) Copyright (c) 2010, 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 # absoulte path to what we are reading.
27 _PARSEDIR = ${.PARSEDIR:tA}
29 META_MODE += meta verbose
30 .MAKE.MODE ?= ${META_MODE}
32 .if ${.MAKE.LEVEL} == 0
33 _make_mode := ${.MAKE.MODE} ${META_MODE}
34 .if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
35 # tell everyone we are not updating Makefile.depend*
36 UPDATE_DEPENDFILE = NO
37 .export UPDATE_DEPENDFILE
39 .if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon)
40 # we should not get upset
41 META_MODE += nofilemon
46 .if !defined(NO_SILENT)
47 .if ${MAKE_VERSION} > 20110818
48 # only be silent when we have a .meta file
49 META_MODE += silent=yes
55 # make defaults .MAKE.DEPENDFILE to .depend
56 # that won't work for us.
57 .if ${.MAKE.DEPENDFILE} == ".depend"
58 .undef .MAKE.DEPENDFILE
61 # if you don't cross build for multiple MACHINEs concurrently, then
62 # .MAKE.DEPENDFILE = Makefile.depend
63 # probably makes sense - you can set that in local.sys.mk
64 .MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE}
66 # we use the pseudo machine "host" for the build host.
67 # this should be taken care of before we get here
68 .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
72 .if ${.MAKE.LEVEL} == 0
73 # it can be handy to know which MACHINE kicked off the build
74 # for example, if using Makefild.depend for multiple machines,
75 # allowing only MACHINE0 to update can keep things simple.
76 MACHINE0 := ${MACHINE}
79 .if defined(PYTHON) && exists(${PYTHON})
80 # we prefer the python version of this - it is much faster
81 META2DEPS ?= ${.PARSEDIR}/meta2deps.py
83 META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
85 META2DEPS := ${META2DEPS}
89 MAKE_PRINT_VAR_ON_ERROR += \
96 .if !defined(SB) && defined(SRCTOP)
99 ERROR_LOGDIR ?= ${SB}/error
100 meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
102 # we are not interested in make telling us a failure happened elsewhere
104 _metaError: .NOMETA .NOTMAIN
105 -@[ "${.ERROR_META_FILE}" ] && { \
106 grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
107 mkdir -p ${meta_error_log:H}; \
108 cp ${.ERROR_META_FILE} ${meta_error_log}; \
109 echo "ERROR: log ${meta_error_log}" >&2; }; :
113 # Are we, after all, in meta mode?
114 .if ${.MAKE.MODE:Uno:Mmeta*} != ""
115 MKDEP_MK = meta.autodep.mk
117 # if we think we are updating dependencies,
118 # then filemon had better be present
119 .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon)
120 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
123 .if ${.MAKE.LEVEL} == 0
124 # make sure dirdeps target exists and do it first
129 .if defined(ALL_MACHINES)
130 # the first .MAIN: is what counts
131 # by default dirdeps is all we want at level0
133 # tell dirdeps.mk what we want
136 .if ${.TARGETS:Nall} == ""
137 # it works best if we do everything via sub-makes
138 BUILD_AT_LEVEL0 ?= no