test_bound.c: verify_point: use isl_val
[barvinok/uuh.git] / configure.ac
blobcf264c210ca806499fad892144b9dba247c548f9
1 AC_INIT([barvinok], [0.36], [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])])
5 AC_PROG_CC
7 AC_PROG_CXX
8 AM_PROG_LEX
9 AC_PROG_YACC
10 AC_SUBST(versioninfo)
11 versioninfo=23:1: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 AC_CXX_GNUCXX_HASHMAP
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
51         fi
52         if test "${with_ntl+set}" != set -a \
53            -f "$with_default_prefix/include/NTL/ZZ.h"; then
54                 with_ntl=$with_default_prefix
55         fi
56         if test "${with_cddlib+set}" != set -a \
57            -f "$with_default_prefix/include/cddmp.h"; then
58                 with_cddlib=$with_default_prefix
59         fi
60         if test "${with_glpk+set}" != set -a \
61            -f "$with_default_prefix/include/glpk.h"; then
62                 with_glpk=$with_default_prefix
63         fi
64         if test "${with_topcom+set}" != set -a \
65            -f "$with_default_prefix/bin/points2triangs"; then
66                 with_topcom=$with_default_prefix
67         fi
70 dnl Check for GMP library
71 AC_MSG_CHECKING(whether to use GMP)
72 AC_ARG_WITH(libgmp, 
73         [  --with-libgmp           DIR Location of the GMP Distribution], 
74         gmp_package=$withval, gmp_package=yes)
75 if test "x$gmp_package" = "xno"; then
76         AC_MSG_RESULT(no)
77         AC_MSG_ERROR(Need gmp)
78 else
79         AC_MSG_RESULT(yes)
80         if test "x$gmp_package" = "xyes"; then
81                 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
82         else
83             bv_configure_args="$bv_configure_args --with-libgmp=$gmp_package"
84             bv_configure_args="$bv_configure_args --with-gmp-prefix=$gmp_package"
85             GMP_DIR=$gmp_package
86             if test ! -d "$GMP_DIR"; then
87                 AC_ERROR(Directory given for GMP Distribution is not a directory)
88             fi
89             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
90             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
91         fi
92         poly_cv_gmpfatal="no"
93         AC_CHECK_HEADER(gmp.h,
94                 [AC_CHECK_LIB(gmp,main,
95                     [],
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])
100         fi
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
110 bundled)
111         bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
112         POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
113         ;;
114 build)
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"
118         ;;
119 system)
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"
124         fi
125         SAVE_CPPFLAGS="$CPPFLAGS"
126         CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
127         AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
128                 AC_MSG_ERROR(Need PolyLib)
129         ])
130         CPPFLAGS="$SAVE_CPPFLAGS"
131 esac
133 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
135 AX_SUBMODULE(isl,build|bundled|system,bundled)
137 AC_SUBST(ISL_CFLAGS)
138 AC_SUBST(ISL_LIBS)
139 AC_SUBST(ISL_BUILDDIR)
140 case "$with_isl" in
141 bundled)
142         ISL_BUILDDIR=isl
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'
146         ;;
147 build)
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'
152         ;;
153 system)
154         PKG_CHECK_MODULES([ISL], [isl])
155         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
156 esac
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)
161 AC_SUBST(PET_CFLAGS)
162 AC_SUBST(PET_LIBS)
163 AC_SUBST(PET_BUILDDIR)
164 case "$with_pet" in
165 bundled)
166         PET_CFLAGS="-I\$(top_srcdir)/pet/include"
167         AC_DEFINE(HAVE_PET,[],[use Pet])
168         ;;
169 build)
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])
173         ;;
174 system)
175         PKG_CHECK_MODULES([PET], [pet])
176         AC_DEFINE(HAVE_PET,[],[use Pet])
177 esac
178 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
179 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
181 AC_MSG_CHECKING(if the fractional representation should be used)
182 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
183                                           [Don't use fractional representation])],
184             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
185 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
186                                       [Don't use fractional representation])],
187             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
188 AC_MSG_RESULT($bv_cv_modulo)
189 if test "x$bv_cv_modulo" != "xno" ; then
190         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
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             [  --with-ntl=DIR          DIR Location of NTL],
212             [ echo "Package ntl : $withval" && ntl_package=$withval],  
213             [ ntl_package=yes ])
215 if test "$ntl_package" = "no"; then
216     AC_MSG_ERROR(Need ntl)
219 AC_SUBST(NTL_CPPFLAGS)
220 AC_SUBST(NTL_LDFLAGS)
221 if test "$ntl_package" != "yes"; then
222     NTL_CPPFLAGS="-I$ntl_package/include"
223     NTL_LDFLAGS="-L$ntl_package/lib"
226 bv_no_ntl=false
227 SAVE_CPPFLAGS="$CPPFLAGS"
228 SAVE_LDFLAGS="$LDFLAGS"
229 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
230 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
231 AC_LANG_PUSH(C++)
232 AC_CHECK_HEADER([NTL/ZZ.h],[],[bv_no_ntl=true])
233 AC_EGREP_CPP(yes, [
234     #include <NTL/ZZ.h>
235     #ifdef NTL_GMP_LIP
236     yes
237     #endif
238     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
239 AC_LANG_POP
241 AC_CHECK_LIB(ntl, main,[],[bv_no_ntl=true])
242 if test "$bv_no_ntl" = "true"; then
243     AC_MSG_ERROR(Need ntl)
245 CPPFLAGS="$SAVE_CPPFLAGS"
246 LDFLAGS="$SAVE_LDFLAGS"
248 AC_SUBST(bv_cone_hilbert_basis)
249 AC_MSG_CHECKING(whether to compile zsolve)
250 AC_ARG_WITH(zsolve,
251             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
252             [ with_zsolve=$withval],  [ with_zsolve=yes ])
253 AC_MSG_RESULT($with_zsolve)
255 use_zsolve=false
256 if test "$with_zsolve" != "no"; then
257         if test "$GCC" = "yes"; then
258                 $CC --version |
259                 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
260                 (read major minor
261                         if test $major -gt 3; then
262                                 exit 0
263                         fi
264                         if test $major -eq 3 -a $minor -ge 4; then
265                                 exit 0
266                         fi
267                         exit 1
268                 ) && use_zsolve=true
269         fi
270         if test "$use_zsolve" = false; then
271                 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
272         else
273                 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
274                 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
275         fi
277 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
279 AX_SUBMODULE(omega,no|system,no)
281 AC_SUBST(OMEGA_CPPFLAGS)
282 AC_SUBST(OMEGA_LDFLAGS)
283 AC_SUBST(OMEGA_LIBS)
284 AC_SUBST(OMEGA_CODEGEN_LIBS)
285 have_omega=false
286 have_codegen=false
287 case "$with_omega" in
288 system)
289     if test "x$with_omega_prefix" != "xyes"; then
290         OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
291         OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
292     else
293         for i in /usr/include /usr/local/include; do
294             if test -f $i/omega/omega.h; then
295                 OMEGA_CPPFLAGS="-I$i/omega"
296             fi
297         done
298     fi
300     AC_LANG_PUSH(C++)
301     SAVE_CPPFLAGS="$CPPFLAGS"
302     SAVE_LDFLAGS="$LDFLAGS"
303     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
304     LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
305     AC_CHECK_HEADERS([omega.h],[
306         OMEGA_LIBS="-lomega"
307         AC_CHECK_LIB(code_gen,main,[
308                 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
309                 have_codegen=true
310         ])
311         have_omega=true
312     ],[AC_MSG_WARN(Omega not found)])
313     CPPFLAGS="$SAVE_CPPFLAGS"
314     LDFLAGS="$SAVE_LDFLAGS"
315     AC_LANG_POP
316     ;;
317 esac
318 if test "$have_omega" = true; then
319         AC_DEFINE(HAVE_OMEGA,[],[use omega])
321 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
323 use_parker=false
324 AC_MSG_CHECKING(whether to compile parker)
325 AC_ARG_WITH(parker,
326             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
327             [ with_parker=$withval],  [ with_parker=yes ])
328 AC_MSG_RESULT($with_parker)
330 if test "$with_parker" != "no"; then
331         AC_MSG_CHECKING(for mona)
332         AC_ARG_WITH(mona,
333                 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
334                                 [], [AC_MSG_RESULT(not specified)])
336         if test "x$with_mona" != "x"; then
337                 AC_SUBST(MONAPATH)
338                 MONAPATH=$with_mona
339                 AC_MSG_RESULT($MONAPATH)
340                 use_parker=true
341                 AC_DEFINE(USE_PARKER,[],[use parker])
342         fi
344         if test "x$with_mona" = "x"; then
345                 AC_MSG_WARN(mona source directory required to compile parker)
346                 AC_MSG_WARN(http://www.brics.dk/mona/download)
347         fi
349 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
351 AC_MSG_CHECKING(whether to use cddlib)
352 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
353             [ cddlib_package=$withval],  [ cddlib_package=yes ])
354 AC_MSG_RESULT($cddlib_package)
356 have_cddlib=false
357 if test "$cddlib_package" != "no"; then
358     if test "x$cddlib_package" != "xyes"; then
359         CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
360         LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
361     fi
362     AC_TRY_LINK([
363 #define GMPRATIONAL
364 #include <setoper.h>
365 #include <cddmp.h>
366 ], [
367     mytype a;
368     dd_init(a); ], [
369         have_cddlib=true
370         AC_CHECK_LIB(cddgmp, main,[
371                 SAVE_LIBS="$LIBS"
372                 LIBS="-lcddgmp $LIBS"
373                 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
374                 AC_LANG_PUSH(C++)
375                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
376 #include <setoper.h>
377 #include <cdd.h>]],
378                 [[
379         const char *filename = SRCDIR"/cdd94e-test";
380         FILE *f;
381         dd_MatrixPtr M;
382         dd_LPType *lp;
383         dd_ErrorType err = dd_NoError;
385         dd_set_global_constants();
387         f = fopen(filename, "r");
388         M = dd_PolyFile2Matrix(f, &err);
389         lp = dd_Matrix2LP(M, &err);
390         dd_LPSolve(lp, dd_DualSimplex, &err);
391         return lp->LPS == dd_Inconsistent;
392                 ]])],[
393                         AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
394                 ],[
395                         AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
396                         LIBS="$SAVE_LIBS"
397                         have_cddlib=false
398                 ])
399                 AC_LANG_POP
400         ],[have_cddlib=false])
401     ])
403 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
407 AC_MSG_CHECKING(whether to use GLPK)
408 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
409             [ glpk_package=$withval],  [ glpk_package=yes ])
410 AC_MSG_RESULT($glpk_package)
412 have_glpk=false
413 if test "$glpk_package" != "no"; then
414     if test "x$glpk_package" != "xyes"; then
415         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
416         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
417     fi
418     AC_CHECK_HEADERS([glpk.h],[
419         have_glpk=true
420         AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
421     ])
423 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
425 AC_MSG_CHECKING(location of TOPCOM)
426 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
427             [topcom_package=$withval], [topcom_package=unspecified])
428 AC_MSG_RESULT($topcom_package)
429 have_topcom=false
430 if test "$topcom_package" != no; then
431         topcom_path="$PATH"
432         if test "$topcom_package" != unspecified; then
433                 topcom_path="$topcom_package/bin"
434         fi
435         AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
436         if test -n "$POINTS2TRIANGS"; then
437                 have_topcom=true
438                 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
439                                     [Path of points2triangs])
440         fi
442 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
444 AC_SUBST(GIT_HEAD_ID)
445 AC_SUBST(GIT_HEAD)
446 AC_SUBST(GIT_HEAD_VERSION)
447 if test -f $srcdir/.git/HEAD; then
448     GIT_HEAD="$srcdir/.git/index"
449     GIT_REPO="$srcdir/.git"
450     GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
451 elif test -f $srcdir/GIT_HEAD_ID; then
452     GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
453 else
454     mysrcdir=`(cd $srcdir; pwd)`
455     head=`basename $mysrcdir | sed -e 's/.*-//'`
456     head2=`echo $head | sed -e 's/[^0-9a-f]//'`
457     head3=`echo $head2 | sed -e 's/........................................//'`
458     base=`basename $mysrcdir | sed -e 's/-.*//'`
459     if test "x$head3" = "x" -a "x$head" = "x$head2"; then
460         GIT_HEAD_ID="barvinok-$VERSION-$head
461     elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
462         GIT_HEAD_ID="barvinok-$VERSION-$head
463     else
464         GIT_HEAD_ID="UNKNOWN"
465     fi
467 if test -z "$GIT_REPO" ; then
468     GIT_HEAD_VERSION="$GIT_HEAD_ID"
469 else
470     GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
472 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
474 AC_LANG_PUSH(C++)
475 AC_TRY_COMPILE([
476                 #include <set>
477                 void negate();
478         ], [negate()],
479         suffix="normal", suffix="broken")
480 AC_CONFIG_COMMANDS([barvinok/set.h],
481                    [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
482                    [suffix="$suffix"])
483 AC_CONFIG_COMMANDS([barvinok/NTL.h],
484                    [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
485                    [suffix="$suffix"])
486 use_fdstream=false
487 SAVE_CPPFLAGS="$CPPFLAGS"
488 CPPFLAGS="-I$srcdir $CPPFLAGS"
489 AC_TRY_COMPILE([#include "fdstream.h"],[],
490         [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
491         use_fdstream=true])
492 CPPFLAGS="$SAVE_CPPFLAGS"
493 AC_LANG_POP
494 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
496 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
497 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
498 AX_CREATE_PKGCONFIG_INFO
500 AC_CONFIG_HEADERS(config.h)
501 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
502 AC_CONFIG_FILES(parker/Makefile)
503 if test $with_polylib = bundled; then
504         AC_CONFIG_SUBDIRS(polylib)
506 if test $with_isl = bundled; then
507         AC_CONFIG_SUBDIRS(isl)
509 if test $with_pet = bundled; then
510         AC_CONFIG_SUBDIRS(pet)
512 AC_CONFIG_COMMANDS_POST([
513         dnl pass on arguments to subdir configures, but don't
514         dnl add them to config.status
515         ac_configure_args="$ac_configure_args $bv_configure_args"
517 AC_OUTPUT