* configure.in: check for hstrerror.
[bpt/guile.git] / configure.in
CommitLineData
777b022a
JB
1dnl configuration script for Guile
2dnl Process this file with autoconf to produce configure.
50848747 3dnl
2adc1dd3 4dnl Copyright (C) 1998, 1999 Free Software Foundation, Inc.
50848747
JB
5dnl
6dnl This file is part of GUILE
7dnl
8dnl GUILE is free software; you can redistribute it and/or modify it
9dnl under the terms of the GNU General Public License as published by
10dnl the Free Software Foundation; either version 2, or (at your
11dnl option) any later version.
12dnl
13dnl GUILE is distributed in the hope that it will be useful, but
14dnl WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16dnl General Public License for more details.
17dnl
18dnl You should have received a copy of the GNU General Public License
19dnl along with GUILE; see the file COPYING. If not, write to the
20dnl Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21dnl Boston, MA 02111-1307, USA.
22
0f2d19dd 23AC_INIT(Makefile.in)
2d26def0 24. $srcdir/GUILE-VERSION
3a629497 25AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
15ae1bee 26AM_MAINTAINER_MODE
3a629497 27AM_CONFIG_HEADER(libguile/scmconfig.h)
2d26def0 28
3a629497 29#--------------------------------------------------------------------
0e8a8468
MV
30#
31# Independent Subdirectories
32#
33#--------------------------------------------------------------------
34
35AC_CONFIG_SUBDIRS(guile-readline)
36
37#--------------------------------------------------------------------
3a629497
JB
38#
39# User options
40#
41#--------------------------------------------------------------------
86789f9b 42
3a629497 43AC_ARG_ENABLE(dynamic-linking,
52cfc69b 44 [ --enable-dynamic-linking include support for dynamic linking],,
af8865f7 45 enable_dynamic_linking=yes)
3a629497
JB
46
47AC_ARG_ENABLE(guile-debug,
52cfc69b 48 [ --enable-guile-debug include internal debugging functions],
7a11a87c
MD
49 if test "$enable_guile_debug" = y || test "$enable_guile_debug" = yes; then
50 AC_DEFINE(GUILE_DEBUG)
51 fi)
52
52b3923a
GB
53AC_ARG_ENABLE(debug-freelist,
54 [ --enable-debug-freelist Include garbage collector freelist debugging code],
55 if test "$enable_debug_freelist" = y || test "$enable_debug_freelist" = yes; then
fca7547b 56 AC_DEFINE(GUILE_DEBUG_FREELIST)
52b3923a
GB
57 fi)
58
52cfc69b
GH
59AC_ARG_ENABLE(posix,
60 [ --disable-posix omit posix interfaces],,
61 enable_posix=yes)
62
63AC_ARG_ENABLE(networking,
64 [ --disable-net omit networking interfaces],,
65 enable_networking=yes)
66
67AC_ARG_ENABLE(regex,
68 [ --disable-regex omit regular expression interfaces],,
69 enable_regex=yes)
70
c176b92b
JB
71dnl The --disable-debug used to control these two. But now they are
72dnl a required part of the distribution.
73AC_DEFINE(DEBUG_EXTENSIONS)
74AC_DEFINE(READER_EXTENSIONS)
75
52cfc69b
GH
76dnl files which are destined for separate modules.
77
78if test "$enable_posix" = yes; then
79 LIBOBJS="$LIBOBJS filesys.o posix.o"
80 AC_DEFINE(HAVE_POSIX)
81fi
82
83if test "$enable_networking" = yes; then
84 LIBOBJS="$LIBOBJS net_db.o socket.o"
85 AC_DEFINE(HAVE_NETWORKING)
86fi
87
3a629497
JB
88#--------------------------------------------------------------------
89
90AC_PROG_CC
91AC_PROG_CPP
3a629497
JB
92
93AC_AIX
94AC_ISC_POSIX
95AC_MINIX
96
e40ffcb6 97AM_PROG_CC_STDC
9da7f717 98AM_PROG_LIBTOOL
e40ffcb6 99
3a629497 100AC_C_CONST
5e9345c3 101AC_C_INLINE
9dec9737
MD
102AC_CHECK_SIZEOF(int)
103AC_CHECK_SIZEOF(long)
104AC_CACHE_CHECK([for long longs], scm_cv_long_longs,
105 AC_TRY_COMPILE(,
106 [long long a],
107 scm_cv_long_longs=yes,
108 scm_cv_long_longs=no))
109if test "$scm_cv_long_longs" = yes; then
110 AC_DEFINE(HAVE_LONG_LONGS)
111fi
3a629497
JB
112
113AC_HEADER_STDC
114AC_HEADER_DIRENT
115AC_HEADER_TIME
116AC_HEADER_SYS_WAIT
2adc1dd3 117AC_CHECK_HEADERS(io.h 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
118GUILE_HEADER_LIBC_WITH_UNISTD
119
120AC_TYPE_GETGROUPS
121AC_TYPE_SIGNAL
122AC_TYPE_MODE_T
123
5852c051 124AC_CHECK_LIB(m, main)
4c787b52 125AC_CHECK_FUNCS(gethostbyname)
5852c051
JB
126if test $ac_cv_func_gethostbyname = no; then
127 AC_CHECK_LIB(nsl, gethostbyname)
128fi
4c787b52 129AC_CHECK_FUNCS(connect)
5852c051
JB
130if test $ac_cv_func_connect = no; then
131 AC_CHECK_LIB(socket, connect)
132fi
5ee74cec 133
90fcac06
JB
134# Checks for dynamic linking
135
5852c051
JB
136if test "$enable_dynamic_linking" = "yes"; then
137
138AC_CHECK_LIB(dl,dlopen)
139if test "$ac_cv_lib_dl_dlopen" = "yes"; then
4c787b52 140 AC_CHECK_FUNCS(dlopen)
5852c051
JB
141 AC_DEFINE(DYNAMIC_LINKING)
142else
143AC_CHECK_LIB(dld,dld_link)
144if test "$ac_cv_lib_dld_dld_link" = "yes"; then
5852c051
JB
145 AC_DEFINE(DYNAMIC_LINKING)
146else
4c787b52 147AC_CHECK_FUNCS(shl_load)
5852c051
JB
148if test "$ac_cv_func_shl_load" = "yes"; then
149 AC_DEFINE(DYNAMIC_LINKING)
a4995389 150else
4c787b52 151AC_CHECK_FUNCS(dlopen)
a4995389
MV
152if test "$ac_cv_func_dlopen" = "yes"; then
153 AC_DEFINE(DYNAMIC_LINKING)
154fi
5852c051
JB
155fi
156fi
157fi
158
159fi
160
2a0d7176 161GUILE_DLSYM_USCORE
5852c051 162
7ee92fce 163AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit)
64e121dc 164
777b022a
JB
165### Some systems don't declare some functions. On such systems, we
166### need to at least provide our own K&R-style declarations.
167
168### GUILE_FUNC_DECLARED(function, headerfile)
169
170### Check for a declaration of FUNCTION in HEADERFILE; if it is
171### not there, #define MISSING_FUNCTION_DECL.
172AC_DEFUN(GUILE_FUNC_DECLARED, [
fc342a63 173 AC_CACHE_CHECK(for $1 declaration, guile_cv_func_$1_declared,
777b022a 174 AC_EGREP_HEADER($1, $2,
fc342a63
JB
175 guile_cv_func_$1_declared=yes,
176 guile_cv_func_$1_declared=no))
177 if test [x$guile_cv_func_]$1[_declared] = xno; then
777b022a
JB
178 AC_DEFINE([MISSING_]translit($1, [a-z], [A-Z])[_DECL])
179 fi
180])
181
182GUILE_FUNC_DECLARED(strptime, time.h)
183GUILE_FUNC_DECLARED(bzero, string.h)
c31bfb85 184GUILE_FUNC_DECLARED(sleep, unistd.h)
777b022a 185GUILE_FUNC_DECLARED(usleep, unistd.h)
e1a191a8 186
da753252
JB
187### On some systems usleep has no return value. If it does have one,
188### we'd like to return it; otherwise, we'll fake it.
fc342a63 189AC_CACHE_CHECK([return type of usleep], guile_cv_func_usleep_return_type,
c43f86c1 190 [AC_EGREP_HEADER(changequote(<, >)<void[ ]+usleep>changequote([, ]),
fc342a63
JB
191 /usr/include/unistd.h,
192 [guile_cv_func_usleep_return_type=void],
193 [guile_cv_func_usleep_return_type=int])])
194case "$guile_cv_func_usleep_return_type" in
195 "void" )
196 AC_DEFINE(USLEEP_RETURNS_VOID)
197 ;;
198esac
199
da88f0cb
JB
200dnl <GNU-WIN32 hacks>
201
202AC_CHECK_HEADER(sys/un.h, have_sys_un_h=1)
203if test -n "$have_sys_un_h" ; then
204AC_DEFINE(HAVE_UNIX_DOMAIN_SOCKETS)
205fi
206
207AC_CHECK_FUNCS(socketpair getgroups setpwent pause tzset)
208
f4e5b810
GH
209dnl I don't know what this prefixing of cygwin32_ is for.
210dnl scmconfig.h wasn't updated with the test results.
211dnl so use AC_CHECK_FUNCS for now.
212
213dnl how about:
214dnl save confdefs.h
215dnl if test $ac_cv_cigwin = yes; then
216dnl modify confdefs.h
217dnl fi
218dnl AC_CHECK_FUNCS...
219dnl restore confdefs.h
220
221dnl cp confdefs.h confdefs.h.bak
5c11cc9d 222dnl for func in gethostent sethostent endhostent getnetent setnetent endnetent getprotoent setprotoent endprotoent getservent setservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof hstrerror; do
f4e5b810
GH
223dnl cp confdefs.h.bak confdefs.h
224dnl cat >> confdefs.h << EOF
225dnl #ifdef __CYGWIN32__
226dnl #define $func cygwin32_$func
227dnl #endif
228dnl EOF
229dnl AC_CHECK_FUNC($func)
230dnl done
231dnl cp confdefs.h.bak confdefs.h
232
219a5a5b
JB
233AC_CHECK_FUNCS(sethostent gethostent endhostent dnl
234 setnetent getnetent endnetent dnl
235 setprotoent getprotoent endprotoent dnl
236 setservent getservent endservent dnl
5c11cc9d
GH
237 getnetbyaddr getnetbyname dnl
238 inet_lnaof inet_makeaddr inet_netof hstrerror)
da88f0cb
JB
239
240dnl </GNU-WIN32 hacks>
241
7ee92fce
GH
242dnl Test whether system calls are restartable by default on the
243dnl current system. If they are not, we put a loop around every system
244dnl call to check for EINTR (see SCM_SYSCALL) and do not attempt to
245dnl change from the default behaviour. On the other hand, if signals
246dnl are restartable then the loop is not installed and when libguile
247dnl initialises it also resets the behaviour of each signal to cause a
248dnl restart (in case a different runtime had a different default
249dnl behaviour for some reason: e.g., different versions of linux seem
250dnl to behave differently.)
251
08b8c694 252AC_SYS_RESTARTABLE_SYSCALLS
e1a191a8 253
52cfc69b
GH
254if test "$enable_regex" = yes; then
255 if test "$ac_cv_header_regex_h" = yes ||
256 test "$ac_cv_header_rxposix_h" = yes ||
257 test "$ac_cv_header_rx_rxposix_h" = yes; then
258 GUILE_NAMED_CHECK_FUNC(regcomp, norx, [LIBOBJS="regex-posix.o $LIBOBJS"],
259 [AC_CHECK_LIB(rx, main)
260 GUILE_NAMED_CHECK_FUNC(regcomp, rx, [LIBOBJS="regex-posix.o $LIBOBJS"])]
261 )
262 dnl The following should not be necessary, but for some reason
263 dnl autoheader misses it if we don't include it!
264 if test "$ac_cv_func_regcomp_norx" = yes ||
265 test "$ac_cv_func_regcomp_rx" = yes; then
266 AC_DEFINE(HAVE_REGCOMP)
267 fi
268 fi
da88f0cb 269fi
8e1bfcd0 270
dbbbec40 271AC_REPLACE_FUNCS(inet_aton putenv strerror memmove)
3a629497 272
4a5fa91c
TP
273# When testing for the presence of alloca, we need to add alloca.o
274# explicitly to LIBOBJS to make sure that it is translated to
275# `alloca.lo' for libtool later on. This can and should be done more cleanly.
3a629497 276AC_FUNC_ALLOCA
4a5fa91c 277if test "$ALLOCA" = "alloca.o"; then LIBOBJS="alloca.o $LIBOBJS"; fi
3a629497
JB
278
279AC_STRUCT_ST_RDEV
280AC_STRUCT_ST_BLKSIZE
075edbde
JB
281
282# We could use AC_STRUCT_ST_BLOCKS here, but that adds fileblocks.o to
283# LIBOBJS, which we don't need. This seems more direct.
284AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
285[AC_TRY_COMPILE([#include <sys/types.h>
286#include <sys/stat.h>], [struct stat s; s.st_blocks;],
287ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
288if test $ac_cv_struct_st_blocks = yes; then
289 AC_DEFINE(HAVE_ST_BLOCKS)
290fi
291
fd02f2ad
MD
292AC_CACHE_CHECK([for S_ISLNK in sys/stat.h], ac_cv_macro_S_ISLNK,
293 [AC_TRY_CPP([#include <sys/stat.h>
294 #ifndef S_ISLNK
295 #error no S_ISLNK
296 #endif],
297 ac_cv_macro_S_ISLNK=yes,
298 ac_cv_macro_S_ISLNK=no)])
299if test $ac_cv_macro_S_ISLNK = yes; then
300 AC_DEFINE(HAVE_S_ISLNK)
301fi
302
3a629497
JB
303AC_STRUCT_TIMEZONE
304GUILE_STRUCT_UTIMBUF
305
3a629497
JB
306#--------------------------------------------------------------------
307#
308# Which way does the stack grow?
309#
310#--------------------------------------------------------------------
311
312AC_TRY_RUN(aux (l) unsigned long l;
313 { int x; exit (l >= ((unsigned long)&x)); }
314 main () { int q; aux((unsigned long)&q); },
315 AC_DEFINE(SCM_STACK_GROWS_UP),,AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h.in))
316
3a171311
JB
317AC_CACHE_CHECK([whether floats fit in longs], guile_cv_type_float_fits_long,
318 [AC_TRY_RUN([main () { exit (sizeof(float) > sizeof(long)); }],
319 [guile_cv_type_float_fits_long=yes],
320 [guile_cv_type_float_fits_long=no],
321 [guile_cv_type_float_fits_long=guess-yes])])
322case $guile_cv_type_float_fits_long in
323 "yes" )
324 AC_DEFINE(SCM_SINGLES)
325 ;;
326 "guess-yes" )
327 AC_DEFINE(SCM_SINGLES)
328 AC_MSG_WARN([guessing that sizeof(long) == sizeof(float)])
329 AC_MSG_WARN([see SCM_SINGLES in scmconfig.h.in])
330 ;;
331esac
3a629497 332
3a629497
JB
333
334AC_MSG_CHECKING(for struct linger)
335AC_CACHE_VAL(scm_cv_struct_linger,
336 AC_TRY_COMPILE([
337#include <sys/types.h>
338#include <sys/socket.h>],
339 [struct linger lgr; lgr.l_linger = 100],
340 scm_cv_struct_linger="yes",
341 scm_cv_struct_linger="no"))
342AC_MSG_RESULT($scm_cv_struct_linger)
343if test $scm_cv_struct_linger = yes; then
344 AC_DEFINE(HAVE_STRUCT_LINGER)
345fi
3a629497
JB
346
347#--------------------------------------------------------------------
348#
349# Flags for thread support
350#
351#--------------------------------------------------------------------
352
539c89a1
JB
353### What thread package has the user asked for?
354AC_ARG_WITH(threads, [ --with-threads thread interface],
355 , with_threads=no)
356
357### Turn $with_threads into either the name of a threads package, like
358### `qt', or `no', meaning that threads should not be supported.
e0f54bcc 359AC_MSG_CHECKING(whether to support threads)
539c89a1
JB
360case "$with_threads" in
361 "yes" | "qt" | "coop" | "")
362 with_threads=qt
363 ;;
364 "no" )
365 ;;
366 * )
367 AC_MSG_ERROR(invalid value for --with-threads: $with_threads)
368 ;;
369esac
e0f54bcc 370AC_MSG_RESULT($with_threads)
3a629497 371
539c89a1
JB
372## Make sure the threads package we've chosen is actually supported on
373## the present platform.
374case "${with_threads}" in
375 "qt" )
376 ## This configures the QuickThreads package, and sets or clears
377 ## the THREAD_PACKAGE variable if qthreads don't configure
378 ## correctly.
379 QTHREADS_CONFIGURE
380 ;;
381esac
3a629497 382
539c89a1
JB
383## If we're using threads, bring in some other parts of Guile which
384## work with them.
385if test "${THREAD_PACKAGE}" != "" ; then
386 AC_DEFINE(USE_THREADS, 1)
3a629497 387
539c89a1
JB
388 ## Include the Guile thread interface in the library...
389 LIBOBJS="$LIBOBJS threads.o"
933a7411 390
539c89a1
JB
391 ## ... and tell it which package to talk to.
392 case "${THREAD_PACKAGE}" in
393 "QT" )
394 AC_DEFINE(USE_COOP_THREADS, 1)
395 ;;
396 * )
397 AC_MSG_ERROR(invalid value for THREAD_PACKAGE: ${THREAD_PACKAGE})
398 ;;
399 esac
400
401 ## Bring in scm_internal_select, if appropriate.
402 if test $ac_cv_func_gettimeofday = yes &&
403 test $ac_cv_func_select = yes; then
404 LIBOBJS="$LIBOBJS iselect.o"
405 AC_DEFINE(GUILE_ISELECT, 1)
406 fi
933a7411
MD
407fi
408
3a629497
JB
409## If we're using GCC, ask for aggressive warnings.
410case "$GCC" in
99be3450 411 yes )
0a1b8b15
JB
412 ## We had -Wstrict-prototypes in here for a bit, but Guile does too
413 ## much stuff with generic function pointers for that to really be
414 ## less than exasperating.
415 CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wmissing-prototypes" ;;
3a629497
JB
416esac
417
418AC_PROG_AWK
419
420## If we're creating a shared library (using libtool!), then we'll
421## need to generate a list of .lo files corresponding to the .o files
422## given in LIBOBJS. We'll call it LIBLOBJS.
423LIBLOBJS="`echo ${LIBOBJS} | sed 's/\.o/.lo/g'`"
424
7c86ae05
JB
425AC_SUBST(GUILE_MAJOR_VERSION)
426AC_SUBST(GUILE_MINOR_VERSION)
427AC_SUBST(GUILE_VERSION)
539c89a1 428
bcc695e3 429dnl Tell guile-config what flags guile users should link against.
539c89a1 430GUILE_LIBS="$LDFLAGS $THREAD_LIBS_INSTALLED $LIBS"
daa4f38c 431AC_SUBST(GUILE_LIBS)
7c86ae05 432
3a629497
JB
433AC_SUBST(AWK)
434AC_SUBST(LIBLOBJS)
435
981ad727 436AC_OUTPUT([Makefile libguile/Makefile libguile/guile-snarf libguile/versiondat.h ice-9/Makefile qt/Makefile qt/qt.h qt/md/Makefile qt/time/Makefile guile-config/Makefile doc/Makefile], [chmod +x libguile/guile-snarf])
0f2d19dd 437
3a629497
JB
438dnl Local Variables:
439dnl comment-start: "dnl "
440dnl comment-end: ""
441dnl comment-start-skip: "\\bdnl\\b\\s *"
442dnl End: