dfa1a6260368c165361356be341ea2b10a783168
[bpt/guile.git] / acinclude.m4
1 dnl On the NeXT, #including <utime.h> doesn't give you a definition for
2 dnl struct utime, unless you #define _POSIX_SOURCE.
3
4 AC_DEFUN(GUILE_STRUCT_UTIMBUF, [
5 AC_CACHE_CHECK([whether we need POSIX to get struct utimbuf],
6 guile_cv_struct_utimbuf_needs_posix,
7 [AC_TRY_CPP([
8 #ifdef __EMX__
9 #include <sys/utime.h>
10 #else
11 #include <utime.h>
12 #endif
13 struct utime blah;
14 ],
15 guile_cv_struct_utimbuf_needs_posix=no,
16 guile_cv_struct_utimbuf_needs_posix=yes)])
17 if test "$guile_cv_struct_utimbuf_needs_posix" = yes; then
18 AC_DEFINE(UTIMBUF_NEEDS_POSIX)
19 fi])
20
21
22
23
24 dnl
25 dnl Apparently, at CMU they have a weird version of libc.h that is
26 dnl installed in /usr/local/include and conflicts with unistd.h.
27 dnl In these situations, we should not #include libc.h.
28 dnl This test arranges to #define LIBC_H_WITH_UNISTD_H iff libc.h is
29 dnl present on the system, and is safe to #include.
30 dnl
31 AC_DEFUN([GUILE_HEADER_LIBC_WITH_UNISTD],
32 [
33 AC_CHECK_HEADERS(libc.h unistd.h)
34 AC_CACHE_CHECK(
35 "whether libc.h and unistd.h can be included together",
36 guile_cv_header_libc_with_unistd,
37 [
38 if test "$ac_cv_header_libc_h" = "no"; then
39 guile_cv_header_libc_with_unistd="no"
40 elif test "$ac_cv_header_unistd.h" = "no"; then
41 guile_cv_header_libc_with_unistd="yes"
42 else
43 AC_TRY_COMPILE(
44 [
45 # include <libc.h>
46 # include <unistd.h>
47 ],
48 [],
49 [guile_cv_header_libc_with_unistd=yes],
50 [guile_cv_header_libc_with_unistd=no]
51 )
52 fi
53 ]
54 )
55 if test "$guile_cv_header_libc_with_unistd" = yes; then
56 AC_DEFINE(LIBC_H_WITH_UNISTD_H)
57 fi
58 ]
59 )
60
61
62
63 dnl This is needed when we want to check for the same function repeatedly
64 dnl with other parameters, such as libraries, varying.
65 dnl
66 dnl GUILE_NAMED_CHECK_FUNC(FUNCTION, TESTNAME,
67 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
68 AC_DEFUN(GUILE_NAMED_CHECK_FUNC,
69 [AC_MSG_CHECKING([for $1])
70 AC_CACHE_VAL(ac_cv_func_$1_$2,
71 [AC_TRY_LINK(
72 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
73 dnl which includes <sys/select.h> which contains a prototype for
74 dnl select. Similarly for bzero.
75 [/* System header to define __stub macros and hopefully few prototypes,
76 which can conflict with char $1(); below. */
77 #include <assert.h>
78 /* Override any gcc2 internal prototype to avoid an error. */
79 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
80 extern "C"
81 #endif
82 ])dnl
83 [/* We use char because int might match the return type of a gcc2
84 builtin and then its argument prototype would still apply. */
85 char $1();
86 ], [
87 /* The GNU C library defines this for functions which it implements
88 to always fail with ENOSYS. Some functions are actually named
89 something starting with __ and the normal name is an alias. */
90 #if defined (__stub_$1) || defined (__stub___$1)
91 choke me
92 #else
93 $1();
94 #endif
95 ], eval "ac_cv_func_$1_$2=yes", eval "ac_cv_func_$1_$2=no")])
96 if eval "test \"`echo '$ac_cv_func_'$1'_'$2`\" = yes"; then
97 AC_MSG_RESULT(yes)
98 ifelse([$3], , :, [$3])
99 else
100 AC_MSG_RESULT(no)
101 ifelse([$4], , , [$4
102 ])dnl
103 fi
104 ])
105
106
107
108 dnl Check checks whether dlsym (if present) requires a leading underscore.
109 dnl Written by Dan Hagerty <hag@ai.mit.edu> for scsh-0.5.0.
110 AC_DEFUN(GUILE_DLSYM_USCORE, [
111 AC_MSG_CHECKING(for underscore before symbols)
112 AC_CACHE_VAL(guile_cv_uscore,[
113 echo "main(){int i=1;}
114 fnord(){int i=23; int ltuae=42;}" > conftest.c
115 ${CC} conftest.c > /dev/null
116 if (nm a.out | grep _fnord) > /dev/null; then
117 guile_cv_uscore=yes
118 else
119 guile_cv_uscore=no
120 fi])
121 AC_MSG_RESULT($guile_cv_uscore)
122 rm -f conftest.c a.out
123
124 if test $guile_cv_uscore = yes; then
125 AC_DEFINE(USCORE)
126
127 if test $ac_cv_func_dlopen = yes -o $ac_cv_lib_dl_dlopen = yes ; then
128 AC_MSG_CHECKING(whether dlsym always adds an underscore for us)
129 AC_CACHE_VAL(guile_cv_dlsym_adds_uscore,AC_TRY_RUN( [
130 #include <dlfcn.h>
131 #include <stdio.h>
132 fnord() { int i=42;}
133 main() { void *self, *ptr1, *ptr2; self=dlopen(NULL,RTLD_LAZY);
134 if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
135 if(ptr1 && !ptr2) exit(0); } exit(1); }
136 ], [guile_cv_dlsym_adds_uscore=yes
137 AC_DEFINE(DLSYM_ADDS_USCORE) ], guile_cv_dlsym_adds_uscore=no,
138 guile_cv_dlsym_adds_uscore=no))
139
140 AC_MSG_RESULT($guile_cv_dlsym_adds_uscore)
141 fi
142 fi
143 ])