philipp / rpms / dhcp

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