diff --git a/configure.ac b/configure.ac index 502e897..c20606f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(libsntl, 0.1) -LDFLAGS="$LDFLAGS -L/mingw/lib -L/local/lib" +#LDFLAGS="$LDFLAGS -L/mingw/lib -L/local/lib" AC_CONFIG_MACRO_DIR(['/share/aclocal/']) AC_CONFIG_HEADERS([config.h]) @@ -15,11 +15,6 @@ AC_PROG_CC LT_INIT -PKG_CHECK_MODULES(OPENSSL, [openssl]) -dnl PKG_CHECK_MODULES(LIBUUID, [uuid]) -PKG_CHECK_MODULES(LIBTDATA, [libtdata]) -PKG_CHECK_MODULES(LIBSEXPR, [libsexpr]) - dnl ***************** dnl ***** options ***** dnl ***************** @@ -33,6 +28,29 @@ AS_IF([test "x$enable_build_examples" = "xyes"], [ AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_build_examples" = "xyes") +dnl ************win32********* + +AC_ARG_ENABLE([win32], + AS_HELP_STRING([--enable-win32-build], [Enable win32 build mode])) + +AS_IF([test "x$enable_win32_build" = "xyes"], [ + AC_DEFINE([BUILD_WIN32], 1, [build for win32]), + LDFLAGS="$LDFLAGS -L/mingw/lib -L/local/lib" +], + [ + PKG_CHECK_MODULES(LIBUUID, [uuid]) + ] +) + +PKG_CHECK_MODULES(OPENSSL, [openssl]) +dnl PKG_CHECK_MODULES(LIBUUID, [uuid]) + +PKG_CHECK_MODULES(LIBTDATA, [libtdata]) +PKG_CHECK_MODULES(LIBSEXPR, [libsexpr]) + +AM_CONDITIONAL(BUILD_WIN32, test "x$enable_win32_build" = "xyes") + + AC_OUTPUT([ Makefile lib/libsntl.pc diff --git a/examples/Makefile.am b/examples/Makefile.am index 4499645..c5d9021 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -10,21 +10,34 @@ AM_CPPFLAGS = \ AM_CFLAGS = -Wall -g -#LIBS += $(ZOFFICE_LIBS) +if !BUILD_WIN32 +LIBS += $(ZOFFICE_LIBS) +endif !BUILD_WIN32 libsntl = ../lib/.libs/libsntl.la bin_PROGRAMS = sntlc -#sntld_SOURCES = sntld.c -#sntld_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ -# $(LIBUUID_LIBS) $(libsntl) -lws2_32 + +if !BUILD_WIN32 +sntld_SOURCES = sntld.c +sntld_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ + $(LIBUUID_LIBS) $(libsntl) + +sntlc_SOURCES = sntlc.c +sntlc_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ + $(LIBUUID_LIBS) $(libsntl) + +gentest_SOURCES = gentest.c +gentest_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ + $(LIBUUID_LIBS) $(libsntl) + +else BUILD_WIN32 + sntlc_SOURCES = sntlc.c sntlc_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ $(LIBUUID_LIBS) $(libsntl) -lws2_32 -#gentest_SOURCES = gentest.c -#gentest_LDADD = $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ -# $(LIBUUID_LIBS) $(libsntl) +endif BUILD_WIN32 #zsyncd_LDFLAGS = \ # -Wl,--export-dynamic diff --git a/lib/Makefile.am b/lib/Makefile.am index 90baed7..d2c68a2 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,8 +18,11 @@ libsntl_la_SOURCES = \ libsntl_la_LDFLAGS = -Wl,--export-dynamic -libsntl_la_LIBADD = -lpthread -lcrypto $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) \ - -luuid +libsntl_la_LIBADD = -lpthread -lcrypto $(LIBTDATA_LIBS) $(LIBSEXPR_LIBS) $(OPENSSL_LIBS) + +if BUILD_WIN32 +libsntl_la_LIBADD += -luuid +endif BUILD_WIN32 pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libsntl.pc diff --git a/lib/connection.c b/lib/connection.c index 5ed6ace..1e0e975 100644 --- a/lib/connection.c +++ b/lib/connection.c @@ -93,10 +93,12 @@ static int __conn_read(conn_t *co, void *buf, size_t buf_len) int ofcmode, read_blocked = 0, read_blocked_on_write = 0; /* First we make the socket nonblocking */ +#ifndef WIN32 ofcmode = fcntl(rfd, F_GETFL,0); ofcmode |= O_NDELAY; if(fcntl(rfd, F_SETFL, ofcmode)) fprintf(stderr, "Couldn't make socket nonblocking"); +#endif __retry: