configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. # -*- Autoconf -*-
  2. AC_PREREQ(2.69)
  3. AC_INIT(smlsharp)
  4. AC_CONFIG_SRCDIR([src/compiler/compilePhases/toplevel/main/Top.sml])
  5. AC_CONFIG_HEADER([config.h])
  6. AC_CANONICAL_TARGET
  7. AC_ARG_PROGRAM
  8. # -------- Checks for C/C++ compiler capability --------
  9. AC_PROG_CC
  10. AC_PROG_CC_C99
  11. if test "x$ac_cv_prog_cc_c99" = "xno"; then
  12. AC_MSG_ERROR([C99 compiler is required])
  13. fi
  14. AC_PROG_CXX
  15. AC_LANG(C)
  16. AC_USE_SYSTEM_EXTENSIONS
  17. AC_CHECK_HEADERS(stdatomic.h, [], [
  18. AC_MSG_CHECKING([for __atomic builtins])
  19. AC_COMPILE_IFELSE(
  20. [ AC_LANG_SOURCE([
  21. int foo(void **p1, void **p2, void *p3) {
  22. return __atomic_compare_exchange_n
  23. (p1, p2, p3, 1, __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
  24. }
  25. ])],
  26. [ AC_MSG_RESULT([yes])
  27. AC_DEFINE(HAVE_GCC_ATOMIC, 1, [Define if __atomic builtins are available])
  28. ],
  29. [ AC_MSG_RESULT([no])
  30. AC_MSG_ERROR([__atomic builtins are not available. Use GCC 4.7 or later])
  31. ])
  32. ])
  33. AC_MSG_CHECKING([for alignof])
  34. AC_COMPILE_IFELSE(
  35. [ AC_LANG_SOURCE([ int x = alignof(void *); ]) ],
  36. [ AC_MSG_RESULT([yes])
  37. AC_DEFINE(HAVE_ALIGNOF, 1, [Define if aligonof is available]) ],
  38. [ AC_COMPILE_IFELSE(
  39. [ AC_LANG_SOURCE([ int x = __alignof__(void *); ]) ],
  40. [ AC_MSG_RESULT([yes])
  41. AC_DEFINE(HAVE_ALIGNOF, 1)
  42. AC_DEFINE(alignof, __alignof__, [Alternative to alignof]) ],
  43. [ AC_MSG_RESULT([no]) ]) ])
  44. AC_MSG_CHECKING([for _Thread_local storage class])
  45. AC_COMPILE_IFELSE(
  46. [ AC_LANG_SOURCE([ _Thread_local int hoge; int foo() { return hoge; } ]) ],
  47. [ AC_MSG_RESULT([yes])
  48. AC_DEFINE(HAVE_TLS, 1, [Define if _Thread_local is available]) ],
  49. [ AC_MSG_RESULT([no])
  50. AC_MSG_CHECKING([for __thread storage class])
  51. AC_COMPILE_IFELSE(
  52. [ AC_LANG_SOURCE([ __thread int hoge; int foo() { return hoge; } ]) ],
  53. [ AC_MSG_RESULT([yes])
  54. AC_DEFINE(_Thread_local, __thread, [alternative to _Thread_local])
  55. AC_DEFINE(HAVE_TLS, 1) ]
  56. [ AC_MSG_RESULT([no]) ])
  57. ])
  58. # -------- Check for tools --------
  59. AC_PROG_MAKE_SET
  60. AC_PROG_INSTALL
  61. AC_PATH_PROG(FIND, find)
  62. AC_PROG_RANLIB
  63. AC_CHECK_TOOL(LD, ld)
  64. AC_CHECK_TOOL(AR, ar)
  65. dnl AC_CHECK_TOOL(WINDRES, windres)
  66. dnl AC_PATH_PROG(DOXYGEN, doxygen)
  67. dnl ToDo: check ar and ranlib working
  68. # -------- Check for system-dependent properties --------
  69. : ${SMLFLAGS=-O2}
  70. : ${LLCFLAGS=}
  71. RUNTIME_DEFS=
  72. AC_SUBST(SMLFLAGS)
  73. AC_SUBST(LLCFLAGS)
  74. AC_SUBST(RUNTIME_DEFS)
  75. AC_SUBST(LIBEXT)
  76. AC_SUBST(DLLEXT)
  77. AC_SUBST(ASMEXT)
  78. AC_SUBST(OBJEXT)
  79. AC_SUBST(EXEEXT)
  80. AC_SUBST(A_OUT)
  81. AC_SUBST(RUNLOOP_DLDFLAGS)
  82. AC_SUBST(HOST_OS_TYPE)
  83. AC_SUBST(CMDLINE_MAXLEN)
  84. case "$target_os" in
  85. dnl *cygwin*)
  86. dnl DLLEXT='dll'
  87. dnl EXEEXT=.exe
  88. dnl A_OUT=a.exe
  89. dnl AC_CHECK_TOOL(DLLTOOL, dlltool, :)
  90. dnl AC_PATH_PROG(CYGPATH, cygpath)
  91. dnl if test "x$CYGPATH" = "x"; then
  92. dnl case "$host_os" in
  93. dnl *cygwin*)
  94. dnl AC_MSG_ERROR([cygpath is not found.])
  95. dnl ;;
  96. dnl esac
  97. dnl fi
  98. dnl AC_SUBST(CYGPATH)
  99. dnl if test "x$WINDRES" != "x"; then
  100. dnl RESOURCE_TYPE=rc
  101. dnl fi
  102. dnl AC_SUBST(RESOURCE_TYPE)
  103. mingw*)
  104. : ${DLLEXT='dll'}
  105. : ${EXEEXT='.exe'}
  106. : ${A_OUT=a.exe}
  107. : ${HOST_OS_TYPE=Mingw}
  108. : ${CMDLINE_MAXLEN='SOME 2047'}
  109. : ${RDYNAMIC_LDFFLAGS='-Wl,--export-all-symbols -Wl,--out-implib=src/compiler/smlsharp.lib'}
  110. : ${RUNLOOP_DLDFLAGS='-shared -Wl,--enable-auto-import,--enable-stdcall-fixup'}
  111. ;;
  112. darwin*)
  113. : ${DLLEXT='dylib'}
  114. : ${HOST_OS_TYPE=Unix}
  115. : ${CMDLINE_MAXLEN='NONE'}
  116. : ${RDYNAMIC_LDFLAGS=}
  117. : ${RUNLOOP_DLDFLAGS='-dynamiclib -Wl,-undefined,dynamic_lookup,-flat_namespace'}
  118. ;;
  119. linux*|*bsd*)
  120. : ${HOST_OS_TYPE=Unix}
  121. : ${CMDLINE_MAXLEN='NONE'}
  122. : ${RDYNAMIC_LDFLAGS='-rdynamic'}
  123. : ${RUNLOOP_DLDFLAGS='-shared'}
  124. ;;
  125. esac
  126. : ${LIBEXT=a}
  127. : ${DLLEXT=so}
  128. : ${ASMEXT=s}
  129. : ${OBJEXT=o}
  130. : ${EXEEXT=}
  131. : ${A_OUT=a.out}
  132. if test "x${HOST_OS_TYPE-__unset__}" = "x__unset__" || \
  133. test "x${CMDLINE_MAXLEN-__unset__}" = "x__unset__" || \
  134. test "x${RDYNAMIC_LDFLAGS-__unset__}" = "x__unset__" || \
  135. test "x${RUNLOOP_DLDFLAGS-__unset__}" = "x__unset__"; then
  136. echo $HOST_OS_TYPE
  137. echo $CMDLINE_MAXLEN
  138. echo $RDYNAMIC_LDFLAGS
  139. echo $RUNLOOP_DLDFLAGS
  140. AC_MSG_ERROR([configure cannot guess HOST_OS_TYPE, CMDLINE_MAXLEN, RDYNAMIC_LDFLAGS, and RUNLOOP_DLDFLAGS for $target_os. You need to speficy them by the configure command line.])
  141. fi
  142. AC_DEFUN([CHECK_LDFLAGS], [
  143. orig_LDFLAGS=$LDFLAGS
  144. LDFLAGS="$orig_LDFLAGS $[]$1"
  145. AC_MSG_CHECKING([that $1 works])
  146. AC_LINK_IFELSE(
  147. [ AC_LANG_SOURCE([ int foo() { return 0; } int main() { return 0; } ]) ],
  148. [ AC_MSG_RESULT(yes) ],
  149. [ AC_MSG_RESULT(no)
  150. AC_MSG_ERROR([$1 does not work]) ])
  151. LDFLAGS=$orig_LDFLAGS
  152. ])
  153. CHECK_LDFLAGS(RDYNAMIC_LDFLAGS)
  154. CHECK_LDFLAGS(RUNLOOP_DLDFLAGS)
  155. RDYNAMIC_SMLFLAGS=
  156. AC_SUBST(RDYNAMIC_SMLFLAGS)
  157. for i in $RDYNAMIC_LDFLAGS; do
  158. test -n "$RDYNAMIC_SMLFLAGS" && RDYNAMIC_SMLFLAGS="${RDYNAMIC_SMLFLAGS} "
  159. RDYNAMIC_SMLFLAGS="${RDYNAMIC_SMLFLAGS}-Xlinker $i"
  160. done
  161. # -------- Check for LLVM --------
  162. LLVM_PATH=$PATH
  163. AC_ARG_WITH(llvm,
  164. AS_HELP_STRING([--with-llvm=DIR],
  165. [specify where LLVM has installed in]),
  166. [
  167. case "x$withval" in
  168. yes|no) ;;
  169. *) LLVM_PATH="$withval/bin:$LLVM_PATH" ;;
  170. esac
  171. ])
  172. AC_DEFUN([LLVM_CHECK_PROG], [
  173. AC_PATH_PROG($1, $2, [], $3)
  174. if test -z "$[]$1"; then
  175. AC_MSG_ERROR([$2 is not found.])
  176. fi
  177. ])
  178. AC_DEFUN([LLVM_CHECK_CONFIG], [
  179. AC_MSG_CHECKING([for LLVM $2])
  180. $1=`$[]LLVM_CONFIG --$2` || AC_MSG_ERROR([failed])
  181. AC_MSG_RESULT($[]$1)
  182. AC_SUBST($1)
  183. ])
  184. LLVM_CHECK_PROG(LLVM_CONFIG, llvm-config, $LLVM_PATH)
  185. LLVM_CHECK_CONFIG(LLVM_bindir, bindir)
  186. LLVM_CHECK_CONFIG(LLVM_CXXFLAGS, cxxflags)
  187. LLVM_CHECK_CONFIG(LLVM_VERSION, version)
  188. LLVM_CHECK_PROG(LLC, llc, $LLVM_bindir)
  189. LLVM_CHECK_PROG(OPT, opt, $LLVM_bindir)
  190. LLVM_CHECK_PROG(LLVM_DIS, llvm-dis, $LLVM_bindir)
  191. LLVM_CHECK_PROG(LLVM_AS, llvm-as, $LLVM_bindir)
  192. AC_ARG_WITH(incompatible-llvm,
  193. AS_HELP_STRING([--with-incompatible-llvm], [skip LLVM compatibility check]))
  194. AC_MSG_CHECKING([for LLVM compatibility])
  195. LLVM_VERSION=`echo "$LLVM_VERSION" | sed 's/\.[[0-9]]*$//'`
  196. AC_SUBST(LLVM_VERSION)
  197. case "$LLVM_VERSION" in
  198. 3.9|[[4-9]].0|1[[0-1]].0|11.1|12.0)
  199. AC_MSG_RESULT(yes)
  200. ;;
  201. *)
  202. AC_MSG_RESULT(no)
  203. AC_MSG_WARN([SML[#] does not support LLVM $LLVM_VERSION. Build may fail due to incompatibility.])
  204. if test "x$with_incompatible_llvm" != "xyes"; then
  205. AC_MSG_ERROR([Specify --with-incompatible-llvm if you really want to build SML[#] with it.])
  206. fi
  207. ;;
  208. esac
  209. # -------- Check for self- and cross-compilation ---------
  210. MINISMLLEX='$(SMLLEX)'
  211. MINISMLYACC='$(SMLYACC)'
  212. MINISMLFORMAT='$(SMLFORMAT)'
  213. MINISMLSHARP_LLVM_PLUGIN='$(LLVM_PLUGIN)'
  214. MINISMLSHARP=./minismlsharp
  215. AC_SUBST(MINISMLLEX)
  216. AC_SUBST(MINISMLYACC)
  217. AC_SUBST(MINISMLFORMAT)
  218. AC_SUBST(MINISMLSHARP_LLVM_PLUGIN)
  219. AC_SUBST(MINISMLSHARP)
  220. AC_ARG_WITH(smlsharp,
  221. AS_HELP_STRING([--with-smlsharp=DIR],
  222. [specify smlsharp directory (required for cross compile)]),
  223. [
  224. if test "x$withval" = "xno"; then
  225. if test "x$build" != "x$target"; then
  226. AC_ERROR([--with-smlsharp is required for cross-compiling the compiler])
  227. fi
  228. elif test -f "$withval/src/compiler/smlsharp"; then
  229. MINISMLLEX="$withval/src/ml-lex/smllex"
  230. MINISMLYACC="$withval/src/ml-yacc/smlyacc"
  231. MINISMLFORMAT="$withval/src/smlformat/smlformat"
  232. MINISMLSHARP_LLVM_PLUGIN=""
  233. MINISMLSHARP="$withval/src/compiler/smlsharp"
  234. SMLFLAGS="-BX $withval/src $SMLFLAGS"
  235. else
  236. AC_ERROR([Specify a complete build tree to --with-smlsharp])
  237. fi
  238. ],
  239. [
  240. if test "x$build" != "x$target"; then
  241. AC_ERROR([--with-smlsharp is required for cross-compiling the compiler])
  242. fi
  243. ])
  244. AC_SUBST(PRECOMPILED_ARCH)
  245. if test "x$build" = "x$target"; then
  246. if test "x$MINISMLSHARP" = "x./minismlsharp"; then
  247. AC_PATH_PROG(XZ, xz)
  248. if test "x$XZ" = "x"; then
  249. AC_MSG_ERROR([xz is required to build smlsharp.])
  250. fi
  251. fi
  252. case "$target_cpu" in
  253. x86_64|amd64)
  254. PRECOMPILED_ARCH=x86_64
  255. ;;
  256. *)
  257. AC_MSG_ERROR([the compiler is not precompiled for target_cpu $target_cpu.])
  258. ;;
  259. esac
  260. else
  261. SMLFLAGS="--target=$target $SMLFLAGS"
  262. fi
  263. # -------- Check for supporting target platform --------
  264. AC_MSG_CHECKING([whether target platform is supported])
  265. case "$target_cpu" in
  266. i[[3456]]86)
  267. AC_MSG_RESULT([yes])
  268. RUNTIME_DEFS="$RUNTIME_DEFS -DHOST_CPU_i386"
  269. LLCFLAGS="$LLCFLAGS -no-x86-call-frame-opt"
  270. ;;
  271. x86_64|amd64)
  272. AC_MSG_RESULT([yes])
  273. RUNTIME_DEFS="$RUNTIME_DEFS -DHOST_CPU_i386"
  274. LLCFLAGS="$LLCFLAGS -no-x86-call-frame-opt"
  275. ;;
  276. *)
  277. AC_MSG_RESULT([no])
  278. AC_MSG_ERROR([target_cpu $target_cpu is not supported.])
  279. ;;
  280. esac
  281. PIC_DEFAULT=false
  282. AC_SUBST(PIC_DEFAULT)
  283. case "$target" in
  284. *-darwin*-*|x86_64-*|amd64-*)
  285. PIC_DEFAULT=true
  286. ;;
  287. esac
  288. if test "x$PIC_DEFAULT" = "xtrue"; then
  289. LLCFLAGS="$LLCFLAGS -relocation-model=pic"
  290. CFLAGS="$CFLAGS -fPIC"
  291. fi
  292. case "$target_os" in
  293. *mingw*)
  294. AC_DEFINE(MINGW, 1, [Define if your system is Windows])
  295. ;;
  296. esac
  297. AC_C_BIGENDIAN([
  298. AC_DEFINE(WORDS_BIGENDIAN, [1], [Define if your processor is big endian])
  299. ])
  300. AC_SUBST(BYTE_ORDER)
  301. # -------- Extra options for developers --------
  302. RELEASE='$(srcdir)/RELEASE'
  303. MKREL='#'
  304. MKDST='#'
  305. AC_SUBST(RELEASE)
  306. AC_SUBST(MKREL)
  307. AC_SUBST(MKDST)
  308. if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then
  309. MKDST=
  310. x=`cd "$srcdir" && git ls-files RELEASE 2>/dev/null || :`
  311. if test -z "$x"; then
  312. RELEASE=RELEASE
  313. MKREL=
  314. fi
  315. fi
  316. if test -n "$MKREL" && test ! -f "$srcdir/RELEASE"; then
  317. AC_MSG_WARN([SML[#] version is unknown because of lack of RELEASE file])
  318. RELEASE=
  319. fi
  320. EXTRA_OPTIONS=
  321. AC_SUBST(EXTRA_OPTIONS)
  322. AC_ARG_ENABLE(extra-options,
  323. AS_HELP_STRING([--enable-extra-options=OPTIONS],
  324. [set default extra options (for developers only)]),
  325. [
  326. case "$enableval" in
  327. yes|no) ;;
  328. *) EXTRA_OPTIONS=$enableval ;;
  329. esac
  330. ])
  331. # -------- Checks for multithread support --------
  332. AC_CHECK_LIB(pthread, pthread_create,
  333. [], [ AC_MSG_ERROR([pthread library is not found]) ])
  334. AC_ARG_WITH(massivethreads,
  335. AS_HELP_STRING([--with-massivethreads=DIR],
  336. [specify where MassiveThreads has installed in]),
  337. [
  338. case "$withval" in
  339. yes|no) ;;
  340. *) if test -d "$withval/include"; then
  341. CPPFLAGS="$CPPFLAGS -I$withval/include"
  342. fi
  343. if test -d "$withval/lib"; then
  344. LDFLAGS="$LDFLAGS -L$withval/lib"
  345. elif test -d "$withval/lib64"; then
  346. LDFLAGS="$LDFLAGS -L$withval/lib64"
  347. fi
  348. with_massivethreads=yes
  349. ;;
  350. esac
  351. ], [ with_massivethreads=yes ])
  352. if test "x$with_massivethreads" = "xyes"; then
  353. AC_CHECK_LIB(myth, myth_is_myth_worker,
  354. [], [
  355. AC_CHECK_LIB(myth, myth_create,
  356. [ AC_MSG_ERROR([the massivethreads library is old. check out the latest one.]) ],
  357. [ AC_MSG_ERROR([the massivethreads library is not found]) ])
  358. ])
  359. else
  360. RUNTIME_DEFS="$RUNTIME_DEFS -DWITHOUT_MASSIVETHREADS"
  361. fi
  362. # -------- Check for required libraries --------
  363. AC_CHECK_LIB(gmp, __gmpz_init,
  364. [], [ AC_MSG_ERROR([GMP library is not found]) ])
  365. AC_CHECK_LIB(m, sqrt)
  366. AC_CHECK_LIB(socket, socket)
  367. AC_CHECK_LIB(dl, dlopen)
  368. AC_CHECK_LIB(rt, clock_gettime)
  369. dnl ## cygwin has dlopen in libcygwin.dll.
  370. dnl if test "x$ac_cv_lib_dl_dlopen" = "xno"; then
  371. dnl case "$target_os" in
  372. dnl *cygwin*)
  373. dnl AC_SEARCH_LIBS(dlopen, [dl],
  374. dnl [ ac_cv_lib_dl_dlopen=yes; echo "#define HAVE_LIBDL 1" >> confdefs.h ])
  375. dnl ;;
  376. dnl *)
  377. dnl ;;
  378. dnl esac
  379. dnl fi
  380. # -------- Check for linker --------
  381. # ToDo: check for method for dynamic linking.
  382. AC_LANG_PUSH(C++)
  383. AC_MSG_CHECKING([whether C++ linker works])
  384. AC_LINK_IFELSE(
  385. [ AC_LANG_CALL([], [__gmpz_init]) ],
  386. [ AC_MSG_RESULT(yes) ],
  387. [ AC_MSG_RESULT(no)
  388. AC_MSG_ERROR([failed to link libraries by $CXX.]) ])
  389. AC_LANG_POP(C++)
  390. # -------- Check for C header files --------
  391. AC_DEFUN([REQUIRED_HEADER], [
  392. AC_CHECK_HEADER($1, [], [
  393. AC_MSG_ERROR([required header file <$1> is not found.])
  394. ])])
  395. # C99 headers
  396. REQUIRED_HEADER(assert.h)
  397. REQUIRED_HEADER(ctype.h)
  398. REQUIRED_HEADER(dirent.h)
  399. REQUIRED_HEADER(errno.h)
  400. REQUIRED_HEADER(inttypes.h)
  401. REQUIRED_HEADER(limits.h)
  402. REQUIRED_HEADER(math.h)
  403. REQUIRED_HEADER(setjmp.h)
  404. REQUIRED_HEADER(stdarg.h)
  405. REQUIRED_HEADER(stddef.h)
  406. REQUIRED_HEADER(stdint.h)
  407. REQUIRED_HEADER(stdio.h)
  408. REQUIRED_HEADER(stdlib.h)
  409. REQUIRED_HEADER(string.h)
  410. REQUIRED_HEADER(time.h)
  411. # POSIX headers
  412. REQUIRED_HEADER(fcntl.h)
  413. REQUIRED_HEADER(fenv.h)
  414. REQUIRED_HEADER(dlfcn.h)
  415. REQUIRED_HEADER(poll.h)
  416. REQUIRED_HEADER(signal.h)
  417. REQUIRED_HEADER(sys/mman.h)
  418. REQUIRED_HEADER(sys/resource.h)
  419. REQUIRED_HEADER(sys/time.h)
  420. REQUIRED_HEADER(sys/times.h)
  421. REQUIRED_HEADER(sys/stat.h)
  422. REQUIRED_HEADER(sys/socket.h)
  423. REQUIRED_HEADER(unistd.h)
  424. REQUIRED_HEADER(utime.h)
  425. if test "x$with_pthread" = "xyes"; then
  426. REQUIRED_HEADER(pthread.h)
  427. fi
  428. # others
  429. REQUIRED_HEADER(gmp.h)
  430. case "$target_os" in
  431. *mingw*)
  432. REQUIRED_HEADER(windows.h)
  433. ;;
  434. esac
  435. AC_CHECK_HEADERS(libunwind.h)
  436. AC_CHECK_FUNCS(unw_getcontext)
  437. # -------- check for C functions --------
  438. dnl AC_FUNC_FORK
  439. dnl AC_FUNC_MALLOC
  440. dnl AC_FUNC_REALLOC
  441. AC_CHECK_FUNCS([ \
  442. ceilf \
  443. clock_gettime \
  444. copysign \
  445. copysignf \
  446. dlopen \
  447. fegetround \
  448. fesetround \
  449. finite \
  450. floorf \
  451. fpclass \
  452. frexpf \
  453. getrusage \
  454. gettimeofday \
  455. ldexpf \
  456. mkstemp \
  457. mmap \
  458. modf \
  459. modff \
  460. nextafter \
  461. nextafterf \
  462. poll \
  463. readlink \
  464. roundf \
  465. select \
  466. sleep \
  467. socket \
  468. strptime \
  469. times \
  470. utime \
  471. utimes \
  472. ])
  473. AC_CHECK_DECLS([CLOCK_MONOTONIC],,,[#include <time.h>])
  474. AC_CHECK_DECLS([fpclassify, isinf, isnan, isnormal, signbit],,,
  475. [#include <math.h>])
  476. # FreeBSD does not define fegetround/fesetround as library functions,
  477. # but as inline functions in fenv.h.
  478. if test "x$ac_cv_func_fegetround" = "xno"; then
  479. AC_CHECK_DECLS([fegetround],,,[#include <fenv.h>])
  480. fi
  481. if test "x$ac_cv_func_fesetround" = "xno"; then
  482. AC_CHECK_DECLS([fesetround],,,[#include <fenv.h>])
  483. fi
  484. AC_CHECK_TYPES([max_align_t])
  485. # -------- check for C/POSIX features that the compiler implies --------
  486. AC_DEFUN([REQUIRED_TYPE], [
  487. AC_CHECK_SIZEOF($1, [], [
  488. AC_INCLUDES_DEFAULT
  489. $3
  490. ])
  491. if test "$[]AS_TR_SH([ac_cv_sizeof_$1])" -eq 0; then
  492. AC_MSG_ERROR([required type $1 is not found.])
  493. fi
  494. flag=
  495. for i in $2; do
  496. if test "[$]AS_TR_SH([ac_cv_sizeof_$1])" -eq [$]i; then
  497. flag="AS_TR_CPP($1)=[$]i"
  498. METAFLAGS="$METAFLAGS [$]flag"
  499. fi
  500. done
  501. if test -z "$[]flag"; then
  502. AC_MSG_ERROR([unsupported size of $1])
  503. fi
  504. AS_TR_SH([SIZEOF_$1])=[$]AS_TR_SH([ac_cv_sizeof_$1])
  505. AS_TR_SH([BITSOF_$1])=`expr "$[]AS_TR_SH([SIZEOF_$1])" '*' 8`
  506. AC_SUBST(AS_TR_SH([SIZEOF_$1]))
  507. AC_SUBST(AS_TR_SH([BITSOF_$1]))
  508. ])
  509. REQUIRED_TYPE(int, 4)
  510. REQUIRED_TYPE(float, 4)
  511. REQUIRED_TYPE(double, 8)
  512. REQUIRED_TYPE(long, 4 8)
  513. REQUIRED_TYPE(long long, 4 8)
  514. REQUIRED_TYPE(size_t, 4 8)
  515. # -------- Finale --------
  516. AC_CONFIG_FILES([
  517. Makefile
  518. config.mk
  519. src/config.mk
  520. ])
  521. AC_CONFIG_FILES([stamp-h], [AS_ECHO(timestamp) > stamp-h])
  522. AC_OUTPUT
  523. if test "x$no_create" != "xyes" && test "x$srcdir" != "x."; then
  524. (cd "$srcdir" && $FIND precompiled src tests -type d) | while read i; do
  525. AS_ECHO("creating directory $i")
  526. AS_MKDIR_P("$i")
  527. done
  528. for i in src/builtin.smi; do
  529. AS_ECHO("copying file $i")
  530. cp $srcdir/$i $i
  531. done
  532. fi