From 501543b3ef715488a142e3d301ff2733aa33eec7 Mon Sep 17 00:00:00 2001
From: Awais Belal <awais_belal@mentor.com>
Date: Wed, 25 Oct 2017 21:00:05 +0500
Subject: [PATCH] dhcp: correct the intention for xml2 lib search

A missing case breaks the build when libxml2 is
required and found appropriately. The third argument
to the function AC_SEARCH_LIB is action-if-found which
was mistakenly been used for the case where the library
is not found and hence breaks the configure phase
where it shoud actually pass.
We now pass on silently when action-if-found is
executed.

Upstream-Status: Pending

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: dhcp-4.4.3/configure.ac
===================================================================
--- dhcp-4.4.3.orig/configure.ac
+++ dhcp-4.4.3/configure.ac
@@ -1,5 +1,7 @@
 AC_INIT([DHCP],[4.4.3],[dhcp-users@isc.org])
 
+# for libtool
+AC_CONFIG_MACRO_DIR([m4])
 
 # we specify "foreign" to avoid having to have the GNU mandated files,
 # like AUTHORS, COPYING, and such
@@ -60,7 +62,6 @@ AC_SUBST(BINDCONFIG)
 # Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
 AC_USE_SYSTEM_EXTENSIONS
 
-AC_PROG_RANLIB
 
 AC_PATH_PROG(AR, ar)
 AC_SUBST(AR)
@@ -603,10 +604,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
 # Look for optional headers.
 AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
 
-# find an MD5 library
-AC_SEARCH_LIBS(MD5_Init, [crypto])
-AC_SEARCH_LIBS(MD5Init, [crypto])
-
 # Solaris needs some libraries for functions
 AC_SEARCH_LIBS(socket, [socket])
 AC_SEARCH_LIBS(inet_ntoa, [nsl])
@@ -633,17 +630,6 @@ if test "$have_nanosleep" = "rt"; then
 	LIBS="-lrt $LIBS"
 fi
 
-AC_ARG_WITH(libxml2,
-	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
-	with_libxml2="$withval", with_libxml2="no")
-
-if test x$with_libxml2 != xno; then
-	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],
-		[if test x$with_libxml2 != xauto; then
-			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
-		fi])
-fi
-
 # check for /dev/random (declares ISC_PATH_RANDOMDEV)
 AC_MSG_CHECKING(for random device)
 AC_ARG_WITH(randomdev,
@@ -806,22 +792,22 @@ no)
 	if test ! -d "$use_libbind"; then
 		AC_MSG_ERROR([Cannot find bind directory at $use_libbind])
 	fi
-	if test ! -d "$use_libbind/include" -o \
-	        ! -f "$use_libbind/include/isc/buffer.h"
+	if test ! -d "$use_libbind/$includedir" -o \
+	        ! -f "$use_libbind/$includedir/isc/buffer.h"
 	then
-		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/include])
+		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/$includedir])
 	fi
-	if test	! -d "$use_libbind/lib" -o \
-	        \( ! -f "$use_libbind/lib/libisc.a" -a \
-		   ! -f	"$use_libbind/lib/libisc.la" \)
+	if test	! -d "$use_libbind/$libdir" -o \
+	        \( ! -f "$use_libbind/$libdir/libisc.a" -a \
+		   ! -f	"$use_libbind/$libdir/libisc.la" \)
 	then
-		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/lib])
+		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/$libdir])
 	fi
 	BINDDIR="$use_libbind"
-	BINDLIBIRSDIR="$BINDDIR/lib"
-	BINDLIBDNSDIR="$BINDDIR/lib"
-	BINDLIBISCCFGDIR="$BINDDIR/lib"
-	BINDLIBISCDIR="$BINDDIR/lib"
+	BINDLIBIRSDIR="$BINDDIR/$libdir"
+	BINDLIBDNSDIR="$BINDDIR/$libdir"
+	BINDLIBISCCFGDIR="$BINDDIR/$libdir"
+	BINDLIBISCDIR="$BINDDIR/$libdir"
 	DISTCHECK_LIBBIND_CONFIGURE_FLAG="--with-libbind=$use_libbind"
 	;;
 esac
@@ -849,39 +835,38 @@ case "$build_os" in
 esac
 
 want_libtool="no"
+LT_INIT
+want_libtool="yes"
 
 BINDLT=
 DISTCHECK_LIBTOOL_CONFIGURE_FLAG=
 AC_ARG_ENABLE(libtool,
 	AS_HELP_STRING([--enable-libtool],
-[use GNU libtool for dynamic shared libraries (default is no).]),
+[use GNU libtool for dynamic shared libraries (default is yes).]),
 	want_libtool="$enableval")
 
 if test "$use_libbind" != "no"; then
 	if test "$want_libtool" = "yes" -a \
-	        ! -f "$use_libbind/lib/libisc.la"
+	        ! -f "$use_libbind/$libdir/libisc.la"
 	then
-		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
+		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/$libdir])
 	fi
 	if test "$want_libtool" = "no" -a \
-	        ! -f "$use_libbind/lib/libisc.a"
+	        ! -f "$use_libbind/$libdir/libisc.a"
 	then
-		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
+		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/$libdir])
 	fi
 fi
 
-
-if test "$want_libtool" = "yes"; then
-	AC_MSG_WARN([legacy configure is used but libtool is enabled. Trying to recover...])
-	# expand $ac_configure_args
-	eval "set my_configure_args $ac_configure_args"
-	shift
-	cd $srcdir; exec ./config+lt "$@"
-	AC_MSG_ERROR([Recovering failed])
+if test "$want_libtool" = "no"; then
+	AC_MSG_ERROR([libtool configure is used but libtool is disabled?])
 fi
 
-DHLIBS=LIBRARIES
-A=a
+DHLIBS=LTLIBRARIES
+A=la
+BINDLT="--with-libtool --disable-symtable"
+DISTCHECK_LIBTOOL_CONFIGURE_FLAG="--enable-libtool"
+
 
 AC_SUBST(DHLIBS)
 AC_SUBST(A)
@@ -895,6 +880,7 @@ AC_SUBST(Q)
 # install bind includes and libraries
 
 want_install_bind="no"
+want_install_bind="yes"
 if test "$want_libtool" = "yes"; then
 	want_install_bind="yes"
 fi
@@ -903,7 +889,7 @@ if test "$use_libbind" != "no"; then
 fi
 AC_ARG_ENABLE(bind_install,
 	AS_HELP_STRING([--enable-bind-install],
-[install bind includes and libraries (default is no).]),
+[install bind includes and libraries.]),
 	want_install_bind="$enableval")
 if test "$want_install_bind" = "yes"; then
         if test "$use_libbind" != "no"; then
@@ -914,6 +900,18 @@ elif test "$want_libtool" = "yes" -a "$u
 fi
 AM_CONDITIONAL(INSTALL_BIND, test "$want_install_bind" = "yes")
 
+AC_ARG_WITH(libxml2,
+	AS_HELP_STRING([--with-libxml2], [link against libxml2. this is needed if bind was built with xml2 support enabled]),
+	with_libxml2="$withval", with_libxml2="no")
+
+if test x$with_libxml2 != xno; then
+	AC_SEARCH_LIBS(xmlTextWriterStartElement, [xml2],,
+		[if test x$with_libxml2 != xauto; then
+			AC_MSG_FAILURE([*** Cannot find xmlTextWriterStartElement with -lxml2 and libxml2 was requested])
+		fi])
+fi
+
+
 # OpenLDAP support.
 AC_ARG_WITH(ldap,
     AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
@@ -985,6 +983,17 @@ if test x$ldap = xyes || test x$ldapcryp
     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
 fi
 
+AC_ARG_WITH(systemd,
+        AC_HELP_STRING([--with-systemd],
+                       [enable sending status notifications to systemd daemon (default is no)]),
+        [systemd=$withval],
+        [systemd=no])
+
+if test x$systemd = xyes ; then
+   AC_CHECK_LIB(systemd, sd_notifyf, ,
+                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
+fi
+
 # Append selected warning levels to CFLAGS before substitution (but after
 # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
 CFLAGS="$CFLAGS $STD_CWARNINGS"
@@ -1029,6 +1038,10 @@ AC_CONFIG_FILES([
 ])
 AC_OUTPUT
 
+AC_MSG_NOTICE([postconfig: run automake in $srcdir])
+(cd $srcdir; automake)
+AC_MSG_NOTICE([postconfig: rerun config.status])
+sh ./config.status
 
 if test "$enable_dhcpv4o6" = "yes"; then
 	DHCP_VERSIONS="DHCPv4, DHCPv6 and DHCPv4-over-DHCPv6"
