From 89f0563609ac5f30e515a8b93aa2ccc5e98abadb Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 18 Nov 2015 09:54:42 +0000
Subject: [PATCH 10/14] Add support for building with system libtirpc

This is needed for buliding with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 open-vm-tools/configure.ac                               | 14 ++++++++++++++
 open-vm-tools/lib/dynxdr/Makefile.am                     |  8 +++++++-
 open-vm-tools/lib/guestRpc/Makefile.am                   |  6 ++++++
 open-vm-tools/lib/netUtil/Makefile.am                    |  4 ++++
 open-vm-tools/lib/nicInfo/Makefile.am                    |  2 ++
 open-vm-tools/lib/rpcChannel/Makefile.am                 |  4 ++++
 open-vm-tools/lib/slashProc/Makefile.am                  |  4 ++++
 open-vm-tools/libguestlib/Makefile.am                    |  2 ++
 open-vm-tools/rpctool/Makefile.am                        |  3 +++
 open-vm-tools/rpctool/rpctool.c                          |  2 ++
 open-vm-tools/services/plugins/dndcp/Makefile.am         |  2 ++
 open-vm-tools/services/plugins/guestInfo/Makefile.am     |  1 +
 open-vm-tools/services/plugins/resolutionSet/Makefile.am |  2 ++
 open-vm-tools/services/plugins/vix/Makefile.am           |  2 ++
 open-vm-tools/services/plugins/vmbackup/Makefile.am      |  2 ++
 open-vm-tools/toolbox/Makefile.am                        |  2 ++
 16 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac
index b9f89115..a6312aa4 100644
--- a/open-vm-tools/configure.ac
+++ b/open-vm-tools/configure.ac
@@ -405,6 +405,20 @@ AC_VMW_CHECK_LIB([fuse],
                   AC_MSG_WARN([Fuse is missing, vmblock-fuse/vmhgfs-fuse will be disabled.])])
 
 #
+# Check for libtirpc
+#
+AC_VMW_CHECK_LIB([libtirpc],
+                 [LIBTIRPC],
+                 [libtirpc],
+                 [],
+                 [],
+                 [rpc/xdr.h],
+                 [xdr_void],
+                 [have_libtirpc=yes],
+                 [have_libtitirpc=no;
+                  AC_MSG_WARN([libtirpc is missing.])])
+
+#
 # Check for PAM.
 #
 AC_ARG_WITH([pam],
diff --git a/open-vm-tools/lib/dynxdr/Makefile.am b/open-vm-tools/lib/dynxdr/Makefile.am
index 841c17db..5212f693 100644
--- a/open-vm-tools/lib/dynxdr/Makefile.am
+++ b/open-vm-tools/lib/dynxdr/Makefile.am
@@ -17,7 +17,13 @@
 
 noinst_LTLIBRARIES = libDynxdr.la
 
-libDynxdr_la_SOURCES = 
+libDynxdr_la_SOURCES =
 libDynxdr_la_SOURCES += dynxdr.c
 libDynxdr_la_SOURCES += xdrutil.c
 
+libDynxdr_la_CPPFLAGS =
+libDynxdr_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
+
+libDynxdr_la_LIBADD =
+libDynxdr_la_LIBADD += @LIBTIRPC_LIBS@
+
diff --git a/open-vm-tools/lib/guestRpc/Makefile.am b/open-vm-tools/lib/guestRpc/Makefile.am
index 1605a27c..e37ecc7a 100644
--- a/open-vm-tools/lib/guestRpc/Makefile.am
+++ b/open-vm-tools/lib/guestRpc/Makefile.am
@@ -20,6 +20,12 @@ noinst_LTLIBRARIES = libGuestRpc.la
 libGuestRpc_la_SOURCES =
 libGuestRpc_la_SOURCES += nicinfo_xdr.c
 
+libGuestRpc_la_CPPFLAGS =
+libGuestRpc_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
+
+libGuestRpc_la_LIBADD =
+libGuestRpc_la_LIBADD += @LIBTIRPC_LIBS@
+
 # XXX: Autoreconf complains about this and recommends using AM_CFLAGS instead.
 # Problem is, $(CFLAGS) is appended to the compiler command line after AM_CFLAGS
 # and after libGuestRpc_la_CFLAGS, so "-Wall -Werror" will override this flag.
diff --git a/open-vm-tools/lib/netUtil/Makefile.am b/open-vm-tools/lib/netUtil/Makefile.am
index eddc4ae0..fccc824f 100644
--- a/open-vm-tools/lib/netUtil/Makefile.am
+++ b/open-vm-tools/lib/netUtil/Makefile.am
@@ -20,3 +20,7 @@ noinst_LTLIBRARIES = libNetUtil.la
 libNetUtil_la_SOURCES =
 libNetUtil_la_SOURCES += netUtilLinux.c
 
+libNetUtil_la_CPPFLAGS =
+libNetUtil_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
+
+libNetUtil_la_LIBADD = @LIBTIRPC_LIBS@
diff --git a/open-vm-tools/lib/nicInfo/Makefile.am b/open-vm-tools/lib/nicInfo/Makefile.am
index de09172b..ddc44dda 100644
--- a/open-vm-tools/lib/nicInfo/Makefile.am
+++ b/open-vm-tools/lib/nicInfo/Makefile.am
@@ -25,12 +25,14 @@ libNicInfo_la_SOURCES += nicInfoPosix.c
 
 libNicInfo_la_CPPFLAGS =
 libNicInfo_la_CPPFLAGS += @GLIB2_CPPFLAGS@
+libNicInfo_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 
 AM_CFLAGS = $(DNET_CPPFLAGS)
 if USE_SLASH_PROC
 AM_CFLAGS += -DUSE_SLASH_PROC
 endif
 libNicInfo_la_LIBADD =
+libNicInfo_la_LIBADD += @LIBTIRPC_LIBS@
 if HAVE_DNET
    libNicInfo_la_LIBADD += @DNET_LIBS@
 endif
diff --git a/open-vm-tools/lib/rpcChannel/Makefile.am b/open-vm-tools/lib/rpcChannel/Makefile.am
index 4577b655..457f1938 100644
--- a/open-vm-tools/lib/rpcChannel/Makefile.am
+++ b/open-vm-tools/lib/rpcChannel/Makefile.am
@@ -27,3 +27,7 @@ endif
 
 libRpcChannel_la_CPPFLAGS =
 libRpcChannel_la_CPPFLAGS += @VMTOOLS_CPPFLAGS@
+libRpcChannel_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
+
+libRpcChannel_la_LIBADD =
+libRpcChannel_la_LIBADD += @LIBTIRPC_LIBS@
diff --git a/open-vm-tools/lib/slashProc/Makefile.am b/open-vm-tools/lib/slashProc/Makefile.am
index b3afe9e5..8220f5f8 100644
--- a/open-vm-tools/lib/slashProc/Makefile.am
+++ b/open-vm-tools/lib/slashProc/Makefile.am
@@ -22,6 +22,10 @@ libSlashProc_la_SOURCES += net.c
 
 libSlashProc_la_CPPFLAGS =
 libSlashProc_la_CPPFLAGS += @GLIB2_CPPFLAGS@
+libSlashProc_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
+
+libSlashProc_la_LIBADD =
+libSlashProc_la_LIBADD += @LIBTIRPC_LIBS@
 
 AM_CFLAGS = $(DNET_CPPFLAGS)
 
diff --git a/open-vm-tools/libguestlib/Makefile.am b/open-vm-tools/libguestlib/Makefile.am
index b49af696..393f5c13 100644
--- a/open-vm-tools/libguestlib/Makefile.am
+++ b/open-vm-tools/libguestlib/Makefile.am
@@ -22,6 +22,7 @@ AM_CFLAGS += -I$(top_srcdir)/include
 
 libguestlib_la_LIBADD =
 libguestlib_la_LIBADD += @VMTOOLS_LIBS@
+libguestlib_la_LIBADD += @LIBTIRPC_LIBS@
 
 libguestlib_la_SOURCES =
 libguestlib_la_SOURCES += guestlibV3_xdr.c
@@ -56,6 +57,7 @@ CFLAGS += -Wno-unused
 libguestlib_la_CPPFLAGS =
 libguestlib_la_CPPFLAGS += -DVMTOOLS_USE_GLIB
 libguestlib_la_CPPFLAGS += @GLIB2_CPPFLAGS@
+libguestlib_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 
 EXTRA_DIST = vmguestlib.pc.in
 
diff --git a/open-vm-tools/rpctool/Makefile.am b/open-vm-tools/rpctool/Makefile.am
index cb05cf8a..03d65285 100644
--- a/open-vm-tools/rpctool/Makefile.am
+++ b/open-vm-tools/rpctool/Makefile.am
@@ -17,10 +17,13 @@
 
 bin_PROGRAMS = vmware-rpctool
 
+vmware_rpctool_CFLAGS= @LIBTIRPC_LIBS@
+
 vmware_rpctool_SOURCES =
 vmware_rpctool_SOURCES += rpctool.c
 
 vmware_rpctool_LDADD =
+vmware_rpctool_LDADD += @LIBTIRPC_LIBS@
 vmware_rpctool_LDADD += ../lib/rpcOut/libRpcOut.la
 vmware_rpctool_LDADD += ../lib/message/libMessage.la
 vmware_rpctool_LDADD += ../lib/backdoor/libBackdoor.la
diff --git a/open-vm-tools/rpctool/rpctool.c b/open-vm-tools/rpctool/rpctool.c
index f1528948..448d3328 100644
--- a/open-vm-tools/rpctool/rpctool.c
+++ b/open-vm-tools/rpctool/rpctool.c
@@ -23,6 +23,8 @@
  */
 
 #ifndef _WIN32
+#define _GNU_SOURCE
+#include <signal.h>
 #include "sigPosixRegs.h"
 #include <errno.h>
 #include <stdint.h>
diff --git a/open-vm-tools/services/plugins/dndcp/Makefile.am b/open-vm-tools/services/plugins/dndcp/Makefile.am
index d1543054..21209c8c 100644
--- a/open-vm-tools/services/plugins/dndcp/Makefile.am
+++ b/open-vm-tools/services/plugins/dndcp/Makefile.am
@@ -23,6 +23,7 @@ plugin_LTLIBRARIES = libdndcp.la
 libdndcp_la_CPPFLAGS =
 libdndcp_la_CPPFLAGS += @GTK_CPPFLAGS@
 libdndcp_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
+libdndcp_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/dnd
 libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/dndGuest
 libdndcp_la_CPPFLAGS += -I$(top_srcdir)/services/plugins/dndcp/stringxx
@@ -44,6 +45,7 @@ libdndcp_la_LIBADD += @GTK_LIBS@
 libdndcp_la_LIBADD += @GTKMM_LIBS@
 libdndcp_la_LIBADD += @VMTOOLS_LIBS@
 libdndcp_la_LIBADD += @HGFS_LIBS@
+libdndcp_la_LIBADD += @LIBTIRPC_LIBS@
 libdndcp_la_LIBADD += $(top_builddir)/lib/hgfsUri/hgfsUriPosix.lo
 
 libdndcp_la_SOURCES =
diff --git a/open-vm-tools/services/plugins/guestInfo/Makefile.am b/open-vm-tools/services/plugins/guestInfo/Makefile.am
index 4400e5a1..419bab08 100644
--- a/open-vm-tools/services/plugins/guestInfo/Makefile.am
+++ b/open-vm-tools/services/plugins/guestInfo/Makefile.am
@@ -22,6 +22,7 @@ plugin_LTLIBRARIES = libguestInfo.la
 
 libguestInfo_la_CPPFLAGS =
 libguestInfo_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
+libguestInfo_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 
 libguestInfo_la_LDFLAGS =
 libguestInfo_la_LDFLAGS += @PLUGIN_LDFLAGS@
diff --git a/open-vm-tools/services/plugins/resolutionSet/Makefile.am b/open-vm-tools/services/plugins/resolutionSet/Makefile.am
index 3d8dbc4f..1d057c63 100644
--- a/open-vm-tools/services/plugins/resolutionSet/Makefile.am
+++ b/open-vm-tools/services/plugins/resolutionSet/Makefile.am
@@ -21,6 +21,7 @@ plugin_LTLIBRARIES = libresolutionSet.la
 libresolutionSet_la_CPPFLAGS =
 libresolutionSet_la_CPPFLAGS += @GTK_CPPFLAGS@
 libresolutionSet_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
+libresolutionSet_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 libresolutionSet_la_CPPFLAGS += -DRESOLUTION_X11
 
 libresolutionSet_la_LDFLAGS =
@@ -30,6 +31,7 @@ libresolutionSet_la_LIBADD =
 libresolutionSet_la_LIBADD += @COMMON_XLIBS@
 libresolutionSet_la_LIBADD += @GTK_LIBS@
 libresolutionSet_la_LIBADD += @VMTOOLS_LIBS@
+libresolutionSet_la_LIBADD += @LIBTIRPC_LIBS@
 
 libresolutionSet_la_SOURCES =
 libresolutionSet_la_SOURCES += libvmwarectrl.c
diff --git a/open-vm-tools/services/plugins/vix/Makefile.am b/open-vm-tools/services/plugins/vix/Makefile.am
index f7d541e5..af4e0a55 100644
--- a/open-vm-tools/services/plugins/vix/Makefile.am
+++ b/open-vm-tools/services/plugins/vix/Makefile.am
@@ -20,6 +20,7 @@ plugin_LTLIBRARIES = libvix.la
 
 libvix_la_CPPFLAGS =
 libvix_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
+libvix_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 libvix_la_CPPFLAGS += -I$(top_srcdir)/vgauth/public
 
 libvix_la_LDFLAGS =
@@ -29,6 +30,7 @@ libvix_la_LIBADD =
 libvix_la_LIBADD += @VIX_LIBADD@
 libvix_la_LIBADD += @VMTOOLS_LIBS@
 libvix_la_LIBADD += @HGFS_LIBS@
+libvix_la_LIBADD += @LIBTIRPC_LIBS@
 libvix_la_LIBADD += $(top_builddir)/lib/auth/libAuth.la
 libvix_la_LIBADD += $(top_builddir)/lib/foundryMsg/libFoundryMsg.la
 libvix_la_LIBADD += $(top_builddir)/lib/impersonate/libImpersonate.la
diff --git a/open-vm-tools/services/plugins/vmbackup/Makefile.am b/open-vm-tools/services/plugins/vmbackup/Makefile.am
index 81fc5c7f..00224f65 100644
--- a/open-vm-tools/services/plugins/vmbackup/Makefile.am
+++ b/open-vm-tools/services/plugins/vmbackup/Makefile.am
@@ -20,6 +20,7 @@ plugin_LTLIBRARIES = libvmbackup.la
 
 libvmbackup_la_CPPFLAGS =
 libvmbackup_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
+libvmbackup_la_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 
 libvmbackup_la_LDFLAGS =
 libvmbackup_la_LDFLAGS += @PLUGIN_LDFLAGS@
@@ -27,6 +28,7 @@ libvmbackup_la_LDFLAGS += @PLUGIN_LDFLAGS@
 libvmbackup_la_LIBADD =
 libvmbackup_la_LIBADD += @GOBJECT_LIBS@
 libvmbackup_la_LIBADD += @VMTOOLS_LIBS@
+libvmbackup_la_LIBADD += @LIBTIRPC_LIBS@
 
 libvmbackup_la_SOURCES =
 libvmbackup_la_SOURCES += nullProvider.c
diff --git a/open-vm-tools/toolbox/Makefile.am b/open-vm-tools/toolbox/Makefile.am
index 66d36ac6..2becd3c7 100644
--- a/open-vm-tools/toolbox/Makefile.am
+++ b/open-vm-tools/toolbox/Makefile.am
@@ -20,9 +20,11 @@ bin_PROGRAMS = vmware-toolbox-cmd
 vmware_toolbox_cmd_LDADD =
 vmware_toolbox_cmd_LDADD += ../libguestlib/libguestlib.la
 vmware_toolbox_cmd_LDADD += @VMTOOLS_LIBS@
+vmware_toolbox_cmd_LDADD += @LIBTIRPC_LIBS@
 
 vmware_toolbox_cmd_CPPFLAGS =
 vmware_toolbox_cmd_CPPFLAGS += @VMTOOLS_CPPFLAGS@
+vmware_toolbox_cmd_CPPFLAGS += @LIBTIRPC_CPPFLAGS@
 
 vmware_toolbox_cmd_SOURCES =
 vmware_toolbox_cmd_SOURCES += toolbox-cmd.c
-- 
2.11.0

