1# $Id: gendirdeps.mk,v 1.21 2013/03/28 20:01:05 sjg Exp $ |
2 |
3# Copyright (c) 2010-2013, Juniper Networks, Inc. 4# All rights reserved. |
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}} |
54.if ${_OBJROOT:M*/} 55_slash=/ 56.else 57_slash= 58.endif 59_objroot ?= ${_OBJROOT:tA}${_slash} |
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} \ |
115 -R ${RELDIR} -H ${HOST_TARGET} \ 116 ${M2D_OBJROOTS:O:u:@o@-O $o@} 117 |
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 |
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 |
129# and tell it not to add machine qualifiers 130META2DEPS_ARGS += MACHINE=none |
131.endif |
132.if defined(SB_BACKING_SB) |
133META2DEPS_CMD += -S ${SB_BACKING_SB}/src 134M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX} |
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) |
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} |
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}' |
182.endif |
183dir_list += ${ddeps} 184.endif 185.endif 186.endif |
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} |
198dirdep_list = \ |
199 ${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \ |
200 ${GENDIRDEPS_DIR_LIST_XTRAS} 201 |
202# sort longest first 203M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]} 204 |
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). |
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 |
215 |
216dirdep_list := ${dirdep_list:O:u} |
217qualdir_list := ${qualdir_list:N*.${MACHINE}:O:u} |
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} |
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; \ |
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; \ |
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 |