Index: head/CHANGES =================================================================== --- head/CHANGES +++ head/CHANGES @@ -10,6 +10,17 @@ All ports committers are allowed to commit to this file. +20150828: +AUTHOR: mat@FreeBSD.org + + _VARS and _VARS_OFF have been introduced to allow for a generic way + to set/append to variables. + + OPT1_VARS= foo=bar baz+=bam + + will set FOO to bar and append bam to BAZ if OPT1 is enabled. _VARS_OFF + works the same way, if the option is disabled. + 20150818: AUTHOR: kde@FreeBSD.org Index: head/Mk/bsd.options.mk =================================================================== --- head/Mk/bsd.options.mk +++ head/Mk/bsd.options.mk @@ -110,6 +110,15 @@ # ${opt}_USE_OFF= FOO=bar When option is disabled, it will enable # USE_FOO+= bar # +# ${opt}_VARS= FOO=bar When option is enabled, it will run +# FOO= bar +# ${opt}_VARS= FOO+=bar When option is enabled, it will run +# FOO+= bar +# ${opt}_VARS_OFF= FOO=bar When option is disabled, it will run +# FOO= bar +# ${opt}_VARS_OFF= FOO+=bar When option is disabled, it will run +# FOO+= bar +# # For each of: # ALL_TARGET BROKEN CATEGORIES CFLAGS CONFIGURE_ENV CONFLICTS CONFLICTS_BUILD # CONFLICTS_INSTALL CPPFLAGS CXXFLAGS DISTFILES EXTRA_PATCHES EXTRACT_ONLY @@ -463,6 +472,16 @@ USE_${_u:tu}+= ${option:C/.*=//g:C/,/ /g} . endfor . endif +. if defined(${opt}_VARS) +. for var in ${${opt}_VARS} +_u= ${var:C/=.*//} +. if ${_u:M*+} +${_u:C/.$//:tu}+= ${var:C/[^+]*\+=//:C/^"(.*)"$$/\1/} +. else +${_u:tu}= ${var:C/[^=]*=//:C/^"(.*)"$$/\1/} +. endif +. endfor +. endif . if defined(${opt}_CONFIGURE_ENABLE) . for iopt in ${${opt}_CONFIGURE_ENABLE} CONFIGURE_ARGS+= --enable-${iopt} @@ -501,6 +520,16 @@ USE_${_u:tu}+= ${option:C/.*=//g:C/,/ /g} . endfor . endif +. if defined(${opt}_VARS_OFF) +. for var in ${${opt}_VARS_OFF} +_u= ${var:C/=.*//} +. if ${_u:M*+} +${_u:C/.$//:tu}+= ${var:C/[^+]*\+=//:C/^"(.*)"$$/\1/} +. else +${_u:tu}= ${var:C/[^=]*=//:C/^"(.*)"$$/\1/} +. endif +. endfor +. endif . if defined(${opt}_CONFIGURE_ENABLE) . for iopt in ${${opt}_CONFIGURE_ENABLE} CONFIGURE_ARGS+= --disable-${iopt:C/=.*//}