Implementation for the R6RS (rnrs programs) library.
[bpt/guile.git] / configure.ac
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
75c242a2 7Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
a73256d0
KR
8
9This file is part of GUILE
10
53befeb7
NJ
11GUILE is free software; you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the
13Free Software Foundation; either version 3, or (at your option) any
14later version.
a73256d0 15
53befeb7
NJ
16GUILE is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19License for more details.
a73256d0 20
53befeb7
NJ
21You should have received a copy of the GNU Lesser General Public
22License along with GUILE; see the file COPYING.LESSER. If not, write
23to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
24Floor, Boston, MA 02110-1301, USA.
a73256d0
KR
25
26]])
50848747 27
4bdc8fb5 28AC_PREREQ(2.61)
237b3247 29
b3aa4626
KR
30dnl `patsubst' here deletes the newline which "echo" prints. We can't use
31dnl "echo -n" since -n is not portable (see autoconf manual "Limitations of
32dnl Builtins"), in particular on solaris it results in a literal "-n" in
33dnl the output.
34dnl
0c1eb9b6 35AC_INIT([GNU Guile],
b3aa4626
KR
36 patsubst(m4_esyscmd(. ./GUILE-VERSION && echo ${GUILE_VERSION}),[
37]),
2039f7be 38 [bug-guile@gnu.org])
f6b4d9b4
LC
39AC_CONFIG_AUX_DIR([build-aux])
40AC_CONFIG_MACRO_DIR([m4])
5ae51dad 41AC_CONFIG_SRCDIR(GUILE-VERSION)
f6b4d9b4 42
47871d5a 43AM_INIT_AUTOMAKE([gnu no-define check-news -Wall -Wno-override])
5ae51dad 44
a73256d0 45AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT)
8907576f 46AC_CONFIG_SRCDIR([GUILE-VERSION])
5ae51dad 47
2d26def0 48. $srcdir/GUILE-VERSION
5ae51dad 49
4bdc8fb5 50AC_CONFIG_HEADERS([config.h])
a73256d0 51AH_TOP(/*GUILE_CONFIGURE_COPYRIGHT*/)
2d26def0 52
a6be66ed
RB
53#--------------------------------------------------------------------
54
4bdc8fb5
LC
55AC_LANG([C])
56
a6be66ed 57dnl Some more checks for Win32
4bdc8fb5
LC
58AC_CANONICAL_HOST
59
a6be66ed
RB
60AC_LIBTOOL_WIN32_DLL
61
62AC_PROG_INSTALL
63AC_PROG_CC
6caac03c 64gl_EARLY
a6be66ed 65AC_PROG_CPP
c2be4e89 66AC_PROG_SED
a6be66ed
RB
67AC_PROG_AWK
68
6caac03c
LC
69dnl Gnulib.
70gl_INIT
a6be66ed 71
4bdc8fb5
LC
72AC_PROG_CC_C89
73
45c0ff10
KR
74# for per-target cflags in the libguile subdir
75AM_PROG_CC_C_O
a6be66ed
RB
76
77AC_LIBTOOL_DLOPEN
c78a96e0 78AC_PROG_LIBTOOL
a98dbc87
MV
79AC_CHECK_LIB([ltdl], [lt_dlinit], ,
80 [AC_MSG_ERROR([libltdl not found. See README.])])
96e3f63a
LC
81AC_CHECK_HEADER([ltdl.h], [],
82 [AC_MSG_ERROR([<ltdl.h> not found. See README.])])
a6be66ed
RB
83
84AC_CHECK_PROG(have_makeinfo, makeinfo, yes, no)
85AM_CONDITIONAL(HAVE_MAKEINFO, test "$have_makeinfo" = yes)
86
d995da7f
NJ
87AM_PATH_LISPDIR
88
d7a22073
LC
89AC_DEFINE_UNQUOTED([HOST_TYPE], ["$host"],
90 [Define to the host's GNU triplet.])
91
0e8a8468 92#--------------------------------------------------------------------
3a629497 93#
a6be66ed 94# User options (after above tests that may set default CFLAGS etc.)
3a629497
JB
95#
96#--------------------------------------------------------------------
86789f9b 97
13922e3f 98GUILE_ERROR_ON_WARNING="no"
bdcccc18 99
8afd1a2a
RB
100AC_ARG_ENABLE(error-on-warning,
101 [ --enable-error-on-warning treat compile warnings as errors],
102 [case "${enableval}" in
bdcccc18
RB
103 yes | y) GUILE_ERROR_ON_WARNING="yes" ;;
104 no | n) GUILE_ERROR_ON_WARNING="no" ;;
8afd1a2a
RB
105 *) AC_MSG_ERROR(bad value ${enableval} for --enable-error-on-warning) ;;
106 esac])
107
cf890744 108AC_ARG_ENABLE(debug-malloc,
e73dd549 109 [ --enable-debug-malloc include malloc debugging code],
cf890744 110 if test "$enable_debug_malloc" = y || test "$enable_debug_malloc" = yes; then
feef98f2 111 AC_DEFINE([GUILE_DEBUG_MALLOC], 1,
eede3dbc 112 [Define this if you want to debug scm_must_malloc/realloc/free calls.])
cf890744
MD
113 fi)
114
9a52bc2a 115SCM_I_GSC_GUILE_DEBUG=0
62002dcb 116AC_ARG_ENABLE(guile-debug,
4bdc8fb5 117 [AS_HELP_STRING([--enable-guile-debug],
9a52bc2a 118 [include internal debugging functions])],
62002dcb 119 if test "$enable_guile_debug" = y || test "$enable_guile_debug" = yes; then
9a52bc2a 120 SCM_I_GSC_GUILE_DEBUG=1
62002dcb
MD
121 fi)
122
52cfc69b
GH
123AC_ARG_ENABLE(posix,
124 [ --disable-posix omit posix interfaces],,
125 enable_posix=yes)
126
127AC_ARG_ENABLE(networking,
dc914156 128 [ --disable-networking omit networking interfaces],,
52cfc69b
GH
129 enable_networking=yes)
130
131AC_ARG_ENABLE(regex,
132 [ --disable-regex omit regular expression interfaces],,
133 enable_regex=yes)
134
f5922e27 135AC_ARG_ENABLE([discouraged],
4bdc8fb5 136 AS_HELP_STRING([--disable-discouraged],[omit discouraged features]))
f5922e27
MV
137
138if test "$enable_discouraged" = no; then
139 SCM_I_GSC_ENABLE_DISCOURAGED=0
140else
141 SCM_I_GSC_ENABLE_DISCOURAGED=1
142fi
143
9a52bc2a 144AC_ARG_ENABLE([deprecated],
4bdc8fb5 145 AS_HELP_STRING([--disable-deprecated],[omit deprecated features]))
eede3dbc 146
e73dd549 147if test "$enable_deprecated" = no; then
9a52bc2a 148 SCM_I_GSC_ENABLE_DEPRECATED=0
6ab8238d 149 warn_default=no
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
e73dd549 159fi
feef98f2 160AC_DEFINE_UNQUOTED([SCM_WARN_DEPRECATED_DEFAULT], "$warn_default",
6ab8238d 161[Define this to control the default warning level for deprecated features.])
e73dd549 162
d05bcb2e
NJ
163dnl Added the following configure option in January 2008 following
164dnl investigation of problems with "64" system and library calls on
165dnl Darwin (MacOS X). The libguile code (_scm.h) assumes that if a
166dnl system has stat64, it will have all the other 64 APIs too; but on
167dnl Darwin, stat64 is there but other APIs are missing.
168dnl
169dnl It also appears, from the Darwin docs, that most system call APIs
170dnl there (i.e. the traditional ones _without_ "64" in their names) have
171dnl been 64-bit-capable for a long time now, so it isn't necessary to
172dnl use "64" versions anyway. For example, Darwin's off_t is 64-bit.
173dnl
174dnl A similar problem has been reported for HP-UX:
175dnl http://www.nabble.com/Building-guile-1.8.2-on-hpux-td13106681.html
176dnl
177dnl Therefore, and also because a Guile without LARGEFILE64 support is
178dnl better than no Guile at all, we provide this option to suppress
179dnl trying to use "64" calls.
180dnl
181dnl It may be that for some 64-bit function on Darwin/HP-UX we do need
182dnl to use a "64" call, and hence that by using --without-64-calls we're
183dnl missing out on that. If so, someone can work on that in the future.
184dnl For now, --without-64-calls allows Guile to build on OSs where it
185dnl wasn't building before.
4b26c03e 186AC_MSG_CHECKING([whether to use system and library "64" calls])
d05bcb2e 187AC_ARG_WITH([64-calls],
4bdc8fb5 188 AS_HELP_STRING([--without-64-calls],
d05bcb2e
NJ
189 [don't attempt to use system and library calls with "64" in their names]),
190 [use_64_calls=$withval],
191 [use_64_calls=yes
192 case $host in
193 *-apple-darwin* )
194 use_64_calls=no
195 ;;
32b164aa
NJ
196 powerpc-ibm-aix* )
197 use_64_calls=no
198 ;;
d05bcb2e 199 esac])
4b26c03e 200AC_MSG_RESULT($use_64_calls)
d05bcb2e
NJ
201case "$use_64_calls" in
202 y* )
feef98f2 203 AC_DEFINE([GUILE_USE_64_CALLS], 1,
d05bcb2e
NJ
204 [Define to 1 in order to try to use "64" versions of system and library calls.])
205 ;;
206esac
207
a44e61ac
MV
208#--------------------------------------------------------------------
209
4f6f9ae3
GH
210dnl Check for dynamic linking
211
212use_modules=yes
213AC_ARG_WITH(modules,
214[ --with-modules[=FILES] Add support for dynamic modules],
215use_modules="$withval")
216test -z "$use_modules" && use_modules=yes
217DLPREOPEN=
218if test "$use_modules" != no; then
4f6f9ae3
GH
219 if test "$use_modules" = yes; then
220 DLPREOPEN="-dlpreopen force"
221 else
222 DLPREOPEN="-export-dynamic"
223 for module in $use_modules; do
224 DLPREOPEN="$DLPREOPEN -dlopen $module"
225 done
226 fi
227fi
228
52cfc69b
GH
229dnl files which are destined for separate modules.
230
4f6f9ae3
GH
231if test "$use_modules" != no; then
232 AC_LIBOBJ([dynl])
233fi
234
52cfc69b 235if test "$enable_posix" = yes; then
eede3dbc
RB
236 AC_LIBOBJ([filesys])
237 AC_LIBOBJ([posix])
feef98f2 238 AC_DEFINE([HAVE_POSIX], 1,
eede3dbc 239 [Define this if you want support for POSIX system calls in Guile.])
52cfc69b
GH
240fi
241
242if test "$enable_networking" = yes; then
eede3dbc
RB
243 AC_LIBOBJ([net_db])
244 AC_LIBOBJ([socket])
feef98f2 245 AC_DEFINE([HAVE_NETWORKING], 1,
eede3dbc 246 [Define this if you want support for networking in Guile.])
52cfc69b
GH
247fi
248
cf890744 249if test "$enable_debug_malloc" = yes; then
eede3dbc 250 AC_LIBOBJ([debug-malloc])
cf890744
MD
251fi
252
9a5fa6e9 253AC_CHECK_LIB(uca, __uc_get_ar_bsp)
3d1a89b9 254
3a629497 255AC_C_CONST
5b079b46 256
b3aa4626
KR
257# "volatile" is used in a couple of tests below.
258AC_C_VOLATILE
259
9a52bc2a 260AC_C_INLINE
5bd732c9 261if test "$ac_cv_c_inline" != no; then
9a52bc2a
RB
262 SCM_I_GSC_C_INLINE="\"${ac_cv_c_inline}\""
263else
264 SCM_I_GSC_C_INLINE=NULL
5bd732c9 265fi
9a5fa6e9 266AC_CHECK_LIB(uca, __uc_get_ar_bsp)
5bd732c9 267
9a52bc2a
RB
268AC_C_BIGENDIAN
269
659b4611
AW
270AC_C_LABELS_AS_VALUES
271
9a52bc2a
RB
272AC_CHECK_SIZEOF(char)
273AC_CHECK_SIZEOF(unsigned char)
813b3dd4 274AC_CHECK_SIZEOF(short)
9a52bc2a 275AC_CHECK_SIZEOF(unsigned short)
9dec9737 276AC_CHECK_SIZEOF(int)
9a52bc2a 277AC_CHECK_SIZEOF(unsigned int)
9dec9737 278AC_CHECK_SIZEOF(long)
9a52bc2a 279AC_CHECK_SIZEOF(unsigned long)
813b3dd4 280AC_CHECK_SIZEOF(size_t)
813b3dd4 281AC_CHECK_SIZEOF(long long)
9a52bc2a 282AC_CHECK_SIZEOF(unsigned long long)
fcc5d734
SJ
283AC_CHECK_SIZEOF(__int64)
284AC_CHECK_SIZEOF(unsigned __int64)
1be6b49c 285AC_CHECK_SIZEOF(void *)
9a52bc2a
RB
286AC_CHECK_SIZEOF(intptr_t)
287AC_CHECK_SIZEOF(uintptr_t)
288AC_CHECK_SIZEOF(ptrdiff_t)
d20008c0 289AC_CHECK_SIZEOF(size_t)
4f416616 290AC_CHECK_SIZEOF(off_t)
1be6b49c 291
f3f70257
ML
292if test "$ac_cv_sizeof_long" -ne "$ac_cv_sizeof_void_p"; then
293 AC_MSG_ERROR(sizes of long and void* are not identical)
9dec9737 294fi
3a629497 295
c134fe9d 296if test "$ac_cv_sizeof_ptrdiff_t" -ne 0; then
9a52bc2a
RB
297 SCM_I_GSC_T_PTRDIFF='"ptrdiff_t"'
298else
299 SCM_I_GSC_T_PTRDIFF='"long"'
300fi
301AC_SUBST([SCM_I_GSC_T_PTRDIFF])
302
303AC_CHECK_HEADERS([stdint.h])
304AC_CHECK_HEADERS([inttypes.h])
305
d20008c0
MV
306AC_CHECK_SIZEOF(intmax_t)
307
9a52bc2a
RB
308SCM_I_GSC_NEEDS_STDINT_H=0
309SCM_I_GSC_NEEDS_INTTYPES_H=0
310
311### intptr and uintptr (try not to use inttypes if we don't have to)
312if test "$ac_cv_header_inttypes_h" = yes; then
313 if test "$ac_cv_sizeof_intptr_t" -eq 0; then
314 AC_CHECK_SIZEOF([intptr_t],,[#include <inttypes.h>
315#include <stdio.h>])
316 if test "$ac_cv_sizeof_intptr_t" -ne 0; then
317 SCM_I_GSC_NEEDS_INTTYPES_H=1
318 fi
319 fi
320 if test "$ac_cv_sizeof_uintptr_t" -eq 0; then
321 AC_CHECK_SIZEOF([uintptr_t],,[#include <inttypes.h>
322#include <stdio.h>])
323 if test "$ac_cv_sizeof_uintptr_t" -ne 0; then
324 SCM_I_GSC_NEEDS_INTTYPES_H=1
325 fi
326 fi
327fi
328
329### See what's provided by stdint.h
330if test "$ac_cv_header_stdint_h" = yes; then
331 AC_CHECK_TYPE([int8_t],[scm_stdint_has_int8=1],,[#include <stdint.h>])
332 AC_CHECK_TYPE([uint8_t],[scm_stdint_has_uint8=1],,[#include <stdint.h>])
333 AC_CHECK_TYPE([int16_t],[scm_stdint_has_int16=1],,[#include <stdint.h>])
334 AC_CHECK_TYPE([uint16_t],[scm_stdint_has_uint16=1],,[#include <stdint.h>])
335 AC_CHECK_TYPE([int32_t],[scm_stdint_has_int32=1],,[#include <stdint.h>])
336 AC_CHECK_TYPE([uint32_t],[scm_stdint_has_uint32=1],,[#include <stdint.h>])
337 AC_CHECK_TYPE([int64_t],[scm_stdint_has_int64=1],,[#include <stdint.h>])
338 AC_CHECK_TYPE([uint64_t],[scm_stdint_has_uint64=1],,[#include <stdint.h>])
eb1f89f6
MV
339 AC_CHECK_TYPE([intmax_t],[scm_stdint_has_intmax=1],,[#include <stdint.h>])
340 AC_CHECK_TYPE([uintmax_t],[scm_stdint_has_uintmax=1],,[#include <stdint.h>])
114bc68a
LC
341 AC_CHECK_TYPE([intptr_t],[scm_stdint_has_intptr=1],,[#include <stdint.h>])
342 AC_CHECK_TYPE([uintptr_t],[scm_stdint_has_uintptr=1],,[#include <stdint.h>])
9a52bc2a
RB
343fi
344
345# so we don't get confused by the cache (wish there was a better way
346# to check particular headers for the same type...)
347
348unset ac_cv_type_int8_t
349unset ac_cv_type_uint8_t
350unset ac_cv_type_int16_t
351unset ac_cv_type_uint16_t
352unset ac_cv_type_int32_t
353unset ac_cv_type_uint32_t
354unset ac_cv_type_int64_t
355unset ac_cv_type_uint64_t
eb1f89f6
MV
356unset ac_cv_type_intmax_t
357unset ac_cv_type_uintmax_t
9a52bc2a
RB
358
359### See what's provided by inttypes.h
360if test "$ac_cv_header_inttypes_h" = yes; then
361 AC_CHECK_TYPE([int8_t],[scm_inttypes_has_int8=1],,[#include <inttypes.h>])
362 AC_CHECK_TYPE([uint8_t],[scm_inttypes_has_uint8=1],,[#include <inttypes.h>])
363 AC_CHECK_TYPE([int16_t],[scm_inttypes_has_int16=1],,[#include <inttypes.h>])
364 AC_CHECK_TYPE([uint16_t],[scm_inttypes_has_uint16=1],,[#include <inttypes.h>])
365 AC_CHECK_TYPE([int32_t],[scm_inttypes_has_int32=1],,[#include <inttypes.h>])
366 AC_CHECK_TYPE([uint32_t],[scm_inttypes_has_uint32=1],,[#include <inttypes.h>])
367 AC_CHECK_TYPE([int64_t],[scm_inttypes_has_int64=1],,[#include <inttypes.h>])
368 AC_CHECK_TYPE([uint64_t],[scm_inttypes_has_uint64=1],,[#include <inttypes.h>])
eb1f89f6
MV
369 AC_CHECK_TYPE([intmax_t],[scm_inttypes_has_intmax=1],,[#include <inttypes.h>])
370 AC_CHECK_TYPE([uintmax_t],[scm_inttypes_has_uintmax=1],,[#include <inttypes.h>])
114bc68a
LC
371 AC_CHECK_TYPE([intptr_t],[scm_inttypes_has_intptr=1],,[#include <inttypes.h>])
372 AC_CHECK_TYPE([uintptr_t],[scm_inttypes_has_uintptr=1],,[#include <inttypes.h>])
9a52bc2a
RB
373fi
374
375# Try hard to find definitions for some required scm_t_*int* types.
376
377### Required type scm_t_int8
6aa84fdd 378if test "$scm_stdint_has_int8"; then
9a52bc2a
RB
379 SCM_I_GSC_T_INT8='"int8_t"'
380 SCM_I_GSC_NEEDS_STDINT_H=1
381elif test "$scm_inttypes_has_int8"; then
382 SCM_I_GSC_T_INT8='"int8_t"'
383 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
384elif test "$ac_cv_sizeof_char" -eq 1; then
385 SCM_I_GSC_T_INT8='"signed char"'
9a52bc2a
RB
386else
387 AC_MSG_ERROR([Can't find appropriate type for scm_t_int8.])
388fi
389AC_SUBST([SCM_I_GSC_T_INT8])
390
391### Required type scm_t_uint8
6aa84fdd 392if test "$scm_stdint_has_uint8"; then
9a52bc2a
RB
393 SCM_I_GSC_T_UINT8='"uint8_t"'
394 SCM_I_GSC_NEEDS_STDINT_H=1
395elif test "$scm_inttypes_has_uint8"; then
396 SCM_I_GSC_T_UINT8='"uint8_t"'
397 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
398elif test "$ac_cv_sizeof_unsigned_char" -eq 1; then
399 SCM_I_GSC_T_UINT8='"unsigned char"'
9a52bc2a
RB
400else
401 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint8.])
402fi
403AC_SUBST([SCM_I_GSC_T_UINT8])
9a52bc2a
RB
404
405### Required type scm_t_int16 (ANSI C says int or short might work)
6aa84fdd 406if test "$scm_stdint_has_int16"; then
9a52bc2a
RB
407 SCM_I_GSC_T_INT16='"int16_t"'
408 SCM_I_GSC_NEEDS_STDINT_H=1
409elif test "$scm_inttypes_has_int16"; then
410 SCM_I_GSC_T_INT16='"int16_t"'
411 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
412elif test "$ac_cv_sizeof_int" -eq 2; then
413 SCM_I_GSC_T_INT16='"int"'
6aa84fdd
MV
414elif test "$ac_cv_sizeof_short" -eq 2; then
415 SCM_I_GSC_T_INT16='"short"'
9a52bc2a
RB
416else
417 AC_MSG_ERROR([Can't find appropriate type for scm_t_int16.])
418fi
419AC_SUBST([SCM_I_GSC_T_INT16])
420
421### Required type scm_t_uint16 (ANSI C says int or short might work)
6aa84fdd 422if test "$scm_stdint_has_uint16"; then
9a52bc2a
RB
423 SCM_I_GSC_T_UINT16='"uint16_t"'
424 SCM_I_GSC_NEEDS_STDINT_H=1
425elif test "$scm_inttypes_has_uint16"; then
426 SCM_I_GSC_T_UINT16='"uint16_t"'
427 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
428elif test "$ac_cv_sizeof_unsigned_int" -eq 2; then
429 SCM_I_GSC_T_UINT16='"unsigned int"'
6aa84fdd
MV
430elif test "$ac_cv_sizeof_unsigned_short" -eq 2; then
431 SCM_I_GSC_T_UINT16='"unsigned short"'
9a52bc2a
RB
432else
433 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint16.])
434fi
435AC_SUBST([SCM_I_GSC_T_UINT16])
436
437
438### Required type scm_t_int32 (ANSI C says int, short, or long might work)
6aa84fdd 439if test "$scm_stdint_has_int32"; then
9a52bc2a
RB
440 SCM_I_GSC_T_INT32='"int32_t"'
441 SCM_I_GSC_NEEDS_STDINT_H=1
442elif test "$scm_inttypes_has_int32"; then
443 SCM_I_GSC_T_INT32='"int32_t"'
444 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
445elif test "$ac_cv_sizeof_int" -eq 4; then
446 SCM_I_GSC_T_INT32='"int"'
6aa84fdd
MV
447elif test "$ac_cv_sizeof_long" -eq 4; then
448 SCM_I_GSC_T_INT32='"long"'
6aa84fdd
MV
449elif test "$ac_cv_sizeof_short" -eq 4; then
450 SCM_I_GSC_T_INT32='"short"'
9a52bc2a
RB
451else
452 AC_MSG_ERROR([Can't find appropriate type for scm_t_int32.])
453fi
454AC_SUBST([SCM_I_GSC_T_INT32])
455
456### Required type scm_t_uint32 (ANSI C says int, short, or long might work)
6aa84fdd 457if test "$scm_stdint_has_uint32"; then
9a52bc2a
RB
458 SCM_I_GSC_T_UINT32='"uint32_t"'
459 SCM_I_GSC_NEEDS_STDINT_H=1
460elif test "$scm_inttypes_has_uint32"; then
461 SCM_I_GSC_T_UINT32='"uint32_t"'
462 SCM_I_GSC_NEEDS_INTTYPES_H=1
6aa84fdd
MV
463elif test "$ac_cv_sizeof_unsigned_int" -eq 4; then
464 SCM_I_GSC_T_UINT32='"unsigned int"'
6aa84fdd
MV
465elif test "$ac_cv_sizeof_unsigned_long" -eq 4; then
466 SCM_I_GSC_T_UINT32='"unsigned long"'
6aa84fdd
MV
467elif test "$ac_cv_sizeof_unsigned_short" -eq 4; then
468 SCM_I_GSC_T_UINT32='"unsigned short"'
9a52bc2a
RB
469else
470 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint32.])
471fi
472AC_SUBST([SCM_I_GSC_T_UINT32])
473
a6be66ed 474### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
fcc5d734 475### Also try 'long long' and '__int64' if we have it.
9a52bc2a 476SCM_I_GSC_T_INT64=0
6aa84fdd
MV
477if test "$scm_stdint_has_int64"; then
478 SCM_I_GSC_T_INT64='"int64_t"'
6aa84fdd
MV
479 SCM_I_GSC_NEEDS_STDINT_H=1
480elif test "$scm_inttypes_has_int64"; then
481 SCM_I_GSC_T_INT64='"int64_t"'
6aa84fdd
MV
482 SCM_I_GSC_NEEDS_INTTYPES_H=1
483elif test "$ac_cv_sizeof_int" -eq 8; then
9a52bc2a
RB
484 SCM_I_GSC_T_INT64='"int"'
485elif test "$ac_cv_sizeof_long" -eq 8; then
486 SCM_I_GSC_T_INT64='"long"'
487elif test "$ac_cv_sizeof_short" -eq 8; then
488 SCM_I_GSC_T_INT64='"short"'
489elif test "$ac_cv_sizeof_long_long" -eq 8; then
490 SCM_I_GSC_T_INT64='"long long"'
fcc5d734
SJ
491elif test "$ac_cv_sizeof___int64" -eq 8; then
492 SCM_I_GSC_T_INT64='"__int64"'
9a52bc2a
RB
493else
494 AC_MSG_ERROR([Can't find appropriate type for scm_t_int64.])
495fi
496AC_SUBST([SCM_I_GSC_T_INT64])
6aa84fdd 497
9a52bc2a 498
a6be66ed 499### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
fcc5d734 500### Also try 'long long' and '__int64' if we have it.
9a52bc2a 501SCM_I_GSC_T_UINT64=0
6aa84fdd
MV
502if test "$scm_stdint_has_uint64"; then
503 SCM_I_GSC_T_UINT64='"uint64_t"'
6aa84fdd
MV
504 SCM_I_GSC_NEEDS_STDINT_H=1
505elif test "$scm_inttypes_has_uint64"; then
506 SCM_I_GSC_T_UINT64='"uint64_t"'
6aa84fdd
MV
507 SCM_I_GSC_NEEDS_INTTYPES_H=1
508elif test "$ac_cv_sizeof_unsigned_int" -eq 8; then
9a52bc2a
RB
509 SCM_I_GSC_T_UINT64='"unsigned int"'
510elif test "$ac_cv_sizeof_unsigned_long" -eq 8; then
511 SCM_I_GSC_T_UINT64='"unsigned long"'
512elif test "$ac_cv_sizeof_unsigned_short" -eq 8; then
513 SCM_I_GSC_T_UINT64='"unsigned short"'
514elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
515 SCM_I_GSC_T_UINT64='"unsigned long long"'
fcc5d734
SJ
516elif test "$ac_cv_sizeof_unsigned___int64" -eq 8; then
517 SCM_I_GSC_T_UINT64='"unsigned __int64"'
9a52bc2a
RB
518else
519 AC_MSG_ERROR([Can't find appropriate type for scm_t_uint64.])
520fi
521AC_SUBST([SCM_I_GSC_T_UINT64])
522
eb1f89f6
MV
523### Required type scm_t_intmax
524###
525### We try 'intmax_t', '__int64', 'long long' in this order. When
526### none of them is available, we use 'long'.
527###
528SCM_I_GSC_T_INTMAX=0
529if test "$scm_stdint_has_intmax"; then
530 SCM_I_GSC_T_INTMAX='"intmax_t"'
531 SCM_I_GSC_NEEDS_STDINT_H=1
532elif test "$scm_inttypes_has_intmax"; then
533 SCM_I_GSC_T_INTMAX='"intmax_t"'
534 SCM_I_GSC_NEEDS_INTTYPES_H=1
535elif test "$ac_cv_sizeof___int64" -ne 0; then
536 SCM_I_GSC_T_INTMAX='"__int64"'
537elif test "$ac_cv_sizeof_long_long" -ne 0; then
538 SCM_I_GSC_T_INTMAX='"long long"'
539else
540 SCM_I_GSC_T_INTMAX='"long"'
541fi
542AC_SUBST([SCM_I_GSC_T_INTMAX])
543
544### Required type scm_t_uintmax
545###
546### We try 'uintmax_t', 'unsigned __int64', 'unsigned long long' in
547### this order. When none of them is available, we use 'unsigned long'.
548###
549SCM_I_GSC_T_UINTMAX=0
550if test "$scm_stdint_has_uintmax"; then
551 SCM_I_GSC_T_UINTMAX='"uintmax_t"'
552 SCM_I_GSC_NEEDS_STDINT_H=1
553elif test "$scm_inttypes_has_uintmax"; then
554 SCM_I_GSC_T_UINTMAX='"uintmax_t"'
555 SCM_I_GSC_NEEDS_INTTYPES_H=1
556elif test "$ac_cv_sizeof_unsigned___int64" -ne 0; then
557 SCM_I_GSC_T_UINTMAX='"unsigned __int64"'
558elif test "$ac_cv_sizeof_unsigned_long_long" -ne 0; then
559 SCM_I_GSC_T_UINTMAX='"unsigned long long"'
560else
561 SCM_I_GSC_T_UINTMAX='"unsigned long"'
562fi
563AC_SUBST([SCM_I_GSC_T_UINTMAX])
564
114bc68a
LC
565### Required type scm_t_intptr
566###
567SCM_I_GSC_T_INTPTR=0
568if test "$scm_stdint_has_intptr"; then
569 SCM_I_GSC_T_INTPTR='"intptr_t"'
570 SCM_I_GSC_NEEDS_STDINT_H=1
571elif test "$scm_inttypes_has_intptr"; then
572 SCM_I_GSC_T_INTPTR='"intptr_t"'
573 SCM_I_GSC_NEEDS_INTTYPES_H=1
574elif test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_void_p"; then
575 SCM_I_GSC_T_INTPTR='"int"'
576elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_void_p"; then
577 SCM_I_GSC_T_INTPTR='"long"'
578elif test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_void_p"; then
579 SCM_I_GSC_T_INTPTR='"long long"'
580else
581 AC_MSG_ERROR([Can't find appropriate type for `scm_t_intptr'.])
582fi
583AC_SUBST([SCM_I_GSC_T_INTPTR])
584
585### Required type scm_t_uintptr
586###
587SCM_I_GSC_T_UINTPTR=0
588if test "$scm_stdint_has_uintptr"; then
589 SCM_I_GSC_T_UINTPTR='"uintptr_t"'
590 SCM_I_GSC_NEEDS_STDINT_H=1
591elif test "$scm_inttypes_has_uintptr"; then
592 SCM_I_GSC_T_UINTPTR='"uintptr_t"'
593 SCM_I_GSC_NEEDS_INTTYPES_H=1
594elif test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_void_p"; then
595 SCM_I_GSC_T_UINTPTR='"unsigned int"'
596elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_void_p"; then
597 SCM_I_GSC_T_UINTPTR='"unsigned long"'
598elif test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_void_p"; then
599 SCM_I_GSC_T_UINTPTR='"unsigned long long"'
600else
601 AC_MSG_ERROR([Can't find appropriate type for `scm_t_uintptr'.])
602fi
603AC_SUBST([SCM_I_GSC_T_UINTPTR])
604
9a52bc2a
RB
605
606AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
607AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H])
608
3a629497 609AC_HEADER_STDC
3a629497
JB
610AC_HEADER_TIME
611AC_HEADER_SYS_WAIT
450be18d
LC
612AC_HEADER_DIRENT
613
614# Reason for checking:
615#
616# HP-UX 11.11 (at least) doesn't provide `struct dirent64', even
617# with `_LARGEFILE64_SOURCE', so check whether it's available.
618#
619AC_CHECK_MEMBER([struct dirent64.d_name],
620 [SCM_I_GSC_HAVE_STRUCT_DIRENT64=1], [SCM_I_GSC_HAVE_STRUCT_DIRENT64=0],
621 [ #ifndef _LARGEFILE64_SOURCE
622 # define _LARGEFILE64_SOURCE
623 #endif
624
625 /* Per Autoconf manual. */
626 #include <sys/types.h>
627 #ifdef HAVE_DIRENT_H
628 # include <dirent.h>
629 #else
630 # define dirent direct
631 # ifdef HAVE_SYS_NDIR_H
632 # include <sys/ndir.h>
633 # endif
634 # ifdef HAVE_SYS_DIR_H
635 # include <sys/dir.h>
636 # endif
637 # ifdef HAVE_NDIR_H
638 # include <ndir.h>
639 # endif
640 #endif ])
641AC_SUBST([SCM_I_GSC_HAVE_STRUCT_DIRENT64])
bdcccc18 642
63177e46 643# Reasons for testing:
8ab3d8a0 644# complex.h - new in C99
63177e46 645# fenv.h - available in C99, but not older systems
66818dbb
LC
646# machine/fpu.h - on Tru64 5.1b, the declaration of fesetround(3) is in
647# this file instead of <fenv.h>
45c0ff10 648# process.h - mingw specific
a2f00b9b 649# langinfo.h, nl_types.h - SuS v2
63177e46 650#
45c0ff10 651AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h memory.h process.h string.h \
bdcccc18
RB
652regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
653sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
654sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
66818dbb 655direct.h langinfo.h nl_types.h machine/fpu.h])
bdcccc18 656
56d288b8
LC
657# Reasons for testing:
658# nl_item - lacking on Cygwin
659AC_CHECK_TYPES([nl_item], [], [],
660 [[#ifdef HAVE_LANGINFO_H
661 # include <langinfo.h>
662 #endif
663 #ifdef HAVE_NL_TYPES_H
664 # include <nl_types.h>
665 #endif]])
666
8ab3d8a0
KR
667# "complex double" is new in C99, and "complex" is only a keyword if
668# <complex.h> is included
669AC_CHECK_TYPES(complex double,,,
670[#if HAVE_COMPLEX_H
671#include <complex.h>
672#endif])
673
4f416616
KR
674# On MacOS X <sys/socklen.h> contains socklen_t, so must include that
675# when testing.
676AC_CHECK_TYPE(socklen_t, ,
feef98f2 677 [AC_DEFINE_UNQUOTED([socklen_t], int,
4f416616
KR
678 [Define to `int' if <sys/socket.h> does not define.])],
679 [#if HAVE_SYS_TYPES_H
680#include <sys/types.h>
681#endif
682#include <sys/socket.h>
683])
684AC_CHECK_TYPE(struct ip_mreq)
685
3a629497
JB
686GUILE_HEADER_LIBC_WITH_UNISTD
687
688AC_TYPE_GETGROUPS
689AC_TYPE_SIGNAL
690AC_TYPE_MODE_T
691
45c0ff10
KR
692# On mingw -lm is empty, so this test is unnecessary, but it's
693# harmless so we don't hard-code to suppress it.
694#
695AC_CHECK_LIB(m, cos)
696
4c787b52 697AC_CHECK_FUNCS(gethostbyname)
5852c051
JB
698if test $ac_cv_func_gethostbyname = no; then
699 AC_CHECK_LIB(nsl, gethostbyname)
700fi
39e8f371 701
4c787b52 702AC_CHECK_FUNCS(connect)
5852c051
JB
703if test $ac_cv_func_connect = no; then
704 AC_CHECK_LIB(socket, connect)
705fi
5ee74cec 706
f9e5e096
MV
707dnl
708dnl Check for Winsock and other functionality on Win32 (*not* CygWin)
709dnl
710EXTRA_DEFS=""
45c0ff10
KR
711case $host in
712 *-*-mingw*)
6812c28f 713 AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1,
f9e5e096
MV
714 [Define if you have the <winsock2.h> header file.])])
715 AC_CHECK_LIB(ws2_32, main)
eede3dbc
RB
716 AC_LIBOBJ([win32-uname])
717 AC_LIBOBJ([win32-dirent])
b4e15479 718 if test "$enable_networking" = yes ; then
eede3dbc 719 AC_LIBOBJ([win32-socket])
b4e15479
SJ
720 fi
721 if test "$enable_shared" = yes ; then
8f99e3f3 722 EXTRA_DEFS="-DSCM_IMPORT"
feef98f2 723 AC_DEFINE([USE_DLL_IMPORT], 1,
8f99e3f3 724 [Define if you need additional CPP macros on Win32 platforms.])
f9e5e096 725 fi
45c0ff10
KR
726 ;;
727esac
f9e5e096 728AC_SUBST(EXTRA_DEFS)
f9e5e096 729
ef73a2a0
KR
730# Reasons for testing:
731# crt_externs.h - Darwin specific
732#
733AC_CHECK_HEADERS([assert.h crt_externs.h])
bdcccc18 734
ef73a2a0 735# Reasons for testing:
1df72834
KR
736# DINFINITY - OSF specific
737# DQNAN - OSF specific
738# (DINFINITY and DQNAN are actually global variables, not functions)
8ab3d8a0 739# chsize - an MS-DOS-ism, found in mingw
b69471c1
KR
740# cexp, clog - not in various pre-c99 systems, and note that it's possible
741# for gcc to provide the "complex double" type but the system to not
742# have functions like cexp and clog
8ab3d8a0 743# clog10 - not in mingw (though others like clog and csqrt are)
63177e46 744# fesetround - available in C99, but not older systems
8ab3d8a0
KR
745# ftruncate - posix, but probably not older systems (current mingw
746# has it as an inline for chsize)
23f2b9a3 747# ioctl - not in mingw.
c9d1dcc0 748# gmtime_r - recent posix, not on old systems
45c0ff10
KR
749# pipe - not in mingw
750# _pipe - specific to mingw, taking 3 args
66ec83c9 751# readdir_r - recent posix, not on old systems
450be18d 752# readdir64_r - not available on HP-UX 11.11
4f416616 753# stat64 - SuS largefile stuff, not on old systems
6b01eac9 754# sysconf - not on old systems
8ab3d8a0 755# truncate - not in mingw
a17d2654 756# isblank - available as a GNU extension or in C99
ef73a2a0 757# _NSGetEnviron - Darwin specific
a2f00b9b
LC
758# strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
759# nl_langinfo - X/Open, not available on Windows.
06bfe276 760# utimensat: posix.1-2008
ef73a2a0 761#
06bfe276 762AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_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 nl_langinfo utimensat])
64e121dc 763
6b01eac9
KR
764# Reasons for testing:
765# netdb.h - not in mingw
766# sys/param.h - not in mingw
45c0ff10
KR
767# pthread.h - only available with pthreads. ACX_PTHREAD doesn't
768# check this specifically, we need it for the timespec test below.
8ab3d8a0
KR
769# sethostname - the function itself check because it's not in mingw,
770# the DECL is checked because Solaris 10 doens't have in any header
ca329120
LC
771# hstrerror - on Tru64 5.1b the symbol is available in libc but the
772# declaration isn't anywhere.
5f380d71
LC
773# cuserid - on Tru64 5.1b the declaration is documented to be available
774# only with `_XOPEN_SOURCE' or some such.
6b01eac9 775#
414e4441 776AC_CHECK_HEADERS([crypt.h netdb.h pthread.h sys/param.h sys/resource.h sys/file.h])
94e6d793 777AC_CHECK_FUNCS(chroot flock getlogin cuserid getpriority setpriority getpass sethostname gethostname)
5f380d71 778AC_CHECK_DECLS([sethostname, hstrerror, cuserid])
63271ac5
KR
779
780# crypt() may or may not be available, for instance in some countries there
781# are restrictions on cryptography.
782#
783# crypt() might be in libc (eg. OpenBSD), or it might be in a separate
784# -lcrypt library (eg. Debian GNU/Linux).
785#
786# On HP-UX 11, crypt() is in libc and there's a dummy libcrypt.a. We must
787# be careful to avoid -lcrypt in this case, since libtool will see there's
788# only a static libcrypt and decide to build only a static libguile.
789#
790# AC_SEARCH_LIBS lets us add -lcrypt to LIBS only if crypt() is not in the
791# libraries already in that list.
792#
793AC_SEARCH_LIBS(crypt, crypt,
feef98f2 794 [AC_DEFINE([HAVE_CRYPT],1,
63271ac5 795 [Define to 1 if you have the `crypt' function.])])
94e6d793 796
8cd5eae9
NJ
797# When compiling with GCC on some OSs (Solaris, AIX), _Complex_I doesn't
798# work; in the reported cases so far, 1.0fi works well instead. According
799# to the C99 spec, the complex.h header must provide a working definition
800# of _Complex_I, so we always try _Complex_I first. The 1.0fi fallback
801# is a workaround for the failure of some systems to conform to C99.
4b26c03e
NJ
802if test "$ac_cv_type_complex_double" = yes; then
803 AC_MSG_CHECKING([for i])
4bdc8fb5 804 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4b26c03e
NJ
805#if HAVE_COMPLEX_H
806#include <complex.h>
807#endif
808complex double z;
4bdc8fb5 809]], [[
4b26c03e 810z = _Complex_I;
4bdc8fb5 811]])],
feef98f2 812 [AC_DEFINE([GUILE_I],_Complex_I,[The imaginary unit (positive square root of -1).])
4bdc8fb5
LC
813 AC_MSG_RESULT([_Complex_I])],
814 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4b26c03e
NJ
815#if HAVE_COMPLEX_H
816#include <complex.h>
817#endif
818complex double z;
4bdc8fb5 819]],[[
4b26c03e 820z = 1.0fi;
4bdc8fb5 821]])],
feef98f2 822 [AC_DEFINE([GUILE_I],1.0fi)
4bdc8fb5
LC
823 AC_MSG_RESULT([1.0fi])],
824 [ac_cv_type_complex_double=no
825 AC_MSG_RESULT([not available])])])
4b26c03e
NJ
826fi
827
8ab3d8a0
KR
828# glibc 2.3.6 (circa 2006) and various prior versions had a bug where
829# csqrt(-i) returned a negative real part, when it should be positive
830# for the principal root.
831#
832if test "$ac_cv_type_complex_double" = yes; then
1d8ce4c0 833
8ab3d8a0
KR
834 AC_CACHE_CHECK([whether csqrt is usable],
835 guile_cv_use_csqrt,
4bdc8fb5 836 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
8ab3d8a0
KR
837#include <complex.h>
838/* "volatile" is meant to prevent gcc from calculating the sqrt as a
839 constant, we want to test libc. */
840volatile complex double z = - _Complex_I;
841int
842main (void)
843{
844 z = csqrt (z);
845 if (creal (z) > 0.0)
846 return 0; /* good */
847 else
848 return 1; /* bad */
4bdc8fb5 849}]])],
8ab3d8a0
KR
850 [guile_cv_use_csqrt=yes],
851 [guile_cv_use_csqrt="no, glibc 2.3 bug"],
852 [guile_cv_use_csqrt="yes, hopefully (cross-compiling)"])])
853 case $guile_cv_use_csqrt in
854 yes*)
feef98f2 855 AC_DEFINE([HAVE_USABLE_CSQRT], 1, [Define to 1 if csqrt is bug-free])
8ab3d8a0
KR
856 ;;
857 esac
858fi
859
860
a6be66ed 861dnl GMP tests
db5034ab 862AC_LIB_HAVE_LINKFLAGS([gmp],
4bdc8fb5 863 [],
f4863880 864 [#include <gmp.h>],
db5034ab
LC
865 [mpz_import (0, 0, 0, 0, 0, 0, 0);])
866
867if test "x$HAVE_LIBGMP" != "xyes"; then
868 AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README])
869fi
9f1555fe 870
18c73f8e 871dnl GNU libunistring is checked for by Gnulib's `libunistring' module.
b7b93288
LC
872if test "x$LTLIBUNISTRING" != "x"; then
873 LIBS="$LTLIBUNISTRING $LIBS"
874else
875 AC_MSG_ERROR([GNU libunistring is required, please install it.])
876fi
9f1555fe 877
75c242a2
AW
878dnl Libffi is needed to compile Guile's foreign function interface, but its
879dnl interface isn't exposed in Guile's API.
880PKG_CHECK_MODULES(LIBFFI, libffi)
881AC_SUBST(LIBFFI_CFLAGS)
882AC_SUBST(LIBFFI_LIBS)
883
884dnl figure out approriate ffi type for size_t
885AC_CHECK_SIZEOF(size_t)
886AC_CHECK_SIZEOF(ssize_t)
887ffi_size_type=uint$(($ac_cv_sizeof_size_t*8))
888ffi_ssize_type=sint$(($ac_cv_sizeof_ssize_t*8))
889AC_DEFINE_UNQUOTED(ffi_type_size_t, ffi_type_${ffi_size_type},
890 [ffi type for size_t])
891AC_DEFINE_UNQUOTED(ffi_type_ssize_t, ffi_type_${ffi_ssize_type},
892 [ffi type for ssize_t])
893
83cd507c 894dnl i18n tests
b6540274
MV
895#AC_CHECK_HEADERS([libintl.h])
896#AC_CHECK_FUNCS(gettext)
897#if test $ac_cv_func_gettext = no; then
898# AC_CHECK_LIB(intl, gettext)
899#fi
900#AC_CHECK_FUNCS([bindtextdomain textdomain])
901AM_GNU_GETTEXT([external], [need-ngettext])
83cd507c 902
777b022a
JB
903### Some systems don't declare some functions. On such systems, we
904### need to at least provide our own K&R-style declarations.
905
906### GUILE_FUNC_DECLARED(function, headerfile)
907
908### Check for a declaration of FUNCTION in HEADERFILE; if it is
909### not there, #define MISSING_FUNCTION_DECL.
d70e0619 910AC_DEFUN([GUILE_FUNC_DECLARED], [
fc342a63 911 AC_CACHE_CHECK(for $1 declaration, guile_cv_func_$1_declared,
777b022a 912 AC_EGREP_HEADER($1, $2,
01e5e07e 913 guile_cv_func_$1_declared=yes,
fc342a63
JB
914 guile_cv_func_$1_declared=no))
915 if test [x$guile_cv_func_]$1[_declared] = xno; then
eede3dbc
RB
916 AC_DEFINE([MISSING_]translit($1, [a-z], [A-Z])[_DECL], 1,
917 [Define if the operating system supplies $1 without declaring it.])
777b022a
JB
918 fi
919])
920
c31bfb85 921GUILE_FUNC_DECLARED(sleep, unistd.h)
777b022a 922GUILE_FUNC_DECLARED(usleep, unistd.h)
e1a191a8 923
0777022d
KR
924AC_CHECK_DECLS([strptime],,,
925[#define _GNU_SOURCE /* ask glibc to give strptime prototype */
926#include <time.h>])
927
da753252
JB
928### On some systems usleep has no return value. If it does have one,
929### we'd like to return it; otherwise, we'll fake it.
fc342a63 930AC_CACHE_CHECK([return type of usleep], guile_cv_func_usleep_return_type,
c43f86c1 931 [AC_EGREP_HEADER(changequote(<, >)<void[ ]+usleep>changequote([, ]),
4874dfc8 932 unistd.h,
fc342a63
JB
933 [guile_cv_func_usleep_return_type=void],
934 [guile_cv_func_usleep_return_type=int])])
935case "$guile_cv_func_usleep_return_type" in
936 "void" )
feef98f2 937 AC_DEFINE([USLEEP_RETURNS_VOID], 1,
eede3dbc 938 [Define if the system headers declare usleep to return void.])
fc342a63
JB
939 ;;
940esac
941
da88f0cb
JB
942AC_CHECK_HEADER(sys/un.h, have_sys_un_h=1)
943if test -n "$have_sys_un_h" ; then
feef98f2 944 AC_DEFINE([HAVE_UNIX_DOMAIN_SOCKETS], 1,
eede3dbc 945 [Define if the system supports Unix-domain (file-domain) sockets.])
da88f0cb
JB
946fi
947
4ea9429e
AW
948AC_CHECK_FUNCS(getrlimit setrlimit)
949
d707b9df 950AC_CHECK_FUNCS(socketpair getgroups setgroups setpwent pause tzset)
da88f0cb 951
219a5a5b
JB
952AC_CHECK_FUNCS(sethostent gethostent endhostent dnl
953 setnetent getnetent endnetent dnl
954 setprotoent getprotoent endprotoent dnl
955 setservent getservent endservent dnl
5c11cc9d 956 getnetbyaddr getnetbyname dnl
8912421c 957 inet_lnaof inet_makeaddr inet_netof hstrerror)
da88f0cb 958
feef329e
KR
959# struct sockaddr field sin_len is only present on BSD systems.
960# On 4.4BSD apparently a #define SIN_LEN exists, but on other BSD systems
961# (eg. FreeBSD 4.9) it doesn't and we must use this configure check
962AC_CHECK_MEMBERS([struct sockaddr.sin_len],,,
963[#ifdef HAVE_SYS_TYPES_H
964#include <sys/types.h>
965#endif
966#include <netinet/in.h>])
967
d19c9767 968AC_MSG_CHECKING(for __libc_stack_end)
2e945bcc 969AC_CACHE_VAL(guile_cv_have_libc_stack_end,
4bdc8fb5
LC
970[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
971extern char *__libc_stack_end;]],
972 [[printf("%p", (char*) __libc_stack_end);]])],
973 [guile_cv_have_libc_stack_end=yes],
974 [guile_cv_have_libc_stack_end=no])])
2e945bcc
SJ
975AC_MSG_RESULT($guile_cv_have_libc_stack_end)
976
977if test $guile_cv_have_libc_stack_end = yes; then
feef98f2 978 AC_DEFINE([HAVE_LIBC_STACK_END], 1,
d19c9767
MV
979 [Define if you have the __libc_stack_end variable.])
980fi
981
08f980a4
GH
982dnl Some systems do not declare this. Some systems do declare it, as a
983dnl macro. With cygwin it may be in a DLL.
984
985AC_MSG_CHECKING(whether netdb.h declares h_errno)
986AC_CACHE_VAL(guile_cv_have_h_errno,
4bdc8fb5
LC
987 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
988 [[int a = h_errno;]])],
989 [guile_cv_have_h_errno=yes],
990 [guile_cv_have_h_errno=no])])
08f980a4
GH
991AC_MSG_RESULT($guile_cv_have_h_errno)
992if test $guile_cv_have_h_errno = yes; then
feef98f2 993 AC_DEFINE([HAVE_H_ERRNO], 1, [Define if h_errno is declared in netdb.h.])
08f980a4 994fi
da88f0cb 995
4f522b6f 996AC_MSG_CHECKING(whether uint32_t is defined)
c5316ea3 997AC_CACHE_VAL(guile_cv_have_uint32_t,
4bdc8fb5 998 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
af68e5e5
SJ
999 #if HAVE_STDINT_H
1000 #include <stdint.h>
1001 #endif
45c0ff10 1002 #ifndef HAVE_NETDB_H
af68e5e5 1003 #include <netdb.h>
4bdc8fb5
LC
1004 #endif]],
1005 [[uint32_t a;]])],
1006 [guile_cv_have_uint32_t=yes],
1007 [guile_cv_have_uint32_t=no])])
c5316ea3
GH
1008AC_MSG_RESULT($guile_cv_have_uint32_t)
1009if test $guile_cv_have_uint32_t = yes; then
feef98f2 1010 AC_DEFINE([HAVE_UINT32_T], 1,
eede3dbc 1011 [Define if uint32_t typedef is defined when netdb.h is include.])
c5316ea3
GH
1012fi
1013
018a53a1
GH
1014AC_MSG_CHECKING(for working IPv6 support)
1015AC_CACHE_VAL(guile_cv_have_ipv6,
4bdc8fb5 1016[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8f16fe5a
MV
1017#ifdef HAVE_SYS_TYPES_H
1018#include <sys/types.h>
1019#endif
1020#include <netinet/in.h>
4bdc8fb5
LC
1021#include <sys/socket.h>]],
1022[[struct sockaddr_in6 a; a.sin6_family = AF_INET6;]])],
1023[guile_cv_have_ipv6=yes],
1024[guile_cv_have_ipv6=no])])
018a53a1
GH
1025AC_MSG_RESULT($guile_cv_have_ipv6)
1026if test $guile_cv_have_ipv6 = yes; then
feef98f2 1027 AC_DEFINE([HAVE_IPV6], 1, [Define if you want support for IPv6.])
018a53a1
GH
1028fi
1029
67641981
GH
1030# included in rfc2553 but not in older implementations, e.g., glibc 2.1.3.
1031AC_MSG_CHECKING(whether sockaddr_in6 has sin6_scope_id)
1032AC_CACHE_VAL(guile_cv_have_sin6_scope_id,
4bdc8fb5 1033[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8f16fe5a
MV
1034#ifdef HAVE_SYS_TYPES_H
1035#include <sys/types.h>
1036#endif
4bdc8fb5
LC
1037#include <netinet/in.h>]],
1038[[struct sockaddr_in6 sok; sok.sin6_scope_id = 0;]])],
1039[guile_cv_have_sin6_scope_id=yes],
1040[guile_cv_have_sin6_scope_id=no])])
67641981
GH
1041AC_MSG_RESULT($guile_cv_have_sin6_scope_id)
1042if test $guile_cv_have_sin6_scope_id = yes; then
feef98f2 1043 AC_DEFINE([HAVE_SIN6_SCOPE_ID], 1,
eede3dbc 1044 [Define this if your IPv6 has sin6_scope_id in sockaddr_in6 struct.])
67641981
GH
1045fi
1046
feef329e
KR
1047# struct sockaddr_in6 field sin_len is only present on BSD systems
1048AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_len],,,
1049[#ifdef HAVE_SYS_TYPES_H
1050#include <sys/types.h>
1051#endif
1052#include <netinet/in.h>])
1053
38c1d3c4
GH
1054AC_MSG_CHECKING(whether localtime caches TZ)
1055AC_CACHE_VAL(guile_cv_localtime_cache,
1056[if test x$ac_cv_func_tzset = xyes; then
4bdc8fb5 1057AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
38c1d3c4
GH
1058#if STDC_HEADERS
1059# include <stdlib.h>
1060#endif
1061extern char **environ;
1062unset_TZ ()
1063{
1064 char **from, **to;
1065 for (to = from = environ; (*to = *from); from++)
1066 if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
1067 to++;
1068}
1069char TZ_GMT0[] = "TZ=GMT0";
1070char TZ_PST8[] = "TZ=PST8";
1071main()
1072{
1073 time_t now = time ((time_t *) 0);
1074 int hour_GMT0, hour_unset;
1075 if (putenv (TZ_GMT0) != 0)
1076 exit (1);
1077 hour_GMT0 = localtime (&now)->tm_hour;
1078 unset_TZ ();
1079 hour_unset = localtime (&now)->tm_hour;
1080 if (putenv (TZ_PST8) != 0)
1081 exit (1);
1082 if (localtime (&now)->tm_hour == hour_GMT0)
1083 exit (1);
1084 unset_TZ ();
1085 if (localtime (&now)->tm_hour != hour_unset)
1086 exit (1);
1087 exit (0);
4bdc8fb5
LC
1088}]])],
1089[guile_cv_localtime_cache=no],
1090[guile_cv_localtime_cache=yes],
38c1d3c4
GH
1091[# If we have tzset, assume the worst when cross-compiling.
1092guile_cv_localtime_cache=yes])
1093else
1094 # If we lack tzset, report that localtime does not cache TZ,
1095 # since we can't invalidate the cache if we don't have tzset.
1096 guile_cv_localtime_cache=no
1097fi])dnl
1098AC_MSG_RESULT($guile_cv_localtime_cache)
1099if test $guile_cv_localtime_cache = yes; then
feef98f2 1100 AC_DEFINE([LOCALTIME_CACHE], 1, [Define if localtime caches the TZ setting.])
38c1d3c4
GH
1101fi
1102
52cfc69b
GH
1103if test "$enable_regex" = yes; then
1104 if test "$ac_cv_header_regex_h" = yes ||
1105 test "$ac_cv_header_rxposix_h" = yes ||
1106 test "$ac_cv_header_rx_rxposix_h" = yes; then
eede3dbc 1107 GUILE_NAMED_CHECK_FUNC(regcomp, norx, [AC_LIBOBJ([regex-posix])],
52cfc69b 1108 [AC_CHECK_LIB(rx, main)
eede3dbc 1109 GUILE_NAMED_CHECK_FUNC(regcomp, rx, [AC_LIBOBJ([regex-posix])],
f9e5e096 1110 [AC_CHECK_LIB(regex, main)
eede3dbc 1111 GUILE_NAMED_CHECK_FUNC(regcomp, regex, [AC_LIBOBJ([regex-posix])])])]
52cfc69b
GH
1112 )
1113 dnl The following should not be necessary, but for some reason
1114 dnl autoheader misses it if we don't include it!
1115 if test "$ac_cv_func_regcomp_norx" = yes ||
f9e5e096 1116 test "$ac_cv_func_regcomp_regex" = yes ||
52cfc69b 1117 test "$ac_cv_func_regcomp_rx" = yes; then
feef98f2 1118 AC_DEFINE([HAVE_REGCOMP], 1,
eede3dbc 1119 [This is included as part of a workaround for a autoheader bug.])
52cfc69b
GH
1120 fi
1121 fi
da88f0cb 1122fi
8e1bfcd0 1123
1bf291e4 1124AC_REPLACE_FUNCS([strerror memmove mkstemp])
3a629497 1125
594e69b7
MV
1126AC_CHECK_HEADERS(floatingpoint.h ieeefp.h nan.h)
1127
21b860c8
KR
1128# Reasons for testing:
1129# asinh, acosh, atanh, trunc - C99 standard, generally not available on
1130# older systems
1131# sincos - GLIBC extension
9af31eed 1132#
8ab3d8a0 1133AC_CHECK_FUNCS(asinh acosh atanh copysign finite sincos trunc)
4d0bfea1
KR
1134
1135# C99 specifies isinf and isnan as macros.
1136# HP-UX provides only macros, no functions.
c80bab35
KR
1137# glibc 2.3.2 provides both macros and functions.
1138# IRIX 6.5 and Solaris 8 only provide functions.
4d0bfea1 1139#
c80bab35
KR
1140# The following tests detect isinf and isnan either as functions or as
1141# macros from <math.h>. Plain AC_CHECK_FUNCS is insufficient, it doesn't
1142# use <math.h> so doesn't detect on macro-only systems like HP-UX.
4d0bfea1
KR
1143#
1144AC_MSG_CHECKING([for isinf])
b3aa4626
KR
1145AC_LINK_IFELSE(AC_LANG_SOURCE(
1146[[#include <math.h>
1147volatile double x = 0.0;
1148int main () { return (isinf(x) != 0); }]]),
4d0bfea1 1149 [AC_MSG_RESULT([yes])
feef98f2 1150 AC_DEFINE([HAVE_ISINF], 1,
4d0bfea1
KR
1151 [Define to 1 if you have the `isinf' macro or function.])],
1152 [AC_MSG_RESULT([no])])
1153AC_MSG_CHECKING([for isnan])
b3aa4626
KR
1154AC_LINK_IFELSE(AC_LANG_SOURCE(
1155[[#include <math.h>
1156volatile double x = 0.0;
1157int main () { return (isnan(x) != 0); }]]),
4d0bfea1 1158 [AC_MSG_RESULT([yes])
feef98f2 1159 AC_DEFINE([HAVE_ISNAN], 1,
4d0bfea1
KR
1160 [Define to 1 if you have the `isnan' macro or function.])],
1161 [AC_MSG_RESULT([no])])
594e69b7 1162
23f2b9a3
KR
1163# Reasons for checking:
1164#
1165# st_rdev
1166# st_blksize
1167# st_blocks not in mingw
8ab3d8a0 1168# tm_gmtoff BSD+GNU, not in C99
23f2b9a3
KR
1169#
1170# Note AC_STRUCT_ST_BLOCKS is not used here because we don't want the
1171# AC_LIBOBJ(fileblocks) replacement which that macro gives.
1172#
06bfe276
AW
1173AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blksize, struct stat.st_blocks, struct stat.st_atim, struct stat.st_mtim, struct stat.st_ctim],,,
1174 [#define _GNU_SOURCE
1175AC_INCLUDES_DEFAULT
1176])
fd02f2ad 1177
3a629497 1178AC_STRUCT_TIMEZONE
8ab3d8a0
KR
1179AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,
1180[#include <time.h>
1181#ifdef TIME_WITH_SYS_TIME
1182# include <sys/time.h>
1183# include <time.h>
1184#else
1185# if HAVE_SYS_TIME_H
1186# include <sys/time.h>
1187# else
1188# include <time.h>
1189# endif
1190#endif
1191])
3a629497
JB
1192GUILE_STRUCT_UTIMBUF
1193
8ab3d8a0 1194
3a629497
JB
1195#--------------------------------------------------------------------
1196#
1197# Which way does the stack grow?
1198#
4696a666
NJ
1199# Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA
1200# macro (/usr/share/autoconf/autoconf/functions.m4). Gnulib has
1201# very similar code, so in future we could look at using that.
1202#
1203# An important detail is that the code involves find_stack_direction
1204# calling _itself_ - which means that find_stack_direction (or at
1205# least the second find_stack_direction() call) cannot be inlined.
1206# If the code could be inlined, that might cause the test to give
1207# an incorrect answer.
3a629497
JB
1208#--------------------------------------------------------------------
1209
9a52bc2a 1210SCM_I_GSC_STACK_GROWS_UP=0
5ea8e76e 1211AC_RUN_IFELSE([AC_LANG_SOURCE(
4696a666
NJ
1212[AC_INCLUDES_DEFAULT
1213int
1214find_stack_direction ()
1215{
1216 static char *addr = 0;
1217 auto char dummy;
1218 if (addr == 0)
1219 {
1220 addr = &dummy;
1221 return find_stack_direction ();
1222 }
1223 else
1224 return (&dummy > addr) ? 1 : -1;
1225}
1226
1227int
1228main ()
1229{
1230 return find_stack_direction () < 0;
1231}])],
1232 [SCM_I_GSC_STACK_GROWS_UP=1],
1233 [],
5ea8e76e 1234 [AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)])
eede3dbc 1235
26224b3f
LC
1236#--------------------------------------------------------------------
1237#
1238# Boehm's GC library
1239#
1240#--------------------------------------------------------------------
1f26b531
LC
1241PKG_CHECK_MODULES([BDW_GC], [bdw-gc])
1242
1243CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
1244LIBS="$BDW_GC_LIBS $LIBS"
26224b3f 1245
9625c900
LC
1246# `GC_do_blocking ()' is available in GC 7.1 but not declared.
1247AC_CHECK_FUNCS([GC_do_blocking])
1248AC_CHECK_DECL([GC_do_blocking],
1249 [AC_DEFINE([HAVE_DECL_GC_DO_BLOCKING], [1],
1250 [Define this if the `GC_do_blocking ()' function is declared])],
1251 [],
1252 [#include <gc/gc.h>])
1253
3d1af79f
LC
1254# `GC_fn_type' is not available in GC 7.1 and earlier.
1255AC_CHECK_TYPE([GC_fn_type],
1256 [AC_DEFINE([HAVE_GC_FN_TYPE], [1],
1257 [Define this if the `GC_fn_type' type is available.])],
1258 [],
1259 [#include <gc/gc.h>])
1260
26224b3f 1261
a9e0a8af
KR
1262AC_CHECK_SIZEOF(float)
1263if test "$ac_cv_sizeof_float" -le "$ac_cv_sizeof_long"; then
feef98f2 1264 AC_DEFINE([SCM_SINGLES], 1,
a9e0a8af
KR
1265 [Define this if floats are the same size as longs.])
1266fi
3a629497
JB
1267
1268AC_MSG_CHECKING(for struct linger)
1269AC_CACHE_VAL(scm_cv_struct_linger,
4bdc8fb5 1270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3a629497 1271#include <sys/types.h>
4bdc8fb5
LC
1272#include <sys/socket.h>]],
1273 [[struct linger lgr; lgr.l_linger = 100]])],
1274 [scm_cv_struct_linger="yes"],
1275 [scm_cv_struct_linger="no"]))
3a629497
JB
1276AC_MSG_RESULT($scm_cv_struct_linger)
1277if test $scm_cv_struct_linger = yes; then
feef98f2 1278 AC_DEFINE([HAVE_STRUCT_LINGER], 1,
eede3dbc
RB
1279 [Define this if your system defines struct linger, for use with the
1280 getsockopt and setsockopt system calls.])
3a629497 1281fi
3a629497 1282
7534dfdc 1283
45c0ff10
KR
1284# On mingw, struct timespec is in <pthread.h>.
1285#
7534dfdc
MD
1286AC_MSG_CHECKING(for struct timespec)
1287AC_CACHE_VAL(scm_cv_struct_timespec,
4bdc8fb5 1288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
45c0ff10
KR
1289#include <time.h>
1290#if HAVE_PTHREAD_H
1291#include <pthread.h>
4bdc8fb5
LC
1292#endif]], [[struct timespec t; t.tv_nsec = 100]])],
1293 [scm_cv_struct_timespec="yes"],
1294 [scm_cv_struct_timespec="no"]))
7534dfdc
MD
1295AC_MSG_RESULT($scm_cv_struct_timespec)
1296if test $scm_cv_struct_timespec = yes; then
feef98f2 1297 AC_DEFINE([HAVE_STRUCT_TIMESPEC], 1,
45c0ff10 1298 [Define this if your system defines struct timespec via either <time.h> or <pthread.h>.])
7534dfdc
MD
1299fi
1300
3a629497
JB
1301#--------------------------------------------------------------------
1302#
1303# Flags for thread support
1304#
1305#--------------------------------------------------------------------
1306
9a52bc2a
RB
1307SCM_I_GSC_USE_PTHREAD_THREADS=0
1308SCM_I_GSC_USE_NULL_THREADS=0
9a52bc2a
RB
1309AC_SUBST([SCM_I_GSC_USE_PTHREAD_THREADS])
1310AC_SUBST([SCM_I_GSC_USE_NULL_THREADS])
9a52bc2a 1311
539c89a1
JB
1312### What thread package has the user asked for?
1313AC_ARG_WITH(threads, [ --with-threads thread interface],
18622c4e 1314 , with_threads=yes)
539c89a1 1315
8ab3d8a0 1316AC_SUBST(SCM_I_GSC_NEED_BRACES_ON_PTHREAD_ONCE_INIT, 0)
66302618 1317AC_SUBST(SCM_I_GSC_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER, 0)
8ab3d8a0 1318
539c89a1 1319case "$with_threads" in
9bc4701c 1320 "yes" | "pthread" | "pthreads" | "pthread-threads" | "")
56ae2148
LC
1321
1322 build_pthread_support="yes"
1323
345b17e9
LC
1324 ACX_PTHREAD([CC="$PTHREAD_CC"
1325 LIBS="$PTHREAD_LIBS $LIBS"
1326 SCM_I_GSC_USE_PTHREAD_THREADS=1
1327 with_threads="pthreads"],
1328 [with_threads="null"
1329 build_pthread_support="no"])
49aaa6d2
MV
1330
1331 old_CFLAGS="$CFLAGS"
1332 CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
8ab3d8a0
KR
1333
1334 # Reasons for testing:
1335 # pthread_getattr_np - "np" meaning "non portable" says it
1336 # all; not present on MacOS X or Solaris 10
45c0ff10
KR
1337 # pthread_get_stackaddr_np - "np" meaning "non portable" says it
1338 # all; specific to MacOS X
1339 # pthread_sigmask - not available on mingw
8ab3d8a0 1340 #
45c0ff10 1341 AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_sigmask)
8ab3d8a0
KR
1342
1343 # On past versions of Solaris, believe 8 through 10 at least, you
1344 # had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };".
66302618 1345 # This is contrary to POSIX:
8ab3d8a0
KR
1346 # http://www.opengroup.org/onlinepubs/000095399/functions/pthread_once.html
1347 # Check here if this style is required.
1348 #
1349 # glibc (2.3.6 at least) works both with or without braces, so the
1350 # test checks whether it works without.
1351 #
66302618
LC
1352
1353 if test "$GCC" = "yes"; then
1354 # Since GCC only issues a warning for missing braces, so we need
1355 # `-Werror' to catch it.
1356 CFLAGS="-Werror -Wmissing-braces $CFLAGS"
1357 fi
1358
8ab3d8a0
KR
1359 AC_CACHE_CHECK([whether PTHREAD_ONCE_INIT needs braces],
1360 guile_cv_need_braces_on_pthread_once_init,
66302618
LC
1361 [AC_COMPILE_IFELSE([#include <pthread.h>
1362 pthread_once_t foo = PTHREAD_ONCE_INIT;],
8ab3d8a0
KR
1363 [guile_cv_need_braces_on_pthread_once_init=no],
1364 [guile_cv_need_braces_on_pthread_once_init=yes])])
1365 if test "$guile_cv_need_braces_on_pthread_once_init" = yes; then
1366 SCM_I_GSC_NEED_BRACES_ON_PTHREAD_ONCE_INIT=1
1367 fi
1368
66302618
LC
1369 # Same problem with `PTHREAD_MUTEX_INITIALIZER', e.g., on IRIX
1370 # 6.5.30m with GCC 3.3.
1371 AC_CACHE_CHECK([whether PTHREAD_MUTEX_INITIALIZER needs braces],
1372 guile_cv_need_braces_on_pthread_mutex_initializer,
1373 [AC_COMPILE_IFELSE([#include <pthread.h>
1374 pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER;],
1375 [guile_cv_need_braces_on_pthread_mutex_initializer=no],
1376 [guile_cv_need_braces_on_pthread_mutex_initializer=yes])])
1377 if test "$guile_cv_need_braces_on_pthread_mutex_initializer" = yes; then
1378 SCM_I_GSC_NEED_BRACES_ON_PTHREAD_MUTEX_INITIALIZER=1
1379 fi
1380
49aaa6d2
MV
1381 CFLAGS="$old_CFLAGS"
1382
d707b9df
MV
1383 # On Solaris, sched_yield lives in -lrt.
1384 AC_SEARCH_LIBS(sched_yield, rt)
1385
539c89a1 1386 ;;
539c89a1 1387esac
3a629497 1388
18622c4e 1389case "$with_threads" in
9bc4701c 1390 "pthreads")
585356dc 1391 ;;
18622c4e 1392 "no" | "null")
9a52bc2a 1393 SCM_I_GSC_USE_NULL_THREADS=1
81adf76a 1394 SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=0
18622c4e 1395 with_threads="null-threads"
18306183 1396 ;;
585356dc 1397 * )
18622c4e 1398 AC_MSG_ERROR(invalid value for --with-threads: $with_threads)
585356dc
MV
1399 ;;
1400esac
539c89a1 1401
18622c4e
MV
1402AC_MSG_CHECKING(what kind of threads to support)
1403AC_MSG_RESULT($with_threads)
933a7411 1404
56ae2148
LC
1405AM_CONDITIONAL([BUILD_PTHREAD_SUPPORT],
1406 [test "x$build_pthread_support" = "xyes"])
1407
1408
4f416616
KR
1409## Check whether pthread_attr_getstack works for the main thread
1410
23f2b9a3
KR
1411if test "$with_threads" = pthreads; then
1412
4f416616
KR
1413AC_MSG_CHECKING(whether pthread_attr_getstack works for the main thread)
1414old_CFLAGS="$CFLAGS"
1415CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
4bdc8fb5 1416AC_RUN_IFELSE([AC_LANG_SOURCE([[
4f416616
KR
1417#if HAVE_PTHREAD_ATTR_GETSTACK
1418#include <pthread.h>
1419
1420int main ()
1421{
1422 pthread_attr_t attr;
1423 void *start, *end;
1424 size_t size;
1425
1426 pthread_getattr_np (pthread_self (), &attr);
1427 pthread_attr_getstack (&attr, &start, &size);
1428 end = (char *)start + size;
1429
1430 if ((void *)&attr < start || (void *)&attr >= end)
1431 return 1;
1432 else
1433 return 0;
1434}
1435#else
1436int main ()
1437{
1438 return 1;
1439}
1440#endif
4bdc8fb5 1441]])],
4f416616 1442[works=yes
feef98f2 1443AC_DEFINE([PTHREAD_ATTR_GETSTACK_WORKS], [1], [Define when pthread_att_get_stack works for the main thread])],
4bdc8fb5
LC
1444[works=no],
1445[])
4f416616
KR
1446CFLAGS="$old_CFLAGS"
1447AC_MSG_RESULT($works)
1448
705edb95
LC
1449GUILE_THREAD_LOCAL_STORAGE
1450
23f2b9a3
KR
1451fi # with_threads=pthreads
1452
1453
0db83c04
MV
1454## Cross building
1455if test "$cross_compiling" = "yes"; then
1456 AC_MSG_CHECKING(cc for build)
1457 ## /usr/bin/cc still uses wrong assembler
1458 ## CC_FOR_BUILD="${CC_FOR_BUILD-/usr/bincc}"
1459 CC_FOR_BUILD="${CC_FOR_BUILD-PATH=/usr/bin:$PATH cc}"
1460else
1461 CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
1462fi
0db83c04
MV
1463
1464## AC_MSG_CHECKING("if we are cross compiling")
1465## AC_MSG_RESULT($cross_compiling)
1466if test "$cross_compiling" = "yes"; then
1467 AC_MSG_RESULT($CC_FOR_BUILD)
1468fi
1469
1470## No need as yet to be more elaborate
1471CCLD_FOR_BUILD="$CC_FOR_BUILD"
1472
1473AC_SUBST(cross_compiling)
457a4e81 1474AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
0db83c04
MV
1475AC_SUBST(CCLD_FOR_BUILD)
1476
1477## libtool erroneously calls CC_FOR_BUILD HOST_CC;
1478## --HOST is the platform that PACKAGE is compiled for.
1479HOST_CC="$CC_FOR_BUILD"
1480AC_SUBST(HOST_CC)
1481
1482if test "$cross_compiling" = "yes"; then
1483 AC_MSG_CHECKING(guile for build)
1484 GUILE_FOR_BUILD="${GUILE_FOR_BUILD-guile}"
1485else
1486 GUILE_FOR_BUILD='$(preinstguile)'
1487fi
0db83c04
MV
1488
1489## AC_MSG_CHECKING("if we are cross compiling")
1490## AC_MSG_RESULT($cross_compiling)
1491if test "$cross_compiling" = "yes"; then
1492 AC_MSG_RESULT($GUILE_FOR_BUILD)
1493fi
89f69c52 1494AC_ARG_VAR(GUILE_FOR_BUILD,[guile for build system])
0db83c04
MV
1495AC_SUBST(GUILE_FOR_BUILD)
1496
3a629497 1497## If we're using GCC, ask for aggressive warnings.
f29ded4b 1498GCC_CFLAGS=""
3a629497 1499case "$GCC" in
99be3450 1500 yes )
0a1b8b15
JB
1501 ## We had -Wstrict-prototypes in here for a bit, but Guile does too
1502 ## much stuff with generic function pointers for that to really be
1503 ## less than exasperating.
aee8ca3f
GH
1504 ## -Wpointer-arith was here too, but something changed in gcc/glibc
1505 ## and it became equally exasperating (gcc 2.95 and/or glibc 2.1.2).
8bcecbd3
LC
1506 POTENTIAL_GCC_CFLAGS="-Wall -Wmissing-prototypes \
1507 -Wdeclaration-after-statement -Wundef \
1508 -Wswitch-enum"
5c07af6e
MV
1509 # Do this here so we don't screw up any of the tests above that might
1510 # not be "warning free"
1511 if test "${GUILE_ERROR_ON_WARNING}" = yes
1512 then
f29ded4b 1513 POTENTIAL_GCC_CFLAGS="${POTENTIAL_GCC_CFLAGS} -Werror"
5c07af6e
MV
1514 enable_compile_warnings=no
1515 fi
f29ded4b
LC
1516
1517 for flag in $POTENTIAL_GCC_CFLAGS
1518 do
1519 gl_WARN_ADD([$flag], [GCC_CFLAGS])
1520 done
5c07af6e 1521 ;;
3a629497
JB
1522esac
1523
582a4997
LC
1524AC_SUBST(GCC_CFLAGS)
1525
9d19a9d6
LC
1526# Check for GNU ld's "-z relro".
1527GUILE_GNU_LD_RELRO
1528
1529
3a629497
JB
1530## If we're creating a shared library (using libtool!), then we'll
1531## need to generate a list of .lo files corresponding to the .o files
1532## given in LIBOBJS. We'll call it LIBLOBJS.
eede3dbc 1533LIBLOBJS="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`"
3a629497 1534
e9e225e5 1535## We also need to create corresponding .doc and .x files
eede3dbc
RB
1536EXTRA_DOT_DOC_FILES="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.doc ,g;s,\.[[^.]]*$,.doc,'`"
1537EXTRA_DOT_X_FILES="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.x ,g;s,\.[[^.]]*$,.x,'`"
91411868 1538
7a5ab369
LC
1539# GNU Readline bindings.
1540GUILE_READLINE
1541
7c86ae05
JB
1542AC_SUBST(GUILE_MAJOR_VERSION)
1543AC_SUBST(GUILE_MINOR_VERSION)
df4a8db0 1544AC_SUBST(GUILE_MICRO_VERSION)
9e6e154e 1545AC_SUBST(GUILE_EFFECTIVE_VERSION)
7c86ae05 1546AC_SUBST(GUILE_VERSION)
9e202853 1547
22b7f585
RB
1548#######################################################################
1549# library versioning
1550
9e202853
RB
1551AC_SUBST(LIBGUILE_INTERFACE_CURRENT)
1552AC_SUBST(LIBGUILE_INTERFACE_REVISION)
1553AC_SUBST(LIBGUILE_INTERFACE_AGE)
1554AC_SUBST(LIBGUILE_INTERFACE)
539c89a1 1555
b8b9ec68 1556AC_SUBST(LIBGUILE_SRFI_SRFI_1_MAJOR)
cfc7c7c0
MD
1557AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_CURRENT)
1558AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_REVISION)
1559AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE_AGE)
1560AC_SUBST(LIBGUILE_SRFI_SRFI_1_INTERFACE)
1561
b8b9ec68 1562AC_SUBST(LIBGUILE_SRFI_SRFI_4_MAJOR)
22b7f585
RB
1563AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_CURRENT)
1564AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_REVISION)
1565AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE_AGE)
1566AC_SUBST(LIBGUILE_SRFI_SRFI_4_INTERFACE)
1567
b8b9ec68 1568AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_MAJOR)
22b7f585
RB
1569AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_CURRENT)
1570AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_REVISION)
1571AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE_AGE)
1572AC_SUBST(LIBGUILE_SRFI_SRFI_13_14_INTERFACE)
1573
6bba4fad
KR
1574AC_SUBST(LIBGUILE_SRFI_SRFI_60_MAJOR)
1575AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_CURRENT)
1576AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_REVISION)
1577AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE_AGE)
1578AC_SUBST(LIBGUILE_SRFI_SRFI_60_INTERFACE)
1579
b89c4943
LC
1580AC_SUBST(LIBGUILE_I18N_MAJOR)
1581AC_SUBST(LIBGUILE_I18N_INTERFACE_CURRENT)
1582AC_SUBST(LIBGUILE_I18N_INTERFACE_REVISION)
1583AC_SUBST(LIBGUILE_I18N_INTERFACE_AGE)
1584AC_SUBST(LIBGUILE_I18N_INTERFACE)
1585
1586
22b7f585
RB
1587#######################################################################
1588
d8b1bb93 1589dnl Tell guile-config what flags guile users should compile and link with.
a8d7ba11 1590GUILE_LIBS="$LDFLAGS $LIBS"
25a640ca 1591GUILE_CFLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
daa4f38c 1592AC_SUBST(GUILE_LIBS)
d8b1bb93 1593AC_SUBST(GUILE_CFLAGS)
7c86ae05 1594
3a629497
JB
1595AC_SUBST(AWK)
1596AC_SUBST(LIBLOBJS)
91411868 1597AC_SUBST(EXTRA_DOT_DOC_FILES)
e9e225e5 1598AC_SUBST(EXTRA_DOT_X_FILES)
3a629497 1599
6812c28f
TTN
1600dnl See also top_builddir in info node: (libtool)AC_PROG_LIBTOOL
1601top_builddir_absolute=`pwd`
1602AC_SUBST(top_builddir_absolute)
9e6e154e 1603top_srcdir_absolute=`(cd $srcdir && pwd)`
2f13db9a 1604AC_SUBST(top_srcdir_absolute)
6812c28f 1605
92826dd0
LC
1606dnl We need `sitedir' in `guile-1.8.pc'.
1607dnl Note: `sitedir' must be kept in sync with `GUILE_SITE_DIR' in `guile.m4'.
0c1eb9b6 1608pkgdatadir="$datadir/$PACKAGE_TARNAME"
92826dd0
LC
1609sitedir="$pkgdatadir/site"
1610AC_SUBST([sitedir])
1611
9a52bc2a
RB
1612# Additional SCM_I_GSC definitions are above.
1613AC_SUBST([SCM_I_GSC_GUILE_DEBUG])
f5922e27 1614AC_SUBST([SCM_I_GSC_ENABLE_DISCOURAGED])
9a52bc2a 1615AC_SUBST([SCM_I_GSC_ENABLE_DEPRECATED])
9a52bc2a
RB
1616AC_SUBST([SCM_I_GSC_STACK_GROWS_UP])
1617AC_SUBST([SCM_I_GSC_C_INLINE])
1618AC_CONFIG_FILES([libguile/gen-scmconfig.h])
1619
237b3247
RB
1620AC_CONFIG_FILES([
1621 Makefile
6812c28f 1622 am/Makefile
6caac03c 1623 lib/Makefile
9e6e154e
RB
1624 benchmark-suite/Makefile
1625 doc/Makefile
9e6e154e
RB
1626 doc/r5rs/Makefile
1627 doc/ref/Makefile
1e2346ae 1628 emacs/Makefile
9e6e154e 1629 examples/Makefile
9e6e154e 1630 libguile/Makefile
237b3247 1631 srfi/Makefile
7a5ab369 1632 guile-readline/Makefile
849f29a4
RB
1633 test-suite/Makefile
1634 test-suite/standalone/Makefile
0b6d8fdc 1635 meta/Makefile
e610dc38 1636 module/Makefile
e610dc38 1637 testsuite/Makefile
849f29a4 1638])
9e6e154e 1639
c1a15f3d
LC
1640AC_CONFIG_FILES([meta/guile-2.0.pc])
1641AC_CONFIG_FILES([meta/guile-2.0-uninstalled.pc])
9e6e154e
RB
1642AC_CONFIG_FILES([check-guile], [chmod +x check-guile])
1643AC_CONFIG_FILES([benchmark-guile], [chmod +x benchmark-guile])
0b6d8fdc
AW
1644AC_CONFIG_FILES([meta/guile], [chmod +x meta/guile])
1645AC_CONFIG_FILES([meta/uninstalled-env], [chmod +x meta/uninstalled-env])
1646AC_CONFIG_FILES([meta/gdb-uninstalled-guile], [chmod +x meta/gdb-uninstalled-guile])
54b38caf 1647AC_CONFIG_FILES([meta/guile-tools], [chmod +x meta/guile-tools])
9e6e154e
RB
1648AC_CONFIG_FILES([libguile/guile-snarf],
1649 [chmod +x libguile/guile-snarf])
1650AC_CONFIG_FILES([libguile/guile-doc-snarf],
1651 [chmod +x libguile/guile-doc-snarf])
1652AC_CONFIG_FILES([libguile/guile-func-name-check],
1653 [chmod +x libguile/guile-func-name-check])
1654AC_CONFIG_FILES([libguile/guile-snarf-docs],
1655 [chmod +x libguile/guile-snarf-docs])
d8b6e191
NJ
1656AC_CONFIG_FILES([test-suite/standalone/test-use-srfi],
1657 [chmod +x test-suite/standalone/test-use-srfi])
a9931e4e
NJ
1658AC_CONFIG_FILES([test-suite/standalone/test-fast-slot-ref],
1659 [chmod +x test-suite/standalone/test-fast-slot-ref])
22b5f518 1660AC_CONFIG_FILES([doc/ref/effective-version.texi])
237b3247
RB
1661
1662AC_OUTPUT
0f2d19dd 1663
3a629497
JB
1664dnl Local Variables:
1665dnl comment-start: "dnl "
1666dnl comment-end: ""
1667dnl comment-start-skip: "\\bdnl\\b\\s *"
d67c13f6 1668dnl End: