acinclude.m4 20 KB

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