2 AM_INIT_AUTOMAKE(barvinok, 0.26)
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="-Ipolylib/include -I$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 if test "$ntl_package" != "yes"; then
255 CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
256 LDFLAGS="-L$ntl_package/lib $LDFLAGS"
264 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
266 AC_CHECK_LIB(ntl, main,[],[
267 AC_MSG_ERROR(Need ntl)
270 AC_SUBST(bv_cone_hilbert_basis)
271 AC_MSG_CHECKING(whether to compile zsolve)
272 AC_ARG_WITH(bernstein,
273 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
274 [ with_zsolve=$withval], [ with_zsolve=yes ])
275 AC_MSG_RESULT($with_zsolve)
278 if test "$with_zsolve" != "no"; then
279 if test "$GCC" = "yes"; then
281 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
283 if test $major -gt 3; then
286 if test $major -eq 3 -a $minor -ge 4; then
292 if test "$use_zsolve" = false; then
293 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
295 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
296 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
299 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
301 AC_MSG_CHECKING(whether to compile bernstein)
302 AC_ARG_WITH(bernstein,
303 [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
304 [ with_bernstein=$withval], [ with_bernstein=yes ])
305 AC_MSG_RESULT($with_bernstein)
307 AC_ARG_WITH(ginac_prefix,
308 [AS_HELP_STRING([--with-ginac-prefix=DIR],[Installation prefix of GiNaC])])
309 if test "x$with_ginac_prefix" != "x"; then
310 export PKG_CONFIG_PATH=$with_ginac_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
313 AC_SUBST(bv_barvinok_bound)
315 if test "$with_bernstein" != "no"; then
316 PKG_CHECK_EXISTS([ginac], [
317 PKG_CHECK_MODULES(ginac, ginac)
319 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
320 EXTRA_PACKAGE_LIBS="-lbernstein $EXTRA_PACKAGE_LIBS"
321 bv_barvinok_bound="barvinok_bound\$(EXEEXT) test_bound\$(EXEEXT)"
324 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
326 AC_MSG_CHECKING(whether to use Omega)
327 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
328 [ omega_package=$withval], [ omega_package=yes ])
329 AC_MSG_RESULT($omega_package)
331 AC_SUBST(OMEGA_CPPFLAGS)
332 AC_SUBST(OMEGA_LDFLAGS)
334 AC_SUBST(bv_omega_programs)
336 if test "$omega_package" != "no"; then
337 if test "x$omega_package" != "xyes"; then
338 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
339 OMEGA_LDFLAGS="-L$omega_package/lib"
341 for i in /usr/include /usr/local/include; do
342 if test -f $i/omega/omega.h; then
343 OMEGA_CPPFLAGS="-I$i/omega"
349 SAVE_CPPFLAGS="$CPPFLAGS"
350 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
351 AC_CHECK_HEADERS([omega.h],[
352 if test x$have_ginac = xtrue; then
353 AC_CHECK_LIB(code_gen,main,[
354 bv_omega_programs="occ $bv_omega_programs"
357 AC_DEFINE(HAVE_OMEGA,[],[use omega])
360 ],[AC_MSG_WARN(Omega not found)])
361 CPPFLAGS="$SAVE_CPPFLAGS"
364 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
367 AC_MSG_CHECKING(whether to compile parker)
369 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
370 [ with_parker=$withval], [ with_parker=yes ])
371 AC_MSG_RESULT($with_parker)
373 if test "$with_parker" != "no"; then
374 AC_MSG_CHECKING(for mona)
376 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
377 [], [AC_MSG_RESULT(not specified)])
379 if test "x$with_mona" != "x"; then
382 AC_MSG_RESULT($MONAPATH)
384 AC_DEFINE(USE_PARKER,[],[use parker])
387 if test "x$with_mona" = "x"; then
388 AC_MSG_WARN(mona source directory required to compile parker)
389 AC_MSG_WARN(http://www.brics.dk/mona/download)
392 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
394 AC_MSG_CHECKING(whether to use cddlib)
395 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
396 [ cddlib_package=$withval], [ cddlib_package=yes ])
397 AC_MSG_RESULT($cddlib_package)
400 if test "$cddlib_package" != "no"; then
401 if test "x$cddlib_package" != "xyes"; then
402 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
403 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
413 AC_CHECK_LIB(cddgmp, main,[
415 LIBS="-lcddgmp $LIBS"
416 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
418 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
422 const char *filename = SRCDIR"/cdd94e-test";
426 dd_ErrorType err = dd_NoError;
428 dd_set_global_constants();
430 f = fopen(filename, "r");
431 M = dd_PolyFile2Matrix(f, &err);
432 lp = dd_Matrix2LP(M, &err);
433 dd_LPSolve(lp, dd_DualSimplex, &err);
434 return lp->LPS == dd_Inconsistent;
436 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
438 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
443 ],[have_cddlib=false])
446 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
450 AC_MSG_CHECKING(whether to use GLPK)
451 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
452 [ glpk_package=$withval], [ glpk_package=yes ])
453 AC_MSG_RESULT($glpk_package)
456 if test "$glpk_package" != "no"; then
457 if test "x$glpk_package" != "xyes"; then
458 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
459 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
461 AC_CHECK_HEADERS([glpk.h],[
463 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
466 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
468 AC_MSG_CHECKING(location of TOPCOM)
469 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
470 [topcom_package=$withval], [topcom_package=unspecified])
471 AC_MSG_RESULT($topcom_package)
473 if test "$topcom_package" != no; then
475 if test "$topcom_package" != unspecified; then
476 topcom_path="$topcom_package/bin"
478 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
479 if test -n "$POINTS2TRIANGS"; then
481 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
482 [Path of points2triangs])
485 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
487 AC_SUBST(GIT_HEAD_ID)
489 AC_SUBST(GIT_HEAD_VERSION)
490 if test -f $srcdir/.git/HEAD; then
491 GIT_HEAD="$srcdir/.git/index"
492 GIT_REPO="$srcdir/.git"
493 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
494 elif test -f $srcdir/GIT_HEAD_ID; then
495 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
497 mysrcdir=`(cd $srcdir; pwd)`
498 head=`basename $mysrcdir | sed -e 's/.*-//'`
499 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
500 head3=`echo $head2 | sed -e 's/........................................//'`
501 base=`basename $mysrcdir | sed -e 's/-.*//'`
502 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
503 GIT_HEAD_ID="barvinok-$VERSION-$head
504 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
505 GIT_HEAD_ID="barvinok-$VERSION-$head
507 GIT_HEAD_ID="UNKNOWN"
510 if test -z "$GIT_REPO" ; then
511 GIT_HEAD_VERSION="$GIT_HEAD_ID"
513 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
515 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
522 suffix="normal", suffix="broken")
523 AC_CONFIG_COMMANDS([barvinok/set.h],
524 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
526 AC_CONFIG_COMMANDS([barvinok/NTL.h],
527 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
530 SAVE_CPPFLAGS="$CPPFLAGS"
531 CPPFLAGS="-I$srcdir $CPPFLAGS"
532 AC_TRY_COMPILE([#include "fdstream.h"],[],
533 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
535 CPPFLAGS="$SAVE_CPPFLAGS"
537 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
539 PACKAGE_LIBS="-lbarvinok -lbarvinok-core $EXTRA_PACKAGE_LIBS -lpolylibgmp -lpiplibMP"
540 AX_CREATE_PKGCONFIG_INFO
542 AC_CONFIG_HEADERS(config.h)
543 AC_CONFIG_FILES(Makefile lib/Makefile zsolve/Makefile doc/Makefile omega/Makefile)
544 AC_CONFIG_FILES(parker/Makefile)
545 if test $with_polylib = bundled; then
546 AC_CONFIG_SUBDIRS(polylib)
548 if test $with_piplib = bundled; then
549 AC_CONFIG_SUBDIRS(piplib)
551 if test x$have_ginac = xtrue; then
552 AC_CONFIG_SUBDIRS(bernstein)
554 AC_CONFIG_COMMANDS_POST([
555 dnl pass on arguments to subdir configures, but don't
556 dnl add them to config.status
557 ac_configure_args="$ac_configure_args $bv_configure_args"