Subject: A way to get more consistency with *USE_* variables
To: None <tech-pkg@netbsd.org>
From: Quentin Garnier <cube@NetBSD.org>
List: tech-pkg
Date: 05/02/2004 01:26:36
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
I find it rather annoying the way we are unconsistently making
features optional inside packages. I already made a change
recently for the OpenLDAP case, but I'd like to go a step
further and have a generalized way of handling this.
The issue with having USE_<FEATURE> gloablly set is that
sometimes, for a given package, you don't want to enable
that feature, or you want it only for one package.
I suggest the following: having a set of optional features,
that get actived with USE_<feature>=YES globally, but can
also be set on a per-package basis, using:
USE_<feature>.<package>=YES
I've made a quick patch that does this for OpenLDAP. It
defines a variable in bsd.pkg.defaults.mk, GLOBAL_FEATURES
that defines every USE_* variable that can be defined on a
per-package basis. Right now it only contains OPENLDAP.
The only big change it needs is moving away the defintion of
PKGNAME and PKGBASE (and associated) into bsd.prefs.mk,
because we need them way before inclusion of bsd.pkg.mk in the
packages Makefile.
The patch also adds a small message about how you got the
value of the BUILD_DEFS variable and that tells the user she
can set the specific variable USE_<FEATURE>.<package>.
It might be implemented in another way, a bit like
PREFER_PKGSRC/PRFER_NATIVE, where the user would give a list
of package in USE_<FEATURE> defition, and also we could use
along an AVOID_<FEATURE> variable. I prefer the .<package>
way, even if it means more lines in mk.conf.
Comments?
Quentin Garnier.
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ldap.diff"
Index: editors/xemacs/Makefile.common
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/editors/xemacs/Makefile.common,v
retrieving revision 1.3
diff -u -r1.3 Makefile.common
--- editors/xemacs/Makefile.common 21 Apr 2004 20:50:41 -0000 1.3
+++ editors/xemacs/Makefile.common 1 May 2004 23:11:52 -0000
@@ -69,7 +69,7 @@
. endif
.endif
-.if defined(USE_OPENLDAP) && (${USE_OPENLDAP} == "YES")
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
WITH_LDAP= --with-ldap
. include "../../databases/openldap/buildlink3.mk"
.else
Index: editors/xemacs-current/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/editors/xemacs-current/Makefile,v
retrieving revision 1.39
diff -u -r1.39 Makefile
--- editors/xemacs-current/Makefile 21 Apr 2004 20:50:41 -0000 1.39
+++ editors/xemacs-current/Makefile 1 May 2004 23:11:52 -0000
@@ -41,7 +41,7 @@
CONFIGURE_ARGS += --with-sound=none
.endif
-.if defined(USE_OPENLDAP) && (${USE_OPENLDAP} == "YES")
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
WITH_LDAP= --with-ldap
. include "../../databases/openldap/buildlink3.mk"
.else
Index: mail/balsa2/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/balsa2/Makefile,v
retrieving revision 1.27
diff -u -r1.27 Makefile
--- mail/balsa2/Makefile 14 Apr 2004 16:15:24 -0000 1.27
+++ mail/balsa2/Makefile 1 May 2004 23:11:52 -0000
@@ -35,7 +35,7 @@
.include "../../mk/bsd.prefs.mk"
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
CONFIGURE_ARGS+= --with-ldap
.include "../../databases/openldap/buildlink3.mk"
.endif
Index: mail/pine/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/pine/Makefile,v
retrieving revision 1.85
diff -u -r1.85 Makefile
--- mail/pine/Makefile 21 Apr 2004 21:09:31 -0000 1.85
+++ mail/pine/Makefile 1 May 2004 23:11:52 -0000
@@ -36,7 +36,7 @@
BUILDFILE= neb
.endif
-.if defined(USE_OPENLDAP) && (${USE_OPENLDAP} == "YES")
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink2.mk"
LDAPCFLAGS= LDAPCFLAGS="-DENABLE_LDAP"
LDAPLIBS= LDAPLIBS="-lldap -llber"
Index: mail/postfix/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/postfix/Makefile,v
retrieving revision 1.129
diff -u -r1.129 Makefile
--- mail/postfix/Makefile 21 Apr 2004 21:09:31 -0000 1.129
+++ mail/postfix/Makefile 1 May 2004 23:11:52 -0000
@@ -73,7 +73,7 @@
CCARGS+= -DNO_PCRE
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == "YES"
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink3.mk"
CCARGS+= -DHAS_LDAP
AUXLIBS+= -L${BUILDLINK_PREFIX.openldap}/lib \
Index: mail/postfix-current/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/postfix-current/Makefile,v
retrieving revision 1.31
diff -u -r1.31 Makefile
--- mail/postfix-current/Makefile 21 Apr 2004 21:09:31 -0000 1.31
+++ mail/postfix-current/Makefile 1 May 2004 23:11:52 -0000
@@ -75,7 +75,7 @@
CCARGS+= -DNO_PCRE
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == "YES"
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink3.mk"
CCARGS+= -DHAS_LDAP
AUXLIBS+= -L${BUILDLINK_PREFIX.openldap}/lib \
Index: mail/sendmail/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/sendmail/Makefile,v
retrieving revision 1.69
diff -u -r1.69 Makefile
--- mail/sendmail/Makefile 21 Apr 2004 21:09:31 -0000 1.69
+++ mail/sendmail/Makefile 1 May 2004 23:11:52 -0000
@@ -21,7 +21,7 @@
.include "../../databases/db/buildlink2.mk"
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
.include "../../databases/openldap/buildlink2.mk"
.endif
@@ -45,7 +45,7 @@
${CAT} ${FILESDIR}/site.config.m4-tcpwrappers >>${SITECONFIG}
${ECHO} -n ' TCPWRAPPERS' >>${DESCR_SRC}
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
${CAT} ${FILESDIR}/site.config.m4-ldap >>${SITECONFIG}
${ECHO} -n ' LDAP' >>${DESCR_SRC}
.endif
Index: mail/sendmail811/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/sendmail811/Makefile,v
retrieving revision 1.17
diff -u -r1.17 Makefile
--- mail/sendmail811/Makefile 21 Apr 2004 21:09:31 -0000 1.17
+++ mail/sendmail811/Makefile 1 May 2004 23:11:52 -0000
@@ -55,7 +55,7 @@
. include "../../databases/db/buildlink3.mk"
.endif
-.if defined(USE_OPENLDAP) && (${USE_OPENLDAP} == "YES")
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink3.mk"
.endif
@@ -92,7 +92,7 @@
.if ${OPSYS} == "SunOS"
${CAT} ${FILESDIR}/site.config.m4-solaris >>${SITECONFIG}
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
${CAT} ${FILESDIR}/site.config.m4-ldap >>${SITECONFIG}
${ECHO} -n ' LDAP' >>${DESCR_SRC}
.endif
Index: mail/sylpheed/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/sylpheed/Makefile,v
retrieving revision 1.65
diff -u -r1.65 Makefile
--- mail/sylpheed/Makefile 25 Apr 2004 04:16:43 -0000 1.65
+++ mail/sylpheed/Makefile 1 May 2004 23:11:52 -0000
@@ -46,7 +46,7 @@
. include "../../mail/faces/buildlink3.mk"
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
CONFIGURE_ARGS+= --enable-ldap
.include "../../databases/openldap/buildlink3.mk"
.endif
Index: mail/sylpheed-claws/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/sylpheed-claws/Makefile,v
retrieving revision 1.33
diff -u -r1.33 Makefile
--- mail/sylpheed-claws/Makefile 26 Mar 2004 02:27:44 -0000 1.33
+++ mail/sylpheed-claws/Makefile 1 May 2004 23:11:52 -0000
@@ -46,7 +46,7 @@
. include "../../mail/faces/buildlink3.mk"
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
CONFIGURE_ARGS+= --enable-ldap
.include "../../databases/openldap/buildlink3.mk"
.endif
Index: mail/sylpheed-gtk2/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mail/sylpheed-gtk2/Makefile,v
retrieving revision 1.13
diff -u -r1.13 Makefile
--- mail/sylpheed-gtk2/Makefile 17 Apr 2004 11:08:12 -0000 1.13
+++ mail/sylpheed-gtk2/Makefile 1 May 2004 23:11:52 -0000
@@ -48,7 +48,7 @@
. include "../../mail/faces/buildlink3.mk"
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
CONFIGURE_ARGS+= --enable-ldap
.include "../../databases/openldap/buildlink3.mk"
.endif
Index: mk/bsd.pkg.defaults.mk
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mk/bsd.pkg.defaults.mk,v
retrieving revision 1.235
diff -u -r1.235 bsd.pkg.defaults.mk
--- mk/bsd.pkg.defaults.mk 28 Apr 2004 11:27:54 -0000 1.235
+++ mk/bsd.pkg.defaults.mk 1 May 2004 23:11:53 -0000
@@ -1977,12 +1977,6 @@
# Possible: YES, NO
# Default: NO
-USE_OPENLDAP?= NO
-# Enable openldap support. Used in xemacs, gnupg, dovecot, postfix, samba,
-# sendmail, sylpheed, pine and others.
-# Possible: YES, or NO.
-# Default: NO
-
#USE_OSS=
#
# Used to enable OSS audio support in preference to or in place of Sun audio
@@ -2135,6 +2129,18 @@
# Possible: defined, not defined
# Default: not defined
+# Globalized variables
+GLOBAL_FEATURES= OPENLDAP
+
+# Default value is 'NO' for not-yet-defined variables, but it can be
+# overriden on a package-by-package basis
+.for _feat_ in ${GLOBAL_FEATURES}
+USE_${_feat_}?= NO
+. if defined(USE_${_feat_}.${PKGBASE}) && \
+ !empty(USE_${_feat_}.${PKGBASE}:M[Yy][Ee][Ss])
+USE_${_feat_}= ${USE_${_feat_}.${PKGBASE}}
+. endif
+.endfor
#
# Overrides for faster or cheaper sites.
Index: mk/bsd.pkg.mk
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1454
diff -u -r1.1454 bsd.pkg.mk
--- mk/bsd.pkg.mk 27 Apr 2004 22:35:47 -0000 1.1454
+++ mk/bsd.pkg.mk 1 May 2004 23:11:54 -0000
@@ -56,6 +56,13 @@
. else
@${ECHO} " * ${var} = ${${var}}"
. endif
+. if !empty(GLOBAL_FEATURES:M${var:S/^USE_//})
+. if !empty(${var}.${PKGBASE})
+ @${ECHO} " (using ${var}.${PKGBASE})"
+. else
+ @${ECHO} " (it can be set locally with ${var}.${PKGBASE})"
+. endif
+. endif
. endfor
@${ECHO} ""
@${ECHO} "You may want to abort the process now with CTRL-C and change their value"
@@ -99,10 +106,6 @@
SHLIB_HANDLING?= YES # do automatic shared lib handling
NOCLEAN?= NO # don't clean up after update
-PKGBASE?= ${PKGNAME:C/-[^-]*$//}
-PKGVERSION?= ${PKGNAME:C/^.*-//}
-PKGWILDCARD?= ${PKGBASE}-[0-9]*
-
_DISTDIR?= ${DISTDIR}/${DIST_SUBDIR}
INTERACTIVE_STAGE?= none
@@ -1198,18 +1201,6 @@
# Derived names so that they're easily overridable.
DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
-.if defined(PKGREVISION) && ${PKGREVISION} != "" && ${PKGREVISION} != "0"
-. if defined(PKGNAME)
-PKGNAME_NOREV:= ${PKGNAME}
-PKGNAME:= ${PKGNAME}nb${PKGREVISION}
-. else
-PKGNAME?= ${DISTNAME}nb${PKGREVISION}
-PKGNAME_NOREV= ${DISTNAME}
-. endif
-.else
-PKGNAME?= ${DISTNAME}
-PKGNAME_NOREV= ${PKGNAME}
-.endif
SVR4_PKGNAME?= ${PKGNAME}
MAINTAINER?= tech-pkg@NetBSD.org
Index: mk/bsd.prefs.mk
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/mk/bsd.prefs.mk,v
retrieving revision 1.160
diff -u -r1.160 bsd.prefs.mk
--- mk/bsd.prefs.mk 26 Apr 2004 17:29:33 -0000 1.160
+++ mk/bsd.prefs.mk 1 May 2004 23:11:54 -0000
@@ -212,6 +212,23 @@
. endif
.endif
+.if defined(PKGREVISION) && ${PKGREVISION} != "" && ${PKGREVISION} != "0"
+. if defined(PKGNAME)
+PKGNAME_NOREV:= ${PKGNAME}
+PKGNAME:= ${PKGNAME}nb${PKGREVISION}
+. else
+PKGNAME?= ${DISTNAME}nb${PKGREVISION}
+PKGNAME_NOREV= ${DISTNAME}
+. endif
+.else
+PKGNAME?= ${DISTNAME}
+PKGNAME_NOREV= ${PKGNAME}
+.endif
+
+PKGBASE?= ${PKGNAME:C/-[^-]*$//}
+PKGVERSION?= ${PKGNAME:C/^.*-//}
+PKGWILDCARD?= ${PKGBASE}-[0-9]*
+
# include the defaults file
.if exists(${.CURDIR}/../../mk/bsd.pkg.defaults.mk)
. include "${.CURDIR}/../../mk/bsd.pkg.defaults.mk"
Index: net/ja-samba/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/net/ja-samba/Makefile,v
retrieving revision 1.24
diff -u -r1.24 Makefile
--- net/ja-samba/Makefile 21 Apr 2004 21:09:32 -0000 1.24
+++ net/ja-samba/Makefile 1 May 2004 23:11:55 -0000
@@ -42,7 +42,7 @@
CONFIGURE_ARGS+= --with-pam
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == "YES"
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink2.mk"
BUILD_DEFS+= USE_OPENLDAP
CONFIGURE_ARGS+= --with-ldapsam
Index: net/samba/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/net/samba/Makefile,v
retrieving revision 1.121
diff -u -r1.121 Makefile
--- net/samba/Makefile 21 Apr 2004 21:09:32 -0000 1.121
+++ net/samba/Makefile 1 May 2004 23:11:55 -0000
@@ -93,7 +93,7 @@
.endif
BUILD_DEFS+= USE_PAM
-.if defined(SAMBA_USE_LDAP) || (defined(USE_OPENLDAP) && !empty(USE_OPENLDAP:M[yY][eE][sS]))
+.if defined(SAMBA_USE_LDAP) || !empty(USE_OPENLDAP:M[yY][eE][sS])
. include "../../databases/openldap/buildlink3.mk"
CONFIGURE_ARGS+= --with-ldap
. if defined(SAMBA_USE_LDAP_COMPAT) && \
Index: net/samba2/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/net/samba2/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- net/samba2/Makefile 21 Apr 2004 21:09:33 -0000 1.12
+++ net/samba2/Makefile 1 May 2004 23:11:55 -0000
@@ -32,7 +32,7 @@
CONFIGURE_ARGS+= --with-pam
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == "YES"
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
.include "../../databases/openldap/buildlink3.mk"
BUILD_DEFS+= USE_OPENLDAP
CONFIGURE_ARGS+= --with-ldapsam
Index: news/nntpcache/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/news/nntpcache/Makefile,v
retrieving revision 1.18
diff -u -r1.18 Makefile
--- news/nntpcache/Makefile 21 Apr 2004 21:09:33 -0000 1.18
+++ news/nntpcache/Makefile 1 May 2004 23:11:55 -0000
@@ -16,7 +16,9 @@
# enable pgp signed nocem support?
NNTP_USE_PGP?= no
-.if defined(USE_OPENLDAP) && !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
DEPENDS+= openldap-[0-9]*:../../databases/openldap
.endif
Index: security/gnupg/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/security/gnupg/Makefile,v
retrieving revision 1.65
diff -u -r1.65 Makefile
--- security/gnupg/Makefile 9 Apr 2004 00:36:06 -0000 1.65
+++ security/gnupg/Makefile 1 May 2004 23:11:55 -0000
@@ -57,7 +57,7 @@
${GZCAT} ${DISTDIR}/idea.c.gz > ${WRKSRC}/cipher/idea.c
.endif
-.if defined(USE_OPENLDAP) && ${USE_OPENLDAP} == YES
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
.include "../../databases/openldap/buildlink3.mk"
PLIST_SUBST+= OPENLDAP=""
.else
Index: security/cyrus-saslauthd/Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/security/cyrus-saslauthd/Makefile,v
retrieving revision 1.13
diff -u -r1.13 Makefile
--- security/cyrus-saslauthd/Makefile 21 Apr 2004 21:09:33 -0000 1.13
+++ security/cyrus-saslauthd/Makefile 1 May 2004 23:11:55 -0000
@@ -39,7 +39,7 @@
CONFIGURE_ARGS+= --with-pam=${BUILDLINK_PREFIX.pam}
.endif
-.if defined(USE_OPENLDAP) && !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
. include "../../databases/openldap/buildlink3.mk"
. include "../../security/cyrus-sasl2/buildlink3.mk"
. include "../../security/openssl/buildlink3.mk"
@@ -81,7 +81,7 @@
for f in saslcache testsaslauthd; do \
${INSTALL_PROGRAM} ${WRKSRC}/$$f ${PREFIX}/bin/$$f; \
done
-.if defined(USE_OPENLDAP) && !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
+.if !empty(USE_OPENLDAP:M[Yy][Ee][Ss])
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/cyrus-saslauthd
${INSTALL_DATA} ${WRKSRC}/LDAP_SASLAUTHD \
${PREFIX}/share/doc/cyrus-saslauthd
--k1lZvvs/B4yU6o8G--