xref: /freebsd/share/mk/bsd.mkopt.mk (revision ce5fa47c)
15144b2beSWarner Losh#
25144b2beSWarner Losh#
39b01449fSWarner Losh# Generic mechanism to deal with WITH and WITHOUT options and turn
4ce5fa47cSBrooks Davis# them into MK_ options.  Also turn group options into OPT_ options.
55144b2beSWarner Losh#
614cac2a6SJohn-Mark Gurney# For each option FOO in __DEFAULT_YES_OPTIONS, MK_FOO is set to
79b01449fSWarner Losh# "yes", unless WITHOUT_FOO is defined, in which case it is set to
89b01449fSWarner Losh# "no".
95144b2beSWarner Losh#
10b908f6c4SColin Percival# For each option FOO in __REQUIRED_OPTIONS, MK_FOO is set to "yes".
11b908f6c4SColin Percival#
1214cac2a6SJohn-Mark Gurney# For each option FOO in __DEFAULT_NO_OPTIONS, MK_FOO is set to "no",
139b01449fSWarner Losh# unless WITH_FOO is defined, in which case it is set to "yes".
145144b2beSWarner Losh#
1584bfb424SSimon J. Gerraty# For each entry FOO/BAR in __DEFAULT_DEPENDENT_OPTIONS,
1684bfb424SSimon J. Gerraty# MK_FOO is set to "no" if WITHOUT_FOO is defined,
1784bfb424SSimon J. Gerraty# "yes" if WITH_FOO is defined, otherwise the value of MK_BAR.
1884bfb424SSimon J. Gerraty#
199b01449fSWarner Losh# If both WITH_FOO and WITHOUT_FOO are defined, WITHOUT_FOO wins and
209b01449fSWarner Losh# MK_FOO is set to "no" regardless of which list it was in.
219b01449fSWarner Losh#
2284bfb424SSimon J. Gerraty# All of __DEFAULT_YES_OPTIONS, __DEFAULT_NO_OPTIONS and
2384bfb424SSimon J. Gerraty# __DEFAULT_DEPENDENT_OPTIONS are undef'd after all this processing,
2484bfb424SSimon J. Gerraty# allowing this file to be included multiple times with different lists.
259b01449fSWarner Losh#
2606d4e2abSWarner Losh# Other parts of the build system will set BROKEN_OPTIONS to a list
2706d4e2abSWarner Losh# of options that are broken on this platform. This will not be unset
2806d4e2abSWarner Losh# before returning. Clients are expected to always += this variable.
2906d4e2abSWarner Losh#
309b01449fSWarner Losh# Users should generally define WITH_FOO or WITHOUT_FOO, but the build
319b01449fSWarner Losh# system should use MK_FOO={yes,no} when it needs to override the
329b01449fSWarner Losh# user's desires or default behavior.
339b01449fSWarner Losh#
34ce5fa47cSBrooks Davis# For each option in __SINGLE_OPTIONS, OPT_FOO is set to FOO if
35ce5fa47cSBrooks Davis# defined and __FOO_DEFAULT if not.  Valid values for FOO are specified
36ce5fa47cSBrooks Davis# by __FOO_OPTIONS.
37ce5fa47cSBrooks Davis#
38ce5fa47cSBrooks Davis# Other parts of the build system will set BROKEN_SINGLE_OPTIONS to a
39ce5fa47cSBrooks Davis# list of 3-tuples of the form: "OPTION broken_value replacment_value".
40ce5fa47cSBrooks Davis# This will not be unset before returning. Clients are expected to
41ce5fa47cSBrooks Davis# always += this variable.
42ce5fa47cSBrooks Davis#
439b01449fSWarner Losh
449b01449fSWarner Losh#
459b01449fSWarner Losh# MK_* options which default to "yes".
465144b2beSWarner Losh#
475144b2beSWarner Losh.for var in ${__DEFAULT_YES_OPTIONS}
485144b2beSWarner Losh.if !defined(MK_${var})
49f4d987cdSWarner Losh.if defined(WITH_${var}) && ${WITH_${var}} == "no"
50bca92be6SJohn Baldwin.warning Use WITHOUT_${var}=1 instead of WITH_${var}=no
51f4d987cdSWarner Losh.endif
529b01449fSWarner Losh.if defined(WITHOUT_${var})			# WITHOUT always wins
535144b2beSWarner LoshMK_${var}:=	no
545144b2beSWarner Losh.else
555144b2beSWarner LoshMK_${var}:=	yes
565144b2beSWarner Losh.endif
57a469e551SWarner Losh.else
58a469e551SWarner Losh.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
59bca92be6SJohn Baldwin.error Illegal value for MK_${var}: ${MK_${var}}
605144b2beSWarner Losh.endif
61a469e551SWarner Losh.endif # !defined(MK_${var})
625144b2beSWarner Losh.endfor
635144b2beSWarner Losh.undef __DEFAULT_YES_OPTIONS
645144b2beSWarner Losh
655144b2beSWarner Losh#
66b908f6c4SColin Percival# MK_* options which are always yes, typically as a transitional
67b908f6c4SColin Percival# step towards removing the options entirely.
68b908f6c4SColin Percival#
69b908f6c4SColin Percival.for var in ${__REQUIRED_OPTIONS}
70824b64a2SColin Percival.if defined(WITHOUT_${var})
71824b64a2SColin Percival.warning WITHOUT_${var} option ignored: it is no longer supported
72824b64a2SColin Percival.endif
73b908f6c4SColin PercivalMK_${var}:=	yes
74b908f6c4SColin Percival.endfor
75b908f6c4SColin Percival
76b908f6c4SColin Percival#
775144b2beSWarner Losh# MK_* options which default to "no".
785144b2beSWarner Losh#
795144b2beSWarner Losh.for var in ${__DEFAULT_NO_OPTIONS}
805144b2beSWarner Losh.if !defined(MK_${var})
81f4d987cdSWarner Losh.if defined(WITH_${var}) && ${WITH_${var}} == "no"
82bca92be6SJohn Baldwin.warning Use WITHOUT_${var}=1 instead of WITH_${var}=no
83f4d987cdSWarner Losh.endif
843ceb1e53SWarner Losh.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
855144b2beSWarner LoshMK_${var}:=	yes
865144b2beSWarner Losh.else
875144b2beSWarner LoshMK_${var}:=	no
885144b2beSWarner Losh.endif
89a469e551SWarner Losh.else
90a469e551SWarner Losh.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
91bca92be6SJohn Baldwin.error Illegal value for MK_${var}: ${MK_${var}}
925144b2beSWarner Losh.endif
93a469e551SWarner Losh.endif # !defined(MK_${var})
945144b2beSWarner Losh.endfor
955144b2beSWarner Losh.undef __DEFAULT_NO_OPTIONS
9606d4e2abSWarner Losh
9706d4e2abSWarner Losh#
9806d4e2abSWarner Losh# MK_* options which are always no, usually because they are
9906d4e2abSWarner Losh# unsupported/badly broken on this architecture.
10006d4e2abSWarner Losh#
10106d4e2abSWarner Losh.for var in ${BROKEN_OPTIONS}
10206d4e2abSWarner LoshMK_${var}:=	no
10306d4e2abSWarner Losh.endfor
104d800e677SSimon J. Gerraty
105ce5fa47cSBrooks Davis#
106ce5fa47cSBrooks Davis# Group options set an OPT_FOO variable for each option.
107ce5fa47cSBrooks Davis#
108ce5fa47cSBrooks Davis.for opt in ${__SINGLE_OPTIONS}
109ce5fa47cSBrooks Davis.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS)
110ce5fa47cSBrooks Davis.error __${opt}_OPTIONS undefined or empty
111ce5fa47cSBrooks Davis.endif
112ce5fa47cSBrooks Davis.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT)
113ce5fa47cSBrooks Davis.error __${opt}_DEFAULT undefined or empty
114ce5fa47cSBrooks Davis.endif
115ce5fa47cSBrooks Davis.if defined(${opt})
116ce5fa47cSBrooks DavisOPT_${opt}:=	${${opt}}
117ce5fa47cSBrooks Davis.else
118ce5fa47cSBrooks DavisOPT_${opt}:=	${__${opt}_DEFAULT}
119ce5fa47cSBrooks Davis.endif
120ce5fa47cSBrooks Davis.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}}
121ce5fa47cSBrooks Davis.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS}
122ce5fa47cSBrooks Davis.endif
123ce5fa47cSBrooks Davis.endfor
124ce5fa47cSBrooks Davis.undef __SINGLE_OPTIONS
125ce5fa47cSBrooks Davis
126ce5fa47cSBrooks Davis.for opt val rep in ${BROKEN_SINGLE_OPTIONS}
127ce5fa47cSBrooks Davis.if ${OPT_${opt}} == ${val}
128ce5fa47cSBrooks DavisOPT_${opt}:=    ${rep}
129ce5fa47cSBrooks Davis.endif
130ce5fa47cSBrooks Davis.endfor
131ce5fa47cSBrooks Davis
132d800e677SSimon J. Gerraty.for vv in ${__DEFAULT_DEPENDENT_OPTIONS}
133d800e677SSimon J. Gerraty.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
134d800e677SSimon J. GerratyMK_${vv:H}?= no
135d800e677SSimon J. Gerraty.elif defined(WITH_${vv:H})
136d800e677SSimon J. GerratyMK_${vv:H}?= yes
137d800e677SSimon J. Gerraty.elif defined(WITHOUT_${vv:H})
138d800e677SSimon J. GerratyMK_${vv:H}?= no
139d800e677SSimon J. Gerraty.else
140d800e677SSimon J. GerratyMK_${vv:H}?= ${MK_${vv:T}}
141d800e677SSimon J. Gerraty.endif
1427090067bSSimon J. GerratyMK_${vv:H}:= ${MK_${vv:H}}
143d800e677SSimon J. Gerraty.endfor
144d800e677SSimon J. Gerraty.undef __DEFAULT_DEPENDENT_OPTIONS
145