Fix build when gmp isn't installed
[packages/integer-gmp.git] / configure.ac
1 AC_INIT([Haskell integer (GMP)], [0.1], [libraries@haskell.org], [integer])
2
3 # Safety check: Ensure that we are in the correct source directory.
4 AC_CONFIG_SRCDIR([cbits/gmp-wrappers.cmm])
5
6 AC_CANONICAL_TARGET
7
8 AC_ARG_WITH([cc],
9             [C compiler],
10             [CC=$withval])
11 AC_PROG_CC()
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
51 if test "$GMP_FORCE_INTREE" != "YES"
52 then
53     if test "$GMP_PREFER_FRAMEWORK" = "YES"
54     then
55         LOOK_FOR_GMP_FRAMEWORK
56         LOOK_FOR_GMP_LIB
57     else
58         LOOK_FOR_GMP_LIB
59         LOOK_FOR_GMP_FRAMEWORK
60     fi
61 fi
62 if test "$HaveFrameworkGMP" = "YES" || test "$HaveLibGmp" = "YES"
63 then
64     AC_CHECK_HEADER([gmp.h], , [AC_MSG_ERROR([Cannot find gmp.h])])
65 fi
66
67 dnl--------------------------------------------------------------------
68 dnl * Make sure we got some form of gmp
69 dnl--------------------------------------------------------------------
70
71 AC_SUBST(GMP_INCLUDE_DIRS)
72 AC_SUBST(GMP_LIBS)
73 AC_SUBST(GMP_LIB_DIRS)
74 AC_SUBST(GMP_FRAMEWORK)
75 AC_SUBST(HaveLibGmp)
76 AC_SUBST(HaveFrameworkGMP)
77
78 AC_CONFIG_FILES([integer-gmp.buildinfo gmp/config.mk])
79
80 dnl--------------------------------------------------------------------
81 dnl * Generate the header cbits/GmpDerivedConstants.h
82 dnl--------------------------------------------------------------------
83
84 AC_OUTPUT