I have been trying to compile neon (checked out from the trunk) with
MinGW, but ./configure has been failing with the following message:

checking for library containing socket... not found
configure: error: could not find library containing socket

After digging into it further, I found that the configure script was
trying to compile a file like the following:

int
main ()
{
  socket();
  return 0;
}

There were two problems. First, it needed winsock2.h (such as in
ne_socket.c). Second, the socket function accepts three parameters. The
attached diff causes the following file to be generated and compiled
instead:

#ifdef WIN32
#include <winsock2.h>
#endif

int
main ()
{
  socket(0,0,0);
  return 0;
}

I have only tested this in Windows and have not had a chance to test it
on other platforms. Also, perhaps there is a better way to achieve the
same result?

Thanks.

-Matthias Miller


Index: macros/neon.m4
===================================================================
--- macros/neon.m4      (revision 1064)
+++ macros/neon.m4      (working copy)
@@ -339,7 +339,7 @@
 ])
 
 dnl AC_SEARCH_LIBS done differently. Usage:
-dnl   NE_SEARCH_LIBS(function, libnames, [extralibs], [actions-if-not-found],
+dnl   NE_SEARCH_LIBS(name, function, prologue, libnames, [extralibs], 
[actions-if-not-found],
 dnl                            [actions-if-found])
 dnl Tries to find 'function' by linking againt `-lLIB $NEON_LIBS' for each
 dnl LIB in libnames.  If link fails and 'extralibs' is given, will also
@@ -352,28 +352,28 @@
 
 AC_CACHE_CHECK([for library containing $1], [ne_cv_libsfor_$1], [
 AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM([], [[$1();]])], 
+  [AC_LANG_PROGRAM([$3], [$2])], 
   [ne_cv_libsfor_$1="none needed"], [
 ne_sl_save_LIBS=$LIBS
 ne_cv_libsfor_$1="not found"
-for lib in $2; do
+for lib in $4; do
     LIBS="$ne_sl_save_LIBS -l$lib $NEON_LIBS"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[$1();]])],
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([$3], [$2])],
                    [ne_cv_libsfor_$1="-l$lib"; break])
-    m4_if($3, [], [], dnl If $3 is specified, then...
-              [LIBS="$ne_sl_save_LIBS -l$lib $3 $NEON_LIBS"
-               AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[$1();]])], 
-                              [ne_cv_libsfor_$1="-l$lib $3"; break])])
+    m4_if($5, [], [], dnl If $5 is specified, then...
+              [LIBS="$ne_sl_save_LIBS -l$lib $5 $NEON_LIBS"
+               AC_LINK_IFELSE([AC_LANG_PROGRAM([$3], [$2])], 
+                              [ne_cv_libsfor_$1="-l$lib $5"; break])])
 done
 LIBS=$ne_sl_save_LIBS])])
 
 if test "$ne_cv_libsfor_$1" = "not found"; then
-   m4_if([$4], [], [AC_MSG_ERROR([could not find library containing $1])], 
[$4])
+   m4_if([$6], [], [AC_MSG_ERROR([could not find library containing $1])], 
[$6])
 elif test "$ne_cv_libsfor_$1" = "none needed"; then
-   m4_if([$5], [], [:], [$5])
+   m4_if([$7], [], [:], [$7])
 else
    NEON_LIBS="$ne_cv_libsfor_$1 $NEON_LIBS"
-   $5
+   $7
 fi])
 
 dnl Check for presence and suitability of zlib library
@@ -603,11 +603,15 @@
 
 # Unixware 7 can only link gethostbyname with -lnsl -lsocket
 # Pick up -lsocket first, then the gethostbyname check will work.
-NE_SEARCH_LIBS(socket, socket inet ws2_32)
+NE_SEARCH_LIBS(socket, [socket(0,0,0)], [
+       #ifdef WIN32
+       #include <winsock2.h>
+       #endif
+], socket inet ws2_32)
 
 # Enable getaddrinfo support if it, gai_strerror and inet_ntop are
 # all available.
-NE_SEARCH_LIBS(getaddrinfo, nsl,,
+NE_SEARCH_LIBS(getaddrinfo, [], [getaddrinfo();], nsl,,
   [ne_enable_gai=no],
   [# HP-UX boxes commonly get into a state where getaddrinfo is present
    # but borked: http://marc.theaimsgroup.com/?l=apr-dev&m=107730955207120&w=2
@@ -636,8 +640,8 @@
    # Checks for non-getaddrinfo() based resolver interfaces.
    # QNX has gethostbyname in -lsocket. BeOS only has it in -lbind.
    # CygWin/Winsock2 has it in -lws2_32, allegedly.
-   NE_SEARCH_LIBS(gethostbyname, socket nsl bind)
-   NE_SEARCH_LIBS(hstrerror, resolv,,[:])
+   NE_SEARCH_LIBS(gethostbyname, [], [gethostbyname();], socket nsl bind)
+   NE_SEARCH_LIBS(hstrerror, [], [hstrerror();], resolv,,[:])
    NE_CHECK_FUNCS(hstrerror)
    # Older Unixes don't declare h_errno.
    AC_CHECK_DECLS(h_errno,,,[#define _XOPEN_SOURCE_EXTENDED 1
@@ -854,8 +858,8 @@
      CPPFLAGS="$CPPFLAGS ${NE_SSL_CFLAGS}"
      NEON_LIBS="$NEON_LIBS ${NE_SSL_LIBS}"],
     [# Either OpenSSL library may require -ldl if built with dynamic engine 
support
-     NE_SEARCH_LIBS(RSA_new, crypto, -ldl)
-     NE_SEARCH_LIBS(SSL_library_init, ssl, -ldl)])
+     NE_SEARCH_LIBS(RSA_new, [], [RSA_new();], crypto, -ldl)
+     NE_SEARCH_LIBS(SSL_library_init, [], [SSL_library_init();], ssl, -ldl)])
 
    AC_CHECK_HEADERS(openssl/ssl.h openssl/opensslv.h,,
    [AC_MSG_ERROR([OpenSSL headers not found, cannot enable SSL support])])
@@ -1097,7 +1101,7 @@
   # presume that dgettext() is available if bindtextdomain() is...
   # checking for dgettext() itself is awkward because gcc has a 
   # builtin of that function, which confuses AC_CHECK_FUNCS et al.
-  NE_SEARCH_LIBS(bindtextdomain, intl,,[enable_nls=no])
+  NE_SEARCH_LIBS(bindtextdomain, [], [bindtextdomain();], 
intl,,[enable_nls=no])
   NE_CHECK_FUNCS(bind_textdomain_codeset)
 fi
 

_______________________________________________
neon mailing list
[email protected]
http://mailman.webdav.org/mailman/listinfo/neon

Reply via email to