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