bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

netinet_in module: make <netinet.h> self-contained


From: Bruno Haible
Subject: netinet_in module: make <netinet.h> self-contained
Date: Sat, 3 Mar 2007 04:53:55 +0100
User-agent: KMail/1.5.4

Hi Simon,

Like for <sys/socket.h>, <netinet/in.h> should be self-contained according
to POSIX, and the test verifies this. It fails on MacOS X, because it
needs <sys/types.h> to be included first. Here's a proposed change to
create an overridden netinet/in.h also in this case.

2007-03-02  Bruno Haible  <address@hidden>

        * 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.

=========================== lib/netinet_in_.h ==============================
/* Substitute for <netinet/in.h>.
   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, <netinet/in.h> assumes prior inclusion of
   <sys/types.h>.  */

# include <sys/types.h>
# include @ABSOLUTE_NETINET_IN_H@

#else

/* A platform that lacks <netinet/in.h>.  */

# include <sys/socket.h>

#endif

#endif /* _GL_NETINET_IN_H */
============================================================================
*** m4/netinet_in_h.m4  28 Jul 2006 17:27:29 -0000      1.1
--- m4/netinet_in_h.m4  3 Mar 2007 03:52:59 -0000
***************
*** 1,18 ****
! # netinet_in_h.m4 serial 1
! dnl Copyright (C) 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 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
      NETINET_IN_H=''
    else
      NETINET_IN_H='netinet/in.h'
    fi
!   AC_SUBST(NETINET_IN_H)
  ])
--- 1,38 ----
! # 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.
  
  AC_DEFUN([gl_HEADER_NETINET_IN],
  [
!   AC_CACHE_CHECK([whether <netinet/in.h> is self-contained],
!     [gl_cv_header_netinet_in_h_selfcontained],
!     [
!       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netinet/in.h>], [])],
!         [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'
+ 
+     dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+     dnl the check for those headers unconditional; yet cygwin reports
+     dnl that the headers are present but cannot be compiled (since on
+     dnl cygwin, all socket information should come from 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])
  ])
*** modules/netinet_in  2 Feb 2007 13:06:22 -0000       1.6
--- modules/netinet_in  3 Mar 2007 03:52:59 -0000
***************
*** 1,10 ****
  Description:
! A <netinet/in.h> for systems lacking it (e.g., Mingw).
  
  Files:
  m4/netinet_in_h.m4
  
  Depends-on:
  sys_socket
  
  configure.ac:
--- 1,12 ----
  Description:
! A <netinet/in.h> for systems lacking it.
  
  Files:
+ lib/netinet_in_.h
  m4/netinet_in_h.m4
  
  Depends-on:
+ absolute-header
  sys_socket
  
  configure.ac:
***************
*** 20,26 ****
        @MKDIR_P@ netinet
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
!         echo '#include <sys/socket.h>'; \
        } > address@hidden
        mv address@hidden $@
  MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
--- 22,30 ----
        @MKDIR_P@ netinet
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
!         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; \
        } > address@hidden
        mv address@hidden $@
  MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t





reply via email to

[Prev in Thread] Current Thread [Next in Thread]