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