dpoly: add some documentation
[barvinok.git] / configure.in
blobf6918cdf0838a95cfc04282dfdc7df3571cc4939
1 AC_INIT
2 AM_INIT_AUTOMAKE(barvinok, 0.22)
3 AC_PROG_CC
4 gl_EARLY
6 AC_PROG_CXX
7 AM_PROG_LEX
8 AC_PROG_YACC
9 AC_SUBST(versioninfo)
10 versioninfo=12:0:0
12 AC_CANONICAL_HOST
13 AC_LIBTOOL_WIN32_DLL
14 AC_SUBST(BV_LDFLAGS)
15 case $host in
16         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
17         if test "$enable_shared" = yes; then
18                 BV_LDFLAGS="-no-undefined" 
19         fi
20         ;;
21 esac
23 AC_DISABLE_SHARED
24 AC_PROG_LIBTOOL
26 gl_MODULES(argp progname)
27 gl_INIT
29 AC_CHECK_HEADERS(getopt.h)
30 AC_CHECK_HEADERS(sys/times.h)
32 dnl Check for GMP library
33 AC_MSG_CHECKING(whether to use GMP)
34 AC_ARG_WITH(libgmp, 
35         [  --with-libgmp           DIR Location of the GMP Distribution], 
36         gmp_package=$withval, gmp_package=yes)
37 if test "x$gmp_package" = "xno"; then
38         AC_MSG_RESULT(no)
39         AC_MSG_ERROR(Need gmp)
40 else
41         AC_MSG_RESULT(yes)
42         if test "x$gmp_package" != "xyes"; then
43             GMP_DIR=$gmp_package
44             if test ! -d "$GMP_DIR"; then
45                 AC_ERROR(Directory given for GMP Distribution is not a directory)
46             fi
47             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
48             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
49         fi
50         poly_cv_gmpfatal="no"
51         AC_CHECK_HEADER(gmp.h,
52                 [AC_CHECK_LIB(gmp,main,
53                     [],
54                     [poly_cv_gmpfatal="yes"])],
55                 [poly_cv_gmpfatal="yes"])
56         if test "$poly_cv_gmpfatal" = "yes"; then
57                 AC_MSG_ERROR([GMP not found])
58         fi
60 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
62 AC_ARG_WITH(polylib,
63             [  --with-polylib=DIR      DIR Location of PolyLib],
64             [ echo "Package polylib : $withval" && polylib_package=$withval],  
65             [ polylib_package=yes ])
67 if test "$polylib_package" = "no"; then
68     AC_MSG_ERROR(Need polylib)
71 if test "$polylib_package" != "yes"; then
72     CPPFLAGS="-I$polylib_package/include $CPPFLAGS"
73     LDFLAGS="-L$polylib_package/lib $LDFLAGS"
74     LD_LIBRARY_PATH="$polylib_package/lib:$LD_LIBRARY_PATH"
75     export LD_LIBRARY_PATH
78 AC_CHECK_LIB(polylibgmp, PolyhedronTSort,[],[
79     AC_MSG_ERROR(Need polylib)
81 AC_CHECK_FUNCS(Enumeration_Free)
82 AC_CHECK_FUNCS(compress_parms, [AC_LIBOBJ(remove_equalities)])
83 AC_SUBST(bv_extra_programs)
84 AC_CHECK_FUNCS(LexSmaller,[
85         bv_extra_programs="verify_lexsmaller $bv_extra_programs"
86     ])
87 AC_REPLACE_FUNCS(DomainConstraintSimplify)
88 AC_TRY_RUN([
89 #include <polylib/polylibgmp.h>
91 int main()
93     int i, j;
94     Polyhedron *P;
95     Matrix *M = Matrix_Alloc(6,5);
96     for (i = 0; i < 6; ++i) {
97         value_set_si(M->p[i][0], 1);
98         for (j = 1; j < 4; ++j)
99             value_set_si(M->p[i][j], (j-1 == i/2) * (1-2*(i%2)));
100         value_set_si(M->p[i][4], i%2);
101     }
102     P = Constraints2Polyhedron(M, 6);
103     return !(P->NbRays == 8);
106 [AC_DEFINE(HAVE_GROWING_CHERNIKOVA,[],
107           [PolyLib automatically grows the Chernikova table space])],
108 AC_MSG_WARN([This version of PolyLib does not automatically])
109 AC_MSG_WARN([enlarge the Chernikova table space]),
110 AC_MSG_WARN([Unable to determine whether PolyLib automatically])
111 AC_MSG_WARN([grows the Chernikova table space]))
113 AC_TRY_RUN([
114 #include <polylib/polylibgmp.h>
116 int main()
118     enode *en = new_enode(polynomial, 1, 1);
119     return !(en->arr[0].x.p == NULL);
122 AC_MSG_WARN([This version of polylib leaks]),[true])
124 AC_TRY_RUN([
125 #include <stdio.h>
126 #include <polylib/polylibgmp.h>
128 int main()
130     Matrix *M;
131     Polyhedron *P, *C;
132     Param_Polyhedron *PP;
133     int i;
134     Param_Vertices *V;
136     freopen("$srcdir/tests/ehrhart/t12.in", "r", stdin);
137     M = Matrix_Read();
138     P = Constraints2Polyhedron(M, 1024);
139     M = Matrix_Read();
140     C = Constraints2Polyhedron(M, 1024);
141     PP = Polyhedron2Param_Domain(P, C, 1024);
142     for (i = 0, V = PP->V; V; ++i, V = V->next)
143         ;
144     return !(i == 10);
147 [AC_DEFINE(HAVE_CORRECT_VERTICES,[],
148           [PolyLib computes correct vertices])],
149 AC_MSG_WARN([This version of polylib produces incorrect vertices.]),
150 AC_MSG_WARN([Unable to determine whether PolyLib computes correct vertices]))
152 AC_MSG_CHECKING([number of arguments of Polyhedron_Enumerate])
153 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
154                [Polyhedron_Enumerate(NULL,NULL,0,NULL)],
155                [AC_MSG_RESULT(4)
156                 AC_DEFINE(HAVE_ENUMERATE4,[],
157                           [Polyhedron_Enumerate takes four arguments])],
158                [AC_MSG_RESULT(3)])
160 AC_MSG_CHECKING([number of arguments of count_points])
161 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
162                [count_points(0,NULL,NULL,NULL)],
163                [AC_MSG_RESULT(4)
164                 AC_DEFINE(HAVE_COUNT_POINTS4,[],
165                           [count_points takes four arguments])],
166                [AC_MSG_RESULT(3)])
168 AC_ARG_WITH(piplib,
169             [  --with-piplib=DIR       DIR Location of PIP],
170             [ echo "Package piplib : $withval" && piplib_package=$withval],  
171             [ piplib_package=yes ])
173 have_piplib=false
174 if test "$piplib_package" != "no"; then
175     SAVE_CPPFLAGS="$CPPFLAGS"
176     SAVE_LDFLAGS="$LDFLAGS"
177     if test "$piplib_package" != "yes"; then
178         CPPFLAGS="-I$piplib_package/include $CPPFLAGS"
179         LDFLAGS="-L$piplib_package/lib $LDFLAGS"
180     fi
182     bv_cv_piplibfatal="no"
183     AC_CHECK_LIB(piplibMP, pip_solve,[
184         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
185             AC_MSG_WARN([Piplib too old; please install version 1.3.6 or newer])
186             bv_cv_piplibfatal="yes"
187         ],[#include <stdio.h>
188            #include <piplib/piplibMP.h>])
189     ],[
190         AC_MSG_WARN([Piplib not found])
191         bv_cv_piplibfatal="yes"
192     ])
193     if test "$bv_cv_piplibfatal" = "no"; then
194         AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
195         LIBS="-lpiplibMP $LIBS"
196         AC_LIBOBJ(piputil)
197         bv_extra_programs="piptest $bv_extra_programs"
198         have_piplib=true
199     else
200         CPPFLAGS="$SAVE_CPPFLAGS"
201         LDFLAGS="$SAVE_LDFLAGS"
202     fi
204 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
206 AC_MSG_CHECKING(if the fractional representation should be used)
207 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
208                                           [Don't use fractional representation])],
209             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
210 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
211                                       [Don't use fractional representation])],
212             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
213 AC_MSG_RESULT($bv_cv_modulo)
214 if test "x$bv_cv_modulo" != "xno" ; then
215         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
218 AC_MSG_CHECKING(whether to use incremental algorithm)
219 AC_ARG_ENABLE(incremental,
220         [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
221                         [Enable incremental algorithm [bf]])],
222         [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
223 AC_MSG_RESULT($bv_cv_incremental)
224 case $bv_cv_incremental in
225         yes | bf)
226                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
227                           [Use breadth-first incremental algorithm])
228         ;;
229         df)
230                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
231                           [Use depth-first incremental algorithm])
232         ;;
233 esac
235 AC_ARG_WITH(ntl,
236             [  --with-ntl=DIR          DIR Location of NTL],
237             [ echo "Package ntl : $withval" && ntl_package=$withval],  
238             [ ntl_package=yes ])
240 if test "$ntl_package" = "no"; then
241     AC_MSG_ERROR(Need ntl)
244 if test "$ntl_package" != "yes"; then
245     CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
246     LDFLAGS="-L$ntl_package/lib $LDFLAGS"
249 AC_EGREP_CPP(yes, [
250     #include <NTL/ZZ.h>
251     #ifdef NTL_GMP_LIP
252     yes
253     #endif
254     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
256 AC_CHECK_LIB(ntl, main,[],[
257     AC_MSG_ERROR(Need ntl)
260 AC_MSG_CHECKING(whether to compile bernstein)
261 AC_ARG_WITH(bernstein,
262             [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
263             [ with_bernstein=$withval],  [ with_bernstein=yes ])
264 AC_MSG_RESULT($with_bernstein)
266 have_ginac=false
267 if test "$with_bernstein" != "no"; then
268         AC_LANG_PUSH(C++)
269         AM_PATH_GINAC(1.3.3, [
270                 have_ginac=true
271                 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])]
272                 PACKAGE_LIBS="-lbarvinok -lbernstein")
273         AC_LANG_POP
275 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
277 AC_MSG_CHECKING(whether to use Omega)
278 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
279             [ omega_package=$withval],  [ omega_package=yes ])
280 AC_MSG_RESULT($omega_package)
282 AC_SUBST(OMEGA_CPPFLAGS)
283 AC_SUBST(OMEGA_LDFLAGS)
284 AC_SUBST(OMEGA_LIBS)
285 AC_SUBST(bv_omega_programs)
286 have_omega=false
287 if test "$omega_package" != "no"; then
288     if test "x$omega_package" != "xyes"; then
289         OMEGA_CPPFLAGS="-I$omega_package/include/omega"
290         OMEGA_LDFLAGS="-L$omega_package/lib"
291     else
292         for i in /usr/include /usr/local/include; do
293             if test -f $i/omega/omega.h; then
294                 OMEGA_CPPFLAGS="-I$i/omega"
295             fi
296         done
297     fi
299     AC_LANG_PUSH(C++)
300     SAVE_CPPFLAGS="$CPPFLAGS"
301     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
302     AC_CHECK_HEADERS([omega.h],[
303         if test x$have_ginac = xtrue; then
304             bv_omega_programs="occ $bv_omega_programs"
305         fi
306         AC_DEFINE(HAVE_OMEGA,[],[use omega])
307         OMEGA_LIBS="-lcode_gen -lomega"
308         have_omega=true
309     ],[AC_MSG_WARN(Omega not found)])
310     CPPFLAGS="$SAVE_CPPFLAGS"
311     AC_LANG_POP
313 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
316 AC_MSG_CHECKING(whether to use cddlib)
317 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
318             [ cddlib_package=$withval],  [ cddlib_package=yes ])
319 AC_MSG_RESULT($cddlib_package)
321 have_cddlib=false
322 if test "$cddlib_package" != "no"; then
323     if test "x$cddlib_package" != "xyes"; then
324         CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
325         LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
326     fi
327     AC_TRY_LINK([
328 #define GMPRATIONAL
329 #include <setoper.h>
330 #include <cddmp.h>
331 ], [
332     mytype a;
333     dd_init(a); ], [
334         have_cddlib=true
335         AC_CHECK_LIB(cddgmp, main,[],[have_cddlib=false])
336     ])
338 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
342 AC_MSG_CHECKING(whether to use GLPK)
343 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
344             [ glpk_package=$withval],  [ glpk_package=yes ])
345 AC_MSG_RESULT($glpk_package)
347 have_glpk=false
348 if test "$glpk_package" != "no"; then
349     if test "x$glpk_package" != "xyes"; then
350         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
351         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
352     fi
353     AC_CHECK_HEADERS([glpk.h],[
354         have_glpk=true
355         AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
356     ])
358 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
360 if test "$have_glpk" = "true" -o "$have_cddlib" = "true"; then
361     AC_LIBOBJ(sample)
362     bv_extra_programs="polyhedron_sample 4coins lexmin $bv_extra_programs"
363     bv_extra_programs="polytope_scan $bv_extra_programs"
366 AC_SUBST(GIT_HEAD_ID)
367 AC_SUBST(GIT_HEAD)
368 AC_SUBST(GIT_HEAD_VERSION)
369 if test -f $srcdir/.git/HEAD; then
370     GIT_HEAD="$srcdir/.git/index"
371     GIT_REPO="$srcdir/.git"
372     GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
373 elif test -f $srcdir/GIT_HEAD_ID; then
374     GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
375 else
376     mysrcdir=`(cd $srcdir; pwd)`
377     head=`basename $mysrcdir | sed -e 's/.*-//'`
378     head2=`echo $head | sed -e 's/[^0-9a-f]//'`
379     head3=`echo $head2 | sed -e 's/........................................//'`
380     base=`basename $mysrcdir | sed -e 's/-.*//'`
381     if test "x$head3" = "x" -a "x$head" = "x$head2"; then
382         GIT_HEAD_ID="barvinok-$VERSION-$head
383     elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
384         GIT_HEAD_ID="barvinok-$VERSION-$head
385     else
386         GIT_HEAD_ID="UNKNOWN"
387     fi
389 if test -z "$GIT_REPO" ; then
390     GIT_HEAD_VERSION="$GIT_HEAD_ID"
391 else
392     GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
394 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
396 AX_CREATE_PKGCONFIG_INFO
398 AC_CONFIG_HEADERS(config.h)
399 AC_CONFIG_FILES(Makefile lib/Makefile doc/Makefile omega/Makefile)
400 if test x$have_ginac = xtrue; then
401     AC_CONFIG_SUBDIRS(bernstein)
403 AC_OUTPUT