Deleted Added
full compact
gendirdeps.mk (246223) gendirdeps.mk (249033)
1# $Id: gendirdeps.mk,v 1.10 2012/06/30 00:37:50 sjg Exp $
1# $Id: gendirdeps.mk,v 1.21 2013/03/28 20:01:05 sjg Exp $
2
2
3# Copyright (c) 2010, Juniper Networks, Inc.
3# Copyright (c) 2010-2013, Juniper Networks, Inc.
4# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the

--- 33 unchanged lines hidden (view full) ---

45.MAKE.MODE = compat
46
47all:
48
49_CURDIR ?= ${.CURDIR}
50_OBJDIR ?= ${.OBJDIR}
51_OBJTOP ?= ${OBJTOP}
52_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the

--- 33 unchanged lines hidden (view full) ---

46.MAKE.MODE = compat
47
48all:
49
50_CURDIR ?= ${.CURDIR}
51_OBJDIR ?= ${.OBJDIR}
52_OBJTOP ?= ${OBJTOP}
53_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
53_objroot ?= ${_OBJROOT:tA}
54.if ${_OBJROOT:M*/}
55_slash=/
56.else
57_slash=
58.endif
59_objroot ?= ${_OBJROOT:tA}${_slash}
54
55_this = ${.PARSEDIR}/${.PARSEFILE}
56
57# remember what to make
58_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
59
60# We do _not_ want to read our own output!
61.MAKE.DEPENDFILE = /dev/null

--- 39 unchanged lines hidden (view full) ---

101_sh_x =
102_py_d =
103.endif
104
105.if ${META2DEPS:E} == "py"
106# we can afford to do this all the time.
107DPDEPS ?= no
108META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d} \
60
61_this = ${.PARSEDIR}/${.PARSEFILE}
62
63# remember what to make
64_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
65
66# We do _not_ want to read our own output!
67.MAKE.DEPENDFILE = /dev/null

--- 39 unchanged lines hidden (view full) ---

107_sh_x =
108_py_d =
109.endif
110
111.if ${META2DEPS:E} == "py"
112# we can afford to do this all the time.
113DPDEPS ?= no
114META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d} \
109 -R ${RELDIR} -H ${HOST_TARGET} -O ${M2D_OBJROOT}
115 -R ${RELDIR} -H ${HOST_TARGET} \
116 ${M2D_OBJROOTS:O:u:@o@-O $o@}
117
110.if ${DPDEPS:tl} != "no"
111META2DEPS_CMD += -D ${DPDEPS}
112.endif
118.if ${DPDEPS:tl} != "no"
119META2DEPS_CMD += -D ${DPDEPS}
120.endif
121
122M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${_objroot}
123.if defined(SB_OBJROOT)
124M2D_OBJROOTS += ${SB_OBJROOT}
125.endif
113.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == ""
114# meta2deps.py only groks objroot
115# so we need to give it what it expects
126.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == ""
127# meta2deps.py only groks objroot
128# so we need to give it what it expects
116M2D_OBJROOT = ${OBJTOP}/
117# and tell it not to add machine qualifiers
118META2DEPS_ARGS += MACHINE=none
129# and tell it not to add machine qualifiers
130META2DEPS_ARGS += MACHINE=none
119.else
120.if defined(SB_OBJROOT)
121M2D_OBJROOT ?= ${SB_OBJROOT}
122.else
123M2D_OBJROOT = ${OBJTOP}/
124.endif
131.endif
125.endif
126.if defined(SB_BACKING_SB)
132.if defined(SB_BACKING_SB)
127META2DEPS_CMD += -S ${SB_BACKING_SB}/src -O ${SB_BACKING_SB}/${SB_OBJPREFIX}
133META2DEPS_CMD += -S ${SB_BACKING_SB}/src
134M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX}
128.endif
129META2DEPS_FILTER = sed 's,^src:,${SRCTOP}/,;s,^\([^/]\),${OBJTOP}/\1,' |
130.elif ${META2DEPS:E} == "sh"
131META2DEPS_CMD = ${_time} ${_sh_x} ${META2DEPS} \
132 OBJTOP=${_objtop} SB_OBJROOT=${_objroot}
133.else
134META2DEPS_CMD ?= ${META2DEPS}
135.endif

--- 14 unchanged lines hidden (view full) ---

150.warning ${dir_list:tW:C,.*(ERROR),\1,}
151.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
152# we are not going to update anything
153.else
154
155.if !empty(DPADD)
156_nonlibs := ${DPADD:T:Nlib*:N*include}
157.if !empty(_nonlibs)
135.endif
136META2DEPS_FILTER = sed 's,^src:,${SRCTOP}/,;s,^\([^/]\),${OBJTOP}/\1,' |
137.elif ${META2DEPS:E} == "sh"
138META2DEPS_CMD = ${_time} ${_sh_x} ${META2DEPS} \
139 OBJTOP=${_objtop} SB_OBJROOT=${_objroot}
140.else
141META2DEPS_CMD ?= ${META2DEPS}
142.endif

--- 14 unchanged lines hidden (view full) ---

157.warning ${dir_list:tW:C,.*(ERROR),\1,}
158.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
159# we are not going to update anything
160.else
161
162.if !empty(DPADD)
163_nonlibs := ${DPADD:T:Nlib*:N*include}
164.if !empty(_nonlibs)
158dir_list += ${_nonlibs:@x@${DPADD:M*/$x}@:H:tA}
165ddep_list =
166.for f in ${_nonlibs:@x@${DPADD:M*/$x}@}
167.if exists($f.dirdep)
168ddep_list += $f.dirdep
169.elif exists(${f:H}.dirdep)
170ddep_list += ${f:H}.dirdep
171.else
172dir_list += ${f:H:tA}
159.endif
173.endif
174.endfor
175.if !empty(ddep_list)
176ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
177 sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,;s,\.${MACHINE}$$,,'
178
179.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
180.info ${RELDIR}: raw_dir_list='${dir_list}'
181.info ${RELDIR}: ddeps='${ddeps}'
160.endif
182.endif
183dir_list += ${ddeps}
184.endif
185.endif
186.endif
161
162# DIRDEPS represent things that had to have been built first
163# so they should all be undir OBJTOP.
164# Note that ${_OBJTOP}/bsd/include/machine will get reported
165# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we
166# will want to visit bsd/include
167# so we add
168# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
169# to GENDIRDEPS_DIR_LIST_XTRAS
187
188# DIRDEPS represent things that had to have been built first
189# so they should all be undir OBJTOP.
190# Note that ${_OBJTOP}/bsd/include/machine will get reported
191# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we
192# will want to visit bsd/include
193# so we add
194# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
195# to GENDIRDEPS_DIR_LIST_XTRAS
196_objtops = ${OBJTOP} ${_OBJTOP} ${_obtop}
197_objtops := ${_objtops:O:u}
170dirdep_list = \
198dirdep_list = \
171 ${dir_list:M${_objtop}*/*:C,${_objtop}[^/]*/,,} \
199 ${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \
172 ${GENDIRDEPS_DIR_LIST_XTRAS}
173
200 ${GENDIRDEPS_DIR_LIST_XTRAS}
201
202# sort longest first
203M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]}
204
174# anything we use from an object dir other than ours
175# needs to be qualified with its .<machine> suffix
176# (we used the pseudo machine "host" for the HOST_TARGET).
205# anything we use from an object dir other than ours
206# needs to be qualified with its .<machine> suffix
207# (we used the pseudo machine "host" for the HOST_TARGET).
177qualdir_list = \
178 ${dir_list:M${_objroot}*/*/*:N${SRCTOP}*:N${_objtop}*:C,${_objroot}([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
208skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
209.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}}
210# we need := so only skip_ql to this point applies
211ql := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
212qualdir_list += ${ql}
213skip_ql+= $o*
214.endfor
179
215
180.if ${_OBJROOT} != ${_objroot}
181dirdep_list += \
182 ${dir_list:M${_OBJTOP}*/*:C,${_OBJTOP}[^/]*/,,}
183
184qualdir_list += \
185 ${dir_list:M${_OBJROOT}*/*/*:N${SRCTOP}*:N${_OBJTOP}*:C,${_OBJROOT}([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
186.endif
187
188dirdep_list := ${dirdep_list:O:u}
216dirdep_list := ${dirdep_list:O:u}
189qualdir_list := ${qualdir_list:O:u}
217qualdir_list := ${qualdir_list:N*.${MACHINE}:O:u}
190
191DIRDEPS = \
192 ${dirdep_list:N${RELDIR}:N${RELDIR}/*} \
193 ${qualdir_list:N${RELDIR}.*:N${RELDIR}/*}
194
195# We only consider things below $RELDIR/ if they have a makefile.
196# This is the same test that _DIRDEPS_USE applies.
197# We have do a double test with dirdep_list as it _may_ contain

--- 4 unchanged lines hidden (view full) ---

202# in fact we can only assume that RELDIR is.
203DIRDEPS += \
204 ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \
205 ${qualdir_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/${d:R}/$m):?$d:}@}@}
206
207DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:O:u}
208
209.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
218
219DIRDEPS = \
220 ${dirdep_list:N${RELDIR}:N${RELDIR}/*} \
221 ${qualdir_list:N${RELDIR}.*:N${RELDIR}/*}
222
223# We only consider things below $RELDIR/ if they have a makefile.
224# This is the same test that _DIRDEPS_USE applies.
225# We have do a double test with dirdep_list as it _may_ contain

--- 4 unchanged lines hidden (view full) ---

230# in fact we can only assume that RELDIR is.
231DIRDEPS += \
232 ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \
233 ${qualdir_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/${d:R}/$m):?$d:}@}@}
234
235DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:O:u}
236
237.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
238.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
210.info ${RELDIR}: dir_list='${dir_list}'
211.info ${RELDIR}: dirdep_list='${dirdep_list}'
212.info ${RELDIR}: qualdir_list='${qualdir_list}'
213.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'
214.info ${RELDIR}: GENDIRDEPS_FILTER='${GENDIRDEPS_FILTER}'
215.info ${RELDIR}: FORCE_DPADD='${DPADD}'
216.info ${RELDIR}: DIRDEPS='${DIRDEPS}'
217.endif

--- 40 unchanged lines hidden (view full) ---

258
259# 'cat .depend' should suffice, but if we are mixing build modes
260# .depend may contain things we don't want.
261# The sed command at the end of the stream, allows for the filters
262# to output _{VAR} tokens which we will turn into proper ${VAR} references.
263${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
264 @(echo '# Autogenerated - do NOT edit!'; echo; \
265 echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
239.info ${RELDIR}: dir_list='${dir_list}'
240.info ${RELDIR}: dirdep_list='${dirdep_list}'
241.info ${RELDIR}: qualdir_list='${qualdir_list}'
242.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'
243.info ${RELDIR}: GENDIRDEPS_FILTER='${GENDIRDEPS_FILTER}'
244.info ${RELDIR}: FORCE_DPADD='${DPADD}'
245.info ${RELDIR}: DIRDEPS='${DIRDEPS}'
246.endif

--- 40 unchanged lines hidden (view full) ---

287
288# 'cat .depend' should suffice, but if we are mixing build modes
289# .depend may contain things we don't want.
290# The sed command at the end of the stream, allows for the filters
291# to output _{VAR} tokens which we will turn into proper ${VAR} references.
292${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
293 @(echo '# Autogenerated - do NOT edit!'; echo; \
294 echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
266 echo 'DEP_MACHINE := $${.PARSEFILE:E}'; echo; \
267 echo 'DIRDEPS = \'; \
268 echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
269 ${_include_src_dirdeps} \
270 echo '.include <dirdeps.mk>'; \
271 echo; \
272 echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \
273 echo '# local dependencies - needed for -jN in clean tree'; \
274 [ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \

--- 5 unchanged lines hidden (view full) ---

280
281DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u}
282
283all: ${_DEPENDFILE}
284
285${_DEPENDFILE}: ${MAKEFILE} ${_this}
286 @(echo '# Autogenerated - do NOT edit!'; echo; \
287 echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
295 echo 'DIRDEPS = \'; \
296 echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
297 ${_include_src_dirdeps} \
298 echo '.include <dirdeps.mk>'; \
299 echo; \
300 echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \
301 echo '# local dependencies - needed for -jN in clean tree'; \
302 [ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \

--- 5 unchanged lines hidden (view full) ---

308
309DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u}
310
311all: ${_DEPENDFILE}
312
313${_DEPENDFILE}: ${MAKEFILE} ${_this}
314 @(echo '# Autogenerated - do NOT edit!'; echo; \
315 echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
288 echo 'DEP_MACHINE := $${.PARSEFILE:E}'; echo; \
289 echo 'DIRDEPS = \'; \
290 echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
291 echo '.include <dirdeps.mk>'; \
292 echo ) | sed 's,_\([{(]\),$$\1,g' > $@.new
293 @${InstallNew}; InstallNew $@.new
294
295.else
296
297# nothing to do
298all ${_DEPENDFILE}:
299
300.endif
301${_DEPENDFILE}: .PRECIOUS
316 echo 'DIRDEPS = \'; \
317 echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
318 echo '.include <dirdeps.mk>'; \
319 echo ) | sed 's,_\([{(]\),$$\1,g' > $@.new
320 @${InstallNew}; InstallNew $@.new
321
322.else
323
324# nothing to do
325all ${_DEPENDFILE}:
326
327.endif
328${_DEPENDFILE}: .PRECIOUS