changeset 6536:169ab032c734

Add sys_socket module.
author Simon Josefsson <simon@josefsson.org>
date Tue, 10 Jan 2006 14:28:52 +0000
parents f0b048cba3a9
children 040ffb6174b7
files ChangeLog lib/ChangeLog lib/socket_.h m4/ChangeLog m4/sys_socket_h.m4 modules/sys_socket
diffstat 6 files changed, 103 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
new file mode 100644
--- /dev/null
+++ b/lib/socket_.h
@@ -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 */
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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.
new file mode 100644
--- /dev/null
+++ b/m4/sys_socket_h.m4
@@ -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)
+])
new file mode 100644
--- /dev/null
+++ b/modules/sys_socket
@@ -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