Skip to content

Commit

Permalink
Mk/bsd.port.mk: Allow category_port_VARS= in make.conf for arbitrary …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
RhodiumToad authored and clausecker committed Jul 11, 2023
1 parent 0b0e05c commit f685268
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Mk/bsd.port.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f685268

Please sign in to comment.