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