poset: Add fixity declarations.
[altfloat.git] / configure.ac
blob7230a972737bbb541a69cbf9f9ce6019a5d17322
1 dnl Copyright (C) 2009-2010 Nick Bowler
2 dnl Copying and distribution of this file, with or without modification,
3 dnl are permitted in any medium without royalty provided the copyright
4 dnl notice and this notice are preserved.  This file is offered as-is,
5 dnl without any warranty.
7 AC_PREREQ(2.62)
8 AC_INIT([altfloat],[0.3],[nbowler@draconx.ca])
9 AC_CONFIG_SRCDIR([altfloat.cabal])
10 AC_CONFIG_HEADER([config.h])
12 dnl We don't actually care, but this shuts up the warning.
13 AC_ARG_WITH([compiler], [AS_HELP_STRING([--with-compiler],
14         [specify which Haskell compiler to use])])
16 AC_PROG_CC_C99
18 dnl Cabal won't let us specify the C compiler, so we need this hack.
19 CC_OPTS=`echo $CC | sed 's/@<:@^@<:@:space:@:>@@:>@*//'`
20 AC_SUBST([CC_OPTS])
22 dnl We need to know the size and alignment of fenv_t in order to allocate it
23 dnl in Haskell code.
24 m4_define([FENV_HEADERS], [dnl
25 #include <fenv.h>
28 AC_CHECK_SIZEOF([fenv_t], [], [FENV_HEADERS])
29 AC_CHECK_ALIGNOF([fenv_t], [FENV_HEADERS])
31 dnl Determine characteristics of floating point types.  We assume that GHC
32 dnl and the C compiler agree.
33 AC_DEFUN([CHECK_FLOAT], [dnl
34         AC_MSG_CHECKING([$1])
35         AC_CACHE_VAL([altfloat_cv_$2], [AC_COMPUTE_INT(
36                 [altfloat_cv_$2], [$2], [#include <float.h>])])
37         AC_MSG_RESULT([$altfloat_cv_$2]ifelse([$3], [], [], [ $3]))
38         AC_DEFINE_UNQUOTED([$2][_VAL], [$altfloat_cv_$2],
39                 [Define to the value of $2])])
41 CHECK_FLOAT([floating point radix], [FLT_RADIX])
42 CHECK_FLOAT([precision of double], [DBL_MANT_DIG], [digits])
43 CHECK_FLOAT([precision of float],  [FLT_MANT_DIG], [digits])
45 CHECK_FLOAT([minimum normal exponent for double], [DBL_MIN_EXP])
46 CHECK_FLOAT([maximum finite exponent for double], [DBL_MAX_EXP])
47 CHECK_FLOAT([minimum normal exponent for float],  [FLT_MIN_EXP])
48 CHECK_FLOAT([maximum finite exponent for float],  [FLT_MAX_EXP])
50 dnl Check for some C library functions.
51 m4_define([C99_FLOAT_FUNCS], [dnl
52         [acosf], [asinf], [atanf], [atan2f], [cosf], [sinf], [tanf], [acoshf],
53         [asinhf], [atanhf], [coshf], [sinhf], [tanhf], [expf], [exp2f],
54         [expm1f], [frexpf], [ilogbf], [ldexpf], [logf], [log10f], [log1pf],
55         [log2f], [logbf], [modff], [scalbnf], [scalblnf], [cbrtf], [fabsf],
56         [hypotf], [powf], [sqrtf], [fmodf], [remainderf], [remquof],
57         [copysignf], [nanf], [erff], [erfcf], [lgammaf], [tgammaf], [ceilf],
58         [floorf], [nearbyintf], [rintf], [lrintf], [llrintf], [roundf],
59         [lroundf], [llroundf], [truncf], [fdimf], [fmaxf], [fminf], [fmaf]])
61 replaced_libm=no
62 AC_DEFUN([CHECK_LIBM], [AC_SEARCH_LIBS([$1], [m], [], [dnl
63         replaced_libm=yes
64         AC_DEFINE([NEED_LIBM_]m4_toupper([$1]), [1],
65                 [Define to 1 if you do not have a working $1 function.])])])
66 CHECK_LIBM([nan])
67 CHECK_LIBM([log2])
68 CHECK_LIBM([exp2])
69 CHECK_LIBM([fma])
70 CHECK_LIBM([remquo])
72 m4_foreach([func], [C99_FLOAT_FUNCS], [CHECK_LIBM(m4_strip(func))])
74 AC_CONFIG_FILES([
75         altfloat.buildinfo
77 AC_OUTPUT
79 if test x"$replaced_libm" = x"yes"; then
80 echo
81 AC_MSG_WARN([
82 Your C library appears to not provide all C99 math functions.
83 Replacements will be built, but note that they may raise spurious
84 exceptions or their accuracy may deviate from applicable standards.])