Update Win32 builds to mostly work under Cygwin.
authorMichael Poole <mdpoole@troilus.org>
Thu, 24 Apr 2008 11:29:24 +0000 (07:29 -0400)
committerMichael Poole <mdpoole@troilus.org>
Thu, 24 Apr 2008 11:29:24 +0000 (07:29 -0400)
Makefile.win32: Add -mno-cygwin to LDFLAGS so native Cygwin builds work.
configure.in: Look for stdint.h, localtime() and --with-win32.
src/compat.c: Remove "extern" modifiers on function definitions. Only
  implement localtime_r() if we have localtime() too.
src/compat.h: Include stdint.h if we have it; define LINE_MAX if needed.
  Also define NI_NUMERICHOST for the benefits of getnameinfo().
src/config.h.win32: Resynchronize with config.h.in; set WITH_IOSET_SELECT
  and WITH_PROTOCOL_P10.

Makefile.win32
configure.in
src/compat.c
src/compat.h
src/config.h.win32

index 24c2419a940250e8993eba570eb5fc7080711a00..825b92bf398ed3876d6861e6470083ae9913e20c 100644 (file)
@@ -6,6 +6,7 @@ VPATH=.
 # CC=i586-mingw32msvc-cc
 CPPFLAGS=-I$(VPATH) -Isrc
 CFLAGS=-mno-cygwin -W -Wall -O2
+LDFLAGS=-mno-cygwin
 EXE_EXT=.exe
 LIBS=-lws2_32
 
@@ -64,7 +65,7 @@ SRVX_OBJS = \
        $(addsuffix .o,$(addprefix src/mod-,$(MODULES)))
 
 srvx$(EXE_EXT): src/config.h src/modules-list.h $(RX_OBJS) $(SRVX_OBJS)
-       $(CC) -o $@ $(RX_OBJS) $(SRVX_OBJS) $(LIBS)
+       $(CC) -o $@ $(LDFLAGS) $(RX_OBJS) $(SRVX_OBJS) $(LIBS)
 src/config.h: $(VPATH)/src/config.h.win32
        cp $< $@
 src/modules-list.h:
index 30be5ea1f40f7d4282e04eb3dc01aa3cf34ff899..3bc1459eaf635d7791a0f3620aa57ffe35fc8f80 100644 (file)
@@ -69,7 +69,7 @@ AC_HEADER_TIME
 AC_STRUCT_TM
 
 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
-AC_CHECK_HEADERS(fcntl.h malloc.h netdb.h arpa/inet.h netinet/in.h sys/resource.h sys/timeb.h sys/times.h sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h unistd.h getopt.h memory.h regex.h arpa/inet.h sys/mman.h sys/stat.h dirent.h sys/epoll.h sys/event.h,,)
+AC_CHECK_HEADERS(fcntl.h malloc.h netdb.h arpa/inet.h netinet/in.h sys/resource.h sys/timeb.h sys/times.h sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h unistd.h getopt.h memory.h regex.h arpa/inet.h sys/mman.h sys/stat.h dirent.h sys/epoll.h sys/event.h stdint.h,,)
 
 dnl portability stuff, hurray! -Jedi
 AC_CHECK_MEMBER([struct sockaddr.sa_len],
@@ -83,7 +83,7 @@ AC_CHECK_MEMBER([struct addrinfo.ai_flags],
 #include <netdb.h>])
 
 dnl We have fallbacks in case these are missing, so just check for them.
-AC_CHECK_FUNCS(freeaddrinfo getaddrinfo gai_strerror getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long regcomp regexec regfree sysconf inet_aton epoll_create kqueue kevent select gettimeofday times GetProcessTimes mprotect,,)
+AC_CHECK_FUNCS(freeaddrinfo getaddrinfo gai_strerror getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime localtime_r setrlimit getopt getopt_long regcomp regexec regfree sysconf inet_aton epoll_create kqueue kevent select gettimeofday times GetProcessTimes mprotect,,)
 
 dnl Check for the fallbacks for functions missing above.
 if test $ac_cv_func_gettimeofday = no; then
@@ -266,6 +266,16 @@ if test "x$withval" = xyes ; then
   IOMUXES="$IOMUXES kevent"
 fi
 
+AC_ARG_WITH([win32],
+[  --with-win32             Enables the Win32 I/O backend],
+[],
+[withval="no"])
+if test "x$withval" = xyes ; then
+  AC_DEFINE(WITH_IOSET_WIN32, 1, [Define if using the Win32 I/O backend])
+  MODULE_OBJS="$MODULE_OBJS ioset-win32.\$(OBJEXT)"
+  IOMUXES="$IOMUXES win32"
+fi
+
 IOMUXES=`echo $IOMUXES | sed 's/^ +//'`
 if test "x$IOMUXES" = "x" ; then
   AC_MSG_ERROR([No supported I/O multiplexing backend found])
index 2035b858bde78a74fafb3e4acac0988f33789cc3..65ffada5f963e1a2fd99feb4f530cdee838090fe 100644 (file)
@@ -16,7 +16,7 @@
 #endif
 
 #if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME)
-extern int gettimeofday(struct timeval * tv, struct timezone * tz)
+int gettimeofday(struct timeval * tv, struct timezone * tz)
 {
     if (!tv)
     {
@@ -35,8 +35,8 @@ extern int gettimeofday(struct timeval * tv, struct timezone * tz)
 }
 #endif
 
-#ifndef HAVE_GETLOCALTIME_R
-extern struct tm *localtime_r(const time_t *timep, struct tm *result)
+#if !defined(HAVE_GETLOCALTIME_R) && defined(HAVE_LOCALTIME)
+struct tm *localtime_r(const time_t *timep, struct tm *result)
 {
     memcpy(result, localtime(timep), sizeof(*result));
     return result;
@@ -44,7 +44,7 @@ extern struct tm *localtime_r(const time_t *timep, struct tm *result)
 #endif
 
 #ifndef HAVE_MEMCPY
-extern void * memcpy(void * dest, void const * src, unsigned long n)
+void * memcpy(void * dest, void const * src, unsigned long n)
 {
 /* very slow, your fault for not having memcpy()*/
     unsigned char * td=dest;
@@ -62,7 +62,7 @@ extern void * memcpy(void * dest, void const * src, unsigned long n)
 
 #ifndef HAVE_MEMSET
 /* very slow, deal with it */
-extern void * memset(void * dest, int c, unsigned long n)
+void * memset(void * dest, int c, unsigned long n)
 {
     unsigned char * temp=dest;
     unsigned long   i;
@@ -77,7 +77,7 @@ extern void * memset(void * dest, int c, unsigned long n)
 #endif
 
 #ifndef HAVE_STRDUP
-extern char * strdup(char const * str)
+char * strdup(char const * str)
 {
     char * out;
 
@@ -91,7 +91,7 @@ extern char * strdup(char const * str)
 #endif
 
 #ifndef HAVE_STRERROR
-extern char const * strerror(int errornum)
+char const * strerror(int errornum)
 {
     if (errornum==0)
         return "No error";
@@ -407,8 +407,6 @@ int getaddrinfo(const char *node, const char *service, const struct addrinfo *hi
     return 0;
 }
 
-/* TODO: implement fallback getnameinfo() */
-
 void freeaddrinfo(struct addrinfo *res)
 {
     struct addrinfo *next;
@@ -417,7 +415,6 @@ void freeaddrinfo(struct addrinfo *res)
         free(res);
     }
 }
-
 #endif
 
 #ifndef HAVE_GAI_STRERROR
@@ -464,3 +461,12 @@ const char *gai_strerror(int errcode)
     return "Unknown GAI_* error";
 }
 #endif
+
+#ifndef HAVE_GETNAMEINFO
+int getnameinfo(const struct sockaddr *sa, socklen_t salen,
+                char *host, size_t hostlen,
+                char *serv, size_t servlen, int flags)
+{
+    /* TODO: implement fallback getnameinfo() */
+}
+#endif
index 40b17ba9c9f711285f71123696875c5248ec8786..66a1fd88fe4532d7563e3dad9390fe1661478098 100644 (file)
@@ -57,6 +57,10 @@ char *alloca();
 #include <sys/socket.h>
 #endif
 
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
@@ -75,6 +79,11 @@ char *alloca();
 #include <unistd.h>
 #endif
 
+/* Cygwin (for example) doesn't define LINE_MAX, although mingw does. */
+#if !defined(LINE_MAX)
+# define LINE_MAX 2048
+#endif
+
 #ifdef HAVE_VA_COPY
 #define VA_COPY(DEST, SRC) va_copy(DEST, SRC)
 #elif HAVE___VA_COPY
@@ -130,17 +139,19 @@ struct addrinfo {
 #endif /* !defined(HAVE_STRUCT_ADDRINFO) */
 
 #ifndef HAVE_GETADDRINFO
-
 int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
-int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
 void freeaddrinfo(struct addrinfo *res);
-
 #endif
 
 #ifndef HAVE_GAI_STRERROR
 const char *gai_strerror(int errcode);
 #endif
 
+#ifndef HAVE_GETNAMEINFO
+#define NI_NUMERICHOST 1
+int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
+#endif
+
 #ifndef EINPROGRESS
 # ifdef WSAEINPROGRESS
 #  define EINPROGRESS WSAEINPROGRESS
index eabe16fbbab9fe651f645b95a1c9ad40488682ab..bb08ba2c0cc6d936de84e3d0784303eaa6affe18 100644 (file)
@@ -55,6 +55,9 @@
 /* Define to 1 if you have the `ftime' function. */
 #define HAVE_FTIME 1
 
+/* Define to 1 if you have the `gai_strerror' function. */
+#define HAVE_GAI_STRERROR 1
+
 /* Define to 1 if you have the <gc/gc.h> header file. */
 #undef HAVE_GC_GC_H
 
@@ -64,9 +67,6 @@
 /* Define to 1 if you have the `getnameinfo' function. */
 #define HAVE_GETNAMEINFO 1
 
-/* Define to 1 if you have the `getnameinfo' function. */
-#define HAVE_GAI_STRERROR 1
-
 /* Define to 1 if you have the `getopt' function. */
 #undef HAVE_GETOPT
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
 
+/* Define to 1 if you have the `kevent' function. */
+#undef HAVE_KEVENT
+
+/* Define to 1 if you have the `kqueue' function. */
+#undef HAVE_KQUEUE
+
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL
 
 /* Define to 1 if you have the <mpatrol.h> header file. */
 #undef HAVE_MPATROL_H
 
+/* Define to 1 if you have the `mprotect' function. */
+#undef HAVE_MPROTECT
+
 /* Define to 1 if you have the <netdb.h> header file. */
 #undef HAVE_NETDB_H
 
 #undef HAVE_REGFREE
 
 /* Define to 1 if you have the `select' function. */
-#undef HAVE_SELECT
+#define HAVE_SELECT 1
 
 /* Define to 1 if you have the `setrlimit' function. */
 #undef HAVE_SETRLIMIT
 /* Define to 1 if you have the <sys/epoll.h> header file. */
 #undef HAVE_SYS_EPOLL_H
 
+/* Define to 1 if you have the <sys/event.h> header file. */
+#undef HAVE_SYS_EVENT_H
+
 /* Define to 1 if you have the <sys/mman.h> header file. */
 #undef HAVE_SYS_MMAN_H
 
 /* Version number of package */
 #define VERSION 1.4
 
-/* Define if using the Win32 I/O backend */
-#define WITH_IOSET_WIN32 1
-
 /* Define if using the epoll I/O backend */
 #undef WITH_IOSET_EPOLL
 
+/* Define if using the kevent I/O backend */
+#undef WITH_IOSET_KEVENT
+
 /* Define if using the select() I/O backend */
-#undef WITH_IOSET_SELECT
+#define WITH_IOSET_SELECT 1
+
+/* Define if using the Win32 I/O backend */
+#define WITH_IOSET_WIN32 1
 
 /* Define if using the Boehm GC to garbage collect and check memory leaks */
 #undef WITH_MALLOC_BOEHM_GC
 /* Define if using the system's malloc */
 #undef WITH_MALLOC_SYSTEM
 
+/* Define if using the Bahamut dialect of IRC */
+#undef WITH_PROTOCOL_BAHAMUT
+
+/* Define if using the P10 dialect of IRC */
+#define WITH_PROTOCOL_P10 1
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const