configure.ac 55 KB

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