2 AM_INIT_AUTOMAKE(barvinok, 0.24)
16 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
17 if test "$enable_shared" = yes; then
18 BV_LDFLAGS="-no-undefined"
26 gl_MODULES(argp progname)
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
41 if test "${with_libgmp+set}" != set -a \
42 -f "$with_default_prefix/include/gmp.h"; then
43 with_libgmp=$with_default_prefix
45 if test "${with_polylib+set}" != set -a \
46 -f "$with_default_prefix/include/polylib/polylibgmp.h"; then
47 with_polylib=$with_default_prefix
49 if test "${with_piplib+set}" != set -a \
50 -f "$with_default_prefix/include/piplib/piplibMP.h"; then
51 with_piplib=$with_default_prefix
53 if test "${with_ntl+set}" != set -a \
54 -f "$with_default_prefix/include/NTL/ZZ.h"; then
55 with_ntl=$with_default_prefix
57 if test "${with_omega+set}" != set -a \
58 -f "$with_default_prefix/include/omega/omega.h"; then
59 with_omega=$with_default_prefix
61 if test "${with_cddlib+set}" != set -a \
62 -f "$with_default_prefix/include/cddmp.h"; then
63 with_cddlib=$with_default_prefix
65 if test "${with_glpk+set}" != set -a \
66 -f "$with_default_prefix/include/glpk.h"; then
67 with_glpk=$with_default_prefix
69 if test "${with_topcom+set}" != set -a \
70 -f "$with_default_prefix/bin/points2triangs"; then
71 with_topcom=$with_default_prefix
75 dnl Check for GMP library
76 AC_MSG_CHECKING(whether to use GMP)
78 [ --with-libgmp DIR Location of the GMP Distribution],
79 gmp_package=$withval, gmp_package=yes)
80 if test "x$gmp_package" = "xno"; then
82 AC_MSG_ERROR(Need gmp)
85 if test "x$gmp_package" != "xyes"; then
87 if test ! -d "$GMP_DIR"; then
88 AC_ERROR(Directory given for GMP Distribution is not a directory)
90 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
91 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
94 AC_CHECK_HEADER(gmp.h,
95 [AC_CHECK_LIB(gmp,main,
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])
103 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
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"
133 AC_REPLACE_FUNCS(DomainConstraintSimplify)
135 #include <polylib/polylibgmp.h>
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);
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]))
160 #include <polylib/polylibgmp.h>
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])
172 #include <polylib/polylibgmp.h>
178 Param_Polyhedron *PP;
182 freopen("$srcdir/tests/ehrhart/t12.in", "r", stdin);
184 P = Constraints2Polyhedron(M, 1024);
186 C = Constraints2Polyhedron(M, 1024);
187 PP = Polyhedron2Param_Domain(P, C, 1024);
188 for (i = 0, V = PP->V; V; ++i, V = V->next)
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)],
201 AC_DEFINE(HAVE_ENUMERATE4,[],
202 [Polyhedron_Enumerate takes four arguments])],
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)],
209 AC_DEFINE(HAVE_COUNT_POINTS4,[],
210 [count_points takes four arguments])],
214 [ --with-piplib=DIR DIR Location of PIP],
215 [ echo "Package piplib : $withval" && piplib_package=$withval],
216 [ piplib_package=yes ])
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"
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>])
235 AC_MSG_WARN([Piplib not found])
236 bv_cv_piplibfatal="yes"
238 if test "$bv_cv_piplibfatal" = "no"; then
239 AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
240 LIBS="-lpiplibMP $LIBS"
242 bv_extra_programs="piptest\$(EXEEXT) $bv_extra_programs"
245 CPPFLAGS="$SAVE_CPPFLAGS"
246 LDFLAGS="$SAVE_LDFLAGS"
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
271 AC_DEFINE(USE_INCREMENTAL_BF,[],
272 [Use breadth-first incremental algorithm])
275 AC_DEFINE(USE_INCREMENTAL_DF,[],
276 [Use depth-first incremental algorithm])
281 [ --with-ntl=DIR DIR Location of NTL],
282 [ echo "Package ntl : $withval" && ntl_package=$withval],
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"
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)
313 if test "$with_bernstein" != "no"; then
315 AM_PATH_GINAC(1.3.3, [
317 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
318 PACKAGE_LIBS="-lbarvinok -lbernstein"
319 bv_barvinok_maximize="barvinok_maximize\$(EXEEXT)"
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)
333 AC_SUBST(bv_omega_programs)
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"
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"
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"
354 AC_DEFINE(HAVE_OMEGA,[],[use omega])
355 OMEGA_LIBS="-lcode_gen -lomega"
357 ],[AC_MSG_WARN(Omega not found)])
358 CPPFLAGS="$SAVE_CPPFLAGS"
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)
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"
383 AC_CHECK_LIB(cddgmp, main,[],[have_cddlib=false])
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)
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"
401 AC_CHECK_HEADERS([glpk.h],[
403 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
406 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
408 if test "$have_glpk" = "true" -o "$have_cddlib" = "true"; then
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)
418 if test "$topcom_package" != no; then
420 if test "$topcom_package" != unspecified; then
421 topcom_path="$topcom_package/bin"
423 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
424 if test -n "$POINTS2TRIANGS"; then
426 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
427 [Path of points2triangs])
430 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
432 AC_SUBST(GIT_HEAD_ID)
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`
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
452 GIT_HEAD_ID="UNKNOWN"
455 if test -z "$GIT_REPO" ; then
456 GIT_HEAD_VERSION="$GIT_HEAD_ID"
458 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
460 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
467 suffix="normal", suffix="broken")
468 AC_CONFIG_COMMANDS([barvinok/set.h],
469 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
471 AC_CONFIG_COMMANDS([barvinok/NTL.h],
472 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
475 SAVE_CPPFLAGS="$CPPFLAGS"
476 CPPFLAGS="-I$srcdir $CPPFLAGS"
477 AC_TRY_COMPILE([#include "fdstream.h"],[],
478 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
480 CPPFLAGS="$SAVE_CPPFLAGS"
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)