configure.ac 45 KB

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