1 AC_INIT([barvinok], [0.34], [isl-development@googlegroups.com])
2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE([foreign])
4 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
17 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
18 if test "$enable_shared" = yes; then
19 BV_LDFLAGS="-no-undefined"
28 AC_CHECK_HEADERS(getopt.h)
29 AC_CHECK_HEADERS(sys/times.h)
30 AC_CHECK_FUNCS(sigaction)
32 AC_MSG_CHECKING(whether to build shared libbarvinok)
33 AC_ARG_ENABLE(shared_barvinok,
34 AS_HELP_STRING([--enable-shared-barvinok],
35 [build shared barvinok library]),
36 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
37 AC_MSG_RESULT($bv_cv_shared_barvinok)
38 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
39 BV_LDFLAGS="$BV_LDFLAGS -static"
44 AC_ARG_WITH(default-prefix,
45 AS_HELP_STRING([--with-default-prefix=DIR],
46 [Default installation prefix of optional packages]))
47 if test "${with_default_prefix+set}" = set; then
48 if test "${with_libgmp+set}" != set -a \
49 -f "$with_default_prefix/include/gmp.h"; then
50 with_libgmp=$with_default_prefix
52 if test "${with_ntl+set}" != set -a \
53 -f "$with_default_prefix/include/NTL/ZZ.h"; then
54 with_ntl=$with_default_prefix
56 if test "${with_cddlib+set}" != set -a \
57 -f "$with_default_prefix/include/cddmp.h"; then
58 with_cddlib=$with_default_prefix
60 if test "${with_glpk+set}" != set -a \
61 -f "$with_default_prefix/include/glpk.h"; then
62 with_glpk=$with_default_prefix
64 if test "${with_topcom+set}" != set -a \
65 -f "$with_default_prefix/bin/points2triangs"; then
66 with_topcom=$with_default_prefix
70 dnl Check for GMP library
71 AC_MSG_CHECKING(whether to use GMP)
73 [ --with-libgmp DIR Location of the GMP Distribution],
74 gmp_package=$withval, gmp_package=yes)
75 if test "x$gmp_package" = "xno"; then
77 AC_MSG_ERROR(Need gmp)
80 if test "x$gmp_package" = "xyes"; then
81 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
83 bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
84 bv_configure_args="$bv_configure_args --with-gmp-prefix=$gmp_package"
86 if test ! -d "$GMP_DIR"; then
87 AC_ERROR(Directory given for GMP Distribution is not a directory)
89 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
90 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
93 AC_CHECK_HEADER(gmp.h,
94 [AC_CHECK_LIB(gmp,main,
96 [poly_cv_gmpfatal="yes"])],
97 [poly_cv_gmpfatal="yes"])
98 if test "$poly_cv_gmpfatal" = "yes"; then
99 AC_MSG_ERROR([GMP not found])
102 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
104 AX_SUBMODULE(polylib,build|bundled|system,bundled)
106 AC_SUBST(POLYLIB_CPPFLAGS)
107 AC_SUBST(POLYLIB_LDFLAGS)
108 AC_SUBST(POLYLIB_LIBS)
109 case "$with_polylib" in
111 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
112 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
115 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
116 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
117 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
120 POLYLIB_LIBS="-lpolylibgmp"
121 if test "x$with_polylib_prefix" != "x"; then
122 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
123 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
125 SAVE_CPPFLAGS="$CPPFLAGS"
126 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
127 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
128 AC_MSG_ERROR(Need PolyLib)
130 CPPFLAGS="$SAVE_CPPFLAGS"
133 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
135 AX_SUBMODULE(isl,build|bundled|system,bundled)
139 AC_SUBST(ISL_BUILDDIR)
143 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
144 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
145 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
148 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
149 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
150 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
151 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
154 PKG_CHECK_MODULES([ISL], [isl])
155 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
157 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
158 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
160 AX_SUBMODULE(pet,bundled|build|system|no,no)
163 AC_SUBST(PET_BUILDDIR)
166 PET_CFLAGS="-I\$(top_srcdir)/pet/include"
167 AC_DEFINE(HAVE_PET,[],[use Pet])
170 PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
171 PET_CFLAGS="-I$pet_srcdir/include"
172 AC_DEFINE(HAVE_PET,[],[use Pet])
175 PKG_CHECK_MODULES([PET], [pet])
176 AC_DEFINE(HAVE_PET,[],[use Pet])
178 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
179 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
181 AX_SUBMODULE(isl-polylib,build|bundled|system,bundled)
183 AC_SUBST(ISL_POLYLIB_CFLAGS)
184 AC_SUBST(ISL_POLYLIB_LIBS)
185 case "$with_isl_polylib" in
187 ISL_POLYLIB_CFLAGS="-I\$(top_srcdir)/isl-polylib/include -I\$(top_builddir)/isl-polylib/include"
190 ISL_POLYLIB_CFLAGS="-I$isl_polylib_srcdir/include -I$with_isl_polylib_builddir/include"
191 ISL_POLYLIB_LIBS="$with_isl_polylib_builddir/libisl-polylib.la"
194 PKG_CHECK_MODULES([ISL_POLYLIB], [isl-polylib])
196 AM_CONDITIONAL(BUNDLED_ISL_POLYLIB, test $with_isl_polylib = bundled)
198 AC_MSG_CHECKING(if the fractional representation should be used)
199 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
200 [Don't use fractional representation])],
201 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
202 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
203 [Don't use fractional representation])],
204 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
205 AC_MSG_RESULT($bv_cv_modulo)
206 if test "x$bv_cv_modulo" != "xno" ; then
207 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
210 AC_MSG_CHECKING(whether to use incremental algorithm)
211 AC_ARG_ENABLE(incremental,
212 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
213 [Enable incremental algorithm [bf]])],
214 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
215 AC_MSG_RESULT($bv_cv_incremental)
216 case $bv_cv_incremental in
218 AC_DEFINE(USE_INCREMENTAL_BF,[],
219 [Use breadth-first incremental algorithm])
222 AC_DEFINE(USE_INCREMENTAL_DF,[],
223 [Use depth-first incremental algorithm])
228 [ --with-ntl=DIR DIR Location of NTL],
229 [ echo "Package ntl : $withval" && ntl_package=$withval],
232 if test "$ntl_package" = "no"; then
233 AC_MSG_ERROR(Need ntl)
236 AC_SUBST(NTL_CPPFLAGS)
237 AC_SUBST(NTL_LDFLAGS)
238 if test "$ntl_package" != "yes"; then
239 NTL_CPPFLAGS="-I$ntl_package/include"
240 NTL_LDFLAGS="-L$ntl_package/lib"
243 SAVE_CPPFLAGS="$CPPFLAGS"
244 SAVE_LDFLAGS="$LDFLAGS"
245 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
246 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
253 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
256 AC_CHECK_LIB(ntl, main,[],[
257 AC_MSG_ERROR(Need ntl)
259 CPPFLAGS="$SAVE_CPPFLAGS"
260 LDFLAGS="$SAVE_LDFLAGS"
262 AC_SUBST(bv_cone_hilbert_basis)
263 AC_MSG_CHECKING(whether to compile zsolve)
265 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
266 [ with_zsolve=$withval], [ with_zsolve=yes ])
267 AC_MSG_RESULT($with_zsolve)
270 if test "$with_zsolve" != "no"; then
271 if test "$GCC" = "yes"; then
273 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
275 if test $major -gt 3; then
278 if test $major -eq 3 -a $minor -ge 4; then
284 if test "$use_zsolve" = false; then
285 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
287 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
288 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
291 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
293 AX_SUBMODULE(omega,no|system,no)
295 AC_SUBST(OMEGA_CPPFLAGS)
296 AC_SUBST(OMEGA_LDFLAGS)
298 AC_SUBST(OMEGA_CODEGEN_LIBS)
301 case "$with_omega" in
303 if test "x$with_omega_prefix" != "xyes"; then
304 OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
305 OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
307 for i in /usr/include /usr/local/include; do
308 if test -f $i/omega/omega.h; then
309 OMEGA_CPPFLAGS="-I$i/omega"
315 SAVE_CPPFLAGS="$CPPFLAGS"
316 SAVE_LDFLAGS="$LDFLAGS"
317 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
318 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
319 AC_CHECK_HEADERS([omega.h],[
321 AC_CHECK_LIB(code_gen,main,[
322 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
326 ],[AC_MSG_WARN(Omega not found)])
327 CPPFLAGS="$SAVE_CPPFLAGS"
328 LDFLAGS="$SAVE_LDFLAGS"
332 if test "$have_omega" = true; then
333 AC_DEFINE(HAVE_OMEGA,[],[use omega])
335 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
338 AC_MSG_CHECKING(whether to compile parker)
340 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
341 [ with_parker=$withval], [ with_parker=yes ])
342 AC_MSG_RESULT($with_parker)
344 if test "$with_parker" != "no"; then
345 AC_MSG_CHECKING(for mona)
347 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
348 [], [AC_MSG_RESULT(not specified)])
350 if test "x$with_mona" != "x"; then
353 AC_MSG_RESULT($MONAPATH)
355 AC_DEFINE(USE_PARKER,[],[use parker])
358 if test "x$with_mona" = "x"; then
359 AC_MSG_WARN(mona source directory required to compile parker)
360 AC_MSG_WARN(http://www.brics.dk/mona/download)
363 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
365 AC_MSG_CHECKING(whether to use cddlib)
366 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
367 [ cddlib_package=$withval], [ cddlib_package=yes ])
368 AC_MSG_RESULT($cddlib_package)
371 if test "$cddlib_package" != "no"; then
372 if test "x$cddlib_package" != "xyes"; then
373 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
374 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
384 AC_CHECK_LIB(cddgmp, main,[
386 LIBS="-lcddgmp $LIBS"
387 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
389 AC_RUN_IFELSE(AC_LANG_PROGRAM([[#define GMPRATIONAL
393 const char *filename = SRCDIR"/cdd94e-test";
397 dd_ErrorType err = dd_NoError;
399 dd_set_global_constants();
401 f = fopen(filename, "r");
402 M = dd_PolyFile2Matrix(f, &err);
403 lp = dd_Matrix2LP(M, &err);
404 dd_LPSolve(lp, dd_DualSimplex, &err);
405 return lp->LPS == dd_Inconsistent;
407 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
409 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
414 ],[have_cddlib=false])
417 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
421 AC_MSG_CHECKING(whether to use GLPK)
422 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
423 [ glpk_package=$withval], [ glpk_package=yes ])
424 AC_MSG_RESULT($glpk_package)
427 if test "$glpk_package" != "no"; then
428 if test "x$glpk_package" != "xyes"; then
429 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
430 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
432 AC_CHECK_HEADERS([glpk.h],[
434 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
437 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
439 AC_MSG_CHECKING(location of TOPCOM)
440 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
441 [topcom_package=$withval], [topcom_package=unspecified])
442 AC_MSG_RESULT($topcom_package)
444 if test "$topcom_package" != no; then
446 if test "$topcom_package" != unspecified; then
447 topcom_path="$topcom_package/bin"
449 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
450 if test -n "$POINTS2TRIANGS"; then
452 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
453 [Path of points2triangs])
456 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
458 AX_SUBMODULE(cloog,no|build|bundled|system,bundled)
460 AC_SUBST(CLOOG_LDFLAGS)
461 AC_SUBST(CLOOG_CFLAGS)
463 CLOOG_CFLAGS="-DCLOOG_INT_GMP=1"
464 case "$with_cloog" in
466 CLOOG_CFLAGS="$CLOOG_CFLAGS -I\$(top_srcdir)/cloog/include -I\$(top_builddir)/cloog/include"
467 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
470 with_cloog_builddir=`echo @abs_builddir@ | $with_cloog_builddir/config.status --file=-`
471 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$cloog_srcdir/include -I$with_cloog_builddir/include"
472 CLOOG_LIBS="$with_cloog_builddir/libcloog-isl.la"
473 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
476 if test "x$with_cloog_prefix" != "x"; then
477 CLOOG_CFLAGS="$CLOOG_CFLAGS -I$with_cloog_prefix/include"
479 if test "x$with_cloog_exec_prefix" != "x"; then
480 CLOOG_LDFLAGS="-L$with_cloog_exec_prefix/lib"
482 CLOOG_LIBS="-lcloog-isl"
483 AC_DEFINE(HAVE_CLOOG,[],[use CLooG])
485 AM_CONDITIONAL(BUNDLED_CLOOG, test $with_cloog = bundled)
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_CFLAGS="$PACKAGE_CFLAGS_ISL"
540 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lisl-polylib -lpolylibgmp -lisl"
541 AX_CREATE_PKGCONFIG_INFO
543 AC_CONFIG_HEADERS(config.h)
544 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
545 AC_CONFIG_FILES(parker/Makefile)
546 if test $with_polylib = bundled; then
547 AC_CONFIG_SUBDIRS(polylib)
549 if test $with_isl = bundled; then
550 AC_CONFIG_SUBDIRS(isl)
552 if test $with_pet = bundled; then
553 AC_CONFIG_SUBDIRS(pet)
555 if test $with_isl_polylib = bundled; then
556 AC_CONFIG_SUBDIRS(isl-polylib)
558 if test $with_cloog = bundled; then
559 AC_CONFIG_SUBDIRS(cloog)
561 AC_CONFIG_COMMANDS_POST([
562 dnl pass on arguments to subdir configures, but don't
563 dnl add them to config.status
564 ac_configure_args="$ac_configure_args $bv_configure_args"