Index: trunk/Makefile
===================================================================
--- trunk/Makefile	(revision 239)
+++ trunk/Makefile	(revision 240)
@@ -3,4 +3,5 @@
 PWD = `pwd`
 PLATFORM = generic
+PLATFORM_IDENT = NOT_WINDOWS
 PREFIX = /usr/local
 MODULE = ./Module
@@ -24,5 +25,5 @@
 
 ./Server:: ./Common ./Tool/option ./Tool/genconf ./Tool/itworks
-	$(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`"
+	$(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../ $(PLATFORM_IDENT)`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`"
 
 ./Module:: ./Common
Index: trunk/Platform/bcc.mk
===================================================================
--- trunk/Platform/bcc.mk	(revision 239)
+++ trunk/Platform/bcc.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = ../bcc.sh
 AR = tlib
@@ -9,5 +10,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
 LDFLAGS =
-LIBS = -lws2_32
+LIBS =
 EXEC =
 STATIC = lib
Index: trunk/Platform/vc6.mk
===================================================================
--- trunk/Platform/vc6.mk	(revision 239)
+++ trunk/Platform/vc6.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = ../vc6.sh
 AR = lib
@@ -8,5 +9,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
 LDFLAGS =
-LIBS = -lws2_32 -ladvapi32 -llibcmt
+LIBS = -ladvapi32 -llibcmt
 EXEC =
 STATIC = lib
Index: trunk/Platform/watcom.mk
===================================================================
--- trunk/Platform/watcom.mk	(revision 239)
+++ trunk/Platform/watcom.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS_WATCOM
 CC = owcc
 AR = wlib
@@ -8,5 +9,5 @@
 CFLAGS = -b nt$(END) -I $(WATCOM)/h/nt -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
 LDFLAGS = -b nt$(END)
-LIBS = ws2_32.lib
+LIBS =
 EXEC = .exe
 STATIC = lib
Index: trunk/Platform/win32-service.mk
===================================================================
--- trunk/Platform/win32-service.mk	(revision 239)
+++ trunk/Platform/win32-service.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = i686-w64-mingw32-gcc
 AR = i686-w64-mingw32-ar
@@ -8,5 +9,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC -DSERVICE -mwindows
 LDFLAGS = -mwindows
-LIBS = -lws2_32
+LIBS = 
 EXEC = .exe
 LIBSUF = .dll
Index: trunk/Platform/win32.mk
===================================================================
--- trunk/Platform/win32.mk	(revision 239)
+++ trunk/Platform/win32.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = i686-w64-mingw32-gcc
 AR = i686-w64-mingw32-ar
@@ -8,5 +9,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC
 LDFLAGS =
-LIBS = -lws2_32
+LIBS =
 EXEC = .exe
 LIBSUF = .dll
Index: trunk/Platform/win64-service.mk
===================================================================
--- trunk/Platform/win64-service.mk	(revision 239)
+++ trunk/Platform/win64-service.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = x86_64-w64-mingw32-gcc
 AR = x86_64-w64-mingw32-ar
@@ -8,5 +9,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC -DSERVICE -mwindows
 LDFLAGS = -mwindows
-LIBS = -lws2_32
+LIBS =
 EXEC = .exe
 LIBSUF = .dll
Index: trunk/Platform/win64.mk
===================================================================
--- trunk/Platform/win64.mk	(revision 239)
+++ trunk/Platform/win64.mk	(revision 240)
@@ -3,4 +3,5 @@
 PREFIX = C:/Tewi
 
+PLATFORM_IDENT = WINDOWS
 CC = x86_64-w64-mingw32-gcc
 AR = x86_64-w64-mingw32-ar
@@ -8,5 +9,5 @@
 CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC
 LDFLAGS =
-LIBS = -lws2_32
+LIBS = 
 EXEC = .exe
 LIBSUF = .dll
Index: trunk/Server/config.c
===================================================================
--- trunk/Server/config.c	(revision 239)
+++ trunk/Server/config.c	(revision 240)
@@ -16,5 +16,9 @@
 
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
+#ifdef USE_WINSOCK1
+#include <winsock.h>
+#else
 #include <winsock2.h>
+#endif
 #endif
 
Index: trunk/Server/http.c
===================================================================
--- trunk/Server/http.c	(revision 239)
+++ trunk/Server/http.c	(revision 240)
@@ -17,5 +17,9 @@
 
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef USE_WINSOCK1
+#include <winsock.h>
+#else
 #include <winsock2.h>
+#endif
 #else
 #ifdef USE_POLL
Index: trunk/Server/server.c
===================================================================
--- trunk/Server/server.c	(revision 239)
+++ trunk/Server/server.c	(revision 240)
@@ -38,5 +38,9 @@
 #include <wspiapi.h>
 #endif
+#ifdef USE_WINSOCK1
+#include <winsock.h>
+#else
 #include <winsock2.h>
+#endif
 #include <process.h>
 #include <windows.h>
@@ -123,5 +127,9 @@
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 	WSADATA wsa;
+#ifdef USE_WINSOCK1
+	WSAStartup(MAKEWORD(1, 1), &wsa);
+#else
 	WSAStartup(MAKEWORD(2, 0), &wsa);
+#endif
 #endif
 	for(i = 0; config.ports[i] != -1; i++)
Index: trunk/Server/tw_config.h
===================================================================
--- trunk/Server/tw_config.h	(revision 239)
+++ trunk/Server/tw_config.h	(revision 240)
@@ -16,5 +16,9 @@
 
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef USE_WINSOCK1
+#include <winsock.h>
+#else
 #include <winsock2.h>
+#endif
 #define NO_IPV6
 #else
Index: trunk/Tool/option.c
===================================================================
--- trunk/Tool/option.c	(revision 239)
+++ trunk/Tool/option.c	(revision 240)
@@ -27,4 +27,17 @@
 		printf("-lssl -lcrypto");
 #endif
+		if(strcmp(argv[3], "WINDOWS") == 0){
+#ifdef USE_WINSOCK1
+			printf(" -lwsock32");
+#else
+			printf(" -lws2_32");
+#endif
+		}else if(strcmp(argv[3], "WINDOWS_WATCOM") == 0){
+#ifdef USE_WINSOCK1
+			printf(" wsock32.lib");
+#else
+			printf(" ws2_32.lib");
+#endif
+		}
 	}
 	printf("\n");
Index: trunk/bcc.sh
===================================================================
--- trunk/bcc.sh	(revision 239)
+++ trunk/bcc.sh	(revision 240)
@@ -32,5 +32,7 @@
 		options="$options -`echo "$i" | sed "s/^-//g"`"
 	elif [ "`echo "$i" | grep -Eo "^-l"`" = "-l" ]; then
-		libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib"
+		if [ ! "$i" = "-lwsock32" ]; then
+			libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib"
+		fi
 	elif [ "$dowhat" = "output" ]; then
 		dowhat=""
Index: trunk/config.h.tmpl
===================================================================
--- trunk/config.h.tmpl	(revision 239)
+++ trunk/config.h.tmpl	(revision 240)
@@ -11,4 +11,5 @@
 #define HAS_CHROOT
 #undef NO_GETADDRINFO
+#undef USE_WINSOCK1
 
 /* DO NOT EDIT BELOW THIS LINE */
@@ -21,4 +22,8 @@
 #undef USE_POLL
 /* Force select(2) for Windows */
+#endif
+#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_WINSOCK1) && !defined(NO_GETADDRINFO)
+#define NO_GETADDRINFO
+/* getaddrinfo is not on winsock 1 */
 #endif
 
