xref: /freebsd/share/mk/dirdeps-options.mk (revision 675aae732d3dd2ec0f12f39df3a1fbfe693a4ebd)
1# $FreeBSD$
2# $Id: dirdeps-options.mk,v 1.9 2018/09/20 00:07:19 sjg Exp $
3#
4#	@(#) Copyright (c) 2018, 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# This should have been set by Makefile.depend.options
43# before including us
44DIRDEPS_OPTIONS ?=
45
46# pickup any DIRDEPS.* we need
47.-include <local.dirdeps-options.mk>
48
49.if ${.MAKE.LEVEL} == 0
50# :U below avoids potential errors when we :=
51.for o in ${DIRDEPS_OPTIONS:tu}
52DIRDEPS += ${DIRDEPS.$o.${MK_$o:U}:U}
53.endfor
54DIRDEPS := ${DIRDEPS:O:u}
55# avoid cross contamination
56.for o in ${DIRDEPS_OPTIONS:tu}
57.undef DIRDEPS.$o.yes
58.undef DIRDEPS.$o.no
59.endfor
60.else
61# whether options are enabled or not,
62# we want to filter out the relevant DIRDEPS.*
63# we should only be included by meta.autodep.mk
64# if dependencies are to be updated
65.for o in ${DIRDEPS_OPTIONS:tu}
66.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no}
67.if exists(${SRCTOP}/$d)
68GENDIRDEPS_FILTER += N$d*
69.elif exists(${SRCTOP}/${d:R})
70GENDIRDEPS_FILTER += N${d:R}*
71.endif
72.endfor
73.endfor
74.endif
75