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