1 AC_INIT([barvinok], [0.39], [isl-development@googlegroups.com])
2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE([foreign subdir-objects])
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"
43 AX_CXX_COMPILE_STDCXX_11([], [optional])
47 AC_ARG_WITH(default-prefix,
48 AS_HELP_STRING([--with-default-prefix=DIR],
49 [Default installation prefix of optional packages]))
50 if test "${with_default_prefix+set}" = set; then
51 if test "${with_libgmp+set}" != set -a \
52 -f "$with_default_prefix/include/gmp.h"; then
53 with_gmp_prefix=$with_default_prefix
55 if test "${with_ntl+set}" != set -a \
56 "${with_ntl_prefix+set}" != set -a \
57 -f "$with_default_prefix/include/NTL/ZZ.h"; then
58 with_ntl_prefix=$with_default_prefix
60 if test "${with_cddlib+set}" != set -a \
61 -f "$with_default_prefix/include/cddmp.h"; then
62 with_cddlib=$with_default_prefix
64 if test "${with_glpk+set}" != set -a \
65 -f "$with_default_prefix/include/glpk.h"; then
66 with_glpk=$with_default_prefix
68 if test "${with_topcom+set}" != set -a \
69 -f "$with_default_prefix/bin/points2triangs"; then
70 with_topcom=$with_default_prefix
74 AX_SUBMODULE(gmp,system|build,system)
78 with_gmp_builddir=`echo @abs_builddir@ | \
79 $with_gmp_builddir/config.status --file=-`
80 CPPFLAGS="-I$with_gmp_builddir $CPPFLAGS"
81 LDFLAGS="-L$with_gmp_builddir/$lt_cv_objdir $LDFLAGS"
82 bv_extra="--with-gmp --with-gmp-builddir=$with_gmp_builddir"
83 bv_configure_args="$bv_configure_args $bv_extra"
86 if test "x$with_gmp_prefix" != "x"; then
87 bv_extra="--with-libgmp=$with_gmp_prefix"
88 bv_configure_args="$bv_configure_args $bv_extra"
89 CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
90 LDFLAGS="-L$with_gmp_prefix/lib $LDFLAGS"
92 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
98 AC_CHECK_HEADER(gmp.h,
99 [AC_CHECK_LIB(gmp,main,
101 [poly_cv_gmpfatal="yes"])],
102 [poly_cv_gmpfatal="yes"])
103 if test "$poly_cv_gmpfatal" = "yes"; then
104 AC_MSG_ERROR([GMP not found])
106 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
108 AX_SUBMODULE(polylib,build|bundled|system,bundled)
110 AC_SUBST(POLYLIB_CPPFLAGS)
111 AC_SUBST(POLYLIB_LDFLAGS)
112 AC_SUBST(POLYLIB_LIBS)
113 case "$with_polylib" in
115 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
116 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
119 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
120 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
121 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
124 POLYLIB_LIBS="-lpolylibgmp"
125 if test "x$with_polylib_prefix" != "x"; then
126 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
127 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
129 SAVE_CPPFLAGS="$CPPFLAGS"
130 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
131 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
132 AC_MSG_ERROR(Need PolyLib)
134 CPPFLAGS="$SAVE_CPPFLAGS"
137 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
139 AX_SUBMODULE(isl,build|bundled|system,bundled)
144 AC_SUBST(ISL_BUILDDIR)
147 ISL_SRCDIR="$srcdir/isl"
149 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
150 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
151 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
154 ISL_SRCDIR="$isl_srcdir"
155 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
156 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
157 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
158 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
161 PKG_CHECK_MODULES([ISL], [isl])
162 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
164 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
165 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
167 AX_SUBMODULE(pet,bundled|build|system|no,no)
170 AC_SUBST(PET_BUILDDIR)
174 PET_CFLAGS="-I\$(top_srcdir)/pet/include"
175 AC_DEFINE(HAVE_PET,[],[use Pet])
178 PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
179 PET_CFLAGS="-I$pet_srcdir/include"
180 AC_DEFINE(HAVE_PET,[],[use Pet])
183 PKG_CHECK_MODULES([PET], [pet])
184 AC_DEFINE(HAVE_PET,[],[use Pet])
187 pet_suffix="top.no_pet"
190 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
191 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
193 AC_MSG_CHECKING(whether to use incremental algorithm)
194 AC_ARG_ENABLE(incremental,
195 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
196 [Enable incremental algorithm [bf]])],
197 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
198 AC_MSG_RESULT($bv_cv_incremental)
199 case $bv_cv_incremental in
201 AC_DEFINE(USE_INCREMENTAL_BF,[],
202 [Use breadth-first incremental algorithm])
205 AC_DEFINE(USE_INCREMENTAL_DF,[],
206 [Use depth-first incremental algorithm])
211 [AC_HELP_STRING([--with-ntl=system|build],
212 [Which NTL to use [default=system]])])
214 AC_ARG_WITH(ntl-prefix,
215 [AC_HELP_STRING([--with-ntl-prefix=DIR],
216 [Prefix of NTL installation])])
218 AC_ARG_WITH(ntl-builddir,
219 [AC_HELP_STRING([--with-ntl-builddir=DIR],
220 [Prefix of NTL root build directory
221 containing include and src subdirectories])])
223 if test "x$with_ntl_builddir" != "x"; then
224 if test "x$with_ntl" != "xbuild" -a "x$with_ntl" != "x"; then
225 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-builddir implies
231 if test "x$with_ntl_prefix" != "x"; then
232 if test "x$with_ntl" != "xsystem" -a "x$with_ntl" != "x"; then
233 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-prefix implies
246 AC_MSG_CHECKING([which NTL to use])
247 AC_MSG_RESULT($with_ntl)
249 AC_SUBST(NTL_CPPFLAGS)
250 AC_SUBST(NTL_LDFLAGS)
253 NTL_CPPFLAGS="-I$with_ntl_builddir/include"
254 NTL_LDFLAGS="-L$with_ntl_builddir/src/$lt_cv_objdir"
255 ntl_builddir_found=false
256 AC_CHECK_FILE(["$with_ntl_builddir/src/ZZ.c"],
257 [ntl_builddir_found=true],[])
258 if test "x$ntl_builddir_found" != "xtrue"; then
259 if test -f "$with_ntl_builddir/ZZ.c"; then
260 ntl_builddir=`dirname $with_ntl_builddir`
261 AC_MSG_ERROR(m4_normalize(
262 [NTL source directory src/ specified as builddir.
263 Use root directory instead as
264 --with-ntl-builddir=$ntl_builddir]))
266 AC_MSG_ERROR([Could not find NTL in the builddir])
271 if test "x$with_ntl_prefix" != "x"; then
272 NTL_CPPFLAGS="-I$with_ntl_prefix/include"
273 NTL_LDFLAGS="-L$with_ntl_prefix/lib"
280 AC_SUBST(bv_cone_hilbert_basis)
281 AC_MSG_CHECKING(whether to compile zsolve)
283 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
284 [ with_zsolve=$withval], [ with_zsolve=yes ])
285 AC_MSG_RESULT($with_zsolve)
288 if test "$with_zsolve" != "no"; then
289 if test "$GCC" = "yes"; then
291 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
293 if test $major -gt 3; then
296 if test $major -eq 3 -a $minor -ge 4; then
302 if test "$use_zsolve" = false; then
303 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
305 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
306 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
309 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
311 AX_SUBMODULE(omega,no|system,no)
313 AC_SUBST(OMEGA_CPPFLAGS)
314 AC_SUBST(OMEGA_LDFLAGS)
316 AC_SUBST(OMEGA_CODEGEN_LIBS)
319 case "$with_omega" in
321 if test "x$with_omega_prefix" != "xyes"; then
322 OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
323 OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
325 for i in /usr/include /usr/local/include; do
326 if test -f $i/omega/omega.h; then
327 OMEGA_CPPFLAGS="-I$i/omega"
333 SAVE_CPPFLAGS="$CPPFLAGS"
334 SAVE_LDFLAGS="$LDFLAGS"
335 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
336 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
337 AC_CHECK_HEADERS([omega.h],[
339 AC_CHECK_LIB(code_gen,main,[
340 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
344 ],[AC_MSG_WARN(Omega not found)])
345 CPPFLAGS="$SAVE_CPPFLAGS"
346 LDFLAGS="$SAVE_LDFLAGS"
350 if test "$have_omega" = true; then
351 AC_DEFINE(HAVE_OMEGA,[],[use omega])
353 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
356 AC_MSG_CHECKING(whether to compile parker)
358 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
359 [ with_parker=$withval], [ with_parker=yes ])
360 AC_MSG_RESULT($with_parker)
362 if test "$with_parker" != "no"; then
363 AC_MSG_CHECKING(for mona)
365 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
366 [], [AC_MSG_RESULT(not specified)])
368 if test "x$with_mona" != "x"; then
371 AC_MSG_RESULT($MONAPATH)
373 AC_DEFINE(USE_PARKER,[],[use parker])
376 if test "x$with_mona" = "x"; then
377 AC_MSG_WARN(mona source directory required to compile parker)
378 AC_MSG_WARN(http://www.brics.dk/mona/download)
381 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
383 AC_MSG_CHECKING(whether to use cddlib)
384 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
385 [ cddlib_package=$withval], [ cddlib_package=yes ])
386 AC_MSG_RESULT($cddlib_package)
389 if test "$cddlib_package" != "no"; then
390 if test "x$cddlib_package" != "xyes"; then
391 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
392 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
402 AC_CHECK_LIB(cddgmp, main,[
404 LIBS="-lcddgmp $LIBS"
405 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
407 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
411 const char *filename = SRCDIR"/cdd94e-test";
415 dd_ErrorType err = dd_NoError;
417 dd_set_global_constants();
419 f = fopen(filename, "r");
420 M = dd_PolyFile2Matrix(f, &err);
421 lp = dd_Matrix2LP(M, &err);
422 dd_LPSolve(lp, dd_DualSimplex, &err);
423 return lp->LPS == dd_Inconsistent;
425 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
427 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
432 ],[have_cddlib=false])
435 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
439 AC_MSG_CHECKING(whether to use GLPK)
440 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
441 [ glpk_package=$withval], [ glpk_package=yes ])
442 AC_MSG_RESULT($glpk_package)
445 if test "$glpk_package" != "no"; then
446 if test "x$glpk_package" != "xyes"; then
447 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
448 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
450 AC_CHECK_HEADERS([glpk.h],[
452 AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
455 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
457 AC_MSG_CHECKING(location of TOPCOM)
458 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
459 [topcom_package=$withval], [topcom_package=unspecified])
460 AC_MSG_RESULT($topcom_package)
462 if test "$topcom_package" != no; then
464 if test "$topcom_package" != unspecified; then
465 topcom_path="$topcom_package/bin"
467 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
468 if test -n "$POINTS2TRIANGS"; then
470 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
471 [Path of points2triangs])
474 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
477 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
484 suffix="normal", suffix="broken")
485 AC_CONFIG_COMMANDS([barvinok/set.h],
486 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
488 AC_CONFIG_COMMANDS([barvinok/NTL.h],
489 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
492 SAVE_CPPFLAGS="$CPPFLAGS"
493 CPPFLAGS="-I$srcdir $CPPFLAGS"
494 AC_TRY_COMPILE([#include "fdstream.h"],[],
495 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
497 CPPFLAGS="$SAVE_CPPFLAGS"
499 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
501 AC_CONFIG_COMMANDS([interface/isl.py.top],
502 [cp $srcdir/interface/isl.py.$pet_suffix interface/isl.py.top],
503 [pet_suffix="$pet_suffix"])
505 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
506 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
507 AX_CREATE_PKGCONFIG_INFO
509 AH_BOTTOM([#include "config_post.h"])
510 AC_CONFIG_HEADERS(config.h)
511 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
512 AC_CONFIG_FILES(parker/Makefile)
513 if test $with_polylib = bundled; then
514 AC_CONFIG_SUBDIRS(polylib)
516 if test $with_isl = bundled; then
517 AC_CONFIG_SUBDIRS(isl)
519 if test $with_pet = bundled; then
520 AC_CONFIG_SUBDIRS(pet)
522 AC_CONFIG_COMMANDS_POST([
523 dnl pass on arguments to subdir configures, but don't
524 dnl add them to config.status
525 ac_configure_args="$ac_configure_args $bv_configure_args"