Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jul 2023 22:08:32 GMT
From:      Robert Clausecker <fuz@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: f685268e17b6 - main - Mk/bsd.port.mk: Allow category_port_VARS= in make.conf for arbitrary per-port overrides.
Message-ID:  <202307112208.36BM8WrG004787@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f685268e17b60e84024b0c7378b459c82ea1ee57

commit f685268e17b60e84024b0c7378b459c82ea1ee57
Author:     Andrew Gierth <andrew@tao11.riddles.org.uk>
AuthorDate: 2023-07-11 07:44:53 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-07-11 22:04:07 +0000

    Mk/bsd.port.mk: Allow category_port_VARS= in make.conf for arbitrary per-port overrides.
    
    Currently the only way to specify make.conf variables (other than port
    options which have their own mechanism) in a per-port fashion is to use
    conditionals on .CURDIR, which is fragile since it tends to involve
    assumptions about where the ports tree is mounted.
    
    Instead, allow category_portname_VARS= to be set in make.conf to provide
    arbitrary assignments when building a specified port. For example one
    might use
    
        devel_llvm10_VARS= MAKE_JOBS_NUMBER=2
    
    or
    
        converters_lua-iconv_VARS= TRYBROKEN=yes
    
    This is intended to be consistent with the existing
    category_portname_SET= variables for port options, and uses the same
    syntax for values as option_VARS= in port makefiles, but without the
    case-folding behavior since that makes it impossible to handle
    mixed-case or lowercase variable names.
    
    Reviewed by:    koobs, mat, adamw, mandree, 0mp
    Approved by:    portmgr (bapt)
    Differential Revision:  https://reviews.freebsd.org/D24324
    VAR+=val can be used to append to a variable, and VAR@ to unset one entirely.
---
 Mk/bsd.port.mk | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 703a8541e383..e35313491bcb 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1283,6 +1283,23 @@ _PORTDIRNAME=	${.CURDIR:T}
 PORTDIRNAME?=	${_PORTDIRNAME}
 PKGORIGIN?=		${PKGCATEGORY}/${PORTDIRNAME}
 
+# Now that PKGORIGIN is set, look for origin-specific variables.
+# These are typically set in a make.conf, in the form:
+#
+# category_portname_VARS= varname=value othervar+=value novar@
+#
+# e.g.  devel_llvm10_VARS= MAKE_JOBS_NUMBER=2
+
+.    for var in ${${PKGORIGIN:S/\//_/}_VARS:C/=.*//:O:u}
+.      if ${var:M*@}
+.  undef ${var:C/.$//}
+.      elif ${var:M*+}
+${var:C/.$//}+=	${${PKGORIGIN:S/\//_/}_VARS:M${var}=*:C/[^+]*\+=//:C/^"(.*)"$$/\1/}
+.      else
+${var}=			${${PKGORIGIN:S/\//_/}_VARS:M${var}=*:C/[^=]*=//:C/^"(.*)"$$/\1/}
+.      endif
+.    endfor
+
 # where 'make config' records user configuration options
 PORT_DBDIR?=	/var/db/ports
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307112208.36BM8WrG004787>