update polylib for .gitignore
[barvinok.git] / configure.ac
blob6f0112a9bacecafc4bcbccc4ed631e3fffa8b634
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 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            "${with_ntl_prefix+set}" != set -a \
54            -f "$with_default_prefix/include/NTL/ZZ.h"; then
55                 with_ntl_prefix=$with_default_prefix
56         fi
57         if test "${with_cddlib+set}" != set -a \
58            -f "$with_default_prefix/include/cddmp.h"; then
59                 with_cddlib=$with_default_prefix
60         fi
61         if test "${with_glpk+set}" != set -a \
62            -f "$with_default_prefix/include/glpk.h"; then
63                 with_glpk=$with_default_prefix
64         fi
65         if test "${with_topcom+set}" != set -a \
66            -f "$with_default_prefix/bin/points2triangs"; then
67                 with_topcom=$with_default_prefix
68         fi
71 AX_SUBMODULE(gmp,system|build,system)
73 case "$with_gmp" in
74 build)
75         with_gmp_builddir=`echo @abs_builddir@ | \
76                            $with_gmp_builddir/config.status --file=-`
77         CPPFLAGS="-I$with_gmp_builddir $CPPFLAGS"
78         LDFLAGS="-L$with_gmp_builddir/$lt_cv_objdir $LDFLAGS"
79         bv_extra="--with-gmp --with-gmp-builddir=$with_gmp_builddir"
80         bv_configure_args="$bv_configure_args $bv_extra"
81         ;;
82 system)
83         if test "x$with_gmp_prefix" != "x"; then
84                 bv_extra="--with-libgmp=$with_gmp_prefix"
85                 bv_configure_args="$bv_configure_args $bv_extra"
86                 CPPFLAGS="-I$with_gmp_prefix/include $CPPFLAGS"
87                 LDFLAGS="-L$with_gmp_prefix/lib $LDFLAGS"
88         else
89                 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
90         fi
91         ;;
92 esac
94 poly_cv_gmpfatal="no"
95 AC_CHECK_HEADER(gmp.h,
96         [AC_CHECK_LIB(gmp,main,
97             [],
98             [poly_cv_gmpfatal="yes"])],
99         [poly_cv_gmpfatal="yes"])
100 if test "$poly_cv_gmpfatal" = "yes"; then
101         AC_MSG_ERROR([GMP not found])
103 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
105 AX_SUBMODULE(polylib,build|bundled|system,bundled)
107 AC_SUBST(POLYLIB_CPPFLAGS)
108 AC_SUBST(POLYLIB_LDFLAGS)
109 AC_SUBST(POLYLIB_LIBS)
110 case "$with_polylib" in
111 bundled)
112         bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
113         POLYLIB_CPPFLAGS="-I\$(top_builddir)/polylib/include -I\$(top_srcdir)/polylib/include"
114         ;;
115 build)
116         with_polylib_builddir=`echo @abs_builddir@ | $with_polylib_builddir/config.status --file=-`
117         POLYLIB_CPPFLAGS="-I$polylib_srcdir/include -I$with_polylib_builddir/include"
118         POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
119         ;;
120 system)
121         POLYLIB_LIBS="-lpolylibgmp"
122         if test "x$with_polylib_prefix" != "x"; then
123                 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
124                 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
125         fi
126         SAVE_CPPFLAGS="$CPPFLAGS"
127         CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
128         AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
129                 AC_MSG_ERROR(Need PolyLib)
130         ])
131         CPPFLAGS="$SAVE_CPPFLAGS"
132 esac
134 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
136 AX_SUBMODULE(isl,build|bundled|system,bundled)
138 AC_SUBST(ISL_CFLAGS)
139 AC_SUBST(ISL_LIBS)
140 AC_SUBST(ISL_SRCDIR)
141 AC_SUBST(ISL_BUILDDIR)
142 case "$with_isl" in
143 bundled)
144         ISL_SRCDIR="$srcdir/isl"
145         ISL_BUILDDIR=isl
146         ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
147         bv_configure_args="$bv_configure_args --with-isl-builddir=../isl"
148         PACKAGE_CFLAGS_ISL='-I${prefix}/include'
149         ;;
150 build)
151         ISL_SRCDIR="$isl_srcdir"
152         ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
153         bv_configure_args="$bv_configure_args --with-isl-builddir=$ISL_BUILDDIR"
154         ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
155         PACKAGE_CFLAGS_ISL='-I${prefix}/include'
156         ;;
157 system)
158         PKG_CHECK_MODULES([ISL], [isl])
159         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
160 esac
161 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
162 AM_CONDITIONAL(BUILD_ISL, test $with_isl = build)
164 AX_SUBMODULE(pet,bundled|build|system|no,no)
165 AC_SUBST(PET_CFLAGS)
166 AC_SUBST(PET_LIBS)
167 AC_SUBST(PET_BUILDDIR)
168 pet_suffix="top.pet"
169 case "$with_pet" in
170 bundled)
171         PET_CFLAGS="-I\$(top_srcdir)/pet/include"
172         AC_DEFINE(HAVE_PET,[],[use Pet])
173         ;;
174 build)
175         PET_BUILDDIR=`echo @abs_builddir@ | $with_pet_builddir/config.status --file=-`
176         PET_CFLAGS="-I$pet_srcdir/include"
177         AC_DEFINE(HAVE_PET,[],[use Pet])
178         ;;
179 system)
180         PKG_CHECK_MODULES([PET], [pet])
181         AC_DEFINE(HAVE_PET,[],[use Pet])
182         ;;
184         pet_suffix="top.no_pet"
185         ;;
186 esac
187 AM_CONDITIONAL(BUNDLED_PET, test $with_pet = bundled)
188 AM_CONDITIONAL(BUILD_PET, test $with_pet = build)
190 AC_MSG_CHECKING(if the fractional representation should be used)
191 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
192                                           [Don't use fractional representation])],
193             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
194 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
195                                       [Don't use fractional representation])],
196             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
197 AC_MSG_RESULT($bv_cv_modulo)
198 if test "x$bv_cv_modulo" != "xno" ; then
199         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
202 AC_MSG_CHECKING(whether to use incremental algorithm)
203 AC_ARG_ENABLE(incremental,
204         [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
205                         [Enable incremental algorithm [bf]])],
206         [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
207 AC_MSG_RESULT($bv_cv_incremental)
208 case $bv_cv_incremental in
209         yes | bf)
210                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
211                           [Use breadth-first incremental algorithm])
212         ;;
213         df)
214                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
215                           [Use depth-first incremental algorithm])
216         ;;
217 esac
219 AC_ARG_WITH(ntl,
220             [AC_HELP_STRING([--with-ntl=system|build],
221                             [Which NTL to use [default=system]])])
223 AC_ARG_WITH(ntl-prefix,
224             [AC_HELP_STRING([--with-ntl-prefix=DIR],
225                             [Prefix of NTL installation])])
227 AC_ARG_WITH(ntl-builddir,
228             [AC_HELP_STRING([--with-ntl-builddir=DIR],
229                             [Prefix of NTL root build directory
230                              containing include and src subdirectories])])
232 if test "x$with_ntl_builddir" != "x"; then
233         if test "x$with_ntl" != "xbuild" -a "x$with_ntl" != "x"; then
234                 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-builddir implies
235                                            use of build NTL]))
236         fi
237         with_ntl="build"
240 if test "x$with_ntl_prefix" != "x"; then
241         if test "x$with_ntl" != "xsystem" -a "x$with_ntl" != "x"; then
242                 AC_MSG_ERROR(m4_normalize([Setting --with-ntl-prefix implies
243                                            use of system NTL]))
244         fi
245         with_ntl="system"
248 case "$with_ntl" in
249 build|system)
250         ;;
252         with_ntl="system"
253         ;;
254 esac
255 AC_MSG_CHECKING([which NTL to use])
256 AC_MSG_RESULT($with_ntl)
258 AC_SUBST(NTL_CPPFLAGS)
259 AC_SUBST(NTL_LDFLAGS)
260 case "$with_ntl" in
261 build)
262         NTL_CPPFLAGS="-I$with_ntl_builddir/include"
263         NTL_LDFLAGS="-L$with_ntl_builddir/src/$lt_cv_objdir"
264         ntl_builddir_found=false
265         AC_CHECK_FILE(["$with_ntl_builddir/src/ZZ.c"],
266                       [ntl_builddir_found=true],[])
267         if test "x$ntl_builddir_found" != "xtrue"; then
268                 if test -f "$with_ntl_builddir/ZZ.c"; then
269                         ntl_builddir=`dirname $with_ntl_builddir`
270                         AC_MSG_ERROR(m4_normalize(
271                               [NTL source directory src/ specified as builddir.
272                                Use root directory instead as
273                                --with-ntl-builddir=$ntl_builddir]))
274                 else
275                         AC_MSG_ERROR([Could not find NTL in the builddir])
276                 fi
277         fi
278         ;;
279 system)
280         if test "x$with_ntl_prefix" != "x"; then
281                 NTL_CPPFLAGS="-I$with_ntl_prefix/include"
282                 NTL_LDFLAGS="-L$with_ntl_prefix/lib"
283         fi
284         ;;
285 esac
287 AX_CHECK_NTL
289 AC_SUBST(bv_cone_hilbert_basis)
290 AC_MSG_CHECKING(whether to compile zsolve)
291 AC_ARG_WITH(zsolve,
292             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
293             [ with_zsolve=$withval],  [ with_zsolve=yes ])
294 AC_MSG_RESULT($with_zsolve)
296 use_zsolve=false
297 if test "$with_zsolve" != "no"; then
298         if test "$GCC" = "yes"; then
299                 $CC --version |
300                 sed -e 's/.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\.\(@<:@0-9@:>@@<:@0-9@:>@*\).*/\1 \2/' |
301                 (read major minor
302                         if test $major -gt 3; then
303                                 exit 0
304                         fi
305                         if test $major -eq 3 -a $minor -ge 4; then
306                                 exit 0
307                         fi
308                         exit 1
309                 ) && use_zsolve=true
310         fi
311         if test "$use_zsolve" = false; then
312                 AC_MSG_WARN(gcc 3.4 required to compile zsolve)
313         else
314                 AC_DEFINE(USE_ZSOLVE,[],[use zsolve])
315                 bv_cone_hilbert_basis="cone_hilbert_basis\$(EXEEXT)"
316         fi
318 AM_CONDITIONAL(USE_ZSOLVE, test x$use_zsolve = xtrue)
320 AX_SUBMODULE(omega,no|system,no)
322 AC_SUBST(OMEGA_CPPFLAGS)
323 AC_SUBST(OMEGA_LDFLAGS)
324 AC_SUBST(OMEGA_LIBS)
325 AC_SUBST(OMEGA_CODEGEN_LIBS)
326 have_omega=false
327 have_codegen=false
328 case "$with_omega" in
329 system)
330     if test "x$with_omega_prefix" != "xyes"; then
331         OMEGA_CPPFLAGS="-I$with_omega_prefix/include/omega"
332         OMEGA_LDFLAGS="-L$with_omega_prefix/lib"
333     else
334         for i in /usr/include /usr/local/include; do
335             if test -f $i/omega/omega.h; then
336                 OMEGA_CPPFLAGS="-I$i/omega"
337             fi
338         done
339     fi
341     AC_LANG_PUSH(C++)
342     SAVE_CPPFLAGS="$CPPFLAGS"
343     SAVE_LDFLAGS="$LDFLAGS"
344     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
345     LDFLAGS="$OMEGA_LDFLAGS $LDFLAGS"
346     AC_CHECK_HEADERS([omega.h],[
347         OMEGA_LIBS="-lomega"
348         AC_CHECK_LIB(code_gen,main,[
349                 OMEGA_CODEGEN_LIBS="-lcode_gen -lomega"
350                 have_codegen=true
351         ])
352         have_omega=true
353     ],[AC_MSG_WARN(Omega not found)])
354     CPPFLAGS="$SAVE_CPPFLAGS"
355     LDFLAGS="$SAVE_LDFLAGS"
356     AC_LANG_POP
357     ;;
358 esac
359 if test "$have_omega" = true; then
360         AC_DEFINE(HAVE_OMEGA,[],[use omega])
362 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
364 use_parker=false
365 AC_MSG_CHECKING(whether to compile parker)
366 AC_ARG_WITH(parker,
367             [AS_HELP_STRING([--without-zsolve],[do not compile zsolve])],
368             [ with_parker=$withval],  [ with_parker=yes ])
369 AC_MSG_RESULT($with_parker)
371 if test "$with_parker" != "no"; then
372         AC_MSG_CHECKING(for mona)
373         AC_ARG_WITH(mona,
374                 [AS_HELP_STRING([--with-mona=DIR],[mona *source* directory])],
375                                 [], [AC_MSG_RESULT(not specified)])
377         if test "x$with_mona" != "x"; then
378                 AC_SUBST(MONAPATH)
379                 MONAPATH=$with_mona
380                 AC_MSG_RESULT($MONAPATH)
381                 use_parker=true
382                 AC_DEFINE(USE_PARKER,[],[use parker])
383         fi
385         if test "x$with_mona" = "x"; then
386                 AC_MSG_WARN(mona source directory required to compile parker)
387                 AC_MSG_WARN(http://www.brics.dk/mona/download)
388         fi
390 AM_CONDITIONAL(USE_PARKER, test x$use_parker = xtrue)
392 AC_MSG_CHECKING(whether to use cddlib)
393 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
394             [ cddlib_package=$withval],  [ cddlib_package=yes ])
395 AC_MSG_RESULT($cddlib_package)
397 have_cddlib=false
398 if test "$cddlib_package" != "no"; then
399     if test "x$cddlib_package" != "xyes"; then
400         CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
401         LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
402     fi
403     AC_TRY_LINK([
404 #define GMPRATIONAL
405 #include <setoper.h>
406 #include <cddmp.h>
407 ], [
408     mytype a;
409     dd_init(a); ], [
410         have_cddlib=true
411         AC_CHECK_LIB(cddgmp, main,[
412                 SAVE_LIBS="$LIBS"
413                 LIBS="-lcddgmp $LIBS"
414                 AC_DEFINE_UNQUOTED([SRCDIR], ["$srcdir"], [srcdir])
415                 AC_LANG_PUSH(C++)
416                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define GMPRATIONAL
417 #include <setoper.h>
418 #include <cdd.h>]],
419                 [[
420         const char *filename = SRCDIR"/cdd94e-test";
421         FILE *f;
422         dd_MatrixPtr M;
423         dd_LPType *lp;
424         dd_ErrorType err = dd_NoError;
426         dd_set_global_constants();
428         f = fopen(filename, "r");
429         M = dd_PolyFile2Matrix(f, &err);
430         lp = dd_Matrix2LP(M, &err);
431         dd_LPSolve(lp, dd_DualSimplex, &err);
432         return lp->LPS == dd_Inconsistent;
433                 ]])],[
434                         AC_DEFINE(HAVE_LIBCDDGMP, [], [Define to 1 if you have the `cddgmp' library (-lcddgmp).])
435                 ],[
436                         AC_MSG_WARN(please upgrade cddlib to 0.94e or later)
437                         LIBS="$SAVE_LIBS"
438                         have_cddlib=false
439                 ])
440                 AC_LANG_POP
441         ],[have_cddlib=false])
442     ])
444 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
448 AC_MSG_CHECKING(whether to use GLPK)
449 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
450             [ glpk_package=$withval],  [ glpk_package=yes ])
451 AC_MSG_RESULT($glpk_package)
453 have_glpk=false
454 if test "$glpk_package" != "no"; then
455     if test "x$glpk_package" != "xyes"; then
456         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
457         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
458     fi
459     AC_CHECK_HEADERS([glpk.h],[
460         have_glpk=true
461         AC_CHECK_LIB(glpk, [glp_simplex],[],[have_glpk=false])
462     ])
464 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
466 AC_MSG_CHECKING(location of TOPCOM)
467 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
468             [topcom_package=$withval], [topcom_package=unspecified])
469 AC_MSG_RESULT($topcom_package)
470 have_topcom=false
471 if test "$topcom_package" != no; then
472         topcom_path="$PATH"
473         if test "$topcom_package" != unspecified; then
474                 topcom_path="$topcom_package/bin"
475         fi
476         AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
477         if test -n "$POINTS2TRIANGS"; then
478                 have_topcom=true
479                 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
480                                     [Path of points2triangs])
481         fi
483 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
485 AX_DETECT_GIT_HEAD
486 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
488 AC_LANG_PUSH(C++)
489 AC_TRY_COMPILE([
490                 #include <set>
491                 void negate();
492         ], [negate()],
493         suffix="normal", suffix="broken")
494 AC_CONFIG_COMMANDS([barvinok/set.h],
495                    [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
496                    [suffix="$suffix"])
497 AC_CONFIG_COMMANDS([barvinok/NTL.h],
498                    [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
499                    [suffix="$suffix"])
500 use_fdstream=false
501 SAVE_CPPFLAGS="$CPPFLAGS"
502 CPPFLAGS="-I$srcdir $CPPFLAGS"
503 AC_TRY_COMPILE([#include "fdstream.h"],[],
504         [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
505         use_fdstream=true])
506 CPPFLAGS="$SAVE_CPPFLAGS"
507 AC_LANG_POP
508 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
510 AC_CONFIG_COMMANDS([interface/isl.py.top],
511                  [cp $srcdir/interface/isl.py.$pet_suffix interface/isl.py.top],
512                  [pet_suffix="$pet_suffix"])
514 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
515 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lisl"
516 AX_CREATE_PKGCONFIG_INFO
518 AC_CONFIG_HEADERS(config.h)
519 AC_CONFIG_FILES(Makefile zsolve/Makefile doc/Makefile)
520 AC_CONFIG_FILES(parker/Makefile)
521 if test $with_polylib = bundled; then
522         AC_CONFIG_SUBDIRS(polylib)
524 if test $with_isl = bundled; then
525         AC_CONFIG_SUBDIRS(isl)
527 if test $with_pet = bundled; then
528         AC_CONFIG_SUBDIRS(pet)
530 AC_CONFIG_COMMANDS_POST([
531         dnl pass on arguments to subdir configures, but don't
532         dnl add them to config.status
533         ac_configure_args="$ac_configure_args $bv_configure_args"
535 AC_OUTPUT