2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE(barvinok, 0.33)
16 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
17 if test "$enable_shared" = yes; then
18 BV_LDFLAGS="-no-undefined"
27 AC_CHECK_HEADERS(getopt.h)
28 AC_CHECK_HEADERS(sys/times.h)
29 AC_CHECK_FUNCS(sigaction)
31 AC_MSG_CHECKING(whether to build shared libbarvinok)
32 AC_ARG_ENABLE(shared_barvinok,
33 AS_HELP_STRING([--enable-shared-barvinok],
34 [build shared barvinok library]),
35 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
36 AC_MSG_RESULT($bv_cv_shared_barvinok)
37 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
38 BV_LDFLAGS="$BV_LDFLAGS -static"
43 AC_ARG_WITH(default-prefix,
44 AS_HELP_STRING([--with-default-prefix=DIR],
45 [Default installation prefix of optional packages]))
46 if test "${with_default_prefix+set}" = set; then
47 if test "${with_libgmp+set}" != set -a \
48 -f "$with_default_prefix/include/gmp.h"; then
49 with_libgmp=$with_default_prefix
51 if test "${with_ntl+set}" != set -a \
52 -f "$with_default_prefix/include/NTL/ZZ.h"; then
53 with_ntl=$with_default_prefix
55 if test "${with_cddlib+set}" != set -a \
56 -f "$with_default_prefix/include/cddmp.h"; then
57 with_cddlib=$with_default_prefix
59 if test "${with_glpk+set}" != set -a \
60 -f "$with_default_prefix/include/glpk.h"; then
61 with_glpk=$with_default_prefix
63 if test "${with_topcom+set}" != set -a \
64 -f "$with_default_prefix/bin/points2triangs"; then
65 with_topcom=$with_default_prefix
69 dnl Check for GMP library
70 AC_MSG_CHECKING(whether to use GMP)
72 [ --with-libgmp DIR Location of the GMP Distribution],
73 gmp_package=$withval, gmp_package=yes)
74 if test "x$gmp_package" = "xno"; then
76 AC_MSG_ERROR(Need gmp)
79 if test "x$gmp_package" = "xyes"; then
80 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
82 bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
83 bv_configure_args="$bv_configure_args --with-gmp-prefix=$gmp_package"
85 if test ! -d "$GMP_DIR"; then
86 AC_ERROR(Directory given for GMP Distribution is not a directory)
88 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
89 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
92 AC_CHECK_HEADER(gmp.h,
93 [AC_CHECK_LIB(gmp,main,
95 [poly_cv_gmpfatal="yes"])],
96 [poly_cv_gmpfatal="yes"])
97 if test "$poly_cv_gmpfatal" = "yes"; then
98 AC_MSG_ERROR([GMP not found])
101 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
103 AX_SUBMODULE(polylib,build|bundled|system,bundled)
105 AC_SUBST(POLYLIB_CPPFLAGS)
106 AC_SUBST(POLYLIB_LDFLAGS)
107 AC_SUBST(POLYLIB_LIBS)
108 case "$with_polylib" in
110 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
111 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
114 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
115 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
116 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
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(isl,build|bundled|system,bundled)
138 AC_SUBST(ISL_BUILDDIR)
141 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
142 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
143 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
146 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
147 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
148 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
149 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
152 PKG_CHECK_MODULES([ISL], [isl])
153 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
155 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
156 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
158 AX_SUBMODULE(isl-polylib,build|bundled|system,bundled)
160 AC_SUBST(ISL_POLYLIB_CFLAGS)
161 AC_SUBST(ISL_POLYLIB_LIBS)
162 case "$with_isl_polylib" in
164 ISL_POLYLIB_CFLAGS="-I\$(top_srcdir)/isl-polylib/include -I\$(top_builddir)/isl-polylib/include"
167 ISL_POLYLIB_CFLAGS="-I$isl_polylib_srcdir/include -I$with_isl_polylib_builddir/include"
168 ISL_POLYLIB_LIBS="$with_isl_polylib_builddir/libisl-polylib.la"
171 PKG_CHECK_MODULES([ISL_POLYLIB], [isl-polylib])
173 AM_CONDITIONAL(BUNDLED_ISL_POLYLIB, test $with_isl_polylib = bundled)
175 AC_MSG_CHECKING(if the fractional representation should be used)
176 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
177 [Don't use fractional representation])],
178 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
179 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
180 [Don't use fractional representation])],
181 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
182 AC_MSG_RESULT($bv_cv_modulo)
183 if test "x$bv_cv_modulo" != "xno" ; then
184 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
187 AC_MSG_CHECKING(whether to use incremental algorithm)
188 AC_ARG_ENABLE(incremental,
189 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
190 [Enable incremental algorithm [bf]])],
191 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
192 AC_MSG_RESULT($bv_cv_incremental)
193 case $bv_cv_incremental in
195 AC_DEFINE(USE_INCREMENTAL_BF,[],
196 [Use breadth-first incremental algorithm])
199 AC_DEFINE(USE_INCREMENTAL_DF,[],
200 [Use depth-first incremental algorithm])
205 [ --with-ntl=DIR DIR Location of NTL],
206 [ echo "Package ntl : $withval" && ntl_package=$withval],
209 if test "$ntl_package" = "no"; then
210 AC_MSG_ERROR(Need ntl)
213 AC_SUBST(NTL_CPPFLAGS)
214 AC_SUBST(NTL_LDFLAGS)
215 if test "$ntl_package" != "yes"; then
216 NTL_CPPFLAGS="-I$ntl_package/include"
217 NTL_LDFLAGS="-L$ntl_package/lib"
220 SAVE_CPPFLAGS="$CPPFLAGS"
221 SAVE_LDFLAGS="$LDFLAGS"
222 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
223 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
230 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
233 AC_CHECK_LIB(ntl, main,[],[
234 AC_MSG_ERROR(Need ntl)
236 CPPFLAGS="$SAVE_CPPFLAGS"
237 LDFLAGS="$SAVE_LDFLAGS"
239 AC_SUBST(bv_cone_hilbert_basis)
240 AC_MSG_CHECKING(whether to compile zsolve)
242 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
243 [ with_zsolve=$withval], [ with_zsolve=yes ])
244 AC_MSG_RESULT($with_zsolve)
247 if test "$with_zsolve" != "no"; then
248 if test "$GCC" = "yes"; then
250 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
252 if test $major -gt 3; then
255 if test $major -eq 3 -a $minor -ge 4; then
261 if test "$use_zsolve" = false; then
262 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
264 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
265 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
268 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
270 AX_SUBMODULE(omega,no|bundled|system,no)
272 AC_SUBST(OMEGA_CPPFLAGS)
273 AC_SUBST(OMEGA_LDFLAGS)
275 AC_SUBST(OMEGA_CODEGEN_LIBS)
278 case "$with_omega" in
282 OMEGA_CPPFLAGS="-I\$(top_srcdir)/omega/omega_lib/include"
283 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/basic/include"
284 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/code_gen/include"
285 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/omega_calc/include"
288 if test "x$omega_package" != "xyes"; then
289 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
290 OMEGA_LDFLAGS="-L$omega_package/lib"
292 for i in /usr/include /usr/local/include; do
293 if test -f $i/omega/omega.h; then
294 OMEGA_CPPFLAGS="-I$i/omega"
300 SAVE_CPPFLAGS="$CPPFLAGS"
301 SAVE_LDFLAGS="$LDFLAGS"
302 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
303 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
304 AC_CHECK_HEADERS([omega.h],[
306 AC_CHECK_LIB(code_gen,main,[
307 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
311 ],[AC_MSG_WARN(Omega not found)])
312 CPPFLAGS="$SAVE_CPPFLAGS"
313 LDFLAGS="$SAVE_LDFLAGS"
317 if test "$have_omega" = true; then
318 AC_DEFINE(HAVE_OMEGA,[],[use omega])
320 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
321 AM_CONDITIONAL(BUNDLED_OMEGA, test $with_omega = bundled)
324 AC_MSG_CHECKING(whether to compile parker)
326 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
327 [ with_parker=$withval], [ with_parker=yes ])
328 AC_MSG_RESULT($with_parker)
330 if test "$with_parker" != "no"; then
331 AC_MSG_CHECKING(for mona)
333 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
334 [], [AC_MSG_RESULT(not specified)])
336 if test "x$with_mona" != "x"; then
339 AC_MSG_RESULT($MONAPATH)
341 AC_DEFINE(USE_PARKER,[],[use parker])
344 if test "x$with_mona" = "x"; then
345 AC_MSG_WARN(mona source directory required to compile parker)
346 AC_MSG_WARN(http://www.brics.dk/mona/download)
349 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
351 AC_MSG_CHECKING(whether to use cddlib)
352 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
353 [ cddlib_package=$withval], [ cddlib_package=yes ])
354 AC_MSG_RESULT($cddlib_package)
357 if test "$cddlib_package" != "no"; then
358 if test "x$cddlib_package" != "xyes"; then
359 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
360 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
370 AC_CHECK_LIB(cddgmp, main,[
372 LIBS="-lcddgmp $LIBS"
373 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
375 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
379 const char *filename = SRCDIR"/cdd94e-test";
383 dd_ErrorType err = dd_NoError;
385 dd_set_global_constants();
387 f = fopen(filename, "r");
388 M = dd_PolyFile2Matrix(f, &err);
389 lp = dd_Matrix2LP(M, &err);
390 dd_LPSolve(lp, dd_DualSimplex, &err);
391 return lp->LPS == dd_Inconsistent;
393 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
395 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
400 ],[have_cddlib=false])
403 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
407 AC_MSG_CHECKING(whether to use GLPK)
408 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
409 [ glpk_package=$withval], [ glpk_package=yes ])
410 AC_MSG_RESULT($glpk_package)
413 if test "$glpk_package" != "no"; then
414 if test "x$glpk_package" != "xyes"; then
415 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
416 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
418 AC_CHECK_HEADERS([glpk.h],[
420 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
423 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
425 AC_MSG_CHECKING(location of TOPCOM)
426 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
427 [topcom_package=$withval], [topcom_package=unspecified])
428 AC_MSG_RESULT($topcom_package)
430 if test "$topcom_package" != no; then
432 if test "$topcom_package" != unspecified; then
433 topcom_path="$topcom_package/bin"
435 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
436 if test -n "$POINTS2TRIANGS"; then
438 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
439 [Path of points2triangs])
442 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
444 AX_SUBMODULE(cloog,no|build|system,no)
446 AC_SUBST(CLOOG_LDFLAGS)
447 AC_SUBST(CLOOG_CFLAGS)
449 CLOOG_CFLAGS="-DCLOOG_INT_GMP=1"
450 case "$with_cloog" in
452 with_cloog_builddir=`echo @abs_builddir@ | $with_cloog_builddir/config.status --file=-`
453 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$cloog_srcdir/include -I$with_cloog_builddir/include"
454 CLOOG_LIBS="$with_cloog_builddir/libcloog-isl.la"
455 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
458 if test "x$with_cloog_prefix" != "x"; then
459 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$with_cloog_prefix/include"
461 if test "x$with_cloog_exec_prefix" != "x"; then
462 CLOOG_LDFLAGS="-L$with_cloog_exec_prefix/lib"
464 CLOOG_LIBS="-lcloog-isl"
465 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
468 AC_SUBST(GIT_HEAD_ID)
470 AC_SUBST(GIT_HEAD_VERSION)
471 if test -f $srcdir/.git/HEAD; then
472 GIT_HEAD="$srcdir/.git/index"
473 GIT_REPO="$srcdir/.git"
474 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
475 elif test -f $srcdir/GIT_HEAD_ID; then
476 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
478 mysrcdir=`(cd $srcdir; pwd)`
479 head=`basename $mysrcdir | sed -e 's/.*-//'`
480 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
481 head3=`echo $head2 | sed -e 's/........................................//'`
482 base=`basename $mysrcdir | sed -e 's/-.*//'`
483 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
484 GIT_HEAD_ID="barvinok-$VERSION-$head
485 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
486 GIT_HEAD_ID="barvinok-$VERSION-$head
488 GIT_HEAD_ID="UNKNOWN"
491 if test -z "$GIT_REPO" ; then
492 GIT_HEAD_VERSION="$GIT_HEAD_ID"
494 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
496 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
503 suffix="normal", suffix="broken")
504 AC_CONFIG_COMMANDS([barvinok/set.h],
505 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
507 AC_CONFIG_COMMANDS([barvinok/NTL.h],
508 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
511 SAVE_CPPFLAGS="$CPPFLAGS"
512 CPPFLAGS="-I$srcdir $CPPFLAGS"
513 AC_TRY_COMPILE([#include "fdstream.h"],[],
514 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
516 CPPFLAGS="$SAVE_CPPFLAGS"
518 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
520 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
521 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lisl-polylib -lpolylibgmp -lisl"
522 AX_CREATE_PKGCONFIG_INFO
524 AC_CONFIG_HEADERS(config.h)
525 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
526 AC_CONFIG_FILES(parker/Makefile)
527 if test $with_polylib = bundled; then
528 AC_CONFIG_SUBDIRS(polylib)
530 if test $with_isl = bundled; then
531 AC_CONFIG_SUBDIRS(isl)
533 if test $with_isl_polylib = bundled; then
534 AC_CONFIG_SUBDIRS(isl-polylib)
536 if test $with_omega = bundled; then
537 AC_CONFIG_SUBDIRS(omega)
539 AC_CONFIG_COMMANDS_POST([
540 dnl pass on arguments to subdir configures, but don't
541 dnl add them to config.status
542 ac_configure_args="$ac_configure_args $bv_configure_args"