From: Bruno Haible Date: Tue, 29 Apr 2008 11:37:51 +0000 (+0200) Subject: Enable gnulib's replacement also when inet_ntop or inet_pton need to... X-Git-Tag: v0.1~7460 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;ds=inline;h=da79138de50a46870a8c56a7aef09bf66591c402;p=gnulib.git Enable gnulib's replacement also when inet_ntop or inet_pton need to be declared. --- diff --git a/ChangeLog b/ChangeLog index 1066a833f..ceaee0794 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-04-29 Bruno Haible + + * lib/arpa_inet.in.h: Include system's 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 * modules/mkdir (License): Re-license as LGPLv2+. diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h index 900f7f340..6d6282576 100644 --- 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 . + + 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 +#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 @@ extern const char *inet_ntop (int af, const void *restrict src, # 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 @@ extern int inet_pton (int af, const char *restrict src, void *restrict dst); # 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 */ diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4 index baddf0da7..d342be69c 100644 --- 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_DEFUN([gl_HEADER_ARPA_INET], 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 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], 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]) ]) diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4 index 0848c0775..ee7ba5196 100644 --- 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 @@ dnl with or without modifications, as long as this notice is preserved. 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 ]) diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4 index 58f2c3186..4ea89d26e 100644 --- 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 @@ dnl with or without modifications, as long as this notice is preserved. 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 ]) diff --git a/modules/arpa_inet b/modules/arpa_inet index 8c5f3f941..75092bea8 100644 --- a/modules/arpa_inet +++ b/modules/arpa_inet @@ -1,11 +1,12 @@ Description: -A for systems lacking it (e.g., Mingw). +A GNU-like . Files: lib/arpa_inet.in.h m4/arpa_inet_h.m4 Depends-on: +include_next sys_socket configure.ac: @@ -21,7 +22,9 @@ arpa/inet.h: @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' \