Subject: Re: Removal of net/bind9/builtin.mk
To: None <tech-pkg@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-pkg
Date: 07/02/2007 15:21:23
--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Jun 18, 2007 at 01:22:00PM +0100, Matthias Scheler wrote:
> > You actually gave me a very good reason to really remove it. Just
> > depending on any BIND to get the resolver lib is blantantly
> > abuse. It should be something similiar to mk/pthread.b3.mk.
> 
> I'm not objecting to a better solution. But just removing it will
> result in e.g. "milter-greylist" to build the "bind9" package
> for no good reason. And that's hardly an improvment from the
> users point of view.

Attached is a first stab at a more generic solution. The operating
systems with a thread-safe resolver needs to be added, I don't think we
can detect that automatically. For now, DragonFly and FreeBSD are
supported, rest goes to net/bind9.

What do you think?

Joerg

--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="resolv.diff"

Index: mk/resolv.buildlink3.mk
===================================================================
RCS file: mk/resolv.buildlink3.mk
diff -N mk/resolv.buildlink3.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mk/resolv.buildlink3.mk	2 Jul 2007 13:23:49 -0000
@@ -0,0 +1,60 @@
+# $NetBSD: dlopen.buildlink3.mk,v 1.15 2007/06/04 08:10:32 rillig Exp $
+#
+# This Makefile fragment is included by package Makefiles and
+# buildlink3.mk files for the packages that need a thread-safe
+# DNS resolver..
+#
+# It defines the variables RESOLV_LDFLAGS and RESOLV_LIBS,
+# which are also exported into the CONFIGURE_ENV and MAKE_ENV environments.
+#
+# Package-settable variables:
+#
+# RESOLV_AUTO_VARS
+#	When set to "yes", the necessary flags are added automatically
+#	to LDFLAGS and friends.
+#
+#	Default: no
+#
+# Keywords: resolv
+#
+
+RESOLV_BUILDLINK3_MK:=	${RESOLV_BUILDLINK3_MK}+
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+RESOLV_AUTO_VARS?=	no
+CHECK_BUILTIN.resolv=	no
+
+.if ${OPSYS} == "DragonFly" || ${OPSYS} == "FreeBSD"
+USE_BUILTIN.resolv?=	yes
+
+BUILDLINK_LDFLAGS.resolv=	# empty, in libc
+.else
+USE_BUILTIN.resolv?=	no
+.endif
+
+.if !empty(USE_BUILTIN.resolv:M[yY][eE][sS])
+BUILDLINK_PACKAGES:=		${BUILDLINK_PACKAGES:Nresolv}
+BUILDLINK_PACKAGES+=		resolv
+BUILDLINK_ORDER:=		${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}resolv
+BUILDLINK_AUTO_VARS.resolv=	${RESOLV_AUTO_VARS}
+.else
+.  include "../../net/bind9/buildlink3.mk"
+
+BUILDLINK_AUTO_VARS.bind=	${RESOLV_AUTO_VARS}
+BUILDLINK_LDFLAGS.resolv=	${BUILDLINK_LDFLAGS.bind}
+BUILDLINK_LIBS.resolv=		${BUILDLINK_LIBS.bind}
+.endif
+
+.if !empty(RESOLV_BUILDLINK3_MK:M+)
+#
+# Define user-visible RESOLV_{LDFLAGS,LIBS} as compiler options used
+# to link code that needs a thread-safe DNS resolver.
+#
+RESOLV_LDFLAGS=	${BUILDLINK_LDFLAGS.resolv}
+RESOLV_LIBS=	${BUILDLINK_LIBS.resolv}
+CONFIGURE_ENV+=	RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
+CONFIGURE_ENV+=	RESOLV_LIBS=${RESOLV_LIBS:Q}
+MAKE_ENV+=	RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
+MAKE_ENV+=	RESOLV_LIBS=${RESOLV_LIBS:Q}
+.endif	# RESOLV_BUILDLINK3_MK
Index: mail/spamdyke/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/mail/spamdyke/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- mail/spamdyke/Makefile	21 Jun 2007 19:08:45 -0000	1.8
+++ mail/spamdyke/Makefile	2 Jul 2007 13:23:49 -0000
@@ -41,4 +41,5 @@
 		${INSTALL_DATA} $${f} ${PREFIX}/share/doc/${PKGBASE};	\
 	done
 
+.include "../../mk/resolv.buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
Index: mail/spamdyke/distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/mail/spamdyke/distinfo,v
retrieving revision 1.7
diff -u -r1.7 distinfo
--- mail/spamdyke/distinfo	21 Jun 2007 19:08:45 -0000	1.7
+++ mail/spamdyke/distinfo	2 Jul 2007 13:23:49 -0000
@@ -4,5 +4,5 @@
 RMD160 (spamdyke-2.6.3.tgz) = 9b061fc32ee92d731db0d8ad2cf04d61829d59ac
 Size (spamdyke-2.6.3.tgz) = 116041 bytes
 SHA1 (patch-aa) = 9bb28e5535b28fa558ce577670e4a13324664ef4
-SHA1 (patch-ab) = e92e9ed2265debd1bf3607d83c3645a37acb4ffe
-SHA1 (patch-ac) = b8e6f4aedfcc721055c280d23019e26ac4e05ca1
+SHA1 (patch-ab) = 7297b987c9195d5c111390aaa4dfd2c82df37bac
+SHA1 (patch-ac) = 64e4f02e7ff14dee2016c33a4678eba2dc2951f0
Index: mail/spamdyke/patches/patch-ab
===================================================================
RCS file: /cvsroot/pkgsrc/mail/spamdyke/patches/patch-ab,v
retrieving revision 1.3
diff -u -r1.3 patch-ab
--- mail/spamdyke/patches/patch-ab	30 May 2007 05:58:11 -0000	1.3
+++ mail/spamdyke/patches/patch-ab	2 Jul 2007 13:23:49 -0000
@@ -1,14 +1,15 @@
-$NetBSD: patch-ab,v 1.3 2007/05/30 05:58:11 schmonz Exp $
+$NetBSD$
 
---- spamdyke/Makefile.orig	2007-05-24 18:55:10.000000000 -0400
+--- spamdyke/Makefile.orig	2007-05-24 22:55:10.000000000 +0000
 +++ spamdyke/Makefile
 @@ -1,8 +1,8 @@
  #CFLAGS := -Wall -g -funsigned-char
 -CFLAGS := -Wall -O2 -funsigned-char
-+CFLAGS += -Wall -O2 -funsigned-char
- LFLAGS := -lresolv
+-LFLAGS := -lresolv
 -CFLAGS_TLS := -DTLS
 -LFLAGS_TLS := -lssl -lcrypto
++CFLAGS += -Wall -O2 -funsigned-char
++LFLAGS := ${RESOLV_DLFAGS}
 +CFLAGS_TLS ?= -DTLS
 +LFLAGS_TLS ?= -lssl -lcrypto
  OFILES := spamdyke.o command_line.o dns.o environment.o usage.o search_fs.o exec.o base64.o tls.o
Index: mail/spamdyke/patches/patch-ac
===================================================================
RCS file: /cvsroot/pkgsrc/mail/spamdyke/patches/patch-ac,v
retrieving revision 1.4
diff -u -r1.4 patch-ac
--- mail/spamdyke/patches/patch-ac	8 Jun 2007 01:08:29 -0000	1.4
+++ mail/spamdyke/patches/patch-ac	2 Jul 2007 13:23:49 -0000
@@ -1,11 +1,13 @@
-$NetBSD: patch-ac,v 1.4 2007/06/08 01:08:29 schmonz Exp $
+$NetBSD$
 
---- utils/Makefile.orig	2007-06-05 22:51:35.000000000 -0400
+--- utils/Makefile.orig	2007-06-06 02:51:35.000000000 +0000
 +++ utils/Makefile
-@@ -1,5 +1,5 @@
+@@ -1,6 +1,6 @@
  #CFLAGS := -Wall -g -funsigned-char -I../spamdyke
 -CFLAGS := -Wall -O2 -funsigned-char -I../spamdyke
+-LFLAGS := -lresolv
 +CFLAGS += -Wall -O2 -funsigned-char -I../spamdyke
- LFLAGS := -lresolv
++LFLAGS := ${RESOLV_LDFLAGS}
  
  all: domain2path domainsplit dnstxt dnsptr dnsmx passwordcheck
+ 
Index: net/nocol/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/net/nocol/Makefile,v
retrieving revision 1.31
diff -u -r1.31 Makefile
--- net/nocol/Makefile	22 Feb 2007 19:26:57 -0000	1.31
+++ net/nocol/Makefile	2 Jul 2007 13:23:49 -0000
@@ -62,4 +62,5 @@
 			    ${PREFIX}/share/nocol/gifs;			\
 	done
 
+.include "../../mk/resolv.buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
Index: net/nocol/distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/net/nocol/distinfo,v
retrieving revision 1.9
diff -u -r1.9 distinfo
--- net/nocol/distinfo	27 Dec 2005 13:47:11 -0000	1.9
+++ net/nocol/distinfo	2 Jul 2007 13:23:49 -0000
@@ -13,7 +13,7 @@
 SHA1 (patch-aj) = 0eb201f47864132b04702fab4d03e452c07c2e2a
 SHA1 (patch-ak) = 8013fbe6dbff80749dbdc0d0fad391741e48a468
 SHA1 (patch-al) = aa4fa83d53c72e17ea9ffe2685f326ebbbde9132
-SHA1 (patch-am) = 810cbecf5bb1f8a995579e8352be1007f09fa69e
+SHA1 (patch-am) = 395a5c446ac24cedf90783fc504c8817405d8e37
 SHA1 (patch-an) = ed0e6099bdc29faf90de8b2916c858e8df57e493
 SHA1 (patch-ao) = 114ebcc55d00981cc6709095f3280509880d76eb
 SHA1 (patch-ap) = 45f30a886adda7831df056cf0f7a136b97a7e17d
Index: net/nocol/patches/patch-am
===================================================================
RCS file: /cvsroot/pkgsrc/net/nocol/patches/patch-am,v
retrieving revision 1.2
diff -u -r1.2 patch-am
--- net/nocol/patches/patch-am	27 Dec 2005 13:47:11 -0000	1.2
+++ net/nocol/patches/patch-am	2 Jul 2007 13:23:49 -0000
@@ -1,8 +1,25 @@
-$NetBSD: patch-am,v 1.2 2005/12/27 13:47:11 joerg Exp $
+$NetBSD$
 
 --- Configure.orig	2000-01-19 04:34:04.000000000 +0000
 +++ Configure
-@@ -207,7 +207,7 @@ case "$OS" in
+@@ -167,15 +167,7 @@ export PSFLAGS
+ (ps $PSFLAGS) 2>&1 | egrep -i '^usage' >/dev/null 2>&1
+ if [ $? = 0 ]; then PSFLAGS='-ef' ; fi
+ 
+-LIBRESOLV="-lresolv"
+-ls /usr/lib/libresolv* >/dev/null 2>&1
+-if [ $? = 1 ]; then
+-  ls /lib/libresolv* >/dev/null 2>&1
+-  if [ $? = 1 ]; then
+-  	ls /usr/lib/libbind* >/dev/null 2>&1
+-  	if [ $? = 1 ]; then LIBRESOLV="" ; else LIBRESOLV="-lbind" ; fi
+-  fi
+-fi
++LIBRESOLV="${RESOLV_LDFLAGS}"
+ 
+ # mainly for Solaris systems
+ WHOAMI="/usr/ucb/whoami"
+@@ -207,7 +199,7 @@ case "$OS" in
  		OS_LIBS="${LIBRESOLV}"    # -lcompat
  		PING=`which ping`     # can do ping -c cnt host
  		;; 

--5vNYLRcllDrimb99--