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