diff options
author | bapt <bapt@FreeBSD.org> | 2012-12-10 18:14:05 +0800 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-12-10 18:14:05 +0800 |
commit | e775b1b79790e51640283766ee2f8f5f705b09b5 (patch) | |
tree | ad702d3a7471a02dfd1e1fb7ae8ac130fcaa074c /Mk | |
parent | 0cc8d65c71b5242ada3595f6daf8967bc32fcdae (diff) | |
download | freebsd-ports-gnome-e775b1b79790e51640283766ee2f8f5f705b09b5.tar.gz freebsd-ports-gnome-e775b1b79790e51640283766ee2f8f5f705b09b5.tar.zst freebsd-ports-gnome-e775b1b79790e51640283766ee2f8f5f705b09b5.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
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/bsd.options.mk | 32 | ||||
-rw-r--r-- | Mk/bsd.port.mk | 98 |
2 files changed, 122 insertions, 8 deletions
diff --git a/Mk/bsd.options.mk b/Mk/bsd.options.mk index 49bf29870b34..f825564be7f7 100644 --- a/Mk/bsd.options.mk +++ b/Mk/bsd.options.mk @@ -12,15 +12,28 @@ # OPTIONS_EXCLUDE_${ARCH} - List of options unsupported on a given ${ARCH} # ${OPTION}_DESC - Description the the ${OPTION} # -# OPTIONS_SINGLE - List of radio choice grouped options -# OPTIONS_MULTI - List of multiple-choice grouped options +# OPTIONS_SINGLE - List of single-choice grouped options: 1 and +# only 1 among N +# OPTIONS_RADIO - List of radio-choice grouped options: 0 or 1 +# among N +# OPTIONS_MULTI - List of multiple-choice grouped options: at +# least 1 among N +# OPTIONS_GROUP - List of group-choice grouped options: 0 or +# more among N # -# OPTIONS_SINGLE_${NAME} - List of OPTIONS grouped as radio choice (for +# OPTIONS_SINGLE_${NAME} - List of OPTIONS grouped as single choice (for # the single named as ${NAME} as defined in # OPTIONS_SINGLE) -# OTPIONS_MULTI_${NAME} - List of OPTIONS grouped as multiple-choice -# (for the multi named as ${NAME} as defined in +# OPTIONS_RADIO_${NAME} - List of OPTIONS grouped as radio choice (for +# the radio named as ${NAME} as defined in +# OPTIONS_RADIO) +# OPTIONS_MULTI_${NAME} - List of OPTIONS grouped as multiple-choice +# (for the multi named as ${NAME} as defined in # OPTIONS_MULTI) +# OPTIONS_GROUP_${NAME} - List of OPTIONS grouped as group-choice (for +# the group named as ${NAME} as defined in +# OPTIONS_GROUP) +# # WITH Set options from the command line # WITHOUT Unset options from the command line @@ -28,6 +41,8 @@ # Set all the options available for the ports, beginning with the # global ones and ending with the ones decided by the maintainer. # Options global to the entire ports tree +.if !defined(OPTIONSMKINCLUDED) +OPTIONSMKINCLUDED= bsd.options.mk OPTIONSFILE?= ${PORT_DBDIR}/${UNIQUENAME}/options @@ -127,9 +142,15 @@ COMPLETE_OPTIONS_LIST= ${ALL_OPTIONS} .for single in ${OPTIONS_SINGLE} COMPLETE_OPTIONS_LIST+= ${OPTIONS_SINGLE_${single}} .endfor +.for radio in ${OPTIONS_RADIO} +COMPLETE_OPTIONS_LIST+= ${OPTIONS_RADIO_${radio}} +.endfor .for multi in ${OPTIONS_MULTI} COMPLETE_OPTIONS_LIST+= ${OPTIONS_MULTI_${multi}} .endfor +.for group in ${OPTIONS_GROUP} +COMPLETE_OPTIONS_LIST+= ${OPTIONS_GROUP_${group}} +.endfor ## Now create the list of activated options .if defined(OPTIONS_OVERRIDE) @@ -255,4 +276,5 @@ WITH_${opt}:= true .endif . undef opt .endfor +.endif ### 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 |