1 AC_INIT([barvinok], [0.41.5], [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])])
19 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
20 if test "$enable_shared" = yes; then
21 BV_LDFLAGS="-no-undefined"
30 AC_CHECK_HEADERS(getopt.h)
31 AC_CHECK_HEADERS(sys/times.h)
32 AC_CHECK_FUNCS(sigaction)
34 AC_MSG_CHECKING(whether to build shared libbarvinok)
35 AC_ARG_ENABLE(shared_barvinok,
36 AS_HELP_STRING([--enable-shared-barvinok],
37 [build shared barvinok library]),
38 [bv_cv_shared_barvinok=$enableval], [bv_cv_shared_barvinok="no"])
39 AC_MSG_RESULT($bv_cv_shared_barvinok)
40 if test "x$bv_cv_shared_barvinok" != "xyes" ; then
41 BV_LDFLAGS="$BV_LDFLAGS -static"
48 AC_ARG_WITH(default-prefix,
49 AS_HELP_STRING([--with-default-prefix=DIR],
50 [Default installation prefix of optional packages]))
51 if test "${with_default_prefix+set}" = set; then
52 if test "${with_libgmp+set}" != set -a \
53 -f "$with_default_prefix/include/gmp.h"; then
54 with_gmp_prefix=$with_default_prefix
56 if test "${with_ntl+set}" != set -a \
57 "${with_ntl_prefix+set}" != set -a \
58 -f "$with_default_prefix/include/NTL/ZZ.h"; then
59 with_ntl_prefix=$with_default_prefix
61 if test "${with_cddlib+set}" != set -a \
62 -f "$with_default_prefix/include/cddmp.h"; then
63 with_cddlib=$with_default_prefix
65 if test "${with_glpk+set}" != set -a \
66 -f "$with_default_prefix/include/glpk.h"; then
67 with_glpk=$with_default_prefix
69 if test "${with_topcom+set}" != set -a \
70 -f "$with_default_prefix/bin/points2triangs"; then
71 with_topcom=$with_default_prefix
75 AX_SUBMODULE(gmp,system|build,system)
79 with_gmp_builddir=`echo @abs_builddir@ | \
80 $with_gmp_builddir/config.status --file=-`
81 CPPFLAGS="-I$with_gmp_builddir $CPPFLAGS"
82 LDFLAGS="-L$with_gmp_builddir/$lt_cv_objdir $LDFLAGS"
83 bv_extra="--with-gmp --with-gmp-builddir=$with_gmp_builddir"
84 bv_configure_args="$bv_configure_args $bv_extra"
87 if test "x$with_gmp_prefix" != "x"; then
88 bv_extra="--with-libgmp=$with_gmp_prefix"
89 bv_configure_args="$bv_configure_args $bv_extra"
90 CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
91 LDFLAGS="-L$with_gmp_prefix/lib $LDFLAGS"
93 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
99 AC_CHECK_HEADER(gmp.h,
100 [AC_CHECK_LIB(gmp,main,
102 [poly_cv_gmpfatal="yes"])],
103 [poly_cv_gmpfatal="yes"])
104 if test "$poly_cv_gmpfatal" = "yes"; then
105 AC_MSG_ERROR([GMP not found])
107 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
109 AX_SUBMODULE(polylib,build|bundled|system,bundled)
111 AC_SUBST(POLYLIB_CPPFLAGS)
112 AC_SUBST(POLYLIB_LDFLAGS)
113 AC_SUBST(POLYLIB_LIBS)
114 case "$with_polylib" in
116 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
117 POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
120 with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
121 POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
122 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
125 POLYLIB_LIBS="-lpolylibgmp"
126 if test "x$with_polylib_prefix" != "x"; then
127 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
128 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
130 SAVE_CPPFLAGS="$CPPFLAGS"
131 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
132 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
133 AC_MSG_ERROR(Need PolyLib)
135 CPPFLAGS="$SAVE_CPPFLAGS"
138 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
140 AX_SUBMODULE(isl,build|bundled|system,bundled)
145 AC_SUBST(ISL_BUILDDIR)
148 ISL_SRCDIR="$srcdir/isl"
150 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
151 bv_configure_args="$bv_configure_args --with-isl=build"
152 bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
153 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
156 ISL_SRCDIR="$isl_srcdir"
157 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
158 bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
159 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
160 PACKAGE_CFLAGS_ISL='-I${prefix}/include'
163 PKG_CHECK_MODULES([ISL], [isl])
164 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
166 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
167 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
168 AM_CONDITIONAL(HAVE_ISL_BUILDDIR, test "x$ISL_BUILDDIR" != "x")
170 AX_SUBMODULE(pet,bundled|build|system|no,no)
173 AC_SUBST(PET_BUILDDIR)
177 PET_CFLAGS="-I\$(top_srcdir)/pet/include"
178 AC_DEFINE(HAVE_PET,[],[use Pet])
181 PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
182 PET_CFLAGS="-I$pet_srcdir/include"
183 AC_DEFINE(HAVE_PET,[],[use Pet])
186 PKG_CHECK_MODULES([PET], [pet])
187 AC_DEFINE(HAVE_PET,[],[use Pet])
190 pet_suffix="top.no_pet"
193 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
194 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
196 AC_MSG_CHECKING(whether to use incremental algorithm)
197 AC_ARG_ENABLE(incremental,
198 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
199 [Enable incremental algorithm [bf]])],
200 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
201 AC_MSG_RESULT($bv_cv_incremental)
202 case $bv_cv_incremental in
204 AC_DEFINE(USE_INCREMENTAL_BF,[],
205 [Use breadth-first incremental algorithm])
208 AC_DEFINE(USE_INCREMENTAL_DF,[],
209 [Use depth-first incremental algorithm])
214 [AC_HELP_STRING([--with-ntl=system|build],
215 [Which NTL to use [default=system]])])
217 AC_ARG_WITH(ntl-prefix,
218 [AC_HELP_STRING([--with-ntl-prefix=DIR],
219 [Prefix of NTL installation])])
221 AC_ARG_WITH(ntl-builddir,
222 [AC_HELP_STRING([--with-ntl-builddir=DIR],
223 [Prefix of NTL root build directory
224 containing include and src subdirectories])])
226 if test "x$with_ntl_builddir" != "x"; then
227 if test "x$with_ntl" != "xbuild" -a "x$with_ntl" != "x"; then
228 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-builddir implies
234 if test "x$with_ntl_prefix" != "x"; then
235 if test "x$with_ntl" != "xsystem" -a "x$with_ntl" != "x"; then
236 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-prefix implies
249 AC_MSG_CHECKING([which NTL to use])
250 AC_MSG_RESULT($with_ntl)
252 AC_SUBST(NTL_CPPFLAGS)
253 AC_SUBST(NTL_LDFLAGS)
256 ntl_include="$with_ntl_builddir/include"
257 NTL_LDFLAGS="-L$with_ntl_builddir/src/$lt_cv_objdir"
258 ntl_builddir_found=false
259 AC_CHECK_FILE(["$with_ntl_builddir/src/ZZ.c"],
260 [ntl_builddir_found=true],[])
261 if test "x$ntl_builddir_found" != "xtrue"; then
262 if test -f "$with_ntl_builddir/ZZ.c"; then
263 ntl_builddir=`dirname $with_ntl_builddir`
264 AC_MSG_ERROR(m4_normalize(
265 [NTL source directory src/ specified as builddir.
266 Use root directory instead as
267 --with-ntl-builddir=$ntl_builddir]))
269 AC_MSG_ERROR([Could not find NTL in the builddir])
274 if test "x$with_ntl_prefix" != "x"; then
275 ntl_include="$with_ntl_prefix/include"
276 NTL_LDFLAGS="-L$with_ntl_prefix/lib"
280 if test "x$ntl_include" != "x"; then
281 NTL_CPPFLAGS="-I$ntl_include"
283 for path in /usr/local /usr; do
284 if test -f "$path/include/NTL/ZZ.h"; then
285 ntl_include="$path/include"
290 # Look for compiler/linker options needed for linking against NTL
291 ntl_configlog="$ntl_include/NTL/ConfigLog.h"
292 if test -f "$ntl_configlog"; then
293 AC_MSG_CHECKING([for compiler options in $ntl_configlog])
294 eval $($GREP "^CXXAUTOFLAGS" $ntl_configlog | $SED -e 's/^/NTL_/')
295 AC_MSG_RESULT([$NTL_CXXAUTOFLAGS])
296 NTL_CPPFLAGS="$NTL_CPPFLAGS $NTL_CXXAUTOFLAGS"
297 NTL_LDFLAGS="$NTL_LDFLAGS $NTL_CXXAUTOFLAGS"
302 AC_SUBST(bv_cone_hilbert_basis)
303 AC_MSG_CHECKING(whether to compile zsolve)
305 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
306 [ with_zsolve=$withval], [ with_zsolve=yes ])
307 AC_MSG_RESULT($with_zsolve)
310 if test "$with_zsolve" != "no"; then
311 if test "$GCC" = "yes"; then
313 $SED -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
315 if test $major -gt 3; then
318 if test $major -eq 3 -a $minor -ge 4; then
324 if test "$use_zsolve" = false; then
325 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
327 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
328 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
331 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
333 AX_SUBMODULE(omega,no|system,no)
335 AC_SUBST(OMEGA_CPPFLAGS)
336 AC_SUBST(OMEGA_LDFLAGS)
338 AC_SUBST(OMEGA_CODEGEN_LIBS)
341 case "$with_omega" in
343 if test "x$with_omega_prefix" != "xyes"; then
344 OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
345 OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
347 for i in /usr/include /usr/local/include; do
348 if test -f $i/omega/omega.h; then
349 OMEGA_CPPFLAGS="-I$i/omega"
355 SAVE_CPPFLAGS="$CPPFLAGS"
356 SAVE_LDFLAGS="$LDFLAGS"
357 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
358 LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
359 AC_CHECK_HEADERS([omega.h],[
361 AC_CHECK_LIB(code_gen,main,[
362 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
366 ],[AC_MSG_WARN(Omega not found)])
367 CPPFLAGS="$SAVE_CPPFLAGS"
368 LDFLAGS="$SAVE_LDFLAGS"
372 if test "$have_omega" = true; then
373 AC_DEFINE(HAVE_OMEGA,[],[use omega])
375 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
378 AC_MSG_CHECKING(whether to compile parker)
380 [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
381 [ with_parker=$withval], [ with_parker=yes ])
382 AC_MSG_RESULT($with_parker)
384 if test "$with_parker" != "no"; then
385 AC_MSG_CHECKING(for mona)
387 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
388 [], [AC_MSG_RESULT(not specified)])
390 if test "x$with_mona" != "x"; then
393 AC_MSG_RESULT($MONAPATH)
395 AC_DEFINE(USE_PARKER,[],[use parker])
398 if test "x$with_mona" = "x"; then
399 AC_MSG_WARN(mona source directory required to compile parker)
400 AC_MSG_WARN(http://www.brics.dk/mona/download)
403 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
405 AC_MSG_CHECKING(whether to use cddlib)
406 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
407 [ cddlib_package=$withval], [ cddlib_package=yes ])
408 AC_MSG_RESULT($cddlib_package)
411 if test "$cddlib_package" != "no"; then
412 if test "x$cddlib_package" != "xyes"; then
413 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
414 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
424 AC_CHECK_LIB(cddgmp, main,[
426 LIBS="-lcddgmp $LIBS"
427 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
429 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
433 const char *filename = SRCDIR"/cdd94e-test";
437 dd_ErrorType err = dd_NoError;
439 dd_set_global_constants();
441 f = fopen(filename, "r");
442 M = dd_PolyFile2Matrix(f, &err);
443 lp = dd_Matrix2LP(M, &err);
444 dd_LPSolve(lp, dd_DualSimplex, &err);
445 return lp->LPS == dd_Inconsistent;
447 AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
449 AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
454 ],[have_cddlib=false])
457 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
461 AC_MSG_CHECKING(whether to use GLPK)
462 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
463 [ glpk_package=$withval], [ glpk_package=yes ])
464 AC_MSG_RESULT($glpk_package)
467 if test "$glpk_package" != "no"; then
468 if test "x$glpk_package" != "xyes"; then
469 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
470 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
472 AC_CHECK_HEADERS([glpk.h],[
474 AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
477 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
479 AC_MSG_CHECKING(location of TOPCOM)
480 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
481 [topcom_package=$withval], [topcom_package=unspecified])
482 AC_MSG_RESULT($topcom_package)
484 if test "$topcom_package" != no; then
486 if test "$topcom_package" != unspecified; then
487 topcom_path="$topcom_package/bin"
489 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
490 if test -n "$POINTS2TRIANGS"; then
492 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
493 [Path of points2triangs])
496 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
499 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
506 suffix="normal", suffix="broken")
507 AC_CONFIG_COMMANDS([barvinok/set.h],
508 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
510 AC_CONFIG_COMMANDS([barvinok/NTL.h],
511 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
514 SAVE_CPPFLAGS="$CPPFLAGS"
515 CPPFLAGS="-I$srcdir $CPPFLAGS"
516 AC_TRY_COMPILE([#include "fdstream.h"],[],
517 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
519 CPPFLAGS="$SAVE_CPPFLAGS"
521 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
523 AC_CONFIG_COMMANDS([interface/isl.py.top],
524 [cp $srcdir/interface/isl.py.$pet_suffix interface/isl.py.top],
525 [pet_suffix="$pet_suffix"])
527 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
528 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
529 AX_CREATE_PKGCONFIG_INFO
531 AH_BOTTOM([#include "config_post.h"])
532 AC_CONFIG_HEADERS(config.h)
533 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
534 AC_CONFIG_FILES(parker/Makefile)
535 if test $with_polylib = bundled; then
536 AC_CONFIG_SUBDIRS(polylib)
538 if test $with_isl = bundled; then
539 AC_CONFIG_SUBDIRS(isl)
541 if test $with_pet = bundled; then
542 AC_CONFIG_SUBDIRS(pet)
544 AC_CONFIG_COMMANDS_POST([
545 dnl pass on arguments to subdir configures, but don't
546 dnl add them to config.status
547 ac_configure_args="$ac_configure_args $bv_configure_args"