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