configure.ac 45 KB

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