From 3b5b4fc9ef9c5385df749b8315e14c1e7291dbb8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 7 Mar 2007 23:11:37 +0000 Subject: [PATCH] Make self-contained, i.e. allow it to be included without prior . --- ChangeLog | 10 ++++++++++ lib/netinet_in_.h | 37 +++++++++++++++++++++++++++++++++++++ m4/netinet_in_h.m4 | 28 +++++++++++++++++++++------- modules/netinet_in | 8 ++++++-- 4 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 lib/netinet_in_.h diff --git a/ChangeLog b/ChangeLog index ce766ebf9..8dee0e79c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-03-02 Bruno Haible + + * lib/netinet_in_.h: New file. + * m4/netinet_in_h.m4 (gl_HEADER_NETINET_IN): Test whether netinet/in.h + is self-contained. Set ABSOLUTE_NETINET_IN_H, HAVE_NETINET_IN_H. + * modules/netinet_in (Files): Add lib/netinet_in_.h. + (Depends-on): Add absolute-header. + (Makefile.am): Substitute ABSOLUTE_NETINET_IN_H, HAVE_NETINET_IN_H + into netinet/in.h. + 2007-03-03 Bruno Haible * lib/sys_select_.h: New file. diff --git a/lib/netinet_in_.h b/lib/netinet_in_.h new file mode 100644 index 000000000..4a53605f5 --- /dev/null +++ b/lib/netinet_in_.h @@ -0,0 +1,37 @@ +/* Substitute for . + Copyright (C) 2007 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_NETINET_IN_H +#define _GL_NETINET_IN_H + +#if @HAVE_NETINET_IN_H@ + +/* On many platforms, assumes prior inclusion of + . */ + +# include +# include @ABSOLUTE_NETINET_IN_H@ + +#else + +/* A platform that lacks . */ + +# include + +#endif + +#endif /* _GL_NETINET_IN_H */ diff --git a/m4/netinet_in_h.m4 b/m4/netinet_in_h.m4 index d73531a05..966bfe6a1 100644 --- a/m4/netinet_in_h.m4 +++ b/m4/netinet_in_h.m4 @@ -1,18 +1,32 @@ -# netinet_in_h.m4 serial 1 -dnl Copyright (C) 2006 Free Software Foundation, Inc. +# netinet_in_h.m4 serial 2 +dnl Copyright (C) 2006-2007 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 - AC_DEFUN([gl_HEADER_NETINET_IN], [ - AC_CHECK_HEADERS_ONCE([netinet/in.h]) - if test $ac_cv_header_netinet_in_h = yes; then + AC_CACHE_CHECK([whether is self-contained], + [gl_cv_header_netinet_in_h_selfcontained], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [])], + [gl_cv_header_netinet_in_h_selfcontained=yes], + [gl_cv_header_netinet_in_h_selfcontained=no]) + ]) + if test $gl_cv_header_netinet_in_h_selfcontained = yes; then NETINET_IN_H='' else NETINET_IN_H='netinet/in.h' + AC_CHECK_HEADERS([netinet/in.h]) + gl_ABSOLUTE_HEADER([netinet/in.h]) + ABSOLUTE_NETINET_IN_H=\"$gl_cv_absolute_netinet_in_h\" + AC_SUBST([ABSOLUTE_NETINET_IN_H]) + if test $ac_cv_header_netinet_in_h = yes; then + HAVE_NETINET_IN_H=1 + else + HAVE_NETINET_IN_H=0 + fi + AC_SUBST([HAVE_NETINET_IN_H]) fi - AC_SUBST(NETINET_IN_H) + AC_SUBST([NETINET_IN_H]) ]) diff --git a/modules/netinet_in b/modules/netinet_in index 6e6665903..af836befa 100644 --- a/modules/netinet_in +++ b/modules/netinet_in @@ -1,10 +1,12 @@ Description: -A for systems lacking it (e.g., Mingw). +A for systems lacking it. Files: +lib/netinet_in_.h m4/netinet_in_h.m4 Depends-on: +absolute-header sys_socket configure.ac: @@ -20,7 +22,9 @@ netinet/in.h: @MKDIR_P@ netinet rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - echo '#include '; \ + sed -e 's|@''ABSOLUTE_NETINET_IN_H''@|$(ABSOLUTE_NETINET_IN_H)|g' \ + -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ + < $(srcdir)/netinet_in_.h; \ } > $@-t mv $@-t $@ MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t -- 2.11.0