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