Import devel/fpc-fpmkunit version 2.6.4
[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_SLAVE                 - This is designed for slave ports, it removes an
39 #                                 option from the options list inherited from the
40 #                                 master port and it always adds it to PORT_OPTIONS
41 #                                 meaning activated
42 #
43 # These variables can be used in make.conf to configure options.  They are
44 # processed in the order listed below, i.e. later variables override the effects
45 # of previous variables.  Options saved using the options dialog are processed
46 # right before OPTIONS_SET_FORCE.  When building a port a dialog to configure
47 # options will only appear if there are new options, i.e. options which have not
48 # been configured before either using the option dialog in a previous build or
49 # using the variables below.  You can force the dialog to appear by running
50 # "make config".
51 #
52 # OPTIONS_SET                   - List of options to enable for all ports.
53 # OPTIONS_UNSET                 - List of options to disable for all ports.
54 # ${OPTIONS_NAME}_SET           - List of options to enable for a specific port.
55 # ${OPTIONS_NAME}_UNSET         - List of options to disable for a specific port.
56 #
57 # OPTIONS_SET_FORCE             - List of options to enable for all ports.
58 # OPTIONS_UNSET_FORCE           - List of options to disable for all ports.
59 # ${OPTIONS_NAME}_SET_FORCE     - List of options to enable for a specific port.
60 # ${OPTIONS_NAME}_UNSET_FORCE
61 #                               - List of options to disable for a specific port.
62 #
63 # These variables can be used on the command line. They override the effects of
64 # the make.conf variables above.
65 #
66 # WITH                          - Set options from the command line
67 # WITHOUT                       - Unset options from the command line
68 #
69 #
70 # The following knobs are there to simplify the handling of OPTIONS in simple
71 # cases :
72 #
73 # OPTIONS_SUB                   When defined it will add to PLIST_SUB:
74 #                               Option enabled  ${opt}=""
75 #                               Option disabled ${opt}="@comment "
76 #
77 # ${opt}_CONFIGURE_ON           When option is enabled, it will add its content to
78 #                               the CONFIGURE_ARGS.
79 # ${opt}_CONFIGURE_OFF          When option is disabled, it will add its content to
80 #                               the CONFIGURE_ARGS.
81 # ${opt}_CONFIGURE_ENABLE       Will add to CONFIGURE_ARGS:
82 #                               Option enabled  --enable-${content}
83 #                               Option disabled --disable-${content}
84 # ${opt}_CONFIGURE_WITH         Will add to CONFIGURE_ARGS:
85 #                               Option enabled  --with-${content}
86 #                               Option disabled --without-${content}
87 #
88 # ${opt}_CMAKE_ON               When option is enabled, it will add its content to
89 #                               the CMAKE_ARGS.
90 # ${opt}_CMAKE_OFF              When option is disabled, it will add its content to
91 #                               the CMAKE_ARGS.
92 #
93 # ${opt}_QMAKE_ON               When option is enabled, it will add its content to
94 #                               the QMAKE_ARGS.
95 # ${opt}_QMAKE_OFF              When option is disabled, it will add its content to
96 #                               the QMAKE_ARGS.
97 #
98 # ${opt}_USE=   FOO=bar         When option is enabled, it will  enable
99 #                               USE_FOO+= bar
100 #                               If you need more than one option, you can do
101 #                               FOO=bar,baz and you'll get USE_FOO=bar baz
102 #
103 # For each of:
104 # ALL_TARGET CATEGORIES CFLAGS CONFIGURE_ENV CONFLICTS CONFLICTS_BUILD
105 # CONFLICTS_INSTALL CPPFLAGS CXXFLAGS DISTFILES EXTRA_PATCHES
106 # INSTALL_TARGET LDFLAGS LIBS MAKE_ARGS MAKE_ENV PATCHFILES PATCH_SITES
107 # PLIST_DIRS PLIST_DIRSTRY PLIST_FILES PLIST_SUB INFO USES, defining ${opt}_${variable} will
108 # add its content to the actual variable when the option is enabled.  Defining
109 # ${opt}_${variable}_OFF will add its content to the actual variable when the
110 # option is disabled.
111 #
112 # For each of the depends target PKG FETCH EXTRACT PATCH BUILD LIB RUN,
113 # defining ${opt}_${deptype}_DEPENDS will add its content to the actual
114 # dependency when the option is enabled.  Defining
115 # ${opt}_${deptype}_DEPENDS_OFF will add its content to the actual dependency
116 # when the option is disabled.
117
118 ##
119 # Set all the options available for the ports, beginning with the
120 # global ones and ending with the ones decided by the maintainer.
121
122 .if !defined(OPTIONSMKINCLUDED)
123 OPTIONSMKINCLUDED=      bsd.options.mk
124
125 OPTIONS_NAME?=  ${PKGORIGIN:S/\//_/}
126 OPTIONSFILE?=   ${PORT_DBDIR}/${UNIQUENAME}/options
127 OPTIONS_FILE?=  ${PORT_DBDIR}/${OPTIONS_NAME}/options
128
129 _OPTIONS_FLAGS= ALL_TARGET CATEGORIES CFLAGS CONFIGURE_ENV CONFLICTS \
130                 CONFLICTS_BUILD CONFLICTS_INSTALL CPPFLAGS CXXFLAGS DISTFILES \
131                 EXTRA_PATCHES INSTALL_TARGET LDFLAGS LIBS MAKE_ARGS MAKE_ENV \
132                 PATCHFILES PATCH_SITES PLIST_DIRS PLIST_DIRSTRY PLIST_FILES \
133                 PLIST_SUB USES INFO
134 _OPTIONS_DEPENDS=       PKG FETCH EXTRACT PATCH BUILD LIB RUN
135
136 # Set the default values for the global options, as defined by portmgr
137 .if !defined(NOPORTDOCS)
138 PORT_OPTIONS+=  DOCS
139 .else
140 OPTIONS_WARNINGS+=              "NOPORTDOCS"
141 WITHOUT+=                       DOCS
142 OPTIONS_WARNINGS_UNSET+=        DOCS
143 .endif
144
145 .if !defined(WITHOUT_NLS)
146 PORT_OPTIONS+=  NLS
147 .else
148 WITHOUT+=               NLS
149 .endif
150
151 .if !defined(NOPORTEXAMPLES)
152 PORT_OPTIONS+=  EXAMPLES
153 .else
154 OPTIONS_WARNINGS+=              "NOPORTEXAMPLES"
155 WITHOUT+=                       EXAMPLES
156 OPTIONS_WARNINGS_UNSET+=        EXAMPLES
157 .endif
158
159 PORT_OPTIONS+=  IPV6
160
161 # Add per arch options
162 .for opt in ${OPTIONS_DEFINE_${ARCH}}
163 .if empty(OPTIONS_DEFINE:M${opt})
164 OPTIONS_DEFINE+=        ${opt}
165 .endif
166 .endfor
167
168 # Add per arch defaults
169 OPTIONS_DEFAULT+=       ${OPTIONS_DEFAULT_${ARCH}}
170
171 # Remove options the port maintainer doesn't want
172 .for opt in ${OPTIONS_EXCLUDE_${ARCH}} ${OPTIONS_EXCLUDE} ${OPTIONS_SLAVE}
173 OPTIONS_DEFAULT:=       ${OPTIONS_DEFAULT:N${opt}}
174 OPTIONS_DEFINE:=        ${OPTIONS_DEFINE:N${opt}}
175 PORT_OPTIONS:=          ${PORT_OPTIONS:N${opt}}
176 .  for otype in SINGLE RADIO MULTI GROUP
177 .    for m in ${OPTIONS_${otype}}
178 OPTIONS_${otype}_${m}:= ${OPTIONS_${otype}_${m}:N${opt}}
179 .    endfor
180 .  endfor
181 .endfor
182
183 # Remove empty SINGLE/GROUP/RADIO/MULTI
184 # Can be empty because of exclude/slaves
185 .for otype in SINGLE RADIO MULTI GROUP
186 .  for m in ${OPTIONS_${otype}}
187 .    if empty(OPTIONS_${otype}_${m})
188 OPTIONS_${otype}:=      ${OPTIONS_${otype}:N${m}}
189 .    endif
190 .  endfor
191 .endfor
192
193 # Sort options
194 ALL_OPTIONS:=   ${OPTIONS_DEFINE:O:u}
195 OPTIONS_DEFAULT:=       ${OPTIONS_DEFAULT:O:u}
196
197 # complete list
198 COMPLETE_OPTIONS_LIST=  ${ALL_OPTIONS}
199 .for otype in SINGLE RADIO MULTI GROUP
200 .  for m in ${OPTIONS_${otype}}
201 COMPLETE_OPTIONS_LIST+= ${OPTIONS_${otype}_${m}}
202 .  endfor
203 .endfor
204
205 ## Now create the list of activated options
206 .if defined(OPTIONS_OVERRIDE)
207 # Special case $OPTIONS_OVERRIDE; if it is defined forget about anything done
208 # before
209 NEW_OPTIONS=
210 PORT_OPTIONS:=  ${OPTIONS_OVERRIDE}
211 .else
212 NEW_OPTIONS=    ${COMPLETE_OPTIONS_LIST}
213
214 ## Set default options defined by the port maintainer
215 PORT_OPTIONS+=  ${OPTIONS_DEFAULT}
216
217 ## Set system-wide defined options (set by user in make.conf)
218 .  for opt in ${OPTIONS_SET}
219 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
220 PORT_OPTIONS+=  ${opt}
221 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
222 .    endif
223 .  endfor
224
225 ## Remove the options excluded system-wide (set by user in make.conf)
226 .  for opt in ${OPTIONS_UNSET}
227 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
228 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
229 .  endfor
230
231 # XXX To remove once UNIQUENAME will be removed
232 ## Set the options specified per-port (set by user in make.conf)
233 .  for opt in ${${UNIQUENAME}_SET}
234 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
235 PORT_OPTIONS+=  ${opt}
236 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
237 .    endif
238 .  endfor
239
240 ## Unset the options excluded per-port (set by user in make.conf)
241 .  for opt in ${${UNIQUENAME}_UNSET}
242 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
243 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
244 .  endfor
245 # XXX To remove once UNIQUENAME will be removed
246
247 ## Set the options specified per-port (set by user in make.conf)
248 .  for opt in ${${OPTIONS_NAME}_SET}
249 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
250 PORT_OPTIONS+=  ${opt}
251 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
252 .    endif
253 .  endfor
254
255 ## Unset the options excluded per-port (set by user in make.conf)
256 .  for opt in ${${OPTIONS_NAME}_UNSET}
257 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
258 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
259 .  endfor
260
261 # XXX to remove once UNIQUENAME is removed
262 ## options files (from dialog)
263 .  if exists(${OPTIONSFILE}) && !make(rmconfig)
264 .  include "${OPTIONSFILE}"
265 .  endif
266 .  sinclude "${OPTIONSFILE}.local"
267 # XXX to remove once UNIQUENAME is removed
268
269 ## options files (from dialog)
270 .  if exists(${OPTIONS_FILE}) && !make(rmconfig)
271 .  include "${OPTIONS_FILE}"
272 .  endif
273 .  sinclude "${OPTIONS_FILE}.local"
274
275 ### convert WITH and WITHOUT found in make.conf or reloaded from old optionsfile
276 # XXX once WITH_DEBUG is not magic any more, do remove the :NDEBUG from here.
277 .for opt in ${ALL_OPTIONS:NDEBUG}
278 .if defined(WITH_${opt})
279 OPTIONS_WARNINGS+= "WITH_${opt}"
280 OPTIONS_WARNINGS_SET+=  ${opt}
281 PORT_OPTIONS+=  ${opt}
282 .endif
283 .if defined(WITHOUT_${opt})
284 OPTIONS_WARNINGS+= "WITHOUT_${opt}"
285 OPTIONS_WARNINGS_UNSET+=        ${opt}
286 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
287 .endif
288 .endfor
289
290 .if defined(OPTIONS_WARNINGS)
291 WARNING+=       "You are using the following deprecated options: ${OPTIONS_WARNINGS}"
292 WARNING+=       "If you added them on the command line, you should replace them by"
293 WARNING+=       "WITH=\"${OPTIONS_WARNINGS_SET}\" WITHOUT=\"${OPTIONS_WARNINGS_UNSET}\""
294 WARNING+=       ""
295 WARNING+=       "If they are global options set in your make.conf, you should replace them with:"
296 .if defined(OPTIONS_WARNINGS_SET)
297 WARNING+=       "OPTIONS_SET=${OPTIONS_WARNINGS_SET}"
298 .endif
299 .if defined(OPTIONS_WARNINGS_UNSET)
300 WARNING+=       "OPTIONS_UNSET=${OPTIONS_WARNINGS_UNSET}"
301 .endif
302 WARNING+=       ""
303 WARNING+=       "If they are local to this port, you should use:"
304 .if defined(OPTIONS_WARNINGS_SET)
305 WARNING+=       "${OPTIONS_NAME}_SET=${OPTIONS_WARNINGS_SET}"
306 .endif
307 .if defined(OPTIONS_WARNINGS_UNSET)
308 WARNING+=       "${OPTIONS_NAME}_UNSET=${OPTIONS_WARNINGS_UNSET}"
309 .endif
310 .endif
311
312 ## Finish by using the options set by the port config dialog, if any
313 .  for opt in ${OPTIONS_FILE_SET}
314 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
315 PORT_OPTIONS+=  ${opt}
316 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
317 .    endif
318 .  endfor
319
320 .for opt in ${OPTIONS_FILE_UNSET}
321 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
322 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
323 .endfor
324
325 .endif
326
327 ## FORCE
328 ## Set system-wide defined options (set by user in make.conf)
329 .  for opt in ${OPTIONS_SET_FORCE}
330 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
331 PORT_OPTIONS+=  ${opt}
332 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
333 .    endif
334 .  endfor
335
336 ## Remove the options excluded system-wide (set by user in make.conf)
337 .  for opt in ${OPTIONS_UNSET_FORCE}
338 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
339 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
340 .  endfor
341
342 # XXX To remove once UNIQUENAME will be removed
343 ## Set the options specified per-port (set by user in make.conf)
344 .  for opt in ${${UNIQUENAME}_SET_FORCE}
345 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
346 PORT_OPTIONS+=  ${opt}
347 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
348 .    endif
349 .  endfor
350
351 ## Unset the options excluded per-port (set by user in make.conf)
352 .  for opt in ${${UNIQUENAME}_UNSET_FORCE}
353 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
354 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
355 .  endfor
356 # XXX To remove once UNIQUENAME will be removed
357
358 ## Set the options specified per-port (set by user in make.conf)
359 .  for opt in ${${OPTIONS_NAME}_SET_FORCE}
360 .    if !empty(COMPLETE_OPTIONS_LIST:M${opt})
361 PORT_OPTIONS+=  ${opt}
362 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
363 .    endif
364 .  endfor
365
366 ## Unset the options excluded per-port (set by user in make.conf)
367 .  for opt in ${${OPTIONS_NAME}_UNSET_FORCE}
368 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
369 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
370 .  endfor
371
372
373 ## Cmdline always win over the rest
374 .for opt in ${WITH}
375 .  if !empty(COMPLETE_OPTIONS_LIST:M${opt})
376 PORT_OPTIONS+=  ${opt}
377 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
378 .  endif
379 .endfor
380
381 .for opt in ${WITHOUT}
382 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
383 NEW_OPTIONS:=   ${NEW_OPTIONS:N${opt}}
384 .endfor
385
386 # Finally, add options required by slave ports
387 PORT_OPTIONS+=  ${OPTIONS_SLAVE}
388
389 # Sort options and eliminate duplicates
390 PORT_OPTIONS:=  ${PORT_OPTIONS:O:u}
391
392 ## Now some compatibility
393 .if empty(PORT_OPTIONS:MDOCS)
394 NOPORTDOCS=     yes
395 .endif
396
397 .if empty(PORT_OPTIONS:MEXAMPLES)
398 NOPORTEXAMPLES= yes
399 .endif
400
401 .if ${PORT_OPTIONS:MDEBUG}
402 WITH_DEBUG=     yes
403 .endif
404
405 .if defined(NO_OPTIONS_SORT)
406 ALL_OPTIONS=    ${OPTIONS_DEFINE}
407 .endif
408
409 .for opt in ${COMPLETE_OPTIONS_LIST} ${OPTIONS_SLAVE} ${OPTIONS_EXCLUDE_${ARCH}} ${OPTIONS_EXCLUDE}
410 # PLIST_SUB
411 PLIST_SUB?=
412 SUB_LIST?=
413 .  if defined(OPTIONS_SUB)
414 .    if ! ${PLIST_SUB:M${opt}=*}
415 .      if ${PORT_OPTIONS:M${opt}}
416 PLIST_SUB:=     ${PLIST_SUB} ${opt}="" NO_${opt}="@comment "
417 .      else
418 PLIST_SUB:=     ${PLIST_SUB} ${opt}="@comment " NO_${opt}=""
419 .      endif
420 .    endif
421 .    if ! ${SUB_LIST:M${opt}=*}
422 .      if ${PORT_OPTIONS:M${opt}}
423 SUB_LIST:=      ${SUB_LIST} ${opt}="" NO_${opt}="@comment "
424 .      else
425 SUB_LIST:=      ${SUB_LIST} ${opt}="@comment " NO_${opt}=""
426 .      endif
427 .    endif
428 .  endif
429
430 .  if ${PORT_OPTIONS:M${opt}}
431 .    if defined(${opt}_USE)
432 .      for option in ${${opt}_USE}
433 _u=             ${option:C/=.*//g}
434 USE_${_u:tu}+=  ${option:C/.*=//g:C/,/ /g}
435 .      endfor
436 .    endif
437 .    if defined(${opt}_CONFIGURE_ENABLE)
438 .      for iopt in ${${opt}_CONFIGURE_ENABLE}
439 CONFIGURE_ARGS+=        --enable-${iopt}
440 .      endfor
441 .    endif
442 .    if defined(${opt}_CONFIGURE_WITH)
443 .      for iopt in ${${opt}_CONFIGURE_WITH}
444 CONFIGURE_ARGS+=        --with-${iopt}
445 .      endfor
446 .    endif
447 .    for configure in CONFIGURE CMAKE QMAKE
448 .      if defined(${opt}_${configure}_ON)
449 ${configure}_ARGS+=     ${${opt}_${configure}_ON}
450 .      endif
451 .    endfor
452 .    for flags in ${_OPTIONS_FLAGS}
453 .      if defined(${opt}_${flags})
454 ${flags}+=      ${${opt}_${flags}}
455 .      endif
456 .    endfor
457 .    for deptype in ${_OPTIONS_DEPENDS}
458 .      if defined(${opt}_${deptype}_DEPENDS)
459 ${deptype}_DEPENDS+=    ${${opt}_${deptype}_DEPENDS}
460 .      endif
461 .    endfor
462 .  else
463 .    if defined(${opt}_CONFIGURE_ENABLE)
464 .      for iopt in ${${opt}_CONFIGURE_ENABLE}
465 CONFIGURE_ARGS+=        --disable-${iopt}
466 .      endfor
467 .    endif
468 .    if defined(${opt}_CONFIGURE_WITH)
469 .      for iopt in ${${opt}_CONFIGURE_WITH}
470 CONFIGURE_ARGS+=        --without-${iopt:C/=.*//}
471 .      endfor
472 .    endif
473 .    for configure in CONFIGURE CMAKE QMAKE
474 .      if defined(${opt}_${configure}_OFF)
475 ${configure}_ARGS+=     ${${opt}_${configure}_OFF}
476 .      endif
477 .    endfor
478 .    for flags in ${_OPTIONS_FLAGS}
479 .      if defined(${opt}_${flags}_OFF)
480 ${flags}+=      ${${opt}_${flags}_OFF}
481 .      endif
482 .    endfor
483 .    for deptype in ${_OPTIONS_DEPENDS}
484 .      if defined(${opt}_${deptype}_DEPENDS_OFF)
485 ${deptype}_DEPENDS+=    ${${opt}_${deptype}_DEPENDS_OFF}
486 .      endif
487 .    endfor
488 .  endif
489 .endfor
490
491 .endif