changeset 10010:d26ac8a528f7

Enable gnulib's <arpa/inet.h> replacement also when inet_ntop or inet_pton need to be declared.
author Bruno Haible <bruno@clisp.org>
date Tue, 29 Apr 2008 13:37:51 +0200
parents 0fdbc870dc2d
children d266f32e62b2
files ChangeLog lib/arpa_inet.in.h m4/arpa_inet_h.m4 m4/inet_ntop.m4 m4/inet_pton.m4 modules/arpa_inet
diffstat 6 files changed, 58 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-04-29  Bruno Haible  <bruno@clisp.org>
+
+	* lib/arpa_inet.in.h: Include system's <arpa/inet.h> if it exists.
+	(inet_ntop, inet_pton): Change portability warning's wording.
+	* m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Set HAVE_ARPA_INET_H.
+	Invoke gl_CHECK_NEXT_HEADERS.
+	(gl_ARPA_INET_H_DEFAULTS): Initialize ARPA_INET_H.
+	* m4/inet_ntop.m4 (gl_INET_NTOP): Require gl_ARPA_INET_H_DEFAULTS and
+	set ARPA_INET_H.
+	* m4/inet_pton.m4 (gl_INET_PTON): Likewise.
+	* modules/arpa_inet (Description): No longer only for systems that
+	lack it.
+	(Depends-on): Add include_next.
+	(Makeile.am): Substitute INCLUDE_NEXT, NEXT_ARPA_INET_H,
+	HAVE_ARPA_INET_H.
+
 2008-04-29  Jim Meyering  <meyering@redhat.com>
 
 	* modules/mkdir (License): Re-license as LGPLv2+.
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -1,5 +1,6 @@
-/* Provide a arpa/inet header file for systems lacking it (read: MinGW)
-   Copyright (C) 2008 Free Software Foundation, Inc.
+/* A GNU-like <arpa/inet.h>.
+
+   Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
 
    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
@@ -16,12 +17,21 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _GL_ARPA_INET_H
-#define _GL_ARPA_INET_H
 
 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
    under MinGW. */
 #include <sys/socket.h>
 
+#if @HAVE_ARPA_INET_H@
+
+/* The include_next requires a split double-inclusion guard.  */
+# @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
+
+#endif
+
+#ifndef _GL_ARPA_INET_H
+#define _GL_ARPA_INET_H
+
 #if @GNULIB_INET_NTOP@
 # if !@HAVE_DECL_INET_NTOP@
 /* Converts an internet address from internal format to a printable,
@@ -44,8 +54,8 @@
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_ntop
-# define inet_ntop(af,src,dst,cnt)					\
-    (GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \
+# define inet_ntop(af,src,dst,cnt) \
+    (GL_LINK_WARNING ("inet_ntop is unportable - " \
                       "use gnulib module inet_ntop for portability"), \
      inet_ntop (af, src, dst, cnt))
 #endif
@@ -56,10 +66,11 @@
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_pton
-# define inet_pton(af,src,dst)			    \
-  (GL_LINK_WARNING ("inet_pton doesn't exist on mingw - "	  \
-		    "use gnulib module inet_pton for portability"),	  \
+# define inet_pton(af,src,dst) \
+  (GL_LINK_WARNING ("inet_pton is unportable - " \
+		    "use gnulib module inet_pton for portability"), \
    inet_pton (af, src, dst))
 #endif
 
 #endif /* _GL_ARPA_INET_H */
+#endif /* _GL_ARPA_INET_H */
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -1,10 +1,10 @@
-# arpa_inet_h.m4 serial 2
+# arpa_inet_h.m4 serial 3
 dnl Copyright (C) 2006, 2008 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 Written by Simon Josefsson
+dnl Written by Simon Josefsson and Bruno Haible
 
 AC_DEFUN([gl_HEADER_ARPA_INET],
 [
@@ -14,11 +14,16 @@
 
   AC_CHECK_HEADERS_ONCE([arpa/inet.h])
   if test $ac_cv_header_arpa_inet_h = yes; then
-    ARPA_INET_H=''
+    HAVE_ARPA_INET_H=1
   else
     ARPA_INET_H='arpa/inet.h'
+    HAVE_ARPA_INET_H=0
   fi
-  AC_SUBST(ARPA_INET_H)
+  AC_SUBST([HAVE_ARPA_INET_H])
+  dnl Execute this unconditionally, because ARPA_INET_H may be set by other
+  dnl modules, after this code is executed.
+  gl_CHECK_NEXT_HEADERS([arpa/inet.h])
+  
 ])
 
 AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
@@ -35,4 +40,5 @@
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_DECL_INET_NTOP=1;  AC_SUBST([HAVE_DECL_INET_NTOP])
   HAVE_DECL_INET_PTON=1;  AC_SUBST([HAVE_DECL_INET_PTON])
+  ARPA_INET_H='';         AC_SUBST([ARPA_INET_H])
 ])
--- a/m4/inet_ntop.m4
+++ b/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 4
+# inet_ntop.m4 serial 5
 dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,9 @@
 
 AC_DEFUN([gl_INET_NTOP],
 [
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+  ARPA_INET_H='arpa/inet.h'
+
   AC_REPLACE_FUNCS(inet_ntop)
   gl_PREREQ_INET_NTOP
 ])
--- a/m4/inet_pton.m4
+++ b/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 3
+# inet_pton.m4 serial 4
 dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,9 @@
 
 AC_DEFUN([gl_INET_PTON],
 [
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+  ARPA_INET_H='arpa/inet.h'
+
   AC_REPLACE_FUNCS(inet_pton)
   gl_PREREQ_INET_PTON
 ])
--- a/modules/arpa_inet
+++ b/modules/arpa_inet
@@ -1,11 +1,12 @@
 Description:
-A <arpa/inet.h> for systems lacking it (e.g., Mingw).
+A GNU-like <arpa/inet.h>.
 
 Files:
 lib/arpa_inet.in.h
 m4/arpa_inet_h.m4
 
 Depends-on:
+include_next
 sys_socket
 
 configure.ac:
@@ -21,7 +22,9 @@
 	@MKDIR_P@ arpa
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed \
+	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	      -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
+	      -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
 	      -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
 	      -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
 	      -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \