1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

On some systems <libc.h> conflicts with <unistd.h>, 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 <libc.h>.
* configure, scmconfig.h.in: Rebuilt with autoconf and
autoheader.
This commit is contained in:
Jim Blandy 1996-11-10 00:14:45 +00:00
parent deb95d7196
commit 3594582bd1
7 changed files with 180 additions and 43 deletions

View file

@ -44,9 +44,15 @@
#undef SCM_STACK_GROWS_UP
/* Define this if <utime.h> 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 <libc.h> when we've already
#included <unistd.h>. 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

40
libguile/aclocal.m4 vendored
View file

@ -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 <libc.h>
# include <unistd.h>
],
[],
[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
]
)

162
libguile/configure vendored
View file

@ -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
#line 1433 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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 <<EOF
#define $ac_tr_hdr 1
EOF
else
echo "$ac_t""no" 1>&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 <<EOF
#line 1473 "configure"
#include "confdefs.h"
# include <libc.h>
# include <unistd.h>
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
#line 1430 "configure"
#line 1514 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@ -1462,7 +1546,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
#line 1466 "configure"
#line 1550 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@ -1487,7 +1571,7 @@ main()
}
EOF
{ (eval echo configure:1491: \"$ac_link\") 1>&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
#line 1501 "configure"
#line 1585 "configure"
#include "confdefs.h"
#include <unistd.h>
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 <<EOF
#line 1529 "configure"
#line 1613 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@ -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 <<EOF
#line 1569 "configure"
#line 1653 "configure"
#include "confdefs.h"
#include <sys/types.h>
#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 <<EOF
#line 1603 "configure"
#line 1687 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1623,7 +1707,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1627: \"$ac_link\") 1>&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 <<EOF
#line 1657 "configure"
#line 1741 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1677,7 +1761,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1681: \"$ac_link\") 1>&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 <<EOF
#line 1707 "configure"
#line 1791 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -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 <<EOF
#line 1740 "configure"
#line 1824 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -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 <<EOF
#line 1773 "configure"
#line 1857 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -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 <<EOF
#line 1809 "configure"
#line 1893 "configure"
#include "confdefs.h"
#ifdef __EMX__
@ -1817,7 +1901,7 @@ struct utime blah;
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1821: \"$ac_try\") 1>&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 <<EOF
#line 1852 "configure"
#line 1936 "configure"
#include "confdefs.h"
aux (l) unsigned long l;
{ int x; exit (l >= ((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 <<EOF
#line 1877 "configure"
#line 1961 "configure"
#include "confdefs.h"
main () { exit (sizeof(float) != sizeof(long)); }
EOF
{ (eval echo configure:1881: \"$ac_link\") 1>&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 <<EOF
#line 1896 "configure"
#line 1980 "configure"
#include "confdefs.h"
#include <sys/socket.h>
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 <<EOF
#line 1933 "configure"
#line 2017 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -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 <<EOF
#line 1952 "configure"
#line 2036 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -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 <<EOF
#line 1992 "configure"
#line 2076 "configure"
#include "confdefs.h"
#include <stdio.h>
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 <<EOF
#line 2006 "configure"
#line 2090 "configure"
#include "confdefs.h"
#include <stdio.h>
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 <<EOF
#line 2020 "configure"
#line 2104 "configure"
#include "confdefs.h"
#include <stdio.h>
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 <<EOF
#line 2056 "configure"
#line 2140 "configure"
#include "confdefs.h"
#include <stdio.h>
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 <<EOF
#line 2086 "configure"
#line 2170 "configure"
#include "confdefs.h"
#include <stdio.h>
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

View file

@ -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

View file

@ -61,7 +61,7 @@
#include <unistd.h>
#endif
#ifdef HAVE_LIBC_H
#ifdef LIBC_H_WITH_UNISTD_H
#include <libc.h>
#endif

View file

@ -75,7 +75,7 @@ extern char *ttyname();
#endif
#endif
#ifdef HAVE_LIBC_H
#ifdef LIBC_H_WITH_UNISTD_H
#include <libc.h>
#endif

View file

@ -97,9 +97,15 @@
#undef SCM_STACK_GROWS_UP
/* Define this if <utime.h> 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 <libc.h> when we've already
#included <unistd.h>. 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