Annotation of pkgsrc/mk/bsd.options.mk, Revision 1.46
1.46 ! dillo 1: # $NetBSD: bsd.options.mk,v 1.45 2005/07/26 09:00:42 dillo Exp $
1.1 jlam 2: #
3: # This Makefile fragment provides boilerplate code for standard naming
4: # conventions for handling per-package build options.
5: #
1.20 dillo 6: # Before including this file, the following variables can be defined:
1.1 jlam 7: #
1.35 dillo 8: # PKG_SUPPORTED_OPTIONS
1.1 jlam 9: # This is a list of build options supported by the package.
10: # This variable should be set in a package Makefile. E.g.,
11: #
12: # PKG_SUPPORTED_OPTIONS= kerberos ldap ssl
13: #
1.40 wiz 14: # PKG_OPTIONS_VAR (must be defined)
1.20 dillo 15: # The variable the user can set to enable or disable
16: # options specifically for this package.
17: #
1.32 dillo 18: # PKG_OPTIONS_OPTIONAL_GROUPS
1.45 dillo 19: # This is a list of names of groups of mutually exclusive
1.32 dillo 20: # options. The options in each group are listed in
21: # PKG_OPTIONS_GROUP.<groupname>. The most specific
22: # setting of any option from the group takes precedence
1.33 wiz 23: # over all other options in the group. Options from
1.32 dillo 24: # the groups will be automatically added to
25: # PKG_SUPPORTED_OPTOINS.
26: #
27: # PKG_OPTIONS_REQUIRED_GROUPS
28: # Like PKG_OPTIONS_OPTIONAL_GROUPS, but building
29: # the packages will fail if no option from the group
30: # is selected.
31: #
1.45 dillo 32: # PKG_OPTIONS_NONEMPTY_SETS
33: # This is a list of names of sets of options. At
34: # least one option from each set must be selected.
35: # The options in each set are listed in
36: # PKG_OPTIONS_SET.<setname>. Options from the sets
37: # will be automatically added to PKG_SUPPORTED_OPTIONS.
38: #
1.20 dillo 39: # PKG_SUGGESTED_OPTIONS (defaults to empty)
40: # This is a list of build options which are enabled by default.
41: #
1.24 dillo 42: # PKG_OPTIONS_LEGACY_VARS
1.20 dillo 43: # This is a list of USE_VARIABLE:option pairs that
44: # map legacy /etc/mk.conf variables to their option
45: # counterparts.
1.26 dillo 46: #
47: # PKG_OPTIONS_LEGACY_OPTS
48: # This is a list of old-option:new-option pairs that
49: # map options that have been renamed to their new
50: # counterparts.
1.35 dillo 51: #
1.38 dillo 52: # PKG_LEGACY_OPTIONS
53: # A list of options implied by deprecated variables
54: # used. This can be used for cases that neither
55: # PKG_OPTIONS_LEGACY_VARS nor PKG_OPTIONS_LEGACY_OPTS
56: # can handle, e. g. when PKG_OPTIONS_VAR is renamed.
57: #
58: # PKG_OPTIONS_DEPRECATED_WARNINGS
59: # A list of warnings about deprecated variables or
60: # options used, and what to use instead.
61: #
1.45 dillo 62: # If none of PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS,
63: # PKG_OPTIONS_REQUIRED_GROUPS, and PKG_OPTIONS_NONEMPTY_SETS are
64: # defined, PKG_OPTIONS is set to the empty list and the package
65: # is otherwise treated as not using the options framework.
1.20 dillo 66: #
67: #
68: # Optionally, the user may define the following variables in /etc/mk.conf:
1.1 jlam 69: #
70: # PKG_DEFAULT_OPTIONS
1.20 dillo 71: # This variable can be used to override default
72: # options for every package. Options listed in this
73: # variable will be enabled in every package that
74: # supports them. If you prefix an option with `-',
75: # it will be disabled in every package.
76: #
77: # ${PKG_OPTIONS_VAR}
78: # This variable can be used to override default
79: # options and options listed in PKG_DEFAULT_OPTIONS.
80: # The syntax is the same as PKG_DEFAULT_OPTIONS.
1.1 jlam 81: #
82: # After including this file, the following variables are defined:
83: #
84: # PKG_OPTIONS
85: # This is the list of the selected build options, properly
86: # filtered to remove unsupported and duplicate options.
87: #
88: # Example usage:
89: #
90: # -------------8<-------------8<-------------8<-------------8<-------------
1.23 jlam 91: # PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
1.26 dillo 92: # PKG_SUPPORTED_OPTIONS= wibble-foo ldap sasl
1.36 seb 93: # PKG_OPTIONS_OPTIONAL_GROUPS= database
94: # PKG_OPTIONS_GROUP.database= mysql pgsql
1.26 dillo 95: # PKG_SUGGESTED_OPTIONS= wibble-foo
1.20 dillo 96: # PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
97: # PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_SASL2:sasl
1.26 dillo 98: # PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 jlam 99: #
1.38 dillo 100: # # this package was previously named wibble2
101: # .include "../../mk/bsd.prefs.mk"
102: #
103: # .if defined(PKG_OPTIONS.wibble2)
104: # PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
1.39 dillo 105: # PKG_OPTIONS_DEPRECATED_WARNINGS+="Deprecated variable PKG_OPTIONS.wibble2 used, use "${PKG_OPTIONS_VAR:Q}" instead."
1.38 dillo 106: # .endif
107: #
1.1 jlam 108: # .include "../../mk/bsd.options.mk"
109: #
110: # # Package-specific option-handling
111: #
112: # ###
1.20 dillo 113: # ### FOO support
114: # ###
1.26 dillo 115: # .if !empty(PKG_OPTIONS:Mwibble-foo)
1.20 dillo 116: # CONFIGURE_ARGS+= --enable-foo
117: # .endif
118:
119: # ###
1.1 jlam 120: # ### LDAP support
121: # ###
122: # .if !empty(PKG_OPTIONS:Mldap)
123: # . include "../../databases/openldap/buildlink3.mk"
124: # CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap}
125: # .endif
126: #
127: # ###
128: # ### SASL authentication
129: # ###
130: # .if !empty(PKG_OPTIONS:Msasl)
131: # . include "../../security/cyrus-sasl2/buildlink3.mk"
132: # CONFIGURE_ARGS+= --enable-sasl=${BUILDLINK_PREFIX.sasl}
133: # .endif
1.32 dillo 134: #
135: # ###
136: # ### database support
137: # ###
138: # .if !empty(PKG_OPTIONS:Mmysql)
139: # . include "../../mk/mysql.buildlink3.mk"
140: # .endif
141: # .if !empty(PKG_OPTIONS:Mpgsql)
142: # . include "../../mk/pgsql.buildlink3.mk"
143: # .endif
1.1 jlam 144: # -------------8<-------------8<-------------8<-------------8<-------------
145:
146: .include "../../mk/bsd.prefs.mk"
147:
1.21 rillig 148: # Define PKG_OPTIONS, no matter if we have an error or not, to suppress
149: # further make(1) warnings.
150: PKG_OPTIONS= # empty
151:
1.1 jlam 152: # Check for variable definitions required before including this file.
1.42 dillo 153: .if !defined(PKG_OPTIONS_VAR)
1.1 jlam 154: PKG_FAIL_REASON+= "bsd.options.mk: PKG_OPTIONS_VAR is not defined."
1.45 dillo 155: .elif !defined(PKG_SUPPORTED_OPTIONS) && !defined(PKG_OPTIONS_OPTIONAL_GROUPS) && !defined(PKG_OPTIONS_REQUIRED_GROUPS) && !defined(PKG_OPTIONS_NONEMPTY_SETS)
1.42 dillo 156: # no supported options: set PKG_OPTIONS to empty and skip rest of file
157: PKG_OPTIONS= #empty
1.21 rillig 158: .else # process the rest of the file
1.1 jlam 159:
1.32 dillo 160: #
161: # create map of option to group and add group options to PKG_SUPPORTED_OPTOINS
162: #
1.37 dillo 163: .for _grp_ in ${PKG_OPTIONS_OPTIONAL_GROUPS} ${PKG_OPTIONS_REQUIRED_GROUPS}
164: _PKG_OPTIONS_GROUP_STACK.${_grp_}:=#empty
1.46 ! dillo 165: .if !defined(PKG_OPTIONS_GROUP.${_grp_}) || empty(PKG_OPTIONS_GROUP.${_grp_})
1.45 dillo 166: PKG_FAIL_REASON:="bsd.options.mk: PKG_OPTIONS_GROUP."${_grp_:Q}" must be non-empty."
167: .endif
1.37 dillo 168: . for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}}
1.32 dillo 169: PKG_SUPPORTED_OPTIONS+= ${_opt_}
1.37 dillo 170: _PKG_OPTIONS_GROUP_MAP.${_opt_}=${_grp_}
1.32 dillo 171: . endfor
172: .endfor
173:
174: #
1.45 dillo 175: # add options from sets to PKG_SUPPORTED_OPTIONS
176: #
177: _PKG_OPTIONS_ALL_SETS:=#empty
178: .for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
179: . if !defined(PKT_OPTIONS_SET.${_set_}) || empty(PKT_OPTIONS_SET.${_set_})
180: PKG_FAIL_REASON:="bsd.options.mk: PKG_OPTIONS_SET."${_set_:Q}" must be non-empty."
181: . endif
182: . for _opt_ in ${PKG_OPTIONS_SET.${_set_}}
183: PKG_SUPPORTED_OPTIONS+= ${_opt_}
184: _PKG_OPTIONS_ALL_SETS+= ${_opt_}
185: . endfor
186: .endfor
187:
188: #
1.34 dillo 189: # include deprecated variable to options mapping
190: #
191: .include "${.CURDIR}/../../mk/defaults/obsolete.mk"
192:
193: #
1.45 dillo 194: # place options implied by legacy variables in PKG_LEGACY_OPTIONS
1.32 dillo 195: #
1.20 dillo 196: .for _m_ in ${PKG_OPTIONS_LEGACY_VARS}
1.24 dillo 197: _var_:= ${_m_:C/:.*//}
198: _opt_:= ${_m_:C/.*://}
1.31 dillo 199: _popt_:=${_opt_:C/^-//}
1.24 dillo 200: . if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
1.29 wiz 201: . if defined(${_var_})
1.38 dillo 202: PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated variable "${_var_:Q}" used, use PKG_DEFAULT_OPTIONS+="${_popt_:Q}" instead."
1.29 wiz 203: . if empty(${_var_}:M[nN][oO])
1.38 dillo 204: PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} ${_opt_}
1.29 wiz 205: . elif empty(_opt_:M-*)
1.38 dillo 206: PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} -${_popt_}
1.29 wiz 207: . else
1.38 dillo 208: PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} ${_popt_}
1.29 wiz 209: . endif
1.24 dillo 210: . endif
211: . endif
1.1 jlam 212: .endfor
1.24 dillo 213: .undef _var_
214: .undef _opt_
215: .undef _popt_
1.20 dillo 216:
1.32 dillo 217: #
218: # create map of old option name to new option name for legacy options
219: #
1.26 dillo 220: .for _m_ in ${PKG_OPTIONS_LEGACY_OPTS}
221: _old_:= ${_m_:C/:.*//}
222: _new_:= ${_m_:C/.*://}
223: . if !empty(PKG_SUPPORTED_OPTIONS:M${_new_})
224: _PKG_LEGACY_OPTMAP.${_old_}:=${_new_}
225: . endif
226: .endfor
227: .undef _old_
228: .undef _new_
229:
1.20 dillo 230: #
1.25 dillo 231: # filter unsupported options from PKG_DEFAULT_OPTIONS
232: #
1.41 jlam 233: _OPTIONS_DEFAULT_SUPPORTED:= #empty
1.25 dillo 234: .for _o_ in ${PKG_DEFAULT_OPTIONS}
235: _opt_:= ${_o_}
236: _popt_:= ${_opt_:C/^-//}
1.26 dillo 237: .if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_}) \
238: || defined(_PKG_LEGACY_OPTMAP.${_popt_})
1.25 dillo 239: _OPTIONS_DEFAULT_SUPPORTED:=${_OPTIONS_DEFAULT_SUPPORTED} ${_opt_}
240: .endif
241: .endfor
242: .undef _opt_
243: .undef _popt_
244:
245: #
1.22 rillig 246: # process options from generic to specific
1.20 dillo 247: #
1.25 dillo 248: PKG_OPTIONS:= # empty
249: _OPTIONS_UNSUPPORTED:= #empty
1.38 dillo 250: .for _o_ in ${PKG_SUGGESTED_OPTIONS} ${PKG_LEGACY_OPTIONS} \
1.25 dillo 251: ${_OPTIONS_DEFAULT_SUPPORTED} ${${PKG_OPTIONS_VAR}}
1.22 rillig 252: _opt_:= ${_o_}
1.25 dillo 253: _popt_:= ${_o_:C/^-//} # positive option
1.26 dillo 254: . if defined(_PKG_LEGACY_OPTMAP.${_popt_})
1.43 dillo 255: PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated option "${_popt_:Q}" used, use option "${_PKG_LEGACY_OPTMAP.${_popt_}:Q}" instead."
1.26 dillo 256: _popt_:= ${_PKG_LEGACY_OPTMAP.${_popt_}}
257: . if empty(_opt_:M-*)
258: _opt_:= ${_popt_}
259: . else
260: _opt_:= -${_popt_}
261: . endif
262: . endif
1.25 dillo 263: . if empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
264: _OPTIONS_UNSUPPORTED:=${_OPTIONS_UNSUPPORTED} ${_opt_}
265: . else
1.32 dillo 266: . if defined(_PKG_OPTIONS_GROUP_MAP.${_popt_})
1.37 dillo 267: _grp_:= ${_PKG_OPTIONS_GROUP_MAP.${_popt_}}
268: _stk_:= _PKG_OPTIONS_GROUP_STACK.${_grp_}
1.32 dillo 269: _cnt_:= ${${_stk_}}
270: . if !empty(_opt_:M-*)
271: ${_stk_}:= ${_cnt_:N${_popt_}}
272: . else
273: ${_stk_}:= ${_cnt_} ${_popt_}
274: . endif
275: . else
276: . if !empty(_opt_:M-*)
1.22 rillig 277: PKG_OPTIONS:= ${PKG_OPTIONS:N${_popt_}}
1.32 dillo 278: . else
1.22 rillig 279: PKG_OPTIONS:= ${PKG_OPTIONS} ${_popt_}
1.32 dillo 280: . endif
1.25 dillo 281: . endif
1.1 jlam 282: . endif
283: .endfor
1.24 dillo 284: .undef _opt_
285: .undef _popt_
1.32 dillo 286: .undef _stk_
287:
1.37 dillo 288: .for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS}
289: . if empty(_PKG_OPTIONS_GROUP_STACK.${_grp_})
290: PKG_FAIL_REASON:="One of the following options must be selected: "${PKG_OPTIONS_GROUP.${_grp_}:O:u:Q}
1.32 dillo 291: . endif
292: .endfor
293:
1.37 dillo 294: .for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS} ${PKG_OPTIONS_OPTIONAL_GROUPS}
1.32 dillo 295: .undef _opt_
1.37 dillo 296: . for _o_ in ${_PKG_OPTIONS_GROUP_STACK.${_grp_}}
1.32 dillo 297: _opt_:= ${_o_}
298: . endfor
299: . if defined(_opt_)
300: PKG_OPTIONS:= ${PKG_OPTIONS} ${_opt_}
301: . endif
302: .endfor
303: .undef _opt_
1.25 dillo 304:
1.45 dillo 305: .for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
306: _ISEMPTY:=true
307: . for _opt_ in ${PKG_OPTIONS_SET.${_set_}
308: . if !empty(PKG_OPTIONS:M${_opt_})
309: _ISEMPTY:=false
310: . endif
311: . endfor
312: . if ${_ISEMPTY} == "true"
313: PKG_FAIL_REASON:="At least one of the following options must be selected: "${PKG_OPTIONS_SET.${_set_}:O:u:Q}
314: . endif
315: .endfor
316: .undef _ISEMPTY
317:
1.25 dillo 318: .if !empty(_OPTIONS_UNSUPPORTED)
1.32 dillo 319: PKG_FAIL_REASON:= "The following selected options are not supported: "${_OPTIONS_UNSUPPORTED:O:u:Q}"."
1.25 dillo 320: .endif
321:
322: .undef _OPTIONS_UNSUPPORTED
323: .undef _OPTIONS_DEFAULT_SUPPORTED
1.22 rillig 324: PKG_OPTIONS:= ${PKG_OPTIONS:O:u}
1.1 jlam 325:
1.10 jlam 326: _PKG_OPTIONS_WORDWRAP_FILTER= \
1.5 jlam 327: ${AWK} ' \
328: BEGIN { printwidth = 40; line = "" } \
329: { \
330: if (length(line) > 0) \
331: line = line" "$$0; \
332: else \
333: line = $$0; \
334: if (length(line) > 40) { \
335: print " "line; \
336: line = ""; \
337: } \
338: } \
339: END { if (length(line) > 0) print " "line } \
340: '
1.10 jlam 341:
1.27 dillo 342: .PHONY: show-options
343: show-options:
1.45 dillo 344: @${ECHO} Any of the following general options may be selected:
1.20 dillo 345: .for _opt_ in ${PKG_SUPPORTED_OPTIONS:O}
1.45 dillo 346: . if !defined(_PKG_OPTIONS_GROUP_MAP.${_opt_}) && empty(_PKG_OPTIONS_ALL_SETS:M${_opt_})
1.20 dillo 347: @${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
1.37 dillo 348: . endif
349: .endfor
350: .for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS}
351: @${ECHO} "Exactly one of the following "${_grp_:Q}" options is required:"
352: . for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}:O}
353: @${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
354: . endfor
355: .endfor
356: .for _grp_ in ${PKG_OPTIONS_OPTIONAL_GROUPS}
357: @${ECHO} "At most one of the following "${_grp_:Q}" options may be selected:"
358: . for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}:O}
359: @${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
360: . endfor
1.20 dillo 361: .endfor
1.45 dillo 362: .for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
363: @${ECHO} "At least one of the following "${_set_:Q}" options must be selected:"
364: . for _opt_ in ${PKG_OPTIONS_SET.${_set_}:O}
365: @${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
366: . endfor
367: .endfor
1.20 dillo 368: @${ECHO}
369: @${ECHO} "These options are enabled by default: "${PKG_SUGGESTED_OPTIONS:O:Q}
370: @${ECHO} "These options are currently enabled: "${PKG_OPTIONS:O:Q}
1.44 dillo 371: . if defined(PKG_OPTIONS_DEPRECATED_WARNINGS)
372: @${ECHO}
373: @for l in ${PKG_OPTIONS_DEPRECATED_WARNINGS}; \
374: do \
375: ${ECHO} "$$l"; \
376: done
377: . endif
1.20 dillo 378:
1.16 tv 379: .if defined(PKG_SUPPORTED_OPTIONS)
380: .PHONY: supported-options-message
1.28 rillig 381: pre-install-depends: supported-options-message
1.16 tv 382: supported-options-message:
1.10 jlam 383: . if !empty(PKG_SUPPORTED_OPTIONS)
384: @${ECHO} "=========================================================================="
385: @${ECHO} "The supported build options for this package are:"
386: @${ECHO} ""
1.19 jlam 387: @${ECHO} ${PKG_SUPPORTED_OPTIONS:O:Q} | ${XARGS} -n 1 | ${_PKG_OPTIONS_WORDWRAP_FILTER}
1.11 jlam 388: . if !empty(PKG_OPTIONS)
1.10 jlam 389: @${ECHO} ""
390: @${ECHO} "The currently selected options are:"
391: @${ECHO} ""
1.19 jlam 392: @${ECHO} ${PKG_OPTIONS:O:Q} | ${XARGS} -n 1 | ${_PKG_OPTIONS_WORDWRAP_FILTER}
1.11 jlam 393: . endif
1.2 jlam 394: @${ECHO} ""
1.20 dillo 395: @${ECHO} "You can select which build options to use by setting PKG_DEFAULT_OPTIONS"
396: @${ECHO} "or the following variable. Its current value is shown:"
1.2 jlam 397: @${ECHO} ""
1.20 dillo 398: . if !defined(${PKG_OPTIONS_VAR})
399: @${ECHO} " ${PKG_OPTIONS_VAR} (not defined)"
400: . else
401: @${ECHO} " ${PKG_OPTIONS_VAR} = ${${PKG_OPTIONS_VAR}}"
402: . endif
1.38 dillo 403: . if defined(PKG_OPTIONS_DEPRECATED_WARNINGS)
1.20 dillo 404: @${ECHO}
1.38 dillo 405: @for l in ${PKG_OPTIONS_DEPRECATED_WARNINGS}; \
1.20 dillo 406: do \
407: ${ECHO} "$$l"; \
408: done
409: . endif
1.2 jlam 410: @${ECHO} ""
411: @${ECHO} "=========================================================================="
412: . endif
413: .endif
1.21 rillig 414:
415: .endif # defined(PKG_OPTIONS_VAR) && defined(PKG_SUPPORTED_OPTIONS)
CVSweb <webmaster@jp.NetBSD.org>