1*6eef5f0cSAntonio Huete Jimenez# $Id: dirdeps-options.mk,v 1.21 2022/09/06 22:18:45 sjg Exp $ 2ca58f742SDaniel Fojt# 3*6eef5f0cSAntonio Huete Jimenez# @(#) Copyright (c) 2018-2022, Simon J. Gerraty 4ca58f742SDaniel Fojt# 5ca58f742SDaniel Fojt# This file is provided in the hope that it will 6ca58f742SDaniel Fojt# be of use. There is absolutely NO WARRANTY. 7ca58f742SDaniel Fojt# Permission to copy, redistribute or otherwise 8ca58f742SDaniel Fojt# use this file is hereby granted provided that 9ca58f742SDaniel Fojt# the above copyright notice and this notice are 10ca58f742SDaniel Fojt# left intact. 11ca58f742SDaniel Fojt# 12ca58f742SDaniel Fojt# Please send copies of changes and bug-fixes to: 13ca58f742SDaniel Fojt# sjg@crufty.net 14ca58f742SDaniel Fojt# 15ca58f742SDaniel Fojt 16ca58f742SDaniel Fojt## 17ca58f742SDaniel Fojt# 18ca58f742SDaniel Fojt# This makefile is used to deal with optional DIRDEPS. 19ca58f742SDaniel Fojt# 20ca58f742SDaniel Fojt# It is to be included by Makefile.depend.options in a 21ca58f742SDaniel Fojt# directory which has DIRDEPS affected by optional features. 22ca58f742SDaniel Fojt# Makefile.depend.options should set DIRDEPS_OPTIONS and 23ca58f742SDaniel Fojt# may also set specific DIRDEPS.* for those options. 24ca58f742SDaniel Fojt# 25ca58f742SDaniel Fojt# If a Makefile.depend.options file exists, it will be included by 26ca58f742SDaniel Fojt# dirdeps.mk and meta.autodep.mk 27ca58f742SDaniel Fojt# 28ca58f742SDaniel Fojt# We include local.dirdeps-options.mk which may also define DIRDEPS.* 29ca58f742SDaniel Fojt# for options. 30ca58f742SDaniel Fojt# 31ca58f742SDaniel Fojt# Thus a directory, that is affected by an option FOO would have 32ca58f742SDaniel Fojt# a Makefile.depend.options that sets 33ca58f742SDaniel Fojt# DIRDEPS_OPTIONS= FOO 34ca58f742SDaniel Fojt# It can also set either/both of 35ca58f742SDaniel Fojt# DIRDEPS.FOO.yes 36ca58f742SDaniel Fojt# DIRDEPS.FOO.no 37ca58f742SDaniel Fojt# to whatever applies for that dir, or it can rely on globals 38ca58f742SDaniel Fojt# set in local.dirdeps-options.mk 39ca58f742SDaniel Fojt# Either way, we will .undef DIRDEPS.* when done. 40a34d5fb1SAntonio Huete Jimenez# 41a34d5fb1SAntonio Huete Jimenez# In some cases the value of MK_FOO might depend on TARGET_SPEC 42a34d5fb1SAntonio Huete Jimenez# so we qualify MK_FOO with .${TARGET_SPEC} and each component 43a34d5fb1SAntonio Huete Jimenez# TARGET_SPEC_VAR (in reverse order) before using MK_FOO. 44a34d5fb1SAntonio Huete Jimenez# 45*6eef5f0cSAntonio Huete Jimenez# Because Makefile.depend.options are processed at both level 0 (when 46*6eef5f0cSAntonio Huete Jimenez# computing DIRDEPS to build) and higher (when updating 47*6eef5f0cSAntonio Huete Jimenez# Makefile.depend* after successful build), it is important that 48*6eef5f0cSAntonio Huete Jimenez# all references to TARGET_SPEC_VARs should use the syntax 49*6eef5f0cSAntonio Huete Jimenez# ${DEP_${TARGET_SPEC_VAR}:U${TARGET_SPEC_VAR}} to ensure correct 50*6eef5f0cSAntonio Huete Jimenez# behavior. 51*6eef5f0cSAntonio Huete Jimenez# 52ca58f742SDaniel Fojt 53ca58f742SDaniel Fojt# This should have been set by Makefile.depend.options 54ca58f742SDaniel Fojt# before including us 55ca58f742SDaniel FojtDIRDEPS_OPTIONS ?= 56ca58f742SDaniel Fojt 57ca58f742SDaniel Fojt# pickup any DIRDEPS.* we need 58ca58f742SDaniel Fojt.-include <local.dirdeps-options.mk> 59ca58f742SDaniel Fojt 60ca58f742SDaniel Fojt.if ${.MAKE.LEVEL} == 0 61ca58f742SDaniel Fojt# :U below avoids potential errors when we := 62a34d5fb1SAntonio Huete Jimenez# some options can depend on TARGET_SPEC! 63a34d5fb1SAntonio Huete JimenezDIRDEPS_OPTIONS_QUALIFIER_LIST ?= \ 64*6eef5f0cSAntonio Huete Jimenez ${DEP_RELDIR} \ 65a34d5fb1SAntonio Huete Jimenez ${DEP_TARGET_SPEC:U${TARGET_SPEC}} \ 66a34d5fb1SAntonio Huete Jimenez ${TARGET_SPEC_VARSr:U${TARGET_SPEC_VARS}:@v@${DEP_$v:U${$v}}@} 67a34d5fb1SAntonio Huete Jimenez# note that we need to include $o in the variable _o$o 68a34d5fb1SAntonio Huete Jimenez# to ensure correct evaluation. 69a34d5fb1SAntonio Huete Jimenez.for o in ${DIRDEPS_OPTIONS} 70a34d5fb1SAntonio Huete Jimenez.undef _o$o 71a34d5fb1SAntonio Huete Jimenez.undef _v$o 72*6eef5f0cSAntonio Huete Jimenez.for x in ${DIRDEPS_OPTIONS_QUALIFIER_LIST:S,^,${DEP_RELDIR}.,} \ 73*6eef5f0cSAntonio Huete Jimenez ${DIRDEPS_OPTIONS_QUALIFIER_LIST} 74*6eef5f0cSAntonio Huete Jimenez#.info MK_$o.$x=${MK_$o.$x:Uundefined} 75a34d5fb1SAntonio Huete Jimenez.if defined(MK_$o.$x) 76a34d5fb1SAntonio Huete Jimenez_o$o ?= MK_$o.$x 77a34d5fb1SAntonio Huete Jimenez_v$o ?= ${MK_$o.$x} 78a34d5fb1SAntonio Huete Jimenez.endif 79a34d5fb1SAntonio Huete Jimenez.endfor 80a34d5fb1SAntonio Huete Jimenez_v$o ?= ${MK_$o} 81a34d5fb1SAntonio Huete Jimenez.if ${_debug_reldir:U0} 82a34d5fb1SAntonio Huete Jimenez.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} 83a34d5fb1SAntonio Huete Jimenez.endif 84a34d5fb1SAntonio Huete JimenezDIRDEPS += ${DIRDEPS.$o.${_v$o:U}:U} 85ca58f742SDaniel Fojt.endfor 86ca58f742SDaniel FojtDIRDEPS := ${DIRDEPS:O:u} 87a34d5fb1SAntonio Huete Jimenez.if ${_debug_reldir:U0} 88a34d5fb1SAntonio Huete Jimenez.info ${DEP_RELDIR:U${RELDIR}}: DIRDEPS=${DIRDEPS} 89a34d5fb1SAntonio Huete Jimenez.endif 90ca58f742SDaniel Fojt# avoid cross contamination 91a34d5fb1SAntonio Huete Jimenez.for o in ${DIRDEPS_OPTIONS} 92ca58f742SDaniel Fojt.undef DIRDEPS.$o.yes 93ca58f742SDaniel Fojt.undef DIRDEPS.$o.no 94a34d5fb1SAntonio Huete Jimenez.undef _o$o 95a34d5fb1SAntonio Huete Jimenez.undef _v$o 96ca58f742SDaniel Fojt.endfor 97ca58f742SDaniel Fojt.else 98ca58f742SDaniel Fojt# whether options are enabled or not, 99ca58f742SDaniel Fojt# we want to filter out the relevant DIRDEPS.* 100ca58f742SDaniel Fojt# we should only be included by meta.autodep.mk 101ca58f742SDaniel Fojt# if dependencies are to be updated 102a34d5fb1SAntonio Huete Jimenez.for o in ${DIRDEPS_OPTIONS} 103ca58f742SDaniel Fojt.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no} 104ca58f742SDaniel Fojt.if exists(${SRCTOP}/$d) 105ca58f742SDaniel FojtGENDIRDEPS_FILTER += N$d* 106ca58f742SDaniel Fojt.elif exists(${SRCTOP}/${d:R}) 107ca58f742SDaniel FojtGENDIRDEPS_FILTER += N${d:R}* 108ca58f742SDaniel Fojt.endif 109ca58f742SDaniel Fojt.endfor 110ca58f742SDaniel Fojt.endfor 111ca58f742SDaniel Fojt.endif 112