xref: /freebsd/share/mk/bsd.mkopt.mk (revision d0b2dbfa)
1#
2#
3# Generic mechanism to deal with WITH and WITHOUT options and turn
4# them into MK_ options.
5#
6# For each option FOO in __DEFAULT_YES_OPTIONS, MK_FOO is set to
7# "yes", unless WITHOUT_FOO is defined, in which case it is set to
8# "no".
9#
10# For each option FOO in __REQUIRED_OPTIONS, MK_FOO is set to "yes".
11#
12# For each option FOO in __DEFAULT_NO_OPTIONS, MK_FOO is set to "no",
13# unless WITH_FOO is defined, in which case it is set to "yes".
14#
15# For each entry FOO/BAR in __DEFAULT_DEPENDENT_OPTIONS,
16# MK_FOO is set to "no" if WITHOUT_FOO is defined,
17# "yes" if WITH_FOO is defined, otherwise the value of MK_BAR.
18#
19# If both WITH_FOO and WITHOUT_FOO are defined, WITHOUT_FOO wins and
20# MK_FOO is set to "no" regardless of which list it was in.
21#
22# All of __DEFAULT_YES_OPTIONS, __DEFAULT_NO_OPTIONS and
23# __DEFAULT_DEPENDENT_OPTIONS are undef'd after all this processing,
24# allowing this file to be included multiple times with different lists.
25#
26# Other parts of the build system will set BROKEN_OPTIONS to a list
27# of options that are broken on this platform. This will not be unset
28# before returning. Clients are expected to always += this variable.
29#
30# Users should generally define WITH_FOO or WITHOUT_FOO, but the build
31# system should use MK_FOO={yes,no} when it needs to override the
32# user's desires or default behavior.
33#
34
35#
36# MK_* options which default to "yes".
37#
38.for var in ${__DEFAULT_YES_OPTIONS}
39.if !defined(MK_${var})
40.if defined(WITH_${var}) && ${WITH_${var}} == "no"
41.warning Use WITHOUT_${var}=1 instead of WITH_${var}=no
42.endif
43.if defined(WITHOUT_${var})			# WITHOUT always wins
44MK_${var}:=	no
45.else
46MK_${var}:=	yes
47.endif
48.else
49.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
50.error Illegal value for MK_${var}: ${MK_${var}}
51.endif
52.endif # !defined(MK_${var})
53.endfor
54.undef __DEFAULT_YES_OPTIONS
55
56#
57# MK_* options which are always yes, typically as a transitional
58# step towards removing the options entirely.
59#
60.for var in ${__REQUIRED_OPTIONS}
61.if defined(WITHOUT_${var})
62.warning WITHOUT_${var} option ignored: it is no longer supported
63.endif
64MK_${var}:=	yes
65.endfor
66
67#
68# MK_* options which default to "no".
69#
70.for var in ${__DEFAULT_NO_OPTIONS}
71.if !defined(MK_${var})
72.if defined(WITH_${var}) && ${WITH_${var}} == "no"
73.warning Use WITHOUT_${var}=1 instead of WITH_${var}=no
74.endif
75.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
76MK_${var}:=	yes
77.else
78MK_${var}:=	no
79.endif
80.else
81.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
82.error Illegal value for MK_${var}: ${MK_${var}}
83.endif
84.endif # !defined(MK_${var})
85.endfor
86.undef __DEFAULT_NO_OPTIONS
87
88#
89# MK_* options which are always no, usually because they are
90# unsupported/badly broken on this architecture.
91#
92.for var in ${BROKEN_OPTIONS}
93MK_${var}:=	no
94.endfor
95
96.for vv in ${__DEFAULT_DEPENDENT_OPTIONS}
97.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
98MK_${vv:H}?= no
99.elif defined(WITH_${vv:H})
100MK_${vv:H}?= yes
101.elif defined(WITHOUT_${vv:H})
102MK_${vv:H}?= no
103.else
104MK_${vv:H}?= ${MK_${vv:T}}
105.endif
106MK_${vv:H}:= ${MK_${vv:H}}
107.endfor
108.undef __DEFAULT_DEPENDENT_OPTIONS
109