gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12672 - in libmicrohttpd: . src/daemon


From: gnunet
Subject: [GNUnet-SVN] r12672 - in libmicrohttpd: . src/daemon
Date: Thu, 19 Aug 2010 13:27:17 +0200

Author: grothoff
Date: 2010-08-19 13:27:17 +0200 (Thu, 19 Aug 2010)
New Revision: 12672

Modified:
   libmicrohttpd/AUTHORS
   libmicrohttpd/ChangeLog
   libmicrohttpd/acinclude.m4
   libmicrohttpd/configure.ac
   libmicrohttpd/src/daemon/daemon.c
Log:
[libmicrohttpd] Patches for Windows version of libmicrohttpd
From: 
Gerrit Telkamp <address@hidden>
  To: 
address@hidden
  Date: 
Today 11:42:30
  Attachments: 
 libmicrohttpd-windows.patch
   
  It was a bit tricky to build libmicrohttpd (SVN trunk) for Windows. 
I'm using the newest MSYS/MinGW environment (GCC 4.5.1).
I've optimized the autoconf feature, so this should be easier in future. 
Please find enclosed my patches.

In detail:
1- libmicrohttpd needs the "PlibC" library under Windows (libplibc.a). 
Methods of PlibC are referenced by src/daemon/daemon.c.
autoconf assumes that PlibC is installed on the Build environment and 
does not check this.
If PlibC is not installed, the pthreads check (see "acinclude.m4") will 
fail and stops with the wrong error message "Your system is not 
supporting pthreads". This is very confusing.

The patch includes an additional check for PlibC, before pthreads is 
used. The check is only done under cygwin and mingw environments.

Furthermore, an older version of plibc.h was in the include directory. 
This gives some problems if you are using a newer version of the PlibC 
library. So I propose to exclude src/include/plibc.h from the SVN

Files affected:
acinclude.m4 (modified)
configure.ac (modified)
src/include/plibc.h (deleted)

2- setsockopt() uses a different parameter type under Windows ("optval" 
is const char). This caused an error when src/daemon/daemon.c was compiled.

The patch enclosed includes a different call of the setsockopt() on 
Windows machines.
Important: IPV6_V6ONLY is not available on Windows machines < Windows 7! 
So this parameter is "0". But there is a TODO comment, maybe someone has 
an idea how to solve this on Windows XP machines.

Files affected:
src/daemon/daemon.c (modified)

I have tested the patch on a MinGW / MSYS environment only.

Best regards

Gerrit.

libmicrohttpd-windows.patch


Modified: libmicrohttpd/AUTHORS
===================================================================
--- libmicrohttpd/AUTHORS       2010-08-19 10:18:04 UTC (rev 12671)
+++ libmicrohttpd/AUTHORS       2010-08-19 11:27:17 UTC (rev 12672)
@@ -24,6 +24,7 @@
 John Muth <address@hidden>
 Geoffrey McRae <address@hidden>
 Piotr Grzybowski <address@hidden>
+Gerrit Telkamp <address@hidden>
 
 Documentation contributions also came from:
 Marco Maggi <address@hidden>

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2010-08-19 10:18:04 UTC (rev 12671)
+++ libmicrohttpd/ChangeLog     2010-08-19 11:27:17 UTC (rev 12672)
@@ -1,3 +1,6 @@
+Thu Aug 19 13:26:00 CEST 2010
+       Patches for Windows to ease compilation trouble. -GT/CG
+
 Sat Aug 14 15:43:30 CEST 2010
        Fixed small, largely hypothetical leaks. 
        Reduced calls to strlen for header processing. -CG

Modified: libmicrohttpd/acinclude.m4
===================================================================
--- libmicrohttpd/acinclude.m4  2010-08-19 10:18:04 UTC (rev 12671)
+++ libmicrohttpd/acinclude.m4  2010-08-19 11:27:17 UTC (rev 12672)
@@ -1,75 +1,118 @@
+AC_DEFUN([CHECK_PLIBC],
+[
+    # On windows machines, check if PlibC is available. First try without 
-plibc
+    AC_TRY_LINK(
+    [
+        #include <plibc.h>
+    ],[
+        plibc_init("", "");
+    ],[
+        AC_MSG_RESULT(yes)
+        PLIBC_CPPFLAGS=
+        PLIBC_LDFLAGS=
+        PLIBC_LIBS=
+    ],[
+
+        # now with -plibc
+        AC_CHECK_LIB(plibc,plibc_init,
+        [
+            PLIBC_CPPFLAGS=
+            PLIBC_LDFLAGS=
+            PLIBC_LIBS=-lplibc
+        ],[
+            AC_MSG_CHECKING(if PlibC is installed)
+            save_CPPFLAGS="$CPPFLAGS"
+            CPPFLAGS="$CPPFLAGS -plibc"
+            AC_TRY_LINK(
+            [
+                #include <plibc.h>
+            ],[
+                plibc_init("", "");
+            ],[
+                AC_MSG_RESULT(yes)
+                PLIBC_CPPFLAGS=-plibc
+                PLIBC_LDFLAGS=-plibc
+                PLIBC_LIBS=
+            ],[
+                AC_MSG_ERROR([PlibC is not available on your windows machine!])
+            ])
+        ])
+    ])
+    CPPFLAGS="$save_CPPFLAGS"
+])
+
 # See: http://gcc.gnu.org/ml/gcc/2000-05/msg01141.html
 AC_DEFUN([CHECK_PTHREAD],
 [
-        # first try without -pthread
-        AC_TRY_LINK(
-               [
-                       #include <pthread.h>
-               ],[
-                       pthread_create(0,0,0,0);
-               ],[
-                       AC_MSG_RESULT(yes)
-                       PTHREAD_CPPFLAGS=
-                       PTHREAD_LDFLAGS=
-                       PTHREAD_LIBS=
-               ],[
-        # now with -pthread        
-       AC_CHECK_LIB(pthread,pthread_create,
-       [
-               PTHREAD_CPPFLAGS=
-               PTHREAD_LDFLAGS=
-               PTHREAD_LIBS=-lpthread
-       ],[
-               AC_MSG_CHECKING(if compiler supports -pthread)
-               save_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS -pthread"
-               AC_TRY_LINK(
-               [
-                       #include <pthread.h>
-               ],[
-                       pthread_create(0,0,0,0);
-               ],[
-                       AC_MSG_RESULT(yes)
-                       PTHREAD_CPPFLAGS=-pthread
-                       PTHREAD_LDFLAGS=-pthread
-                       PTHREAD_LIBS=
-               ],[
-                       AC_MSG_RESULT(no)
-                       AC_MSG_CHECKING(if compiler supports -pthreads)
-                       save_CPPFLAGS="$CPPFLAGS"
-                       CPPFLAGS="$save_CPPFLAGS -pthreads"
-                       AC_TRY_LINK(
-                       [
-                               #include <pthread.h>
-                       ],[
-                               pthread_create(0,0,0,0);
-                       ],[
-                               AC_MSG_RESULT(yes)
-                               PTHREAD_CPPFLAGS=-pthreads
-                               PTHREAD_LDFLAGS=-pthreads
-                               PTHREAD_LIBS=
-                       ],[
-                               AC_MSG_RESULT(no)
-                               AC_MSG_CHECKING(if compiler supports -threads)
-                               save_CPPFLAGS="$CPPFLAGS"
-                               CPPFLAGS="$save_CPPFLAGS -threads"
-                               AC_TRY_LINK(
-                               [
-                                       #include <pthread.h>
-                               ],[
-                                       pthread_create(0,0,0,0);
-                               ],[
-                                       AC_MSG_RESULT(yes)
-                                       PTHREAD_CPPFLAGS=-threads
-                                       PTHREAD_LDFLAGS=-threads
-                                       PTHREAD_LIBS=
-                               ],[
-                                       AC_MSG_ERROR([Your system is not 
supporting pthreads!])
-                               ])
-                       ])
-               ])
-               CPPFLAGS="$save_CPPFLAGS"
-       ])
-         
+    # first try without -pthread
+    AC_TRY_LINK(
+    [
+        #include <pthread.h>
+    ],[
+        pthread_create(0,0,0,0);
+    ],[
+        AC_MSG_RESULT(yes)
+        PTHREAD_CPPFLAGS=
+        PTHREAD_LDFLAGS=
+        PTHREAD_LIBS=
+    ],[
+
+        # now with -pthread
+        AC_CHECK_LIB(pthread,pthread_create,
+        [
+            PTHREAD_CPPFLAGS=
+            PTHREAD_LDFLAGS=
+            PTHREAD_LIBS=-lpthread
+        ],[
+            AC_MSG_CHECKING(if compiler supports -pthread)
+            save_CPPFLAGS="$CPPFLAGS"
+            CPPFLAGS="$CPPFLAGS -pthread"
+            AC_TRY_LINK(
+            [
+                #include <pthread.h>
+            ],[
+                pthread_create(0,0,0,0);
+            ],[
+                AC_MSG_RESULT(yes)
+                PTHREAD_CPPFLAGS=-pthread
+                PTHREAD_LDFLAGS=-pthread
+                PTHREAD_LIBS=
+            ],[
+                AC_MSG_RESULT(no)
+                AC_MSG_CHECKING(if compiler supports -pthreads)
+                save_CPPFLAGS="$CPPFLAGS"
+                CPPFLAGS="$save_CPPFLAGS -pthreads"
+                AC_TRY_LINK(
+                [
+                    #include <pthread.h>
+                ],[
+                    pthread_create(0,0,0,0);
+                ],[
+                    AC_MSG_RESULT(yes)
+                    PTHREAD_CPPFLAGS=-pthreads
+                    PTHREAD_LDFLAGS=-pthreads
+                    PTHREAD_LIBS=
+                ],[
+                    AC_MSG_RESULT(no)
+                    AC_MSG_CHECKING(if compiler supports -threads)
+                    save_CPPFLAGS="$CPPFLAGS"
+                    CPPFLAGS="$save_CPPFLAGS -threads"
+                    AC_TRY_LINK(
+                    [
+                        #include <pthread.h>
+                    ],[
+                        pthread_create(0,0,0,0);
+                    ],[
+                        AC_MSG_RESULT(yes)
+                        PTHREAD_CPPFLAGS=-threads
+                        PTHREAD_LDFLAGS=-threads
+                        PTHREAD_LIBS=
+                    ],[
+                        AC_MSG_ERROR([Your system is not supporting pthreads!])
+                    ])
+                ])
+            ])
+            CPPFLAGS="$save_CPPFLAGS"
         ])
+    ])
 ])

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2010-08-19 10:18:04 UTC (rev 12671)
+++ libmicrohttpd/configure.ac  2010-08-19 11:27:17 UTC (rev 12672)
@@ -72,6 +72,8 @@
  CFLAGS="-fno-strict-aliasing $CFLAGS"
 fi
 
+# for pkg-config
+MHD_LIBDEPS=""
 
 # Check system type
 case "$host_os" in
@@ -115,12 +117,24 @@
      AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
      AM_CONDITIONAL(HAVE_GNU_LD, false)    
      LDFLAGS="$LDFLAGS -no-undefined"
+     # check if PlibC is available
+     CHECK_PLIBC
+     LIBS="$PLIBC_LIBS $LIBS"
+     AC_SUBST(PLIBC_LIBS)
+     AC_SUBST(PLIBC_LDFLAGS)
+     AC_SUBST(PLIBC_CPPFLAGS)
      ;;
 *mingw*)
      AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
-     LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc"
+     LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32"
      AM_CONDITIONAL(HAVE_GNU_LD, true)    
+     # check if PlibC is available
+     CHECK_PLIBC
+     LIBS="$PLIBC_LIBS $LIBS"
+     AC_SUBST(PLIBC_LIBS)
+     AC_SUBST(PLIBC_LDFLAGS)
+     AC_SUBST(PLIBC_CPPFLAGS)
      ;;
 *openedition*)
      AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system])
@@ -133,10 +147,6 @@
 ;;
 esac
 
-
-# for pkg-config
-MHD_LIBDEPS=""
-
 CHECK_PTHREAD
 LIBS="$PTHREAD_LIBS $LIBS"
 AC_SUBST(PTHREAD_LIBS)

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2010-08-19 10:18:04 UTC (rev 12671)
+++ libmicrohttpd/src/daemon/daemon.c   2010-08-19 11:27:17 UTC (rev 12672)
@@ -1642,10 +1642,25 @@
 
       if ((options & MHD_USE_IPv6) != 0)
        {
+#ifdef IPPROTO_IPV6
+#ifdef IPV6_V6ONLY
+         /* Note: "IPV6_V6ONLY" is declared by Windows Vista ff., see 
"IPPROTO_IPV6 Socket Options" 
+            
(http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); 
+            and may also be missing on older POSIX systems; good luck if you 
have any of those,
+            your IPv6 socket may then also bind against IPv4... */
+#ifndef WINDOWS
          const int on = 1;
          setsockopt (socket_fd, 
                      IPPROTO_IPV6, IPV6_V6ONLY, 
-                     &on, sizeof (on));      
+                     &on, sizeof (on));
+#else
+         const char on = 1;
+         setsockopt (socket_fd, 
+                     IPPROTO_IPV6, IPV6_V6ONLY, 
+                     &on, sizeof (on));
+#endif
+#endif
+#endif
        }
       if (BIND (socket_fd, servaddr, addrlen) == -1)
        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]