Clean up thread configuration.
[bpt/guile.git] / configure.in
1 dnl Process this file with autoconf to produce configure.
2 AC_INIT(Makefile.in)
3 . $srcdir/GUILE-VERSION
4 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
5 AM_MAINTAINER_MODE
6 AM_CONFIG_HEADER(libguile/scmconfig.h)
7
8 #--------------------------------------------------------------------
9 #
10 # User options
11 #
12 #--------------------------------------------------------------------
13
14 AC_ARG_ENABLE(debug,
15 [ --disable-debug Don't include debugging support])
16 if test "$enableval" != n && test "$enableval" != no; then
17 AC_DEFINE(DEBUG_EXTENSIONS)
18 AC_DEFINE(READER_EXTENSIONS)
19 LIBOBJS="backtrace.o stacks.o debug.o srcprop.o $LIBOBJS"
20 fi
21
22 AC_ARG_ENABLE(dynamic-linking,
23 [ --enable-dynamic-linking Include support for dynamic linking],,
24 enable_dynamic_linking=yes)
25
26 AC_ARG_ENABLE(guile-debug,
27 [ --enable-guile-debug Include internal debugging functions])
28 if test "$enableval" = y || test "$enableval" = yes; then
29 AC_DEFINE(GUILE_DEBUG)
30 fi
31
32 #--------------------------------------------------------------------
33
34 AC_PROG_CC
35 AC_PROG_CPP
36 AM_PROG_LIBTOOL
37
38 AC_AIX
39 AC_ISC_POSIX
40 AC_MINIX
41
42 AC_C_CONST
43
44 AC_HEADER_STDC
45 AC_HEADER_DIRENT
46 AC_HEADER_TIME
47 AC_HEADER_SYS_WAIT
48 AC_CHECK_HEADERS(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)
49 GUILE_HEADER_LIBC_WITH_UNISTD
50
51 AC_TYPE_GETGROUPS
52 AC_TYPE_SIGNAL
53 AC_TYPE_MODE_T
54
55 AC_CHECK_LIB(m, main)
56 AC_CHECK_FUNCS(gethostbyname)
57 if test $ac_cv_func_gethostbyname = no; then
58 AC_CHECK_LIB(nsl, gethostbyname)
59 fi
60 AC_CHECK_FUNCS(connect)
61 if test $ac_cv_func_connect = no; then
62 AC_CHECK_LIB(socket, connect)
63 fi
64 AC_CHECK_LIB(termcap, tgoto)
65 AC_CHECK_LIB(readline, readline)
66 AC_CHECK_FUNCS(rl_getc_function rl_clear_signals rl_cleanup_after_signal)
67 if test $ac_cv_lib_readline_readline = yes -a $ac_cv_func_rl_getc_function = no; then
68 echo 'Warning: libreadline is too old on your system. Need >= 2.1.'
69 fi
70
71 # The following test defines TOTORO if we're configuring on
72 # totoro.red-bean.com. For some etheric reason, totoro refuses to
73 # perform the test for presence of rl_getc_function in libreadline
74 # correctly. This variable is used in a workaround which forces
75 # totoro to include readline support regardless. This kludge should
76 # obviously be removed as fast as possible.
77
78 AC_CHECK_PROG(PROG_HOSTNAME, hostname, hostname)
79 if test "$PROG_HOSTNAME" = hostname; then
80 if test "`hostname`" = totoro.red-bean.com; then
81 AC_DEFINE(TOTORO)
82 fi
83 fi
84
85 # Checks for dynamic linking
86
87 if test "$enable_dynamic_linking" = "yes"; then
88
89 AC_CHECK_LIB(dl,dlopen)
90 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
91 AC_CHECK_FUNCS(dlopen)
92 AC_DEFINE(DYNAMIC_LINKING)
93 else
94 AC_CHECK_LIB(dld,dld_link)
95 if test "$ac_cv_lib_dld_dld_link" = "yes"; then
96 AC_DEFINE(DYNAMIC_LINKING)
97 else
98 AC_CHECK_FUNCS(shl_load)
99 if test "$ac_cv_func_shl_load" = "yes"; then
100 AC_DEFINE(DYNAMIC_LINKING)
101 else
102 AC_CHECK_FUNCS(dlopen)
103 if test "$ac_cv_func_dlopen" = "yes"; then
104 AC_DEFINE(DYNAMIC_LINKING)
105 fi
106 fi
107 fi
108 fi
109
110 fi
111
112 GUILE_DLSYM_USCORE
113
114 AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gethostent gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep)
115
116 # Determine the host we are working on
117 AC_CANONICAL_HOST
118
119 # Some operating systems don't declare all functions
120 case "$host_os" in
121 solaris2.5*)
122 AC_DEFINE(DECLARE_BZERO)
123 AC_DEFINE(DECLARE_USLEEP)
124 ;;
125 esac
126
127 # On some systems usleep has no return value
128 AC_EGREP_HEADER(changequote(<, >)<void[ ][ ]*usleep>changequote([, ]),
129 /usr/include/unistd.h,
130 AC_DEFINE(USLEEP_RETURNS_VOID)
131 )
132
133
134 dnl <GNU-WIN32 hacks>
135
136 AC_CHECK_HEADER(sys/un.h, have_sys_un_h=1)
137 if test -n "$have_sys_un_h" ; then
138 AC_DEFINE(HAVE_UNIX_DOMAIN_SOCKETS)
139 fi
140
141 AC_CHECK_FUNCS(socketpair getgroups setpwent pause tzset)
142
143 dnl I don't know what this prefixing of cygwin32_ is for.
144 dnl scmconfig.h wasn't updated with the test results.
145 dnl so use AC_CHECK_FUNCS for now.
146
147 dnl how about:
148 dnl save confdefs.h
149 dnl if test $ac_cv_cigwin = yes; then
150 dnl modify confdefs.h
151 dnl fi
152 dnl AC_CHECK_FUNCS...
153 dnl restore confdefs.h
154
155 dnl cp confdefs.h confdefs.h.bak
156 dnl for func in sethostent endhostent getnetent setnetent endnetent getprotoent endprotoent getservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof ; do
157 dnl cp confdefs.h.bak confdefs.h
158 dnl cat >> confdefs.h << EOF
159 dnl #ifdef __CYGWIN32__
160 dnl #define $func cygwin32_$func
161 dnl #endif
162 dnl EOF
163 dnl AC_CHECK_FUNC($func)
164 dnl done
165 dnl cp confdefs.h.bak confdefs.h
166
167 AC_CHECK_FUNCS(sethostent endhostent getnetent setnetent endnetent getprotoent endprotoent getservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof)
168
169 dnl </GNU-WIN32 hacks>
170
171 AC_CACHE_CHECK([for restartable system calls], scm_cv_restarts,
172 if test $ac_cv_func_sigaction = yes; then
173 [AC_TRY_COMPILE([#include <signal.h>],
174 [int a = SA_RESTART],
175 scm_cv_restarts=yes,
176 scm_cv_restarts=no)]
177 else
178 scm_cv_restarts=no
179 fi)
180 if test $scm_cv_restarts = yes; then
181 AC_DEFINE(HAVE_RESTARTS)
182 fi
183
184 if test "$ac_cv_header_regex_h" = yes ||
185 test "$ac_cv_header_rxposix_h" = yes ||
186 test "$ac_cv_header_rx_rxposix_h" = yes; then
187 GUILE_NAMED_CHECK_FUNC(regcomp, norx, [LIBOBJS="regex-posix.o $LIBOBJS"],
188 [AC_CHECK_LIB(rx, main)
189 GUILE_NAMED_CHECK_FUNC(regcomp, rx, [LIBOBJS="regex-posix.o $LIBOBJS"])]
190 )
191 dnl The following should not be necessary, but for some reason
192 dnl autoheader misses it if we don't include it!
193 if test "$ac_cv_func_regcomp_norx" = yes ||
194 test "$ac_cv_func_regcomp_rx" = yes; then
195 AC_DEFINE(HAVE_REGCOMP)
196 fi
197 fi
198
199 AC_REPLACE_FUNCS(inet_aton putenv strerror)
200
201 # When testing for the presence of alloca, we need to add alloca.o
202 # explicitly to LIBOBJS to make sure that it is translated to
203 # `alloca.lo' for libtool later on. This can and should be done more cleanly.
204 AC_FUNC_ALLOCA
205 if test "$ALLOCA" = "alloca.o"; then LIBOBJS="alloca.o $LIBOBJS"; fi
206
207 AC_STRUCT_ST_RDEV
208 AC_STRUCT_ST_BLKSIZE
209
210 # We could use AC_STRUCT_ST_BLOCKS here, but that adds fileblocks.o to
211 # LIBOBJS, which we don't need. This seems more direct.
212 AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
213 [AC_TRY_COMPILE([#include <sys/types.h>
214 #include <sys/stat.h>], [struct stat s; s.st_blocks;],
215 ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
216 if test $ac_cv_struct_st_blocks = yes; then
217 AC_DEFINE(HAVE_ST_BLOCKS)
218 fi
219
220 AC_STRUCT_TIMEZONE
221 GUILE_STRUCT_UTIMBUF
222
223 #--------------------------------------------------------------------
224 #
225 # Which way does the stack grow?
226 #
227 #--------------------------------------------------------------------
228
229 AC_TRY_RUN(aux (l) unsigned long l;
230 { int x; exit (l >= ((unsigned long)&x)); }
231 main () { int q; aux((unsigned long)&q); },
232 AC_DEFINE(SCM_STACK_GROWS_UP),,AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h.in))
233
234
235 AC_TRY_RUN(main () { exit (sizeof(float) != sizeof(long)); },
236 AC_DEFINE(SCM_SINGLES),,AC_DEFINE(SCM_SINGLES)
237 AC_MSG_WARN(Guessing that sizeof(long) == sizeof(float) -- see scmconfig.h.in))
238
239 AC_MSG_CHECKING(for struct linger)
240 AC_CACHE_VAL(scm_cv_struct_linger,
241 AC_TRY_COMPILE([
242 #include <sys/types.h>
243 #include <sys/socket.h>],
244 [struct linger lgr; lgr.l_linger = 100],
245 scm_cv_struct_linger="yes",
246 scm_cv_struct_linger="no"))
247 AC_MSG_RESULT($scm_cv_struct_linger)
248 if test $scm_cv_struct_linger = yes; then
249 AC_DEFINE(HAVE_STRUCT_LINGER)
250 fi
251
252 #--------------------------------------------------------------------
253 #
254 # How can you violate a stdio abstraction by setting a stream's fd?
255 #
256 #--------------------------------------------------------------------
257
258 AC_MSG_CHECKING(how to set a stream file descriptor)
259 AC_CACHE_VAL(scm_cv_fd_setter,
260 AC_TRY_COMPILE([#include <stdio.h>],
261 [stdout->_file = 1],
262 scm_cv_fd_setter="_file",
263 AC_TRY_COMPILE([#include <stdio.h>],
264 [stdout->_fileno = 1],
265 scm_cv_fd_setter="_fileno",
266 scm_cv_fd_setter="")))
267
268 if test "$scm_cv_fd_setter"; then
269 AC_MSG_RESULT($scm_cv_fd_setter)
270 AC_DEFINE_UNQUOTED(FD_SETTER, $scm_cv_fd_setter)
271 else
272 AC_MSG_RESULT(we couldn't do it!)
273 fi
274
275 #--------------------------------------------------------------------
276 # How to find out whether a FILE structure contains buffered data.
277 # From Tk we have the following list:
278 # _cnt: Most UNIX systems
279 # __cnt: HPUX
280 # _r: BSD
281 # readCount: Sprite
282 # Or, in GNU libc there are two fields, _gptr and _egptr, which
283 # have to be compared.
284 # These can also be known as _IO_read_ptr and _IO_read_end.
285 #--------------------------------------------------------------------
286
287 AC_MSG_CHECKING(how to get buffer char count from FILE structure)
288 AC_CACHE_VAL(scm_cv_struct_file_count,
289 AC_TRY_COMPILE([#include <stdio.h>],
290 [FILE *f = stdin; f->_cnt = 0],
291 scm_cv_struct_file_count="_cnt",
292 AC_TRY_COMPILE([#include <stdio.h>],
293 [FILE *f = stdin; f->_r = 0],
294 scm_cv_struct_file_count="_r",
295 AC_TRY_COMPILE([#include <stdio.h>],
296 [FILE *f = stdin; f->readCount = 0],
297 scm_cv_struct_file_count="readCount",
298 scm_cv_struct_file_count=""))))
299 if test "$scm_cv_struct_file_count"; then
300 AC_MSG_RESULT($scm_cv_struct_file_count)
301 AC_DEFINE_UNQUOTED(FILE_CNT_FIELD, $scm_cv_struct_file_count)
302 else
303 AC_CACHE_VAL(scm_cv_struct_file_gptr,
304 AC_TRY_COMPILE([#include <stdio.h>],
305 [FILE *f = stdin; f->_gptr = f->egptr;],
306 scm_cv_struct_file_gptr=1,
307 scm_cv_struct_file_gptr=""))
308 if test "$scm_cv_struct_gptr"; then
309 AC_MSG_RESULT(gptr)
310 AC_DEFINE_UNQUOTED(FILE_CNT_GPTR, $scm_cv_struct_file_gptr)
311 else
312 AC_CACHE_VAL(scm_cv_struct_file_readptr,
313 AC_TRY_COMPILE([#include <stdio.h>],
314 [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;],
315 scm_cv_struct_file_readptr=1))
316 if test "$scm_cv_struct_file_readptr"; then
317 AC_MSG_RESULT(read_ptr)
318 AC_DEFINE_UNQUOTED(FILE_CNT_READPTR, $scm_cv_struct_file_readptr)
319 else
320 AC_MSG_RESULT(we couldn't do it!)
321 fi
322 fi
323 fi
324
325 #--------------------------------------------------------------------
326 #
327 # Flags for thread support
328 #
329 #--------------------------------------------------------------------
330
331 ### What thread package has the user asked for?
332 AC_ARG_WITH(threads, [ --with-threads thread interface],
333 , with_threads=no)
334
335 ### Turn $with_threads into either the name of a threads package, like
336 ### `qt', or `no', meaning that threads should not be supported.
337 case "$with_threads" in
338 "yes" | "qt" | "coop" | "")
339 with_threads=qt
340 ;;
341 "no" )
342 ;;
343 * )
344 AC_MSG_ERROR(invalid value for --with-threads: $with_threads)
345 ;;
346 esac
347
348 ## Make sure the threads package we've chosen is actually supported on
349 ## the present platform.
350 case "${with_threads}" in
351 "qt" )
352 ## This configures the QuickThreads package, and sets or clears
353 ## the THREAD_PACKAGE variable if qthreads don't configure
354 ## correctly.
355 QTHREADS_CONFIGURE
356 ;;
357 esac
358
359 ## If we're using threads, bring in some other parts of Guile which
360 ## work with them.
361 if test "${THREAD_PACKAGE}" != "" ; then
362 AC_DEFINE(USE_THREADS, 1)
363
364 ## Include the Guile thread interface in the library...
365 LIBOBJS="$LIBOBJS threads.o"
366
367 ## ... and tell it which package to talk to.
368 case "${THREAD_PACKAGE}" in
369 "QT" )
370 AC_DEFINE(USE_COOP_THREADS, 1)
371 ;;
372 * )
373 AC_MSG_ERROR(invalid value for THREAD_PACKAGE: ${THREAD_PACKAGE})
374 ;;
375 esac
376
377 ## Bring in scm_internal_select, if appropriate.
378 if test $ac_cv_func_gettimeofday = yes &&
379 test $ac_cv_func_select = yes; then
380 LIBOBJS="$LIBOBJS iselect.o"
381 AC_DEFINE(GUILE_ISELECT, 1)
382 fi
383 fi
384
385 ## If we're using GCC, ask for aggressive warnings.
386 case "$GCC" in
387 yes ) CFLAGS="$CFLAGS -Wall -Wpointer-arith" ;;
388 esac
389
390 AC_PROG_AWK
391
392 ## If we're creating a shared library (using libtool!), then we'll
393 ## need to generate a list of .lo files corresponding to the .o files
394 ## given in LIBOBJS. We'll call it LIBLOBJS.
395 LIBLOBJS="`echo ${LIBOBJS} | sed 's/\.o/.lo/g'`"
396
397 AC_SUBST(GUILE_MAJOR_VERSION)
398 AC_SUBST(GUILE_MINOR_VERSION)
399 AC_SUBST(GUILE_VERSION)
400
401 dnl Tell build-guile what flags guile users should link against.
402 GUILE_LIBS="$LDFLAGS $THREAD_LIBS_INSTALLED $LIBS"
403 AC_SUBST(GUILE_LIBS)
404
405 dnl timestamping the interpreter and scheme libraries:
406 dnl
407 dnl Help us notice when we're running one version of the Guile
408 dnl interpreter against a different version of the ice-9 Scheme code.
409 dnl This will definitely detect version skew due to differing
410 dnl snapshots and releases, but may not catch skew for the developers.
411 dnl Hopefully it will not detect skew when there is none; if that
412 dnl happens, the warnings will be useless, and we should remove this.
413 GUILE_STAMP="`date`"
414 AC_SUBST(GUILE_STAMP)
415
416 AC_SUBST(AWK)
417 AC_SUBST(LIBLOBJS)
418
419 AC_OUTPUT([Makefile libguile/Makefile libguile/guile-snarf ice-9/Makefile ice-9/version.scm qt/Makefile qt/qt.h qt/md/Makefile qt/time/Makefile build/Makefile], [chmod +x libguile/guile-snarf])
420
421 dnl Local Variables:
422 dnl comment-start: "dnl "
423 dnl comment-end: ""
424 dnl comment-start-skip: "\\bdnl\\b\\s *"
425 dnl End: