Subject: RFC: Removing redundancy from packages that use
To: NetBSD pkgsrc Discussion <>
From: Roland Illig <>
List: tech-pkg
Date: 06/06/2007 09:44:43
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


we have a fairly established convention of how the variables for 
package-specific options are called: PKG_OPTIONS.${pkgbase}. In most 
cases, this value can be computed from either PKGNAME or DISTNAME (in 
that order), so that most of the currently 570 definitions for that 
variable can be removed. The appended patch does the work to enable the 
removal. May I commit it?

I'm asking because I am not sure about other's opinions. Maybe some 
developers want to keep that redundancy to make the reader aware of the 
variable name. But to those I can say that the variable name is printed 
in an eye-catching way when building the package.

By the way, the WARNINGS variable isn't used yet, but certainly will 
become used in the near future. In the same step, I may want to rename 
PKG_FAIL_REASON to ERRORS, since I didn't like that variable name from 
the beginning: It's a list of things, but the name isn't a plural form. 
The name is also quite long. See NetBSD's htdocs/share/mk/, 
at the very end, for prior art.


Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

RCS file: /cvsroot/pkgsrc/mk/,v
retrieving revision 1.60
diff -u -p -r1.60
---	6 Jun 2007 07:12:31 -0000	1.60
+++	6 Jun 2007 07:35:48 -0000
@@ -11,9 +11,11 @@
 #			PKG_SUPPORTED_OPTIONS=	kerberos ldap ssl
-#	PKG_OPTIONS_VAR (must be defined)
 #               The variable the user can set to enable or disable
-#		options specifically for this package.
+#		options specifically for this package. If it is not
+#		given, it is derived from either PKGNAME or DISTNAME,
+#		and is of the form PKG_OPTIONS.${PKGBASE}.
 #		This is a list of names of groups of mutually exclusive
@@ -155,6 +157,22 @@
 PKG_OPTIONS=		# empty
 # Check for variable definitions required before including this file.
+.if defined(PKG_OPTIONS_VAR) && defined(PKGNAME)
+.  if ${PKG_OPTIONS_VAR} == "PKG_OPTIONS.${PKGNAME:C/-[0-9].*//}"
+WARNINGS+=	"[] Setting PKG_OPTIONS_VAR is redundant, since it can be derived from PKGNAME."
+.  endif
+.if defined(PKG_OPTIONS_VAR) && defined(DISTNAME)
+.  if ${PKG_OPTIONS_VAR} == "PKG_OPTIONS.${DISTNAME:C/-[0-9].*//}"
+WARNINGS+=	"[] Setting PKG_OPTIONS_VAR is redundant, since it can be derived from DISTNAME."
+.  endif
+.if defined(PKGNAME)
+.if defined(DISTNAME)
 .if !defined(PKG_OPTIONS_VAR)
 PKG_FAIL_REASON+=	"[] PKG_OPTIONS_VAR is not defined."