Update to bmake-20131001 on the vendor branch
[dragonfly.git] / contrib / bmake / mk / meta.sys.mk
1 # $Id: meta.sys.mk,v 1.16 2012/07/03 05:26:00 sjg Exp $
2
3 #
4 #       @(#) Copyright (c) 2010, Simon J. Gerraty
5 #
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
11 #       left intact. 
12 #      
13 #       Please send copies of changes and bug-fixes to:
14 #       sjg@crufty.net
15 #
16
17 # include this if you want to enable meta mode
18 # for maximum benefit, requires filemon(4) driver.
19
20 .if ${MAKE_VERSION:U0} > 20100901
21 .if !target(.ERROR)
22
23
24 META_MODE += meta verbose
25 .MAKE.MODE ?= ${META_MODE}
26
27 .if ${.MAKE.LEVEL} == 0
28 _make_mode := ${.MAKE.MODE} ${META_MODE}
29 .if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != ""
30 # tell everyone we are not updating Makefile.depend*
31 UPDATE_DEPENDFILE = NO
32 .export UPDATE_DEPENDFILE
33 .endif
34 .if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon)
35 # we should not get upset
36 META_MODE += nofilemon
37 .export META_MODE
38 .endif
39 .endif
40
41 .if !defined(NO_SILENT)
42 .if ${MAKE_VERSION} > 20110818
43 # only be silent when we have a .meta file
44 META_MODE += silent=yes
45 .else
46 .SILENT:
47 .endif
48 .endif
49
50 # make defaults .MAKE.DEPENDFILE to .depend
51 # that won't work for us.
52 .if ${.MAKE.DEPENDFILE} == ".depend"
53 .undef .MAKE.DEPENDFILE
54 .endif
55
56 # if you don't cross build for multiple MACHINEs concurrently, then
57 # .MAKE.DEPENDFILE = Makefile.depend
58 # probably makes sense - you can set that in local.sys.mk 
59 .MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE}
60
61 # we use the pseudo machine "host" for the build host.
62 # this should be taken care of before we get here
63 .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
64 MACHINE = host
65 .endif
66
67 .if ${.MAKE.LEVEL} == 0
68 # it can be handy to know which MACHINE kicked off the build
69 # for example, if using Makefild.depend for multiple machines,
70 # allowing only MACHINE0 to update can keep things simple.
71 MACHINE0 := ${MACHINE}
72
73 .if defined(PYTHON) && exists(${PYTHON})
74 # we prefer the python version of this - it is much faster
75 META2DEPS ?= ${.PARSEDIR}/meta2deps.py
76 .else
77 META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
78 .endif
79 META2DEPS := ${META2DEPS}
80 .export META2DEPS
81 .endif
82
83 MAKE_PRINT_VAR_ON_ERROR += \
84         .ERROR_TARGET \
85         .ERROR_META_FILE \
86         .MAKE.LEVEL \
87         MAKEFILE \
88         .MAKE.MODE
89
90 .if !defined(SB) && defined(SRCTOP)
91 SB = ${SRCTOP:H}
92 .endif
93 ERROR_LOGDIR ?= ${SB}/error
94 meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
95
96 # we are not interested in make telling us a failure happened elsewhere
97 .ERROR: _metaError
98 _metaError: .NOMETA .NOTMAIN
99         -@[ "${.ERROR_META_FILE}" ] && { \
100         grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
101         mkdir -p ${meta_error_log:H}; \
102         cp ${.ERROR_META_FILE} ${meta_error_log}; \
103         echo "ERROR: log ${meta_error_log}" >&2; }; :
104
105 .endif
106
107 # Are we, after all, in meta mode?
108 .if ${.MAKE.MODE:Mmeta*} != ""
109 MKDEP = meta.autodep
110
111 .if ${.MAKE.LEVEL} == 0
112 # make sure dirdeps target exists and do it first
113 all: dirdeps .WAIT
114 dirdeps:
115 .NOPATH: dirdeps
116
117 .if defined(ALL_MACHINES)
118 # the first .MAIN: is what counts
119 # by default dirdeps is all we want at level0
120 .MAIN: dirdeps
121 # tell dirdeps.mk what we want
122 BUILD_AT_LEVEL0 = no
123 .endif
124
125 .if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
126 # it works best if we do everything via sub-makes
127 BUILD_AT_LEVEL0 ?= no
128 .endif
129 BUILD_AT_LEVEL0 ?= yes
130 .endif
131
132 # if we think we are updating dependencies, 
133 # then filemon had better be present
134 .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon)
135 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
136 .endif
137
138 .endif
139 .endif