add FSF header.
[bpt/guile.git] / configure.in
CommitLineData
777b022a
JB
1dnl configuration script for Guile
2dnl Process this file with autoconf to produce configure.
50848747 3dnl
a73256d0
KR
4
5define(GUILE_CONFIGURE_COPYRIGHT,[[
6
4f416616 7Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
a73256d0
KR
8
9This file is part of GUILE
10
11GUILE is free software; you can redistribute it and/or modify it
12under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2, or (at your
14option) any later version.
15
16GUILE is distributed in the hope that it will be useful, but
17WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with GUILE; see the file COPYING. If not, write to the
92205699
MV
23Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24Boston, MA 02110-1301, USA.
a73256d0
KR
25
26]])
50848747 27
a44e61ac 28AC_PREREQ(2.53)
237b3247 29
5ae51dad 30AC_INIT(m4_esyscmd(. ./GUILE-VERSION && echo -n ${PACKAGE}),
d9f71a07 31 m4_esyscmd(. ./GUILE-VERSION && echo -n ${GUILE_VERSION}),
2039f7be 32 [bug-guile@gnu.org])
23f2b9a3 33AC_CONFIG_AUX_DIR([.])
5ae51dad
RB
34AC_CONFIG_SRCDIR(GUILE-VERSION)
35AM_INIT_AUTOMAKE([no-define])
36
a73256d0 37AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT)
8907576f 38AC_CONFIG_SRCDIR([GUILE-VERSION])
5ae51dad 39
2d26def0 40. $srcdir/GUILE-VERSION
5ae51dad 41
15ae1bee 42AM_MAINTAINER_MODE
9a52bc2a 43AM_CONFIG_HEADER([config.h])
a73256d0 44AH_TOP(/*GUILE_CONFIGURE_COPYRIGHT*/)
2d26def0 45
3a629497 46#--------------------------------------------------------------------
0e8a8468
MV
47#
48# Independent Subdirectories
49#
50#--------------------------------------------------------------------
51
52AC_CONFIG_SUBDIRS(guile-readline)
53
a6be66ed
RB
54#--------------------------------------------------------------------
55
56dnl Some more checks for Win32
57AC_CYGWIN
a6be66ed
RB
58AC_LIBTOOL_WIN32_DLL
59
60AC_PROG_INSTALL
61AC_PROG_CC
62AC_PROG_CPP
63AC_PROG_AWK
64
65AC_AIX
66AC_ISC_POSIX
67AC_MINIX
68
69AM_PROG_CC_STDC
45c0ff10
KR
70# for per-target cflags in the libguile subdir
71AM_PROG_CC_C_O
a6be66ed
RB
72
73AC_LIBTOOL_DLOPEN
c78a96e0 74AC_PROG_LIBTOOL
a98dbc87
MV
75AC_CHECK_LIB([ltdl], [lt_dlinit], ,
76 [AC_MSG_ERROR([libltdl not found. See README.])])
c62a2bb9
MV
77
78AC_SUBST(DLPREOPEN)
a6be66ed
RB
79
80AC_CHECK_PROG(have_makeinfo, makeinfo, yes, no)
81AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes)
82
d995da7f
NJ
83AM_PATH_LISPDIR
84
0e8a8468 85#--------------------------------------------------------------------
3a629497 86#
a6be66ed 87# User options (after above tests that may set default CFLAGS etc.)
3a629497
JB
88#
89#--------------------------------------------------------------------
86789f9b 90
bdcccc18
RB
91GUILE_ERROR_ON_WARNING="yes"
92
8afd1a2a
RB
93AC_ARG_ENABLE(error-on-warning,
94 [ --enable-error-on-warning treat compile warnings as errors],
95 [case "${enableval}" in
bdcccc18
RB
96 yes | y) GUILE_ERROR_ON_WARNING="yes" ;;
97 no | n) GUILE_ERROR_ON_WARNING="no" ;;
8afd1a2a
RB
98 *) AC_MSG_ERROR(bad value ${enableval} for --enable-error-on-warning) ;;
99 esac])
100
9a52bc2a 101SCM_I_GSC_GUILE_DEBUG_FREELIST=0
52b3923a 102AC_ARG_ENABLE(debug-freelist,
e73dd549 103 [ --enable-debug-freelist include garbage collector freelist debugging code],
9a52bc2a
RB
104 if test "$enable_debug_freelist" = y \
105 || test "$enable_debug_freelist" = yes; then
106 SCM_I_GSC_GUILE_DEBUG_FREELIST=1
52b3923a
GB
107 fi)
108
cf890744 109AC_ARG_ENABLE(debug-malloc,
e73dd549 110 [ --enable-debug-malloc include malloc debugging code],
cf890744 111 if test "$enable_debug_malloc" = y || test "$enable_debug_malloc" = yes; then
eede3dbc
RB
112 AC_DEFINE(GUILE_DEBUG_MALLOC, 1,
113 [Define this if you want to debug scm_must_malloc/realloc/free calls.])
cf890744
MD
114 fi)
115
9a52bc2a 116SCM_I_GSC_GUILE_DEBUG=0
62002dcb 117AC_ARG_ENABLE(guile-debug,
9a52bc2a
RB
118 [AC_HELP_STRING([--enable-guile-debug],
119 [include internal debugging functions])],
62002dcb 120 if test "$enable_guile_debug" = y || test "$enable_guile_debug" = yes; then
9a52bc2a 121 SCM_I_GSC_GUILE_DEBUG=1
62002dcb
MD
122 fi)
123
52cfc69b
GH
124AC_ARG_ENABLE(posix,
125 [ --disable-posix omit posix interfaces],,
126 enable_posix=yes)
127
128AC_ARG_ENABLE(networking,
dc914156 129 [ --disable-networking omit networking interfaces],,
52cfc69b
GH
130 enable_networking=yes)
131
132AC_ARG_ENABLE(regex,
133 [ --disable-regex omit regular expression interfaces],,
134 enable_regex=yes)
135
f5922e27
MV
136AC_ARG_ENABLE([discouraged],
137 AC_HELP_STRING([--disable-discouraged],[omit discouraged features]))
138
139if test "$enable_discouraged" = no; then
140 SCM_I_GSC_ENABLE_DISCOURAGED=0
141else
142 SCM_I_GSC_ENABLE_DISCOURAGED=1
143fi
144
9a52bc2a
RB
145AC_ARG_ENABLE([deprecated],
146 AC_HELP_STRING([--disable-deprecated],[omit deprecated features]))
eede3dbc 147
e73dd549 148if test "$enable_deprecated" = no; then
9a52bc2a 149 SCM_I_GSC_ENABLE_DEPRECATED=0
e73dd549
MV
150else
151 if test "$enable_deprecated" = yes || test "$enable_deprecated" = ""; then
94a0d885
MV
152 warn_default=summary
153 elif test "$enable_deprecated" = shutup; then
154 warn_default=no
155 else
156 warn_default=$enable_deprecated
e73dd549 157 fi
9a52bc2a 158 SCM_I_GSC_ENABLE_DEPRECATED=1
eede3dbc
RB
159 AC_DEFINE_UNQUOTED(SCM_WARN_DEPRECATED_DEFAULT, "$warn_default",
160 [Define this to control the default warning level for deprecated features.])
e73dd549
MV
161fi
162
3d1a89b9
NJ
163AC_ARG_ENABLE(elisp,
164 [ --disable-elisp omit Emacs Lisp support],,
165 enable_elisp=yes)
166
a44e61ac
MV
167#--------------------------------------------------------------------
168
4f6f9ae3
GH
169dnl Check for dynamic linking
170
171use_modules=yes
172AC_ARG_WITH(modules,
173[ --with-modules[=FILES] Add support for dynamic modules],
174use_modules="$withval")
175test -z "$use_modules" && use_modules=yes
176DLPREOPEN=
177if test "$use_modules" != no; then
4f6f9ae3
GH
178 if test "$use_modules" = yes; then
179 DLPREOPEN="-dlpreopen force"
180 else
181 DLPREOPEN="-export-dynamic"
182 for module in $use_modules; do
183 DLPREOPEN="$DLPREOPEN -dlopen $module"
184 done
185 fi
186fi
187
52cfc69b
GH
188dnl files which are destined for separate modules.
189
4f6f9ae3
GH
190if test "$use_modules" != no; then
191 AC_LIBOBJ([dynl])
192fi
193
52cfc69b 194if test "$enable_posix" = yes; then
eede3dbc
RB
195 AC_LIBOBJ([filesys])
196 AC_LIBOBJ([posix])
197 AC_DEFINE(HAVE_POSIX, 1,
198 [Define this if you want support for POSIX system calls in Guile.])
52cfc69b
GH
199fi
200
201if test "$enable_networking" = yes; then
eede3dbc
RB
202 AC_LIBOBJ([net_db])
203 AC_LIBOBJ([socket])
204 AC_DEFINE(HAVE_NETWORKING, 1,
205 [Define this if you want support for networking in Guile.])
52cfc69b
GH
206fi
207
cf890744 208if test "$enable_debug_malloc" = yes; then
eede3dbc 209 AC_LIBOBJ([debug-malloc])
cf890744
MD
210fi
211
3d1a89b9 212if test "$enable_elisp" = yes; then
9a52bc2a
RB
213 SCM_I_GSC_ENABLE_ELISP=1
214else
215 SCM_I_GSC_ENABLE_ELISP=0
3d1a89b9 216fi
9a5fa6e9 217AC_CHECK_LIB(uca, __uc_get_ar_bsp)
3d1a89b9 218
3a629497 219AC_C_CONST
5b079b46 220
9a52bc2a 221AC_C_INLINE
5bd732c9 222if test "$ac_cv_c_inline" != no; then
9a52bc2a
RB
223 SCM_I_GSC_C_INLINE="\"${ac_cv_c_inline}\""
224else
225 SCM_I_GSC_C_INLINE=NULL
5bd732c9 226fi
9a5fa6e9 227AC_CHECK_LIB(uca, __uc_get_ar_bsp)
5bd732c9 228
9a52bc2a
RB
229AC_C_BIGENDIAN
230
231AC_CHECK_SIZEOF(char)
232AC_CHECK_SIZEOF(unsigned char)
813b3dd4 233AC_CHECK_SIZEOF(short)
9a52bc2a 234AC_CHECK_SIZEOF(unsigned short)
9dec9737 235AC_CHECK_SIZEOF(int)
9a52bc2a 236AC_CHECK_SIZEOF(unsigned int)
9dec9737 237AC_CHECK_SIZEOF(long)
9a52bc2a 238AC_CHECK_SIZEOF(unsigned long)
813b3dd4 239AC_CHECK_SIZEOF(size_t)
813b3dd4 240AC_CHECK_SIZEOF(long long)
9a52bc2a 241AC_CHECK_SIZEOF(unsigned long long)
fcc5d734
SJ
242AC_CHECK_SIZEOF(__int64)
243AC_CHECK_SIZEOF(unsigned __int64)
1be6b49c 244AC_CHECK_SIZEOF(void *)
9a52bc2a
RB
245AC_CHECK_SIZEOF(intptr_t)
246AC_CHECK_SIZEOF(uintptr_t)
247AC_CHECK_SIZEOF(ptrdiff_t)
d20008c0 248AC_CHECK_SIZEOF(size_t)
4f416616 249AC_CHECK_SIZEOF(off_t)
1be6b49c 250
f3f70257
ML
251if test "$ac_cv_sizeof_long" -ne "$ac_cv_sizeof_void_p"; then
252 AC_MSG_ERROR(sizes of long and void* are not identical)
9dec9737 253fi
3a629497 254
c134fe9d 255if test "$ac_cv_sizeof_ptrdiff_t" -ne 0; then
9a52bc2a
RB
256 SCM_I_GSC_T_PTRDIFF='"ptrdiff_t"'
257else
258 SCM_I_GSC_T_PTRDIFF='"long"'
259fi
260AC_SUBST([SCM_I_GSC_T_PTRDIFF])
261
262AC_CHECK_HEADERS([stdint.h])
263AC_CHECK_HEADERS([inttypes.h])
264
d20008c0
MV
265AC_CHECK_SIZEOF(intmax_t)
266
9a52bc2a
RB
267SCM_I_GSC_NEEDS_STDINT_H=0
268SCM_I_GSC_NEEDS_INTTYPES_H=0
269
270### intptr and uintptr (try not to use inttypes if we don't have to)
271if test "$ac_cv_header_inttypes_h" = yes; then
272 if test "$ac_cv_sizeof_intptr_t" -eq 0; then
273 AC_CHECK_SIZEOF([intptr_t],,[#include <inttypes.h>
274#include <stdio.h>])
275 if test "$ac_cv_sizeof_intptr_t" -ne 0; then
276 SCM_I_GSC_NEEDS_INTTYPES_H=1
277 fi
278 fi
279 if test "$ac_cv_sizeof_uintptr_t" -eq 0; then
280 AC_CHECK_SIZEOF([uintptr_t],,[#include <inttypes.h>
281#include <stdio.h>])
282 if test "$ac_cv_sizeof_uintptr_t" -ne 0; then
283 SCM_I_GSC_NEEDS_INTTYPES_H=1
284 fi
285 fi
286fi
287
288### See what's provided by stdint.h
289if test "$ac_cv_header_stdint_h" = yes; then
290 AC_CHECK_TYPE([int8_t],[scm_stdint_has_int8=1],,[#include <stdint.h>])
291 AC_CHECK_TYPE([uint8_t],[scm_stdint_has_uint8=1],,[#include <stdint.h>])
292 AC_CHECK_TYPE([int16_t],[scm_stdint_has_int16=1],,[#include <stdint.h>])
293 AC_CHECK_TYPE([uint16_t],[scm_stdint_has_uint16=1],,[#include <stdint.h>])
294 AC_CHECK_TYPE([int32_t],[scm_stdint_has_int32=1],,[#include <stdint.h>])
295 AC_CHECK_TYPE([uint32_t],[scm_stdint_has_uint32=1],,[#include <stdint.h>])
296 AC_CHECK_TYPE([int64_t],[scm_stdint_has_int64=1],,[#include <stdint.h>])
297 AC_CHECK_TYPE([uint64_t],[scm_stdint_has_uint64=1],,[#include <stdint.h>])
eb1f89f6
MV
298 AC_CHECK_TYPE([intmax_t],[scm_stdint_has_intmax=1],,[#include <stdint.h>])
299 AC_CHECK_TYPE([uintmax_t],[scm_stdint_has_uintmax=1],,[#include <stdint.h>])
9a52bc2a
RB
300fi
301
302# so we don't get confused by the cache (wish there was a better way
303# to check particular headers for the same type...)
304
305unset ac_cv_type_int8_t
306unset ac_cv_type_uint8_t
307unset ac_cv_type_int16_t
308unset ac_cv_type_uint16_t
309unset ac_cv_type_int32_t
310unset ac_cv_type_uint32_t
311unset ac_cv_type_int64_t
312unset ac_cv_type_uint64_t
eb1f89f6
MV
313unset ac_cv_type_intmax_t
314unset ac_cv_type_uintmax_t
9a52bc2a
RB
315
316### See what's provided by inttypes.h
317if test "$ac_cv_header_inttypes_h" = yes; then
318 AC_CHECK_TYPE([int8_t],[scm_inttypes_has_int8=1],,[#include <inttypes.h>])
319 AC_CHECK_TYPE([uint8_t],[scm_inttypes_has_uint8=1],,[#include <inttypes.h>])
320 AC_CHECK_TYPE([int16_t],[scm_inttypes_has_int16=1],,[#include <inttypes.h>])
321 AC_CHECK_TYPE([uint16_t],[scm_inttypes_has_uint16=1],,[#include <inttypes.h>])
322 AC_CHECK_TYPE([int32_t],[scm_inttypes_has_int32=1],,[#include <inttypes.h>])
323 AC_CHECK_TYPE([uint32_t],[scm_inttypes_has_uint32=1],,[#include <inttypes.h>])
324 AC_CHECK_TYPE([int64_t],[scm_inttypes_has_int64=1],,[#include <inttypes.h>])
325 AC_CHECK_TYPE([uint64_t],[scm_inttypes_has_uint64=1],,[#include <inttypes.h>])
eb1f89f6
MV
326 AC_CHECK_TYPE([intmax_t],[scm_inttypes_has_intmax=1],,[#include <inttypes.h>])
327 AC_CHECK_TYPE([uintmax_t],[scm_inttypes_has_uintmax=1],,[#include <inttypes.h>])
9a52bc2a
RB
328fi
329
330# Try hard to find definitions for some required scm_t_*int* types.
331
332### Required type scm_t_int8
6aa84fdd 333if test "$scm_stdint_has_int8"; then
9a52bc2a
RB
334 SCM_I_GSC_T_INT8='"int8_t"'
335 SCM_I_GSC_NEEDS_STDINT_H=1
336elif test "$scm_inttypes_has_int8"; then
337 SCM_I_GSC_T_INT8='"int8_t"'
338 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
339elif test "$ac_cv_sizeof_char" -eq 1; then
340 SCM_I_GSC_T_INT8='"signed char"'
9a52bc2a
RB
341else
342 AC_MSG_ERROR([Can't find appropriate type for scm_t_int8.])
343fi
344AC_SUBST([SCM_I_GSC_T_INT8])
345
346### Required type scm_t_uint8
6aa84fdd 347if test "$scm_stdint_has_uint8"; then
9a52bc2a
RB
348 SCM_I_GSC_T_UINT8='"uint8_t"'
349 SCM_I_GSC_NEEDS_STDINT_H=1
350elif test "$scm_inttypes_has_uint8"; then
351 SCM_I_GSC_T_UINT8='"uint8_t"'
352 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
353elif test "$ac_cv_sizeof_unsigned_char" -eq 1; then
354 SCM_I_GSC_T_UINT8='"unsigned char"'
9a52bc2a
RB
355else
356 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint8.])
357fi
358AC_SUBST([SCM_I_GSC_T_UINT8])
9a52bc2a
RB
359
360### Required type scm_t_int16 (ANSI C says int or short might work)
6aa84fdd 361if test "$scm_stdint_has_int16"; then
9a52bc2a
RB
362 SCM_I_GSC_T_INT16='"int16_t"'
363 SCM_I_GSC_NEEDS_STDINT_H=1
364elif test "$scm_inttypes_has_int16"; then
365 SCM_I_GSC_T_INT16='"int16_t"'
366 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
367elif test "$ac_cv_sizeof_int" -eq 2; then
368 SCM_I_GSC_T_INT16='"int"'
6aa84fdd
MV
369elif test "$ac_cv_sizeof_short" -eq 2; then
370 SCM_I_GSC_T_INT16='"short"'
9a52bc2a
RB
371else
372 AC_MSG_ERROR([Can't find appropriate type for scm_t_int16.])
373fi
374AC_SUBST([SCM_I_GSC_T_INT16])
375
376### Required type scm_t_uint16 (ANSI C says int or short might work)
6aa84fdd 377if test "$scm_stdint_has_uint16"; then
9a52bc2a
RB
378 SCM_I_GSC_T_UINT16='"uint16_t"'
379 SCM_I_GSC_NEEDS_STDINT_H=1
380elif test "$scm_inttypes_has_uint16"; then
381 SCM_I_GSC_T_UINT16='"uint16_t"'
382 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
383elif test "$ac_cv_sizeof_unsigned_int" -eq 2; then
384 SCM_I_GSC_T_UINT16='"unsigned int"'
6aa84fdd
MV
385elif test "$ac_cv_sizeof_unsigned_short" -eq 2; then
386 SCM_I_GSC_T_UINT16='"unsigned short"'
9a52bc2a
RB
387else
388 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint16.])
389fi
390AC_SUBST([SCM_I_GSC_T_UINT16])
391
392
393### Required type scm_t_int32 (ANSI C says int, short, or long might work)
6aa84fdd 394if test "$scm_stdint_has_int32"; then
9a52bc2a
RB
395 SCM_I_GSC_T_INT32='"int32_t"'
396 SCM_I_GSC_NEEDS_STDINT_H=1
397elif test "$scm_inttypes_has_int32"; then
398 SCM_I_GSC_T_INT32='"int32_t"'
399 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
400elif test "$ac_cv_sizeof_int" -eq 4; then
401 SCM_I_GSC_T_INT32='"int"'
6aa84fdd
MV
402elif test "$ac_cv_sizeof_long" -eq 4; then
403 SCM_I_GSC_T_INT32='"long"'
6aa84fdd
MV
404elif test "$ac_cv_sizeof_short" -eq 4; then
405 SCM_I_GSC_T_INT32='"short"'
9a52bc2a
RB
406else
407 AC_MSG_ERROR([Can't find appropriate type for scm_t_int32.])
408fi
409AC_SUBST([SCM_I_GSC_T_INT32])
410
411### Required type scm_t_uint32 (ANSI C says int, short, or long might work)
6aa84fdd 412if test "$scm_stdint_has_uint32"; then
9a52bc2a
RB
413 SCM_I_GSC_T_UINT32='"uint32_t"'
414 SCM_I_GSC_NEEDS_STDINT_H=1
415elif test "$scm_inttypes_has_uint32"; then
416 SCM_I_GSC_T_UINT32='"uint32_t"'
417 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
418elif test "$ac_cv_sizeof_unsigned_int" -eq 4; then
419 SCM_I_GSC_T_UINT32='"unsigned int"'
6aa84fdd
MV
420elif test "$ac_cv_sizeof_unsigned_long" -eq 4; then
421 SCM_I_GSC_T_UINT32='"unsigned long"'
6aa84fdd
MV
422elif test "$ac_cv_sizeof_unsigned_short" -eq 4; then
423 SCM_I_GSC_T_UINT32='"unsigned short"'
9a52bc2a
RB
424else
425 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint32.])
426fi
427AC_SUBST([SCM_I_GSC_T_UINT32])
428
a6be66ed 429### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
fcc5d734 430### Also try 'long long' and '__int64' if we have it.
9a52bc2a 431SCM_I_GSC_T_INT64=0
6aa84fdd
MV
432if test "$scm_stdint_has_int64"; then
433 SCM_I_GSC_T_INT64='"int64_t"'
6aa84fdd
MV
434 SCM_I_GSC_NEEDS_STDINT_H=1
435elif test "$scm_inttypes_has_int64"; then
436 SCM_I_GSC_T_INT64='"int64_t"'
6aa84fdd
MV
437 SCM_I_GSC_NEEDS_INTTYPES_H=1
438elif test "$ac_cv_sizeof_int" -eq 8; then
9a52bc2a
RB
439 SCM_I_GSC_T_INT64='"int"'
440elif test "$ac_cv_sizeof_long" -eq 8; then
441 SCM_I_GSC_T_INT64='"long"'
442elif test "$ac_cv_sizeof_short" -eq 8; then
443 SCM_I_GSC_T_INT64='"short"'
444elif test "$ac_cv_sizeof_long_long" -eq 8; then
445 SCM_I_GSC_T_INT64='"long long"'
fcc5d734
SJ
446elif test "$ac_cv_sizeof___int64" -eq 8; then
447 SCM_I_GSC_T_INT64='"__int64"'
9a52bc2a
RB
448else
449 AC_MSG_ERROR([Can't find appropriate type for scm_t_int64.])
450fi
451AC_SUBST([SCM_I_GSC_T_INT64])
6aa84fdd 452
9a52bc2a 453
a6be66ed 454### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
fcc5d734 455### Also try 'long long' and '__int64' if we have it.
9a52bc2a 456SCM_I_GSC_T_UINT64=0
6aa84fdd
MV
457if test "$scm_stdint_has_uint64"; then
458 SCM_I_GSC_T_UINT64='"uint64_t"'
6aa84fdd
MV
459 SCM_I_GSC_NEEDS_STDINT_H=1
460elif test "$scm_inttypes_has_uint64"; then
461 SCM_I_GSC_T_UINT64='"uint64_t"'
6aa84fdd
MV
462 SCM_I_GSC_NEEDS_INTTYPES_H=1
463elif test "$ac_cv_sizeof_unsigned_int" -eq 8; then
9a52bc2a
RB
464 SCM_I_GSC_T_UINT64='"unsigned int"'
465elif test "$ac_cv_sizeof_unsigned_long" -eq 8; then
466 SCM_I_GSC_T_UINT64='"unsigned long"'
467elif test "$ac_cv_sizeof_unsigned_short" -eq 8; then
468 SCM_I_GSC_T_UINT64='"unsigned short"'
469elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
470 SCM_I_GSC_T_UINT64='"unsigned long long"'
fcc5d734
SJ
471elif test "$ac_cv_sizeof_unsigned___int64" -eq 8; then
472 SCM_I_GSC_T_UINT64='"unsigned __int64"'
9a52bc2a
RB
473else
474 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint64.])
475fi
476AC_SUBST([SCM_I_GSC_T_UINT64])
477
eb1f89f6
MV
478### Required type scm_t_intmax
479###
480### We try 'intmax_t', '__int64', 'long long' in this order. When
481### none of them is available, we use 'long'.
482###
483SCM_I_GSC_T_INTMAX=0
484if test "$scm_stdint_has_intmax"; then
485 SCM_I_GSC_T_INTMAX='"intmax_t"'
486 SCM_I_GSC_NEEDS_STDINT_H=1
487elif test "$scm_inttypes_has_intmax"; then
488 SCM_I_GSC_T_INTMAX='"intmax_t"'
489 SCM_I_GSC_NEEDS_INTTYPES_H=1
490elif test "$ac_cv_sizeof___int64" -ne 0; then
491 SCM_I_GSC_T_INTMAX='"__int64"'
492elif test "$ac_cv_sizeof_long_long" -ne 0; then
493 SCM_I_GSC_T_INTMAX='"long long"'
494else
495 SCM_I_GSC_T_INTMAX='"long"'
496fi
497AC_SUBST([SCM_I_GSC_T_INTMAX])
498
499### Required type scm_t_uintmax
500###
501### We try 'uintmax_t', 'unsigned __int64', 'unsigned long long' in
502### this order. When none of them is available, we use 'unsigned long'.
503###
504SCM_I_GSC_T_UINTMAX=0
505if test "$scm_stdint_has_uintmax"; then
506 SCM_I_GSC_T_UINTMAX='"uintmax_t"'
507 SCM_I_GSC_NEEDS_STDINT_H=1
508elif test "$scm_inttypes_has_uintmax"; then
509 SCM_I_GSC_T_UINTMAX='"uintmax_t"'
510 SCM_I_GSC_NEEDS_INTTYPES_H=1
511elif test "$ac_cv_sizeof_unsigned___int64" -ne 0; then
512 SCM_I_GSC_T_UINTMAX='"unsigned __int64"'
513elif test "$ac_cv_sizeof_unsigned_long_long" -ne 0; then
514 SCM_I_GSC_T_UINTMAX='"unsigned long long"'
515else
516 SCM_I_GSC_T_UINTMAX='"unsigned long"'
517fi
518AC_SUBST([SCM_I_GSC_T_UINTMAX])
519
9a52bc2a
RB
520
521AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
522AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H])
523
3a629497
JB
524AC_HEADER_STDC
525AC_HEADER_DIRENT
526AC_HEADER_TIME
527AC_HEADER_SYS_WAIT
bdcccc18 528
63177e46 529# Reasons for testing:
8ab3d8a0 530# complex.h - new in C99
63177e46 531# fenv.h - available in C99, but not older systems
45c0ff10 532# process.h - mingw specific
63177e46 533#
45c0ff10 534AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h memory.h process.h string.h \
bdcccc18
RB
535regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
536sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
537sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
538direct.h])
539
8ab3d8a0
KR
540# "complex double" is new in C99, and "complex" is only a keyword if
541# <complex.h> is included
542AC_CHECK_TYPES(complex double,,,
543[#if HAVE_COMPLEX_H
544#include <complex.h>
545#endif])
546
4f416616
KR
547# On MacOS X <sys/socklen.h> contains socklen_t, so must include that
548# when testing.
549AC_CHECK_TYPE(socklen_t, ,
550 [AC_DEFINE_UNQUOTED(socklen_t, int,
551 [Define to `int' if <sys/socket.h> does not define.])],
552 [#if HAVE_SYS_TYPES_H
553#include <sys/types.h>
554#endif
555#include <sys/socket.h>
556])
557AC_CHECK_TYPE(struct ip_mreq)
558
3a629497
JB
559GUILE_HEADER_LIBC_WITH_UNISTD
560
561AC_TYPE_GETGROUPS
562AC_TYPE_SIGNAL
563AC_TYPE_MODE_T
564
45c0ff10
KR
565# On mingw -lm is empty, so this test is unnecessary, but it's
566# harmless so we don't hard-code to suppress it.
567#
568AC_CHECK_LIB(m, cos)
569
4c787b52 570AC_CHECK_FUNCS(gethostbyname)
5852c051
JB
571if test $ac_cv_func_gethostbyname = no; then
572 AC_CHECK_LIB(nsl, gethostbyname)
573fi
39e8f371 574
4c787b52 575AC_CHECK_FUNCS(connect)
5852c051
JB
576if test $ac_cv_func_connect = no; then
577 AC_CHECK_LIB(socket, connect)
578fi
5ee74cec 579
f9e5e096
MV
580dnl
581dnl Check for Winsock and other functionality on Win32 (*not* CygWin)
582dnl
583EXTRA_DEFS=""
45c0ff10
KR
584case $host in
585 *-*-mingw*)
6812c28f 586 AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1,
f9e5e096
MV
587 [Define if you have the <winsock2.h> header file.])])
588 AC_CHECK_LIB(ws2_32, main)
eede3dbc
RB
589 AC_LIBOBJ([win32-uname])
590 AC_LIBOBJ([win32-dirent])
b4e15479 591 if test "$enable_networking" = yes ; then
eede3dbc 592 AC_LIBOBJ([win32-socket])
b4e15479
SJ
593 fi
594 if test "$enable_shared" = yes ; then
8f99e3f3
SJ
595 EXTRA_DEFS="-DSCM_IMPORT"
596 AC_DEFINE(USE_DLL_IMPORT, 1,
597 [Define if you need additional CPP macros on Win32 platforms.])
f9e5e096 598 fi
45c0ff10
KR
599 ;;
600esac
f9e5e096 601AC_SUBST(EXTRA_DEFS)
f9e5e096 602
ef73a2a0
KR
603# Reasons for testing:
604# crt_externs.h - Darwin specific
605#
606AC_CHECK_HEADERS([assert.h crt_externs.h])
bdcccc18 607
ef73a2a0 608# Reasons for testing:
1df72834
KR
609# DINFINITY - OSF specific
610# DQNAN - OSF specific
611# (DINFINITY and DQNAN are actually global variables, not functions)
8ab3d8a0
KR
612# chsize - an MS-DOS-ism, found in mingw
613# clog10 - not in mingw (though others like clog and csqrt are)
63177e46 614# fesetround - available in C99, but not older systems
8ab3d8a0
KR
615# ftruncate - posix, but probably not older systems (current mingw
616# has it as an inline for chsize)
23f2b9a3 617# ioctl - not in mingw.
c9d1dcc0 618# gmtime_r - recent posix, not on old systems
45c0ff10
KR
619# pipe - not in mingw
620# _pipe - specific to mingw, taking 3 args
66ec83c9 621# readdir_r - recent posix, not on old systems
4f416616 622# stat64 - SuS largefile stuff, not on old systems
6b01eac9 623# sysconf - not on old systems
8ab3d8a0 624# truncate - not in mingw
a17d2654 625# isblank - available as a GNU extension or in C99
ef73a2a0 626# _NSGetEnviron - Darwin specific
b89c4943 627# strcoll_l, newlocale - GNU extensions (glibc)
ef73a2a0 628#
45c0ff10 629AC_CHECK_FUNCS([DINFINITY DQNAN chsize clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale])
64e121dc 630
6b01eac9
KR
631# Reasons for testing:
632# netdb.h - not in mingw
633# sys/param.h - not in mingw
45c0ff10
KR
634# pthread.h - only available with pthreads. ACX_PTHREAD doesn't
635# check this specifically, we need it for the timespec test below.
8ab3d8a0
KR
636# sethostname - the function itself check because it's not in mingw,
637# the DECL is checked because Solaris 10 doens't have in any header
6b01eac9 638#
45c0ff10 639AC_CHECK_HEADERS(crypt.h netdb.h pthread.h sys/param.h sys/resource.h sys/file.h)
94e6d793 640AC_CHECK_FUNCS(chroot flock getlogin cuserid getpriority setpriority getpass sethostname gethostname)
8ab3d8a0 641AC_CHECK_DECLS([sethostname])
63271ac5
KR
642
643# crypt() may or may not be available, for instance in some countries there
644# are restrictions on cryptography.
645#
646# crypt() might be in libc (eg. OpenBSD), or it might be in a separate
647# -lcrypt library (eg. Debian GNU/Linux).
648#
649# On HP-UX 11, crypt() is in libc and there's a dummy libcrypt.a. We must
650# be careful to avoid -lcrypt in this case, since libtool will see there's
651# only a static libcrypt and decide to build only a static libguile.
652#
653# AC_SEARCH_LIBS lets us add -lcrypt to LIBS only if crypt() is not in the
654# libraries already in that list.
655#
656AC_SEARCH_LIBS(crypt, crypt,
657 [AC_DEFINE(HAVE_CRYPT,1,
658 [Define to 1 if you have the `crypt' function.])])
94e6d793 659
8ab3d8a0
KR
660# glibc 2.3.6 (circa 2006) and various prior versions had a bug where
661# csqrt(-i) returned a negative real part, when it should be positive
662# for the principal root.
663#
664if test "$ac_cv_type_complex_double" = yes; then
665 AC_CACHE_CHECK([whether csqrt is usable],
666 guile_cv_use_csqrt,
667 [AC_TRY_RUN([
668#include <complex.h>
669/* "volatile" is meant to prevent gcc from calculating the sqrt as a
670 constant, we want to test libc. */
671volatile complex double z = - _Complex_I;
672int
673main (void)
674{
675 z = csqrt (z);
676 if (creal (z) > 0.0)
677 return 0; /* good */
678 else
679 return 1; /* bad */
680}],
681 [guile_cv_use_csqrt=yes],
682 [guile_cv_use_csqrt="no, glibc 2.3 bug"],
683 [guile_cv_use_csqrt="yes, hopefully (cross-compiling)"])])
684 case $guile_cv_use_csqrt in
685 yes*)
686 AC_DEFINE(HAVE_USABLE_CSQRT, 1, [Define to 1 if csqrt is bug-free])
687 ;;
688 esac
689fi
690
691
a6be66ed
RB
692dnl GMP tests
693AC_CHECK_LIB([gmp], [__gmpz_init], ,
a98dbc87 694 [AC_MSG_ERROR([GNU MP not found, see README])])
a6be66ed 695
9f1555fe
MV
696# mpz_import is a macro so we need to include <gmp.h>
697AC_TRY_LINK([#include <gmp.h>],
698 [mpz_import (0, 0, 0, 0, 0, 0, 0);] , ,
a98dbc87 699 [AC_MSG_ERROR([At least GNU MP 4.1 is required, see README])])
9f1555fe 700
83cd507c 701dnl i18n tests
b6540274
MV
702#AC_CHECK_HEADERS([libintl.h])
703#AC_CHECK_FUNCS(gettext)
704#if test $ac_cv_func_gettext = no; then
705# AC_CHECK_LIB(intl, gettext)
706#fi
707#AC_CHECK_FUNCS([bindtextdomain textdomain])
708AM_GNU_GETTEXT([external], [need-ngettext])
83cd507c 709
777b022a
JB
710### Some systems don't declare some functions. On such systems, we
711### need to at least provide our own K&R-style declarations.
712
713### GUILE_FUNC_DECLARED(function, headerfile)
714
715### Check for a declaration of FUNCTION in HEADERFILE; if it is
716### not there, #define MISSING_FUNCTION_DECL.
d70e0619 717AC_DEFUN([GUILE_FUNC_DECLARED], [
fc342a63 718 AC_CACHE_CHECK(for $1 declaration, guile_cv_func_$1_declared,
777b022a 719 AC_EGREP_HEADER($1, $2,
01e5e07e 720 guile_cv_func_$1_declared=yes,
fc342a63
JB
721 guile_cv_func_$1_declared=no))
722 if test [x$guile_cv_func_]$1[_declared] = xno; then
eede3dbc
RB
723 AC_DEFINE([MISSING_]translit($1, [a-z], [A-Z])[_DECL], 1,
724 [Define if the operating system supplies $1 without declaring it.])
777b022a
JB
725 fi
726])
727
c31bfb85 728GUILE_FUNC_DECLARED(sleep, unistd.h)
777b022a 729GUILE_FUNC_DECLARED(usleep, unistd.h)
e1a191a8 730
0777022d
KR
731AC_CHECK_DECLS([strptime],,,
732[#define _GNU_SOURCE /* ask glibc to give strptime prototype */
733#include <time.h>])
734
da753252
JB
735### On some systems usleep has no return value. If it does have one,
736### we'd like to return it; otherwise, we'll fake it.
fc342a63 737AC_CACHE_CHECK([return type of usleep], guile_cv_func_usleep_return_type,
c43f86c1 738 [AC_EGREP_HEADER(changequote(<, >)<void[ ]+usleep>changequote([, ]),
4874dfc8 739 unistd.h,
fc342a63
JB
740 [guile_cv_func_usleep_return_type=void],
741 [guile_cv_func_usleep_return_type=int])])
742case "$guile_cv_func_usleep_return_type" in
743 "void" )
eede3dbc
RB
744 AC_DEFINE(USLEEP_RETURNS_VOID, 1,
745 [Define if the system headers declare usleep to return void.])
fc342a63
JB
746 ;;
747esac
748
da88f0cb
JB
749AC_CHECK_HEADER(sys/un.h, have_sys_un_h=1)
750if test -n "$have_sys_un_h" ; then
eede3dbc
RB
751 AC_DEFINE(HAVE_UNIX_DOMAIN_SOCKETS, 1,
752 [Define if the system supports Unix-domain (file-domain) sockets.])
da88f0cb
JB
753fi
754
d707b9df 755AC_CHECK_FUNCS(socketpair getgroups setgroups setpwent pause tzset)
da88f0cb 756
219a5a5b
JB
757AC_CHECK_FUNCS(sethostent gethostent endhostent dnl
758 setnetent getnetent endnetent dnl
759 setprotoent getprotoent endprotoent dnl
760 setservent getservent endservent dnl
5c11cc9d 761 getnetbyaddr getnetbyname dnl
2a0ef8b7
GH
762 inet_lnaof inet_makeaddr inet_netof hstrerror dnl
763 inet_pton inet_ntop)
da88f0cb 764
feef329e
KR
765# struct sockaddr field sin_len is only present on BSD systems.
766# On 4.4BSD apparently a #define SIN_LEN exists, but on other BSD systems
767# (eg. FreeBSD 4.9) it doesn't and we must use this configure check
768AC_CHECK_MEMBERS([struct sockaddr.sin_len],,,
769[#ifdef HAVE_SYS_TYPES_H
770#include <sys/types.h>
771#endif
772#include <netinet/in.h>])
773
d19c9767 774AC_MSG_CHECKING(for __libc_stack_end)
2e945bcc 775AC_CACHE_VAL(guile_cv_have_libc_stack_end,
c89363e6
MV
776[AC_TRY_LINK([#include <stdio.h>
777extern char *__libc_stack_end;],
778 [printf("%p", (char*) __libc_stack_end);],
2e945bcc
SJ
779 guile_cv_have_libc_stack_end=yes,
780 guile_cv_have_libc_stack_end=no)])
781AC_MSG_RESULT($guile_cv_have_libc_stack_end)
782
783if test $guile_cv_have_libc_stack_end = yes; then
d19c9767
MV
784 AC_DEFINE(HAVE_LIBC_STACK_END, 1,
785 [Define if you have the __libc_stack_end variable.])
786fi
787
08f980a4
GH
788dnl Some systems do not declare this. Some systems do declare it, as a
789dnl macro. With cygwin it may be in a DLL.
790
791AC_MSG_CHECKING(whether netdb.h declares h_errno)
792AC_CACHE_VAL(guile_cv_have_h_errno,
793[AC_TRY_COMPILE([#include <netdb.h>],
794[int a = h_errno;],
795guile_cv_have_h_errno=yes, guile_cv_have_h_errno=no)])
796AC_MSG_RESULT($guile_cv_have_h_errno)
797if test $guile_cv_have_h_errno = yes; then
eede3dbc 798 AC_DEFINE(HAVE_H_ERRNO, 1, [Define if h_errno is declared in netdb.h.])
08f980a4 799fi
da88f0cb 800
4f522b6f 801AC_MSG_CHECKING(whether uint32_t is defined)
c5316ea3 802AC_CACHE_VAL(guile_cv_have_uint32_t,
4f522b6f 803 [AC_TRY_COMPILE([#include <sys/types.h>
af68e5e5
SJ
804 #if HAVE_STDINT_H
805 #include <stdint.h>
806 #endif
45c0ff10 807 #ifndef HAVE_NETDB_H
af68e5e5
SJ
808 #include <netdb.h>
809 #endif],
4f522b6f
GH
810 [uint32_t a;],
811 guile_cv_have_uint32_t=yes, guile_cv_have_uint32_t=no)])
c5316ea3
GH
812AC_MSG_RESULT($guile_cv_have_uint32_t)
813if test $guile_cv_have_uint32_t = yes; then
eede3dbc
RB
814 AC_DEFINE(HAVE_UINT32_T, 1,
815 [Define if uint32_t typedef is defined when netdb.h is include.])
c5316ea3
GH
816fi
817
018a53a1
GH
818AC_MSG_CHECKING(for working IPv6 support)
819AC_CACHE_VAL(guile_cv_have_ipv6,
8f16fe5a
MV
820[AC_TRY_COMPILE([
821#ifdef HAVE_SYS_TYPES_H
822#include <sys/types.h>
823#endif
824#include <netinet/in.h>
b6f04d92 825#include <sys/socket.h>],
018a53a1
GH
826[struct sockaddr_in6 a; a.sin6_family = AF_INET6;],
827guile_cv_have_ipv6=yes, guile_cv_have_ipv6=no)])
828AC_MSG_RESULT($guile_cv_have_ipv6)
829if test $guile_cv_have_ipv6 = yes; then
eede3dbc 830 AC_DEFINE(HAVE_IPV6, 1, [Define if you want support for IPv6.])
018a53a1
GH
831fi
832
67641981
GH
833# included in rfc2553 but not in older implementations, e.g., glibc 2.1.3.
834AC_MSG_CHECKING(whether sockaddr_in6 has sin6_scope_id)
835AC_CACHE_VAL(guile_cv_have_sin6_scope_id,
8f16fe5a
MV
836[AC_TRY_COMPILE([
837#ifdef HAVE_SYS_TYPES_H
838#include <sys/types.h>
839#endif
840#include <netinet/in.h>],
67641981
GH
841[struct sockaddr_in6 sok; sok.sin6_scope_id = 0;],
842guile_cv_have_sin6_scope_id=yes, guile_cv_have_sin6_scope_id=no)])
843AC_MSG_RESULT($guile_cv_have_sin6_scope_id)
844if test $guile_cv_have_sin6_scope_id = yes; then
eede3dbc
RB
845 AC_DEFINE(HAVE_SIN6_SCOPE_ID, 1,
846 [Define this if your IPv6 has sin6_scope_id in sockaddr_in6 struct.])
67641981
GH
847fi
848
feef329e
KR
849# struct sockaddr_in6 field sin_len is only present on BSD systems
850AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_len],,,
851[#ifdef HAVE_SYS_TYPES_H
852#include <sys/types.h>
853#endif
854#include <netinet/in.h>])
855
38c1d3c4
GH
856AC_MSG_CHECKING(whether localtime caches TZ)
857AC_CACHE_VAL(guile_cv_localtime_cache,
858[if test x$ac_cv_func_tzset = xyes; then
859AC_TRY_RUN([#include <time.h>
860#if STDC_HEADERS
861# include <stdlib.h>
862#endif
863extern char **environ;
864unset_TZ ()
865{
866 char **from, **to;
867 for (to = from = environ; (*to = *from); from++)
868 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
869 to++;
870}
871char TZ_GMT0[] = "TZ=GMT0";
872char TZ_PST8[] = "TZ=PST8";
873main()
874{
875 time_t now = time ((time_t *) 0);
876 int hour_GMT0, hour_unset;
877 if (putenv (TZ_GMT0) != 0)
878 exit (1);
879 hour_GMT0 = localtime (&now)->tm_hour;
880 unset_TZ ();
881 hour_unset = localtime (&now)->tm_hour;
882 if (putenv (TZ_PST8) != 0)
883 exit (1);
884 if (localtime (&now)->tm_hour == hour_GMT0)
885 exit (1);
886 unset_TZ ();
887 if (localtime (&now)->tm_hour != hour_unset)
888 exit (1);
889 exit (0);
890}], guile_cv_localtime_cache=no, guile_cv_localtime_cache=yes,
891[# If we have tzset, assume the worst when cross-compiling.
892guile_cv_localtime_cache=yes])
893else
894 # If we lack tzset, report that localtime does not cache TZ,
895 # since we can't invalidate the cache if we don't have tzset.
896 guile_cv_localtime_cache=no
897fi])dnl
898AC_MSG_RESULT($guile_cv_localtime_cache)
899if test $guile_cv_localtime_cache = yes; then
eede3dbc 900 AC_DEFINE(LOCALTIME_CACHE, 1, [Define if localtime caches the TZ setting.])
38c1d3c4
GH
901fi
902
7ee92fce
GH
903dnl Test whether system calls are restartable by default on the
904dnl current system. If they are not, we put a loop around every system
905dnl call to check for EINTR (see SCM_SYSCALL) and do not attempt to
906dnl change from the default behaviour. On the other hand, if signals
907dnl are restartable then the loop is not installed and when libguile
908dnl initialises it also resets the behaviour of each signal to cause a
909dnl restart (in case a different runtime had a different default
910dnl behaviour for some reason: e.g., different versions of linux seem
911dnl to behave differently.)
912
08b8c694 913AC_SYS_RESTARTABLE_SYSCALLS
e1a191a8 914
52cfc69b
GH
915if test "$enable_regex" = yes; then
916 if test "$ac_cv_header_regex_h" = yes ||
917 test "$ac_cv_header_rxposix_h" = yes ||
918 test "$ac_cv_header_rx_rxposix_h" = yes; then
eede3dbc 919 GUILE_NAMED_CHECK_FUNC(regcomp, norx, [AC_LIBOBJ([regex-posix])],
52cfc69b 920 [AC_CHECK_LIB(rx, main)
eede3dbc 921 GUILE_NAMED_CHECK_FUNC(regcomp, rx, [AC_LIBOBJ([regex-posix])],
f9e5e096 922 [AC_CHECK_LIB(regex, main)
eede3dbc 923 GUILE_NAMED_CHECK_FUNC(regcomp, regex, [AC_LIBOBJ([regex-posix])])])]
52cfc69b
GH
924 )
925 dnl The following should not be necessary, but for some reason
926 dnl autoheader misses it if we don't include it!
927 if test "$ac_cv_func_regcomp_norx" = yes ||
f9e5e096 928 test "$ac_cv_func_regcomp_regex" = yes ||
52cfc69b 929 test "$ac_cv_func_regcomp_rx" = yes; then
eede3dbc
RB
930 AC_DEFINE(HAVE_REGCOMP, 1,
931 [This is included as part of a workaround for a autoheader bug.])
52cfc69b
GH
932 fi
933 fi
da88f0cb 934fi
8e1bfcd0 935
5bbfbd1e 936AC_REPLACE_FUNCS(inet_aton putenv strerror memmove mkstemp)
3a629497 937
594e69b7
MV
938AC_CHECK_HEADERS(floatingpoint.h ieeefp.h nan.h)
939
21b860c8
KR
940# Reasons for testing:
941# asinh, acosh, atanh, trunc - C99 standard, generally not available on
942# older systems
943# sincos - GLIBC extension
9af31eed 944#
8ab3d8a0 945AC_CHECK_FUNCS(asinh acosh atanh copysign finite sincos trunc)
4d0bfea1
KR
946
947# C99 specifies isinf and isnan as macros.
948# HP-UX provides only macros, no functions.
c80bab35
KR
949# glibc 2.3.2 provides both macros and functions.
950# IRIX 6.5 and Solaris 8 only provide functions.
4d0bfea1 951#
c80bab35
KR
952# The following tests detect isinf and isnan either as functions or as
953# macros from <math.h>. Plain AC_CHECK_FUNCS is insufficient, it doesn't
954# use <math.h> so doesn't detect on macro-only systems like HP-UX.
4d0bfea1
KR
955#
956AC_MSG_CHECKING([for isinf])
957AC_LINK_IFELSE(
958[#include <math.h>
959int main () { return (isinf(0.0) != 0); }],
960 [AC_MSG_RESULT([yes])
961 AC_DEFINE(HAVE_ISINF, 1,
962 [Define to 1 if you have the `isinf' macro or function.])],
963 [AC_MSG_RESULT([no])])
964AC_MSG_CHECKING([for isnan])
965AC_LINK_IFELSE(
966[#include <math.h>
967int main () { return (isnan(0.0) != 0); }],
968 [AC_MSG_RESULT([yes])
969 AC_DEFINE(HAVE_ISNAN, 1,
970 [Define to 1 if you have the `isnan' macro or function.])],
971 [AC_MSG_RESULT([no])])
594e69b7 972
31e4c69e
MV
973# We must have a proper stack-using alloca in order for stack-copying
974# continuations to work properly. If we don't find a native one,
975# abort.
976
3a629497 977AC_FUNC_ALLOCA
fb2de91a
RB
978if test "$ALLOCA" = "alloca.o"
979then
31e4c69e 980 AC_ERROR([No native alloca found.])
fb2de91a 981fi
3a629497 982
23f2b9a3
KR
983# Reasons for checking:
984#
985# st_rdev
986# st_blksize
987# st_blocks not in mingw
8ab3d8a0 988# tm_gmtoff BSD+GNU, not in C99
23f2b9a3
KR
989#
990# Note AC_STRUCT_ST_BLOCKS is not used here because we don't want the
991# AC_LIBOBJ(fileblocks) replacement which that macro gives.
992#
993AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blksize, struct stat.st_blocks])
fd02f2ad 994
3a629497 995AC_STRUCT_TIMEZONE
8ab3d8a0
KR
996AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,
997[#include <time.h>
998#ifdef TIME_WITH_SYS_TIME
999# include <sys/time.h>
1000# include <time.h>
1001#else
1002# if HAVE_SYS_TIME_H
1003# include <sys/time.h>
1004# else
1005# include <time.h>
1006# endif
1007#endif
1008])
3a629497
JB
1009GUILE_STRUCT_UTIMBUF
1010
8ab3d8a0 1011
3a629497
JB
1012#--------------------------------------------------------------------
1013#
1014# Which way does the stack grow?
1015#
1016#--------------------------------------------------------------------
1017
9a52bc2a 1018SCM_I_GSC_STACK_GROWS_UP=0
3a629497
JB
1019AC_TRY_RUN(aux (l) unsigned long l;
1020 { int x; exit (l >= ((unsigned long)&x)); }
01e5e07e 1021 main () { int q; aux((unsigned long)&q); },
d4628c57 1022 [SCM_I_GSC_STACK_GROWS_UP=1],
eede3dbc 1023 [],
9a52bc2a 1024 [AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)])
eede3dbc 1025
a9e0a8af
KR
1026AC_CHECK_SIZEOF(float)
1027if test "$ac_cv_sizeof_float" -le "$ac_cv_sizeof_long"; then
1028 AC_DEFINE(SCM_SINGLES, 1,
1029 [Define this if floats are the same size as longs.])
1030fi
3a629497
JB
1031
1032AC_MSG_CHECKING(for struct linger)
1033AC_CACHE_VAL(scm_cv_struct_linger,
1034 AC_TRY_COMPILE([
1035#include <sys/types.h>
1036#include <sys/socket.h>],
1037 [struct linger lgr; lgr.l_linger = 100],
1038 scm_cv_struct_linger="yes",
1039 scm_cv_struct_linger="no"))
1040AC_MSG_RESULT($scm_cv_struct_linger)
1041if test $scm_cv_struct_linger = yes; then
eede3dbc
RB
1042 AC_DEFINE(HAVE_STRUCT_LINGER, 1,
1043 [Define this if your system defines struct linger, for use with the
1044 getsockopt and setsockopt system calls.])
3a629497 1045fi
3a629497 1046
7534dfdc 1047
45c0ff10
KR
1048# On mingw, struct timespec is in <pthread.h>.
1049#
7534dfdc
MD
1050AC_MSG_CHECKING(for struct timespec)
1051AC_CACHE_VAL(scm_cv_struct_timespec,
1052 AC_TRY_COMPILE([
45c0ff10
KR
1053#include <time.h>
1054#if HAVE_PTHREAD_H
1055#include <pthread.h>
1056#endif],
7534dfdc
MD
1057 [struct timespec t; t.tv_nsec = 100],
1058 scm_cv_struct_timespec="yes",
1059 scm_cv_struct_timespec="no"))
1060AC_MSG_RESULT($scm_cv_struct_timespec)
1061if test $scm_cv_struct_timespec = yes; then
eede3dbc 1062 AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
45c0ff10 1063 [Define this if your system defines struct timespec via either <time.h> or <pthread.h>.])
7534dfdc
MD
1064fi
1065
3a629497
JB
1066#--------------------------------------------------------------------
1067#
1068# Flags for thread support
1069#
1070#--------------------------------------------------------------------
1071
9a52bc2a
RB
1072SCM_I_GSC_USE_PTHREAD_THREADS=0
1073SCM_I_GSC_USE_NULL_THREADS=0
9a52bc2a
RB
1074AC_SUBST([SCM_I_GSC_USE_PTHREAD_THREADS])
1075AC_SUBST([SCM_I_GSC_USE_NULL_THREADS])
9a52bc2a 1076
539c89a1
JB
1077### What thread package has the user asked for?
1078AC_ARG_WITH(threads, [ --with-threads thread interface],
18622c4e 1079 , with_threads=yes)
539c89a1 1080
8ab3d8a0
KR
1081AC_SUBST(SCM_I_GSC_NEED_BRACES_ON_PTHREAD_ONCE_INIT, 0)
1082
539c89a1 1083case "$with_threads" in
9bc4701c 1084 "yes" | "pthread" | "pthreads" | "pthread-threads" | "")
75bfae86 1085 ACX_PTHREAD(CC="$PTHREAD_CC"
75bfae86 1086 LIBS="$PTHREAD_LIBS $LIBS"
9a52bc2a 1087 SCM_I_GSC_USE_PTHREAD_THREADS=1
9bc4701c 1088 with_threads="pthreads",
18622c4e 1089 with_threads="null")
49aaa6d2
MV
1090
1091 old_CFLAGS="$CFLAGS"
1092 CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
8ab3d8a0
KR
1093
1094 # Reasons for testing:
1095 # pthread_getattr_np - "np" meaning "non portable" says it
1096 # all; not present on MacOS X or Solaris 10
45c0ff10
KR
1097 # pthread_get_stackaddr_np - "np" meaning "non portable" says it
1098 # all; specific to MacOS X
1099 # pthread_sigmask - not available on mingw
8ab3d8a0 1100 #
45c0ff10 1101 AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_sigmask)
8ab3d8a0
KR
1102
1103 # On past versions of Solaris, believe 8 through 10 at least, you
1104 # had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };".
1105 # This is contrary to posix:
1106 # http://www.opengroup.org/onlinepubs/000095399/functions/pthread_once.html
1107 # Check here if this style is required.
1108 #
1109 # glibc (2.3.6 at least) works both with or without braces, so the
1110 # test checks whether it works without.
1111 #
1112 AC_CACHE_CHECK([whether PTHREAD_ONCE_INIT needs braces],
1113 guile_cv_need_braces_on_pthread_once_init,
1114 [AC_TRY_COMPILE([#include <pthread.h>],
1115 [pthread_once_t foo = PTHREAD_ONCE_INIT;],
1116 [guile_cv_need_braces_on_pthread_once_init=no],
1117 [guile_cv_need_braces_on_pthread_once_init=yes])])
1118 if test "$guile_cv_need_braces_on_pthread_once_init" = yes; then
1119 SCM_I_GSC_NEED_BRACES_ON_PTHREAD_ONCE_INIT=1
1120 fi
1121
49aaa6d2
MV
1122 CFLAGS="$old_CFLAGS"
1123
d707b9df
MV
1124 # On Solaris, sched_yield lives in -lrt.
1125 AC_SEARCH_LIBS(sched_yield, rt)
1126
539c89a1 1127 ;;
539c89a1 1128esac
3a629497 1129
18622c4e 1130case "$with_threads" in
9bc4701c 1131 "pthreads")
585356dc 1132 ;;
18622c4e 1133 "no" | "null")
9a52bc2a 1134 SCM_I_GSC_USE_NULL_THREADS=1
18622c4e 1135 with_threads="null-threads"
18306183 1136 ;;
585356dc 1137 * )
18622c4e 1138 AC_MSG_ERROR(invalid value for --with-threads: $with_threads)
585356dc
MV
1139 ;;
1140esac
539c89a1 1141
18622c4e
MV
1142AC_MSG_CHECKING(what kind of threads to support)
1143AC_MSG_RESULT($with_threads)
933a7411 1144
4f416616
KR
1145## Check whether pthread_attr_getstack works for the main thread
1146
23f2b9a3
KR
1147if test "$with_threads" = pthreads; then
1148
4f416616
KR
1149AC_MSG_CHECKING(whether pthread_attr_getstack works for the main thread)
1150old_CFLAGS="$CFLAGS"
1151CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
1152AC_TRY_RUN(
1153[
1154#if HAVE_PTHREAD_ATTR_GETSTACK
1155#include <pthread.h>
1156
1157int main ()
1158{
1159 pthread_attr_t attr;
1160 void *start, *end;
1161 size_t size;
1162
1163 pthread_getattr_np (pthread_self (), &attr);
1164 pthread_attr_getstack (&attr, &start, &size);
1165 end = (char *)start + size;
1166
1167 if ((void *)&attr < start || (void *)&attr >= end)
1168 return 1;
1169 else
1170 return 0;
1171}
1172#else
1173int main ()
1174{
1175 return 1;
1176}
1177#endif
1178],
1179[works=yes
1180AC_DEFINE(PTHREAD_ATTR_GETSTACK_WORKS, [1], [Define when pthread_att_get_stack works for the main thread])],
1181[works=no])
1182CFLAGS="$old_CFLAGS"
1183AC_MSG_RESULT($works)
1184
23f2b9a3
KR
1185fi # with_threads=pthreads
1186
1187
0db83c04
MV
1188## Cross building
1189if test "$cross_compiling" = "yes"; then
1190 AC_MSG_CHECKING(cc for build)
1191 ## /usr/bin/cc still uses wrong assembler
1192 ## CC_FOR_BUILD="${CC_FOR_BUILD-/usr/bincc}"
1193 CC_FOR_BUILD="${CC_FOR_BUILD-PATH=/usr/bin:$PATH cc}"
1194else
1195 CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
1196fi
0db83c04
MV
1197
1198## AC_MSG_CHECKING("if we are cross compiling")
1199## AC_MSG_RESULT($cross_compiling)
1200if test "$cross_compiling" = "yes"; then
1201 AC_MSG_RESULT($CC_FOR_BUILD)
1202fi
1203
1204## No need as yet to be more elaborate
1205CCLD_FOR_BUILD="$CC_FOR_BUILD"
1206
1207AC_SUBST(cross_compiling)
457a4e81 1208AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
0db83c04
MV
1209AC_SUBST(CCLD_FOR_BUILD)
1210
1211## libtool erroneously calls CC_FOR_BUILD HOST_CC;
1212## --HOST is the platform that PACKAGE is compiled for.
1213HOST_CC="$CC_FOR_BUILD"
1214AC_SUBST(HOST_CC)
1215
1216if test "$cross_compiling" = "yes"; then
1217 AC_MSG_CHECKING(guile for build)
1218 GUILE_FOR_BUILD="${GUILE_FOR_BUILD-guile}"
1219else
1220 GUILE_FOR_BUILD='$(preinstguile)'
1221fi
0db83c04
MV
1222
1223## AC_MSG_CHECKING("if we are cross compiling")
1224## AC_MSG_RESULT($cross_compiling)
1225if test "$cross_compiling" = "yes"; then
1226 AC_MSG_RESULT($GUILE_FOR_BUILD)
1227fi
89f69c52 1228AC_ARG_VAR(GUILE_FOR_BUILD,[guile for build system])
0db83c04
MV
1229AC_SUBST(GUILE_FOR_BUILD)
1230
3a629497
JB
1231## If we're using GCC, ask for aggressive warnings.
1232case "$GCC" in
99be3450 1233 yes )
0a1b8b15
JB
1234 ## We had -Wstrict-prototypes in here for a bit, but Guile does too
1235 ## much stuff with generic function pointers for that to really be
1236 ## less than exasperating.
aee8ca3f
GH
1237 ## -Wpointer-arith was here too, but something changed in gcc/glibc
1238 ## and it became equally exasperating (gcc 2.95 and/or glibc 2.1.2).
5c07af6e
MV
1239 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
1240 # Do this here so we don't screw up any of the tests above that might
1241 # not be "warning free"
1242 if test "${GUILE_ERROR_ON_WARNING}" = yes
1243 then
1244 CFLAGS="${CFLAGS} -Werror"
1245 enable_compile_warnings=no
1246 fi
1247 ;;
3a629497
JB
1248esac
1249
3a629497
JB
1250## If we're creating a shared library (using libtool!), then we'll
1251## need to generate a list of .lo files corresponding to the .o files
1252## given in LIBOBJS. We'll call it LIBLOBJS.
eede3dbc 1253LIBLOBJS="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`"
3a629497 1254
e9e225e5 1255## We also need to create corresponding .doc and .x files
eede3dbc
RB
1256EXTRA_DOT_DOC_FILES="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.doc ,g;s,\.[[^.]]*$,.doc,'`"
1257EXTRA_DOT_X_FILES="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.x ,g;s,\.[[^.]]*$,.x,'`"
91411868 1258
7c86ae05
JB
1259AC_SUBST(GUILE_MAJOR_VERSION)
1260AC_SUBST(GUILE_MINOR_VERSION)
df4a8db0 1261AC_SUBST(GUILE_MICRO_VERSION)
9e6e154e 1262AC_SUBST(GUILE_EFFECTIVE_VERSION)
7c86ae05 1263AC_SUBST(GUILE_VERSION)
9e202853 1264
22b7f585
RB
1265#######################################################################
1266# library versioning
1267
9e202853
RB
1268AC_SUBST(LIBGUILE_INTERFACE_CURRENT)
1269AC_SUBST(LIBGUILE_INTERFACE_REVISION)
1270AC_SUBST(LIBGUILE_INTERFACE_AGE)
1271AC_SUBST(LIBGUILE_INTERFACE)
539c89a1 1272
b8b9ec68 1273AC_SUBST(LIBGUILE_SRFI_SRFI_1_MAJOR)
cfc7c7c0
MD
1274AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_CURRENT)
1275AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_REVISION)
1276AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_AGE)
1277AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE)
1278
b8b9ec68 1279AC_SUBST(LIBGUILE_SRFI_SRFI_4_MAJOR)
22b7f585
RB
1280AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_CURRENT)
1281AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_REVISION)
1282AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_AGE)
1283AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE)
1284
b8b9ec68 1285AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_MAJOR)
22b7f585
RB
1286AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_CURRENT)
1287AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_REVISION)
1288AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_AGE)
1289AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE)
1290
6bba4fad
KR
1291AC_SUBST(LIBGUILE_SRFI_SRFI_60_MAJOR)
1292AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_CURRENT)
1293AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_REVISION)
1294AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_AGE)
1295AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE)
1296
b89c4943
LC
1297AC_SUBST(LIBGUILE_I18N_MAJOR)
1298AC_SUBST(LIBGUILE_I18N_INTERFACE_CURRENT)
1299AC_SUBST(LIBGUILE_I18N_INTERFACE_REVISION)
1300AC_SUBST(LIBGUILE_I18N_INTERFACE_AGE)
1301AC_SUBST(LIBGUILE_I18N_INTERFACE)
1302
1303
22b7f585
RB
1304#######################################################################
1305
d8b1bb93 1306dnl Tell guile-config what flags guile users should compile and link with.
a8d7ba11 1307GUILE_LIBS="$LDFLAGS $LIBS"
d8b1bb93 1308GUILE_CFLAGS="$PTHREAD_CFLAGS"
daa4f38c 1309AC_SUBST(GUILE_LIBS)
d8b1bb93 1310AC_SUBST(GUILE_CFLAGS)
7c86ae05 1311
3a629497
JB
1312AC_SUBST(AWK)
1313AC_SUBST(LIBLOBJS)
91411868 1314AC_SUBST(EXTRA_DOT_DOC_FILES)
e9e225e5 1315AC_SUBST(EXTRA_DOT_X_FILES)
3a629497 1316
6812c28f
TTN
1317dnl See also top_builddir in info node: (libtool)AC_PROG_LIBTOOL
1318top_builddir_absolute=`pwd`
1319AC_SUBST(top_builddir_absolute)
9e6e154e 1320top_srcdir_absolute=`(cd $srcdir && pwd)`
2f13db9a 1321AC_SUBST(top_srcdir_absolute)
6812c28f 1322
9a52bc2a
RB
1323# Additional SCM_I_GSC definitions are above.
1324AC_SUBST([SCM_I_GSC_GUILE_DEBUG])
1325AC_SUBST([SCM_I_GSC_GUILE_DEBUG_FREELIST])
f5922e27 1326AC_SUBST([SCM_I_GSC_ENABLE_DISCOURAGED])
9a52bc2a
RB
1327AC_SUBST([SCM_I_GSC_ENABLE_DEPRECATED])
1328AC_SUBST([SCM_I_GSC_ENABLE_ELISP])
9a52bc2a
RB
1329AC_SUBST([SCM_I_GSC_STACK_GROWS_UP])
1330AC_SUBST([SCM_I_GSC_C_INLINE])
1331AC_CONFIG_FILES([libguile/gen-scmconfig.h])
1332
237b3247
RB
1333AC_CONFIG_FILES([
1334 Makefile
6812c28f 1335 am/Makefile
9e6e154e
RB
1336 benchmark-suite/Makefile
1337 doc/Makefile
1338 doc/goops/Makefile
1339 doc/r5rs/Makefile
1340 doc/ref/Makefile
1341 doc/tutorial/Makefile
1e2346ae 1342 emacs/Makefile
9e6e154e
RB
1343 examples/Makefile
1344 examples/box-dynamic-module/Makefile
1345 examples/box-dynamic/Makefile
1346 examples/box-module/Makefile
1347 examples/box/Makefile
1348 examples/modules/Makefile
1349 examples/safe/Makefile
1350 examples/scripts/Makefile
1351 guile-config/Makefile
237b3247 1352 ice-9/Makefile
8ee7506b 1353 ice-9/debugger/Makefile
8746959c 1354 ice-9/debugging/Makefile
3d1a89b9
NJ
1355 lang/Makefile
1356 lang/elisp/Makefile
1357 lang/elisp/internals/Makefile
1358 lang/elisp/primitives/Makefile
9e6e154e 1359 libguile/Makefile
237b3247
RB
1360 oop/Makefile
1361 oop/goops/Makefile
1362 scripts/Makefile
1363 srfi/Makefile
849f29a4
RB
1364 test-suite/Makefile
1365 test-suite/standalone/Makefile
1366])
9e6e154e
RB
1367
1368AC_CONFIG_FILES([check-guile], [chmod +x check-guile])
1369AC_CONFIG_FILES([benchmark-guile], [chmod +x benchmark-guile])
1370AC_CONFIG_FILES([guile-tools], [chmod +x guile-tools])
1371AC_CONFIG_FILES([pre-inst-guile], [chmod +x pre-inst-guile])
849f29a4 1372AC_CONFIG_FILES([pre-inst-guile-env], [chmod +x pre-inst-guile-env])
9e6e154e
RB
1373AC_CONFIG_FILES([libguile/guile-snarf],
1374 [chmod +x libguile/guile-snarf])
1375AC_CONFIG_FILES([libguile/guile-doc-snarf],
1376 [chmod +x libguile/guile-doc-snarf])
1377AC_CONFIG_FILES([libguile/guile-func-name-check],
1378 [chmod +x libguile/guile-func-name-check])
1379AC_CONFIG_FILES([libguile/guile-snarf-docs],
1380 [chmod +x libguile/guile-snarf-docs])
237b3247
RB
1381
1382AC_OUTPUT
0f2d19dd 1383
3a629497
JB
1384dnl Local Variables:
1385dnl comment-start: "dnl "
1386dnl comment-end: ""
1387dnl comment-start-skip: "\\bdnl\\b\\s *"
d67c13f6 1388dnl End: