Merge with master
[barvinok.git] / configure.in
blob77ad01b3ddae9cf2611cf4b55bc179f83523615b
1 AC_INIT
2 AM_INIT_AUTOMAKE(barvinok, 0.15)
3 AC_PROG_CXX
4 AC_SUBST(versioninfo)
5 versioninfo=8:0:4
7 AC_CANONICAL_HOST
8 AC_LIBTOOL_WIN32_DLL
9 AC_SUBST(BV_LDFLAGS)
10 case $host in
11         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
12         if test "$enable_shared" = yes; then
13                 BV_LDFLAGS="-no-undefined" 
14         fi
15         ;;
16 esac
18 AC_PROG_LIBTOOL
20 AC_CHECK_HEADERS(getopt.h)
21 AC_CHECK_HEADERS(sys/times.h)
23 dnl Check for GMP library
24 AC_MSG_CHECKING(whether to use GMP)
25 AC_ARG_WITH(libgmp, 
26         [  --with-libgmp           DIR Location of the GMP Distribution], 
27         gmp_package=$withval, gmp_package=yes)
28 if test "x$gmp_package" = "xno"; then
29         AC_MSG_RESULT(no)
30         AC_MSG_ERROR(Need gmp)
31 else
32         AC_MSG_RESULT(yes)
33         if test "x$gmp_package" != "xyes"; then
34             GMP_DIR=$gmp_package
35             if test ! -d "$GMP_DIR"; then
36                 AC_ERROR(Directory given for GMP Distribution is not a directory)
37             fi
38             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
39             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
40         fi
41         poly_cv_gmpfatal="no"
42         AC_CHECK_HEADER(gmp.h,
43                 [AC_CHECK_LIB(gmp,main,
44                     [],
45                     [poly_cv_gmpfatal="yes"])],
46                 [poly_cv_gmpfatal="yes"])
47         if test "$poly_cv_gmpfatal" = "yes"; then
48                 AC_MSG_ERROR([GMP not found])
49         fi
51 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
53 AC_ARG_WITH(polylib,
54             [  --with-polylib=DIR      DIR Location of PolyLib],
55             [ echo "Package polylib : $withval" && polylib_package=$withval],  
56             [ polylib_package=yes ])
58 if test "$polylib_package" = "no"; then
59     AC_MSG_ERROR(Need polylib)
62 if test "$polylib_package" != "yes"; then
63     CPPFLAGS="-I$polylib_package/include $CPPFLAGS"
64     LDFLAGS="-L$polylib_package/lib $LDFLAGS"
65     LD_LIBRARY_PATH="$polylib_package/lib:$LD_LIBRARY_PATH"
66     export LD_LIBRARY_PATH
69 AC_CHECK_LIB(polylibgmp, PolyhedronTSort,[],[
70     AC_MSG_ERROR(Need polylib)
72 AC_REPLACE_FUNCS(Enumeration_Free reduce_evalue)
73 AC_TRY_RUN([
74 #include <polylib/polylibgmp.h>
76 int main()
78     int i, j;
79     Polyhedron *P;
80     Matrix *M = Matrix_Alloc(6,5);
81     for (i = 0; i < 6; ++i) {
82         value_set_si(M->p[i][0], 1);
83         for (j = 1; j < 4; ++j)
84             value_set_si(M->p[i][j], (j-1 == i/2) * (1-2*(i%2)));
85         value_set_si(M->p[i][4], i%2);
86     }
87     P = Constraints2Polyhedron(M, 6);
88     return !(P->NbRays == 8);
91 [AC_DEFINE(HAVE_GROWING_CHERNIKOVA,[],
92           [PolyLib automatically grows the Chernikova table space])],
93 AC_MSG_WARN([This version of PolyLib does not automatically])
94 AC_MSG_WARN([enlarge the Chernikova table space]),
95 AC_MSG_WARN([Unable to determine whether PolyLib automatically])
96 AC_MSG_WARN([grows the Chernikova table space]))
98 AC_TRY_RUN([
99 #include <polylib/polylibgmp.h>
101 int main()
103     enode *en = new_enode(polynomial, 1, 1);
104     return !(en->arr[0].x.p == NULL);
107 AC_MSG_WARN([This version of polylib leaks]),[true])
109 AC_TRY_RUN([
110 #include <stdio.h>
111 #include <polylib/polylibgmp.h>
113 int main()
115     Matrix *M;
116     Polyhedron *P, *C;
117     Param_Polyhedron *PP;
118     int i;
119     Param_Vertices *V;
121     freopen("$srcdir/tests/ehrhart/t12.in", "r", stdin);
122     M = Matrix_Read();
123     P = Constraints2Polyhedron(M, 1024);
124     M = Matrix_Read();
125     C = Constraints2Polyhedron(M, 1024);
126     PP = Polyhedron2Param_SimplifiedDomain(&P, C, 1024, NULL, NULL);
127     for (i = 0, V = PP->V; V; ++i, V = V->next)
128         ;
129     return !(i == 10);
132 [AC_DEFINE(HAVE_CORRECT_VERTICES,[],
133           [PolyLib computes correct vertices])],
134 AC_MSG_WARN([This version of polylib produces incorrect vertices.]),
135 AC_MSG_WARN([Unable to determine whether PolyLib computes correct vertices]))
137 AC_MSG_CHECKING([number of arguments of Polyhedron_Enumerate])
138 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
139                [Polyhedron_Enumerate(NULL,NULL,0,NULL)],
140                [AC_MSG_RESULT(4)
141                 AC_DEFINE(HAVE_ENUMERATE4,[],
142                           [Polyhedron_Enumerate takes four arguments])],
143                [AC_MSG_RESULT(3)])
145 AC_MSG_CHECKING([number of arguments of count_points])
146 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
147                [count_points(0,NULL,NULL,NULL)],
148                [AC_MSG_RESULT(4)
149                 AC_DEFINE(HAVE_COUNT_POINTS4,[],
150                           [count_points takes four arguments])],
151                [AC_MSG_RESULT(3)])
153 AC_ARG_WITH(piplib,
154             [  --with-piplib=DIR       DIR Location of PolyLib],
155             [ echo "Package piplib : $withval" && piplib_package=$withval],  
156             [ piplib_package=yes ])
158 AC_SUBST(bv_extra_programs)
159 if test "$piplib_package" != "no"; then
160     if test "$piplib_package" != "yes"; then
161         CPPFLAGS="-I$piplib_package/include $CPPFLAGS"
162         LDFLAGS="-L$piplib_package/lib $LDFLAGS"
163     fi
165     AC_CHECK_LIB(piplibMP, pip_solve,[
166         AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
167         LIBS="-lpiplibMP $LIBS"
168         AC_LIBOBJ(piputil)
169         bv_extra_programs="piptest $bv_extra_programs"
170     ],[
171         AC_MSG_WARN([Piplib not found])
172     ])
176 AC_MSG_CHECKING(if --enable-fractional option specified)
177 AC_ARG_ENABLE(fractional,
178             [  --enable-fractional     Use fractional representation],
179             [bv_cv_fractional=$enableval], [bv_cv_fractional="no"])
180 AC_MSG_RESULT($bv_cv_fractional)
181 AC_MSG_CHECKING(if --enable-modulo option specified)
182 AC_ARG_ENABLE(modulo,
183             [  --enable-modulo         Use fractional representation],
184             [bv_cv_modulo=$enableval], [bv_cv_modulo="no"])
185 AC_MSG_RESULT($bv_cv_modulo)
186 if test "x$bv_cv_modulo" != "xno" -o "x$bv_cv_fractional" != "xno"; then
187         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
190 AC_MSG_CHECKING(whether to use incremental algorithm)
191 AC_ARG_ENABLE(incremental,
192             [  --enable-incremental    Enable incremental algorithm],
193             [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
194 AC_MSG_RESULT($bv_cv_incremental)
195 if test "x$bv_cv_incremental" = "xyes"; then
196         AC_DEFINE(USE_INCREMENTAL,[], [Use incremental algorithm])
199 AC_ARG_WITH(ntl,
200             [  --with-ntl=DIR          DIR Location of NTL],
201             [ echo "Package ntl : $withval" && ntl_package=$withval],  
202             [ ntl_package=yes ])
204 if test "$ntl_package" = "no"; then
205     AC_MSG_ERROR(Need ntl)
208 AC_EGREP_CPP(yes, [
209     #include <NTL/ZZ.h>
210     #ifdef NTL_GMP_LIP
211     yes
212     #endif
213     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
215 if test "$ntl_package" != "yes"; then
216     CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
217     LDFLAGS="-L$ntl_package/lib $LDFLAGS"
220 AC_CHECK_LIB(ntl, main,[],[
221     AC_MSG_ERROR(Need ntl)
224 AC_CONFIG_HEADERS(config.h)
225 AC_OUTPUT(Makefile)