[patch] conditional header inclusion

Lars J. Aas mailto:larsa@sim.no
Thu, 16 Nov 2000 10:26:26 +0100


The following headers aren't available on the Cygwin system (Cygwin 1.1,
NT 4.0, MSVC++) I'm trying to build Guile on:

  arpa/inet.h
  grp.h
  netdb.h
  netinet/in.h
  pwd.h
  sys/socket.h
  sys/utsname.h

This patch adds tests for those headers and wraps the corresponding
include directives.

  Lars J

Index: configure.in
===================================================================
RCS file: /cvs/guile/guile-core/configure.in,v
retrieving revision 1.124
diff -u -r1.124 configure.in
--- configure.in	2000/10/25 14:45:36	1.124
+++ configure.in	2000/11/16 09:11:42
@@ -133,7 +134,7 @@
 AC_HEADER_DIRENT
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/utime.h time.h unistd.h utime.h)
+AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/utime.h time.h unistd.h utime.h pwd.h sys/socket.h netdb.h netinet/in.h arpa/inet.h grp.h sys/utsname.h)
 GUILE_HEADER_LIBC_WITH_UNISTD
 
 AC_TYPE_GETGROUPS
Index: libguile/filesys.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/filesys.c,v
retrieving revision 1.85
diff -u -r1.85 filesys.c
--- libguile/filesys.c	2000/11/07 21:34:45	1.85
+++ libguile/filesys.c	2000/11/16 09:02:25
@@ -91,7 +91,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
 
 
 #if HAVE_DIRENT_H
Index: libguile/net_db.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/net_db.c,v
retrieving revision 1.48
diff -u -r1.48 net_db.c
--- libguile/net_db.c	2000/10/30 11:42:26	1.48
+++ libguile/net_db.c	2000/11/16 09:02:36
@@ -65,10 +65,18 @@
 #endif
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
+#endif
 
 #if !defined (HAVE_H_ERRNO)
 extern int h_errno;
Index: libguile/posix.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/posix.c,v
retrieving revision 1.76
diff -u -r1.76 posix.c
--- libguile/posix.c	2000/11/01 17:55:41	1.76
+++ libguile/posix.c	2000/11/16 09:02:42
@@ -86,7 +86,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#if HAVE_PWD_H
 #include <pwd.h>
+#endif
 
 #if HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -103,8 +105,12 @@
 extern FILE *popen ();
 extern char ** environ;
 
+#ifdef HAVE_GRP_H
 #include <grp.h>
+#endif
+#ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
+#endif
 
 #if HAVE_DIRENT_H
 # include <dirent.h>
Index: libguile/socket.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/socket.c,v
retrieving revision 1.56
diff -u -r1.56 socket.c
--- libguile/socket.c	2000/10/30 11:42:26	1.56
+++ libguile/socket.c	2000/11/16 09:02:50
@@ -63,13 +63,21 @@
 #include <unistd.h>
 #endif
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
 #include <sys/un.h>
 #endif
+#ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
+#endif