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