iscc: add "cross_range" operation
[barvinok.git] / configure.ac
blobb7795251a3fbdc1aa0a017c11fbe630bfbbc18fb
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])])
5 AC_PROG_CC
7 AC_PROG_CXX
8 AM_PROG_LEX
9 AC_PROG_YACC
10 AC_SUBST(versioninfo)
11 versioninfo=23:4:0
13 AC_CANONICAL_HOST
14 AC_LIBTOOL_WIN32_DLL
15 AC_SUBST(BV_LDFLAGS)
16 case $host in
17         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
18         if test "$enable_shared" = yes; then
19                 BV_LDFLAGS="-no-undefined" 
20         fi
21         ;;
22 esac
24 AC_PROG_LIBTOOL
26 PKG_PROG_PKG_CONFIG
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"
42 AX_C___ATTRIBUTE__
43 AX_CXX_COMPILE_STDCXX_11([], [optional])
44 AX_UNORDERED_MAP
45 AC_CXX_GNUCXX_HASHMAP
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
54         fi
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
59         fi
60         if test "${with_cddlib+set}" != set -a \
61            -f "$with_default_prefix/include/cddmp.h"; then
62                 with_cddlib=$with_default_prefix
63         fi
64         if test "${with_glpk+set}" != set -a \
65            -f "$with_default_prefix/include/glpk.h"; then
66                 with_glpk=$with_default_prefix
67         fi
68         if test "${with_topcom+set}" != set -a \
69            -f "$with_default_prefix/bin/points2triangs"; then
70                 with_topcom=$with_default_prefix
71         fi
74 AX_SUBMODULE(gmp,system|build,system)
76 case "$with_gmp" in
77 build)
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"
84         ;;
85 system)
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"
91         else
92                 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
93         fi
94         ;;
95 esac
97 poly_cv_gmpfatal="no"
98 AC_CHECK_HEADER(gmp.h,
99         [AC_CHECK_LIB(gmp,main,
100             [],
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
114 bundled)
115         bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
116         POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
117         ;;
118 build)
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"
122         ;;
123 system)
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"
128         fi
129         SAVE_CPPFLAGS="$CPPFLAGS"
130         CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
131         AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
132                 AC_MSG_ERROR(Need PolyLib)
133         ])
134         CPPFLAGS="$SAVE_CPPFLAGS"
135 esac
137 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
139 AX_SUBMODULE(isl,build|bundled|system,bundled)
141 AC_SUBST(ISL_CFLAGS)
142 AC_SUBST(ISL_LIBS)
143 AC_SUBST(ISL_SRCDIR)
144 AC_SUBST(ISL_BUILDDIR)
145 case "$with_isl" in
146 bundled)
147         ISL_SRCDIR="$srcdir/isl"
148         ISL_BUILDDIR=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'
152         ;;
153 build)
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'
159         ;;
160 system)
161         PKG_CHECK_MODULES([ISL], [isl])
162         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
163 esac
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)
168 AC_SUBST(PET_CFLAGS)
169 AC_SUBST(PET_LIBS)
170 AC_SUBST(PET_BUILDDIR)
171 pet_suffix="top.pet"
172 case "$with_pet" in
173 bundled)
174         PET_CFLAGS="-I\$(top_srcdir)/pet/include"
175         AC_DEFINE(HAVE_PET,[],[use Pet])
176         ;;
177 build)
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])
181         ;;
182 system)
183         PKG_CHECK_MODULES([PET], [pet])
184         AC_DEFINE(HAVE_PET,[],[use Pet])
185         ;;
187         pet_suffix="top.no_pet"
188         ;;
189 esac
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
200         yes | bf)
201                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
202                           [Use breadth-first incremental algorithm])
203         ;;
204         df)
205                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
206                           [Use depth-first incremental algorithm])
207         ;;
208 esac
210 AC_ARG_WITH(ntl,
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
226                                            use of build NTL]))
227         fi
228         with_ntl="build"
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
234                                            use of system NTL]))
235         fi
236         with_ntl="system"
239 case "$with_ntl" in
240 build|system)
241         ;;
243         with_ntl="system"
244         ;;
245 esac
246 AC_MSG_CHECKING([which NTL to use])
247 AC_MSG_RESULT($with_ntl)
249 AC_SUBST(NTL_CPPFLAGS)
250 AC_SUBST(NTL_LDFLAGS)
251 case "$with_ntl" in
252 build)
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]))
265                 else
266                         AC_MSG_ERROR([Could not find NTL in the builddir])
267                 fi
268         fi
269         ;;
270 system)
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"
274         fi
275         ;;
276 esac
278 AX_CHECK_NTL
280 AC_SUBST(bv_cone_hilbert_basis)
281 AC_MSG_CHECKING(whether to compile zsolve)
282 AC_ARG_WITH(zsolve,
283             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
284             [ with_zsolve=$withval],  [ with_zsolve=yes ])
285 AC_MSG_RESULT($with_zsolve)
287 use_zsolve=false
288 if test "$with_zsolve" != "no"; then
289         if test "$GCC" = "yes"; then
290                 $CC --version |
291                 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
292                 (read major minor
293                         if test $major -gt 3; then
294                                 exit 0
295                         fi
296                         if test $major -eq 3 -a $minor -ge 4; then
297                                 exit 0
298                         fi
299                         exit 1
300                 ) && use_zsolve=true
301         fi
302         if test "$use_zsolve" = false; then
303                 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
304         else
305                 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
306                 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
307         fi
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)
315 AC_SUBST(OMEGA_LIBS)
316 AC_SUBST(OMEGA_CODEGEN_LIBS)
317 have_omega=false
318 have_codegen=false
319 case "$with_omega" in
320 system)
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"
324     else
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"
328             fi
329         done
330     fi
332     AC_LANG_PUSH(C++)
333     SAVE_CPPFLAGS="$CPPFLAGS"
334     SAVE_LDFLAGS="$LDFLAGS"
335     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
336     LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
337     AC_CHECK_HEADERS([omega.h],[
338         OMEGA_LIBS="-lomega"
339         AC_CHECK_LIB(code_gen,main,[
340                 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
341                 have_codegen=true
342         ])
343         have_omega=true
344     ],[AC_MSG_WARN(Omega not found)])
345     CPPFLAGS="$SAVE_CPPFLAGS"
346     LDFLAGS="$SAVE_LDFLAGS"
347     AC_LANG_POP
348     ;;
349 esac
350 if test "$have_omega" = true; then
351         AC_DEFINE(HAVE_OMEGA,[],[use omega])
353 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
355 use_parker=false
356 AC_MSG_CHECKING(whether to compile parker)
357 AC_ARG_WITH(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)
364         AC_ARG_WITH(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
369                 AC_SUBST(MONAPATH)
370                 MONAPATH=$with_mona
371                 AC_MSG_RESULT($MONAPATH)
372                 use_parker=true
373                 AC_DEFINE(USE_PARKER,[],[use parker])
374         fi
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)
379         fi
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)
388 have_cddlib=false
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"
393     fi
394     AC_TRY_LINK([
395 #define GMPRATIONAL
396 #include <setoper.h>
397 #include <cddmp.h>
398 ], [
399     mytype a;
400     dd_init(a); ], [
401         have_cddlib=true
402         AC_CHECK_LIB(cddgmp, main,[
403                 SAVE_LIBS="$LIBS"
404                 LIBS="-lcddgmp $LIBS"
405                 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
406                 AC_LANG_PUSH(C++)
407                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
408 #include <setoper.h>
409 #include <cdd.h>]],
410                 [[
411         const char *filename = SRCDIR"/cdd94e-test";
412         FILE *f;
413         dd_MatrixPtr M;
414         dd_LPType *lp;
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;
424                 ]])],[
425                         AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
426                 ],[
427                         AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
428                         LIBS="$SAVE_LIBS"
429                         have_cddlib=false
430                 ])
431                 AC_LANG_POP
432         ],[have_cddlib=false])
433     ])
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)
444 have_glpk=false
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"
449     fi
450     AC_CHECK_HEADERS([glpk.h],[
451         have_glpk=true
452         AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
453     ])
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)
461 have_topcom=false
462 if test "$topcom_package" != no; then
463         topcom_path="$PATH"
464         if test "$topcom_package" != unspecified; then
465                 topcom_path="$topcom_package/bin"
466         fi
467         AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
468         if test -n "$POINTS2TRIANGS"; then
469                 have_topcom=true
470                 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
471                                     [Path of points2triangs])
472         fi
474 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
476 AX_DETECT_GIT_HEAD
477 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
479 AC_LANG_PUSH(C++)
480 AC_TRY_COMPILE([
481                 #include <set>
482                 void negate();
483         ], [negate()],
484         suffix="normal", suffix="broken")
485 AC_CONFIG_COMMANDS([barvinok/set.h],
486                    [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
487                    [suffix="$suffix"])
488 AC_CONFIG_COMMANDS([barvinok/NTL.h],
489                    [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
490                    [suffix="$suffix"])
491 use_fdstream=false
492 SAVE_CPPFLAGS="$CPPFLAGS"
493 CPPFLAGS="-I$srcdir $CPPFLAGS"
494 AC_TRY_COMPILE([#include "fdstream.h"],[],
495         [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
496         use_fdstream=true])
497 CPPFLAGS="$SAVE_CPPFLAGS"
498 AC_LANG_POP
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"
527 AC_OUTPUT