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