2 AM_INIT_AUTOMAKE(barvinok, 0.27)
16 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
17 if test "$enable_shared" = yes; then
18 BV_LDFLAGS="-no-undefined"
25 gl_MODULES(argp progname)
30 AC_CHECK_HEADERS(getopt.h)
31 AC_CHECK_HEADERS(sys/times.h)
33 AC_MSG_CHECKING(whether to build shared libbarvinok)
34 AC_ARG_ENABLE(shared_barvinok,
35 AS_HELP_STRING([--enable-shared-barvinok],
36 [build shared barvinok library]),
37 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
38 AC_MSG_RESULT($bv_cv_shared_barvinok)
39 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
40 BV_LDFLAGS="$BV_LDFLAGS -static"
45 AC_ARG_WITH(default-prefix,
46 AS_HELP_STRING([--with-default-prefix=DIR],
47 [Default installation prefix of optional packages]))
48 if test "${with_default_prefix+set}" = set; then
49 if test "${with_ginac_prefix+set}" != set -a \
50 -f "$with_default_prefix/lib/pkgconfig/ginac.pc"; then
51 with_ginac_prefix=$with_default_prefix
53 if test "${with_libgmp+set}" != set -a \
54 -f "$with_default_prefix/include/gmp.h"; then
55 with_libgmp=$with_default_prefix
57 if test "${with_ntl+set}" != set -a \
58 -f "$with_default_prefix/include/NTL/ZZ.h"; then
59 with_ntl=$with_default_prefix
61 if test "${with_omega+set}" != set -a \
62 -f "$with_default_prefix/include/omega/omega.h"; then
63 with_omega=$with_default_prefix
65 if test "${with_cddlib+set}" != set -a \
66 -f "$with_default_prefix/include/cddmp.h"; then
67 with_cddlib=$with_default_prefix
69 if test "${with_glpk+set}" != set -a \
70 -f "$with_default_prefix/include/glpk.h"; then
71 with_glpk=$with_default_prefix
73 if test "${with_topcom+set}" != set -a \
74 -f "$with_default_prefix/bin/points2triangs"; then
75 with_topcom=$with_default_prefix
79 dnl Check for GMP library
80 AC_MSG_CHECKING(whether to use GMP)
82 [ --with-libgmp DIR Location of the GMP Distribution],
83 gmp_package=$withval, gmp_package=yes)
84 if test "x$gmp_package" = "xno"; then
86 AC_MSG_ERROR(Need gmp)
89 if test "x$gmp_package" = "xyes"; then
90 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
92 bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
93 bv_configure_args="$bv_configure_args --with-gmp=$gmp_package"
95 if test ! -d "$GMP_DIR"; then
96 AC_ERROR(Directory given for GMP Distribution is not a directory)
98 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
99 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
101 poly_cv_gmpfatal="no"
102 AC_CHECK_HEADER(gmp.h,
103 [AC_CHECK_LIB(gmp,main,
105 [poly_cv_gmpfatal="yes"])],
106 [poly_cv_gmpfatal="yes"])
107 if test "$poly_cv_gmpfatal" = "yes"; then
108 AC_MSG_ERROR([GMP not found])
111 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
113 # BV_SUBMODULE(SUBMODULE)
114 AC_DEFUN([BV_SUBMODULE],[
117 AC_MSG_ERROR(Need $1)
122 if test -d $srcdir/.git -a \
123 ! -d $srcdir/$1/.git; then
125 [git repo detected, but submodule $1 not initialized])
126 AC_MSG_WARN([You may want to run])
127 AC_MSG_WARN([ git submodule init])
128 AC_MSG_WARN([ git submodule update])
129 AC_MSG_WARN([ sh autogen.sh])
131 if test -f $srcdir/$1/configure; then
141 [AS_HELP_STRING([--with-polylib=bundled|system],[Which PolyLib to use])])
142 AC_ARG_WITH(polylib_prefix,
143 [AS_HELP_STRING([--with-polylib-prefix=DIR],[Location of system PolyLib])])
145 if test "x$with_polylib_prefix" != "x"; then
146 with_polylib="system"
148 BV_SUBMODULE(polylib)
149 AC_MSG_CHECKING([which PolyLib to use])
150 AC_MSG_RESULT($with_polylib)
152 AC_SUBST(POLYLIB_CPPFLAGS)
153 AC_SUBST(POLYLIB_LDFLAGS)
154 AC_SUBST(POLYLIB_LIBS)
155 if test "$with_polylib" = "bundled"; then
156 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
157 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
159 POLYLIB_LIBS="-lpolylibgmp"
160 if test "x$with_polylib_prefix" != "x"; then
161 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
162 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
164 SAVE_CPPFLAGS="$CPPFLAGS"
165 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
166 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
167 AC_MSG_ERROR(Need PolyLib)
169 CPPFLAGS="$SAVE_CPPFLAGS"
172 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
175 [AS_HELP_STRING([--with-piplib=bundled|system],[Which piplib to use])])
176 AC_ARG_WITH(piplib_prefix,
177 [AS_HELP_STRING([--with-piplib-prefix=DIR],[Location of system piplib])])
179 if test "x$with_piplib_prefix" != "x"; then
183 AC_MSG_CHECKING([which piplib to use])
184 AC_MSG_RESULT($with_piplib)
186 AC_SUBST(PIPLIB_CPPFLAGS)
187 AC_SUBST(PIPLIB_LDFLAGS)
188 AC_SUBST(PIPLIB_LIBS)
189 if test "$with_piplib" = "bundled"; then
190 bv_configure_args="$bv_configure_args --with-piplib-builddir=../piplib"
191 bv_configure_args="$bv_configure_args --enable-mp-version"
192 PIPLIB_CPPFLAGS="-I$srcdir/piplib/include"
194 PIPLIB_LIBS="-lpiplibMP"
195 if test "x$with_piplib_prefix" != "x"; then
196 PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
197 PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
199 SAVE_CPPFLAGS="$CPPFLAGS"
200 SAVE_LDFLAGS="$LDFLAGS"
201 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
202 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
203 AC_CHECK_LIB(piplibMP, pip_solve,[
204 AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
205 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
206 ],[#include <stdio.h>
207 #include <piplib/piplibMP.h>])
209 AC_MSG_ERROR([Piplib not found])
211 CPPFLAGS="$SAVE_CPPFLAGS"
212 LDFLAGS="$SAVE_LDFLAGS"
214 AM_CONDITIONAL(BUNDLED_PIPLIB, test $with_piplib = bundled)
216 AC_MSG_CHECKING(if the fractional representation should be used)
217 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
218 [Don't use fractional representation])],
219 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
220 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
221 [Don't use fractional representation])],
222 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
223 AC_MSG_RESULT($bv_cv_modulo)
224 if test "x$bv_cv_modulo" != "xno" ; then
225 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
228 AC_MSG_CHECKING(whether to use incremental algorithm)
229 AC_ARG_ENABLE(incremental,
230 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
231 [Enable incremental algorithm [bf]])],
232 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
233 AC_MSG_RESULT($bv_cv_incremental)
234 case $bv_cv_incremental in
236 AC_DEFINE(USE_INCREMENTAL_BF,[],
237 [Use breadth-first incremental algorithm])
240 AC_DEFINE(USE_INCREMENTAL_DF,[],
241 [Use depth-first incremental algorithm])
246 [ --with-ntl=DIR DIR Location of NTL],
247 [ echo "Package ntl : $withval" && ntl_package=$withval],
250 if test "$ntl_package" = "no"; then
251 AC_MSG_ERROR(Need ntl)
254 AC_SUBST(NTL_CPPFLAGS)
255 AC_SUBST(NTL_LDFLAGS)
256 if test "$ntl_package" != "yes"; then
257 NTL_CPPFLAGS="-I$ntl_package/include"
258 NTL_LDFLAGS="-L$ntl_package/lib"
261 SAVE_CPPFLAGS="$CPPFLAGS"
262 SAVE_LDFLAGS="$LDFLAGS"
263 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
264 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
270 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
272 AC_CHECK_LIB(ntl, main,[],[
273 AC_MSG_ERROR(Need ntl)
275 CPPFLAGS="$SAVE_CPPFLAGS"
276 LDFLAGS="$SAVE_LDFLAGS"
278 AC_SUBST(bv_cone_hilbert_basis)
279 AC_MSG_CHECKING(whether to compile zsolve)
280 AC_ARG_WITH(bernstein,
281 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
282 [ with_zsolve=$withval], [ with_zsolve=yes ])
283 AC_MSG_RESULT($with_zsolve)
286 if test "$with_zsolve" != "no"; then
287 if test "$GCC" = "yes"; then
289 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
291 if test $major -gt 3; then
294 if test $major -eq 3 -a $minor -ge 4; then
300 if test "$use_zsolve" = false; then
301 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
303 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
304 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
307 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
309 AC_MSG_CHECKING(whether to compile bernstein)
310 AC_ARG_WITH(bernstein,
311 [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
312 [ with_bernstein=$withval], [ with_bernstein=yes ])
313 AC_MSG_RESULT($with_bernstein)
315 AC_ARG_WITH(ginac_prefix,
316 [AS_HELP_STRING([--with-ginac-prefix=DIR],[Installation prefix of GiNaC])])
317 if test "x$with_ginac_prefix" != "x"; then
318 export PKG_CONFIG_PATH=$with_ginac_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
321 AC_SUBST(bv_barvinok_bound)
323 if test "$with_bernstein" != "no"; then
324 PKG_CHECK_EXISTS([ginac], [
325 PKG_CHECK_MODULES(ginac, ginac)
327 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
328 EXTRA_PACKAGE_LIBS="-lbernstein $EXTRA_PACKAGE_LIBS"
329 bv_barvinok_bound="barvinok_bound\$(EXEEXT) test_bound\$(EXEEXT)"
332 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
334 AC_MSG_CHECKING(whether to use Omega)
335 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
336 [ omega_package=$withval], [ omega_package=yes ])
337 AC_MSG_RESULT($omega_package)
339 AC_SUBST(OMEGA_CPPFLAGS)
340 AC_SUBST(OMEGA_LDFLAGS)
342 AC_SUBST(bv_omega_programs)
344 if test "$omega_package" != "no"; then
345 if test "x$omega_package" != "xyes"; then
346 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
347 OMEGA_LDFLAGS="-L$omega_package/lib"
349 for i in /usr/include /usr/local/include; do
350 if test -f $i/omega/omega.h; then
351 OMEGA_CPPFLAGS="-I$i/omega"
357 SAVE_CPPFLAGS="$CPPFLAGS"
358 SAVE_LDFLAGS="$LDFLAGS"
359 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
360 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
361 AC_CHECK_HEADERS([omega.h],[
362 if test x$have_ginac = xtrue; then
363 AC_CHECK_LIB(code_gen,main,[
364 bv_omega_programs="occ $bv_omega_programs"
367 AC_DEFINE(HAVE_OMEGA,[],[use omega])
370 ],[AC_MSG_WARN(Omega not found)])
371 CPPFLAGS="$SAVE_CPPFLAGS"
372 LDFLAGS="$SAVE_LDFLAGS"
375 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
378 AC_MSG_CHECKING(whether to compile parker)
380 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
381 [ with_parker=$withval], [ with_parker=yes ])
382 AC_MSG_RESULT($with_parker)
384 if test "$with_parker" != "no"; then
385 AC_MSG_CHECKING(for mona)
387 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
388 [], [AC_MSG_RESULT(not specified)])
390 if test "x$with_mona" != "x"; then
393 AC_MSG_RESULT($MONAPATH)
395 AC_DEFINE(USE_PARKER,[],[use parker])
398 if test "x$with_mona" = "x"; then
399 AC_MSG_WARN(mona source directory required to compile parker)
400 AC_MSG_WARN(http://www.brics.dk/mona/download)
403 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
405 AC_MSG_CHECKING(whether to use cddlib)
406 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
407 [ cddlib_package=$withval], [ cddlib_package=yes ])
408 AC_MSG_RESULT($cddlib_package)
411 if test "$cddlib_package" != "no"; then
412 if test "x$cddlib_package" != "xyes"; then
413 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
414 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
424 AC_CHECK_LIB(cddgmp, main,[
426 LIBS="-lcddgmp $LIBS"
427 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
429 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
433 const char *filename = SRCDIR"/cdd94e-test";
437 dd_ErrorType err = dd_NoError;
439 dd_set_global_constants();
441 f = fopen(filename, "r");
442 M = dd_PolyFile2Matrix(f, &err);
443 lp = dd_Matrix2LP(M, &err);
444 dd_LPSolve(lp, dd_DualSimplex, &err);
445 return lp->LPS == dd_Inconsistent;
447 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
449 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
454 ],[have_cddlib=false])
457 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
461 AC_MSG_CHECKING(whether to use GLPK)
462 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
463 [ glpk_package=$withval], [ glpk_package=yes ])
464 AC_MSG_RESULT($glpk_package)
467 if test "$glpk_package" != "no"; then
468 if test "x$glpk_package" != "xyes"; then
469 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
470 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
472 AC_CHECK_HEADERS([glpk.h],[
474 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
477 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
479 AC_MSG_CHECKING(location of TOPCOM)
480 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
481 [topcom_package=$withval], [topcom_package=unspecified])
482 AC_MSG_RESULT($topcom_package)
484 if test "$topcom_package" != no; then
486 if test "$topcom_package" != unspecified; then
487 topcom_path="$topcom_package/bin"
489 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
490 if test -n "$POINTS2TRIANGS"; then
492 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
493 [Path of points2triangs])
496 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
498 AC_SUBST(GIT_HEAD_ID)
500 AC_SUBST(GIT_HEAD_VERSION)
501 if test -f $srcdir/.git/HEAD; then
502 GIT_HEAD="$srcdir/.git/index"
503 GIT_REPO="$srcdir/.git"
504 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
505 elif test -f $srcdir/GIT_HEAD_ID; then
506 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
508 mysrcdir=`(cd $srcdir; pwd)`
509 head=`basename $mysrcdir | sed -e 's/.*-//'`
510 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
511 head3=`echo $head2 | sed -e 's/........................................//'`
512 base=`basename $mysrcdir | sed -e 's/-.*//'`
513 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
514 GIT_HEAD_ID="barvinok-$VERSION-$head
515 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
516 GIT_HEAD_ID="barvinok-$VERSION-$head
518 GIT_HEAD_ID="UNKNOWN"
521 if test -z "$GIT_REPO" ; then
522 GIT_HEAD_VERSION="$GIT_HEAD_ID"
524 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
526 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
533 suffix="normal", suffix="broken")
534 AC_CONFIG_COMMANDS([barvinok/set.h],
535 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
537 AC_CONFIG_COMMANDS([barvinok/NTL.h],
538 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
541 SAVE_CPPFLAGS="$CPPFLAGS"
542 CPPFLAGS="-I$srcdir $CPPFLAGS"
543 AC_TRY_COMPILE([#include "fdstream.h"],[],
544 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
546 CPPFLAGS="$SAVE_CPPFLAGS"
548 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
550 PACKAGE_LIBS="-lbarvinok -lbarvinok-core $EXTRA_PACKAGE_LIBS -lpolylibgmp -lpiplibMP"
551 AX_CREATE_PKGCONFIG_INFO
553 AC_CONFIG_HEADERS(config.h)
554 AC_CONFIG_FILES(Makefile lib/Makefile zsolve/Makefile doc/Makefile omega/Makefile)
555 AC_CONFIG_FILES(parker/Makefile)
556 if test $with_polylib = bundled; then
557 AC_CONFIG_SUBDIRS(polylib)
559 if test $with_piplib = bundled; then
560 AC_CONFIG_SUBDIRS(piplib)
562 if test x$have_ginac = xtrue; then
563 AC_CONFIG_SUBDIRS(bernstein)
565 AC_CONFIG_COMMANDS_POST([
566 dnl pass on arguments to subdir configures, but don't
567 dnl add them to config.status
568 ac_configure_args="$ac_configure_args $bv_configure_args"