Merge pull request #131 from jbkempf/win32_mingw

Support Win32 compilation with Mingw
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2016-01-16 08:51:31 -08:00
commit 66876e2879
15 changed files with 59 additions and 14 deletions

View File

@ -1,7 +1,7 @@
AC_PREREQ(2.50)
AC_INIT([libnfs], [1.9.8], [ronniesahlberg@gmail.com])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall foreign])
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIR([m4])
m4_pattern_allow([AM_PROG_AR])
@ -98,6 +98,8 @@ if test "$ac_cv_prog_gcc" = yes; then
fi
AC_SUBST(WARN_CFLAGS)
LIBSOCKET=
SYS=
case $host in
*solaris*)
@ -106,9 +108,15 @@ case $host in
AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])])
;;
*mingw32* | *cygwin* | *wince* | *mingwce*)
LIBSOCKET='-lws2_32'
SYS=mingw32
;;
*)
;;
esac
AM_CONDITIONAL(HAVE_WIN32, test "${SYS}" = "mingw32")
AC_SUBST([LIBSOCKET])
# check for poll.h
dnl Check for poll.h

View File

@ -3,10 +3,18 @@ noinst_PROGRAMS = nfsclient-async nfsclient-raw nfsclient-sync nfsclient-bcast n
AM_CPPFLAGS = \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/include/win32 \
-I$(abs_top_srcdir)/mount \
-I$(abs_top_srcdir)/nfs \
-I$(abs_top_srcdir)/portmap \
-I$(abs_top_srcdir)/rquota \
"-D_U_=__attribute__((unused))"
AM_LDFLAGS = ../lib/.libs/libnfs.la -lpopt
COMMON_LIBS = ../lib/libnfs.la -lpopt
nfsclient_async_LDADD = $(COMMON_LIBS)
nfsclient_raw_LDADD = $(COMMON_LIBS)
nfsclient_sync_LDADD = $(COMMON_LIBS)
nfsclient_bcast_LDADD = $(COMMON_LIBS)
nfsclient_listservers_LDADD = $(COMMON_LIBS)
nfs_io_LDADD = $(COMMON_LIBS)
portmap_client_LDADD = $(COMMON_LIBS)

View File

@ -8,7 +8,8 @@ dist_nfsc_HEADERS = \
../nfs/libnfs-raw-nfs.h \
../nlm/libnfs-raw-nlm.h \
../nsm/libnfs-raw-nsm.h \
../rquota/libnfs-raw-rquota.h
../rquota/libnfs-raw-rquota.h \
../win32/win32_compat.h
dist_noinst_HEADERS = \
libnfs-private.h \

View File

@ -69,10 +69,12 @@ struct statvfs {
uint32_t f_flag;
uint32_t f_namemax;
};
#if !defined(__MINGW32__)
struct utimbuf {
time_t actime;
time_t modtime;
};
#endif
#define R_OK 4
#define W_OK 2
#define X_OK 1

View File

@ -10,6 +10,7 @@ libnfs_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/nsm \
-I$(abs_top_srcdir)/portmap \
-I$(abs_top_srcdir)/rquota \
-I$(abs_top_srcdir)/win32 \
"-D_U_=__attribute__((unused))"
libnfs_la_SOURCES = \
@ -18,7 +19,8 @@ libnfs_la_SOURCES = \
libnfs-sync.c \
libnfs-zdr.c \
pdu.c \
socket.c
socket.c \
../win32/win32_compat.c
SOCURRENT=9
SOREVISION=0

View File

@ -457,7 +457,11 @@ int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh)
/*
* fstat()
*/
#ifdef WIN32
int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct __stat64 *st)
#else
int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st)
#endif
{
struct sync_cb_data cb_data;

View File

@ -7,7 +7,8 @@ mount_GENERATED = $(mount_SOURCES_GENERATED) $(mount_HEADERS_GENERATED)
CLEANFILES = $(mount_GENERATED) mount-stamp
libmount_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
libmount_la_SOURCES = \
$(mount_SOURCES_GENERATED) \
mount.c libnfs-raw-mount.c libnfs-raw-mount.h

View File

@ -7,7 +7,8 @@ nfs_GENERATED = $(nfs_SOURCES_GENERATED) $(nfs_HEADERS_GENERATED)
CLEANFILES = $(nfs_GENERATED) nfs-stamp
libnfs_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
libnfs_la_SOURCES = \
$(nfs_SOURCES_GENERATED) \
nfs.c nfsacl.c libnfs-raw-nfs.c libnfs-raw-nfs.h

View File

@ -7,7 +7,8 @@ nlm_GENERATED = $(nlm_SOURCES_GENERATED) $(nlm_HEADERS_GENERATED)
CLEANFILES = $(nlm_GENERATED) nlm-stamp
libnlm_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
libnlm_la_SOURCES = \
$(nlm_SOURCES_GENERATED) \
nlm.c libnfs-raw-nlm.c libnfs-raw-nlm.h

View File

@ -7,7 +7,8 @@ nsm_GENERATED = $(nsm_SOURCES_GENERATED) $(nsm_HEADERS_GENERATED)
CLEANFILES = $(nsm_GENERATED) nsm-stamp
libnsm_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
libnsm_la_SOURCES = \
$(nsm_SOURCES_GENERATED) \
nsm.c libnfs-raw-nsm.c libnfs-raw-nsm.h

View File

@ -7,7 +7,8 @@ portmap_GENERATED = $(portmap_SOURCES_GENERATED) $(portmap_HEADERS_GENERATED)
CLEANFILES = $(portmap_GENERATED) portmap-stamp
libportmap_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
libportmap_la_SOURCES = \
$(portmap_SOURCES_GENERATED) \
portmap.c libnfs-raw-portmap.c libnfs-raw-portmap.h

View File

@ -7,7 +7,8 @@ rquota_GENERATED = $(rquota_SOURCES_GENERATED) $(rquota_HEADERS_GENERATED)
CLEANFILES = $(rquota_GENERATED) rquota-stamp
librquota_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/win32
librquota_la_SOURCES = \
$(rquota_SOURCES_GENERATED) \
rquota.c libnfs-raw-rquota.c libnfs-raw-rquota.h

View File

@ -1,9 +1,18 @@
bin_PROGRAMS = nfs-cat nfs-cp nfs-ls
bin_PROGRAMS = nfs-cat nfs-ls
if !HAVE_WIN32
bin_PROGRAMS += nfs-cp
endif
AM_CPPFLAGS = \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/nfsc \
-I$(abs_top_srcdir)/mount \
-I$(abs_top_srcdir)/win32 \
"-D_U_=__attribute__((unused))"
AM_LDFLAGS = ../lib/.libs/libnfs.la
COMMON_LIBS = ../lib/libnfs.la $(LIBSOCKET)
nfs_cat_LDADD = $(COMMON_LIBS)
nfs_ls_LDADD = $(COMMON_LIBS)
nfs_cp_LDADD = $(COMMON_LIBS)

View File

@ -23,7 +23,7 @@ THE SOFTWARE.
#ifndef WIN32
static int dummy ATTRIBUTE((unused));
static int dummy _U_;
#else
#include "win32_compat.h"
@ -156,6 +156,7 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
#ifndef __MINGW32__
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
@ -198,3 +199,4 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
}
#endif
#endif

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#include <winsock2.h>
#include <ws2tcpip.h>
#include <Ws2ipdef.h>
#include <ws2ipdef.h>
#include <basetsd.h>
#include <io.h>
#include <sys/stat.h>
@ -108,6 +108,9 @@ struct pollfd {
int win32_inet_pton(int af, const char * src, void * dst);
int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout);
int win32_gettimeofday(struct timeval *tv, struct timezone *tz);
#ifdef __MINGW32__
# define win32_gettimeofday mingw_gettimeofday
#endif
#define DllExport