Add sys_socket module.
authorSimon Josefsson <simon@josefsson.org>
Tue, 10 Jan 2006 14:28:52 +0000 (14:28 +0000)
committerSimon Josefsson <simon@josefsson.org>
Tue, 10 Jan 2006 14:28:52 +0000 (14:28 +0000)
ChangeLog
lib/ChangeLog
lib/socket_.h [new file with mode: 0644]
m4/ChangeLog
m4/sys_socket_h.m4 [new file with mode: 0644]
modules/sys_socket [new file with mode: 0644]

index c62cb38deaa5de08a0ece1ef4515ac98f27cbf40..3af1bc40de2544ff7b498ecd4f789b2282d4a99a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <jas@extundo.com>
+
+       * modules/sys_socket: New file.
+
 2006-01-07  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool (func_emit_tests_Makefile_am): Emit an empty SUBDIR
index 7d87fcb22bbb894215394a9d55cb7df8e873bf5b..ccad8070cc8b241a12bbd55c4162414adae10cc7 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <jas@extundo.com>
+
+       * socket_.h: New file.
+
 2006-01-10  Bruno Haible  <bruno@clisp.org>
 
        * localcharset.c: Update from GNU gettext.
diff --git a/lib/socket_.h b/lib/socket_.h
new file mode 100644 (file)
index 0000000..f3a63b7
--- /dev/null
@@ -0,0 +1,37 @@
+/* Provide a sys/socket header file for systems lacking it (read: mingw32).
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+
+/* This file is supposed to be used on platforms that lack
+   sys/socket.h.  It is intended to provide definitions and prototypes
+   needed by an application.
+
+   Currently only mingw32 is supported, which has the header files
+   winsock2.h and ws2tcpip.h that declare the sys/socket.h definitions
+   we need. */
+
+#if HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
+#if HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+
+#endif /* _SYS_SOCKET_H */
index 35e04419458d1ed2107c3383171343ec4aa26fb9..3dbe1c929e98043b5794ddae6a828c30e4825bc4 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-10  Simon Josefsson  <jas@extundo.com>
+
+       * sys_socket_h.m4: New file.
+
 2006-01-10  Bruno Haible  <bruno@clisp.org>
 
        * localcharset.m4 (gl_LOCALCHARSET): Also test for getc_unlocked.
diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
new file mode 100644 (file)
index 0000000..10d042c
--- /dev/null
@@ -0,0 +1,19 @@
+# sys_socket_h.m4 serial 1
+dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson.
+
+AC_DEFUN([gl_HEADER_SYS_SOCKET],
+[
+  AC_CHECK_HEADERS_ONCE([sys/socket.h])
+  if test $ac_cv_header_sys_socket_h = yes; then
+    SYS_SOCKET_H=''
+  else
+    AC_CHECK_HEADERS_ONCE([winsock2.h ws2tcpip.h])
+    SYS_SOCKET_H='sys/socket.h'
+  fi
+  AC_SUBST(SYS_SOCKET_H)
+])
diff --git a/modules/sys_socket b/modules/sys_socket
new file mode 100644 (file)
index 0000000..5da2ac5
--- /dev/null
@@ -0,0 +1,35 @@
+Description:
+A <sys/socket.h> for systems lacking it.
+
+Files:
+lib/socket_.h
+m4/sys_socket_h.m4
+
+Depends-on:
+
+configure.ac:
+gl_HEADER_SYS_SOCKET
+
+Makefile.am:
+BUILT_SOURCES += $(SYS_SOCKET_H)
+EXTRA_DIST += socket_.h
+
+# We need the following in order to create <sys/socket.h> when the system
+# doesn't have one that works with the given compiler.
+sys/socket.h: socket_.h
+       test -d sys || mkdir sys
+       cp $(srcdir)/socket_.h $@-t
+       mv $@-t $@
+MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
+
+mostlyclean-local:
+       -rmdir sys 2>/dev/null
+
+Include:
+#include <sys/socket.h>
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson