Don't put "extra-libraries: gmp" in the cabal file; it comes from the buildinfo file
[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/mkGmpDerivedConstants.c])
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
31 dnl--------------------------------------------------------------------
32 dnl * Check whether this machine has gmp/gmp3 installed
33 dnl--------------------------------------------------------------------
34
35 AC_CHECK_LIB([gmp],  [__gmpz_fdiv_qr],
36              [HAVE_GMP=YES; GMP_LIBS=gmp],
37              [HAVE_GMP=NO;  GMP_LIBS=])
38 if test "$HAVE_GMP" = "NO"; then
39 AC_CHECK_LIB([gmp3], [__gmpz_fdiv_qr],
40              [HAVE_GMP=YES; GMP_LIBS=gmp3],
41              [HAVE_GMP=NO;  GMP_LIBS=])
42 fi
43
44 dnl--------------------------------------------------------------------
45 dnl * Mac OS X only: check for GMP.framework
46 dnl--------------------------------------------------------------------
47
48 case $target_os in
49   darwin*)
50     AC_MSG_CHECKING([for GMP.framework])
51     save_libs="$LIBS"
52     LIBS="-framework GMP"
53     AC_TRY_LINK_FUNC(__gmpz_fdiv_qr,
54       [HAVE_GMP_FRAMEWORK=yes; GMP_FRAMEWORK=GMP; GMP_LIBS=; HAVE_GMP=YES],
55       [HAVE_GMP_FRAMEWORK=no])
56     LIBS="$save_libs"
57     AC_MSG_RESULT([$HAVE_GMP_FRAMEWORK])
58     ;;
59 esac
60
61 dnl--------------------------------------------------------------------
62 dnl * Make sure we got some form of gmp
63 dnl--------------------------------------------------------------------
64
65 if test "$HAVE_GMP" = "NO"; then
66   AC_MSG_ERROR([cannot find the gmp library on the system.]
67     [If you have gmp installed in a non-standard location re-run ./configure]
68     [and specify the flags --with-gmp-includes= and/or --with-gmp-libraries=])
69 fi
70
71
72 AC_SUBST(GMP_INCLUDE_DIRS)
73 AC_SUBST(GMP_LIBS)
74 AC_SUBST(GMP_LIB_DIRS)
75 AC_SUBST(GMP_FRAMEWORK)
76
77 AC_CONFIG_FILES([integer.buildinfo])
78
79 dnl--------------------------------------------------------------------
80 dnl * Generate the header cbits/GmpDerivedConstants.h
81 dnl--------------------------------------------------------------------
82
83 AC_MSG_NOTICE([generating GmpDerivedConstants.h])
84 ${CC} $CFLAGS cbits/mkGmpDerivedConstants.c -o cbits/mkGmpDerivedConstants
85 cbits/mkGmpDerivedConstants > cbits/GmpDerivedConstants.h
86 rm cbits/mkGmpDerivedConstants
87
88 AC_OUTPUT