1# $Id: dirdeps.mk,v 1.23 2012/11/06 05:44:03 sjg Exp $
| 1# $Id: dirdeps.mk,v 1.28 2013/03/25 21:11:43 sjg Exp $
|
2
| 2
|
3# Copyright (c) 2010-2012, 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 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26# Much of the complexity here is for supporting cross-building. 27# If a tree does not support that, simply using plain Makefile.depend 28# should provide sufficient clue. 29# Otherwise the recommendation is to use Makefile.depend.${MACHINE} 30# as expected below. 31 32# Note: this file gets multiply included. 33# This is what we do with DIRDEPS 34 35# DIRDEPS:
| 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 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 27# Much of the complexity here is for supporting cross-building. 28# If a tree does not support that, simply using plain Makefile.depend 29# should provide sufficient clue. 30# Otherwise the recommendation is to use Makefile.depend.${MACHINE} 31# as expected below. 32 33# Note: this file gets multiply included. 34# This is what we do with DIRDEPS 35 36# DIRDEPS:
|
36# This is a list of directories - relative to SRCTOP, it is only 37# of interest to .MAKE.LEVEL 0.
| 37# This is a list of directories - relative to SRCTOP, it is 38# normally only of interest to .MAKE.LEVEL 0.
|
38# In some cases the entry may be qualified with a .<machine>
| 39# In some cases the entry may be qualified with a .<machine>
|
39# suffix, for example to force building something for the pseudo
| 40# or .<target_spec> suffix (see TARGET_SPEC_VARS below), 41# for example to force building something for the pseudo
|
40# machines "host" or "common" regardless of current ${MACHINE}.
| 42# machines "host" or "common" regardless of current ${MACHINE}.
|
41# All unqualified entries end up being qualified with .${MACHINE} 42# and _DIRDEPS_USE below, uses the suffix to set MACHINE
| 43# 44# All unqualified entries end up being qualified with .${TARGET_SPEC} 45# and partially qualified (if TARGET_SPEC_VARS has multiple 46# entries) are also expanded to a full .<target_spec>. 47# The _DIRDEPS_USE target uses the suffix to set TARGET_SPEC
|
43# correctly when visiting each entry. 44#
| 48# correctly when visiting each entry. 49#
|
45# Each entry is also converted into a set of paths to look for 46# Makefile.depend.<machine> to learn the dependencies of each. 47# Each Makefile.depend.<machine> sets DEP_RELDIR to be the
| 50# The fully qualified directory entries are used to construct a 51# dependency graph that will drive the build later. 52# 53# Also, for each fully qualified directory target, we will search 54# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional 55# dependencies. We use Makefile.depend (default value for 56# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to 57# distinguish them from others. 58# 59# Each Makefile.depend file sets DEP_RELDIR to be the
|
48# the RELDIR (path relative to SRCTOP) for its directory, and
| 60# the RELDIR (path relative to SRCTOP) for its directory, and
|
49# DEP_MACHINE to its suffix (<machine>), further since 50# each Makefile.depend.<machine> includes dirdeps.mk, this
| 61# since each Makefile.depend file includes dirdeps.mk, this
|
51# processing is recursive and results in .MAKE.LEVEL 0 learning the 52# dependencies of the tree wrt the initial directory (_DEP_RELDIR). 53# 54# BUILD_AT_LEVEL0 55# Indicates whether .MAKE.LEVEL 0 builds anything: 56# if "no" sub-makes are used to build everything, 57# if "yes" sub-makes are only used to build for other machines.
| 62# processing is recursive and results in .MAKE.LEVEL 0 learning the 63# dependencies of the tree wrt the initial directory (_DEP_RELDIR). 64# 65# BUILD_AT_LEVEL0 66# Indicates whether .MAKE.LEVEL 0 builds anything: 67# if "no" sub-makes are used to build everything, 68# if "yes" sub-makes are only used to build for other machines.
|
| 69# It is best to use "no", but this can require fixing some 70# makefiles to not do anything at .MAKE.LEVEL 0.
|
58# 59# TARGET_SPEC_VARS
| 71# 72# TARGET_SPEC_VARS
|
60# All the description above (and below) assumes <machine> is the 61# only data needed to control the build. 62# This is not always the case. So in addition to setting 63# MACHINE in the build environment we set TARGET_SPEC which is 64# composed of the values of TARGET_SPEC_VARS separated by 65# commas. The default is just MACHINE.
| 73# The default value is just MACHINE, and for most environments 74# this is sufficient. The _DIRDEPS_USE target actually sets 75# both MACHINE and TARGET_SPEC to the suffix of the current 76# target so that in the general case TARGET_SPEC can be ignored.
|
66#
| 77#
|
67# If more that MACHINE is needed then sys.mk needs to decompose
| 78# If more than MACHINE is needed then sys.mk needs to decompose
|
68# TARGET_SPEC and set the relevant variables accordingly.
| 79# TARGET_SPEC and set the relevant variables accordingly.
|
69# It is important that MACHINE be included in TARGET_SPEC_VARS 70# since if there is more the value passed as MACHINE will infact 71# be the TARGET_SPEC.
| 80# It is important that MACHINE be included in and actually be 81# the first member of TARGET_SPEC_VARS. This allows other 82# variables to be considered optional, and some of the treatment 83# below relies on MACHINE being the first entry.
|
72# Note: TARGET_SPEC cannot contain any '.'s so the target
| 84# Note: TARGET_SPEC cannot contain any '.'s so the target
|
73# tripple used by compiler folk won't work (directly anyway).
| 85# triple used by compiler folk won't work (directly anyway).
|
74# 75# For example: 76#
| 86# 87# For example: 88#
|
77# # variables other than MACHINE might be optional
| 89# # Always list MACHINE first, 90# # other variables might be optional.
|
78# TARGET_SPEC_VARS = MACHINE TARGET_OS 79# .if ${TARGET_SPEC:Uno:M*,*} != "" 80# _tspec := ${TARGET_SPEC:S/,/ /g} 81# MACHINE := ${_tspec:[1]} 82# TARGET_OS := ${_tspec:[2]} 83# # etc.
| 91# TARGET_SPEC_VARS = MACHINE TARGET_OS 92# .if ${TARGET_SPEC:Uno:M*,*} != "" 93# _tspec := ${TARGET_SPEC:S/,/ /g} 94# MACHINE := ${_tspec:[1]} 95# TARGET_OS := ${_tspec:[2]} 96# # etc.
|
| 97# # We need to stop that TARGET_SPEC affecting any submakes 98# # and deal with MACHINE=${TARGET_SPEC} in the environment. 99# TARGET_SPEC = 100# # export but do not track 101# .export-env TARGET_SPEC 102# .export ${TARGET_SPEC_VARS}
|
84# .for v in ${TARGET_SPEC_VARS:O:u} 85# .if empty($v) 86# .undef $v 87# .endif 88# .endfor 89# .endif
| 103# .for v in ${TARGET_SPEC_VARS:O:u} 104# .if empty($v) 105# .undef $v 106# .endif 107# .endfor 108# .endif
|
| 109# # make sure we know what TARGET_SPEC is 110# # as we may need it to find Makefile.depend* 111# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
90# 91 92.if ${.MAKE.LEVEL} == 0 93# only the first instance is interested in all this 94 95# First off, we want to know what ${MACHINE} to build for. 96# This can be complicated if we are using a mixture of ${MACHINE} specific 97# and non-specific Makefile.depend* 98 99.if !target(_DIRDEP_USE) 100# do some setup we only need once 101_CURDIR ?= ${.CURDIR} 102
| 112# 113 114.if ${.MAKE.LEVEL} == 0 115# only the first instance is interested in all this 116 117# First off, we want to know what ${MACHINE} to build for. 118# This can be complicated if we are using a mixture of ${MACHINE} specific 119# and non-specific Makefile.depend* 120 121.if !target(_DIRDEP_USE) 122# do some setup we only need once 123_CURDIR ?= ${.CURDIR} 124
|
| 125# make sure these are empty to start with 126_DEP_TARGET_SPEC = 127_DIRDEP_CHECKED = 128
|
103# If TARGET_SPEC_VARS is other than just MACHINE 104# it should be set by sys.mk or similar by now. 105# TARGET_SPEC must not contain any '.'s. 106TARGET_SPEC_VARS ?= MACHINE
| 129# If TARGET_SPEC_VARS is other than just MACHINE 130# it should be set by sys.mk or similar by now. 131# TARGET_SPEC must not contain any '.'s. 132TARGET_SPEC_VARS ?= MACHINE
|
| 133# this is what we started with
|
107TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
| 134TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
| 135# this is what we mostly use below 136DEP_TARGET_SPEC = ${TARGET_SPEC_VARS:S,^,DEP_,:@v@${$v:U}@:ts,} 137# make sure we have defaults 138.for v in ${TARGET_SPEC_VARS} 139DEP_$v ?= ${$v} 140.endfor
|
108
| 141
|
| 142.if ${TARGET_SPEC_VARS:[#]} > 1 143# Ok, this gets more complex (putting it mildly). 144# In order to stay sane, we need to ensure that all the build_dirs 145# we compute below are fully qualified wrt DEP_TARGET_SPEC. 146# The makefiles may only partially specify (eg. MACHINE only), 147# so we need to construct a set of modifiers to fill in the gaps. 148# jot 10 should output 1 2 3 .. 10 149JOT ?= jot 150_tspec_x := ${${JOT} ${TARGET_SPEC_VARS:[#]}:L:sh} 151# this handles unqualified entries 152M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.${DEP_TARGET_SPEC}; 153# there needs to be at least one item missing for these to make sense 154.for i in ${_tspec_x:[2..-1]} 155_tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,} 156_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$${DEP_$v}@:ts,} 157M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i}; 158.endfor 159.else 160# A harmless? default. 161M_dep_qual_fixes = U 162.endif 163
|
109.if !defined(.MAKE.DEPENDFILE_PREFERENCE)
| 164.if !defined(.MAKE.DEPENDFILE_PREFERENCE)
|
110# this makes the logic below neater?
| 165# .MAKE.DEPENDFILE_PREFERENCE makes the logic below neater? 166# you really want this set by sys.mk or similar
|
111.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T} 112.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}" 113.if ${TARGET_SPEC} != ${MACHINE} 114.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE} 115.endif 116.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R} 117.endif 118.endif 119 120_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T}
| 167.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T} 168.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}" 169.if ${TARGET_SPEC} != ${MACHINE} 170.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE} 171.endif 172.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R} 173.endif 174.endif 175 176_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T}
|
121_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:M*.${TARGET_SPEC}} \ 122 ${.MAKE.DEPENDFILE_PREFERENCE:M*.${MACHINE}}
| 177_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*}
|
123 124# for machine specific dependfiles we require ${MACHINE} to be at the end 125# also for the sake of sanity we require a common prefix 126.if !defined(.MAKE.DEPENDFILE_PREFIX)
| 178 179# for machine specific dependfiles we require ${MACHINE} to be at the end 180# also for the sake of sanity we require a common prefix 181.if !defined(.MAKE.DEPENDFILE_PREFIX)
|
| 182# knowing .MAKE.DEPENDFILE_PREFIX helps
|
127.if !empty(_machine_dependfiles) 128.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R} 129.else 130.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T} 131.endif 132.endif 133 134 135# this is how we identify non-machine specific dependfiles
| 183.if !empty(_machine_dependfiles) 184.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R} 185.else 186.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T} 187.endif 188.endif 189 190 191# this is how we identify non-machine specific dependfiles
|
136N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N${TARGET_SPEC}:N${MACHINE}:${M_ListToSkip}}
| 192N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}}
|
137 138.endif # !target(_DIRDEP_USE) 139
| 193 194.endif # !target(_DIRDEP_USE) 195
|
| 196# if we were included recursively _DEP_TARGET_SPEC should be valid. 197.if empty(_DEP_TARGET_SPEC) 198# we may or may not have included a dependfile yet
|
140_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
| 199_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
|
| 200.if !empty(_debug_reldir) 201.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}' 202.endif
|
141
| 203
|
142# Note: if a makefile is read many times, the above 143# will not work, so we also test for DEP_MACHINE==depend below. 144.if empty(_last_dependfile) 145# we haven't included one yet 146DEP_MACHINE ?= ${TARGET_MACHINE:U${TARGET_SPEC}} 147# else it should be correctly set by ${.MAKE.DEPENDFILE} 148.elif ${_last_dependfile:E:${N_notmachine}} == "" || ${DEP_MACHINE:Uno:${N_notmachine}} == "" 149# don't rely on manually maintained files to be correct 150DEP_MACHINE := ${_DEP_MACHINE:U${TARGET_SPEC}}
| 204.if empty(_last_dependfile) || ${_last_dependfile:E:${N_notmachine}} == "" 205# this is all we have to work with 206DEP_MACHINE = ${TARGET_MACHINE:U${MACHINE}} 207_DEP_TARGET_SPEC := ${DEP_TARGET_SPEC}
|
151.else
| 208.else
|
152# just in case 153DEP_MACHINE ?= ${_last_dependfile:E}
| 209_DEP_TARGET_SPEC = ${_last_dependfile:${M_dep_qual_fixes:ts:}:E}
|
154.endif
| 210.endif
|
| 211.if !empty(_last_dependfile) 212# record that we've read dependfile for this 213_DIRDEP_CHECKED += ${_CURDIR}.${TARGET_SPEC} 214.endif 215.endif
|
155
| 216
|
| 217# by now _DEP_TARGET_SPEC should be set, parse it. 218.if ${TARGET_SPEC_VARS:[#]} > 1 219# we need to parse DEP_MACHINE may or may not contain more info 220_tspec := ${_DEP_TARGET_SPEC:S/,/ /g} 221.for i in ${_tspec_x} 222DEP_${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]} 223.endfor 224.for v in ${TARGET_SPEC_VARS:O:u} 225.if empty(DEP_$v) 226.undef DEP_$v 227.endif 228.endfor 229.else 230DEP_MACHINE := ${_DEP_TARGET_SPEC} 231.endif 232
|
156# pickup customizations 157# as below you can use !target(_DIRDEP_USE) to protect things 158# which should only be done once. 159.-include "local.dirdeps.mk" 160 161# the first time we are included the _DIRDEP_USE target will not be defined 162# we can use this as a clue to do initialization and other one time things. 163.if !target(_DIRDEP_USE) 164# make sure this target exists 165dirdeps: 166 167# We normally expect to be included by Makefile.depend.* 168# which sets the DEP_* macros below. 169DEP_RELDIR ?= ${RELDIR} 170 171# this can cause lots of output! 172# set to a set of glob expressions that might match RELDIR 173DEBUG_DIRDEPS ?= no 174 175# remember the initial value of DEP_RELDIR - we test for it below. 176_DEP_RELDIR := ${DEP_RELDIR} 177 178# things we skip for host tools 179SKIP_HOSTDIR ?= 180 181NSkipHostDir = ${SKIP_HOSTDIR:N*.host:S,$,.host,:N.host:${M_ListToSkip}}
| 233# pickup customizations 234# as below you can use !target(_DIRDEP_USE) to protect things 235# which should only be done once. 236.-include "local.dirdeps.mk" 237 238# the first time we are included the _DIRDEP_USE target will not be defined 239# we can use this as a clue to do initialization and other one time things. 240.if !target(_DIRDEP_USE) 241# make sure this target exists 242dirdeps: 243 244# We normally expect to be included by Makefile.depend.* 245# which sets the DEP_* macros below. 246DEP_RELDIR ?= ${RELDIR} 247 248# this can cause lots of output! 249# set to a set of glob expressions that might match RELDIR 250DEBUG_DIRDEPS ?= no 251 252# remember the initial value of DEP_RELDIR - we test for it below. 253_DEP_RELDIR := ${DEP_RELDIR} 254 255# things we skip for host tools 256SKIP_HOSTDIR ?= 257 258NSkipHostDir = ${SKIP_HOSTDIR:N*.host:S,$,.host,:N.host:${M_ListToSkip}}
|
182NSkipHostDep = ${SKIP_HOSTDIR:R:@d@*/$d*.host@:${M_ListToSkip}}
| |
183 184# things we always skip 185# SKIP_DIRDEPS allows for adding entries on command line. 186SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS}
| 259 260# things we always skip 261# SKIP_DIRDEPS allows for adding entries on command line. 262SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS}
|
| 263SKIP_DIR.host += ${SKIP_HOSTDIR}
|
187
| 264
|
188.ifdef HOSTPROG 189SKIP_DIR += ${SKIP_HOSTDIR} 190.endif
| 265DEP_SKIP_DIR = ${SKIP_DIR} \ 266 ${SKIP_DIR.${DEP_TARGET_SPEC}:U} \ 267 ${SKIP_DIR.${DEP_MACHINE}:U} \ 268 ${SKIP_DIRDEPS.${DEP_MACHINE}:U}
|
191
| 269
|
192NSkipDir = ${SKIP_DIR:${M_ListToSkip}}
| 270NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}}
|
193 194.if defined(NO_DIRDEPS) || defined(NODIRDEPS) 195# confine ourselves to the original dir 196DIRDEPS_FILTER += M${_DEP_RELDIR}* 197.endif 198 199# we supress SUBDIR when visiting the leaves 200# we assume sys.mk will set MACHINE_ARCH
| 271 272.if defined(NO_DIRDEPS) || defined(NODIRDEPS) 273# confine ourselves to the original dir 274DIRDEPS_FILTER += M${_DEP_RELDIR}* 275.endif 276 277# we supress SUBDIR when visiting the leaves 278# we assume sys.mk will set MACHINE_ARCH
|
| 279# you can add extras to DIRDEP_USE_ENV 280# if there is no makefile in the target directory, we skip it.
|
201_DIRDEP_USE: .USE .MAKE 202 @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ 203 test -s ${.TARGET:R}/$$m || continue; \ 204 echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \
| 281_DIRDEP_USE: .USE .MAKE 282 @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ 283 test -s ${.TARGET:R}/$$m || continue; \ 284 echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \
|
| 285 MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \
|
205 TARGET_SPEC=${.TARGET:E} \
| 286 TARGET_SPEC=${.TARGET:E} \
|
206 MACHINE=${.TARGET:E} MACHINE_ARCH= NO_SUBDIR=1 \
| 287 MACHINE=${.TARGET:E} \
|
207 ${.MAKE} -C ${.TARGET:R} || exit 1; \ 208 break; \ 209 done 210 211.ifdef ALL_MACHINES 212# this is how you limit it to only the machines we have been built for 213# previously. 214.if empty(ONLY_MACHINE_LIST) 215.if !empty(ALL_MACHINE_LIST) 216# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else 217_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo 218.else 219_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo 220.endif 221_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u} 222.else 223_only_machines := ${ONLY_MACHINE_LIST} 224.endif 225 226.if empty(_only_machines) 227# we must be boot-strapping 228_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}} 229.endif 230 231.else # ! ALL_MACHINES 232# if ONLY_MACHINE_LIST is set, we are limited to that 233# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST 234# otherwise DEP_MACHINE is it - so DEP_MACHINE will match. 235_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}} 236.endif 237 238.if !empty(NOT_MACHINE_LIST) 239_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}} 240.endif 241 242# make sure we have a starting place? 243DIRDEPS ?= ${RELDIR} 244.endif # target 245 246_debug_reldir := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} 247_debug_search := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} 248 249# the rest is done repeatedly for every Makefile.depend we read. 250# if we are anything but the original dir we care only about the 251# machine type we were included for.. 252 253.if ${DEP_RELDIR} == "." 254_this_dir := ${SRCTOP} 255.else 256_this_dir := ${SRCTOP}/${DEP_RELDIR} 257.endif 258 259# on rare occasions, there can be a need for extra help 260_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc 261.-include "${_dep_hack}" 262
| 288 ${.MAKE} -C ${.TARGET:R} || exit 1; \ 289 break; \ 290 done 291 292.ifdef ALL_MACHINES 293# this is how you limit it to only the machines we have been built for 294# previously. 295.if empty(ONLY_MACHINE_LIST) 296.if !empty(ALL_MACHINE_LIST) 297# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else 298_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo 299.else 300_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo 301.endif 302_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u} 303.else 304_only_machines := ${ONLY_MACHINE_LIST} 305.endif 306 307.if empty(_only_machines) 308# we must be boot-strapping 309_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}} 310.endif 311 312.else # ! ALL_MACHINES 313# if ONLY_MACHINE_LIST is set, we are limited to that 314# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST 315# otherwise DEP_MACHINE is it - so DEP_MACHINE will match. 316_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}} 317.endif 318 319.if !empty(NOT_MACHINE_LIST) 320_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}} 321.endif 322 323# make sure we have a starting place? 324DIRDEPS ?= ${RELDIR} 325.endif # target 326 327_debug_reldir := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} 328_debug_search := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} 329 330# the rest is done repeatedly for every Makefile.depend we read. 331# if we are anything but the original dir we care only about the 332# machine type we were included for.. 333 334.if ${DEP_RELDIR} == "." 335_this_dir := ${SRCTOP} 336.else 337_this_dir := ${SRCTOP}/${DEP_RELDIR} 338.endif 339 340# on rare occasions, there can be a need for extra help 341_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc 342.-include "${_dep_hack}" 343
|
263.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_MACHINE} != ${TARGET_SPEC}
| 344.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC}
|
264# this should be all 265_machines := ${DEP_MACHINE} 266.else 267# this is the machine list we actually use below 268_machines := ${_only_machines} 269 270.if defined(HOSTPROG) || ${DEP_MACHINE} == "host" 271# we need to build this guy's dependencies for host as well. 272_machines += host 273.endif 274 275_machines := ${_machines:O:u} 276.endif 277
| 345# this should be all 346_machines := ${DEP_MACHINE} 347.else 348# this is the machine list we actually use below 349_machines := ${_only_machines} 350 351.if defined(HOSTPROG) || ${DEP_MACHINE} == "host" 352# we need to build this guy's dependencies for host as well. 353_machines += host 354.endif 355 356_machines := ${_machines:O:u} 357.endif 358
|
278# reset these each time through
| 359.if ${TARGET_SPEC_VARS:[#]} > 1 360# we need to tweak _machines 361_dm := ${DEP_MACHINE} 362_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@} 363DEP_MACHINE := ${_dm} 364.endif 365 366# reset each time through
|
279_build_dirs =
| 367_build_dirs =
|
280_depdir_files =
| |
281 282.if ${DEP_RELDIR} == ${_DEP_RELDIR} 283# pickup other machines for this dir if necessary 284.if ${BUILD_AT_LEVEL0:Uyes} == "no" 285_build_dirs += ${_machines:@m@${_CURDIR}.$m@} 286.else
| 368 369.if ${DEP_RELDIR} == ${_DEP_RELDIR} 370# pickup other machines for this dir if necessary 371.if ${BUILD_AT_LEVEL0:Uyes} == "no" 372_build_dirs += ${_machines:@m@${_CURDIR}.$m@} 373.else
|
287_build_dirs += ${_machines:N${DEP_MACHINE}:@m@${_CURDIR}.$m@} 288.if ${DEP_MACHINE} == ${TARGET_SPEC}
| 374_build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@} 375.if ${DEP_TARGET_SPEC} == ${TARGET_SPEC}
|
289# pickup local dependencies now 290.-include <.depend> 291.endif 292.endif 293.endif 294 295.if !empty(_debug_reldir)
| 376# pickup local dependencies now 377.-include <.depend> 378.endif 379.endif 380.endif 381 382.if !empty(_debug_reldir)
|
296.info ${DEP_RELDIR}.${DEP_MACHINE}: _last_dependfile='${_last_dependfile}' 297.info ${DEP_RELDIR}.${DEP_MACHINE}: DIRDEPS='${DIRDEPS}' 298.info ${DEP_RELDIR}.${DEP_MACHINE}: _machines='${_machines}'
| 383.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}' 384.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}'
|
299.endif 300 301.if !empty(DIRDEPS)
| 385.endif 386 387.if !empty(DIRDEPS)
|
| 388# these we reset each time through as they can depend on DEP_MACHINE 389DEP_DIRDEPS_FILTER = \ 390 ${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \ 391 ${DIRDEPS_FILTER.${DEP_MACHINE}:U} \ 392 ${DIRDEPS_FILTER:U} 393.if empty(DEP_DIRDEPS_FILTER) 394# something harmless 395DEP_DIRDEPS_FILTER = U 396.endif
|
302 303# this is what we start with
| 397 398# this is what we start with
|
304__depdirs := ${DIRDEPS:${NSkipDir}:${DIRDEPS_FILTER:ts:}:O:u:@d@${SRCTOP}/$d@}
| 399__depdirs := ${DIRDEPS:${NSkipDir}:${DEP_DIRDEPS_FILTER:ts:}:O:u:@d@${SRCTOP}/$d@}
|
305 306# some entries may be qualified with .<machine> 307# the :M*/*/*.* just tries to limit the dirs we check to likely ones. 308# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd 309__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@} 310__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}} 311 312.if ${DEP_RELDIR} == ${_DEP_RELDIR} 313# if it was called out - we likely need it. 314__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@} 315__qual_depdirs += ${__hostdpadd} 316.endif 317 318.if !empty(_debug_reldir) 319.info depdirs=${__depdirs} 320.info qualified=${__qual_depdirs} 321.info unqualified=${__unqual_depdirs} 322.endif 323 324# _build_dirs is what we will feed to _DIRDEP_USE 325_build_dirs += \ 326 ${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \ 327 ${__qual_depdirs:N*.host} \ 328 ${_machines:@m@${__unqual_depdirs:@d@$d.$m@}@} 329
| 400 401# some entries may be qualified with .<machine> 402# the :M*/*/*.* just tries to limit the dirs we check to likely ones. 403# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd 404__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@} 405__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}} 406 407.if ${DEP_RELDIR} == ${_DEP_RELDIR} 408# if it was called out - we likely need it. 409__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@} 410__qual_depdirs += ${__hostdpadd} 411.endif 412 413.if !empty(_debug_reldir) 414.info depdirs=${__depdirs} 415.info qualified=${__qual_depdirs} 416.info unqualified=${__unqual_depdirs} 417.endif 418 419# _build_dirs is what we will feed to _DIRDEP_USE 420_build_dirs += \ 421 ${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \ 422 ${__qual_depdirs:N*.host} \ 423 ${_machines:@m@${__unqual_depdirs:@d@$d.$m@}@} 424
|
330_build_dirs := ${_build_dirs:O:u}
| 425# qualify everything now 426_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
|
331
| 427
|
332# this is where we will pick up more dependencies from 333# the inner inline loops look complex, but save a significant 334# amount of memory compared to a .for loop. 335_depdir_files = 336.for d in ${_build_dirs} 337.if exists($d) 338# easy, we're building for ${MACHINE} 339_depdir_files += ${.MAKE.DEPENDFILE_PREFERENCE:T:@m@${exists($d/$m):?$d/$m:}@:[1]} 340.elif exists(${d:R}) && ${d:R:T} == ${d:T:R} 341# a little more complex - building for another machine 342# we will ensure the file is qualified with a machine 343# so that if necessary _DEP_MACHINE can be set below 344_depdir_files += ${.MAKE.DEPENDFILE_PREFERENCE:T:S,.${TARGET_SPEC}$,.${d:E},:S,.${MACHINE}$,.${d:E},:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]:@m@${"${m:M*.${d:E}}":?$m:$m.${d:E}}@} 345.endif 346.endfor 347 348# clean up 349_depdir_files := ${_depdir_files:O:u} 350
| |
351.endif # empty DIRDEPS 352 353# Normally if doing make -V something, 354# we do not want to waste time chasing DIRDEPS 355# but if we want to count the number of Makefile.depend* read, we do. 356.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" 357.if !empty(_build_dirs) 358# this makes it all happen 359dirdeps: ${_build_dirs} 360${_build_dirs}: _DIRDEP_USE 361 362.if !empty(_debug_reldir)
| 428.endif # empty DIRDEPS 429 430# Normally if doing make -V something, 431# we do not want to waste time chasing DIRDEPS 432# but if we want to count the number of Makefile.depend* read, we do. 433.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" 434.if !empty(_build_dirs) 435# this makes it all happen 436dirdeps: ${_build_dirs} 437${_build_dirs}: _DIRDEP_USE 438 439.if !empty(_debug_reldir)
|
363.info ${DEP_RELDIR}.${DEP_MACHINE}: ${_build_dirs}
| 440.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs}
|
364.endif 365
| 441.endif 442
|
| 443# this builds the dependency graph
|
366.for m in ${_machines} 367# it would be nice to do :N${.TARGET} 368.if !empty(__qual_depdirs)
| 444.for m in ${_machines} 445# it would be nice to do :N${.TARGET} 446.if !empty(__qual_depdirs)
|
369.for q in ${__qual_depdirs:E:O:u:N$m}
| 447.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
|
370.if !empty(_debug_reldir) || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
| 448.if !empty(_debug_reldir) || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
|
371.info ${DEP_RELDIR}.$m: ${_build_dirs:M*.$q}
| 449.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
|
372.endif 373${_this_dir}.$m: ${_build_dirs:M*.$q} 374.endfor 375.endif 376.if !empty(_debug_reldir)
| 450.endif 451${_this_dir}.$m: ${_build_dirs:M*.$q} 452.endfor 453.endif 454.if !empty(_debug_reldir)
|
377.info ${DEP_RELDIR}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
| 455.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
378.endif 379${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} 380.endfor 381 382.endif 383
| 456.endif 457${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} 458.endfor 459 460.endif 461
|
384.for d in ${_depdir_files} 385.if ${.MAKE.MAKEFILES:M${d}} == ""
| 462# Now find more dependencies - and recurse. 463.for d in ${_build_dirs} 464.if ${_DIRDEP_CHECKED:M$d} == "" 465# once only 466_DIRDEP_CHECKED += $d 467# Note: _build_dirs is fully qualifed so d:R is always the directory 468.if exists(${d:R}) 469# Warning: there is an assumption here that MACHINE is always 470# the first entry in TARGET_SPEC_VARS. 471# If TARGET_SPEC and MACHINE are insufficient, you have a problem. 472_m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d:E:C/,.*//};:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]} 473.if !empty(_m) 474_qm := ${_m:${M_dep_qual_fixes:ts:}}
|
386.if !empty(_debug_search)
| 475.if !empty(_debug_search)
|
387.info Looking for $d
| 476.info Looking for ${_qm}
|
388.endif
| 477.endif
|
389.if exists($d) 390.include <$d> 391.elif exists(${d:R}) 392# an unqualified file exists, we qualified it above so we can set _DEP_MACHINE 393# it might be manually maintained and shared by all machine types 394# tell it the machine we are interested in. 395_DEP_MACHINE := ${d:E} 396.if !empty(_debug_reldir) 397.info loading ${d:R} for ${_DEP_MACHINE}
| 478# we pass _DEP_TARGET_SPEC to tell the next step what we want 479_DEP_TARGET_SPEC := ${d:E} 480# some makefiles may still look at this 481_DEP_MACHINE := ${d:E:C/,.*//} 482.if !empty(_debug_reldir) && ${_qm} != ${_m} 483.info loading ${_m} for ${d:E}
|
398.endif
| 484.endif
|
399# pretend we read $d, so we don't come by here again. 400.MAKE.MAKEFILES += $d 401.include <${d:R}>
| 485.include <${_m}>
|
402.endif 403.endif
| 486.endif 487.endif
|
| 488.endif
|
404.endfor
| 489.endfor
|
| 490
|
405.endif # -V 406 407.elif ${.MAKE.LEVEL} > 42 408.error You should have stopped recursing by now. 409.else 410_DEP_RELDIR := ${DEP_RELDIR} 411# pickup local dependencies 412.-include <.depend> 413.endif 414
| 491.endif # -V 492 493.elif ${.MAKE.LEVEL} > 42 494.error You should have stopped recursing by now. 495.else 496_DEP_RELDIR := ${DEP_RELDIR} 497# pickup local dependencies 498.-include <.depend> 499.endif 500
|