2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE(barvinok, 0.32.1)
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)
30 AC_MSG_CHECKING(whether to build shared libbarvinok)
31 AC_ARG_ENABLE(shared_barvinok,
32 AS_HELP_STRING([--enable-shared-barvinok],
33 [build shared barvinok library]),
34 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
35 AC_MSG_RESULT($bv_cv_shared_barvinok)
36 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
37 BV_LDFLAGS="$BV_LDFLAGS -static"
42 AC_ARG_WITH(default-prefix,
43 AS_HELP_STRING([--with-default-prefix=DIR],
44 [Default installation prefix of optional packages]))
45 if test "${with_default_prefix+set}" = set; then
46 if test "${with_libgmp+set}" != set -a \
47 -f "$with_default_prefix/include/gmp.h"; then
48 with_libgmp=$with_default_prefix
50 if test "${with_ntl+set}" != set -a \
51 -f "$with_default_prefix/include/NTL/ZZ.h"; then
52 with_ntl=$with_default_prefix
54 if test "${with_cddlib+set}" != set -a \
55 -f "$with_default_prefix/include/cddmp.h"; then
56 with_cddlib=$with_default_prefix
58 if test "${with_glpk+set}" != set -a \
59 -f "$with_default_prefix/include/glpk.h"; then
60 with_glpk=$with_default_prefix
62 if test "${with_topcom+set}" != set -a \
63 -f "$with_default_prefix/bin/points2triangs"; then
64 with_topcom=$with_default_prefix
68 dnl Check for GMP library
69 AC_MSG_CHECKING(whether to use GMP)
71 [ --with-libgmp DIR Location of the GMP Distribution],
72 gmp_package=$withval, gmp_package=yes)
73 if test "x$gmp_package" = "xno"; then
75 AC_MSG_ERROR(Need gmp)
78 if test "x$gmp_package" = "xyes"; then
79 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
81 bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
82 bv_configure_args="$bv_configure_args --with-gmp-prefix=$gmp_package"
84 if test ! -d "$GMP_DIR"; then
85 AC_ERROR(Directory given for GMP Distribution is not a directory)
87 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
88 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
91 AC_CHECK_HEADER(gmp.h,
92 [AC_CHECK_LIB(gmp,main,
94 [poly_cv_gmpfatal="yes"])],
95 [poly_cv_gmpfatal="yes"])
96 if test "$poly_cv_gmpfatal" = "yes"; then
97 AC_MSG_ERROR([GMP not found])
100 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
102 AX_SUBMODULE(polylib,build|bundled|system,bundled)
104 AC_SUBST(POLYLIB_CPPFLAGS)
105 AC_SUBST(POLYLIB_LDFLAGS)
106 AC_SUBST(POLYLIB_LIBS)
107 case "$with_polylib" in
109 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
110 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
113 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
114 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
115 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
118 POLYLIB_LIBS="-lpolylibgmp"
119 if test "x$with_polylib_prefix" != "x"; then
120 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
121 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
123 SAVE_CPPFLAGS="$CPPFLAGS"
124 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
125 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
126 AC_MSG_ERROR(Need PolyLib)
128 CPPFLAGS="$SAVE_CPPFLAGS"
131 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
133 AX_SUBMODULE(piplib,no|bundled|system,bundled)
135 AC_SUBST(PIPLIB_CPPFLAGS)
136 AC_SUBST(PIPLIB_LDFLAGS)
137 AC_SUBST(PIPLIB_LIBS)
139 case "$with_piplib" in
142 bv_configure_args="$bv_configure_args --with-piplib-builddir=../piplib"
143 bv_configure_args="$bv_configure_args --with-bits=gmp"
144 PIPLIB_CPPFLAGS="-I$srcdir/piplib/include"
147 PIPLIB_LIBS="-lpiplibMP"
148 if test "x$with_piplib_prefix" != "x"; then
149 PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
150 PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
152 SAVE_CPPFLAGS="$CPPFLAGS"
153 SAVE_LDFLAGS="$LDFLAGS"
154 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
155 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
156 AC_CHECK_LIB(piplibMP, pip_solve,[
157 AC_CHECK_MEMBER(PipOptions.Urs_parms, [have_piplib=true], [
158 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
159 ],[#include <stdio.h>
160 #include <piplib/piplibMP.h>])
162 AC_MSG_WARN([Piplib not found])
164 CPPFLAGS="$SAVE_CPPFLAGS"
165 LDFLAGS="$SAVE_LDFLAGS"
168 if test "$have_piplib" = true; then
169 AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
171 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
172 AM_CONDITIONAL(BUNDLED_PIPLIB, test $with_piplib = bundled)
174 AX_SUBMODULE(isl,build|bundled|system,bundled)
178 AC_SUBST(ISL_BUILDDIR)
181 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
182 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
183 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
186 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
187 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
188 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
189 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
192 PKG_CHECK_MODULES([ISL], [isl])
193 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
195 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
196 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
198 AX_SUBMODULE(isl-polylib,build|bundled|system,bundled)
200 AC_SUBST(ISL_POLYLIB_CFLAGS)
201 AC_SUBST(ISL_POLYLIB_LIBS)
202 case "$with_isl_polylib" in
204 ISL_POLYLIB_CFLAGS="-I\$(top_srcdir)/isl-polylib/include -I\$(top_builddir)/isl-polylib/include"
207 ISL_POLYLIB_CFLAGS="-I$isl_polylib_srcdir/include -I$with_isl_polylib_builddir/include"
208 ISL_POLYLIB_LIBS="$with_isl_polylib_builddir/libisl-polylib.la"
211 PKG_CHECK_MODULES([ISL_POLYLIB], [isl-polylib])
213 AM_CONDITIONAL(BUNDLED_ISL_POLYLIB, test $with_isl_polylib = bundled)
215 AC_MSG_CHECKING(if the fractional representation should be used)
216 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
217 [Don't use fractional representation])],
218 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
219 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
220 [Don't use fractional representation])],
221 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
222 AC_MSG_RESULT($bv_cv_modulo)
223 if test "x$bv_cv_modulo" != "xno" ; then
224 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
227 AC_MSG_CHECKING(whether to use incremental algorithm)
228 AC_ARG_ENABLE(incremental,
229 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
230 [Enable incremental algorithm [bf]])],
231 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
232 AC_MSG_RESULT($bv_cv_incremental)
233 case $bv_cv_incremental in
235 AC_DEFINE(USE_INCREMENTAL_BF,[],
236 [Use breadth-first incremental algorithm])
239 AC_DEFINE(USE_INCREMENTAL_DF,[],
240 [Use depth-first incremental algorithm])
245 [ --with-ntl=DIR DIR Location of NTL],
246 [ echo "Package ntl : $withval" && ntl_package=$withval],
249 if test "$ntl_package" = "no"; then
250 AC_MSG_ERROR(Need ntl)
253 AC_SUBST(NTL_CPPFLAGS)
254 AC_SUBST(NTL_LDFLAGS)
255 if test "$ntl_package" != "yes"; then
256 NTL_CPPFLAGS="-I$ntl_package/include"
257 NTL_LDFLAGS="-L$ntl_package/lib"
260 SAVE_CPPFLAGS="$CPPFLAGS"
261 SAVE_LDFLAGS="$LDFLAGS"
262 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
263 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
270 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
273 AC_CHECK_LIB(ntl, main,[],[
274 AC_MSG_ERROR(Need ntl)
276 CPPFLAGS="$SAVE_CPPFLAGS"
277 LDFLAGS="$SAVE_LDFLAGS"
279 AC_SUBST(bv_cone_hilbert_basis)
280 AC_MSG_CHECKING(whether to compile zsolve)
282 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
283 [ with_zsolve=$withval], [ with_zsolve=yes ])
284 AC_MSG_RESULT($with_zsolve)
287 if test "$with_zsolve" != "no"; then
288 if test "$GCC" = "yes"; then
290 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
292 if test $major -gt 3; then
295 if test $major -eq 3 -a $minor -ge 4; then
301 if test "$use_zsolve" = false; then
302 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
304 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
305 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
308 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
310 AX_SUBMODULE(omega,no|bundled|system,no)
312 AC_SUBST(OMEGA_CPPFLAGS)
313 AC_SUBST(OMEGA_LDFLAGS)
315 AC_SUBST(OMEGA_CODEGEN_LIBS)
318 case "$with_omega" in
322 OMEGA_CPPFLAGS="-I\$(top_srcdir)/omega/omega_lib/include"
323 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/basic/include"
324 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/code_gen/include"
325 OMEGA_CPPFLAGS="$OMEGA_CPPFLAGS -I\$(top_srcdir)/omega/omega_calc/include"
328 if test "x$omega_package" != "xyes"; then
329 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
330 OMEGA_LDFLAGS="-L$omega_package/lib"
332 for i in /usr/include /usr/local/include; do
333 if test -f $i/omega/omega.h; then
334 OMEGA_CPPFLAGS="-I$i/omega"
340 SAVE_CPPFLAGS="$CPPFLAGS"
341 SAVE_LDFLAGS="$LDFLAGS"
342 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
343 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
344 AC_CHECK_HEADERS([omega.h],[
346 AC_CHECK_LIB(code_gen,main,[
347 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
351 ],[AC_MSG_WARN(Omega not found)])
352 CPPFLAGS="$SAVE_CPPFLAGS"
353 LDFLAGS="$SAVE_LDFLAGS"
357 if test "$have_omega" = true; then
358 AC_DEFINE(HAVE_OMEGA,[],[use omega])
360 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
361 AM_CONDITIONAL(BUNDLED_OMEGA, test $with_omega = bundled)
364 AC_MSG_CHECKING(whether to compile parker)
366 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
367 [ with_parker=$withval], [ with_parker=yes ])
368 AC_MSG_RESULT($with_parker)
370 if test "$with_parker" != "no"; then
371 AC_MSG_CHECKING(for mona)
373 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
374 [], [AC_MSG_RESULT(not specified)])
376 if test "x$with_mona" != "x"; then
379 AC_MSG_RESULT($MONAPATH)
381 AC_DEFINE(USE_PARKER,[],[use parker])
384 if test "x$with_mona" = "x"; then
385 AC_MSG_WARN(mona source directory required to compile parker)
386 AC_MSG_WARN(http://www.brics.dk/mona/download)
389 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
391 AC_MSG_CHECKING(whether to use cddlib)
392 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
393 [ cddlib_package=$withval], [ cddlib_package=yes ])
394 AC_MSG_RESULT($cddlib_package)
397 if test "$cddlib_package" != "no"; then
398 if test "x$cddlib_package" != "xyes"; then
399 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
400 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
410 AC_CHECK_LIB(cddgmp, main,[
412 LIBS="-lcddgmp $LIBS"
413 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
415 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
419 const char *filename = SRCDIR"/cdd94e-test";
423 dd_ErrorType err = dd_NoError;
425 dd_set_global_constants();
427 f = fopen(filename, "r");
428 M = dd_PolyFile2Matrix(f, &err);
429 lp = dd_Matrix2LP(M, &err);
430 dd_LPSolve(lp, dd_DualSimplex, &err);
431 return lp->LPS == dd_Inconsistent;
433 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
435 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
440 ],[have_cddlib=false])
443 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
447 AC_MSG_CHECKING(whether to use GLPK)
448 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
449 [ glpk_package=$withval], [ glpk_package=yes ])
450 AC_MSG_RESULT($glpk_package)
453 if test "$glpk_package" != "no"; then
454 if test "x$glpk_package" != "xyes"; then
455 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
456 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
458 AC_CHECK_HEADERS([glpk.h],[
460 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
463 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
465 AC_MSG_CHECKING(location of TOPCOM)
466 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
467 [topcom_package=$withval], [topcom_package=unspecified])
468 AC_MSG_RESULT($topcom_package)
470 if test "$topcom_package" != no; then
472 if test "$topcom_package" != unspecified; then
473 topcom_path="$topcom_package/bin"
475 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
476 if test -n "$POINTS2TRIANGS"; then
478 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
479 [Path of points2triangs])
482 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
484 AX_SUBMODULE(cloog,no|build|system,no)
486 AC_SUBST(CLOOG_LDFLAGS)
487 AC_SUBST(CLOOG_CFLAGS)
489 CLOOG_CFLAGS="-DCLOOG_INT_GMP=1"
490 case "$with_cloog" in
492 with_cloog_builddir=`echo @abs_builddir@ | $with_cloog_builddir/config.status --file=-`
493 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$cloog_srcdir/include -I$with_cloog_builddir/include"
494 CLOOG_LIBS="$with_cloog_builddir/libcloog-isl.la"
495 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
498 if test "x$with_cloog_prefix" != "x"; then
499 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$with_cloog_prefix/include"
501 if test "x$with_cloog_exec_prefix" != "x"; then
502 CLOOG_LDFLAGS="-L$with_cloog_exec_prefix/lib"
504 CLOOG_LIBS="-lcloog-isl"
505 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
508 AC_SUBST(GIT_HEAD_ID)
510 AC_SUBST(GIT_HEAD_VERSION)
511 if test -f $srcdir/.git/HEAD; then
512 GIT_HEAD="$srcdir/.git/index"
513 GIT_REPO="$srcdir/.git"
514 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
515 elif test -f $srcdir/GIT_HEAD_ID; then
516 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
518 mysrcdir=`(cd $srcdir; pwd)`
519 head=`basename $mysrcdir | sed -e 's/.*-//'`
520 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
521 head3=`echo $head2 | sed -e 's/........................................//'`
522 base=`basename $mysrcdir | sed -e 's/-.*//'`
523 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
524 GIT_HEAD_ID="barvinok-$VERSION-$head
525 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
526 GIT_HEAD_ID="barvinok-$VERSION-$head
528 GIT_HEAD_ID="UNKNOWN"
531 if test -z "$GIT_REPO" ; then
532 GIT_HEAD_VERSION="$GIT_HEAD_ID"
534 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
536 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
543 suffix="normal", suffix="broken")
544 AC_CONFIG_COMMANDS([barvinok/set.h],
545 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
547 AC_CONFIG_COMMANDS([barvinok/NTL.h],
548 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
551 SAVE_CPPFLAGS="$CPPFLAGS"
552 CPPFLAGS="-I$srcdir $CPPFLAGS"
553 AC_TRY_COMPILE([#include "fdstream.h"],[],
554 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
556 CPPFLAGS="$SAVE_CPPFLAGS"
558 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
560 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
561 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lisl-polylib -lpolylibgmp -lpiplibMP -lisl"
562 AX_CREATE_PKGCONFIG_INFO
564 AC_CONFIG_HEADERS(config.h)
565 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
566 AC_CONFIG_FILES(parker/Makefile)
567 if test $with_polylib = bundled; then
568 AC_CONFIG_SUBDIRS(polylib)
570 if test $with_piplib = bundled; then
571 AC_CONFIG_SUBDIRS(piplib)
573 if test $with_isl = bundled; then
574 AC_CONFIG_SUBDIRS(isl)
576 if test $with_isl_polylib = bundled; then
577 AC_CONFIG_SUBDIRS(isl-polylib)
579 if test $with_omega = bundled; then
580 AC_CONFIG_SUBDIRS(omega)
582 AC_CONFIG_COMMANDS_POST([
583 dnl pass on arguments to subdir configures, but don't
584 dnl add them to config.status
585 ac_configure_args="$ac_configure_args $bv_configure_args"