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

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