From 3594582bd1b6431baff66a082e5d740e41b696ae Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 10 Nov 1996 00:14:45 +0000 Subject: [PATCH] On some systems conflicts with , and should not be #included at all. * aclocal.m4 (GUILE_HEADER_LIBC_WITH_UNISTD): New autoconf macro. * configure.in: Call it. * acconfig.h (LIBC_H_WITH_UNISTD_H): New CPP symbol. * posix.c, filesys.c: Use its results to decide whether or not to #include . * configure, scmconfig.h.in: Rebuilt with autoconf and autoheader. --- libguile/acconfig.h | 8 +- libguile/aclocal.m4 | 40 ++++++++++ libguile/configure | 162 ++++++++++++++++++++++++++++++---------- libguile/configure.in | 1 + libguile/filesys.c | 2 +- libguile/posix.c | 2 +- libguile/scmconfig.h.in | 8 +- 7 files changed, 180 insertions(+), 43 deletions(-) diff --git a/libguile/acconfig.h b/libguile/acconfig.h index c54e0c503..90099bece 100644 --- a/libguile/acconfig.h +++ b/libguile/acconfig.h @@ -44,9 +44,15 @@ #undef SCM_STACK_GROWS_UP /* Define this if doesn't define struct utimbuf unless - _POSIX_SOURCE is #defined. */ + _POSIX_SOURCE is #defined. See GUILE_STRUCT_UTIMBUF in aclocal.m4. */ #undef UTIMBUF_NEEDS_POSIX +/* Define this if we should #include when we've already + #included . On some systems, they conflict, and libc.h + should be omitted. See GUILE_HEADER_LIBC_WITH_UNISTD in + aclocal.m4. */ +#undef LIBC_H_WITH_UNISTD_H + /* Define these to indicate the current version of Guile. These values are supposed to be supplied by the configuration system. */ #undef GUILE_MAJOR_VERSION diff --git a/libguile/aclocal.m4 b/libguile/aclocal.m4 index a0e03479b..65b4b11c2 100644 --- a/libguile/aclocal.m4 +++ b/libguile/aclocal.m4 @@ -17,3 +17,43 @@ struct utime blah; if test "$guile_cv_struct_utimbuf_needs_posix" = yes; then AC_DEFINE(UTIMBUF_NEEDS_POSIX) fi]) + + + + +dnl +dnl Apparently, at CMU they have a weird version of libc.h that is +dnl installed in /usr/local/include and conflicts with unistd.h. +dnl In these situations, we should not #include libc.h. +dnl This test arranges to #define LIBC_H_WITH_UNISTD_H iff libc.h is +dnl present on the system, and is safe to #include. +dnl +AC_DEFUN([GUILE_HEADER_LIBC_WITH_UNISTD], + [ + AC_CHECK_HEADERS(libc.h unistd.h) + AC_CACHE_CHECK( + "whether libc.h and unistd.h can be included together", + guile_cv_header_libc_with_unistd, + [ + if test "$ac_cv_header_libc_h" = "no"; then + guile_cv_header_libc_with_unistd="no" + elif test "$ac_cv_header_unistd.h" = "no"; then + guile_cv_header_libc_with_unistd="yes" + else + AC_TRY_COMPILE( + [ +# include +# include + ], + [], + [guile_cv_header_libc_with_unistd=yes], + [guile_cv_header_libc_with_unistd=no] + ) + fi + ] + ) + if test "$guile_cv_header_libc_with_unistd" = yes; then + AC_DEFINE(LIBC_H_WITH_UNISTD_H) + fi + ] +) diff --git a/libguile/configure b/libguile/configure index f0b4d69cd..17d5b39a1 100755 --- a/libguile/configure +++ b/libguile/configure @@ -1421,12 +1421,96 @@ fi done + for ac_hdr in libc.h unistd.h +do +ac_safe=`echo "$ac_hdr" | tr './\055' '___'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'` + cat >> confdefs.h <&6 +fi +done + + echo $ac_n "checking "whether libc.h and unistd.h can be included together"""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'guile_cv_header_libc_with_unistd'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + if test "$ac_cv_header_libc_h" = "no"; then + guile_cv_header_libc_with_unistd="no" + elif test "$ac_cv_header_unistd.h" = "no"; then + guile_cv_header_libc_with_unistd="yes" + else + cat > conftest.$ac_ext < +# include + +int main() { return 0; } +int t() { + +; return 0; } +EOF +if { (eval echo configure:1484: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + guile_cv_header_libc_with_unistd=yes +else + rm -rf conftest* + guile_cv_header_libc_with_unistd=no + +fi +rm -f conftest* + + fi + + +fi + +echo "$ac_t""$guile_cv_header_libc_with_unistd" 1>&6 + if test "$guile_cv_header_libc_with_unistd" = yes; then + cat >> confdefs.h <<\EOF +#define LIBC_H_WITH_UNISTD_H 1 +EOF + + fi + + + echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -1462,7 +1546,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then ac_cv_type_getgroups=gid_t else @@ -1497,7 +1581,7 @@ fi rm -fr conftest* if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -1525,7 +1609,7 @@ if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1543,7 +1627,7 @@ int t() { int i; ; return 0; } EOF -if { (eval echo configure:1547: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1565,7 +1649,7 @@ if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1599,7 +1683,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1653,7 +1737,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1703,7 +1787,7 @@ if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1712,7 +1796,7 @@ int t() { struct stat s; s.st_rdev; ; return 0; } EOF -if { (eval echo configure:1716: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1800: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_rdev=yes else @@ -1736,7 +1820,7 @@ if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1745,7 +1829,7 @@ int t() { struct stat s; s.st_blksize; ; return 0; } EOF -if { (eval echo configure:1749: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blksize=yes else @@ -1769,7 +1853,7 @@ if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1778,7 +1862,7 @@ int t() { struct stat s; s.st_blocks; ; return 0; } EOF -if { (eval echo configure:1782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1866: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blocks=yes else @@ -1805,7 +1889,7 @@ if eval "test \"`echo '$''{'guile_cv_struct_utimbuf_needs_posix'+set}'`\" = set" echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1905: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1848,13 +1932,13 @@ if test "$cross_compiling" = yes; then echo "configure: warning: Guessing that stack grows down -- see scmconfig.h.in" 1>&2 else cat > conftest.$ac_ext <= ((unsigned long)&x)); } main () { int q; aux((unsigned long)&q); } EOF -{ (eval echo configure:1858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then cat >> confdefs.h <<\EOF #define SCM_STACK_GROWS_UP 1 @@ -1873,11 +1957,11 @@ EOF echo "configure: warning: Guessing that sizeof(long) == sizeof(float) -- see scmconfig.h.in" 1>&2 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then cat >> confdefs.h <<\EOF #define SCM_SINGLES 1 @@ -1892,7 +1976,7 @@ if eval "test \"`echo '$''{'scm_cv_struct_linger'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } @@ -1900,7 +1984,7 @@ int t() { struct linger lgr; lgr.l_linger = 100 ; return 0; } EOF -if { (eval echo configure:1904: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_linger="yes" else @@ -1929,7 +2013,7 @@ FD_SETTER="" if test "x$FD_SETTER" = x; then cat > conftest.$ac_ext < @@ -1938,7 +2022,7 @@ int t() { stdout->_file = 1 ; return 0; } EOF -if { (eval echo configure:1942: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2026: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* FD_SETTER="((F)->_file = (D))" fi @@ -1948,7 +2032,7 @@ fi if test "x$FD_SETTER" = x; then cat > conftest.$ac_ext < @@ -1957,7 +2041,7 @@ int t() { stdout->_fileno ; return 0; } EOF -if { (eval echo configure:1961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* FD_SETTER="((F)->_fileno = (D))" fi @@ -1988,7 +2072,7 @@ if eval "test \"`echo '$''{'scm_cv_struct_file_count'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } @@ -1996,13 +2080,13 @@ int t() { FILE *f = stdin; f->_cnt = 0 ; return 0; } EOF -if { (eval echo configure:2000: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2084: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_file_count="_cnt" else rm -rf conftest* cat > conftest.$ac_ext < int main() { return 0; } @@ -2010,13 +2094,13 @@ int t() { FILE *f = stdin; f->_r = 0 ; return 0; } EOF -if { (eval echo configure:2014: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2098: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_file_count="_r" else rm -rf conftest* cat > conftest.$ac_ext < int main() { return 0; } @@ -2024,7 +2108,7 @@ int t() { FILE *f = stdin; f->readCount = 0 ; return 0; } EOF -if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_file_count="readCount" else @@ -2052,7 +2136,7 @@ if eval "test \"`echo '$''{'scm_cv_struct_file_gptr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } @@ -2060,7 +2144,7 @@ int t() { FILE *f = stdin; f->_gptr = f->egptr; ; return 0; } EOF -if { (eval echo configure:2064: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2148: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_file_gptr=1 else @@ -2082,7 +2166,7 @@ if eval "test \"`echo '$''{'scm_cv_struct_file_readptr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } @@ -2090,7 +2174,7 @@ int t() { FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end; ; return 0; } EOF -if { (eval echo configure:2094: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2178: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_file_readptr=1 fi diff --git a/libguile/configure.in b/libguile/configure.in index 0801f0fb0..bb6487438 100644 --- a/libguile/configure.in +++ b/libguile/configure.in @@ -41,6 +41,7 @@ AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(libc.h limits.h malloc.h memory.h string.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) +GUILE_HEADER_LIBC_WITH_UNISTD AC_TYPE_GETGROUPS AC_TYPE_SIGNAL diff --git a/libguile/filesys.c b/libguile/filesys.c index a50c2cdd6..38f0b7768 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -61,7 +61,7 @@ #include #endif -#ifdef HAVE_LIBC_H +#ifdef LIBC_H_WITH_UNISTD_H #include #endif diff --git a/libguile/posix.c b/libguile/posix.c index 3838ae906..ebdbf202c 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -75,7 +75,7 @@ extern char *ttyname(); #endif #endif -#ifdef HAVE_LIBC_H +#ifdef LIBC_H_WITH_UNISTD_H #include #endif diff --git a/libguile/scmconfig.h.in b/libguile/scmconfig.h.in index fe9d14606..d0b292546 100644 --- a/libguile/scmconfig.h.in +++ b/libguile/scmconfig.h.in @@ -97,9 +97,15 @@ #undef SCM_STACK_GROWS_UP /* Define this if doesn't define struct utimbuf unless - _POSIX_SOURCE is #defined. */ + _POSIX_SOURCE is #defined. See GUILE_STRUCT_UTIMBUF in aclocal.m4. */ #undef UTIMBUF_NEEDS_POSIX +/* Define this if we should #include when we've already + #included . On some systems, they conflict, and libc.h + should be omitted. See GUILE_HEADER_LIBC_WITH_UNISTD in + aclocal.m4. */ +#undef LIBC_H_WITH_UNISTD_H + /* Define these to indicate the current version of Guile. These values are supposed to be supplied by the configuration system. */ #undef GUILE_MAJOR_VERSION