Index: head/Mk/bsd.options.mk =================================================================== --- head/Mk/bsd.options.mk +++ head/Mk/bsd.options.mk @@ -640,22 +640,15 @@ .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 +# Wait to expand PORT_OPTIONS until the last moment in case something modifies +# the selected OPTIONS after bsd.port.options.mk is included. This uses +# bmake's :@ for loop. +SELECTED_OPTIONS= ${ALL_OPTIONS:@opt@${PORT_OPTIONS:M${opt}}@} +DESELECTED_OPTIONS= ${ALL_OPTIONS:@opt@${"${PORT_OPTIONS:M${opt}}":?:${opt}}@} .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 +SELECTED_OPTIONS+= ${OPTIONS_${otype}_${m}:@opt@${PORT_OPTIONS:M${opt}}@} +DESELECTED_OPTIONS+= ${OPTIONS_${otype}_${m}:@opt@${"${PORT_OPTIONS:M${opt}}":?:${opt}}@} . endfor .endfor