configure.ac 45 KB

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