1 AC_INIT([barvinok], [0.37], [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_gmp_prefix=$with_default_prefix
52 if test "${with_ntl+set}" != set -a \
53 "${with_ntl_prefix+set}" != set -a \
54 -f "$with_default_prefix/include/NTL/ZZ.h"; then
55 with_ntl_prefix=$with_default_prefix
57 if test "${with_cddlib+set}" != set -a \
58 -f "$with_default_prefix/include/cddmp.h"; then
59 with_cddlib=$with_default_prefix
61 if test "${with_glpk+set}" != set -a \
62 -f "$with_default_prefix/include/glpk.h"; then
63 with_glpk=$with_default_prefix
65 if test "${with_topcom+set}" != set -a \
66 -f "$with_default_prefix/bin/points2triangs"; then
67 with_topcom=$with_default_prefix
71 AX_SUBMODULE(gmp,system|build,system)
75 with_gmp_builddir=`echo @abs_builddir@ | \
76 $with_gmp_builddir/config.status --file=-`
77 CPPFLAGS="-I$with_gmp_builddir $CPPFLAGS"
78 LDFLAGS="-L$with_gmp_builddir/$lt_cv_objdir $LDFLAGS"
79 bv_extra="--with-gmp --with-gmp-builddir=$with_gmp_builddir"
80 bv_configure_args="$bv_configure_args $bv_extra"
83 if test "x$with_gmp_prefix" != "x"; then
84 bv_extra="--with-libgmp=$with_gmp_prefix"
85 bv_configure_args="$bv_configure_args $bv_extra"
86 CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
87 LDFLAGS="-L$with_gmp_prefix/lib $LDFLAGS"
89 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
95 AC_CHECK_HEADER(gmp.h,
96 [AC_CHECK_LIB(gmp,main,
98 [poly_cv_gmpfatal="yes"])],
99 [poly_cv_gmpfatal="yes"])
100 if test "$poly_cv_gmpfatal" = "yes"; then
101 AC_MSG_ERROR([GMP not found])
103 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
105 AX_SUBMODULE(polylib,build|bundled|system,bundled)
107 AC_SUBST(POLYLIB_CPPFLAGS)
108 AC_SUBST(POLYLIB_LDFLAGS)
109 AC_SUBST(POLYLIB_LIBS)
110 case "$with_polylib" in
112 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
113 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
116 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
117 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
118 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
121 POLYLIB_LIBS="-lpolylibgmp"
122 if test "x$with_polylib_prefix" != "x"; then
123 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
124 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
126 SAVE_CPPFLAGS="$CPPFLAGS"
127 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
128 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
129 AC_MSG_ERROR(Need PolyLib)
131 CPPFLAGS="$SAVE_CPPFLAGS"
134 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
136 AX_SUBMODULE(isl,build|bundled|system,bundled)
140 AC_SUBST(ISL_BUILDDIR)
144 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
145 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
146 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
149 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
150 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
151 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
152 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
155 PKG_CHECK_MODULES([ISL], [isl])
156 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
158 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
159 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
161 AX_SUBMODULE(pet,bundled|build|system|no,no)
164 AC_SUBST(PET_BUILDDIR)
167 PET_CFLAGS="-I\$(top_srcdir)/pet/include"
168 AC_DEFINE(HAVE_PET,[],[use Pet])
171 PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
172 PET_CFLAGS="-I$pet_srcdir/include"
173 AC_DEFINE(HAVE_PET,[],[use Pet])
176 PKG_CHECK_MODULES([PET], [pet])
177 AC_DEFINE(HAVE_PET,[],[use Pet])
179 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
180 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
182 AC_MSG_CHECKING(if the fractional representation should be used)
183 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
184 [Don't use fractional representation])],
185 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
186 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
187 [Don't use fractional representation])],
188 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
189 AC_MSG_RESULT($bv_cv_modulo)
190 if test "x$bv_cv_modulo" != "xno" ; then
191 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
194 AC_MSG_CHECKING(whether to use incremental algorithm)
195 AC_ARG_ENABLE(incremental,
196 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
197 [Enable incremental algorithm [bf]])],
198 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
199 AC_MSG_RESULT($bv_cv_incremental)
200 case $bv_cv_incremental in
202 AC_DEFINE(USE_INCREMENTAL_BF,[],
203 [Use breadth-first incremental algorithm])
206 AC_DEFINE(USE_INCREMENTAL_DF,[],
207 [Use depth-first incremental algorithm])
212 [AC_HELP_STRING([--with-ntl=system|build],
213 [Which NTL to use [default=system]])])
215 AC_ARG_WITH(ntl-prefix,
216 [AC_HELP_STRING([--with-ntl-prefix=DIR],
217 [Prefix of NTL installation])])
219 AC_ARG_WITH(ntl-builddir,
220 [AC_HELP_STRING([--with-ntl-builddir=DIR],
221 [Prefix of NTL root build directory
222 containing include and src subdirectories])])
224 if test "x$with_ntl_builddir" != "x"; then
225 if test "x$with_ntl" != "xbuild" -a "x$with_ntl" != "x"; then
226 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-builddir implies
232 if test "x$with_ntl_prefix" != "x"; then
233 if test "x$with_ntl" != "xsystem" -a "x$with_ntl" != "x"; then
234 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-prefix implies
247 AC_MSG_CHECKING([which NTL to use])
248 AC_MSG_RESULT($with_ntl)
250 AC_SUBST(NTL_CPPFLAGS)
251 AC_SUBST(NTL_LDFLAGS)
254 NTL_CPPFLAGS="-I$with_ntl_builddir/include"
255 NTL_LDFLAGS="-L$with_ntl_builddir/src/$lt_cv_objdir"
256 ntl_builddir_found=false
257 AC_CHECK_FILE(["$with_ntl_builddir/src/ZZ.c"],
258 [ntl_builddir_found=true],[])
259 if test "x$ntl_builddir_found" != "xtrue"; then
260 if test -f "$with_ntl_builddir/ZZ.c"; then
261 ntl_builddir=`dirname $with_ntl_builddir`
262 AC_MSG_ERROR(m4_normalize(
263 [NTL source directory src/ specified as builddir.
264 Use root directory instead as
265 --with-ntl-builddir=$ntl_builddir]))
267 AC_MSG_ERROR([Could not find NTL in the builddir])
272 if test "x$with_ntl_prefix" != "x"; then
273 NTL_CPPFLAGS="-I$with_ntl_prefix/include"
274 NTL_LDFLAGS="-L$with_ntl_prefix/lib"
280 SAVE_CPPFLAGS="$CPPFLAGS"
281 SAVE_LDFLAGS="$LDFLAGS"
282 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
283 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
285 AC_CHECK_HEADER([NTL/ZZ.h],[],[bv_no_ntl=true])
291 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
294 AC_CHECK_LIB(ntl, main,[],[bv_no_ntl=true])
295 if test "$bv_no_ntl" = "true"; then
296 AC_MSG_ERROR(Need ntl)
298 CPPFLAGS="$SAVE_CPPFLAGS"
299 LDFLAGS="$SAVE_LDFLAGS"
301 AC_SUBST(bv_cone_hilbert_basis)
302 AC_MSG_CHECKING(whether to compile zsolve)
304 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
305 [ with_zsolve=$withval], [ with_zsolve=yes ])
306 AC_MSG_RESULT($with_zsolve)
309 if test "$with_zsolve" != "no"; then
310 if test "$GCC" = "yes"; then
312 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
314 if test $major -gt 3; then
317 if test $major -eq 3 -a $minor -ge 4; then
323 if test "$use_zsolve" = false; then
324 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
326 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
327 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
330 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
332 AX_SUBMODULE(omega,no|system,no)
334 AC_SUBST(OMEGA_CPPFLAGS)
335 AC_SUBST(OMEGA_LDFLAGS)
337 AC_SUBST(OMEGA_CODEGEN_LIBS)
340 case "$with_omega" in
342 if test "x$with_omega_prefix" != "xyes"; then
343 OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
344 OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
346 for i in /usr/include /usr/local/include; do
347 if test -f $i/omega/omega.h; then
348 OMEGA_CPPFLAGS="-I$i/omega"
354 SAVE_CPPFLAGS="$CPPFLAGS"
355 SAVE_LDFLAGS="$LDFLAGS"
356 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
357 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
358 AC_CHECK_HEADERS([omega.h],[
360 AC_CHECK_LIB(code_gen,main,[
361 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
365 ],[AC_MSG_WARN(Omega not found)])
366 CPPFLAGS="$SAVE_CPPFLAGS"
367 LDFLAGS="$SAVE_LDFLAGS"
371 if test "$have_omega" = true; then
372 AC_DEFINE(HAVE_OMEGA,[],[use omega])
374 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
377 AC_MSG_CHECKING(whether to compile parker)
379 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
380 [ with_parker=$withval], [ with_parker=yes ])
381 AC_MSG_RESULT($with_parker)
383 if test "$with_parker" != "no"; then
384 AC_MSG_CHECKING(for mona)
386 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
387 [], [AC_MSG_RESULT(not specified)])
389 if test "x$with_mona" != "x"; then
392 AC_MSG_RESULT($MONAPATH)
394 AC_DEFINE(USE_PARKER,[],[use parker])
397 if test "x$with_mona" = "x"; then
398 AC_MSG_WARN(mona source directory required to compile parker)
399 AC_MSG_WARN(http://www.brics.dk/mona/download)
402 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
404 AC_MSG_CHECKING(whether to use cddlib)
405 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
406 [ cddlib_package=$withval], [ cddlib_package=yes ])
407 AC_MSG_RESULT($cddlib_package)
410 if test "$cddlib_package" != "no"; then
411 if test "x$cddlib_package" != "xyes"; then
412 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
413 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
423 AC_CHECK_LIB(cddgmp, main,[
425 LIBS="-lcddgmp $LIBS"
426 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
428 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
432 const char *filename = SRCDIR"/cdd94e-test";
436 dd_ErrorType err = dd_NoError;
438 dd_set_global_constants();
440 f = fopen(filename, "r");
441 M = dd_PolyFile2Matrix(f, &err);
442 lp = dd_Matrix2LP(M, &err);
443 dd_LPSolve(lp, dd_DualSimplex, &err);
444 return lp->LPS == dd_Inconsistent;
446 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
448 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
453 ],[have_cddlib=false])
456 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
460 AC_MSG_CHECKING(whether to use GLPK)
461 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
462 [ glpk_package=$withval], [ glpk_package=yes ])
463 AC_MSG_RESULT($glpk_package)
466 if test "$glpk_package" != "no"; then
467 if test "x$glpk_package" != "xyes"; then
468 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
469 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
471 AC_CHECK_HEADERS([glpk.h],[
473 AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
476 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
478 AC_MSG_CHECKING(location of TOPCOM)
479 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
480 [topcom_package=$withval], [topcom_package=unspecified])
481 AC_MSG_RESULT($topcom_package)
483 if test "$topcom_package" != no; then
485 if test "$topcom_package" != unspecified; then
486 topcom_path="$topcom_package/bin"
488 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
489 if test -n "$POINTS2TRIANGS"; then
491 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
492 [Path of points2triangs])
495 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
498 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
505 suffix="normal", suffix="broken")
506 AC_CONFIG_COMMANDS([barvinok/set.h],
507 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
509 AC_CONFIG_COMMANDS([barvinok/NTL.h],
510 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
513 SAVE_CPPFLAGS="$CPPFLAGS"
514 CPPFLAGS="-I$srcdir $CPPFLAGS"
515 AC_TRY_COMPILE([#include "fdstream.h"],[],
516 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
518 CPPFLAGS="$SAVE_CPPFLAGS"
520 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
522 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
523 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
524 AX_CREATE_PKGCONFIG_INFO
526 AC_CONFIG_HEADERS(config.h)
527 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
528 AC_CONFIG_FILES(parker/Makefile)
529 if test $with_polylib = bundled; then
530 AC_CONFIG_SUBDIRS(polylib)
532 if test $with_isl = bundled; then
533 AC_CONFIG_SUBDIRS(isl)
535 if test $with_pet = bundled; then
536 AC_CONFIG_SUBDIRS(pet)
538 AC_CONFIG_COMMANDS_POST([
539 dnl pass on arguments to subdir configures, but don't
540 dnl add them to config.status
541 ac_configure_args="$ac_configure_args $bv_configure_args"