Changeset View
Changeset View
Standalone View
Standalone View
head/share/mk/dirdeps-targets.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# RCSid: | # RCSid: | ||||
# $Id: dirdeps-targets.mk,v 1.9 2019/10/06 20:07:50 sjg Exp $ | # $Id: dirdeps-targets.mk,v 1.22 2020/08/15 18:00:11 sjg Exp $ | ||||
# | # | ||||
# @(#) Copyright (c) 2019 Simon J. Gerraty | # @(#) Copyright (c) 2019-2020 Simon J. Gerraty | ||||
# | # | ||||
# This file is provided in the hope that it will | # This file is provided in the hope that it will | ||||
# be of use. There is absolutely NO WARRANTY. | # be of use. There is absolutely NO WARRANTY. | ||||
# Permission to copy, redistribute or otherwise | # Permission to copy, redistribute or otherwise | ||||
# use this file is hereby granted provided that | # use this file is hereby granted provided that | ||||
# the above copyright notice and this notice are | # the above copyright notice and this notice are | ||||
# left intact. | # left intact. | ||||
# | # | ||||
# Please send copies of changes and bug-fixes to: | # Please send copies of changes and bug-fixes to: | ||||
# sjg@crufty.net | # sjg@crufty.net | ||||
# | # | ||||
## | ## | ||||
# This makefile is used to set initial DIRDEPS for top-level build | # This makefile is used to set initial DIRDEPS for top-level build | ||||
# targets. | # targets. | ||||
# | # | ||||
# The basic idea is that we have a list of directories in | # The basic idea is that we have a list of directories in | ||||
# DIRDEPS_TARGETS_DIRS which are relative to SRCTOP. | # DIRDEPS_TARGETS_DIRS which are relative to SRCTOP. | ||||
# When asked to make 'foo' we look for any directory named 'foo' | # When asked to make 'foo' we look for any directory named 'foo' | ||||
# under DIRDEPS_TARGETS_DIRS. | # under DIRDEPS_TARGETS_DIRS. | ||||
# We then search those dirs for any Makefile.depend* | # We then search those dirs for any Makefile.depend* | ||||
# Finally we select any that match conditions like REQUESTED_MACHINE | # Finally we select any that match conditions like REQUESTED_MACHINE | ||||
# or TARGET_SPEC and initialize DIRDEPS accordingly. | # or TARGET_SPEC and initialize DIRDEPS accordingly. | ||||
# | # | ||||
# We will check each of the initial DIRDEPS for Makefile.dirdeps.options | |||||
# and include any found. | |||||
# This makes it feasible to tweak options like MK_DIRDEPS_CACHE | |||||
# for a specific target. | |||||
# | |||||
# If MK_STATIC_DIRDEPS_CACHE is defined we will check if the | |||||
# initial DIRDEPS has a static cache (Makefile.dirdeps.cache). | |||||
# This only makes sense for seriously expensive targets. | |||||
# | |||||
.if ${.MAKE.LEVEL} == 0 | .if ${.MAKE.LEVEL} == 0 | ||||
# pickup customizations | # pickup customizations | ||||
.-include <local.dirdeps-targets.mk> | .-include <local.dirdeps-targets.mk> | ||||
# for DIRDEPS_BUILD this is how we prime the pump | # for DIRDEPS_BUILD this is how we prime the pump | ||||
DIRDEPS_TARGETS_DIRS ?= targets targets/pseudo | DIRDEPS_TARGETS_DIRS ?= targets targets/pseudo | ||||
# these prefixes can modify how we behave | # these prefixes can modify how we behave | ||||
# they need to be stripped when looking for target dirs | # they need to be stripped when looking for target dirs | ||||
DIRDEPS_TARGETS_PREFIX_LIST ?= pkg- build- | DIRDEPS_TARGETS_PREFIX_LIST ?= pkg- build- | ||||
# some .TARGETS need filtering | |||||
DIRDEPS_TARGETS_FILTER += Nall | |||||
# matching target dirs if any | # matching target dirs if any | ||||
tdirs := ${.TARGETS:Nall:${DIRDEPS_TARGETS_PREFIX_LIST:@p@S,^$p,,@:ts:}:@t@${DIRDEPS_TARGETS_DIRS:@d@$d/$t@}@:@d@${exists(${SRCTOP}/$d):?$d:}@} | tdirs := ${.TARGETS:${DIRDEPS_TARGETS_FILTER:ts:}:${DIRDEPS_TARGETS_PREFIX_LIST:@p@S,^$p,,@:ts:}:@t@${DIRDEPS_TARGETS_DIRS:@d@$d/$t@}@:@d@${exists(${SRCTOP}/$d):?$d:}@} | ||||
.if !empty(DEBUG_DIRDEPS_TARGETS) | .if !empty(DEBUG_DIRDEPS_TARGETS) | ||||
.info tdirs=${tdirs} | .info tdirs=${tdirs} | ||||
.endif | .endif | ||||
.if !empty(tdirs) | .if !empty(tdirs) | ||||
# some things we know we want to ignore | # some things we know we want to ignore | ||||
DIRDEPS_TARGETS_SKIP_LIST += \ | DIRDEPS_TARGETS_SKIP_LIST += \ | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
.if !empty(DEBUG_DIRDEPS_TARGETS) | .if !empty(DEBUG_DIRDEPS_TARGETS) | ||||
.for x in tdeps ptdeps mqtdeps tqtdeps DIRDEPS | .for x in tdeps ptdeps mqtdeps tqtdeps DIRDEPS | ||||
.info $x=${$x} | .info $x=${$x} | ||||
.endfor | .endfor | ||||
.endif | .endif | ||||
.endif | .endif | ||||
# if we got DIRDEPS get to work | # if we got DIRDEPS get to work | ||||
.if !empty(DIRDEPS) | .if !empty(DIRDEPS) | ||||
DIRDEPS.dirs := ${DIRDEPS:S,^,${SRCTOP}/,:@d@${exists($d):?$d:${d:R}}@} | |||||
# some targets what to tweak options we might want to process now | |||||
.for m in ${DIRDEPS.dirs:S,$,/Makefile.dirdeps.options,} | |||||
.-include <$m> | |||||
.endfor | |||||
.if defined(MK_STATIC_DIRDEPS_CACHE) | |||||
# some targets are very expensive to compute dirdeps for | |||||
# so we may have a static cache | |||||
.for c in ${DIRDEPS.dirs:S,$,/Makefile.dirdeps.cache,} | |||||
.if exists($c) | |||||
STATIC_DIRDEPS_CACHE ?= $c | |||||
.if ${MK_STATIC_DIRDEPS_CACHE} == "yes" | |||||
DIRDEPS_CACHE ?= $c | |||||
MK_DIRDEPS_CACHE = yes | |||||
.endif | |||||
.endif | |||||
.endfor | |||||
.if defined(STATIC_DIRDEPS_CACHE) | |||||
.export STATIC_DIRDEPS_CACHE | |||||
.endif | |||||
.endif | |||||
# allow a top-level makefile to do other stuff | |||||
# before including dirdeps.mk | |||||
.if ${MK_DIRDEPS_TARGETS_INCLUDE_DIRDEPS:Uyes} == "yes" | |||||
.include <dirdeps.mk> | .include <dirdeps.mk> | ||||
.endif | |||||
DIRDEPS_TARGETS_SKIP += all clean* destroy* | DIRDEPS_TARGETS_SKIP += all clean* destroy* | ||||
.for t in ${.TARGETS:${DIRDEPS_TARGETS_SKIP:${M_ListToSkip}}} | .for t in ${.TARGETS:${DIRDEPS_TARGETS_SKIP:${M_ListToSkip}}} | ||||
$t: dirdeps | $t: dirdeps | ||||
.endfor | .endfor | ||||
.endif | .endif | ||||
.endif | .endif |