From cb97dd05753e9bb0b521de837db6f884f01e78f2 Mon Sep 17 00:00:00 2001 From: John Marino Date: Mon, 14 Dec 2015 22:44:39 +0000 Subject: [PATCH] Mk/bsd.options.mk: Introduce SELECTED_OPTIONS, DESELECTED_OPTIONS Until now, the only way to obtain information on the valid port options and the current selection states is by using the pretty-print-config target. It would look something like this: > make -C /usr/ports/lang/gcc5-aux print-print-config Standard[ +FORT +OBJC +NLS -TESTSUITE -ALLSTAGES -STATIC ] \ Bootstrap[ -BOOTSTRAP ] To process the total options and the selection state of each option requires additional processing, e.g. with awk and/or sed. Moreover, if other information is needed about the port it question, it would require a second execution of "make" to reveal variable values. There simply is no other way to obtain the option selection information in a single pass (this limitation came when options framework was brought in). This enhancement allows the option selection information to revealed with make -V so that all port information can be acquired in a single pass. Moreover, they won't require piping through sed or awk. Two read-only variables are introduced: SELECTED_OPTIONS (list of all "on" options) DESELECTED_OPTIONS (liss of all "off" options) Here's an example of a single pass acquisition: > make -C /usr/dports/lang/gcc5-aux -V PKGNAME -V SELECTED_OPTIONS \ -V DESELECTED_OPTIONS gcc5-aux-20150716 NLS OBJC FORT BOOTSTRAP STATIC ALLSTAGES TESTSUITE Obviously the grouping information seen in pretty-print-config is lost, so these new variables will not help if option group information is required. Approved by: portmgr (bapt) --- Mk/bsd.options.mk | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Mk/bsd.options.mk b/Mk/bsd.options.mk index f399660412af..f4581ae13710 100644 --- a/Mk/bsd.options.mk +++ b/Mk/bsd.options.mk @@ -68,6 +68,13 @@ # WITHOUT - Unset options from the command line # # +# These variables are strictly informational (read-only). They indicate the +# current state of the selected options; they are space-delimited lists. +# +# SELECTED_OPTIONS - list of options set "on" +# DESELECTED_OPTIONS - list of options set "off" +# +# # The following knobs are there to simplify the handling of OPTIONS in simple # cases : # @@ -573,4 +580,25 @@ _OPTIONS_${_target}:= ${_OPTIONS_${_target}} ${_prio}:${_type}-${_target}-${opt} . endif .endfor +.undef (SELECTED_OPTIONS) +.undef (DESELECTED_OPTIONS) +.for opt in ${ALL_OPTIONS} +. if ${PORT_OPTIONS:M${opt}} +SELECTED_OPTIONS:= ${opt} ${SELECTED_OPTIONS} +. else +DESELECTED_OPTIONS:= ${opt} ${DESELECTED_OPTIONS} +. endif +.endfor +.for otype in MULTI GROUP SINGLE RADIO +. for m in ${OPTIONS_${otype}} +. for opt in ${OPTIONS_${otype}_${m}} +. if ${PORT_OPTIONS:M${opt}} +SELECTED_OPTIONS:= ${opt} ${SELECTED_OPTIONS} +. else +DESELECTED_OPTIONS:= ${opt} ${DESELECTED_OPTIONS} +. endif +. endfor +. endfor +.endfor + .endif