| 1 | dnl -*- Autoconf -*- |
| 2 | |
| 3 | dnl Copyright (C) 1997, 1999, 2000, 2001, 2002, 2004, 2006, |
| 4 | dnl 2007, 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc. |
| 5 | dnl |
| 6 | dnl This file is part of GUILE |
| 7 | dnl |
| 8 | dnl GUILE is free software; you can redistribute it and/or modify it under |
| 9 | dnl the terms of the GNU Lesser General Public License as published by the |
| 10 | dnl Free Software Foundation; either version 3, or (at your option) any |
| 11 | dnl later version. |
| 12 | dnl |
| 13 | dnl GUILE is distributed in the hope that it will be useful, but WITHOUT |
| 14 | dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 16 | dnl License for more details. |
| 17 | dnl |
| 18 | dnl You should have received a copy of the GNU Lesser General Public |
| 19 | dnl License along with GUILE; see the file COPYING.LESSER. If not, write |
| 20 | dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth |
| 21 | dnl Floor, Boston, MA 02110-1301, USA. |
| 22 | |
| 23 | |
| 24 | dnl On the NeXT, #including <utime.h> doesn't give you a definition for |
| 25 | dnl struct utime, unless you #define _POSIX_SOURCE. |
| 26 | |
| 27 | AC_DEFUN([GUILE_STRUCT_UTIMBUF], [ |
| 28 | AC_CACHE_CHECK([whether we need POSIX to get struct utimbuf], |
| 29 | guile_cv_struct_utimbuf_needs_posix, |
| 30 | [AC_TRY_CPP([ |
| 31 | #ifdef __EMX__ |
| 32 | #include <sys/utime.h> |
| 33 | #else |
| 34 | #include <utime.h> |
| 35 | #endif |
| 36 | struct utime blah; |
| 37 | ], |
| 38 | guile_cv_struct_utimbuf_needs_posix=no, |
| 39 | guile_cv_struct_utimbuf_needs_posix=yes)]) |
| 40 | if test "$guile_cv_struct_utimbuf_needs_posix" = yes; then |
| 41 | AC_DEFINE([UTIMBUF_NEEDS_POSIX], 1, |
| 42 | [Define this if <utime.h> doesn't define struct utimbuf unless |
| 43 | _POSIX_SOURCE is defined. See GUILE_STRUCT_UTIMBUF in aclocal.m4.]) |
| 44 | fi]) |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | dnl |
| 50 | dnl Apparently, at CMU they have a weird version of libc.h that is |
| 51 | dnl installed in /usr/local/include and conflicts with unistd.h. |
| 52 | dnl In these situations, we should not #include libc.h. |
| 53 | dnl This test arranges to #define LIBC_H_WITH_UNISTD_H iff libc.h is |
| 54 | dnl present on the system, and is safe to #include. |
| 55 | dnl |
| 56 | AC_DEFUN([GUILE_HEADER_LIBC_WITH_UNISTD], |
| 57 | [ |
| 58 | AC_CHECK_HEADERS(libc.h unistd.h) |
| 59 | AC_CACHE_CHECK( |
| 60 | [whether libc.h and unistd.h can be included together], |
| 61 | guile_cv_header_libc_with_unistd, |
| 62 | [ |
| 63 | if test "$ac_cv_header_libc_h" = "no"; then |
| 64 | guile_cv_header_libc_with_unistd="no" |
| 65 | elif test "$ac_cv_header_unistd_h" = "no"; then |
| 66 | guile_cv_header_libc_with_unistd="yes" |
| 67 | else |
| 68 | AC_TRY_COMPILE( |
| 69 | [ |
| 70 | # include <libc.h> |
| 71 | # include <unistd.h> |
| 72 | ], |
| 73 | [], |
| 74 | [guile_cv_header_libc_with_unistd=yes], |
| 75 | [guile_cv_header_libc_with_unistd=no] |
| 76 | ) |
| 77 | fi |
| 78 | ] |
| 79 | ) |
| 80 | if test "$guile_cv_header_libc_with_unistd" = yes; then |
| 81 | AC_DEFINE([LIBC_H_WITH_UNISTD_H], 1, |
| 82 | [Define this if we should include <libc.h> when we've already |
| 83 | included <unistd.h>. On some systems, they conflict, and libc.h |
| 84 | should be omitted. See GUILE_HEADER_LIBC_WITH_UNISTD in |
| 85 | aclocal.m4.]) |
| 86 | fi |
| 87 | ] |
| 88 | ) |
| 89 | |
| 90 | |
| 91 | |
| 92 | dnl This is needed when we want to check for the same function repeatedly |
| 93 | dnl with other parameters, such as libraries, varying. |
| 94 | dnl |
| 95 | dnl GUILE_NAMED_CHECK_FUNC(FUNCTION, TESTNAME, |
| 96 | dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) |
| 97 | AC_DEFUN([GUILE_NAMED_CHECK_FUNC], |
| 98 | [AC_MSG_CHECKING([for $1]) |
| 99 | AC_CACHE_VAL(ac_cv_func_$1_$2, |
| 100 | [AC_TRY_LINK( |
| 101 | dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h> |
| 102 | dnl which includes <sys/select.h> which contains a prototype for |
| 103 | dnl select. Similarly for bzero. |
| 104 | [/* System header to define __stub macros and hopefully few prototypes, |
| 105 | which can conflict with char $1(); below. */ |
| 106 | #include <assert.h> |
| 107 | /* Override any gcc2 internal prototype to avoid an error. */ |
| 108 | #ifdef __cplusplus |
| 109 | extern "C" |
| 110 | #endif |
| 111 | /* We use char because int might match the return type of a gcc2 |
| 112 | builtin and then its argument prototype would still apply. */ |
| 113 | char $1(); |
| 114 | ], [ |
| 115 | /* The GNU C library defines this for functions which it implements |
| 116 | to always fail with ENOSYS. Some functions are actually named |
| 117 | something starting with __ and the normal name is an alias. */ |
| 118 | #if defined (__stub_$1) || defined (__stub___$1) |
| 119 | choke me |
| 120 | #else |
| 121 | $1(); |
| 122 | #endif |
| 123 | ], eval "ac_cv_func_$1_$2=yes", eval "ac_cv_func_$1_$2=no")]) |
| 124 | if eval "test \"`echo '$ac_cv_func_'$1'_'$2`\" = yes"; then |
| 125 | AC_MSG_RESULT(yes) |
| 126 | ifelse([$3], , :, [$3]) |
| 127 | else |
| 128 | AC_MSG_RESULT(no) |
| 129 | ifelse([$4], , , [$4 |
| 130 | ])dnl |
| 131 | fi |
| 132 | ]) |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | dnl Available from the Autoconf Macro Archive at: |
| 138 | dnl http://autoconf-archive.cryp.to/acx_pthread.html |
| 139 | dnl |
| 140 | AC_DEFUN([ACX_PTHREAD], [ |
| 141 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| 142 | AC_LANG_SAVE |
| 143 | AC_LANG_C |
| 144 | acx_pthread_ok=no |
| 145 | |
| 146 | # We used to check for pthread.h first, but this fails if pthread.h |
| 147 | # requires special compiler flags (e.g. on True64 or Sequent). |
| 148 | # It gets checked for in the link test anyway. |
| 149 | |
| 150 | # First of all, check if the user has set any of the PTHREAD_LIBS, |
| 151 | # etcetera environment variables, and if threads linking works using |
| 152 | # them: |
| 153 | if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then |
| 154 | save_CFLAGS="$CFLAGS" |
| 155 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 156 | save_LIBS="$LIBS" |
| 157 | LIBS="$PTHREAD_LIBS $LIBS" |
| 158 | AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) |
| 159 | AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) |
| 160 | AC_MSG_RESULT($acx_pthread_ok) |
| 161 | if test x"$acx_pthread_ok" = xno; then |
| 162 | PTHREAD_LIBS="" |
| 163 | PTHREAD_CFLAGS="" |
| 164 | fi |
| 165 | LIBS="$save_LIBS" |
| 166 | CFLAGS="$save_CFLAGS" |
| 167 | fi |
| 168 | |
| 169 | # We must check for the threads library under a number of different |
| 170 | # names; the ordering is very important because some systems |
| 171 | # (e.g. DEC) have both -lpthread and -lpthreads, where one of the |
| 172 | # libraries is broken (non-POSIX). |
| 173 | |
| 174 | # Create a list of thread flags to try. Items starting with a "-" are |
| 175 | # C compiler flags, and other items are library names, except for "none" |
| 176 | # which indicates that we try without any flags at all, and "pthread-config" |
| 177 | # which is a program returning the flags for the Pth emulation library. |
| 178 | |
| 179 | acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" |
| 180 | |
| 181 | # The ordering *is* (sometimes) important. Some notes on the |
| 182 | # individual items follow: |
| 183 | |
| 184 | # pthreads: AIX (must check this before -lpthread) |
| 185 | # none: in case threads are in libc; should be tried before -Kthread and |
| 186 | # other compiler flags to prevent continual compiler warnings |
| 187 | # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) |
| 188 | # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) |
| 189 | # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) |
| 190 | # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) |
| 191 | # -pthreads: Solaris/gcc |
| 192 | # -mthreads: Mingw32/gcc, Lynx/gcc |
| 193 | # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it |
| 194 | # doesn't hurt to check since this sometimes defines pthreads too; |
| 195 | # also defines -D_REENTRANT) |
| 196 | # ... -mt is also the pthreads flag for HP/aCC |
| 197 | # pthread: Linux, etcetera |
| 198 | # --thread-safe: KAI C++ |
| 199 | # pthread-config: use pthread-config program (for GNU Pth library) |
| 200 | |
| 201 | case "${host_cpu}-${host_os}" in |
| 202 | *solaris*) |
| 203 | |
| 204 | # On Solaris (at least, for some versions), libc contains stubbed |
| 205 | # (non-functional) versions of the pthreads routines, so link-based |
| 206 | # tests will erroneously succeed. (We need to link with -pthreads/-mt/ |
| 207 | # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather |
| 208 | # a function called by this macro, so we could check for that, but |
| 209 | # who knows whether they'll stub that too in a future libc.) So, |
| 210 | # we'll just look for -pthreads and -lpthread first: |
| 211 | |
| 212 | acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" |
| 213 | ;; |
| 214 | esac |
| 215 | |
| 216 | if test x"$acx_pthread_ok" = xno; then |
| 217 | for flag in $acx_pthread_flags; do |
| 218 | |
| 219 | case $flag in |
| 220 | none) |
| 221 | AC_MSG_CHECKING([whether pthreads work without any flags]) |
| 222 | ;; |
| 223 | |
| 224 | -*) |
| 225 | AC_MSG_CHECKING([whether pthreads work with $flag]) |
| 226 | PTHREAD_CFLAGS="$flag" |
| 227 | ;; |
| 228 | |
| 229 | pthread-config) |
| 230 | AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) |
| 231 | if test x"$acx_pthread_config" = xno; then continue; fi |
| 232 | PTHREAD_CFLAGS="`pthread-config --cflags`" |
| 233 | PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" |
| 234 | ;; |
| 235 | |
| 236 | *) |
| 237 | AC_MSG_CHECKING([for the pthreads library -l$flag]) |
| 238 | PTHREAD_LIBS="-l$flag" |
| 239 | ;; |
| 240 | esac |
| 241 | |
| 242 | save_LIBS="$LIBS" |
| 243 | save_CFLAGS="$CFLAGS" |
| 244 | LIBS="$PTHREAD_LIBS $LIBS" |
| 245 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 246 | |
| 247 | # Check for various functions. We must include pthread.h, |
| 248 | # since some functions may be macros. (On the Sequent, we |
| 249 | # need a special flag -Kthread to make this header compile.) |
| 250 | # We check for pthread_join because it is in -lpthread on IRIX |
| 251 | # while pthread_create is in libc. We check for pthread_attr_init |
| 252 | # due to DEC craziness with -lpthreads. We check for |
| 253 | # pthread_cleanup_push because it is one of the few pthread |
| 254 | # functions on Solaris that doesn't have a non-functional libc stub. |
| 255 | # We try pthread_create on general principles. |
| 256 | AC_TRY_LINK([#include <pthread.h>], |
| 257 | [pthread_t th; pthread_join(th, 0); |
| 258 | pthread_attr_init(0); pthread_cleanup_push(0, 0); |
| 259 | pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], |
| 260 | [acx_pthread_ok=yes]) |
| 261 | |
| 262 | LIBS="$save_LIBS" |
| 263 | CFLAGS="$save_CFLAGS" |
| 264 | |
| 265 | AC_MSG_RESULT($acx_pthread_ok) |
| 266 | if test "x$acx_pthread_ok" = xyes; then |
| 267 | break; |
| 268 | fi |
| 269 | |
| 270 | PTHREAD_LIBS="" |
| 271 | PTHREAD_CFLAGS="" |
| 272 | done |
| 273 | fi |
| 274 | |
| 275 | # Various other checks: |
| 276 | if test "x$acx_pthread_ok" = xyes; then |
| 277 | save_LIBS="$LIBS" |
| 278 | LIBS="$PTHREAD_LIBS $LIBS" |
| 279 | save_CFLAGS="$CFLAGS" |
| 280 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 281 | |
| 282 | # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. |
| 283 | AC_MSG_CHECKING([for joinable pthread attribute]) |
| 284 | attr_name=unknown |
| 285 | for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do |
| 286 | AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;], |
| 287 | [attr_name=$attr; break]) |
| 288 | done |
| 289 | AC_MSG_RESULT($attr_name) |
| 290 | if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then |
| 291 | AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], $attr_name, |
| 292 | [Define to necessary symbol if this constant |
| 293 | uses a non-standard name on your system.]) |
| 294 | fi |
| 295 | |
| 296 | AC_MSG_CHECKING([if more special flags are required for pthreads]) |
| 297 | flag=no |
| 298 | case "${host_cpu}-${host_os}" in |
| 299 | *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; |
| 300 | *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; |
| 301 | esac |
| 302 | AC_MSG_RESULT(${flag}) |
| 303 | if test "x$flag" != xno; then |
| 304 | PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" |
| 305 | fi |
| 306 | |
| 307 | LIBS="$save_LIBS" |
| 308 | CFLAGS="$save_CFLAGS" |
| 309 | |
| 310 | # More AIX lossage: must compile with xlc_r or cc_r |
| 311 | if test x"$GCC" != xyes; then |
| 312 | AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) |
| 313 | else |
| 314 | PTHREAD_CC=$CC |
| 315 | fi |
| 316 | else |
| 317 | PTHREAD_CC="$CC" |
| 318 | fi |
| 319 | |
| 320 | AC_SUBST(PTHREAD_LIBS) |
| 321 | AC_SUBST(PTHREAD_CFLAGS) |
| 322 | AC_SUBST(PTHREAD_CC) |
| 323 | |
| 324 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: |
| 325 | if test x"$acx_pthread_ok" = xyes; then |
| 326 | ifelse([$1],,AC_DEFINE([HAVE_PTHREAD],1,[Define if you have POSIX threads libraries and header files.]),[$1]) |
| 327 | : |
| 328 | else |
| 329 | acx_pthread_ok=no |
| 330 | $2 |
| 331 | fi |
| 332 | AC_LANG_RESTORE |
| 333 | ])dnl ACX_PTHREAD |
| 334 | |
| 335 | dnl GUILE_GNU_LD_RELRO |
| 336 | dnl |
| 337 | dnl Check whether GNU ld's read-only relocations (the `PT_GNU_RELRO' |
| 338 | dnl ELF segment header) are supported. This allows things like |
| 339 | dnl statically allocated cells (1) to eventually be remapped read-only |
| 340 | dnl by the loader, and (2) to be identified as pointerless by the |
| 341 | dnl garbage collector. Substitute `GNU_LD_FLAGS' with the relevant |
| 342 | dnl flags. |
| 343 | AC_DEFUN([GUILE_GNU_LD_RELRO], [ |
| 344 | AC_MSG_CHECKING([whether the linker understands `-z relro']) |
| 345 | |
| 346 | GNU_LD_FLAGS="-Wl,-z -Wl,relro" |
| 347 | |
| 348 | save_LDFLAGS="$LDFLAGS" |
| 349 | LDFLAGS="$LDFLAGS $GNU_LD_FLAGS" |
| 350 | AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], |
| 351 | [AC_MSG_RESULT([yes])], |
| 352 | [AC_MSG_RESULT([no]) |
| 353 | GNU_LD_FLAGS=""]) |
| 354 | LDFLAGS="$save_LDFLAGS" |
| 355 | |
| 356 | AC_SUBST([GNU_LD_FLAGS]) |
| 357 | ]) |
| 358 | |
| 359 | dnl GUILE_THREAD_LOCAL_STORAGE |
| 360 | dnl |
| 361 | dnl Check for compiler thread-local storage (TLS) support. |
| 362 | AC_DEFUN([GUILE_THREAD_LOCAL_STORAGE], [ |
| 363 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| 364 | |
| 365 | AC_CACHE_CHECK([whether the `__thread' storage class is available], |
| 366 | [ac_cv_have_thread_storage_class], |
| 367 | [dnl On some systems, e.g., NetBSD 5.0 with GCC 4.1, `__thread' is |
| 368 | dnl properly compiled but fails to link due to the lack of TLS |
| 369 | dnl support in the C library. Thus we try to link, not just |
| 370 | dnl compile. Unfortunately, this test is not enough, so we |
| 371 | dnl explicitly check for known-broken systems. See |
| 372 | dnl http://lists.gnu.org/archive/html/guile-devel/2009-10/msg00138.html |
| 373 | dnl for details. |
| 374 | dnl |
| 375 | dnl Known broken systems includes: |
| 376 | dnl - x86_64-unknown-netbsd5.0. |
| 377 | dnl - x86_64-unknown-netbsd5.1 |
| 378 | dnl - sparc-sun-solaris2.8 |
| 379 | dnl |
| 380 | dnl On `x86_64-unknown-freebsd8.0', thread-local storage appears to |
| 381 | dnl be reclaimed at the wrong time, leading to a segfault when |
| 382 | dnl running `threads.test'. So disable it. |
| 383 | case "$enable_shared--$host_os" in |
| 384 | [yes--netbsd[0-5].[0-9]*|yes--solaris2.8|yes--freebsd[0-8]*]) |
| 385 | ac_cv_have_thread_storage_class="no" |
| 386 | ;; |
| 387 | *) |
| 388 | AC_LINK_IFELSE([AC_LANG_PROGRAM([__thread int tls_integer;], |
| 389 | [tls_integer = 123;])], |
| 390 | [ac_cv_have_thread_storage_class="yes"], |
| 391 | [ac_cv_have_thread_storage_class="no"]) |
| 392 | ;; |
| 393 | esac]) |
| 394 | |
| 395 | if test "x$ac_cv_have_thread_storage_class" = "xyes"; then |
| 396 | SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=1 |
| 397 | else |
| 398 | SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=0 |
| 399 | fi |
| 400 | |
| 401 | AC_SUBST([SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS]) |
| 402 | ]) |
| 403 | |
| 404 | dnl GUILE_READLINE |
| 405 | dnl |
| 406 | dnl Check all the things needed by `guile-readline', the Readline |
| 407 | dnl bindings. |
| 408 | AC_DEFUN([GUILE_READLINE], [ |
| 409 | for termlib in ncurses curses termcap terminfo termlib pdcurses ; do |
| 410 | AC_CHECK_LIB(${termlib}, [tgoto], |
| 411 | [READLINE_LIBS="-l${termlib} $READLINE_LIBS"; break]) |
| 412 | done |
| 413 | |
| 414 | AC_LIB_LINKFLAGS([readline]) |
| 415 | |
| 416 | if test "x$LTLIBREADLINE" = "x"; then |
| 417 | AC_MSG_WARN([GNU Readline was not found on your system.]) |
| 418 | else |
| 419 | rl_save_LIBS="$LIBS" |
| 420 | LIBS="$LIBREADLINE $READLINE_LIBS $LIBS" |
| 421 | |
| 422 | AC_CHECK_FUNCS([siginterrupt rl_clear_signals rl_cleanup_after_signal]) |
| 423 | |
| 424 | dnl Check for modern readline naming |
| 425 | AC_CHECK_FUNCS([rl_filename_completion_function]) |
| 426 | AC_CHECK_DECLS([rl_catch_signals, rl_catch_sigwinch], [], [], |
| 427 | [[#include <stdio.h>] |
| 428 | [#include <readline/readline.h>]]) |
| 429 | |
| 430 | dnl Check for rl_get_keymap. We only use this for deciding whether to |
| 431 | dnl install paren matching on the Guile command line (when using |
| 432 | dnl readline for input), so it's completely optional. |
| 433 | AC_CHECK_FUNCS([rl_get_keymap]) |
| 434 | |
| 435 | AC_CACHE_CHECK([for rl_getc_function pointer in readline], |
| 436 | ac_cv_var_rl_getc_function, |
| 437 | [AC_TRY_LINK([ |
| 438 | #include <stdio.h> |
| 439 | #include <readline/readline.h>], |
| 440 | [printf ("%ld", (long) rl_getc_function)], |
| 441 | [ac_cv_var_rl_getc_function=yes], |
| 442 | [ac_cv_var_rl_getc_function=no])]) |
| 443 | if test "${ac_cv_var_rl_getc_function}" = "yes"; then |
| 444 | AC_DEFINE([HAVE_RL_GETC_FUNCTION], 1, |
| 445 | [Define if your readline library has the rl_getc_function variable.]) |
| 446 | fi |
| 447 | |
| 448 | if test $ac_cv_var_rl_getc_function = no; then |
| 449 | AC_MSG_WARN([*** GNU Readline is too old on your system.]) |
| 450 | AC_MSG_WARN([*** You need readline version 2.1 or later.]) |
| 451 | LTLIBREADLINE="" |
| 452 | LIBREADLINE="" |
| 453 | fi |
| 454 | |
| 455 | LIBS="$rl_save_LIBS" |
| 456 | |
| 457 | READLINE_LIBS="$LTLIBREADLINE $READLINE_LIBS" |
| 458 | fi |
| 459 | |
| 460 | AM_CONDITIONAL([HAVE_READLINE], [test "x$LTLIBREADLINE" != "x"]) |
| 461 | |
| 462 | AC_CHECK_FUNCS([strdup]) |
| 463 | |
| 464 | AC_SUBST([READLINE_LIBS]) |
| 465 | ]) |
| 466 | |
| 467 | dnl GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT |
| 468 | dnl |
| 469 | dnl Check whether libunistring has iconv support. When it lacks iconv |
| 470 | dnl support, `mem_iconveh' returns -1 (ENOSYS) and conversions from one |
| 471 | dnl codeset to another do not work. |
| 472 | AC_DEFUN([GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT], [ |
| 473 | AC_CACHE_CHECK([whether libunistring was built with iconv support], |
| 474 | [ac_cv_libunistring_with_iconv_support], [ |
| 475 | save_LIBS=$LIBS |
| 476 | LIBS="$LIBS $LIBUNISTRING" |
| 477 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 478 | #include <uniconv.h> |
| 479 | #include <unistring/iconveh.h> |
| 480 | int |
| 481 | main (int argc, char *argv[]) |
| 482 | { |
| 483 | size_t result_size; |
| 484 | return (NULL == u32_conv_from_encoding ("ASCII", iconveh_question_mark, |
| 485 | "a", 1, |
| 486 | NULL, NULL, &result_size)); |
| 487 | } |
| 488 | ]])], |
| 489 | [ac_cv_libunistring_with_iconv_support=yes], |
| 490 | [ac_cv_libunistring_with_iconv_support=no], |
| 491 | [ac_cv_libunistring_with_iconv_support=yes]) |
| 492 | LIBS=$save_LIBS |
| 493 | ]) |
| 494 | ]) |
| 495 | |
| 496 | dnl GUILE_UNISTRING_CONSTANT NAME |
| 497 | dnl |
| 498 | dnl Determine the compile-time value of NAME and define/substitute |
| 499 | dnl `SCM_I_GSC_NAME'. |
| 500 | AC_DEFUN([GUILE_UNISTRING_CONSTANT], [ |
| 501 | m4_pushdef([UPPER_CASE_NAME], |
| 502 | [m4_translit([$1],[abcdefghijklmnopqrstuvwxyz], |
| 503 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ])]) |
| 504 | |
| 505 | AC_CACHE_CHECK([the value of `$1'], [ac_cv_]$1, [ |
| 506 | AC_COMPUTE_INT([ac_cv_]$1, [$1], |
| 507 | [AC_INCLUDES_DEFAULT |
| 508 | #include <uniconv.h> |
| 509 | ], |
| 510 | [AC_MSG_ERROR([failed to determine the value of `$1'])]) |
| 511 | ]) |
| 512 | |
| 513 | [SCM_I_GSC_]UPPER_CASE_NAME="$ac_cv_[]$1" |
| 514 | AC_SUBST([SCM_I_GSC_]UPPER_CASE_NAME) |
| 515 | m4_popdef([UPPER_CASE_NAME])]) |
| 516 | |
| 517 | dnl GUILE_UNISTRING_ICONVEH_VALUES |
| 518 | dnl |
| 519 | dnl Determine the values of the `iconveh_' libunistring constants. |
| 520 | AC_DEFUN([GUILE_UNISTRING_ICONVEH_VALUES], [ |
| 521 | GUILE_UNISTRING_CONSTANT([iconveh_error]) |
| 522 | GUILE_UNISTRING_CONSTANT([iconveh_question_mark]) |
| 523 | GUILE_UNISTRING_CONSTANT([iconveh_escape_sequence]) |
| 524 | ]) |
| 525 | |
| 526 | dnl GUILE_CHECK_VERSION |
| 527 | dnl |
| 528 | dnl Ensure that $GUILE_FOR_BUILD has the same version as ourselves. |
| 529 | AC_DEFUN([GUILE_CHECK_VERSION], [ |
| 530 | if ! "$GUILE_FOR_BUILD" --version > /dev/null 2>&1; then |
| 531 | AC_MSG_ERROR([failed to run `$GUILE_FOR_BUILD']) |
| 532 | fi |
| 533 | |
| 534 | dnl Use MAJOR.MINOR.MICRO instead of (version) so that developers can |
| 535 | dnl freely shoot themselves in the foot by using, say, 2.0.3.80 and |
| 536 | dnl 2.0.3.42. |
| 537 | AC_CACHE_CHECK([the version of $GUILE_FOR_BUILD], |
| 538 | [ac_cv_guile_for_build_version], |
| 539 | [ac_cv_guile_for_build_version="`"$GUILE_FOR_BUILD" \ |
| 540 | -c '(format #t "~a.~a.~a" (major-version) (minor-version) (micro-version))'`" |
| 541 | ]) |
| 542 | |
| 543 | if test "$ac_cv_guile_for_build_version" != \ |
| 544 | "$GUILE_MAJOR_VERSION.$GUILE_MINOR_VERSION.$GUILE_MICRO_VERSION" |
| 545 | then |
| 546 | AC_MSG_ERROR([building Guile $PACKAGE_VERSION but `$GUILE_FOR_BUILD' has version $ac_cv_guile_for_build_version"]) |
| 547 | fi |
| 548 | ]) |
| 549 | |
| 550 | dnl GUILE_CHECK_GUILE_FOR_BUILD |
| 551 | dnl |
| 552 | dnl When cross-compiling, ensure that $GUILE_FOR_BUILD is suitable. |
| 553 | AC_DEFUN([GUILE_CHECK_GUILE_FOR_BUILD], [ |
| 554 | if test "$cross_compiling" = "yes"; then |
| 555 | if test "x$GUILE_FOR_BUILD" = "x"; then |
| 556 | AC_PATH_PROG([GUILE_FOR_BUILD], [guile], [not-found]) |
| 557 | if test "$GUILE_FOR_BUILD" = "not-found"; then |
| 558 | AC_MSG_ERROR([a native Guile $PACKAGE_VERSION is required to cross-build Guile]) |
| 559 | fi |
| 560 | fi |
| 561 | AC_MSG_CHECKING([guile for build]) |
| 562 | AC_MSG_RESULT([$GUILE_FOR_BUILD]) |
| 563 | |
| 564 | dnl Since there is currently no distinction between the run-time |
| 565 | dnl search path, %load-path, and the compiler's search path, |
| 566 | dnl $GUILE_FOR_BUILD must be a native build of the very same version. |
| 567 | GUILE_CHECK_VERSION |
| 568 | else |
| 569 | GUILE_FOR_BUILD='this-value-will-never-be-used' |
| 570 | fi |
| 571 | |
| 572 | AC_ARG_VAR([GUILE_FOR_BUILD], [guile for the build system]) |
| 573 | AM_SUBST_NOTMAKE([GUILE_FOR_BUILD]) |
| 574 | ]) |
| 575 | |
| 576 | dnl Declare file $1 to be a script that needs configuring, |
| 577 | dnl and arrange to make it executable in the process. |
| 578 | AC_DEFUN([GUILE_CONFIG_SCRIPT],[AC_CONFIG_FILES([$1],[chmod +x $1])]) |