philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-4.2.5-bind-config.patch

45d60a
From 960bee12f1ceca0d6fa97e0423be2ea0a162df96 Mon Sep 17 00:00:00 2001
45d60a
From: Petr Mensik <pemensik@redhat.com>
45d60a
Date: Fri, 9 Feb 2018 15:24:53 +0100
45d60a
Subject: [PATCH] Support for isc-config.sh script on --with-libbind parameter
45d60a
45d60a
Move checks only to isc-config section
45d60a
45d60a
Fix detection of bind flags from config
45d60a
45d60a
Add support for with-libbind=config, Improve help message
45d60a
---
45d60a
 client/Makefile.am       |  4 +-
45d60a
 common/tests/Makefile.am |  4 +-
45d60a
 configure.ac             | 91 ++++++++++++++++++++++++++++++++++++----
45d60a
 dhcpctl/Makefile.am      |  6 ++-
45d60a
 omapip/Makefile.am       |  4 +-
45d60a
 relay/Makefile.am        |  4 +-
45d60a
 server/Makefile.am       |  4 +-
45d60a
 server/tests/Makefile.am |  7 +++-
45d60a
 8 files changed, 108 insertions(+), 16 deletions(-)
45d60a
45d60a
diff --git a/client/Makefile.am b/client/Makefile.am
45d60a
index b78a915..b764a11 100644
45d60a
--- a/client/Makefile.am
45d60a
+++ b/client/Makefile.am
45d60a
@@ -1,3 +1,5 @@
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 dist_sysconf_DATA = dhclient.conf.example
45d60a
 sbin_PROGRAMS = dhclient
45d60a
 dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
45d60a
@@ -5,7 +7,7 @@ dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
45d60a
 		   scripts/netbsd scripts/nextstep scripts/openbsd \
45d60a
 		   scripts/solaris scripts/openwrt
45d60a
 dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.la \
45d60a
-		 $(BIND9_LIBDIR) -ldns-export -lisc-export $(CAPNG_LDADD)
45d60a
+		 $(CAPNG_LDADD) $(BIND_LIBS)
45d60a
 man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
45d60a
 EXTRA_DIST = $(man_MANS)
45d60a
 
45d60a
diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am
45d60a
index df68621..067acd3 100644
45d60a
--- a/common/tests/Makefile.am
45d60a
+++ b/common/tests/Makefile.am
45d60a
@@ -1,5 +1,7 @@
45d60a
 SUBDIRS = .
45d60a
 
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 AM_CPPFLAGS = $(ATF_CFLAGS) -I$(top_srcdir)/includes
45d60a
 
45d60a
 EXTRA_DIST = Atffile
45d60a
@@ -14,7 +16,7 @@ alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
45d60a
 alloc_unittest_LDADD = $(ATF_LDFLAGS)
45d60a
 alloc_unittest_LDADD += ../libdhcp.a  \
45d60a
 	../../omapip/libomapi.la \
45d60a
-	 $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+	 $(BIND_LIBS)
45d60a
 
45d60a
 check: $(ATF_TESTS)
45d60a
 	atf-run | atf-report
45d60a
diff --git a/configure.ac b/configure.ac
45d60a
index 7ef5588..f849f4b 100644
45d60a
--- a/configure.ac
45d60a
+++ b/configure.ac
45d60a
@@ -650,6 +650,10 @@ AC_CHECK_MEMBER(struct msghdr.msg_control,,
45d60a
 	])
45d60a
 
45d60a
 libbind=
45d60a
+BIND_CONFIG=
45d60a
+BIND_CPPFLAGS=
45d60a
+BIND_LIBS=
45d60a
+
45d60a
 AC_ARG_WITH(libbind,
45d60a
 	AC_HELP_STRING([--with-libbind=PATH],
45d60a
 		       [bind includes are in PATH 
45d60a
@@ -657,14 +661,32 @@ AC_ARG_WITH(libbind,
45d60a
 	use_libbind="$withval", use_libbind="no")
45d60a
 case "$use_libbind" in 
45d60a
 yes|no)
45d60a
-	libbind="\${top_srcdir}/bind/include"
45d60a
+	libbind="\${top_srcdir}/bind"
45d60a
+	;;
45d60a
+config)
45d60a
+	AC_PATH_PROG(BIND_CONFIG, [isc-config.sh bind9-config])
45d60a
 	;;
45d60a
 *)
45d60a
-	libbind="$use_libbind"
45d60a
+	if test -f "$use_libbind" -a -x "$use_libbind"; then
45d60a
+		# passed full path of isc-config.sh
45d60a
+		BIND_CONFIG="$use_libbind"
45d60a
+	else
45d60a
+		libbind="$use_libbind"
45d60a
+		if test ! -d "$srcdir/bind"; then
45d60a
+			# no bind directory, create it with a fake Makefile.in
45d60a
+			# (AC_CONFIG_FILES and top Makefile refer to it so
45d60a
+			# it must exits)
45d60a
+			mkdir $srcdir/bind
45d60a
+			cat > $srcdir/bind/Makefile.in << EOF
45d60a
+# placeholder
45d60a
+all check clean distclean distdir install uninstall:
45d60a
+EOF
45d60a
+		fi
45d60a
+	fi
45d60a
 	;;
45d60a
 esac
45d60a
-
45d60a
-BIND9_LIBDIR='-L$(top_builddir)/bind/lib'
45d60a
+	
45d60a
+BIND_LIBDIR='$(top_builddir)/bind/lib'
45d60a
 AC_ARG_WITH(libbind-libs,
45d60a
 	AC_HELP_STRING([--with-libbind-libs=PATH],
45d60a
 		       [bind9 export libraries are in PATH]),
45d60a
@@ -677,13 +699,68 @@ no)
45d60a
 	BUNDLED_BIND=yes
45d60a
 	;;
45d60a
 *)
45d60a
-	BIND9_LIBDIR="-L$libbind_libs"
45d60a
+	BIND_LIBDIR="$libbind_libs"
45d60a
 	BUNDLED_BIND=no
45d60a
 	;;
45d60a
 esac
45d60a
-AM_CONDITIONAL([BUNDLED_BIND], [test "$BUNDLED_BIND" = yes])
45d60a
+BIND9_LIBDIR="-L$BIND_LIBDIR"
45d60a
 AC_SUBST([BIND9_LIBDIR])
45d60a
 
45d60a
+if test -z "$BIND_CONFIG"; then
45d60a
+	BIND_CPPFLAGS="-I${libbind}/include"
45d60a
+	BIND_LIBS="$BIND9_LIBDIR -ldns -lisc"
45d60a
+else
45d60a
+	BIND_CPPFLAGS=`$BIND_CONFIG --cflags`
45d60a
+	BIND_LIBS=`$BIND_CONFIG --libs dns isc`
45d60a
+	BUNDLED_BIND=no
45d60a
+
45d60a
+	# bind is already built
45d60a
+	AC_CHECKING([Checking bind libraries have no thread support])
45d60a
+	saved_libs="$LIBS"
45d60a
+	saved_CPPFLAGS="$CPPFLAGS"
45d60a
+	CPPFLAGS="${CPPFLAGS} ${BIND_CPPFLAGS}"
45d60a
+	LIBS="${LIBS} ${BIND_LIBS}"
45d60a
+AC_TRY_LINK([
45d60a
+#include <isc/bind9.h>
45d60a
+#include <isc/lib.h>
45d60a
+],[
45d60a
+#ifdef BIND9
45d60a
+#error Export BIND library has to be used with BIND version up to 9.9
45d60a
+#endif
45d60a
+isc_lib_register();
45d60a
+], [AC_MSG_RESULT(Bind export library found)
45d60a
+    BIND_EXPORT=yes], [BIND_EXPORT=no]
45d60a
+)
45d60a
+
45d60a
+# Allow build with disabled threads for dhcp
45d60a
+AC_TRY_LINK([
45d60a
+#include <isc/platform.h>
45d60a
+#include <isc/bind9.h>
45d60a
+#include <isc/lib.h>
45d60a
+],[
45d60a
+#ifdef ISC_PLATFORM_USETHREADS
45d60a
+#error Bind library must not be compiled with threads
45d60a
+#endif
45d60a
+isc_lib_register();
45d60a
+if (isc_bind9 != 0) {}
45d60a
+], [AC_MSG_RESULT(Bind single thread library found)
45d60a
+    BIND_SINGLETHREAD=yes], [BIND_SINGLETHREAD=no]
45d60a
+)
45d60a
+
45d60a
+	if test "x$BIND_EXPORT" != xyes -a "x$BIND_SINGLETHREADED" != xyes
45d60a
+	then
45d60a
+		AC_MSG_RESULT([BIND_CONFIG=${BIND_CONFIG}])
45d60a
+		AC_MSG_RESULT([BIND_CPPFLAGS=${BIND_CPPFLAGS}])
45d60a
+		AC_MSG_RESULT([BIND_LIBS=${BIND_LIBS}])
45d60a
+		AC_MSG_ERROR([Bind libraries are not useable for dhcp])
45d60a
+	fi
45d60a
+	CPPFLAGS="$saved_CPPFLAGS"
45d60a
+	LIBS="$saved_LIBS"
45d60a
+fi
45d60a
+AC_SUBST(BIND_CPPFLAGS)
45d60a
+AC_SUBST(BIND_LIBS)
45d60a
+AM_CONDITIONAL([BUNDLED_BIND], [test "$BUNDLED_BIND" = yes])
45d60a
+
45d60a
 # OpenLDAP support.
45d60a
 AC_ARG_WITH(ldap,
45d60a
     AC_HELP_STRING([--with-ldap],
45d60a
@@ -730,7 +807,7 @@ fi
45d60a
 CFLAGS="$CFLAGS $STD_CWARNINGS"
45d60a
 
45d60a
 # Try to add the bind include directory
45d60a
-CFLAGS="$CFLAGS -I$libbind"
45d60a
+CFLAGS="$CFLAGS $BIND_CPPFLAGS"
45d60a
 
45d60a
 AC_C_FLEXIBLE_ARRAY_MEMBER
45d60a
 
45d60a
diff --git a/dhcpctl/Makefile.am b/dhcpctl/Makefile.am
45d60a
index fb7a840..4f59dcf 100644
45d60a
--- a/dhcpctl/Makefile.am
45d60a
+++ b/dhcpctl/Makefile.am
45d60a
@@ -1,3 +1,5 @@
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 bin_PROGRAMS = omshell
45d60a
 lib_LTLIBRARIES = libdhcpctl.la
45d60a
 noinst_PROGRAMS = cltest
45d60a
@@ -6,10 +8,10 @@ EXTRA_DIST = $(man_MANS)
45d60a
 
45d60a
 omshell_SOURCES = omshell.c
45d60a
 omshell_LDADD = libdhcpctl.la ../common/libdhcp.a ../omapip/libomapi.la \
45d60a
-	        $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+	        $(BIND_LIBS)
45d60a
 
45d60a
 libdhcpctl_la_SOURCES = dhcpctl.c callback.c remote.c
45d60a
 
45d60a
 cltest_SOURCES = cltest.c
45d60a
 cltest_LDADD = libdhcpctl.la ../common/libdhcp.a ../omapip/libomapi.la \
45d60a
-	       $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+	        $(BIND_LIBS)
45d60a
diff --git a/omapip/Makefile.am b/omapip/Makefile.am
45d60a
index 6247549..265bcef 100644
45d60a
--- a/omapip/Makefile.am
45d60a
+++ b/omapip/Makefile.am
45d60a
@@ -1,3 +1,5 @@
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 lib_LTLIBRARIES = libomapi.la
45d60a
 noinst_PROGRAMS = svtest
45d60a
 
45d60a
@@ -10,5 +12,5 @@ man_MANS = omapi.3
45d60a
 EXTRA_DIST = $(man_MANS)
45d60a
 
45d60a
 svtest_SOURCES = test.c
45d60a
-svtest_LDADD = libomapi.la $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+svtest_LDADD = libomapi.la $(BIND_LIBS)
45d60a
 
45d60a
diff --git a/relay/Makefile.am b/relay/Makefile.am
45d60a
index 1885c82..999e543 100644
45d60a
--- a/relay/Makefile.am
45d60a
+++ b/relay/Makefile.am
45d60a
@@ -1,9 +1,11 @@
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"'
45d60a
 
45d60a
 sbin_PROGRAMS = dhcrelay
45d60a
 dhcrelay_SOURCES = dhcrelay.c
45d60a
 dhcrelay_LDADD = ../common/libdhcp.a ../omapip/libomapi.la \
45d60a
-		 $(BIND9_LIBDIR) -ldns-export -lisc-export $(CAPNG_LDADD)
45d60a
+		 $(CAPNG_LDADD) $(BIND_LIBS)
45d60a
 man_MANS = dhcrelay.8
45d60a
 EXTRA_DIST = $(man_MANS)
45d60a
 
45d60a
diff --git a/server/Makefile.am b/server/Makefile.am
45d60a
index 1d1122d..e593898 100644
45d60a
--- a/server/Makefile.am
45d60a
+++ b/server/Makefile.am
45d60a
@@ -4,6 +4,8 @@
45d60a
 # production code. Sadly, we are not there yet.
45d60a
 SUBDIRS = . tests
45d60a
 
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+
45d60a
 AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
45d60a
 
45d60a
 dist_sysconf_DATA = dhcpd.conf.example
45d60a
@@ -14,7 +16,7 @@ dhcpd_SOURCES = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \
45d60a
 
45d60a
 dhcpd_CFLAGS = $(LDAP_CFLAGS)
45d60a
 dhcpd_LDADD = ../common/libdhcp.a ../omapip/libomapi.la \
45d60a
-	      ../dhcpctl/libdhcpctl.la $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+	      ../dhcpctl/libdhcpctl.la $(BIND_LIBS)
45d60a
 
45d60a
 man_MANS = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
45d60a
 EXTRA_DIST = $(man_MANS)
45d60a
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
45d60a
index 5f2c5a8..4522f6b 100644
45d60a
--- a/server/tests/Makefile.am
45d60a
+++ b/server/tests/Makefile.am
45d60a
@@ -1,7 +1,10 @@
45d60a
 SUBDIRS = .
45d60a
 
45d60a
+BIND_LIBS = @BIND_LIBS@
45d60a
+BIND_CPPFLAGS = @BIND_CPPFLAGS@
45d60a
+
45d60a
 AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes
45d60a
-AM_CPPFLAGS += -I$(top_srcdir)/bind/include -I$(top_srcdir)
45d60a
+AM_CPPFLAGS += $(BIND_CPPFLAGS) -I$(top_srcdir)
45d60a
 AM_CPPFLAGS += -DLOCALSTATEDIR='"."'
45d60a
 
45d60a
 EXTRA_DIST = Atffile
45d60a
@@ -18,7 +21,7 @@ DHCPSRC = ../dhcp.c ../bootp.c ../confpars.c ../db.c ../class.c      \
45d60a
           ../ldap.c ../ldap_casa.c ../dhcpd.c
45d60a
 
45d60a
 DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.la    \
45d60a
-          $(top_builddir)/dhcpctl/libdhcpctl.la $(BIND9_LIBDIR) -ldns-export -lisc-export
45d60a
+          $(top_builddir)/dhcpctl/libdhcpctl.la $(BIND_LIBS)
45d60a
 
45d60a
 if ENABLE_SYSTEMTAP
45d60a
 DHCPLIBS += ../probes.o
45d60a
-- 
45d60a
2.20.1
45d60a