barvinok.cc: avoid use of isl_union_pw_qpolynomial_add_pw_qpolynomial
[barvinok/uuh.git] / configure.ac
blobb917f32066d773f8bc76d31e3d9a46f71de6b295
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])])
5 AC_PROG_CC
7 AC_PROG_CXX
8 AM_PROG_LEX
9 AC_PROG_YACC
10 AC_SUBST(versioninfo)
11 versioninfo=23:2: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_gmp_prefix=$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 AX_SUBMODULE(gmp,system,system)
72 if test "x$with_gmp_prefix" != "x"; then
73         bv_configure_args="$bv_configure_args --with-libgmp=$with_gmp_prefix"
74         CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
75         LDFLAGS="-L$with_gmp_prefix/lib $LDFLAGS"
76 else
77         bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
79 poly_cv_gmpfatal="no"
80 AC_CHECK_HEADER(gmp.h,
81         [AC_CHECK_LIB(gmp,main,
82             [],
83             [poly_cv_gmpfatal="yes"])],
84         [poly_cv_gmpfatal="yes"])
85 if test "$poly_cv_gmpfatal" = "yes"; then
86         AC_MSG_ERROR([GMP not found])
88 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
90 AX_SUBMODULE(polylib,build|bundled|system,bundled)
92 AC_SUBST(POLYLIB_CPPFLAGS)
93 AC_SUBST(POLYLIB_LDFLAGS)
94 AC_SUBST(POLYLIB_LIBS)
95 case "$with_polylib" in
96 bundled)
97         bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
98         POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
99         ;;
100 build)
101         with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
102         POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
103         POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
104         ;;
105 system)
106         POLYLIB_LIBS="-lpolylibgmp"
107         if test "x$with_polylib_prefix" != "x"; then
108                 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
109                 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
110         fi
111         SAVE_CPPFLAGS="$CPPFLAGS"
112         CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
113         AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
114                 AC_MSG_ERROR(Need PolyLib)
115         ])
116         CPPFLAGS="$SAVE_CPPFLAGS"
117 esac
119 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
121 AX_SUBMODULE(isl,build|bundled|system,bundled)
123 AC_SUBST(ISL_CFLAGS)
124 AC_SUBST(ISL_LIBS)
125 AC_SUBST(ISL_BUILDDIR)
126 case "$with_isl" in
127 bundled)
128         ISL_BUILDDIR=isl
129         ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
130         bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
131         PACKAGE_CFLAGS_ISL='-I${prefix}/include'
132         ;;
133 build)
134         ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
135         bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
136         ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
137         PACKAGE_CFLAGS_ISL='-I${prefix}/include'
138         ;;
139 system)
140         PKG_CHECK_MODULES([ISL], [isl])
141         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
142 esac
143 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
144 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
146 AX_SUBMODULE(pet,bundled|build|system|no,no)
147 AC_SUBST(PET_CFLAGS)
148 AC_SUBST(PET_LIBS)
149 AC_SUBST(PET_BUILDDIR)
150 case "$with_pet" in
151 bundled)
152         PET_CFLAGS="-I\$(top_srcdir)/pet/include"
153         AC_DEFINE(HAVE_PET,[],[use Pet])
154         ;;
155 build)
156         PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
157         PET_CFLAGS="-I$pet_srcdir/include"
158         AC_DEFINE(HAVE_PET,[],[use Pet])
159         ;;
160 system)
161         PKG_CHECK_MODULES([PET], [pet])
162         AC_DEFINE(HAVE_PET,[],[use Pet])
163 esac
164 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
165 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
167 AC_MSG_CHECKING(if the fractional representation should be used)
168 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
169                                           [Don't use fractional representation])],
170             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
171 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
172                                       [Don't use fractional representation])],
173             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
174 AC_MSG_RESULT($bv_cv_modulo)
175 if test "x$bv_cv_modulo" != "xno" ; then
176         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
179 AC_MSG_CHECKING(whether to use incremental algorithm)
180 AC_ARG_ENABLE(incremental,
181         [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
182                         [Enable incremental algorithm [bf]])],
183         [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
184 AC_MSG_RESULT($bv_cv_incremental)
185 case $bv_cv_incremental in
186         yes | bf)
187                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
188                           [Use breadth-first incremental algorithm])
189         ;;
190         df)
191                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
192                           [Use depth-first incremental algorithm])
193         ;;
194 esac
196 AC_ARG_WITH(ntl,
197             [  --with-ntl=DIR          DIR Location of NTL],
198             [ echo "Package ntl : $withval" && ntl_package=$withval],  
199             [ ntl_package=yes ])
201 if test "$ntl_package" = "no"; then
202     AC_MSG_ERROR(Need ntl)
205 AC_SUBST(NTL_CPPFLAGS)
206 AC_SUBST(NTL_LDFLAGS)
207 if test "$ntl_package" != "yes"; then
208     NTL_CPPFLAGS="-I$ntl_package/include"
209     NTL_LDFLAGS="-L$ntl_package/lib"
212 bv_no_ntl=false
213 SAVE_CPPFLAGS="$CPPFLAGS"
214 SAVE_LDFLAGS="$LDFLAGS"
215 CPPFLAGS="$NTL_CPPFLAGS $CPPFLAGS"
216 LDFLAGS="$NTL_LDFLAGS $LDFLAGS"
217 AC_LANG_PUSH(C++)
218 AC_CHECK_HEADER([NTL/ZZ.h],[],[bv_no_ntl=true])
219 AC_EGREP_CPP(yes, [
220     #include <NTL/ZZ.h>
221     #ifdef NTL_GMP_LIP
222     yes
223     #endif
224     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
225 AC_LANG_POP
227 AC_CHECK_LIB(ntl, main,[],[bv_no_ntl=true])
228 if test "$bv_no_ntl" = "true"; then
229     AC_MSG_ERROR(Need ntl)
231 CPPFLAGS="$SAVE_CPPFLAGS"
232 LDFLAGS="$SAVE_LDFLAGS"
234 AC_SUBST(bv_cone_hilbert_basis)
235 AC_MSG_CHECKING(whether to compile zsolve)
236 AC_ARG_WITH(zsolve,
237             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
238             [ with_zsolve=$withval],  [ with_zsolve=yes ])
239 AC_MSG_RESULT($with_zsolve)
241 use_zsolve=false
242 if test "$with_zsolve" != "no"; then
243         if test "$GCC" = "yes"; then
244                 $CC --version |
245                 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
246                 (read major minor
247                         if test $major -gt 3; then
248                                 exit 0
249                         fi
250                         if test $major -eq 3 -a $minor -ge 4; then
251                                 exit 0
252                         fi
253                         exit 1
254                 ) && use_zsolve=true
255         fi
256         if test "$use_zsolve" = false; then
257                 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
258         else
259                 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
260                 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
261         fi
263 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
265 AX_SUBMODULE(omega,no|system,no)
267 AC_SUBST(OMEGA_CPPFLAGS)
268 AC_SUBST(OMEGA_LDFLAGS)
269 AC_SUBST(OMEGA_LIBS)
270 AC_SUBST(OMEGA_CODEGEN_LIBS)
271 have_omega=false
272 have_codegen=false
273 case "$with_omega" in
274 system)
275     if test "x$with_omega_prefix" != "xyes"; then
276         OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
277         OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
278     else
279         for i in /usr/include /usr/local/include; do
280             if test -f $i/omega/omega.h; then
281                 OMEGA_CPPFLAGS="-I$i/omega"
282             fi
283         done
284     fi
286     AC_LANG_PUSH(C++)
287     SAVE_CPPFLAGS="$CPPFLAGS"
288     SAVE_LDFLAGS="$LDFLAGS"
289     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
290     LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
291     AC_CHECK_HEADERS([omega.h],[
292         OMEGA_LIBS="-lomega"
293         AC_CHECK_LIB(code_gen,main,[
294                 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
295                 have_codegen=true
296         ])
297         have_omega=true
298     ],[AC_MSG_WARN(Omega not found)])
299     CPPFLAGS="$SAVE_CPPFLAGS"
300     LDFLAGS="$SAVE_LDFLAGS"
301     AC_LANG_POP
302     ;;
303 esac
304 if test "$have_omega" = true; then
305         AC_DEFINE(HAVE_OMEGA,[],[use omega])
307 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
309 use_parker=false
310 AC_MSG_CHECKING(whether to compile parker)
311 AC_ARG_WITH(parker,
312             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
313             [ with_parker=$withval],  [ with_parker=yes ])
314 AC_MSG_RESULT($with_parker)
316 if test "$with_parker" != "no"; then
317         AC_MSG_CHECKING(for mona)
318         AC_ARG_WITH(mona,
319                 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
320                                 [], [AC_MSG_RESULT(not specified)])
322         if test "x$with_mona" != "x"; then
323                 AC_SUBST(MONAPATH)
324                 MONAPATH=$with_mona
325                 AC_MSG_RESULT($MONAPATH)
326                 use_parker=true
327                 AC_DEFINE(USE_PARKER,[],[use parker])
328         fi
330         if test "x$with_mona" = "x"; then
331                 AC_MSG_WARN(mona source directory required to compile parker)
332                 AC_MSG_WARN(http://www.brics.dk/mona/download)
333         fi
335 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
337 AC_MSG_CHECKING(whether to use cddlib)
338 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
339             [ cddlib_package=$withval],  [ cddlib_package=yes ])
340 AC_MSG_RESULT($cddlib_package)
342 have_cddlib=false
343 if test "$cddlib_package" != "no"; then
344     if test "x$cddlib_package" != "xyes"; then
345         CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
346         LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
347     fi
348     AC_TRY_LINK([
349 #define GMPRATIONAL
350 #include <setoper.h>
351 #include <cddmp.h>
352 ], [
353     mytype a;
354     dd_init(a); ], [
355         have_cddlib=true
356         AC_CHECK_LIB(cddgmp, main,[
357                 SAVE_LIBS="$LIBS"
358                 LIBS="-lcddgmp $LIBS"
359                 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
360                 AC_LANG_PUSH(C++)
361                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
362 #include <setoper.h>
363 #include <cdd.h>]],
364                 [[
365         const char *filename = SRCDIR"/cdd94e-test";
366         FILE *f;
367         dd_MatrixPtr M;
368         dd_LPType *lp;
369         dd_ErrorType err = dd_NoError;
371         dd_set_global_constants();
373         f = fopen(filename, "r");
374         M = dd_PolyFile2Matrix(f, &err);
375         lp = dd_Matrix2LP(M, &err);
376         dd_LPSolve(lp, dd_DualSimplex, &err);
377         return lp->LPS == dd_Inconsistent;
378                 ]])],[
379                         AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
380                 ],[
381                         AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
382                         LIBS="$SAVE_LIBS"
383                         have_cddlib=false
384                 ])
385                 AC_LANG_POP
386         ],[have_cddlib=false])
387     ])
389 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
393 AC_MSG_CHECKING(whether to use GLPK)
394 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
395             [ glpk_package=$withval],  [ glpk_package=yes ])
396 AC_MSG_RESULT($glpk_package)
398 have_glpk=false
399 if test "$glpk_package" != "no"; then
400     if test "x$glpk_package" != "xyes"; then
401         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
402         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
403     fi
404     AC_CHECK_HEADERS([glpk.h],[
405         have_glpk=true
406         AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
407     ])
409 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
411 AC_MSG_CHECKING(location of TOPCOM)
412 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
413             [topcom_package=$withval], [topcom_package=unspecified])
414 AC_MSG_RESULT($topcom_package)
415 have_topcom=false
416 if test "$topcom_package" != no; then
417         topcom_path="$PATH"
418         if test "$topcom_package" != unspecified; then
419                 topcom_path="$topcom_package/bin"
420         fi
421         AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
422         if test -n "$POINTS2TRIANGS"; then
423                 have_topcom=true
424                 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
425                                     [Path of points2triangs])
426         fi
428 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
430 AX_DETECT_GIT_HEAD
431 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
433 AC_LANG_PUSH(C++)
434 AC_TRY_COMPILE([
435                 #include <set>
436                 void negate();
437         ], [negate()],
438         suffix="normal", suffix="broken")
439 AC_CONFIG_COMMANDS([barvinok/set.h],
440                    [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
441                    [suffix="$suffix"])
442 AC_CONFIG_COMMANDS([barvinok/NTL.h],
443                    [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
444                    [suffix="$suffix"])
445 use_fdstream=false
446 SAVE_CPPFLAGS="$CPPFLAGS"
447 CPPFLAGS="-I$srcdir $CPPFLAGS"
448 AC_TRY_COMPILE([#include "fdstream.h"],[],
449         [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
450         use_fdstream=true])
451 CPPFLAGS="$SAVE_CPPFLAGS"
452 AC_LANG_POP
453 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
455 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
456 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
457 AX_CREATE_PKGCONFIG_INFO
459 AC_CONFIG_HEADERS(config.h)
460 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
461 AC_CONFIG_FILES(parker/Makefile)
462 if test $with_polylib = bundled; then
463         AC_CONFIG_SUBDIRS(polylib)
465 if test $with_isl = bundled; then
466         AC_CONFIG_SUBDIRS(isl)
468 if test $with_pet = bundled; then
469         AC_CONFIG_SUBDIRS(pet)
471 AC_CONFIG_COMMANDS_POST([
472         dnl pass on arguments to subdir configures, but don't
473         dnl add them to config.status
474         ac_configure_args="$ac_configure_args $bv_configure_args"
476 AC_OUTPUT