am-utils/am-utils-6.2-use-linux-libtirpc-if-present.patch
2016-09-14 17:56:29 +08:00

94 lines
3.0 KiB
Diff

am-utils-6.2 - use Linux libtirpc if present
From: Ian Kent <raven@themaw.net>
For Linux systems, if the header files and shared libraries of libtirpc
are present use them instead of the glibc RPC implementation.
Signed-off-by: Ian Kent <raven@themaw.net>
---
Makefile.am | 3 ++-
configure.ac | 4 ++++
include/am_compat.h | 8 ++++++--
m4/macros/check_linux_libtirpc.m4 | 13 +++++++++++++
4 files changed, 25 insertions(+), 3 deletions(-)
create mode 100644 m4/macros/check_linux_libtirpc.m4
diff --git a/Makefile.am b/Makefile.am
index bae4615..e094e95 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -146,7 +146,8 @@ EXTRA_DIST_M4 = \
m4/macros/type_xdrproc_t.m4 \
m4/macros/type_xfs_args.m4 \
m4/macros/type_yp_order_outorder.m4 \
- m4/macros/with_addon.m4
+ m4/macros/with_addon.m4 \
+ m4/macros/check_linux_libtirpc.m4
EXTRA_DIST_CONF = \
conf/autofs/autofs_default.h \
diff --git a/configure.ac b/configure.ac
index ce61925..98b444d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,9 @@ dnl lots of code. So I am forced to use a special purpose macro that sets
dnl the libraries based on the OS. Sigh. -Erez.
AMU_CHECK_OS_LIBS
+dnl use Linux libtirpc if possible
+AMU_CHECK_LIBTIRPC
+
dnl librpc and librpcsvc are needed on Solaris
AC_CHECK_LIB(rpc, clnt_sperrno)
AC_CHECK_LIB(rpcsvc, xdr_fhandle)
@@ -433,6 +436,7 @@ AC_CHECK_HEADERS( \
arpa/nameser.h \
arpa/inet.h \
bsd/rpc/rpc.h \
+ tirpc/netconfig.h \
cdfs/cdfsmount.h \
cdfs/cdfs_mount.h \
fs/udf/udf_mount.h \
diff --git a/include/am_compat.h b/include/am_compat.h
index 3463f3f..d6826fc 100644
--- a/include/am_compat.h
+++ b/include/am_compat.h
@@ -454,11 +454,15 @@ struct hsfs_args {
/*
* Define a dummy struct netconfig for non-TLI systems
*/
-#if !defined(HAVE_NETCONFIG_H) && !defined(HAVE_SYS_NETCONFIG_H)
+#if !defined(HAVE_NETCONFIG_H)
+# if !defined(HAVE_SYS_NETCONFIG_H)
+# if !defined(HAVE_TIRPC_NETCONFIG_H)
struct netconfig {
int dummy;
};
-#endif /* not HAVE_NETCONFIG_H and not HAVE_SYS_NETCONFIG_H */
+# endif /* not HAVE_TIRPC_NETCONFIG_H */
+# endif /* not HAVE_SYS_NETCONFIG_H */
+#endif /* not HAVE_NETCONFIG_H */
/* some OSs don't define INADDR_NONE and assume it's unsigned -1 */
#ifndef INADDR_NONE
diff --git a/m4/macros/check_linux_libtirpc.m4 b/m4/macros/check_linux_libtirpc.m4
new file mode 100644
index 0000000..918423c
--- /dev/null
+++ b/m4/macros/check_linux_libtirpc.m4
@@ -0,0 +1,13 @@
+dnl ######################################################################
+dnl Check for Linux libtirpc library
+AC_DEFUN([AMU_CHECK_LIBTIRPC],[
+TIRPC_CPPFLAGS=""
+TIRPC_LIBS=""
+
+AC_CHECK_HEADER(tirpc/netconfig.h,[
+ TIRPC_CPPFLAGS="-I/usr/include/tirpc"
+ AC_DEFINE(HAVE_LIBTIRPC, 1, [Define to 1 if you have libtirpc headers installed])
+ AC_CHECK_LIB(tirpc, clnt_tli_create, [TIRPC_LIBS="-ltirpc"], [TIRPC_CPPFLAGS=""])])
+ AMU_CFLAGS="$AMU_CFLAGS $TIRPC_CPPFLAGS"
+ LIBS="$LIBS $TIRPC_LIBS"
+])