Blob Blame History Raw
diff --git a/aclocal/libxml2.m4 b/aclocal/libxml2.m4
index 5c399b2..8231553 100644
--- a/aclocal/libxml2.m4
+++ b/aclocal/libxml2.m4
@@ -1,15 +1,17 @@
 dnl Checks for libxml2.so
 AC_DEFUN([AC_LIBXML2], [
 
-  if test "$enable_junction" = yes; then
+  PKG_PROG_PKG_CONFIG([0.9.0])
+  AS_IF(
+    [test "$enable_junction" = "yes"],
+    [PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.4],
+                       [LIBXML2="${XML2_LIBS}"
+                        AM_CPPFLAGS="${AM_CPPFLAGS} ${XML2_CFLAGS}"
+                        AC_DEFINE([HAVE_LIBXML2], [1],
+                                  [Define to 1 if you have and wish to use libxml2.])],
+                       [AC_MSG_ERROR([libxml2 not found.])])])
 
-    dnl look for the library; do not add to LIBS if found
-    AC_CHECK_LIB([xml2], [xmlParseFile], [LIBXML2=-lxml2],
-                 [AC_MSG_ERROR([libxml2 not found.])])
-    AC_SUBST(LIBXML2)
-
-    dnl XXX should also check for presence of xml headers
-
-  fi
+  AC_SUBST([AM_CPPFLAGS])
+  AC_SUBST(LIBXML2)
 
 ])dnl
diff --git a/configure.ac b/configure.ac
index cf1c4b9..b458891 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,7 +165,7 @@ AC_ARG_ENABLE(uuid,
 	choose_blkid=default)
 AC_ARG_ENABLE(mount,
 	[AC_HELP_STRING([--disable-mount],
-		[Don't build mount.nfs and do use the util-linux mount(8) functionality. @<:@default=no@:>@])],
+		[Do not build mount.nfs and do use the util-linux mount(8) functionality. @<:@default=no@:>@])],
 	enable_mount=$enableval,
 	enable_mount=yes)
 	AM_CONDITIONAL(CONFIG_MOUNT, [test "$enable_mount" = "yes"])
@@ -185,7 +185,13 @@ AC_ARG_ENABLE(junction,
 			[enable support for NFS junctions @<:@default=no@:>@])],
 	enable_junction=$enableval,
 	enable_junction=no)
-AM_CONDITIONAL(CONFIG_JUNCTION, [test "$enable_junction" = "yes" ])
+	if test "$enable_junction" = yes; then
+		AC_DEFINE(HAVE_JUNCTION_SUPPORT, 1,
+                          [Define this if you want junction support compiled in])
+	else
+		enable_junction=
+	fi
+	AM_CONDITIONAL(CONFIG_JUNCTION, [test "$enable_junction" = "yes" ])
 
 AC_ARG_ENABLE(tirpc,
 	[AC_HELP_STRING([--disable-tirpc],
diff --git a/support/junction/Makefile.am b/support/junction/Makefile.am
index 97e7426..be6958b 100644
--- a/support/junction/Makefile.am
+++ b/support/junction/Makefile.am
@@ -30,5 +30,3 @@ libjunction_la_SOURCES	= display.c export-cache.c junction.c \
 			  locations.c nfs.c path.c xml.c
 
 MAINTAINERCLEANFILES	= Makefile.in
-
-AM_CPPFLAGS		= -I. -I../include -I/usr/include/libxml2
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 6f42512..7e8d403 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -976,8 +976,9 @@ lookup_export(char *dom, char *path, struct addrinfo *ai)
 	return found;
 }
 
-#ifdef CONFIG_JUNCTION
+#ifdef HAVE_JUNCTION_SUPPORT
 
+#include <libxml/parser.h>
 #include "junction.h"
 
 struct nfs_fsloc_set {
@@ -1084,8 +1085,7 @@ static bool locations_to_fslocdata(struct nfs_fsloc_set *locations,
 	*ttl = 0;
 
 	for (;;) {
-		enum jp_status status;
-		int len;
+		int len, status;
 
 		status = get_next_location(locations, &server,
 							&rootpath, ttl);
@@ -1219,7 +1219,7 @@ nfs_get_basic_junction(const char *junct_path, struct nfs_fsloc_set **locset)
 		return EINVAL;
 	}
 
-	locset->ns_current = locset->ns_list;
+	new->ns_current = new->ns_list;
 	new->ns_ttl = 300;
 	*locset = new;
 	return 0;
@@ -1242,7 +1242,7 @@ static struct exportent *lookup_junction(char *dom, const char *pathname,
 	status = nfs_get_basic_junction(pathname, &locations);
 	switch (status) {
 		xlog(L_WARNING, "Dangling junction %s: %s",
-			pathname, strerro(status));
+			pathname, strerror(status));
 		goto out;
 	}
 
@@ -1252,8 +1252,8 @@ static struct exportent *lookup_junction(char *dom, const char *pathname,
 
 	exp = locations_to_export(locations, pathname, parent);
 
-	nfs_free_locations(locset->ns_list);
-	free(locset);
+	nfs_free_locations(locations->ns_list);
+	free(locations);
 
 out:
 	xmlCleanupParser();
@@ -1273,7 +1273,7 @@ static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path
 	free(eep);
 }
 
-#else	/* !CONFIG_JUNCTION */
+#else	/* !HAVE_JUNCTION_SUPPORT */
 
 static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path,
 		struct addrinfo *UNUSED(ai))
@@ -1281,7 +1281,7 @@ static void lookup_nonexport(int f, char *buf, int buflen, char *dom, char *path
 	dump_to_cache(f, buf, buflen, dom, path, NULL, 0);
 }
 
-#endif	/* !CONFIG_JUNCTION */
+#endif	/* !HAVE_JUNCTION_SUPPORT */
 
 static void nfsd_export(int f)
 {
diff --git a/utils/nfsref/Makefile.am b/utils/nfsref/Makefile.am
index 2b2bb53..2409dd0 100644
--- a/utils/nfsref/Makefile.am
+++ b/utils/nfsref/Makefile.am
@@ -27,13 +27,11 @@ noinst_HEADERS		= nfsref.h
 
 sbin_PROGRAMS		= nfsref
 nfsref_SOURCES		= add.c lookup.c nfsref.c remove.c
-LDADD			= $(LIBXML2) $(LIBCAP) \
-			  ../../support/nfs/libnfs.la \
-			  ../../support/junction/libjunction.la
+LDADD			= ../../support/nfs/libnfs.la \
+			  ../../support/junction/libjunction.la \
+			  $(LIBXML2) $(LIBCAP)
 
 man8_MANS		= nfsref.man
 
 MAINTAINERCLEANFILES	= Makefile.in
 
-AM_CPPFLAGS		= -I. -I../../support/include
-##AM_LDFLAGS		= -Wl,--as-needed