aboutsummaryrefslogtreecommitdiff
path: root/Mk/bsd.port.mk
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2012-12-10 10:14:05 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2012-12-10 10:14:05 +0000
commit34d5249610dfb4da7a6eca1af4b1c0e2d3696596 (patch)
treead702d3a7471a02dfd1e1fb7ae8ac130fcaa074c /Mk/bsd.port.mk
parent32cb74faec5625df07b29b0cdde6a4a47311a195 (diff)
downloadports-34d5249610dfb4da7a6eca1af4b1c0e2d3696596.tar.gz
ports-34d5249610dfb4da7a6eca1af4b1c0e2d3696596.zip
Extend the options framework providing 2 new macros:
OPTIONS_RADIO: a more user friendly way to allow selecting only 0 or 1 options among a list of options OPTIONS_GROUP: this macros should be used to group options by theme allowing the user to select 0 or N options among a list of options With hat: portmgr Reviewed by: beat
Notes
Notes: svn path=/head/; revision=308598
Diffstat (limited to 'Mk/bsd.port.mk')
-rw-r--r--Mk/bsd.port.mk98
1 files changed, 95 insertions, 3 deletions
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 90c0f3582853..2aa74894a97d 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -3309,6 +3309,7 @@ DEPENDS_ARGS+= NOCLEANDEPENDS=yes
#
################################################################
.if ((!defined(OPTIONS_DEFINE) && !defined(OPTIONS_SINGLE) && !defined(OPTIONS_MULTI)) \
+ && !defined(OPTIONS_GROUP) && !defined(OPTIONS_RADIO) \
|| defined(CONFIG_DONE_${UNIQUENAME:U}) || \
defined(PACKAGE_BUILDING) || defined(BATCH))
_OPTIONS_OK=yes
@@ -6004,6 +6005,19 @@ OPTIONS_WRONG_SINGLE+= ${single}
.endfor
.undef single
+.for radio in ${OPTIONS_RADIO}
+. for opt in ${OPTIONS_RADIO_${radio}}
+. if !empty(PORT_OPTIONS:M${opt})
+. if defined(OPTFOUND)
+OPTIONS_WRONG_RADIO+= ${radio}
+. else
+OPTFOUND= true
+. endif
+. endif
+. endfor
+. undef OPTFOUND
+.endfor
+
.for multi in ${OPTIONS_MULTI}
. for opt in ${OPTIONS_MULTI_${multi}}
. if empty(ALL_OPTIONS:M${multi}) || !empty(PORT_OPTIONS:M${multi})
@@ -6035,7 +6049,10 @@ _check-config: pre-check-config
.for single in ${OPTIONS_WRONG_SINGLE}
@${ECHO_MSG} "====> You must select one and only one option from the ${single} single"
.endfor
-.if !empty(OPTIONS_WRONG_MULTI) || !empty(OPTIONS_WRONG_SINGLE)
+.for radio in ${OPTIONS_WRONG_RADIO}
+ @${ECHO_MSG} "====> You cannot select multiple options from the ${radio} radio"
+.endfor
+.if !empty(OPTIONS_WRONG_MULTI) || !empty(OPTIONS_WRONG_SINGLE) || !empty(OPTIONS_WRONG_RADIO)
_CHECK_CONFIG_ERROR= true
.endif
.endif # _check-config
@@ -6087,14 +6104,33 @@ DEFOPTIONS+= ${opt} "S(${single}): "${${opt}_DESC:Q} on
. endif
. endfor
.endfor
+.for radio in ${OPTIONS_RADIO}
+. for opt in ${OPTIONS_RADIO_${radio}}
+. if empty(PORT_OPTIONS:M${opt})
+DEFOPTIONS+= ${opt} "R(${radio}): "${${opt}_DESC:Q} off
+. else
+DEFOPTIONS+= ${opt} "R(${radio}): "${${opt}_DESC:Q} on
+. endif
+. endfor
+.endfor
+.for group in ${OPTIONS_GROUP}
+. for opt in ${OPTIONS_GROUP_${group}}
+. if empty(PORT_OPTIONS:M${opt})
+DEFOPTIONS+= ${opt} "G(${group}): "${${opt}_DESC:Q} off
+. else
+DEFOPTIONS+= ${opt} "G(${group}): "${${opt}_DESC:Q} on
+. endif
+. endfor
+.endfor
.undef multi
.undef single
+.undef group
.undef opt
.endif # pre-config
.if !target(do-config)
do-config:
-.if empty(ALL_OPTIONS) && empty(OPTIONS_SINGLE) && empty(OPTIONS_MULTI)
+.if empty(ALL_OPTIONS) && empty(OPTIONS_SINGLE) && empty(OPTIONS_MULTI) && empty(OPTIONS_RADIO) && empty(OPTIONS_GROUP)
@${ECHO_MSG} "===> No options to configure"
.else
.if ${UID} != 0 && !defined(INSTALL_AS_USER)
@@ -6170,7 +6206,7 @@ config-conditional: pre-config
.if !target(showconfig)
.include "${PORTSDIR}/Mk/bsd.options.desc.mk"
showconfig:
-.if !empty(ALL_OPTIONS) || !empty(OPTIONS_SINGLE) || !empty(OPTIONS_MULTI)
+.if !empty(ALL_OPTIONS) || !empty(OPTIONS_SINGLE) || !empty(OPTIONS_MULTI) || !empty(OPTIONS_RADIO) || !empty(OPTIONS_GROUP)
@${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME}":
.for opt in ${ALL_OPTIONS}
. if empty(PORT_OPTIONS:M${opt})
@@ -6215,8 +6251,40 @@ showconfig:
. endfor
.endfor
+.for radio in ${OPTIONS_RADIO}
+ @${ECHO_MSG} "====> Options available for the radio ${radio}: you can only select none or one of them"
+. for opt in ${OPTIONS_RADIO_${radio}}
+. if empty(PORT_OPTIONS:M${opt})
+ @${ECHO_MSG} -n " ${opt}=off"
+. else
+ @${ECHO_MSG} -n " ${opt}=on"
+. endif
+. if !empty(${opt}_DESC)
+ @${ECHO_MSG} -n ": "${${opt}_DESC:Q}
+. endif
+ @${ECHO_MSG} ""
+. endfor
+.endfor
+
+.for group in ${OPTIONS_GROUP}
+ @${ECHO_MSG} "====> Options available for the group ${group}"
+. for opt in ${OPTIONS_GROUP_${group}}
+. if empty(PORT_OPTIONS:M${opt})
+ @${ECHO_MSG} -n " ${opt}=off"
+. else
+ @${ECHO_MSG} -n " ${opt}=on"
+. endif
+. if !empty(${opt}_DESC)
+ @${ECHO_MSG} -n ": "${${opt}_DESC:Q}
+. endif
+ @${ECHO_MSG} ""
+. endfor
+.endfor
+
.undef multi
.undef single
+.undef radio
+.undef group
.undef opt
@${ECHO_MSG} "===> Use 'make config' to modify these settings"
.endif
@@ -6288,8 +6356,32 @@ pretty-print-config:
. endfor
@${ECHO_MSG} -n ") "
.endfor
+.for radio in ${OPTIONS_RADIO}
+ @${ECHO_MSG} -n "${radio}( "
+. for opt in ${OPTIONS_RADIO_${radio}}
+. if empty(PORT_OPTIONS:M${opt})
+ @${ECHO_MSG} -n "-${opt} "
+. else
+ @${ECHO_MSG} -n "+${opt} "
+. endif
+. endfor
+ @${ECHO_MSG} -n ") "
+.endfor
+.for group in ${OPTIONS_GROUP}
+ @${ECHO_MSG} -n "${group}[ "
+. for opt in ${OPTIONS_GROUP_${group}}
+. if empty(PORT_OPTIONS:M${opt})
+ @${ECHO_MSG} -n "-${opt} "
+. else
+ @${ECHO_MSG} -n "+${opt} "
+. endif
+. endfor
+ @${ECHO_MSG} -n "] "
+.endfor
.undef multi
.undef single
+.undef radio
+.undef group
.undef opt
@${ECHO_MSG} ""
.endif # pretty-print-config