Document TOPCOM based chamber decomposition
[barvinok.git] / configure.in
blob18d27e68f6ca5514e00a6048cd640323fb727bda
1 AC_INIT
2 AM_INIT_AUTOMAKE(barvinok, 0.24)
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=14:0:1
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 AC_ARG_WITH(default-prefix,
33         AS_HELP_STRING([--with-default-prefix=DIR],
34             [Default installation prefix of optional packages]))
35 if test "${with_default_prefix+set}" = set; then
36         if test "${with_ginac_prefix+set}" != set -a \
37            "${with_ginac_exec_prefix+set}" != set -a \
38            -f "$with_default_prefix/bin/ginac-config"; then
39                 with_ginac_prefix=$with_default_prefix
40         fi
41         if test "${with_libgmp+set}" != set -a \
42            -f "$with_default_prefix/include/gmp.h"; then
43                 with_libgmp=$with_default_prefix
44         fi
45         if test "${with_polylib+set}" != set -a \
46            -f "$with_default_prefix/include/polylib/polylibgmp.h"; then
47                 with_polylib=$with_default_prefix
48         fi
49         if test "${with_piplib+set}" != set -a \
50            -f "$with_default_prefix/include/piplib/piplibMP.h"; then
51                 with_piplib=$with_default_prefix
52         fi
53         if test "${with_ntl+set}" != set -a \
54            -f "$with_default_prefix/include/NTL/ZZ.h"; then
55                 with_ntl=$with_default_prefix
56         fi
57         if test "${with_omega+set}" != set -a \
58            -f "$with_default_prefix/include/omega/omega.h"; then
59                 with_omega=$with_default_prefix
60         fi
61         if test "${with_cddlib+set}" != set -a \
62            -f "$with_default_prefix/include/cddmp.h"; then
63                 with_cddlib=$with_default_prefix
64         fi
65         if test "${with_glpk+set}" != set -a \
66            -f "$with_default_prefix/include/glpk.h"; then
67                 with_glpk=$with_default_prefix
68         fi
69         if test "${with_topcom+set}" != set -a \
70            -f "$with_default_prefix/bin/points2triangs"; then
71                 with_topcom=$with_default_prefix
72         fi
75 dnl Check for GMP library
76 AC_MSG_CHECKING(whether to use GMP)
77 AC_ARG_WITH(libgmp, 
78         [  --with-libgmp           DIR Location of the GMP Distribution], 
79         gmp_package=$withval, gmp_package=yes)
80 if test "x$gmp_package" = "xno"; then
81         AC_MSG_RESULT(no)
82         AC_MSG_ERROR(Need gmp)
83 else
84         AC_MSG_RESULT(yes)
85         if test "x$gmp_package" != "xyes"; then
86             GMP_DIR=$gmp_package
87             if test ! -d "$GMP_DIR"; then
88                 AC_ERROR(Directory given for GMP Distribution is not a directory)
89             fi
90             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
91             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
92         fi
93         poly_cv_gmpfatal="no"
94         AC_CHECK_HEADER(gmp.h,
95                 [AC_CHECK_LIB(gmp,main,
96                     [],
97                     [poly_cv_gmpfatal="yes"])],
98                 [poly_cv_gmpfatal="yes"])
99         if test "$poly_cv_gmpfatal" = "yes"; then
100                 AC_MSG_ERROR([GMP not found])
101         fi
103 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
105 AC_ARG_WITH(polylib,
106             [  --with-polylib=DIR      DIR Location of PolyLib],
107             [ echo "Package polylib : $withval" && polylib_package=$withval],  
108             [ polylib_package=yes ])
110 if test "$polylib_package" = "no"; then
111     AC_MSG_ERROR(Need polylib)
114 if test "$polylib_package" != "yes"; then
115     CPPFLAGS="-I$polylib_package/include $CPPFLAGS"
116     LDFLAGS="-L$polylib_package/lib $LDFLAGS"
117     LD_LIBRARY_PATH="$polylib_package/lib:$LD_LIBRARY_PATH"
118     export LD_LIBRARY_PATH
121 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
122     AC_MSG_ERROR(Need polylib)
124 AC_CHECK_LIB(polylibgmp, PolyhedronTSort,[],[
125     AC_MSG_ERROR(Need polylib)
127 AC_CHECK_FUNCS(Enumeration_Free)
128 AC_CHECK_FUNCS(compress_parms, [AC_LIBOBJ(remove_equalities)])
129 AC_SUBST(bv_extra_programs)
130 AC_CHECK_FUNCS(LexSmaller,[
131         bv_extra_programs="verify_lexsmaller\$(EXEEXT) $bv_extra_programs"
132     ])
133 AC_REPLACE_FUNCS(DomainConstraintSimplify)
134 AC_TRY_RUN([
135 #include <polylib/polylibgmp.h>
137 int main()
139     int i, j;
140     Polyhedron *P;
141     Matrix *M = Matrix_Alloc(6,5);
142     for (i = 0; i < 6; ++i) {
143         value_set_si(M->p[i][0], 1);
144         for (j = 1; j < 4; ++j)
145             value_set_si(M->p[i][j], (j-1 == i/2) * (1-2*(i%2)));
146         value_set_si(M->p[i][4], i%2);
147     }
148     P = Constraints2Polyhedron(M, 6);
149     return !(P->NbRays == 8);
152 [AC_DEFINE(HAVE_GROWING_CHERNIKOVA,[],
153           [PolyLib automatically grows the Chernikova table space])],
154 AC_MSG_WARN([This version of PolyLib does not automatically])
155 AC_MSG_WARN([enlarge the Chernikova table space]),
156 AC_MSG_WARN([Unable to determine whether PolyLib automatically])
157 AC_MSG_WARN([grows the Chernikova table space]))
159 AC_TRY_RUN([
160 #include <polylib/polylibgmp.h>
162 int main()
164     enode *en = new_enode(polynomial, 1, 1);
165     return !(en->arr[0].x.p == NULL);
168 AC_MSG_WARN([This version of polylib leaks]),[true])
170 AC_TRY_RUN([
171 #include <stdio.h>
172 #include <polylib/polylibgmp.h>
174 int main()
176     Matrix *M;
177     Polyhedron *P, *C;
178     Param_Polyhedron *PP;
179     int i;
180     Param_Vertices *V;
182     freopen("$srcdir/tests/ehrhart/t12.in", "r", stdin);
183     M = Matrix_Read();
184     P = Constraints2Polyhedron(M, 1024);
185     M = Matrix_Read();
186     C = Constraints2Polyhedron(M, 1024);
187     PP = Polyhedron2Param_Domain(P, C, 1024);
188     for (i = 0, V = PP->V; V; ++i, V = V->next)
189         ;
190     return !(i == 10);
194 AC_MSG_ERROR([This version of polylib produces incorrect vertices.]),
195 AC_MSG_WARN([Unable to determine whether PolyLib computes correct vertices]))
197 AC_MSG_CHECKING([number of arguments of Polyhedron_Enumerate])
198 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
199                [Polyhedron_Enumerate(NULL,NULL,0,NULL)],
200                [AC_MSG_RESULT(4)
201                 AC_DEFINE(HAVE_ENUMERATE4,[],
202                           [Polyhedron_Enumerate takes four arguments])],
203                [AC_MSG_RESULT(3)])
205 AC_MSG_CHECKING([number of arguments of count_points])
206 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
207                [count_points(0,NULL,NULL,NULL)],
208                [AC_MSG_RESULT(4)
209                 AC_DEFINE(HAVE_COUNT_POINTS4,[],
210                           [count_points takes four arguments])],
211                [AC_MSG_RESULT(3)])
213 AC_ARG_WITH(piplib,
214             [  --with-piplib=DIR       DIR Location of PIP],
215             [ echo "Package piplib : $withval" && piplib_package=$withval],  
216             [ piplib_package=yes ])
218 have_piplib=false
219 if test "$piplib_package" != "no"; then
220     SAVE_CPPFLAGS="$CPPFLAGS"
221     SAVE_LDFLAGS="$LDFLAGS"
222     if test "$piplib_package" != "yes"; then
223         CPPFLAGS="-I$piplib_package/include $CPPFLAGS"
224         LDFLAGS="-L$piplib_package/lib $LDFLAGS"
225     fi
227     bv_cv_piplibfatal="no"
228     AC_CHECK_LIB(piplibMP, pip_solve,[
229         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
230             AC_MSG_WARN([Piplib too old; please install version 1.3.6 or newer])
231             bv_cv_piplibfatal="yes"
232         ],[#include <stdio.h>
233            #include <piplib/piplibMP.h>])
234     ],[
235         AC_MSG_WARN([Piplib not found])
236         bv_cv_piplibfatal="yes"
237     ])
238     if test "$bv_cv_piplibfatal" = "no"; then
239         AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
240         LIBS="-lpiplibMP $LIBS"
241         AC_LIBOBJ(piputil)
242         bv_extra_programs="piptest\$(EXEEXT) $bv_extra_programs"
243         have_piplib=true
244     else
245         CPPFLAGS="$SAVE_CPPFLAGS"
246         LDFLAGS="$SAVE_LDFLAGS"
247     fi
249 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
251 AC_MSG_CHECKING(if the fractional representation should be used)
252 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
253                                           [Don't use fractional representation])],
254             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
255 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
256                                       [Don't use fractional representation])],
257             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
258 AC_MSG_RESULT($bv_cv_modulo)
259 if test "x$bv_cv_modulo" != "xno" ; then
260         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
263 AC_MSG_CHECKING(whether to use incremental algorithm)
264 AC_ARG_ENABLE(incremental,
265         [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
266                         [Enable incremental algorithm [bf]])],
267         [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
268 AC_MSG_RESULT($bv_cv_incremental)
269 case $bv_cv_incremental in
270         yes | bf)
271                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
272                           [Use breadth-first incremental algorithm])
273         ;;
274         df)
275                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
276                           [Use depth-first incremental algorithm])
277         ;;
278 esac
280 AC_ARG_WITH(ntl,
281             [  --with-ntl=DIR          DIR Location of NTL],
282             [ echo "Package ntl : $withval" && ntl_package=$withval],  
283             [ ntl_package=yes ])
285 if test "$ntl_package" = "no"; then
286     AC_MSG_ERROR(Need ntl)
289 if test "$ntl_package" != "yes"; then
290     CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
291     LDFLAGS="-L$ntl_package/lib $LDFLAGS"
294 AC_EGREP_CPP(yes, [
295     #include <NTL/ZZ.h>
296     #ifdef NTL_GMP_LIP
297     yes
298     #endif
299     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
301 AC_CHECK_LIB(ntl, main,[],[
302     AC_MSG_ERROR(Need ntl)
305 AC_MSG_CHECKING(whether to compile bernstein)
306 AC_ARG_WITH(bernstein,
307             [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
308             [ with_bernstein=$withval],  [ with_bernstein=yes ])
309 AC_MSG_RESULT($with_bernstein)
311 AC_SUBST(bv_barvinok_maximize)
312 have_ginac=false
313 if test "$with_bernstein" != "no"; then
314         AC_LANG_PUSH(C++)
315         AM_PATH_GINAC(1.3.3, [
316                 have_ginac=true
317                 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
318                 PACKAGE_LIBS="-lbarvinok -lbernstein"
319                 bv_barvinok_maximize="barvinok_maximize\$(EXEEXT)"
320         ])
321         AC_LANG_POP
323 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
325 AC_MSG_CHECKING(whether to use Omega)
326 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
327             [ omega_package=$withval],  [ omega_package=yes ])
328 AC_MSG_RESULT($omega_package)
330 AC_SUBST(OMEGA_CPPFLAGS)
331 AC_SUBST(OMEGA_LDFLAGS)
332 AC_SUBST(OMEGA_LIBS)
333 AC_SUBST(bv_omega_programs)
334 have_omega=false
335 if test "$omega_package" != "no"; then
336     if test "x$omega_package" != "xyes"; then
337         OMEGA_CPPFLAGS="-I$omega_package/include/omega"
338         OMEGA_LDFLAGS="-L$omega_package/lib"
339     else
340         for i in /usr/include /usr/local/include; do
341             if test -f $i/omega/omega.h; then
342                 OMEGA_CPPFLAGS="-I$i/omega"
343             fi
344         done
345     fi
347     AC_LANG_PUSH(C++)
348     SAVE_CPPFLAGS="$CPPFLAGS"
349     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
350     AC_CHECK_HEADERS([omega.h],[
351         if test x$have_ginac = xtrue; then
352             bv_omega_programs="occ $bv_omega_programs"
353         fi
354         AC_DEFINE(HAVE_OMEGA,[],[use omega])
355         OMEGA_LIBS="-lcode_gen -lomega"
356         have_omega=true
357     ],[AC_MSG_WARN(Omega not found)])
358     CPPFLAGS="$SAVE_CPPFLAGS"
359     AC_LANG_POP
361 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
364 AC_MSG_CHECKING(whether to use cddlib)
365 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
366             [ cddlib_package=$withval],  [ cddlib_package=yes ])
367 AC_MSG_RESULT($cddlib_package)
369 have_cddlib=false
370 if test "$cddlib_package" != "no"; then
371     if test "x$cddlib_package" != "xyes"; then
372         CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
373         LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
374     fi
375     AC_TRY_LINK([
376 #define GMPRATIONAL
377 #include <setoper.h>
378 #include <cddmp.h>
379 ], [
380     mytype a;
381     dd_init(a); ], [
382         have_cddlib=true
383         AC_CHECK_LIB(cddgmp, main,[],[have_cddlib=false])
384     ])
386 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
390 AC_MSG_CHECKING(whether to use GLPK)
391 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
392             [ glpk_package=$withval],  [ glpk_package=yes ])
393 AC_MSG_RESULT($glpk_package)
395 have_glpk=false
396 if test "$glpk_package" != "no"; then
397     if test "x$glpk_package" != "xyes"; then
398         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
399         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
400     fi
401     AC_CHECK_HEADERS([glpk.h],[
402         have_glpk=true
403         AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
404     ])
406 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
408 if test "$have_glpk" = "true" -o "$have_cddlib" = "true"; then
409     AC_LIBOBJ(sample)
410     bv_extra_programs="polyhedron_sample\$(EXEEXT) 4coins\$(EXEEXT) lexmin\$(EXEEXT) $bv_extra_programs"
413 AC_MSG_CHECKING(location of TOPCOM)
414 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
415             [topcom_package=$withval], [topcom_package=unspecified])
416 AC_MSG_RESULT($topcom_package)
417 have_topcom=false
418 if test "$topcom_package" != no; then
419         topcom_path="$PATH"
420         if test "$topcom_package" != unspecified; then
421                 topcom_path="$topcom_package/bin"
422         fi
423         AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
424         if test -n "$POINTS2TRIANGS"; then
425                 have_topcom=true
426                 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
427                                     [Path of points2triangs])
428         fi
430 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
432 AC_SUBST(GIT_HEAD_ID)
433 AC_SUBST(GIT_HEAD)
434 AC_SUBST(GIT_HEAD_VERSION)
435 if test -f $srcdir/.git/HEAD; then
436     GIT_HEAD="$srcdir/.git/index"
437     GIT_REPO="$srcdir/.git"
438     GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
439 elif test -f $srcdir/GIT_HEAD_ID; then
440     GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
441 else
442     mysrcdir=`(cd $srcdir; pwd)`
443     head=`basename $mysrcdir | sed -e 's/.*-//'`
444     head2=`echo $head | sed -e 's/[^0-9a-f]//'`
445     head3=`echo $head2 | sed -e 's/........................................//'`
446     base=`basename $mysrcdir | sed -e 's/-.*//'`
447     if test "x$head3" = "x" -a "x$head" = "x$head2"; then
448         GIT_HEAD_ID="barvinok-$VERSION-$head
449     elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
450         GIT_HEAD_ID="barvinok-$VERSION-$head
451     else
452         GIT_HEAD_ID="UNKNOWN"
453     fi
455 if test -z "$GIT_REPO" ; then
456     GIT_HEAD_VERSION="$GIT_HEAD_ID"
457 else
458     GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
460 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
462 AC_LANG_PUSH(C++)
463 AC_TRY_COMPILE([
464                 #include <set>
465                 void negate();
466         ], [negate()],
467         suffix="normal", suffix="broken")
468 AC_CONFIG_COMMANDS([barvinok/set.h],
469                    [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
470                    [suffix="$suffix"])
471 AC_CONFIG_COMMANDS([barvinok/NTL.h],
472                    [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
473                    [suffix="$suffix"])
474 use_fdstream=false
475 SAVE_CPPFLAGS="$CPPFLAGS"
476 CPPFLAGS="-I$srcdir $CPPFLAGS"
477 AC_TRY_COMPILE([#include "fdstream.h"],[],
478         [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
479         use_fdstream=true])
480 CPPFLAGS="$SAVE_CPPFLAGS"
481 AC_LANG_POP
482 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
484 AX_CREATE_PKGCONFIG_INFO
486 AC_CONFIG_HEADERS(config.h)
487 AC_CONFIG_FILES(Makefile lib/Makefile doc/Makefile omega/Makefile)
488 if test x$have_ginac = xtrue; then
489     AC_CONFIG_SUBDIRS(bernstein)
491 AC_OUTPUT