2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2017-03-06 23:13:25 +00:00
|
|
|
# $Id: dirdeps.mk,v 1.86 2017/03/01 20:26:51 sjg Exp $
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
|
|
|
# All rights reserved.
|
2012-08-22 19:25:57 +00:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
# Much of the complexity here is for supporting cross-building.
|
|
|
|
# If a tree does not support that, simply using plain Makefile.depend
|
|
|
|
# should provide sufficient clue.
|
|
|
|
# Otherwise the recommendation is to use Makefile.depend.${MACHINE}
|
|
|
|
# as expected below.
|
|
|
|
|
|
|
|
# Note: this file gets multiply included.
|
|
|
|
# This is what we do with DIRDEPS
|
|
|
|
|
|
|
|
# DIRDEPS:
|
2013-02-16 01:16:53 +00:00
|
|
|
# This is a list of directories - relative to SRCTOP, it is
|
|
|
|
# normally only of interest to .MAKE.LEVEL 0.
|
2012-08-22 19:25:57 +00:00
|
|
|
# In some cases the entry may be qualified with a .<machine>
|
2013-02-16 01:16:53 +00:00
|
|
|
# or .<target_spec> suffix (see TARGET_SPEC_VARS below),
|
|
|
|
# for example to force building something for the pseudo
|
2012-08-22 19:25:57 +00:00
|
|
|
# machines "host" or "common" regardless of current ${MACHINE}.
|
2013-02-16 01:16:53 +00:00
|
|
|
#
|
|
|
|
# All unqualified entries end up being qualified with .${TARGET_SPEC}
|
|
|
|
# and partially qualified (if TARGET_SPEC_VARS has multiple
|
|
|
|
# entries) are also expanded to a full .<target_spec>.
|
2014-05-05 17:58:00 +00:00
|
|
|
# The _DIRDEP_USE target uses the suffix to set TARGET_SPEC
|
2012-08-22 19:25:57 +00:00
|
|
|
# correctly when visiting each entry.
|
|
|
|
#
|
2013-02-16 01:16:53 +00:00
|
|
|
# The fully qualified directory entries are used to construct a
|
|
|
|
# dependency graph that will drive the build later.
|
|
|
|
#
|
|
|
|
# Also, for each fully qualified directory target, we will search
|
|
|
|
# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional
|
|
|
|
# dependencies. We use Makefile.depend (default value for
|
|
|
|
# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to
|
|
|
|
# distinguish them from others.
|
|
|
|
#
|
2016-12-23 02:57:00 +00:00
|
|
|
# Before each Makefile.depend file is read, we set
|
2017-03-07 01:42:30 +00:00
|
|
|
# DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for
|
2016-12-23 02:57:00 +00:00
|
|
|
# its directory, and DEP_MACHINE etc according to the .<target_spec>
|
|
|
|
# represented by the suffix of the corresponding target.
|
|
|
|
#
|
|
|
|
# Since each Makefile.depend file includes dirdeps.mk, this
|
2012-08-22 19:25:57 +00:00
|
|
|
# processing is recursive and results in .MAKE.LEVEL 0 learning the
|
|
|
|
# dependencies of the tree wrt the initial directory (_DEP_RELDIR).
|
|
|
|
#
|
|
|
|
# BUILD_AT_LEVEL0
|
|
|
|
# Indicates whether .MAKE.LEVEL 0 builds anything:
|
|
|
|
# if "no" sub-makes are used to build everything,
|
|
|
|
# if "yes" sub-makes are only used to build for other machines.
|
2013-02-16 01:16:53 +00:00
|
|
|
# It is best to use "no", but this can require fixing some
|
|
|
|
# makefiles to not do anything at .MAKE.LEVEL 0.
|
2012-11-08 21:14:57 +00:00
|
|
|
#
|
|
|
|
# TARGET_SPEC_VARS
|
2013-02-16 01:16:53 +00:00
|
|
|
# The default value is just MACHINE, and for most environments
|
2014-05-05 17:58:00 +00:00
|
|
|
# this is sufficient. The _DIRDEP_USE target actually sets
|
2013-02-16 01:16:53 +00:00
|
|
|
# both MACHINE and TARGET_SPEC to the suffix of the current
|
|
|
|
# target so that in the general case TARGET_SPEC can be ignored.
|
2012-11-08 21:14:57 +00:00
|
|
|
#
|
2013-02-16 01:16:53 +00:00
|
|
|
# If more than MACHINE is needed then sys.mk needs to decompose
|
2012-11-08 21:14:57 +00:00
|
|
|
# TARGET_SPEC and set the relevant variables accordingly.
|
2013-02-16 01:16:53 +00:00
|
|
|
# It is important that MACHINE be included in and actually be
|
|
|
|
# the first member of TARGET_SPEC_VARS. This allows other
|
|
|
|
# variables to be considered optional, and some of the treatment
|
|
|
|
# below relies on MACHINE being the first entry.
|
2012-11-08 21:14:57 +00:00
|
|
|
# Note: TARGET_SPEC cannot contain any '.'s so the target
|
2013-02-16 01:16:53 +00:00
|
|
|
# triple used by compiler folk won't work (directly anyway).
|
2012-11-08 21:14:57 +00:00
|
|
|
#
|
|
|
|
# For example:
|
|
|
|
#
|
2013-04-14 01:21:20 +00:00
|
|
|
# # Always list MACHINE first,
|
|
|
|
# # other variables might be optional.
|
2012-11-08 21:14:57 +00:00
|
|
|
# TARGET_SPEC_VARS = MACHINE TARGET_OS
|
|
|
|
# .if ${TARGET_SPEC:Uno:M*,*} != ""
|
|
|
|
# _tspec := ${TARGET_SPEC:S/,/ /g}
|
|
|
|
# MACHINE := ${_tspec:[1]}
|
|
|
|
# TARGET_OS := ${_tspec:[2]}
|
|
|
|
# # etc.
|
2013-04-14 01:21:20 +00:00
|
|
|
# # We need to stop that TARGET_SPEC affecting any submakes
|
|
|
|
# # and deal with MACHINE=${TARGET_SPEC} in the environment.
|
|
|
|
# TARGET_SPEC =
|
|
|
|
# # export but do not track
|
|
|
|
# .export-env TARGET_SPEC
|
|
|
|
# .export ${TARGET_SPEC_VARS}
|
2012-11-08 21:14:57 +00:00
|
|
|
# .for v in ${TARGET_SPEC_VARS:O:u}
|
|
|
|
# .if empty($v)
|
|
|
|
# .undef $v
|
|
|
|
# .endif
|
|
|
|
# .endfor
|
|
|
|
# .endif
|
2013-04-14 01:21:20 +00:00
|
|
|
# # make sure we know what TARGET_SPEC is
|
|
|
|
# # as we may need it to find Makefile.depend*
|
|
|
|
# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
2012-11-08 21:14:57 +00:00
|
|
|
#
|
2016-12-23 02:57:00 +00:00
|
|
|
# The following variables can influence the initial DIRDEPS
|
|
|
|
# computation with regard to the TARGET_SPECs that will be
|
|
|
|
# built.
|
|
|
|
# Most should also be considered by init.mk
|
|
|
|
#
|
|
|
|
# ONLY_TARGET_SPEC_LIST
|
|
|
|
# Defines a list of TARGET_SPECs for which the current
|
|
|
|
# directory can be built.
|
|
|
|
# If ALL_MACHINES is defined, we build for all the
|
|
|
|
# TARGET_SPECs listed.
|
|
|
|
#
|
|
|
|
# ONLY_MACHINE_LIST
|
|
|
|
# As for ONLY_TARGET_SPEC_LIST but only specifies
|
|
|
|
# MACHINEs.
|
|
|
|
#
|
|
|
|
# NOT_TARGET_SPEC_LIST
|
|
|
|
# A list of TARGET_SPECs for which the current
|
|
|
|
# directory should not be built.
|
|
|
|
#
|
|
|
|
# NOT_MACHINE_LIST
|
|
|
|
# A list of MACHINEs the current directory should not be
|
|
|
|
# built for.
|
|
|
|
#
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
# touch this at your peril
|
|
|
|
_DIRDEP_USE_LEVEL?= 0
|
|
|
|
.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
|
2012-08-22 19:25:57 +00:00
|
|
|
# only the first instance is interested in all this
|
|
|
|
|
|
|
|
.if !target(_DIRDEP_USE)
|
2016-04-18 20:56:21 +00:00
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
# do some setup we only need once
|
|
|
|
_CURDIR ?= ${.CURDIR}
|
|
|
|
_OBJDIR ?= ${.OBJDIR}
|
|
|
|
|
|
|
|
now_utc = ${%s:L:gmtime}
|
|
|
|
.if !defined(start_utc)
|
|
|
|
start_utc := ${now_utc}
|
|
|
|
.endif
|
|
|
|
|
2016-04-18 20:56:21 +00:00
|
|
|
.if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != ""
|
|
|
|
# This little trick let's us do
|
|
|
|
#
|
|
|
|
# mk -f dirdeps.mk some/dir.${TARGET_SPEC}
|
|
|
|
#
|
|
|
|
all:
|
|
|
|
${.TARGETS:Nall}: all
|
|
|
|
DIRDEPS := ${.TARGETS:M*[/.]*}
|
|
|
|
# so that -DNO_DIRDEPS works
|
|
|
|
DEP_RELDIR := ${DIRDEPS:[1]:R}
|
|
|
|
# this will become DEP_MACHINE below
|
|
|
|
TARGET_MACHINE := ${DIRDEPS:[1]:E:C/,.*//}
|
2016-04-18 22:00:26 +00:00
|
|
|
.if ${TARGET_MACHINE:N*/*} == ""
|
|
|
|
TARGET_MACHINE := ${MACHINE}
|
|
|
|
.endif
|
2016-04-18 20:56:21 +00:00
|
|
|
# disable DIRDEPS_CACHE as it does not like this trick
|
|
|
|
MK_DIRDEPS_CACHE = no
|
|
|
|
.endif
|
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
# make sure we get the behavior we expect
|
|
|
|
.MAKE.SAVE_DOLLARS = no
|
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# make sure these are empty to start with
|
|
|
|
_DEP_TARGET_SPEC =
|
|
|
|
|
2012-11-08 21:14:57 +00:00
|
|
|
# If TARGET_SPEC_VARS is other than just MACHINE
|
|
|
|
# it should be set by sys.mk or similar by now.
|
|
|
|
# TARGET_SPEC must not contain any '.'s.
|
|
|
|
TARGET_SPEC_VARS ?= MACHINE
|
2013-02-16 01:16:53 +00:00
|
|
|
# this is what we started with
|
2012-11-08 21:14:57 +00:00
|
|
|
TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
2013-02-16 01:16:53 +00:00
|
|
|
# this is what we mostly use below
|
|
|
|
DEP_TARGET_SPEC = ${TARGET_SPEC_VARS:S,^,DEP_,:@v@${$v:U}@:ts,}
|
|
|
|
# make sure we have defaults
|
|
|
|
.for v in ${TARGET_SPEC_VARS}
|
|
|
|
DEP_$v ?= ${$v}
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
.if ${TARGET_SPEC_VARS:[#]} > 1
|
|
|
|
# Ok, this gets more complex (putting it mildly).
|
|
|
|
# In order to stay sane, we need to ensure that all the build_dirs
|
|
|
|
# we compute below are fully qualified wrt DEP_TARGET_SPEC.
|
|
|
|
# The makefiles may only partially specify (eg. MACHINE only),
|
|
|
|
# so we need to construct a set of modifiers to fill in the gaps.
|
2017-03-06 23:13:25 +00:00
|
|
|
.if ${MAKE_VERSION} >= 20170130
|
|
|
|
_tspec_x := ${TARGET_SPEC_VARS:range}
|
|
|
|
.elif ${TARGET_SPEC_VARS:[#]} > 10
|
2016-12-23 02:57:00 +00:00
|
|
|
# seriously? better have jot(1) or equivalent to produce suitable sequence
|
|
|
|
_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh}
|
|
|
|
.else
|
|
|
|
# we can provide the sequence ourselves
|
|
|
|
_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]}
|
|
|
|
.endif
|
2013-02-16 01:16:53 +00:00
|
|
|
# this handles unqualified entries
|
2013-10-12 23:40:17 +00:00
|
|
|
M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC};
|
2013-02-16 01:16:53 +00:00
|
|
|
# there needs to be at least one item missing for these to make sense
|
|
|
|
.for i in ${_tspec_x:[2..-1]}
|
|
|
|
_tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,}
|
2013-10-12 23:40:17 +00:00
|
|
|
_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$$$${DEP_$v}@:ts,}
|
2013-02-16 01:16:53 +00:00
|
|
|
M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i};
|
|
|
|
.endfor
|
|
|
|
.else
|
|
|
|
# A harmless? default.
|
|
|
|
M_dep_qual_fixes = U
|
|
|
|
.endif
|
2012-11-08 21:14:57 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !defined(.MAKE.DEPENDFILE_PREFERENCE)
|
2013-02-16 01:16:53 +00:00
|
|
|
# .MAKE.DEPENDFILE_PREFERENCE makes the logic below neater?
|
|
|
|
# you really want this set by sys.mk or similar
|
2012-08-22 19:25:57 +00:00
|
|
|
.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T}
|
2012-11-08 21:14:57 +00:00
|
|
|
.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}"
|
|
|
|
.if ${TARGET_SPEC} != ${MACHINE}
|
|
|
|
.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE}
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T}
|
2013-02-16 01:16:53 +00:00
|
|
|
_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# for machine specific dependfiles we require ${MACHINE} to be at the end
|
|
|
|
# also for the sake of sanity we require a common prefix
|
|
|
|
.if !defined(.MAKE.DEPENDFILE_PREFIX)
|
2013-02-16 01:16:53 +00:00
|
|
|
# knowing .MAKE.DEPENDFILE_PREFIX helps
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !empty(_machine_dependfiles)
|
|
|
|
.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R}
|
|
|
|
.else
|
|
|
|
.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
|
|
# this is how we identify non-machine specific dependfiles
|
2013-02-16 01:16:53 +00:00
|
|
|
N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.endif # !target(_DIRDEP_USE)
|
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
# First off, we want to know what ${MACHINE} to build for.
|
|
|
|
# This can be complicated if we are using a mixture of ${MACHINE} specific
|
|
|
|
# and non-specific Makefile.depend*
|
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# if we were included recursively _DEP_TARGET_SPEC should be valid.
|
|
|
|
.if empty(_DEP_TARGET_SPEC)
|
|
|
|
# we may or may not have included a dependfile yet
|
2014-05-05 17:58:00 +00:00
|
|
|
.if defined(.INCLUDEDFROMFILE)
|
|
|
|
_last_dependfile := ${.INCLUDEDFROMFILE:M${.MAKE.DEPENDFILE_PREFIX}*}
|
|
|
|
.else
|
2012-08-22 19:25:57 +00:00
|
|
|
_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
|
2014-05-05 17:58:00 +00:00
|
|
|
.endif
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir:U0}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}'
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
.if empty(_last_dependfile) || ${_last_dependfile:E:${N_notmachine}} == ""
|
|
|
|
# this is all we have to work with
|
|
|
|
DEP_MACHINE = ${TARGET_MACHINE:U${MACHINE}}
|
|
|
|
_DEP_TARGET_SPEC := ${DEP_TARGET_SPEC}
|
2012-08-22 19:25:57 +00:00
|
|
|
.else
|
2013-02-16 01:16:53 +00:00
|
|
|
_DEP_TARGET_SPEC = ${_last_dependfile:${M_dep_qual_fixes:ts:}:E}
|
|
|
|
.endif
|
|
|
|
.if !empty(_last_dependfile)
|
|
|
|
# record that we've read dependfile for this
|
2016-03-18 20:03:09 +00:00
|
|
|
_dirdeps_checked.${_CURDIR}.${TARGET_SPEC}:
|
2013-02-16 01:16:53 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# by now _DEP_TARGET_SPEC should be set, parse it.
|
|
|
|
.if ${TARGET_SPEC_VARS:[#]} > 1
|
|
|
|
# we need to parse DEP_MACHINE may or may not contain more info
|
|
|
|
_tspec := ${_DEP_TARGET_SPEC:S/,/ /g}
|
|
|
|
.for i in ${_tspec_x}
|
|
|
|
DEP_${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]}
|
|
|
|
.endfor
|
|
|
|
.for v in ${TARGET_SPEC_VARS:O:u}
|
|
|
|
.if empty(DEP_$v)
|
|
|
|
.undef DEP_$v
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.else
|
|
|
|
DEP_MACHINE := ${_DEP_TARGET_SPEC}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
# reset each time through
|
|
|
|
_build_all_dirs =
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# the first time we are included the _DIRDEP_USE target will not be defined
|
|
|
|
# we can use this as a clue to do initialization and other one time things.
|
|
|
|
.if !target(_DIRDEP_USE)
|
|
|
|
# make sure this target exists
|
2014-05-05 17:58:00 +00:00
|
|
|
dirdeps: beforedirdeps .WAIT
|
|
|
|
beforedirdeps:
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# We normally expect to be included by Makefile.depend.*
|
|
|
|
# which sets the DEP_* macros below.
|
|
|
|
DEP_RELDIR ?= ${RELDIR}
|
|
|
|
|
|
|
|
# this can cause lots of output!
|
|
|
|
# set to a set of glob expressions that might match RELDIR
|
|
|
|
DEBUG_DIRDEPS ?= no
|
|
|
|
|
|
|
|
# remember the initial value of DEP_RELDIR - we test for it below.
|
|
|
|
_DEP_RELDIR := ${DEP_RELDIR}
|
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
.endif
|
|
|
|
|
2016-12-23 02:57:00 +00:00
|
|
|
# DIRDEPS_CACHE can be very handy for debugging.
|
|
|
|
# Also if repeatedly building the same target,
|
|
|
|
# we can avoid the overhead of re-computing the tree dependencies.
|
|
|
|
MK_DIRDEPS_CACHE ?= no
|
|
|
|
BUILD_DIRDEPS_CACHE ?= no
|
|
|
|
BUILD_DIRDEPS ?= yes
|
|
|
|
|
|
|
|
.if ${MK_DIRDEPS_CACHE} == "yes"
|
|
|
|
# this is where we will cache all our work
|
|
|
|
DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
|
|
|
|
.endif
|
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
# pickup customizations
|
|
|
|
# as below you can use !target(_DIRDEP_USE) to protect things
|
|
|
|
# which should only be done once.
|
2016-04-18 20:56:21 +00:00
|
|
|
.-include <local.dirdeps.mk>
|
2016-03-11 01:35:39 +00:00
|
|
|
|
|
|
|
.if !target(_DIRDEP_USE)
|
2012-08-22 19:25:57 +00:00
|
|
|
# things we skip for host tools
|
|
|
|
SKIP_HOSTDIR ?=
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
NSkipHostDir = ${SKIP_HOSTDIR:N*.host*:S,$,.host*,:N.host*:S,^,${SRCTOP}/,:${M_ListToSkip}}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# things we always skip
|
|
|
|
# SKIP_DIRDEPS allows for adding entries on command line.
|
|
|
|
SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS}
|
2013-03-17 01:51:23 +00:00
|
|
|
SKIP_DIR.host += ${SKIP_HOSTDIR}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-03-17 01:51:23 +00:00
|
|
|
DEP_SKIP_DIR = ${SKIP_DIR} \
|
2013-03-17 03:07:13 +00:00
|
|
|
${SKIP_DIR.${DEP_TARGET_SPEC}:U} \
|
2016-12-23 02:57:00 +00:00
|
|
|
${TARGET_SPEC_VARS:@v@${SKIP_DIR.${DEP_$v}:U}@} \
|
|
|
|
${SKIP_DIRDEPS.${DEP_TARGET_SPEC}:U} \
|
|
|
|
${TARGET_SPEC_VARS:@v@${SKIP_DIRDEPS.${DEP_$v}:U}@}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-03-17 01:51:23 +00:00
|
|
|
NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2016-04-18 20:56:21 +00:00
|
|
|
.if defined(NODIRDEPS) || defined(WITHOUT_DIRDEPS)
|
|
|
|
NO_DIRDEPS =
|
|
|
|
.elif defined(WITHOUT_DIRDEPS_BELOW)
|
|
|
|
NO_DIRDEPS_BELOW =
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(NO_DIRDEPS)
|
2016-03-18 20:03:09 +00:00
|
|
|
# confine ourselves to the original dir and below.
|
2012-08-22 19:25:57 +00:00
|
|
|
DIRDEPS_FILTER += M${_DEP_RELDIR}*
|
2016-03-18 20:03:09 +00:00
|
|
|
.elif defined(NO_DIRDEPS_BELOW)
|
|
|
|
DIRDEPS_FILTER += M${_DEP_RELDIR}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2014-05-05 17:58:00 +00:00
|
|
|
# this is what we run below
|
|
|
|
DIRDEP_MAKE?= ${.MAKE}
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
# we suppress SUBDIR when visiting the leaves
|
2012-08-22 19:25:57 +00:00
|
|
|
# we assume sys.mk will set MACHINE_ARCH
|
2013-02-16 01:16:53 +00:00
|
|
|
# you can add extras to DIRDEP_USE_ENV
|
|
|
|
# if there is no makefile in the target directory, we skip it.
|
2012-08-22 19:25:57 +00:00
|
|
|
_DIRDEP_USE: .USE .MAKE
|
|
|
|
@for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \
|
|
|
|
test -s ${.TARGET:R}/$$m || continue; \
|
|
|
|
echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \
|
2013-02-16 01:16:53 +00:00
|
|
|
MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \
|
2012-11-08 21:14:57 +00:00
|
|
|
TARGET_SPEC=${.TARGET:E} \
|
2013-02-16 01:16:53 +00:00
|
|
|
MACHINE=${.TARGET:E} \
|
2014-05-05 17:58:00 +00:00
|
|
|
${DIRDEP_MAKE} -C ${.TARGET:R} || exit 1; \
|
2012-08-22 19:25:57 +00:00
|
|
|
break; \
|
|
|
|
done
|
|
|
|
|
|
|
|
.ifdef ALL_MACHINES
|
|
|
|
# this is how you limit it to only the machines we have been built for
|
|
|
|
# previously.
|
2016-12-23 02:57:00 +00:00
|
|
|
.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST)
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !empty(ALL_MACHINE_LIST)
|
|
|
|
# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else
|
|
|
|
_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo
|
|
|
|
.else
|
|
|
|
_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo
|
|
|
|
.endif
|
|
|
|
_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u}
|
|
|
|
.else
|
2016-12-23 02:57:00 +00:00
|
|
|
_only_machines := ${ONLY_TARGET_SPEC_LIST:U} ${ONLY_MACHINE_LIST:U}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if empty(_only_machines)
|
|
|
|
# we must be boot-strapping
|
|
|
|
_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.else # ! ALL_MACHINES
|
2016-12-23 02:57:00 +00:00
|
|
|
# if ONLY_TARGET_SPEC_LIST or ONLY_MACHINE_LIST is set, we are limited to that.
|
|
|
|
# Note that ONLY_TARGET_SPEC_LIST should be fully qualified.
|
2012-08-22 19:25:57 +00:00
|
|
|
# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST
|
|
|
|
# otherwise DEP_MACHINE is it - so DEP_MACHINE will match.
|
2016-12-23 02:57:00 +00:00
|
|
|
_only_machines := ${ONLY_TARGET_SPEC_LIST:U:M${DEP_MACHINE},*}
|
|
|
|
.if empty(_only_machines)
|
2012-08-22 19:25:57 +00:00
|
|
|
_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}}
|
|
|
|
.endif
|
2016-12-23 02:57:00 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.if !empty(NOT_MACHINE_LIST)
|
|
|
|
_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
|
|
|
|
.endif
|
2016-12-23 02:57:00 +00:00
|
|
|
.if !empty(NOT_TARGET_SPEC_LIST)
|
|
|
|
# we must first qualify
|
|
|
|
_dm := ${DEP_MACHINE}
|
|
|
|
_only_machines := ${_only_machines:M*,*} ${_only_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
|
|
|
|
DEP_MACHINE := ${_dm}
|
|
|
|
_only_machines := ${_only_machines:${NOT_TARGET_SPEC_LIST:${M_ListToSkip}}}
|
|
|
|
.endif
|
|
|
|
# clean up
|
|
|
|
_only_machines := ${_only_machines:O:u}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# make sure we have a starting place?
|
|
|
|
DIRDEPS ?= ${RELDIR}
|
|
|
|
.endif # target
|
|
|
|
|
2016-04-18 20:56:21 +00:00
|
|
|
.if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW)
|
2015-05-26 21:03:41 +00:00
|
|
|
.if ${MK_DIRDEPS_CACHE} == "yes"
|
|
|
|
|
|
|
|
# just ensure this exists
|
|
|
|
build-dirdeps:
|
|
|
|
|
|
|
|
M_oneperline = @x@\\${.newline} $$x@
|
|
|
|
|
|
|
|
.if ${BUILD_DIRDEPS_CACHE} == "no"
|
|
|
|
.if !target(dirdeps-cached)
|
|
|
|
# we do this via sub-make
|
|
|
|
BUILD_DIRDEPS = no
|
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
# ignore anything but these
|
|
|
|
.MAKE.META.IGNORE_FILTER = M*/${.MAKE.DEPENDFILE_PREFIX}*
|
|
|
|
|
2015-05-26 21:03:41 +00:00
|
|
|
dirdeps: dirdeps-cached
|
|
|
|
dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
|
|
|
|
@echo "${TRACER}Using ${DIRDEPS_CACHE}"
|
|
|
|
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
|
|
|
|
dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
|
|
|
|
|
|
|
|
# these should generally do
|
|
|
|
BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}
|
|
|
|
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
|
|
|
|
|
|
|
|
# we need the .meta file to ensure we update if
|
|
|
|
# any of the Makefile.depend* changed.
|
|
|
|
# We do not want to compare the command line though.
|
|
|
|
${DIRDEPS_CACHE}: .META .NOMETA_CMP
|
|
|
|
+@{ echo '# Autogenerated - do NOT edit!'; echo; \
|
|
|
|
echo 'BUILD_DIRDEPS=no'; echo; \
|
|
|
|
echo '.include <dirdeps.mk>'; \
|
|
|
|
} > ${.TARGET}.new
|
|
|
|
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
|
|
|
|
DIRDEPS="${DIRDEPS}" \
|
2016-12-23 02:57:00 +00:00
|
|
|
TARGET_SPEC=${TARGET_SPEC} \
|
2015-05-26 21:03:41 +00:00
|
|
|
MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \
|
|
|
|
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
|
|
|
|
.MAKE.DEPENDFILE=.none \
|
2016-03-11 01:35:39 +00:00
|
|
|
${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \
|
2015-05-26 21:03:41 +00:00
|
|
|
3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \
|
|
|
|
mv ${.TARGET}.new ${.TARGET}
|
|
|
|
|
|
|
|
.endif
|
|
|
|
.elif !target(_count_dirdeps)
|
|
|
|
# we want to capture the dirdeps count in the cache
|
|
|
|
.END: _count_dirdeps
|
|
|
|
_count_dirdeps: .NOMETA
|
|
|
|
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
|
|
|
|
|
|
|
|
.endif
|
|
|
|
.elif !make(dirdeps) && !target(_count_dirdeps)
|
|
|
|
beforedirdeps: _count_dirdeps
|
|
|
|
_count_dirdeps: .NOMETA
|
|
|
|
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
|
|
|
|
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${BUILD_DIRDEPS} == "yes"
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
|
|
|
|
_debug_reldir = 1
|
|
|
|
.else
|
|
|
|
_debug_reldir = 0
|
|
|
|
.endif
|
|
|
|
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
|
|
|
|
_debug_search = 1
|
|
|
|
.else
|
|
|
|
_debug_search = 0
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# the rest is done repeatedly for every Makefile.depend we read.
|
|
|
|
# if we are anything but the original dir we care only about the
|
|
|
|
# machine type we were included for..
|
|
|
|
|
|
|
|
.if ${DEP_RELDIR} == "."
|
|
|
|
_this_dir := ${SRCTOP}
|
|
|
|
.else
|
|
|
|
_this_dir := ${SRCTOP}/${DEP_RELDIR}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# on rare occasions, there can be a need for extra help
|
|
|
|
_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc
|
2016-04-18 20:56:21 +00:00
|
|
|
.-include <${_dep_hack}>
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC}
|
2012-08-22 19:25:57 +00:00
|
|
|
# this should be all
|
|
|
|
_machines := ${DEP_MACHINE}
|
|
|
|
.else
|
|
|
|
# this is the machine list we actually use below
|
|
|
|
_machines := ${_only_machines}
|
|
|
|
|
|
|
|
.if defined(HOSTPROG) || ${DEP_MACHINE} == "host"
|
|
|
|
# we need to build this guy's dependencies for host as well.
|
|
|
|
_machines += host
|
|
|
|
.endif
|
|
|
|
|
|
|
|
_machines := ${_machines:O:u}
|
|
|
|
.endif
|
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
.if ${TARGET_SPEC_VARS:[#]} > 1
|
|
|
|
# we need to tweak _machines
|
|
|
|
_dm := ${DEP_MACHINE}
|
2013-10-12 23:40:17 +00:00
|
|
|
# apply the same filtering that we do when qualifying DIRDEPS.
|
2014-11-20 22:42:40 +00:00
|
|
|
# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.'
|
2016-12-23 02:57:00 +00:00
|
|
|
# Again we expect that any already qualified machines are fully qualified.
|
|
|
|
_machines := ${_machines:M*,*} ${_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
|
2013-02-16 01:16:53 +00:00
|
|
|
DEP_MACHINE := ${_dm}
|
2016-12-23 02:57:00 +00:00
|
|
|
_machines := ${_machines:O:u}
|
2013-02-16 01:16:53 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# reset each time through
|
2012-08-22 19:25:57 +00:00
|
|
|
_build_dirs =
|
|
|
|
|
|
|
|
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
|
|
|
# pickup other machines for this dir if necessary
|
|
|
|
.if ${BUILD_AT_LEVEL0:Uyes} == "no"
|
|
|
|
_build_dirs += ${_machines:@m@${_CURDIR}.$m@}
|
|
|
|
.else
|
2013-02-16 01:16:53 +00:00
|
|
|
_build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
|
|
|
|
.if ${DEP_TARGET_SPEC} == ${TARGET_SPEC}
|
2012-08-22 19:25:57 +00:00
|
|
|
# pickup local dependencies now
|
2016-03-11 01:35:39 +00:00
|
|
|
.if ${MAKE_VERSION} < 20160220
|
2012-08-22 19:25:57 +00:00
|
|
|
.-include <.depend>
|
2016-03-11 01:35:39 +00:00
|
|
|
.else
|
|
|
|
.dinclude <.depend>
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}'
|
|
|
|
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}'
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(DIRDEPS)
|
2013-03-17 01:51:23 +00:00
|
|
|
# these we reset each time through as they can depend on DEP_MACHINE
|
2013-03-17 03:07:13 +00:00
|
|
|
DEP_DIRDEPS_FILTER = \
|
|
|
|
${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \
|
2016-12-23 02:57:00 +00:00
|
|
|
${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \
|
2013-03-17 03:07:13 +00:00
|
|
|
${DIRDEPS_FILTER:U}
|
2013-03-17 01:51:23 +00:00
|
|
|
.if empty(DEP_DIRDEPS_FILTER)
|
|
|
|
# something harmless
|
|
|
|
DEP_DIRDEPS_FILTER = U
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# this is what we start with
|
2014-05-05 17:58:00 +00:00
|
|
|
__depdirs := ${DIRDEPS:${NSkipDir}:${DEP_DIRDEPS_FILTER:ts:}:C,//+,/,g:O:u:@d@${SRCTOP}/$d@}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# some entries may be qualified with .<machine>
|
|
|
|
# the :M*/*/*.* just tries to limit the dirs we check to likely ones.
|
|
|
|
# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd
|
|
|
|
__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@}
|
|
|
|
__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}}
|
|
|
|
|
|
|
|
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
|
|
|
# if it was called out - we likely need it.
|
|
|
|
__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@}
|
|
|
|
__qual_depdirs += ${__hostdpadd}
|
|
|
|
.endif
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir}
|
2012-08-22 19:25:57 +00:00
|
|
|
.info depdirs=${__depdirs}
|
|
|
|
.info qualified=${__qual_depdirs}
|
|
|
|
.info unqualified=${__unqual_depdirs}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# _build_dirs is what we will feed to _DIRDEP_USE
|
|
|
|
_build_dirs += \
|
|
|
|
${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \
|
|
|
|
${__qual_depdirs:N*.host} \
|
2014-11-20 22:42:40 +00:00
|
|
|
${_machines:Mhost*:@m@${__unqual_depdirs:@d@$d.$m@}@:${NSkipHostDir}:N.host} \
|
|
|
|
${_machines:Nhost*:@m@${__unqual_depdirs:@d@$d.$m@}@}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# qualify everything now
|
|
|
|
_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif # empty DIRDEPS
|
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
_build_all_dirs += ${_build_dirs}
|
|
|
|
_build_all_dirs := ${_build_all_dirs:O:u}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# Normally if doing make -V something,
|
|
|
|
# we do not want to waste time chasing DIRDEPS
|
|
|
|
# but if we want to count the number of Makefile.depend* read, we do.
|
|
|
|
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
|
2016-03-11 01:35:39 +00:00
|
|
|
.if !empty(_build_all_dirs)
|
2015-05-26 21:03:41 +00:00
|
|
|
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
|
|
|
x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
|
2016-03-11 01:35:39 +00:00
|
|
|
echo 'dirdeps: ${_build_all_dirs:${M_oneperline}}'; echo; } >&3; echo
|
|
|
|
x!= { ${_build_all_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo
|
2015-05-26 21:03:41 +00:00
|
|
|
.else
|
2012-08-22 19:25:57 +00:00
|
|
|
# this makes it all happen
|
2016-03-11 01:35:39 +00:00
|
|
|
dirdeps: ${_build_all_dirs}
|
2015-05-26 21:03:41 +00:00
|
|
|
.endif
|
2016-03-11 01:35:39 +00:00
|
|
|
${_build_all_dirs}: _DIRDEP_USE
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# this builds the dependency graph
|
2012-08-22 19:25:57 +00:00
|
|
|
.for m in ${_machines}
|
|
|
|
# it would be nice to do :N${.TARGET}
|
|
|
|
.if !empty(__qual_depdirs)
|
2013-02-16 01:16:53 +00:00
|
|
|
.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
|
2013-02-16 01:16:53 +00:00
|
|
|
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2015-05-26 21:03:41 +00:00
|
|
|
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
|
|
|
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo
|
|
|
|
.else
|
2012-08-22 19:25:57 +00:00
|
|
|
${_this_dir}.$m: ${_build_dirs:M*.$q}
|
2015-05-26 21:03:41 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endfor
|
|
|
|
.endif
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2015-05-26 21:03:41 +00:00
|
|
|
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
|
|
|
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo
|
|
|
|
.else
|
2012-08-22 19:25:57 +00:00
|
|
|
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
2015-05-26 21:03:41 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
2013-02-16 01:16:53 +00:00
|
|
|
# Now find more dependencies - and recurse.
|
2016-03-11 01:35:39 +00:00
|
|
|
.for d in ${_build_all_dirs}
|
2016-03-18 20:03:09 +00:00
|
|
|
.if !target(_dirdeps_checked.$d)
|
2013-02-16 01:16:53 +00:00
|
|
|
# once only
|
2016-03-18 20:03:09 +00:00
|
|
|
_dirdeps_checked.$d:
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_search}
|
2013-10-12 23:40:17 +00:00
|
|
|
.info checking $d
|
|
|
|
.endif
|
2016-03-11 01:35:39 +00:00
|
|
|
# Note: _build_all_dirs is fully qualifed so d:R is always the directory
|
2013-02-16 01:16:53 +00:00
|
|
|
.if exists(${d:R})
|
2016-12-23 02:57:00 +00:00
|
|
|
# we pass _DEP_TARGET_SPEC to tell the next step what we want
|
|
|
|
_DEP_TARGET_SPEC := ${d:E}
|
|
|
|
# some makefiles may still look at this
|
|
|
|
_DEP_MACHINE := ${d:E:C/,.*//}
|
|
|
|
# set these too in case Makefile.depend* uses them
|
|
|
|
.if ${TARGET_SPEC_VARS:[#]} > 1
|
|
|
|
_dtspec := ${_DEP_TARGET_SPEC:S/,/ /g}
|
|
|
|
.for i in ${_tspec_x}
|
|
|
|
DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]}
|
|
|
|
.endfor
|
|
|
|
.else
|
|
|
|
DEP_MACHINE := ${_DEP_MACHINE}
|
|
|
|
.endif
|
2013-02-16 01:16:53 +00:00
|
|
|
# Warning: there is an assumption here that MACHINE is always
|
|
|
|
# the first entry in TARGET_SPEC_VARS.
|
|
|
|
# If TARGET_SPEC and MACHINE are insufficient, you have a problem.
|
|
|
|
_m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d:E:C/,.*//};:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]}
|
|
|
|
.if !empty(_m)
|
2013-10-12 23:40:17 +00:00
|
|
|
# M_dep_qual_fixes isn't geared to Makefile.depend
|
|
|
|
_qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}}
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_search}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info Looking for ${_qm}
|
|
|
|
.endif
|
2015-06-08 23:34:04 +00:00
|
|
|
# set this "just in case"
|
|
|
|
# we can skip :tA since we computed the path above
|
|
|
|
DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,}
|
|
|
|
# and reset this
|
|
|
|
DIRDEPS =
|
2014-11-20 22:42:40 +00:00
|
|
|
.if ${_debug_reldir} && ${_qm} != ${_m}
|
2013-02-16 01:16:53 +00:00
|
|
|
.info loading ${_m} for ${d:E}
|
|
|
|
.endif
|
|
|
|
.include <${_m}>
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.endfor
|
2013-02-16 01:16:53 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif # -V
|
2015-05-26 21:03:41 +00:00
|
|
|
.endif # BUILD_DIRDEPS
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.elif ${.MAKE.LEVEL} > 42
|
|
|
|
.error You should have stopped recursing by now.
|
|
|
|
.else
|
2015-06-08 23:34:04 +00:00
|
|
|
# we are building something
|
|
|
|
DEP_RELDIR := ${RELDIR}
|
|
|
|
_DEP_RELDIR := ${RELDIR}
|
2012-08-22 19:25:57 +00:00
|
|
|
# pickup local dependencies
|
2016-03-11 01:35:39 +00:00
|
|
|
.if ${MAKE_VERSION} < 20160220
|
2012-08-22 19:25:57 +00:00
|
|
|
.-include <.depend>
|
2016-03-11 01:35:39 +00:00
|
|
|
.else
|
|
|
|
.dinclude <.depend>
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
# bootstrapping new dependencies made easy?
|
2016-03-11 01:35:39 +00:00
|
|
|
.if !target(bootstrap) && (make(bootstrap) || \
|
|
|
|
make(bootstrap-this) || \
|
|
|
|
make(bootstrap-recurse) || \
|
|
|
|
make(bootstrap-empty))
|
2014-11-20 22:42:40 +00:00
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
# if we are bootstrapping create the default
|
|
|
|
_want = ${.CURDIR}/${.MAKE.DEPENDFILE_DEFAULT:T}
|
|
|
|
|
|
|
|
.if exists(${_want})
|
2014-11-20 22:42:40 +00:00
|
|
|
# stop here
|
|
|
|
${.TARGETS:Mboot*}:
|
2016-03-11 01:35:39 +00:00
|
|
|
.elif !make(bootstrap-empty)
|
2014-11-20 22:42:40 +00:00
|
|
|
# find a Makefile.depend to use as _src
|
|
|
|
_src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*,}; do test -s $$m || continue; echo $$m; break; done; echo
|
|
|
|
.if empty(_src)
|
2016-03-11 01:35:39 +00:00
|
|
|
.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}${.newline}Use: bootstrap-empty
|
2014-11-20 22:42:40 +00:00
|
|
|
.endif
|
|
|
|
|
2016-09-09 01:21:35 +00:00
|
|
|
_src?= ${.MAKE.DEPENDFILE}
|
|
|
|
|
2016-12-23 02:57:00 +00:00
|
|
|
.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's/${_src:E:C/,.*//}/${MACHINE}/g'
|
2014-11-20 22:42:40 +00:00
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
# just create Makefile.depend* for this dir
|
2014-11-20 22:42:40 +00:00
|
|
|
bootstrap-this: .NOTMAIN
|
2016-09-09 01:21:35 +00:00
|
|
|
@echo Bootstrapping ${RELDIR}/${_want:T} from ${_src:T}; \
|
|
|
|
echo You need to build ${RELDIR} to correctly populate it.
|
|
|
|
.if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T}
|
|
|
|
(cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want})
|
|
|
|
.else
|
|
|
|
cp ${.CURDIR}/${_src:T} ${_want}
|
|
|
|
.endif
|
2014-11-20 22:42:40 +00:00
|
|
|
|
2016-03-11 01:35:39 +00:00
|
|
|
# create Makefile.depend* for this dir and its dependencies
|
2014-11-20 22:42:40 +00:00
|
|
|
bootstrap: bootstrap-recurse
|
|
|
|
bootstrap-recurse: bootstrap-this
|
|
|
|
|
|
|
|
_mf := ${.PARSEFILE}
|
|
|
|
bootstrap-recurse: .NOTMAIN .MAKE
|
|
|
|
@cd ${SRCTOP} && \
|
|
|
|
for d in `cd ${RELDIR} && ${.MAKE} -B -f ${"${.MAKEFLAGS:M-n}":?${_src}:${.MAKE.DEPENDFILE:T}} -V DIRDEPS`; do \
|
|
|
|
test -d $$d || d=$${d%.*}; \
|
|
|
|
test -d $$d || continue; \
|
|
|
|
echo "Checking $$d for bootstrap ..."; \
|
|
|
|
(cd $$d && ${.MAKE} -f ${_mf} bootstrap-recurse); \
|
|
|
|
done
|
|
|
|
|
|
|
|
.endif
|
2016-03-11 01:35:39 +00:00
|
|
|
|
|
|
|
# create an empty Makefile.depend* to get the ball rolling.
|
|
|
|
bootstrap-empty: .NOTMAIN .NOMETA
|
2016-09-09 01:21:35 +00:00
|
|
|
@echo Creating empty ${RELDIR}/${_want:T}; \
|
2016-03-11 01:35:39 +00:00
|
|
|
echo You need to build ${RELDIR} to correctly populate it.
|
2016-09-09 01:21:35 +00:00
|
|
|
@{ echo DIRDEPS=; echo ".include <dirdeps.mk>"; } > ${_want}
|
2016-03-11 01:35:39 +00:00
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
.endif
|