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