Remote GHCi: create cost centre stacks in batches
[ghc.git] / libraries / integer-gmp / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT([Haskell integer (GMP)], [1.0], [libraries@haskell.org], [integer])
3
4 # Safety check: Ensure that we are in the correct source directory.
5 AC_CONFIG_SRCDIR([cbits/wrappers.c])
6
7 AC_CANONICAL_TARGET
8
9 AC_PROG_CC
10 dnl make extensions visible to allow feature-tests to detect them lateron
11 AC_USE_SYSTEM_EXTENSIONS
12
13
14 dnl--------------------------------------------------------------------
15 dnl * Deal with arguments telling us gmp is somewhere odd
16 dnl--------------------------------------------------------------------
17
18 AC_ARG_WITH([gmp-includes],
19   [AC_HELP_STRING([--with-gmp-includes],
20     [directory containing gmp.h])],
21     [GMP_INCLUDE_DIRS=$withval; CPPFLAGS="-I$withval"],
22     [GMP_INCLUDE_DIRS=])
23
24 AC_ARG_WITH([gmp-libraries],
25   [AC_HELP_STRING([--with-gmp-libraries],
26     [directory containing gmp library])],
27     [GMP_LIB_DIRS=$withval; LDFLAGS="-L$withval"],
28     [GMP_LIB_DIRS=])
29
30 AC_ARG_WITH([gmp-framework-preferred],
31   [AC_HELP_STRING([--with-gmp-framework-preferred],
32     [on OSX, prefer the GMP framework to the gmp lib])],
33     [GMP_PREFER_FRAMEWORK=YES],
34     [GMP_PREFER_FRAMEWORK=NO])
35
36 AC_ARG_WITH([intree-gmp],
37   [AC_HELP_STRING([--with-intree-gmp],
38     [force using the in-tree GMP])],
39     [GMP_FORCE_INTREE=YES],
40     [GMP_FORCE_INTREE=NO])
41
42 dnl--------------------------------------------------------------------
43 dnl * Detect gmp
44 dnl--------------------------------------------------------------------
45
46 HaveLibGmp=NO
47 GMP_LIBS=
48 HaveFrameworkGMP=NO
49 GMP_FRAMEWORK=
50 HaveSecurePowm=0
51
52 if test "$GMP_FORCE_INTREE" != "YES"
53 then
54     if test "$GMP_PREFER_FRAMEWORK" = "YES"
55     then
56         LOOK_FOR_GMP_FRAMEWORK
57         LOOK_FOR_GMP_LIB
58     else
59         LOOK_FOR_GMP_LIB
60         LOOK_FOR_GMP_FRAMEWORK
61     fi
62 fi
63
64 AC_MSG_CHECKING([whether to use in-tree GMP])
65 if test "$HaveFrameworkGMP" = "YES" || test "$HaveLibGmp" = "YES"
66 then
67     AC_MSG_RESULT([no])
68     UseIntreeGmp=0
69     AC_CHECK_HEADER([gmp.h], , [AC_MSG_ERROR([Cannot find gmp.h])])
70
71     AC_MSG_CHECKING([GMP version])
72     AC_COMPUTE_INT(GhcGmpVerMj, __GNU_MP_VERSION, [#include <gmp.h>],
73         AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION]))
74     AC_COMPUTE_INT(GhcGmpVerMi, __GNU_MP_VERSION_MINOR, [#include <gmp.h>],
75         AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION_MINOR]))
76     AC_COMPUTE_INT(GhcGmpVerPl, __GNU_MP_VERSION_PATCHLEVEL, [#include <gmp.h>],
77         AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION_PATCHLEVEL]))
78     AC_MSG_RESULT([$GhcGmpVerMj.$GhcGmpVerMi.$GhcGmpVerPl])
79
80 else
81     AC_MSG_RESULT([yes])
82     UseIntreeGmp=1
83     HaveSecurePowm=1
84
85     AC_MSG_CHECKING([GMP version])
86     GhcGmpVerMj=5
87     GhcGmpVerMi=0
88     GhcGmpVerPl=4
89     AC_MSG_RESULT([$GhcGmpVerMj.$GhcGmpVerMi.$GhcGmpVerPl])
90 fi
91
92
93 dnl--------------------------------------------------------------------
94 dnl * Make sure we got some form of gmp
95 dnl--------------------------------------------------------------------
96
97 AC_SUBST(GMP_INCLUDE_DIRS)
98 AC_SUBST(GMP_LIBS)
99 AC_SUBST(GMP_LIB_DIRS)
100 AC_SUBST(GMP_FRAMEWORK)
101 AC_SUBST(HaveLibGmp)
102 AC_SUBST(HaveFrameworkGMP)
103 AC_SUBST(HaveSecurePowm)
104 AC_SUBST(UseIntreeGmp)
105 AC_SUBST(GhcGmpVerMj)
106 AC_SUBST(GhcGmpVerMi)
107 AC_SUBST(GhcGmpVerPl)
108
109 AC_CONFIG_FILES([integer-gmp.buildinfo gmp/config.mk include/HsIntegerGmp.h])
110
111 dnl--------------------------------------------------------------------
112 dnl * Generate output files
113 dnl--------------------------------------------------------------------
114
115 AC_OUTPUT