Fresco/Prague configure.ac,1.45,1.46

Tobias Hunger <[email protected]> Thu, 08 Jan 2004 16:18:11 +0100
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Prague
In directory purcel:/tmp/cvs-serv30427/Prague

Modified Files:
	configure.ac 
Log Message:
Improve socklen_t detection based on code from curl. Lets hope this will
work on Linux and FreeBSD:-)


Index: configure.ac
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/configure.ac,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- configure.ac	8 Jan 2004 14:11:28 -0000	1.45
+++ configure.ac	8 Jan 2004 15:17:10 -0000	1.46
@@ -93,7 +93,43 @@
 AC_CHECK_HEADERS([sys/socket.h select.h sys/select.h netinet/in_systm.h netinet/ip.h])
 AC_CHECK_HEADERS([pty.h sys/stropts.h libutil.h])
 AC_CHECK_HEADERS([arpa/inet.h sys/un.h])
-AC_CHECK_TYPE([socklen_t], [], [], [#include <sys/socket.h>])
+AC_CHECK_TYPES([socklen_t],
+   [ AC_DEFINE_UNQUOTED(HAVE_SOCKLEN_T, 1, [defined if we have a socklen_t]) ],
+   [
+     AC_MSG_CHECKING([for socklen_t equivalent])
+     prague_socklen_t_equiv=""
+     for arg2 in "struct sockaddr" void; do
+         for t in int size_t unsigned long "unsigned long"; do
+             AC_TRY_COMPILE([
+                  #ifdef HAVE_SYS_TYPES_H
+                  #include <sys/types.h>
+                  #endif
+                  #ifdef HAVE_SYS_SOCKET_H
+                  #include <sys/socket.h>
+                  #endif
+
+                  int getpeername (int, $arg2 *, $t *);
+               ],[
+                  $t len;
+                  getpeername(0,0,&len);
+               ],[
+                  prague_socklen_t_equiv="$t"
+                  break
+               ]
+             )
+         done
+     done
+
+     if test ".$prague_socklen_t_equiv" = "." ; then
+         AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+     fi
+
+     AC_MSG_RESULT($prague_socklen_t_equiv)
+     AC_DEFINE_UNQUOTED(SOCKLEN_T_EQUIV, $prague_socklen_t_equiv,
+			[type to use in place of socklen_t if not defined])
+   ],
+   [#include <sys/types.h>
+#include <sys/socket.h>])
 AC_SEARCH_LIBS(socket, [socket])
 AC_SEARCH_LIBS(inet_aton, [socket resolv])
 AC_SEARCH_LIBS(login, [util])