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