Proposal: further OptionsNG improvements

Alexey Dokuchaev danfe at nsu.ru
Wed Jun 26 18:32:09 UTC 2013


On Wed, Jun 26, 2013 at 07:30:55PM +0700, Alexey Dokuchaev wrote:
> On Wed, Jun 26, 2013 at 07:12:41PM +0700, Alexey Dokuchaev wrote:
> > I've cooked something up just now, take a look at the attached diff.  I've
> > only barely tested it, but it seems to work for a few of my hand-crafted
> > configurations.  It also handles known options groups (single/multi/etc.),
> > tested on www/firefox.
> 
> One known limitation of option groups right now is that you cannot have
> per-arch or !arch stuff, only :on.  It should not be hard to fix, but I
> need to think how to avoid code duplication.  I miss $(call ...) of GNU
> make sometimes...

It just occurred to me that it seems we actually do not support something
like OPTIONS_SINGLE_AUDIO_${ARCH}, which simplifies my work (please tell
me if I'm wrong).  So all I need is to remember about OPTIONS_EXCLUDE's in
this case.  Now it's possible (example for www/firefox/Makefile.options):

  OPTIONS_SINGLE_AUDIO=   ALSA:on OSS!sparc64 PULSEAUDIO!powerpc,mips,i386

New diff attached (also comes with some comments tweaks, and I've switched
from ^ to ~ as regex delimiter: it looks nicer and there is no confusion
with start-of-line marker).  I hope now it can cover anything possible to
achieve with current OptionsNG.

But we need reviewers and testers!

./danfe

P.S.  This was all developed on 8.3-STABLE, that is, with our traditional
make(1).  I will test new make(1) on 10-CURRENT tomorrow.
-------------- next part --------------
Index: bsd.options.mk
===================================================================
--- bsd.options.mk	(revision 321792)
+++ bsd.options.mk	(working copy)
@@ -10,7 +10,7 @@
 #							  specific to ${ARCH}
 # OPTIONS_DEFAULT			- List of options activated by default
 # OPTIONS_DEFAULT_${ARCH}	- List of options activated by default for a
-#							  given arch
+#							  given ${ARCH}
 #
 # ${OPTION}_DESC			- Description of the ${OPTION}
 #
@@ -94,14 +94,59 @@
 
 PORT_OPTIONS+=	IPV6
 
-# Add per arch options
+### Parse new extended syntax OPTIONS knob (architecture-independent)
+.for opt in ${OPTIONS:N*/*:N*!*}
+OPTIONS_DEFINE+=	${opt:C~:.*~~}
+OPTIONS_DEFAULT+=	${opt:M*\:on:S~:on~~}
+.endfor
+
+# Process known option groups (only architecture exclusion supported)
+.for otype in SINGLE RADIO MULTI GROUP
+.  for group in ${OPTIONS_${otype}}
+# Here we need the temporary variables because of the := operator used few
+# lines below
+_exclude:=		${OPTIONS_${otype}_${group}:M*!*}
+_default:=		${OPTIONS_${otype}_${group}:M*\:on*:C~:.*~~}
+OPTIONS_DEFAULT+=			${_default}
+OPTIONS_${otype}_${group}:=	${OPTIONS_${otype}_${group}:C~[:!].*~~}
+.    for opt in ${_exclude}
+.      for arch in ${opt:C~.*!~~:S~,~ ~g}
+OPTIONS_EXCLUDE_${arch}+=	${opt:C~[:!].*~~}
+.      endfor
+.    endfor
+.  endfor
+.endfor
+
+# Process architecture-specific options
+.for opt in ${OPTIONS:M*/*}
+.  for arch in ${opt:C~.*/~~:S~,~ ~g}
+.    for defarch in OPTIONS_DEFINE_${arch:C~:.*~~}
+${defarch}+=	${opt:C~/.*~~}
+.    endfor
+.    for defarch in OPTIONS_DEFAULT_${arch:M*\:on:S~:on~~}
+${defarch}+=	${opt:C~/.*~~}
+.    endfor
+.  endfor
+.endfor
+
+# Process options unsupported on some architectures
+.for opt in ${OPTIONS:M*!*}
+OPTIONS_DEFINE+=	${opt:C~[:!].*~~}
+OPTIONS_DEFAULT+=	${opt:M*\:on!*:C~:.*~~}
+.  for arch in ${opt:C~.*!~~:S~,~ ~g}
+OPTIONS_EXCLUDE_${arch}+=	${opt:C~[:!].*~~}
+.  endfor
+.endfor
+###
+
+# Add per-architecture options
 .for opt in ${OPTIONS_DEFINE_${ARCH}}
 .if empty(OPTIONS_DEFINE:M${opt})
 OPTIONS_DEFINE+=	${opt}
 .endif
 .endfor
 
-# Add per arch defaults
+# Add per-architecture defaults
 OPTIONS_DEFAULT+=	${OPTIONS_DEFAULT_${ARCH}}
 
 # Remove options the port maintainer doesn't want
@@ -130,7 +175,7 @@
 ALL_OPTIONS:=	${OPTIONS_DEFINE:O:u}
 OPTIONS_DEFAULT:=	${OPTIONS_DEFAULT:O:u}
 
-# complete list
+# Complete list
 COMPLETE_OPTIONS_LIST=	${ALL_OPTIONS}
 .for otype in SINGLE RADIO MULTI GROUP
 .  for m in ${OPTIONS_${otype}}


More information about the freebsd-ports mailing list