* socket.c (scm_fill_sockaddr): zero the address structure before
[bpt/guile.git] / acinclude.m4
CommitLineData
3a629497
JB
1dnl On the NeXT, #including <utime.h> doesn't give you a definition for
2dnl struct utime, unless you #define _POSIX_SOURCE.
3
4AC_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
13struct 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
24dnl
25dnl Apparently, at CMU they have a weird version of libc.h that is
26dnl installed in /usr/local/include and conflicts with unistd.h.
27dnl In these situations, we should not #include libc.h.
28dnl This test arranges to #define LIBC_H_WITH_UNISTD_H iff libc.h is
29dnl present on the system, and is safe to #include.
30dnl
31AC_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"
42d0ffc9 40 elif test "$ac_cv_header_unistd_h" = "no"; then
3a629497
JB
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)
0b89e78e
MD
60
61
62
63dnl This is needed when we want to check for the same function repeatedly
64dnl with other parameters, such as libraries, varying.
65dnl
66dnl GUILE_NAMED_CHECK_FUNC(FUNCTION, TESTNAME,
67dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
68AC_DEFUN(GUILE_NAMED_CHECK_FUNC,
69[AC_MSG_CHECKING([for $1])
70AC_CACHE_VAL(ac_cv_func_$1_$2,
71[AC_TRY_LINK(
72dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
73dnl which includes <sys/select.h> which contains a prototype for
74dnl 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
80extern "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. */
85char $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)
91choke me
92#else
93$1();
94#endif
95], eval "ac_cv_func_$1_$2=yes", eval "ac_cv_func_$1_$2=no")])
96if eval "test \"`echo '$ac_cv_func_'$1'_'$2`\" = yes"; then
97 AC_MSG_RESULT(yes)
98 ifelse([$3], , :, [$3])
99else
100 AC_MSG_RESULT(no)
101ifelse([$4], , , [$4
102])dnl
103fi
104])
2a0d7176
TP
105
106
107
108dnl Check checks whether dlsym (if present) requires a leading underscore.
109dnl Written by Dan Hagerty <hag@ai.mit.edu> for scsh-0.5.0.
110AC_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>
132fnord() { int i=42;}
133main() { 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
774b7f22
TP
137 AC_DEFINE(DLSYM_ADDS_USCORE) ], guile_cv_dlsym_adds_uscore=no,
138 guile_cv_dlsym_adds_uscore=no))
2a0d7176
TP
139
140 AC_MSG_RESULT($guile_cv_dlsym_adds_uscore)
141 fi
142 fi
143])
eb9ef08b
MD
144
145dnl QTHREADS_CONFIGURE configures the QuickThreads package. The QT
146dnl sources should be in $srcdir/qt. If configuration succeeds, this
147dnl macro creates the appropriate symlinks in the qt object directory,
148dnl and sets the following variables, used in building libqthreads.a:
149dnl QTHREAD_LTLIBS --- set to libqthreads.la if configuration
150dnl succeeds, or the empty string if configuration fails.
151dnl qtmd_h, qtmds_s, qtmdc_c, qtdmdb_s --- the names of the machine-
152dnl dependent source files.
153dnl qthread_asflags --- flags to pass to the compiler when processing
154dnl assembly-language files.
155dnl
156dnl It also sets the following variables, which describe how clients
157dnl can link against libqthreads.a:
158dnl THREAD_PACKAGE --- set to "QT" if configuration succeeds, or
159dnl the empty string if configuration fails.
160dnl THREAD_CPPFLAGS --- set to `-I' flags for thread header files
161dnl THREAD_LIBS_LOCAL --- linker options for use in this source tree
162dnl THREAD_LIBS_INSTALLED --- linker options for use after this package
163dnl is installed
164dnl It would be nice if all thread configuration packages for Guile
165dnl followed the same conventions.
166dnl
167dnl All of the above variables will be substituted into Makefiles in
168dnl the usual autoconf fashion.
169dnl
170dnl We distinguish between THREAD_LIBS_LOCAL and
171dnl THREAD_LIBS_INSTALLED because the thread library might be in
172dnl this tree, and be built using libtool. This means that:
173dnl 1) when building other executables in this tree, one must
174dnl pass the relative path to the ../libfoo.la file, but
175dnl 2) once the whole package has been installed, users should
176dnl link using -lfoo.
177dnl Normally, we only care about the first case, but since the
178dnl guile-config script needs to give users all the flags they need
179dnl to link programs against guile, the GUILE_WITH_THREADS macro
180dnl needs to supply the second piece of information as well.
181dnl
182dnl This whole thing is a little confused about what ought to be
183dnl done in the top-level configure script, and what ought to be
184dnl taken care of in the subdirectory. For example, qtmds_s and
185dnl friends really ought not to be even mentioned in the top-level
186dnl configure script, but here they are.
187
188AC_DEFUN([QTHREADS_CONFIGURE],[
189 AC_REQUIRE([AC_PROG_LN_S])
190
191 AC_MSG_CHECKING(QuickThreads configuration)
192 # How can we refer to the qt source directory from within the qt build
193 # directory? For headers, we can rely on the fact that the qt src
194 # directory appears in the #include path.
195 qtsrcdir="`(cd $srcdir; pwd)`/qt"
196
197 changequote(,)dnl We use [ and ] in a regexp in the case
198
199 THREAD_PACKAGE=QT
200 qthread_asflags=''
201 case "$host" in
202 i[3456]86-*-*)
203 port_name=i386
204 qtmd_h=md/i386.h
205 qtmds_s=md/i386.s
206 qtmdc_c=md/null.c
207 qtdmdb_s=
208 case "$host" in
209 *-*-netbsd* )
210 ## NetBSD needs to be told to pass the assembly code through
211 ## the C preprocessor. Other GCC installations seem to do
212 ## this by default, but NetBSD's doesn't. We could get the
213 ## same effect by giving the file a name ending with .S
214 ## instead of .s, but I don't see how to tell automake to do
215 ## that.
216 qthread_asflags='-x assembler-with-cpp'
217 ;;
218 esac
219 ;;
220 mips-sgi-irix[56]*)
221 port_name=irix
222 qtmd_h=md/mips.h
223 qtmds_s=md/mips-irix5.s
224 qtmdc_c=md/null.c
225 qtdmdb_s=md/mips_b.s
226 ;;
227 mips-*-*)
228 port_name=mips
229 qtmd_h=md/mips.h
230 qtmds_s=md/mips.s
231 qtmdc_c=md/null.c
232 qtdmdb_s=md/mips_b.s
233 ;;
234 sparc-*-sunos*)
235 port_name=sparc-sunos
236 qtmd_h=md/sparc.h
237 qtmds_s=md/_sparc.s
238 qtmdc_c=md/null.c
239 qtdmdb_s=md/_sparc_b.s
240 ;;
241 sparc-*-*)
242 port_name=sparc
243 qtmd_h=md/sparc.h
244 qtmds_s=md/sparc.s
245 qtmdc_c=md/null.c
246 qtdmdb_s=md/sparc_b.s
247 ;;
6f9f0fb9 248 alpha*-*-*)
eb9ef08b
MD
249 port_name=alpha
250 qtmd_h=md/axp.h
251 qtmds_s=md/axp.s
252 qtmdc_c=md/null.c
253 qtdmdb_s=md/axp_b.s
254 ;;
255 *)
256 echo "Unknown configuration; threads package disabled"
257 THREAD_PACKAGE=""
258 ;;
259 esac
260 changequote([, ])
261
262 # Did configuration succeed?
263 if test -n "$THREAD_PACKAGE"; then
264 AC_MSG_RESULT($port_name)
265 QTHREAD_LTLIBS=libqthreads.la
266 THREAD_CPPFLAGS="-I$qtsrcdir -I../qt"
267 THREAD_LIBS_LOCAL="../qt/libqthreads.la"
268 THREAD_LIBS_INSTALLED="-lqthreads"
269 else
270 AC_MSG_RESULT(none; disabled)
271 fi
272
273 AC_SUBST(QTHREAD_LTLIBS)
274 AC_SUBST(qtmd_h)
275 AC_SUBST(qtmds_s)
276 AC_SUBST(qtmdc_c)
277 AC_SUBST(qtdmdb_s)
278 AC_SUBST(qthread_asflags)
279 AC_SUBST(THREAD_PACKAGE)
280 AC_SUBST(THREAD_CPPFLAGS)
281 AC_SUBST(THREAD_LIBS_LOCAL)
282 AC_SUBST(THREAD_LIBS_INSTALLED)
283])