diff -ur linc-0.5.3.orig/configure.in linc-0.5.3/configure.in
--- linc-0.5.3.orig/configure.in	2002-08-24 01:44:58.000000000 +0900
+++ linc-0.5.3/configure.in	2002-09-11 18:22:30.000000000 +0900
@@ -38,7 +38,13 @@
 dnl Initialize automake stuff
 AM_INIT_AUTOMAKE(linc, $LINC_VERSION, no-define)
 
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
+
 AM_MAINTAINER_MODE
 
 dnl Cache $ACLOCAL_FLAGS
@@ -47,9 +53,29 @@
 ])
 ACLOCAL="$ACLOCAL $ac_cv_linc_aclocal_flags"
 
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
+AC_MSG_CHECKING([if building for some Win32 platform])
+case "$host" in
+  *-*-mingw*|*-*-cygwin*)
+    platform_win32=yes
+    ;;
+  *)
+    platform_win32=no
+    ;;
+esac
+AC_MSG_RESULT($platform_win32)
+AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
+
+AC_MSG_CHECKING([for cygwin])
+case "$host" in
+  *-*-cygwin*)
+    linc_with_cygwin=yes
+    ;;
+  *)
+    linc_with_cygwin=no
+    ;;
+esac
+AC_MSG_RESULT([$linc_with_cygwin])
+AM_CONDITIONAL(WITH_CYGWIN, test "$linc_with_cygwin" = "yes")
 
 GLIB_REQUIRED=1.3.11
 AC_SUBST(GLIB_REQUIRED)
@@ -101,6 +127,7 @@
 AC_CHECK_HEADERS(fcntl.h unistd.h sys/endian.h endian.h machine/endian.h sys/machine.h sys/isa_defs.h sys/poll.h)
 AC_CHECK_HEADERS(stddef.h wchar.h wcstr.h wctype.h machine/types.h)
 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h sys/un.h linux/irda.h)
+AC_CHECK_HEADERS(arpa/nameser.h resolv.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff -ur linc-0.5.3.orig/src/Makefile.am linc-0.5.3/src/Makefile.am
--- linc-0.5.3.orig/src/Makefile.am	2002-05-22 01:19:26.000000000 +0900
+++ linc-0.5.3/src/Makefile.am	2002-09-11 18:37:34.000000000 +0900
@@ -11,6 +11,10 @@
 	-DG_DISABLE_DEPRECATED	   \
 	-D_GNU_SOURCE
 
+if PLATFORM_WIN32
+no_undefined = -no-undefined
+endif
+
 liblinc_la_SOURCES =		\
 	linc.c			\
 	linc-connection.c	\
@@ -24,7 +28,11 @@
 liblinc_la_LDFLAGS =                 \
 	$(LINC_LIBS)                 \
 	$(SSL_LIBS)                  \
-	-version-info $(LT_VERSION)
+	-version-info $(LT_VERSION) $(no_undefined)
+
+if WITH_CYGWIN
+liblinc_la_LIBADD = -lextras
+endif
 
 linc_cleanup_sockets_SOURCES = \
 	cleanup.c
diff -ur linc-0.5.3.orig/src/linc-compat.h linc-0.5.3/src/linc-compat.h
--- linc-0.5.3.orig/src/linc-compat.h	2002-07-31 19:41:06.000000000 +0900
+++ linc-0.5.3/src/linc-compat.h	2002-09-07 12:59:40.000000000 +0900
@@ -36,8 +36,12 @@
 #endif
 
 #include <arpa/inet.h>
+#ifdef HAVE_ARPA_NAMESER_H
 #include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
 #include <resolv.h>
+#endif
 
 #if !defined (NI_MAXSERV) || !defined (NI_MAXHOST)
 #  include <netdb.h>
diff -ur linc-0.5.3.orig/src/linc-protocols.c linc-0.5.3/src/linc-protocols.c
--- linc-0.5.3.orig/src/linc-protocols.c	2002-07-31 19:45:22.000000000 +0900
+++ linc-0.5.3/src/linc-protocols.c	2002-09-11 22:54:28.000000000 +0900
@@ -14,6 +14,9 @@
 #include <dirent.h>
 #include <linc/linc-protocol.h>
 #include <linc/linc-connection.h>
+#ifdef __CYGWIN__
+#include <cygextras.h>
+#endif
 
 #include "linc-private.h"
 #include "linc-debug.h"
@@ -46,6 +49,9 @@
 		case EEXIST:
 			if (stat (dirname, &statbuf) != 0)
 				g_error ("Can not stat %s\n", dirname);
+#ifdef __CYGWIN__
+			if (check_ntsec (dirname)) {
+#endif
 
 			if (statbuf.st_uid != getuid ())
 				g_error ("Owner of %s is not the current user\n", dirname);
@@ -54,6 +60,9 @@
 			    !S_ISDIR (statbuf.st_mode))
 				g_error ("Wrong permissions for %s\n", dirname);
 
+#ifdef __CYGWIN__
+			}
+#endif
 			break;
 				
 		default:
@@ -111,7 +120,7 @@
 #define LINC_SET_SOCKADDR_LEN(saddr, len)
 #endif
 
-#if defined(AF_INET6) && defined(RES_USE_INET6)
+#if defined(HAVE_RESOLV_H) && defined(AF_INET6) && defined(RES_USE_INET6)
 #define LINC_RESOLV_SET_IPV6     _res.options |= RES_USE_INET6
 #else
 #define LINC_RESOLV_SET_IPV6
@@ -286,8 +295,10 @@
 	if ((saddr->sin_addr.s_addr = inet_addr (hostname)) == INADDR_NONE) {
 
 		LINC_RESOLV_SET_IPV6;
+#ifdef HAVE_RESOLV_H
 		if (!(_res.options & RES_INIT))
 			res_init();
+#endif
 		
 		host = gethostbyname (hostname);
 		if (!host ||
@@ -347,8 +358,10 @@
 		return (struct sockaddr *)saddr;
 #endif
 
+#ifdef HAVE_RESOLV_H
 	if (!(_res.options & RES_INIT))
 		res_init();
+#endif
 
 	LINC_RESOLV_SET_IPV6;
 	host = gethostbyname (hostname);
@@ -412,9 +425,9 @@
 	} else 
 		actual_path = (char *)path;
 
-	pathlen = strlen (actual_path);
+	pathlen = strlen (actual_path) + 1;
 
-	if (pathlen >= sizeof (saddr->sun_path))
+	if (pathlen > sizeof (saddr->sun_path))
 		return NULL;
 
 	saddr = g_new0 (struct sockaddr_un, 1);
diff -ur linc-0.5.3.orig/test/test-linc.c linc-0.5.3/test/test-linc.c
--- linc-0.5.3.orig/test/test-linc.c	2002-07-31 19:56:54.000000000 +0900
+++ linc-0.5.3/test/test-linc.c	2002-09-12 00:07:08.000000000 +0900
@@ -39,7 +39,7 @@
 init_tmp (void)
 {
 	char *dir;
-	const char *user = g_getenv ("USER");
+	const char *user = g_get_user_name ();
 
 	dir = g_strconcat ("/tmp/orbit-", user, NULL);
 
