Tweak devel/riscv64-none-elf-gcc version 8.4.0_2
[dports.git] / Mk / bsd.options.mk
1 # $FreeBSD$
2 #
3 # These variables are used in port makefiles to define the options for a port.
4 #
5 # OPTIONS_DEFINE                - List of options this ports accept
6 # OPTIONS_DEFINE_${ARCH}        - List of options this ports accept and are
7 #                                 specific to ${ARCH}
8 # OPTIONS_DEFAULT               - List of options activated by default
9 # OPTIONS_DEFAULT_${ARCH}       - List of options activated by default for a
10 #                                 given arch
11 #
12 # ${OPTION}_DESC                - Description of the ${OPTION}
13 #
14 # OPTIONS_SINGLE                - List of single-choice grouped options: 1 and
15 #                                 only 1 among N
16 # OPTIONS_RADIO                 - List of radio-choice grouped options: 0 or 1
17 #                                 among N
18 # OPTIONS_MULTI                 - List of multiple-choice grouped options: at
19 #                                 least 1 among N
20 # OPTIONS_GROUP                 - List of group-choice grouped options: 0 or
21 #                                 more among N
22 #
23 # OPTIONS_SINGLE_${NAME}        - List of OPTIONS grouped as single choice (for
24 #                                 the single named as ${NAME} as defined in
25 #                                 OPTIONS_SINGLE)
26 # OPTIONS_RADIO_${NAME}         - List of OPTIONS grouped as radio choice (for
27 #                                 the radio named as ${NAME} as defined in
28 #                                 OPTIONS_RADIO)
29 # OPTIONS_MULTI_${NAME}         - List of OPTIONS grouped as multiple-choice
30 #                                 (for the multi named as ${NAME} as defined in
31 #                                 OPTIONS_MULTI)
32 # OPTIONS_GROUP_${NAME}         - List of OPTIONS grouped as group-choice (for
33 #                                 the group named as ${NAME} as defined in
34 #                                 OPTIONS_GROUP)
35 #
36 # OPTIONS_EXCLUDE               - List of options unsupported (useful for slave ports)
37 # OPTIONS_EXCLUDE_${ARCH}       - List of options unsupported on a given ${ARCH}
38 # OPTIONS_EXCLUDE_${OPSYS}      - List of options unsupported on a given ${OPSYS}
39 # OPTIONS_EXCLUDE_${OPSYS}_${OSREL:R} - List of options unsupported on a given
40 #                                 ${OPSYS} and major version (11/12/13...)
41 # OPTIONS_SLAVE                 - This is designed for slave ports, it removes an
42 #                                 option from the options list inherited from the
43 #                                 master port and it always adds it to PORT_OPTIONS
44 #                                 meaning activated
45 #
46 # These variables can be used in make.conf to configure options.  They are
47 # processed in the order listed below, i.e. later variables override the effects
48 # of previous variables.  Options saved using the options dialog are processed
49 # right before OPTIONS_SET_FORCE.  When building a port a dialog to configure
50 # options will only appear if there are new options, i.e. options which have not
51 # been configured before either using the option dialog in a previous build or
52 # using the variables below.  You can force the dialog to appear by running
53 # "make config".
54 #
55 # OPTIONS_SET                   - List of options to enable for all ports.
56 # OPTIONS_UNSET                 - List of options to disable for all ports.
57 # ${OPTIONS_NAME}_SET           - List of options to enable for a specific port.
58 # ${OPTIONS_NAME}_UNSET         - List of options to disable for a specific port.
59 #
60 # OPTIONS_SET_FORCE             - List of options to enable for all ports.
61 # OPTIONS_UNSET_FORCE           - List of options to disable for all ports.
62 # ${OPTIONS_NAME}_SET_FORCE     - List of options to enable for a specific port.
63 # ${OPTIONS_NAME}_UNSET_FORCE
64 #                               - List of options to disable for a specific port.
65 #
66 # These variables can be used on the command line. They override the effects of
67 # the make.conf variables above.
68 #
69 # WITH                          - Set options from the command line
70 # WITHOUT                       - Unset options from the command line
71 #
72 #
73 # These variables are strictly informational (read-only).  They indicate the
74 # current state of the selected options; they are space-delimited lists.
75 #
76 # SELECTED_OPTIONS              - list of options set "on"
77 # DESELECTED_OPTIONS            - list of options set "off"
78 #
79 #
80 # The following knobs are there to simplify the handling of OPTIONS in simple
81 # cases :
82 #
83 # OPTIONS_SUB                   When defined it will add to PLIST_SUB:
84 #                               Option enabled  ${opt}=""
85 #                               Option disabled ${opt}="@comment "
86 #
87 # ${opt}_CONFIGURE_ON           When option is enabled, it will add its content to
88 #                               the CONFIGURE_ARGS.
89 # ${opt}_CONFIGURE_OFF          When option is disabled, it will add its content to
90 #                               the CONFIGURE_ARGS.
91 # ${opt}_CONFIGURE_ENABLE       Will add to CONFIGURE_ARGS:
92 #                               Option enabled  --enable-${content}
93 #                               Option disabled --disable-${content}
94 # ${opt}_CONFIGURE_WITH         Will add to CONFIGURE_ARGS:
95 #                               Option enabled  --with-${content}
96 #                               Option disabled --without-${content}
97 #
98 # ${opt}_CMAKE_ON               When option is enabled, it will add its content to
99 #                               the CMAKE_ARGS.
100 # ${opt}_CMAKE_OFF              When option is disabled, it will add its content to
101 #                               the CMAKE_ARGS.
102 #
103 # ${opt}_CMAKE_BOOL             Will add to CMAKE_ARGS:
104 #                               Option enabled  -D${content}:BOOL=true
105 #                               Option disabled -D${content}:BOOL=false
106 # ${opt}_CMAKE_BOOL_OFF         Will add to CMAKE_ARGS:
107 #                               Option enabled  -D${content}:BOOL=false
108 #                               Option disabled -D${content}:BOOL=true
109 #
110 # ${opt}_QMAKE_ON               When option is enabled, it will add its content to
111 #                               the QMAKE_ARGS.
112 # ${opt}_QMAKE_OFF              When option is disabled, it will add its content to
113 #                               the QMAKE_ARGS.
114 #
115 # ${opt}_MESON_ON               When option is enabled, it will add its
116 #                               content to MESON_ARGS.
117 # ${opt}_MESON_OFF              When option is disabled, it will add its
118 #                               content to MESON_ARGS.
119 #
120 # ${opt}_MESON_TRUE             Will add to MESON_ARGS:
121 #                               Option enabled  -D${content}=true
122 #                               Option disabled -D${content}=false
123 # ${opt}_MESON_FALSE            Will add to MESON_ARGS:
124 #                               Option enabled  -D${content}=false
125 #                               Option disabled -D${content}=true
126 #
127 # ${opt}_MESON_YES              Will add to MESON_ARGS:
128 #                               Option enabled  -D${content}=yes
129 #                               Option disabled -D${content}=no
130 # ${opt}_MESON_NO               Will add to MESON_ARGS:
131 #                               Option enabled  -D${content}=no
132 #                               Option disabled -D${content}=yes
133 #
134 # ${opt}_MESON_ENABLED          Will add to MESON_ARGS:
135 #                               Option enabled  -D${content}=enabled
136 #                               Option disabled -D${content}=disabled
137 # ${opt}_MESON_DISABLED         Will add to MESON_ARGS:
138 #                               Option enabled  -D${content}=disabled
139 #                               Option disabled -D${content}=enabled
140 #
141 # ${opt}_IMPLIES                When opt is enabled, options named in IMPLIES will
142 #                               get enabled too.
143 # ${opt}_PREVENTS               When opt is enabled, if any options in PREVENTS are
144 #                               also enabled, it will produce an error.
145 # ${opt}_PREVENTS_MSG           Provides a message explaining why the options
146 #                               cannot be selected together.
147 #
148 # ${opt}_USE=   FOO=bar         When option is enabled, it will  enable
149 #                               USE_FOO+= bar
150 #                               If you need more than one option, you can do
151 #                               FOO=bar,baz and you'll get USE_FOO=bar baz
152 # ${opt}_USE_OFF=       FOO=bar When option is disabled, it will enable
153 #                               USE_FOO+= bar
154 #
155 # ${opt}_VARS=  FOO=bar         When option is enabled, it will set
156 #                               FOO= bar
157 # ${opt}_VARS=  FOO+=bar        When option is enabled, it will append
158 #                               FOO+= bar
159 # ${opt}_VARS_OFF=    FOO=bar   When option is disabled, it will set
160 #                               FOO= bar
161 # ${opt}_VARS_OFF=    FOO+=bar  When option is disabled, it will append
162 #                               FOO+= bar
163 #
164 # For each of the depends target PKG FETCH EXTRACT PATCH BUILD LIB RUN,
165 # defining ${opt}_${deptype}_DEPENDS will add its content to the actual
166 # dependency when the option is enabled.  Defining
167 # ${opt}_${deptype}_DEPENDS_OFF will add its content to the actual dependency
168 # when the option is disabled.
169 #
170 # For each of the variables in _OPTIONS_FLAGS below, defining
171 # ${opt}_${variable} will add its content to the actual variable when the
172 # option is enabled.  Defining ${opt}_${variable}_OFF will add its content to
173 # the actual variable when the option is disabled.
174
175 ##
176 # Set all the options available for the ports, beginning with the
177 # global ones and ending with the ones decided by the maintainer.
178
179 .if !defined(OPTIONSMKINCLUDED)
180 OPTIONSMKINCLUDED=      bsd.options.mk
181
182 OPTIONS_NAME?=  ${PKGORIGIN:S/\//_/}
183 OPTIONS_FILE?=  ${PORT_DBDIR}/${OPTIONS_NAME}/options
184
185 _OPTIONS_FLAGS= ALL_TARGET BROKEN CATEGORIES CFLAGS CONFIGURE_ENV CONFLICTS \
186                 CONFLICTS_BUILD CONFLICTS_INSTALL CPPFLAGS CXXFLAGS \
187                 DESKTOP_ENTRIES DISTFILES EXECUTABLES EXTRA_PATCHES EXTRACT_ONLY \
188                 GH_ACCOUNT GH_PROJECT GH_SUBDIR GH_TAGNAME GH_TUPLE \
189                 GL_ACCOUNT GL_COMMIT GL_PROJECT GL_SITE GL_SUBDIR GL_TUPLE \
190                 IGNORE INFO INSTALL_TARGET LDFLAGS LIBS MAKE_ARGS MAKE_ENV \
191                 MASTER_SITES PATCHFILES PATCH_SITES PLIST_DIRS PLIST_FILES \
192                 PLIST_SUB PORTDOCS PORTEXAMPLES SUB_FILES SUB_LIST \
193                 TEST_TARGET USE_CABAL USES BINARY_ALIAS
194 _OPTIONS_DEPENDS=       PKG FETCH EXTRACT PATCH BUILD LIB RUN TEST
195 _ALL_OPTIONS_HELPERS=   ${_OPTIONS_DEPENDS:S/$/_DEPENDS/} \
196                         ${_OPTIONS_DEPENDS:S/$/_DEPENDS_OFF/} \
197                         ${_OPTIONS_FLAGS:S/$/_OFF/} ${_OPTIONS_FLAGS} \
198                         CABAL_FLAGS CMAKE_BOOL CMAKE_BOOL_OFF CMAKE_OFF CMAKE_ON \
199                         CONFIGURE_ENABLE CONFIGURE_OFF CONFIGURE_ON \
200                         CONFIGURE_WITH IMPLIES MESON_ARGS MESON_DISABLED \
201                         MESON_ENABLED MESON_FALSE MESON_OFF MESON_ON MESON_TRUE \
202                         PREVENTS PREVENTS_MSG QMAKE_OFF QMAKE_ON USE USE_OFF \
203                         VARS VARS_OFF
204
205 # The format here is target_family:priority:target-type
206 _OPTIONS_TARGETS=       fetch:300:pre fetch:500:do fetch:700:post \
207                         extract:300:pre extract:500:do extract:700:post \
208                         patch:300:pre patch:500:do patch:700:post \
209                         configure:300:pre configure:500:do configure:700:post \
210                         build:300:pre build:500:do build:700:post \
211                         install:300:pre install:500:do install:700:post  \
212                         test:300:pre test:500:do test:700:post  \
213                         package:300:pre package:500:do package:700:post \
214                         stage:800:post
215
216 # Add per arch options
217 .for opt in ${OPTIONS_DEFINE_${ARCH}}
218 .if empty(OPTIONS_DEFINE:M${opt})
219 OPTIONS_DEFINE+=        ${opt}
220 .endif
221 .endfor
222
223 # Add per arch defaults
224 OPTIONS_DEFAULT+=       ${OPTIONS_DEFAULT_${ARCH}}
225
226 _ALL_EXCLUDE=   ${OPTIONS_EXCLUDE_${ARCH}} ${OPTIONS_EXCLUDE} \
227                 ${OPTIONS_SLAVE} ${OPTIONS_EXCLUDE_${OPSYS}} \
228                 ${OPTIONS_EXCLUDE_${OPSYS}_${OSREL:R}}
229
230 .for opt in ${OPTIONS_DEFINE:O:u}
231 .  if !${_ALL_EXCLUDE:M${opt}}
232 .    for opt_implied in ${${opt}_IMPLIES}
233 .       if ${_ALL_EXCLUDE:M${opt_implied}}
234 _ALL_EXCLUDE+=  ${opt}
235 .       endif
236 .    endfor
237 .  endif
238 .endfor
239
240 # Remove options the port maintainer doesn't want, part 1
241 .for opt in ${_ALL_EXCLUDE:O:u}
242 OPTIONS_DEFAULT:=       ${OPTIONS_DEFAULT:N${opt}}
243 OPTIONS_DEFINE:=        ${OPTIONS_DEFINE:N${opt}}
244 .  for otype in SINGLE RADIO MULTI GROUP
245 .    for m in ${OPTIONS_${otype}}
246 OPTIONS_${otype}_${m}:= ${OPTIONS_${otype}_${m}:N${opt}}
247 .    endfor
248 .  endfor
249 .endfor
250
251 # Remove empty SINGLE/GROUP/RADIO/MULTI
252 # Can be empty because of exclude/slaves
253 .for otype in SINGLE RADIO MULTI GROUP
254 .  for m in ${OPTIONS_${otype}}
255 .    if empty(OPTIONS_${otype}_${m})
256 OPTIONS_${otype}:=      ${OPTIONS_${otype}:N${m}}
257 .    endif
258 .  endfor
259 .endfor
260
261 # Sort options
262 ALL_OPTIONS:=   ${OPTIONS_DEFINE:O:u}
263 OPTIONS_DEFAULT:=       ${OPTIONS_DEFAULT:O:u}
264
265 # complete list
266 COMPLETE_OPTIONS_LIST=  ${ALL_OPTIONS}
267 .for otype in SINGLE RADIO MULTI GROUP
268 .  for m in ${OPTIONS_${otype}}
269 COMPLETE_OPTIONS_LIST+= ${OPTIONS_${otype}_${m}}
270 .  endfor
271 .endfor
272
273 # Some options are always enabled by default.
274 .for _opt in DOCS NLS EXAMPLES IPV6
275 .if ${COMPLETE_OPTIONS_LIST:M${_opt}}
276 PORT_OPTIONS+=  ${_opt}
277 .endif
278 .endfor
279
280 # Remove options the port maintainer doesn't want, part 2
281 .for opt in ${_ALL_EXCLUDE:O:u}
282 PORT_OPTIONS:=          ${PORT_OPTIONS:N${opt}}
283 .endfor
284
285 ## Now create the list of activated options
286 .if defined(OPTIONS_OVERRIDE)
287 # Special case $OPTIONS_OVERRIDE; if it is defined forget about anything done
288 # before
289 NEW_OPTIONS=
290 PORT_OPTIONS:=  ${OPTIONS_OVERRIDE}
291 .else
292 NEW_OPTIONS=    ${COMPLETE_OPTIONS_LIST}
293
294 ## Set default options defined by the port maintainer
295 PORT_OPTIONS+=  ${OPTIONS_DEFAULT}
296
297 ## Set system-wide defined options (set by user in make.conf)
298 .  for opt in ${OPTIONS_SET}
299 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
300 PORT_OPTIONS+=  ${opt}
301 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
302 .    endif
303 .  endfor
304
305 ## Remove the options excluded system-wide (set by user in make.conf)
306 .  for opt in ${OPTIONS_UNSET}
307 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
308 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
309 .  endfor
310
311 ## Set the options specified per-port (set by user in make.conf)
312 .  for opt in ${${OPTIONS_NAME}_SET}
313 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
314 PORT_OPTIONS+=  ${opt}
315 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
316 .    endif
317 .  endfor
318
319 ## Unset the options excluded per-port (set by user in make.conf)
320 .  for opt in ${${OPTIONS_NAME}_UNSET}
321 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
322 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
323 .  endfor
324
325 ## options files (from dialog)
326 .  if exists(${OPTIONS_FILE}) && !make(rmconfig)
327 .  include "${OPTIONS_FILE}"
328 .  endif
329 .  sinclude "${OPTIONS_FILE}.local"
330
331 _OPTIONS_UNIQUENAME=    ${PKGNAMEPREFIX}${PORTNAME}
332 .for _k in SET UNSET SET_FORCE UNSET_FORCE
333 .if defined(${_OPTIONS_UNIQUENAME}_${_k})
334 WARNING+=       "You are using ${_OPTIONS_UNIQUENAME}_${_k} which is not supported any more, use:"
335 WARNING+=       "${OPTIONS_NAME}_${_k}= ${${_OPTIONS_UNIQUENAME}_${_k}}"
336 .endif
337 .endfor
338
339 ## Finish by using the options set by the port config dialog, if any
340 .  for opt in ${OPTIONS_FILE_SET}
341 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
342 PORT_OPTIONS+=  ${opt}
343 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
344 .    endif
345 .  endfor
346
347 .for opt in ${OPTIONS_FILE_UNSET}
348 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
349 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
350 .endfor
351
352 .endif
353
354 ## FORCE
355 ## Set system-wide defined options (set by user in make.conf)
356 .  for opt in ${OPTIONS_SET_FORCE}
357 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
358 PORT_OPTIONS+=  ${opt}
359 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
360 .    endif
361 .  endfor
362
363 ## Remove the options excluded system-wide (set by user in make.conf)
364 .  for opt in ${OPTIONS_UNSET_FORCE}
365 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
366 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
367 .  endfor
368
369 ## Set the options specified per-port (set by user in make.conf)
370 .  for opt in ${${OPTIONS_NAME}_SET_FORCE}
371 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
372 PORT_OPTIONS+=  ${opt}
373 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
374 .    endif
375 .  endfor
376
377 ## Unset the options excluded per-port (set by user in make.conf)
378 .  for opt in ${${OPTIONS_NAME}_UNSET_FORCE}
379 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
380 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
381 .  endfor
382
383
384 ## Cmdline always win over the rest
385 .for opt in ${WITH}
386 .  if !empty(COMPLETE_OPTIONS_LIST:M${opt})
387 PORT_OPTIONS+=  ${opt}
388 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
389 .  endif
390 .endfor
391
392 .for opt in ${WITHOUT}
393 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
394 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
395 .endfor
396
397 ## Enable options implied by other options
398 # _PREVENTS is handled in bsd.port.mk:pre-check-config
399 ## 1) Build dependency chain in A.B format:
400 _DEPCHAIN=
401 .for opt in ${COMPLETE_OPTIONS_LIST}
402 .  for o in ${${opt}_IMPLIES}
403 _DEPCHAIN+=     ${opt}.$o
404 .  endfor
405 .endfor
406 ## 2) Check each dependency pair and if LHS is in PORT_OPTIONS then add RHS.
407 ##    All of RHS of "RHS.*" (i.e. indirect dependency) are also added for
408 ##    fast convergence.
409 _PORT_OPTIONS:= ${PORT_OPTIONS}
410 .for _count in _0 ${COMPLETE_OPTIONS_LIST}
411 count=  ${_count}
412 ### Check if all of the nested dependency are resolved already.
413 .  if ${count} == _0 || ${_PORT_OPTIONS} != ${PORT_OPTIONS}
414 PORT_OPTIONS:=  ${_PORT_OPTIONS}
415 .    for dc in ${_DEPCHAIN}
416 .      for opt in ${_PORT_OPTIONS}
417 _opt=${opt}
418 ### Add all of direct and indirect dependency only if
419 ### they are not in ${PORT_OPTIONS}.
420 .        if !empty(_opt:M${dc:R})
421 .          for d in ${dc:E} ${_DEPCHAIN:M${dc:E}.*:E}
422 .            if empty(_PORT_OPTIONS:M$d)
423 _PORT_OPTIONS+= $d
424 .            endif
425 .          endfor
426 .        endif
427 .      endfor
428 .    endfor
429 .  endif
430 .endfor
431
432 # Finally, add options required by slave ports
433 PORT_OPTIONS+=  ${OPTIONS_SLAVE}
434
435 # Sort options and eliminate duplicates
436 PORT_OPTIONS:=  ${PORT_OPTIONS:O:u}
437
438 _REALLY_ALL_POSSIBLE_OPTIONS:=  ${COMPLETE_OPTIONS_LIST} ${_ALL_EXCLUDE}
439 _REALLY_ALL_POSSIBLE_OPTIONS:=  ${_REALLY_ALL_POSSIBLE_OPTIONS:O:u}
440
441 # Handle PORTDOCS and PORTEXAMPLES
442 .for _type in DOCS EXAMPLES
443 . if !empty(_REALLY_ALL_POSSIBLE_OPTIONS:M${_type})
444 .  if empty(PORT_OPTIONS:M${_type})
445 PLIST_SUB+=             PORT${_type}="@comment "
446 .  else
447 PLIST_SUB+=             PORT${_type}=""
448 .  endif
449 . endif
450 .endfor
451
452 .if defined(NO_OPTIONS_SORT)
453 ALL_OPTIONS=    ${OPTIONS_DEFINE}
454 .endif
455
456 .for target in ${_OPTIONS_TARGETS:C/:.*//:u}
457 _OPTIONS_${target}?=
458 .endfor
459
460 .for opt in ${_REALLY_ALL_POSSIBLE_OPTIONS}
461 # PLIST_SUB
462 PLIST_SUB?=
463 SUB_LIST?=
464 .  if defined(OPTIONS_SUB)
465 .    if ! ${PLIST_SUB:M${opt}=*}
466 .      if ${PORT_OPTIONS:M${opt}}
467 PLIST_SUB:=     ${PLIST_SUB} ${opt}="" NO_${opt}="@comment "
468 .      else
469 PLIST_SUB:=     ${PLIST_SUB} ${opt}="@comment " NO_${opt}=""
470 .      endif
471 .    endif
472 .    if ! ${SUB_LIST:M${opt}=*}
473 .      if ${PORT_OPTIONS:M${opt}}
474 SUB_LIST:=      ${SUB_LIST} ${opt}="" NO_${opt}="@comment "
475 .      else
476 SUB_LIST:=      ${SUB_LIST} ${opt}="@comment " NO_${opt}=""
477 .      endif
478 .    endif
479 .  endif
480
481 .  if ${PORT_OPTIONS:M${opt}}
482 .    if defined(${opt}_USE)
483 .      for option in ${${opt}_USE:C/=.*//:O:u}
484 _u=             ${option}
485 USE_${_u:tu}+=  ${${opt}_USE:M${option}=*:C/.*=//g:C/,/ /g}
486 .      endfor
487 .    endif
488 .    if defined(${opt}_VARS)
489 .      for var in ${${opt}_VARS:C/=.*//:O:u}
490 _u=                     ${var}
491 .        if ${_u:M*+}
492 ${_u:C/.$//:tu}+=       ${${opt}_VARS:M${var}=*:C/[^+]*\+=//:C/^"(.*)"$$/\1/}
493 .        else
494 ${_u:tu}=               ${${opt}_VARS:M${var}=*:C/[^=]*=//:C/^"(.*)"$$/\1/}
495 .        endif
496 .      endfor
497 .    endif
498 .    if defined(${opt}_CONFIGURE_ENABLE)
499 CONFIGURE_ARGS+=        ${${opt}_CONFIGURE_ENABLE:S/^/--enable-/}
500 .    endif
501 .    if defined(${opt}_CONFIGURE_WITH)
502 CONFIGURE_ARGS+=        ${${opt}_CONFIGURE_WITH:S/^/--with-/}
503 .    endif
504 .    if defined(${opt}_CMAKE_BOOL)
505 CMAKE_ARGS+=            ${${opt}_CMAKE_BOOL:C/.*/-D&:BOOL=true/}
506 .    endif
507 .    if defined(${opt}_CMAKE_BOOL_OFF)
508 CMAKE_ARGS+=            ${${opt}_CMAKE_BOOL_OFF:C/.*/-D&:BOOL=false/}
509 .    endif
510 .    if defined(${opt}_MESON_TRUE)
511 MESON_ARGS+=            ${${opt}_MESON_TRUE:C/.*/-D&=true/}
512 .    endif
513 .    if defined(${opt}_MESON_FALSE)
514 MESON_ARGS+=            ${${opt}_MESON_FALSE:C/.*/-D&=false/}
515 .    endif
516 .    if defined(${opt}_MESON_YES)
517 MESON_ARGS+=            ${${opt}_MESON_YES:C/.*/-D&=yes/}
518 .    endif
519 .    if defined(${opt}_MESON_NO)
520 MESON_ARGS+=            ${${opt}_MESON_NO:C/.*/-D&=no/}
521 .    endif
522 .    if defined(${opt}_MESON_ENABLED)
523 MESON_ARGS+=            ${${opt}_MESON_ENABLED:C/.*/-D&=enabled/}
524 .    endif
525 .    if defined(${opt}_MESON_DISABLED)
526 MESON_ARGS+=            ${${opt}_MESON_DISABLED:C/.*/-D&=disabled/}
527 .    endif
528 .    if defined(${opt}_CABAL_FLAGS)
529 CABAL_FLAGS+=   ${${opt}_CABAL_FLAGS}
530 .    endif
531 .    for configure in CONFIGURE CMAKE MESON QMAKE
532 .      if defined(${opt}_${configure}_ON)
533 ${configure}_ARGS+=     ${${opt}_${configure}_ON}
534 .      endif
535 .    endfor
536 .    for flags in ${_OPTIONS_FLAGS}
537 .      if defined(${opt}_${flags})
538 ${flags}+=      ${${opt}_${flags}}
539 .      endif
540 .    endfor
541 .    for deptype in ${_OPTIONS_DEPENDS}
542 .      if defined(${opt}_${deptype}_DEPENDS)
543 ${deptype}_DEPENDS+=    ${${opt}_${deptype}_DEPENDS}
544 .      endif
545 .    endfor
546 .    for target in ${_OPTIONS_TARGETS}
547 _target=        ${target:C/:.*//}
548 _prio=          ${target:C/.*:(.*):.*/\1/}
549 _type=          ${target:C/.*://}
550 _OPTIONS_${_target}:=   ${_OPTIONS_${_target}} ${_prio}:${_type}-${_target}-${opt}-on
551 .    endfor
552 .  else
553 .    if defined(${opt}_USE_OFF)
554 .      for option in ${${opt}_USE_OFF:C/=.*//:O:u}
555 _u=             ${option}
556 USE_${_u:tu}+=  ${${opt}_USE_OFF:M${option}=*:C/.*=//g:C/,/ /g}
557 .      endfor
558 .    endif
559 .    if defined(${opt}_VARS_OFF)
560 .      for var in ${${opt}_VARS_OFF:C/=.*//:O:u}
561 _u=                     ${var}
562 .        if ${_u:M*+}
563 ${_u:C/.$//:tu}+=       ${${opt}_VARS_OFF:M${var}=*:C/[^+]*\+=//:C/^"(.*)"$$/\1/}
564 .        else
565 ${_u:tu}=               ${${opt}_VARS_OFF:M${var}=*:C/[^=]*=//:C/^"(.*)"$$/\1/}
566 .        endif
567 .      endfor
568 .    endif
569 .    if defined(${opt}_CONFIGURE_ENABLE)
570 CONFIGURE_ARGS+=        ${${opt}_CONFIGURE_ENABLE:S/^/--disable-/:C/=.*//}
571 .    endif
572 .    if defined(${opt}_CONFIGURE_WITH)
573 CONFIGURE_ARGS+=        ${${opt}_CONFIGURE_WITH:S/^/--without-/:C/=.*//}
574 .    endif
575 .    if defined(${opt}_CMAKE_BOOL)
576 CMAKE_ARGS+=            ${${opt}_CMAKE_BOOL:C/.*/-D&:BOOL=false/}
577 .    endif
578 .    if defined(${opt}_CMAKE_BOOL_OFF)
579 CMAKE_ARGS+=            ${${opt}_CMAKE_BOOL_OFF:C/.*/-D&:BOOL=true/}
580 .    endif
581 .    if defined(${opt}_MESON_TRUE)
582 MESON_ARGS+=            ${${opt}_MESON_TRUE:C/.*/-D&=false/}
583 .    endif
584 .    if defined(${opt}_MESON_FALSE)
585 MESON_ARGS+=            ${${opt}_MESON_FALSE:C/.*/-D&=true/}
586 .    endif
587 .    if defined(${opt}_MESON_YES)
588 MESON_ARGS+=            ${${opt}_MESON_YES:C/.*/-D&=no/}
589 .    endif
590 .    if defined(${opt}_MESON_NO)
591 MESON_ARGS+=            ${${opt}_MESON_NO:C/.*/-D&=yes/}
592 .    endif
593 .    if defined(${opt}_MESON_ENABLED)
594 MESON_ARGS+=            ${${opt}_MESON_ENABLED:C/.*/-D&=disabled/}
595 .    endif
596 .    if defined(${opt}_MESON_DISABLED)
597 MESON_ARGS+=            ${${opt}_MESON_DISABLED:C/.*/-D&=enabled/}
598 .    endif
599 .    if defined(${opt}_CABAL_FLAGS)
600 CABAL_FLAGS+=   -${${opt}_CABAL_FLAGS}
601 .    endif
602 .    for configure in CONFIGURE CMAKE MESON QMAKE
603 .      if defined(${opt}_${configure}_OFF)
604 ${configure}_ARGS+=     ${${opt}_${configure}_OFF}
605 .      endif
606 .    endfor
607 .    for flags in ${_OPTIONS_FLAGS}
608 .      if defined(${opt}_${flags}_OFF)
609 ${flags}+=      ${${opt}_${flags}_OFF}
610 .      endif
611 .    endfor
612 .    for deptype in ${_OPTIONS_DEPENDS}
613 .      if defined(${opt}_${deptype}_DEPENDS_OFF)
614 ${deptype}_DEPENDS+=    ${${opt}_${deptype}_DEPENDS_OFF}
615 .      endif
616 .    endfor
617 .    for target in ${_OPTIONS_TARGETS}
618 _target=        ${target:C/:.*//}
619 _prio=          ${target:C/.*:(.*):.*/\1/}
620 _type=          ${target:C/.*://}
621 _OPTIONS_${_target}:=   ${_OPTIONS_${_target}} ${_prio}:${_type}-${_target}-${opt}-off
622 .    endfor
623 .  endif
624 .endfor
625
626 # Collect which options helpers are defined at this point for
627 # bsd.sanity.mk later to make sure no other options helper is
628 # defined after bsd.port.options.mk.
629 _OPTIONS_HELPERS_SEEN=
630 .for opt in ${_REALLY_ALL_POSSIBLE_OPTIONS}
631 .  for helper in ${_ALL_OPTIONS_HELPERS}
632 .    if defined(${opt}_${helper})
633 _OPTIONS_HELPERS_SEEN+= ${opt}_${helper}
634 .    endif
635 .  endfor
636 .endfor
637
638 .undef (SELECTED_OPTIONS)
639 .undef (DESELECTED_OPTIONS)
640 # Wait to expand PORT_OPTIONS until the last moment in case something modifies
641 # the selected OPTIONS after bsd.port.options.mk is included.  This uses
642 # bmake's :@ for loop.
643 _SELECTED_OPTIONS=      ${ALL_OPTIONS:@opt@${PORT_OPTIONS:M${opt}}@}
644 _DESELECTED_OPTIONS=    ${ALL_OPTIONS:@opt@${"${PORT_OPTIONS:M${opt}}":?:${opt}}@}
645 .for otype in MULTI GROUP SINGLE RADIO
646 .  for m in ${OPTIONS_${otype}}
647 _SELECTED_OPTIONS+=     ${OPTIONS_${otype}_${m}:@opt@${PORT_OPTIONS:M${opt}}@}
648 _DESELECTED_OPTIONS+=   ${OPTIONS_${otype}_${m}:@opt@${"${PORT_OPTIONS:M${opt}}":?:${opt}}@}
649 .  endfor
650 .endfor
651 SELECTED_OPTIONS=       ${_SELECTED_OPTIONS:O:u}
652 DESELECTED_OPTIONS=     ${_DESELECTED_OPTIONS:O:u}
653
654 .endif