Hi, Gnulib's current (minimal) arpa/inet.h for MinGW doesn't declare inet_ntop and inet_pton, which doesn't exist on MinGW. However, gnulib has inet_ntop and inet_pton modules with their own header files. This patch makes sure that arpa/inet.h provides the expected declarations. Comments?
Yoann, ok to commit? It has minimal consequences for your module inet_ntop, it only adds a gl_ARPA_INET_MODULE_INDICATOR([inet_ntop] to the modules/inet_ntop file. We could consider dropping the inet_ntop.h and inet_pton.h files instead, and just require that you include arpa/inet.h. This would be slightly cleaner. Yoann, what do you think about that? /Simon diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4 index d01d098..8f530c5 100644 --- a/m4/arpa_inet_h.m4 +++ b/m4/arpa_inet_h.m4 @@ -1,5 +1,5 @@ -# arpa_inet_h.m4 serial 1 -dnl Copyright (C) 2006 Free Software Foundation, Inc. +# arpa_inet_h.m4 serial 2 +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. @@ -8,6 +8,10 @@ dnl Written by Simon Josefsson AC_DEFUN([gl_HEADER_ARPA_INET], [ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + AC_CHECK_HEADERS_ONCE([arpa/inet.h]) if test $ac_cv_header_arpa_inet_h = yes; then ARPA_INET_H='' @@ -16,3 +20,16 @@ AC_DEFUN([gl_HEADER_ARPA_INET], fi AC_SUBST(ARPA_INET_H) ]) + +AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], +[ + GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP]) + GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON]) +]) diff --git a/modules/arpa_inet b/modules/arpa_inet index 5193952..6cdf206 100644 --- a/modules/arpa_inet +++ b/modules/arpa_inet @@ -2,6 +2,7 @@ Description: A <arpa/inet.h> for systems lacking it (e.g., Mingw). Files: +lib/arpa_inet.in.h m4/arpa_inet_h.m4 Depends-on: @@ -18,9 +19,11 @@ BUILT_SOURCES += $(ARPA_INET_H) # doesn't have one. arpa/inet.h: @MKDIR_P@ arpa - rm -f [EMAIL PROTECTED] $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - echo '#include <sys/socket.h>'; \ + sed \ + -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ + -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \ + < $(srcdir)/arpa_inet.in.h; \ } > [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t diff --git a/modules/inet_ntop b/modules/inet_ntop index 544ab87..1779359 100644 --- a/modules/inet_ntop +++ b/modules/inet_ntop @@ -14,6 +14,7 @@ netinet_in configure.ac: gl_INET_NTOP +gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) Makefile.am: diff --git a/modules/inet_pton b/modules/inet_pton index c9a4fac..3b6166d 100644 --- a/modules/inet_pton +++ b/modules/inet_pton @@ -14,6 +14,7 @@ netinet_in configure.ac: gl_INET_PTON +gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) Makefile.am: lib/arpa_inet.h: /* Provide a arpa/inet header file for systems lacking it (read: MinGW) Copyright (C) 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 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 _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 @GNULIB_INET_NTOP@ # include <inet_ntop.h> #elif defined GNULIB_POSIXCHECK # undef inet_ntop # define inet_ntop(af,src,dst,cnt) \ (GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \ "use gnulib module inet_ntop for portability"), \ inet_ntop (af, src, dst, cnt)) #endif #if @GNULIB_INET_PTON@ # include <inet_pton.h> #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"), \ inet_pton (af, src, dst)) #endif #endif /* _GL_ARPA_INET_H */