2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE(barvinok, 0.30)
17 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
18 if test "$enable_shared" = yes; then
19 BV_LDFLAGS="-no-undefined"
26 gl_MODULES(argp progname)
31 AC_CHECK_HEADERS(getopt.h)
32 AC_CHECK_HEADERS(sys/times.h)
34 AC_MSG_CHECKING(whether to build shared libbarvinok)
35 AC_ARG_ENABLE(shared_barvinok,
36 AS_HELP_STRING([--enable-shared-barvinok],
37 [build shared barvinok library]),
38 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
39 AC_MSG_RESULT($bv_cv_shared_barvinok)
40 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
41 BV_LDFLAGS="$BV_LDFLAGS -static"
46 AC_ARG_WITH(default-prefix,
47 AS_HELP_STRING([--with-default-prefix=DIR],
48 [Default installation prefix of optional packages]))
49 if test "${with_default_prefix+set}" = set; then
50 if test "${with_ginac_prefix+set}" != set -a \
51 -f "$with_default_prefix/lib/pkgconfig/ginac.pc"; then
52 with_ginac_prefix=$with_default_prefix
54 if test "${with_libgmp+set}" != set -a \
55 -f "$with_default_prefix/include/gmp.h"; then
56 with_libgmp=$with_default_prefix
58 if test "${with_ntl+set}" != set -a \
59 -f "$with_default_prefix/include/NTL/ZZ.h"; then
60 with_ntl=$with_default_prefix
62 if test "${with_cddlib+set}" != set -a \
63 -f "$with_default_prefix/include/cddmp.h"; then
64 with_cddlib=$with_default_prefix
66 if test "${with_glpk+set}" != set -a \
67 -f "$with_default_prefix/include/glpk.h"; then
68 with_glpk=$with_default_prefix
70 if test "${with_topcom+set}" != set -a \
71 -f "$with_default_prefix/bin/points2triangs"; then
72 with_topcom=$with_default_prefix
76 dnl Check for GMP library
77 AC_MSG_CHECKING(whether to use GMP)
79 [ --with-libgmp DIR Location of the GMP Distribution],
80 gmp_package=$withval, gmp_package=yes)
81 if test "x$gmp_package" = "xno"; then
83 AC_MSG_ERROR(Need gmp)
86 if test "x$gmp_package" = "xyes"; then
87 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
89 bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
90 bv_configure_args="$bv_configure_args --with-gmp-prefix=$gmp_package"
92 if test ! -d "$GMP_DIR"; then
93 AC_ERROR(Directory given for GMP Distribution is not a directory)
95 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
96 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
99 AC_CHECK_HEADER(gmp.h,
100 [AC_CHECK_LIB(gmp,main,
102 [poly_cv_gmpfatal="yes"])],
103 [poly_cv_gmpfatal="yes"])
104 if test "$poly_cv_gmpfatal" = "yes"; then
105 AC_MSG_ERROR([GMP not found])
108 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
110 AX_SUBMODULE(polylib,bundled|system,bundled)
112 AC_SUBST(POLYLIB_CPPFLAGS)
113 AC_SUBST(POLYLIB_LDFLAGS)
114 AC_SUBST(POLYLIB_LIBS)
115 if test "$with_polylib" = "bundled"; then
116 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
117 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
119 POLYLIB_LIBS="-lpolylibgmp"
120 if test "x$with_polylib_prefix" != "x"; then
121 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
122 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
124 SAVE_CPPFLAGS="$CPPFLAGS"
125 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
126 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
127 AC_MSG_ERROR(Need PolyLib)
129 CPPFLAGS="$SAVE_CPPFLAGS"
132 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
134 AX_SUBMODULE(piplib,bundled|system,bundled)
136 AC_SUBST(PIPLIB_CPPFLAGS)
137 AC_SUBST(PIPLIB_LDFLAGS)
138 AC_SUBST(PIPLIB_LIBS)
139 if test "$with_piplib" = "bundled"; then
140 bv_configure_args="$bv_configure_args --with-piplib-builddir=../piplib"
141 bv_configure_args="$bv_configure_args --with-bits=gmp"
142 PIPLIB_CPPFLAGS="-I$srcdir/piplib/include"
144 PIPLIB_LIBS="-lpiplibMP"
145 if test "x$with_piplib_prefix" != "x"; then
146 PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
147 PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
149 SAVE_CPPFLAGS="$CPPFLAGS"
150 SAVE_LDFLAGS="$LDFLAGS"
151 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
152 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
153 AC_CHECK_LIB(piplibMP, pip_solve,[
154 AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
155 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
156 ],[#include <stdio.h>
157 #include <piplib/piplibMP.h>])
159 AC_MSG_ERROR([Piplib not found])
161 CPPFLAGS="$SAVE_CPPFLAGS"
162 LDFLAGS="$SAVE_LDFLAGS"
164 AM_CONDITIONAL(BUNDLED_PIPLIB, test $with_piplib = bundled)
166 AX_SUBMODULE(isl,build|bundled|system,bundled)
172 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
173 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
176 with_isl_builddir=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
177 ISL_CFLAGS="-I$isl_srcdir/include -I$with_isl_builddir/include"
178 ISL_LIBS="$with_isl_builddir/libisl.la"
181 PKG_CHECK_MODULES([ISL], [isl])
183 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
185 AX_SUBMODULE(isl-polylib,build|bundled|system,bundled)
187 AC_SUBST(ISL_POLYLIB_CFLAGS)
188 AC_SUBST(ISL_POLYLIB_LIBS)
189 case "$with_isl_polylib" in
191 ISL_POLYLIB_CFLAGS="-I\$(top_srcdir)/isl-polylib/include -I\$(top_builddir)/isl-polylib/include"
194 ISL_POLYLIB_CFLAGS="-I$isl_polylib_srcdir/include -I$with_isl_polylib_builddir/include"
195 ISL_POLYLIB_LIBS="$with_isl_polylib_builddir/libisl-polylib.la"
198 PKG_CHECK_MODULES([ISL_POLYLIB], [isl-polylib])
200 AM_CONDITIONAL(BUNDLED_ISL_POLYLIB, test $with_isl_polylib = bundled)
202 AC_MSG_CHECKING(if the fractional representation should be used)
203 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
204 [Don't use fractional representation])],
205 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
206 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
207 [Don't use fractional representation])],
208 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
209 AC_MSG_RESULT($bv_cv_modulo)
210 if test "x$bv_cv_modulo" != "xno" ; then
211 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
214 AC_MSG_CHECKING(whether to use incremental algorithm)
215 AC_ARG_ENABLE(incremental,
216 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
217 [Enable incremental algorithm [bf]])],
218 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
219 AC_MSG_RESULT($bv_cv_incremental)
220 case $bv_cv_incremental in
222 AC_DEFINE(USE_INCREMENTAL_BF,[],
223 [Use breadth-first incremental algorithm])
226 AC_DEFINE(USE_INCREMENTAL_DF,[],
227 [Use depth-first incremental algorithm])
232 [ --with-ntl=DIR DIR Location of NTL],
233 [ echo "Package ntl : $withval" && ntl_package=$withval],
236 if test "$ntl_package" = "no"; then
237 AC_MSG_ERROR(Need ntl)
240 AC_SUBST(NTL_CPPFLAGS)
241 AC_SUBST(NTL_LDFLAGS)
242 if test "$ntl_package" != "yes"; then
243 NTL_CPPFLAGS="-I$ntl_package/include"
244 NTL_LDFLAGS="-L$ntl_package/lib"
247 SAVE_CPPFLAGS="$CPPFLAGS"
248 SAVE_LDFLAGS="$LDFLAGS"
249 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
250 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
256 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
258 AC_CHECK_LIB(ntl, main,[],[
259 AC_MSG_ERROR(Need ntl)
261 CPPFLAGS="$SAVE_CPPFLAGS"
262 LDFLAGS="$SAVE_LDFLAGS"
264 AC_SUBST(bv_cone_hilbert_basis)
265 AC_MSG_CHECKING(whether to compile zsolve)
266 AC_ARG_WITH(bernstein,
267 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
268 [ with_zsolve=$withval], [ with_zsolve=yes ])
269 AC_MSG_RESULT($with_zsolve)
272 if test "$with_zsolve" != "no"; then
273 if test "$GCC" = "yes"; then
275 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
277 if test $major -gt 3; then
280 if test $major -eq 3 -a $minor -ge 4; then
286 if test "$use_zsolve" = false; then
287 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
289 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
290 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
293 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
295 AC_MSG_CHECKING(whether to compile bernstein)
296 AC_ARG_WITH(bernstein,
297 [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
298 [ with_bernstein=$withval], [ with_bernstein=yes ])
299 AC_MSG_RESULT($with_bernstein)
301 AC_ARG_WITH(ginac_prefix,
302 [AS_HELP_STRING([--with-ginac-prefix=DIR],[Installation prefix of GiNaC])])
303 if test "x$with_ginac_prefix" != "x"; then
304 export PKG_CONFIG_PATH="$with_ginac_prefix/lib/pkgconfig${PKG_CONFIG_PATH+:$PKG_CONFIG_PATH}"
307 AC_SUBST(bv_barvinok_bound)
309 if test "$with_bernstein" != "no"; then
310 PKG_CHECK_EXISTS([ginac], [
311 PKG_CHECK_MODULES(ginac, ginac)
313 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
314 EXTRA_PACKAGE_LIBS="-lbernstein $EXTRA_PACKAGE_LIBS"
315 bv_barvinok_bound="barvinok_bound\$(EXEEXT) test_bound\$(EXEEXT)"
318 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
320 AX_SUBMODULE(omega,no|bundled|system,bundled)
322 AC_SUBST(OMEGA_CPPFLAGS)
323 AC_SUBST(OMEGA_LDFLAGS)
325 AC_SUBST(OMEGA_CODEGEN_LIBS)
326 AC_SUBST(bv_omega_programs)
329 case "$with_omega" in
333 OMEGA_CPPFLAGS="-I\$(top_srcdir)/omega/omega_lib/include"
334 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/basic/include"
335 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/code_gen/include"
336 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/omega_calc/include"
339 if test "x$omega_package" != "xyes"; then
340 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
341 OMEGA_LDFLAGS="-L$omega_package/lib"
343 for i in /usr/include /usr/local/include; do
344 if test -f $i/omega/omega.h; then
345 OMEGA_CPPFLAGS="-I$i/omega"
351 SAVE_CPPFLAGS="$CPPFLAGS"
352 SAVE_LDFLAGS="$LDFLAGS"
353 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
354 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
355 AC_CHECK_HEADERS([omega.h],[
357 AC_CHECK_LIB(code_gen,main,[
358 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
362 ],[AC_MSG_WARN(Omega not found)])
363 CPPFLAGS="$SAVE_CPPFLAGS"
364 LDFLAGS="$SAVE_LDFLAGS"
368 if test "$have_omega" = true; then
369 AC_DEFINE(HAVE_OMEGA,[],[use omega])
371 if test "$have_codegen" = true -a x$have_ginac = xtrue; then
372 AC_CHECK_HEADERS([sys/resource.h], [],
373 [AC_DEFINE([OMIT_GETRUSAGE], [], [Don't use getrusage in occ])])
374 bv_omega_programs="occ\$(EXEEXT) $bv_omega_programs"
376 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
377 AM_CONDITIONAL(BUNDLED_OMEGA, test $with_omega = bundled)
380 AC_MSG_CHECKING(whether to compile parker)
382 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
383 [ with_parker=$withval], [ with_parker=yes ])
384 AC_MSG_RESULT($with_parker)
386 if test "$with_parker" != "no"; then
387 AC_MSG_CHECKING(for mona)
389 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
390 [], [AC_MSG_RESULT(not specified)])
392 if test "x$with_mona" != "x"; then
395 AC_MSG_RESULT($MONAPATH)
397 AC_DEFINE(USE_PARKER,[],[use parker])
400 if test "x$with_mona" = "x"; then
401 AC_MSG_WARN(mona source directory required to compile parker)
402 AC_MSG_WARN(http://www.brics.dk/mona/download)
405 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
407 AC_MSG_CHECKING(whether to use cddlib)
408 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
409 [ cddlib_package=$withval], [ cddlib_package=yes ])
410 AC_MSG_RESULT($cddlib_package)
413 if test "$cddlib_package" != "no"; then
414 if test "x$cddlib_package" != "xyes"; then
415 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
416 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
426 AC_CHECK_LIB(cddgmp, main,[
428 LIBS="-lcddgmp $LIBS"
429 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
431 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
435 const char *filename = SRCDIR"/cdd94e-test";
439 dd_ErrorType err = dd_NoError;
441 dd_set_global_constants();
443 f = fopen(filename, "r");
444 M = dd_PolyFile2Matrix(f, &err);
445 lp = dd_Matrix2LP(M, &err);
446 dd_LPSolve(lp, dd_DualSimplex, &err);
447 return lp->LPS == dd_Inconsistent;
449 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
451 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
456 ],[have_cddlib=false])
459 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
463 AC_MSG_CHECKING(whether to use GLPK)
464 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
465 [ glpk_package=$withval], [ glpk_package=yes ])
466 AC_MSG_RESULT($glpk_package)
469 if test "$glpk_package" != "no"; then
470 if test "x$glpk_package" != "xyes"; then
471 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
472 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
474 AC_CHECK_HEADERS([glpk.h],[
476 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
479 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
481 AC_MSG_CHECKING(location of TOPCOM)
482 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
483 [topcom_package=$withval], [topcom_package=unspecified])
484 AC_MSG_RESULT($topcom_package)
486 if test "$topcom_package" != no; then
488 if test "$topcom_package" != unspecified; then
489 topcom_path="$topcom_package/bin"
491 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
492 if test -n "$POINTS2TRIANGS"; then
494 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
495 [Path of points2triangs])
498 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
500 AC_SUBST(GIT_HEAD_ID)
502 AC_SUBST(GIT_HEAD_VERSION)
503 if test -f $srcdir/.git/HEAD; then
504 GIT_HEAD="$srcdir/.git/index"
505 GIT_REPO="$srcdir/.git"
506 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
507 elif test -f $srcdir/GIT_HEAD_ID; then
508 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
510 mysrcdir=`(cd $srcdir; pwd)`
511 head=`basename $mysrcdir | sed -e 's/.*-//'`
512 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
513 head3=`echo $head2 | sed -e 's/........................................//'`
514 base=`basename $mysrcdir | sed -e 's/-.*//'`
515 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
516 GIT_HEAD_ID="barvinok-$VERSION-$head
517 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
518 GIT_HEAD_ID="barvinok-$VERSION-$head
520 GIT_HEAD_ID="UNKNOWN"
523 if test -z "$GIT_REPO" ; then
524 GIT_HEAD_VERSION="$GIT_HEAD_ID"
526 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
528 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
535 suffix="normal", suffix="broken")
536 AC_CONFIG_COMMANDS([barvinok/set.h],
537 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
539 AC_CONFIG_COMMANDS([barvinok/NTL.h],
540 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
543 SAVE_CPPFLAGS="$CPPFLAGS"
544 CPPFLAGS="-I$srcdir $CPPFLAGS"
545 AC_TRY_COMPILE([#include "fdstream.h"],[],
546 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
548 CPPFLAGS="$SAVE_CPPFLAGS"
550 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
552 PACKAGE_LIBS="-lbarvinok -lbarvinok-core $EXTRA_PACKAGE_LIBS -lpolylibgmp -lpiplibMP"
553 AX_CREATE_PKGCONFIG_INFO
555 AC_CONFIG_HEADERS(config.h)
556 AC_CONFIG_FILES(Makefile lib/Makefile zsolve/Makefile doc/Makefile)
557 AC_CONFIG_FILES(omega_interface/Makefile)
558 AC_CONFIG_FILES(parker/Makefile)
559 if test $with_polylib = bundled; then
560 AC_CONFIG_SUBDIRS(polylib)
562 if test $with_piplib = bundled; then
563 AC_CONFIG_SUBDIRS(piplib)
565 if test $with_isl = bundled; then
566 AC_CONFIG_SUBDIRS(isl)
568 if test $with_isl_polylib = bundled; then
569 AC_CONFIG_SUBDIRS(isl-polylib)
571 if test x$have_ginac = xtrue; then
572 AC_CONFIG_SUBDIRS(bernstein)
574 if test $with_omega = bundled; then
575 AC_CONFIG_SUBDIRS(omega)
577 AC_CONFIG_COMMANDS_POST([
578 dnl pass on arguments to subdir configures, but don't
579 dnl add them to config.status
580 ac_configure_args="$ac_configure_args $bv_configure_args"