1*f974ced3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause 2*f974ced3SSimon J. Gerraty# 3*f974ced3SSimon J. Gerraty# $Id: dirdeps-options.mk,v 1.22 2024/02/17 17:26:57 sjg Exp $ 4a6589ab7SSimon J. Gerraty# 5525d1e20SSimon J. Gerraty# @(#) Copyright (c) 2018-2022, Simon J. Gerraty 6a6589ab7SSimon J. Gerraty# 7a6589ab7SSimon J. Gerraty# This file is provided in the hope that it will 8a6589ab7SSimon J. Gerraty# be of use. There is absolutely NO WARRANTY. 9a6589ab7SSimon J. Gerraty# Permission to copy, redistribute or otherwise 10a6589ab7SSimon J. Gerraty# use this file is hereby granted provided that 11a6589ab7SSimon J. Gerraty# the above copyright notice and this notice are 12a6589ab7SSimon J. Gerraty# left intact. 13a6589ab7SSimon J. Gerraty# 14a6589ab7SSimon J. Gerraty# Please send copies of changes and bug-fixes to: 15a6589ab7SSimon J. Gerraty# sjg@crufty.net 16a6589ab7SSimon J. Gerraty# 17a6589ab7SSimon J. Gerraty 18a6589ab7SSimon J. Gerraty## 19a6589ab7SSimon J. Gerraty# 20a6589ab7SSimon J. Gerraty# This makefile is used to deal with optional DIRDEPS. 21a6589ab7SSimon J. Gerraty# 22a6589ab7SSimon J. Gerraty# It is to be included by Makefile.depend.options in a 23a6589ab7SSimon J. Gerraty# directory which has DIRDEPS affected by optional features. 24a6589ab7SSimon J. Gerraty# Makefile.depend.options should set DIRDEPS_OPTIONS and 25a6589ab7SSimon J. Gerraty# may also set specific DIRDEPS.* for those options. 26a6589ab7SSimon J. Gerraty# 27a6589ab7SSimon J. Gerraty# If a Makefile.depend.options file exists, it will be included by 28a6589ab7SSimon J. Gerraty# dirdeps.mk and meta.autodep.mk 29a6589ab7SSimon J. Gerraty# 30a6589ab7SSimon J. Gerraty# We include local.dirdeps-options.mk which may also define DIRDEPS.* 31a6589ab7SSimon J. Gerraty# for options. 32a6589ab7SSimon J. Gerraty# 33a6589ab7SSimon J. Gerraty# Thus a directory, that is affected by an option FOO would have 34a6589ab7SSimon J. Gerraty# a Makefile.depend.options that sets 35a6589ab7SSimon J. Gerraty# DIRDEPS_OPTIONS= FOO 36a6589ab7SSimon J. Gerraty# It can also set either/both of 37a6589ab7SSimon J. Gerraty# DIRDEPS.FOO.yes 38a6589ab7SSimon J. Gerraty# DIRDEPS.FOO.no 39a6589ab7SSimon J. Gerraty# to whatever applies for that dir, or it can rely on globals 40a6589ab7SSimon J. Gerraty# set in local.dirdeps-options.mk 41a6589ab7SSimon J. Gerraty# Either way, we will .undef DIRDEPS.* when done. 42960b77beSSimon J. Gerraty# 43960b77beSSimon J. Gerraty# In some cases the value of MK_FOO might depend on TARGET_SPEC 44960b77beSSimon J. Gerraty# so we qualify MK_FOO with .${TARGET_SPEC} and each component 45960b77beSSimon J. Gerraty# TARGET_SPEC_VAR (in reverse order) before using MK_FOO. 46960b77beSSimon J. Gerraty# 47bf7aa99aSSimon J. Gerraty# Because Makefile.depend.options are processed at both level 0 (when 48bf7aa99aSSimon J. Gerraty# computing DIRDEPS to build) and higher (when updating 49bf7aa99aSSimon J. Gerraty# Makefile.depend* after successful build), it is important that 50bf7aa99aSSimon J. Gerraty# all references to TARGET_SPEC_VARs should use the syntax 51bf7aa99aSSimon J. Gerraty# ${DEP_${TARGET_SPEC_VAR}:U${TARGET_SPEC_VAR}} to ensure correct 52bf7aa99aSSimon J. Gerraty# behavior. 53bf7aa99aSSimon J. Gerraty# 54a6589ab7SSimon J. Gerraty 55a6589ab7SSimon J. Gerraty# This should have been set by Makefile.depend.options 56a6589ab7SSimon J. Gerraty# before including us 57a6589ab7SSimon J. GerratyDIRDEPS_OPTIONS ?= 58a6589ab7SSimon J. Gerraty 59a6589ab7SSimon J. Gerraty# pickup any DIRDEPS.* we need 60a6589ab7SSimon J. Gerraty.-include <local.dirdeps-options.mk> 61a6589ab7SSimon J. Gerraty 62a6589ab7SSimon J. Gerraty.if ${.MAKE.LEVEL} == 0 63a6589ab7SSimon J. Gerraty# :U below avoids potential errors when we := 64960b77beSSimon J. Gerraty# some options can depend on TARGET_SPEC! 65960b77beSSimon J. GerratyDIRDEPS_OPTIONS_QUALIFIER_LIST ?= \ 66525d1e20SSimon J. Gerraty ${DEP_RELDIR} \ 67960b77beSSimon J. Gerraty ${DEP_TARGET_SPEC:U${TARGET_SPEC}} \ 68960b77beSSimon J. Gerraty ${TARGET_SPEC_VARSr:U${TARGET_SPEC_VARS}:@v@${DEP_$v:U${$v}}@} 69960b77beSSimon J. Gerraty# note that we need to include $o in the variable _o$o 70960b77beSSimon J. Gerraty# to ensure correct evaluation. 71960b77beSSimon J. Gerraty.for o in ${DIRDEPS_OPTIONS} 723b26e5a4SSimon J. Gerraty.undef _o$o 733b26e5a4SSimon J. Gerraty.undef _v$o 74525d1e20SSimon J. Gerraty.for x in ${DIRDEPS_OPTIONS_QUALIFIER_LIST:S,^,${DEP_RELDIR}.,} \ 75525d1e20SSimon J. Gerraty ${DIRDEPS_OPTIONS_QUALIFIER_LIST} 76525d1e20SSimon J. Gerraty#.info MK_$o.$x=${MK_$o.$x:Uundefined} 77960b77beSSimon J. Gerraty.if defined(MK_$o.$x) 78960b77beSSimon J. Gerraty_o$o ?= MK_$o.$x 79960b77beSSimon J. Gerraty_v$o ?= ${MK_$o.$x} 80960b77beSSimon J. Gerraty.endif 81960b77beSSimon J. Gerraty.endfor 82960b77beSSimon J. Gerraty_v$o ?= ${MK_$o} 83960b77beSSimon J. Gerraty.if ${_debug_reldir:U0} 84960b77beSSimon J. Gerraty.info ${DEP_RELDIR:U${RELDIR}}.${DEP_TARGET_SPEC:U${TARGET_SPEC}}: o=$o ${_o$o:UMK_$o}=${_v$o:U} DIRDEPS += ${DIRDEPS.$o.${_v$o:U}:U} 85960b77beSSimon J. Gerraty.endif 86960b77beSSimon J. GerratyDIRDEPS += ${DIRDEPS.$o.${_v$o:U}:U} 87a6589ab7SSimon J. Gerraty.endfor 88a6589ab7SSimon J. GerratyDIRDEPS := ${DIRDEPS:O:u} 89960b77beSSimon J. Gerraty.if ${_debug_reldir:U0} 90960b77beSSimon J. Gerraty.info ${DEP_RELDIR:U${RELDIR}}: DIRDEPS=${DIRDEPS} 91960b77beSSimon J. Gerraty.endif 92a6589ab7SSimon J. Gerraty# avoid cross contamination 93960b77beSSimon J. Gerraty.for o in ${DIRDEPS_OPTIONS} 94fee91942SSimon J. Gerraty.undef DIRDEPS.$o.yes 95fee91942SSimon J. Gerraty.undef DIRDEPS.$o.no 96960b77beSSimon J. Gerraty.undef _o$o 97960b77beSSimon J. Gerraty.undef _v$o 98a6589ab7SSimon J. Gerraty.endfor 99a6589ab7SSimon J. Gerraty.else 100a6589ab7SSimon J. Gerraty# whether options are enabled or not, 101a6589ab7SSimon J. Gerraty# we want to filter out the relevant DIRDEPS.* 102a6589ab7SSimon J. Gerraty# we should only be included by meta.autodep.mk 103a6589ab7SSimon J. Gerraty# if dependencies are to be updated 104960b77beSSimon J. Gerraty.for o in ${DIRDEPS_OPTIONS} 105a6589ab7SSimon J. Gerraty.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no} 106a6589ab7SSimon J. Gerraty.if exists(${SRCTOP}/$d) 107a6589ab7SSimon J. GerratyGENDIRDEPS_FILTER += N$d* 108a6589ab7SSimon J. Gerraty.elif exists(${SRCTOP}/${d:R}) 109a6589ab7SSimon J. GerratyGENDIRDEPS_FILTER += N${d:R}* 110a6589ab7SSimon J. Gerraty.endif 111a6589ab7SSimon J. Gerraty.endfor 112a6589ab7SSimon J. Gerraty.endfor 113a6589ab7SSimon J. Gerraty.endif 114