Blame SOURCES/dhcp-remove-bind.patch

26a25c
From 2698385647a6ebd58b5d25147333e494c3da2409 Mon Sep 17 00:00:00 2001
26a25c
From: Petr Mensik <pemensik@redhat.com>
26a25c
Date: Fri, 9 Feb 2018 15:24:53 +0100
26a25c
Subject: [PATCH] Support for isc-config.sh script on --with-libbind parameter
26a25c
26a25c
Move checks only to isc-config section
26a25c
26a25c
Fix detection of bind flags from config
26a25c
26a25c
Add support for with-libbind=config, Improve help message
26a25c
---
26a25c
 client/Makefile.am       |  5 ++-
26a25c
 client/tests/Makefile.am |  8 ++---
26a25c
 common/tests/Makefile.am | 14 +++-----
26a25c
 configure.ac             | 84 ++++++++++++++++++++++++++++++++++++++++++------
26a25c
 dhcpctl/Makefile.am      |  8 ++---
26a25c
 omapip/Makefile.am       |  5 ++-
26a25c
 relay/Makefile.am        |  5 ++-
26a25c
 server/Makefile.am       |  6 ++--
26a25c
 server/tests/Makefile.am |  9 +++---
26a25c
 9 files changed, 98 insertions(+), 46 deletions(-)
26a25c
26a25c
diff --git a/client/Makefile.am b/client/Makefile.am
26a25c
index 2cb83d8..b85f5d2 100644
26a25c
--- a/client/Makefile.am
26a25c
+++ b/client/Makefile.am
26a25c
@@ -4,7 +4,7 @@
26a25c
 # production code. Sadly, we are not there yet.
26a25c
 SUBDIRS = . tests
26a25c
 
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
26a25c
 	      -DLOCALSTATEDIR='"$(localstatedir)"'
26a25c
@@ -15,7 +15,6 @@ dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
26a25c
 		   scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
26a25c
 		   scripts/netbsd scripts/nextstep scripts/openbsd \
26a25c
 		   scripts/solaris scripts/openwrt
26a25c
-dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
26a25c
-		 $(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
26a25c
+dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a $(BIND_LIBS)
26a25c
 man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
26a25c
 EXTRA_DIST = $(man_MANS)
26a25c
diff --git a/client/tests/Makefile.am b/client/tests/Makefile.am
26a25c
index 5031d0c..bb1fda4 100644
26a25c
--- a/client/tests/Makefile.am
26a25c
+++ b/client/tests/Makefile.am
26a25c
@@ -1,9 +1,9 @@
26a25c
 SUBDIRS = .
26a25c
 
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes
26a25c
-AM_CPPFLAGS += -I@BINDDIR@/include -I$(top_srcdir)
26a25c
+AM_CPPFLAGS += @BIND_CPPFLAGS@ -I$(top_srcdir)
26a25c
 AM_CPPFLAGS += -DLOCALSTATEDIR='"."'
26a25c
 AM_CPPFLAGS += -DCLIENT_PATH='"."'
26a25c
 
26a25c
@@ -18,9 +18,7 @@ info:
26a25c
 DHCPSRC = ../clparse.c ../dhc6.c ../dhclient.c
26a25c
 
26a25c
 DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.a    \
26a25c
-          $(top_builddir)/dhcpctl/libdhcpctl.a $(BINDLIBDIR)/libirs.a \
26a25c
-	  $(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a \
26a25c
-	  $(BINDLIBDIR)/libisc.a
26a25c
+          $(top_builddir)/dhcpctl/libdhcpctl.a $(BIND_LIBS)
26a25c
 
26a25c
 ATF_TESTS =
26a25c
 if HAVE_ATF
26a25c
diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am
26a25c
index f6a43e4..196aa44 100644
26a25c
--- a/common/tests/Makefile.am
26a25c
+++ b/common/tests/Makefile.am
26a25c
@@ -1,6 +1,6 @@
26a25c
 SUBDIRS = .
26a25c
 
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 AM_CPPFLAGS = $(ATF_CFLAGS) -I$(top_srcdir)/includes
26a25c
 
26a25c
@@ -15,26 +15,22 @@ ATF_TESTS += alloc_unittest dns_unittest misc_unittest ns_name_unittest
26a25c
 alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
26a25c
 alloc_unittest_LDADD = $(ATF_LDFLAGS)
26a25c
 alloc_unittest_LDADD += ../libdhcp.a  \
26a25c
-	../../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
26a25c
-	$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a  $(BINDLIBDIR)/libisc.a
26a25c
+	../../omapip/libomapi.a $(BIND_LIBS)
26a25c
 
26a25c
 dns_unittest_SOURCES = dns_unittest.c $(top_srcdir)/tests/t_api_dhcp.c
26a25c
 dns_unittest_LDADD = $(ATF_LDFLAGS)
26a25c
 dns_unittest_LDADD += ../libdhcp.a  \
26a25c
-	../../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
26a25c
-	$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a  $(BINDLIBDIR)/libisc.a
26a25c
+	../../omapip/libomapi.a $(BIND_LIBS)
26a25c
 
26a25c
 misc_unittest_SOURCES = misc_unittest.c $(top_srcdir)/tests/t_api_dhcp.c
26a25c
 misc_unittest_LDADD = $(ATF_LDFLAGS)
26a25c
 misc_unittest_LDADD += ../libdhcp.a  \
26a25c
-	../../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
26a25c
-	$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a  $(BINDLIBDIR)/libisc.a
26a25c
+	../../omapip/libomapi.a $(BIND_LIBS)
26a25c
 
26a25c
 ns_name_unittest_SOURCES = ns_name_test.c $(top_srcdir)/tests/t_api_dhcp.c
26a25c
 ns_name_unittest_LDADD = $(ATF_LDFLAGS)
26a25c
 ns_name_unittest_LDADD += ../libdhcp.a  \
26a25c
-	../../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
26a25c
-	$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a  $(BINDLIBDIR)/libisc.a
26a25c
+	../../omapip/libomapi.a $(BIND_LIBS)
26a25c
 
26a25c
 check: $(ATF_TESTS)
26a25c
 	@if test $(top_srcdir) != ${top_builddir}; then \
26a25c
diff --git a/configure.ac b/configure.ac
26a25c
index cdfa352..ef55f8d 100644
26a25c
--- a/configure.ac
26a25c
+++ b/configure.ac
26a25c
@@ -688,8 +688,12 @@ AC_CHECK_MEMBER(struct tpacket_auxdata.tp_vlan_tci,
26a25c
 
26a25c
 BINDDIR=
26a25c
 BINDSRCDIR=
26a25c
+BIND_CONFIG=
26a25c
+BIND_CPPFLAGS=
26a25c
+BIND_LIBS=
26a25c
 AC_ARG_WITH(libbind,
26a25c
-	AS_HELP_STRING([--with-libbind=PATH],[bind includes and libraries are in PATH
26a25c
+	AS_HELP_STRING([--with-libbind=PATH|config],[bind includes and libraries are in PATH.
26a25c
+		        Use config to obtain libraries from isc-config.sh.
26a25c
 		        (default is ./bind)]),
26a25c
 	use_libbind="$withval", use_libbind="no")
26a25c
 case "$use_libbind" in
26a25c
@@ -701,23 +705,85 @@ no)
26a25c
 	BINDDIR="\${top_srcdir}/bind"
26a25c
 	BINDSRCDIR="\${top_srcdir}/bind"
26a25c
 	;;
26a25c
+config)
26a25c
+	AC_PATH_PROG(BIND_CONFIG, [isc-config.sh bind9-config])
26a25c
+	;;
26a25c
 *)
26a25c
-	BINDDIR="$use_libbind"
26a25c
-	if test ! -d "$srcdir/bind"; then
26a25c
-		# no bind directory, create it with a fake Makefile.in
26a25c
-		# (AC_CONFIG_FILES and top Makefile refer to it so
26a25c
-		# it must exits)
26a25c
-		mkdir $srcdir/bind
26a25c
-		cat > $srcdir/bind/Makefile.in << EOF
26a25c
+	if test -f "$use_libbind" -a -x "$use_libbind"; then
26a25c
+		# passed full path of isc-config.sh
26a25c
+		BIND_CONFIG="$use_libbind"
26a25c
+	else
26a25c
+		BINDDIR="$use_libbind"
26a25c
+		if test ! -d "$srcdir/bind"; then
26a25c
+			# no bind directory, create it with a fake Makefile.in
26a25c
+			# (AC_CONFIG_FILES and top Makefile refer to it so
26a25c
+			# it must exits)
26a25c
+			mkdir $srcdir/bind
26a25c
+			cat > $srcdir/bind/Makefile.in << EOF
26a25c
 # placeholder
26a25c
 all check clean distclean distdir install uninstall:
26a25c
 
26a25c
 EOF
26a25c
+		fi
26a25c
 	fi
26a25c
 	;;
26a25c
 esac
26a25c
+if test -z "$BIND_CONFIG"; then
26a25c
+	BIND_CPPFLAGS="-I${BINDDIR}/include"
26a25c
+	BIND_LIBDIR="${BINDDIR}/lib"
26a25c
+	BIND_LIBS="$(BINDLIBDIR)/libirs.a $(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a  $(BINDLIBDIR)/libisc.a"
26a25c
+else
26a25c
+	BIND_CPPFLAGS=`$BIND_CONFIG --cflags`
26a25c
+	BIND_LIBS=`$BIND_CONFIG --libs irs dns isccfg isc`
26a25c
+
26a25c
+	# bind is already built
26a25c
+	AC_CHECKING([Checking bind libraries have no thread support])
26a25c
+	saved_libs="$LIBS"
26a25c
+	saved_CPPFLAGS="$CPPFLAGS"
26a25c
+	CPPFLAGS="${CPPFLAGS} ${BIND_CPPFLAGS}"
26a25c
+	LIBS="${LIBS} ${BIND_LIBS}"
26a25c
+AC_TRY_LINK([
26a25c
+#include <isc/bind9.h>
26a25c
+#include <isc/lib.h>
26a25c
+],[
26a25c
+#ifdef BIND9
26a25c
+#error Export BIND library has to be used with BIND version up to 9.9
26a25c
+#endif
26a25c
+isc_lib_register();
26a25c
+], [AC_MSG_RESULT(Bind export library found)
26a25c
+    BIND_EXPORT=yes], [BIND_EXPORT=no]
26a25c
+)
26a25c
+
26a25c
+# Allow build with disabled threads for dhcp
26a25c
+AC_TRY_LINK([
26a25c
+#include <isc/platform.h>
26a25c
+#include <isc/bind9.h>
26a25c
+#include <isc/lib.h>
26a25c
+],[
26a25c
+#ifdef ISC_PLATFORM_USETHREADS
26a25c
+#error Bind library must not be compiled with threads
26a25c
+#endif
26a25c
+isc_lib_register();
26a25c
+if (isc_bind9 != 0) {}
26a25c
+], [AC_MSG_RESULT(Bind single thread library found)
26a25c
+    BIND_SINGLETHREAD=yes], [BIND_SINGLETHREAD=no]
26a25c
+)
26a25c
+
26a25c
+	if test "x$BIND_EXPORT" != xyes -a "x$BIND_SINGLETHREADED" != xyes
26a25c
+	then
26a25c
+		AC_MSG_RESULT([BIND_CONFIG=${BIND_CONFIG}])
26a25c
+		AC_MSG_RESULT([BIND_CPPFLAGS=${BIND_CPPFLAGS}])
26a25c
+		AC_MSG_RESULT([BIND_LIBS=${BIND_LIBS}])
26a25c
+		AC_MSG_ERROR([Bind libraries are not useable for dhcp])
26a25c
+	fi
26a25c
+	CPPFLAGS="$saved_CPPFLAGS"
26a25c
+	LIBS="$saved_LIBS"
26a25c
+fi
26a25c
+
26a25c
 AC_SUBST(BINDDIR)
26a25c
 AC_SUBST(BINDSRCDIR)
26a25c
+AC_SUBST(BIND_CPPFLAGS)
26a25c
+AC_SUBST(BIND_LIBS)
26a25c
 
26a25c
 # OpenLDAP support.
26a25c
 AC_ARG_WITH(ldap,
26a25c
@@ -795,7 +861,7 @@ fi
26a25c
 CFLAGS="$CFLAGS $STD_CWARNINGS"
26a25c
 
26a25c
 # Try to add the bind and dhcp include directories
26a25c
-CFLAGS="$CFLAGS -I\$(top_srcdir)/includes -I$BINDDIR/include"
26a25c
+CFLAGS="$CFLAGS -I\$(top_srcdir)/includes $BIND_CPPFLAGS"
26a25c
 
26a25c
 case "$host" in
26a25c
 *-darwin*)
26a25c
diff --git a/dhcpctl/Makefile.am b/dhcpctl/Makefile.am
26a25c
index ceb0de1..fa20a78 100644
26a25c
--- a/dhcpctl/Makefile.am
26a25c
+++ b/dhcpctl/Makefile.am
26a25c
@@ -1,4 +1,4 @@
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 bin_PROGRAMS = omshell
26a25c
 lib_LIBRARIES = libdhcpctl.a
26a25c
@@ -8,12 +8,10 @@ EXTRA_DIST = $(man_MANS)
26a25c
 
26a25c
 omshell_SOURCES = omshell.c
26a25c
 omshell_LDADD = libdhcpctl.a ../common/libdhcp.a ../omapip/libomapi.a \
26a25c
-	        $(BINDLIBDIR)/libirs.a $(BINDLIBDIR)/libdns.a \
26a25c
-	        $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
26a25c
+	        $(BIND_LIBS)
26a25c
 
26a25c
 libdhcpctl_a_SOURCES = dhcpctl.c callback.c remote.c
26a25c
 
26a25c
 cltest_SOURCES = cltest.c
26a25c
 cltest_LDADD = libdhcpctl.a ../common/libdhcp.a ../omapip/libomapi.a \
26a25c
-	       $(BINDLIBDIR)/libirs.a $(BINDLIBDIR)/libdns.a \
26a25c
-               $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
26a25c
+	       $(BIND_LIBS)
26a25c
diff --git a/omapip/Makefile.am b/omapip/Makefile.am
26a25c
index 446a594..b0d2680 100644
26a25c
--- a/omapip/Makefile.am
26a25c
+++ b/omapip/Makefile.am
26a25c
@@ -1,4 +1,4 @@
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 lib_LIBRARIES = libomapi.a
26a25c
 noinst_PROGRAMS = svtest
26a25c
@@ -12,6 +12,5 @@ man_MANS = omapi.3
26a25c
 EXTRA_DIST = $(man_MANS)
26a25c
 
26a25c
 svtest_SOURCES = test.c
26a25c
-svtest_LDADD = libomapi.a $(BINDLIBDIR)/libirs.a $(BINDLIBDIR)/libdns.a \
26a25c
-		$(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
26a25c
+svtest_LDADD = libomapi.a $(BIND_LIBS)
26a25c
 
26a25c
diff --git a/relay/Makefile.am b/relay/Makefile.am
26a25c
index 3060eca..c9a1cba 100644
26a25c
--- a/relay/Makefile.am
26a25c
+++ b/relay/Makefile.am
26a25c
@@ -1,12 +1,11 @@
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"'
26a25c
 
26a25c
 sbin_PROGRAMS = dhcrelay
26a25c
 dhcrelay_SOURCES = dhcrelay.c
26a25c
 dhcrelay_LDADD = ../common/libdhcp.a ../omapip/libomapi.a \
26a25c
-		 $(BINDLIBDIR)/libirs.a $(BINDLIBDIR)/libdns.a \
26a25c
-		 $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
26a25c
+		 $(BIND_LIBS)
26a25c
 man_MANS = dhcrelay.8
26a25c
 EXTRA_DIST = $(man_MANS)
26a25c
 
26a25c
diff --git a/server/Makefile.am b/server/Makefile.am
26a25c
index 54feedf..30cf2b1 100644
26a25c
--- a/server/Makefile.am
26a25c
+++ b/server/Makefile.am
26a25c
@@ -4,7 +4,7 @@
26a25c
 # production code. Sadly, we are not there yet.
26a25c
 SUBDIRS = . tests
26a25c
 
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
 
26a25c
 AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
26a25c
 
26a25c
@@ -16,9 +16,7 @@ dhcpd_SOURCES = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \
26a25c
 
26a25c
 dhcpd_CFLAGS = $(LDAP_CFLAGS)
26a25c
 dhcpd_LDADD = ../common/libdhcp.a ../omapip/libomapi.a \
26a25c
-	      ../dhcpctl/libdhcpctl.a $(BINDLIBDIR)/libirs.a \
26a25c
-	      $(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a \
26a25c
-	      $(BINDLIBDIR)/libisc.a $(LDAP_LIBS)
26a25c
+	      ../dhcpctl/libdhcpctl.a $(BIND_LIBS) $(LDAP_LIBS)
26a25c
 
26a25c
 man_MANS = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
26a25c
 EXTRA_DIST = $(man_MANS)
26a25c
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
26a25c
index a87c5e7..771de06 100644
26a25c
--- a/server/tests/Makefile.am
26a25c
+++ b/server/tests/Makefile.am
26a25c
@@ -1,9 +1,10 @@
26a25c
 SUBDIRS = .
26a25c
 
26a25c
-BINDLIBDIR = @BINDDIR@/lib
26a25c
+BIND_LIBS = @BIND_LIBS@
26a25c
+
26a25c
 
26a25c
 AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes
26a25c
-AM_CPPFLAGS += -I@BINDDIR@/include -I$(top_srcdir)
26a25c
+AM_CPPFLAGS += $(BIND_CPPFLAGS) -I$(top_srcdir)
26a25c
 AM_CPPFLAGS += -DLOCALSTATEDIR='"."'
26a25c
 
26a25c
 EXTRA_DIST = Atffile
26a25c
@@ -20,9 +21,7 @@ DHCPSRC = ../dhcp.c ../bootp.c ../confpars.c ../db.c ../class.c      \
26a25c
           ../ldap.c ../ldap_casa.c ../dhcpd.c ../leasechain.c
26a25c
 
26a25c
 DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.a \
26a25c
-          $(top_builddir)/dhcpctl/libdhcpctl.a $(BINDLIBDIR)/libirs.a \
26a25c
-	  $(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a \
26a25c
-	  $(BINDLIBDIR)/libisc.a
26a25c
+          $(top_builddir)/dhcpctl/libdhcpctl.a $(BIND_LIBS)
26a25c
 
26a25c
 ATF_TESTS =
26a25c
 if HAVE_ATF
26a25c
-- 
26a25c
2.14.3
26a25c