2 AM_INIT_AUTOMAKE(barvinok, 0.25)
16 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
17 if test "$enable_shared" = yes; then
18 BV_LDFLAGS="-no-undefined"
26 gl_MODULES(argp progname)
31 AC_CHECK_HEADERS(getopt.h)
32 AC_CHECK_HEADERS(sys/times.h)
34 AC_ARG_WITH(default-prefix,
35 AS_HELP_STRING([--with-default-prefix=DIR],
36 [Default installation prefix of optional packages]))
37 if test "${with_default_prefix+set}" = set; then
38 if test "${with_ginac_prefix+set}" != set -a \
39 -f "$with_default_prefix/lib/pkgconfig/ginac.pc"; then
40 with_ginac_prefix=$with_default_prefix
42 if test "${with_libgmp+set}" != set -a \
43 -f "$with_default_prefix/include/gmp.h"; then
44 with_libgmp=$with_default_prefix
46 if test "${with_polylib_prefix+set}" != set -a \
47 -f "$with_default_prefix/include/polylib/polylibgmp.h"; then
48 with_polylib_prefix=$with_default_prefix
50 if test "${with_piplib+set}" != set -a \
51 -f "$with_default_prefix/include/piplib/piplibMP.h"; then
52 with_piplib=$with_default_prefix
54 if test "${with_ntl+set}" != set -a \
55 -f "$with_default_prefix/include/NTL/ZZ.h"; then
56 with_ntl=$with_default_prefix
58 if test "${with_omega+set}" != set -a \
59 -f "$with_default_prefix/include/omega/omega.h"; then
60 with_omega=$with_default_prefix
62 if test "${with_cddlib+set}" != set -a \
63 -f "$with_default_prefix/include/cddmp.h"; then
64 with_cddlib=$with_default_prefix
66 if test "${with_glpk+set}" != set -a \
67 -f "$with_default_prefix/include/glpk.h"; then
68 with_glpk=$with_default_prefix
70 if test "${with_topcom+set}" != set -a \
71 -f "$with_default_prefix/bin/points2triangs"; then
72 with_topcom=$with_default_prefix
76 dnl Check for GMP library
77 AC_MSG_CHECKING(whether to use GMP)
79 [ --with-libgmp DIR Location of the GMP Distribution],
80 gmp_package=$withval, gmp_package=yes)
81 if test "x$gmp_package" = "xno"; then
83 AC_MSG_ERROR(Need gmp)
86 if test "x$gmp_package" = "xyes"; then
87 bv_configure_args="$bv_configure_args --with-libgmp --with-gmp"
89 bv_configure_args="$bv_configure_args --with-gmp=$gmp_package"
91 if test ! -d "$GMP_DIR"; then
92 AC_ERROR(Directory given for GMP Distribution is not a directory)
94 CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
95 LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
98 AC_CHECK_HEADER(gmp.h,
99 [AC_CHECK_LIB(gmp,main,
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])
107 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
109 # BV_SUBMODULE(SUBMODULE)
110 AC_DEFUN([BV_SUBMODULE],[
113 AC_MSG_ERROR(Need $1)
118 if test -d $srcdir/.git -a \
119 ! -d $srcdir/$1/.git; then
121 [git repo detected, but submodule $1 not initialized])
122 AC_MSG_WARN([You may want to run])
123 AC_MSG_WARN([ git submodule init])
124 AC_MSG_WARN([ git submodule update])
125 AC_MSG_WARN([ sh autogen.sh])
127 if test -f $srcdir/$1/configure; then
137 [AS_HELP_STRING([--with-polylib=bundled|system],[Which PolyLib to use])])
138 AC_ARG_WITH(polylib_prefix,
139 [AS_HELP_STRING([--with-polylib-prefix=DIR],[Location of system PolyLib])])
141 if test "x$with_polylib_prefix" != "x"; then
142 with_polylib="system"
144 BV_SUBMODULE(polylib)
145 AC_MSG_CHECKING([which PolyLib to use])
146 AC_MSG_RESULT($with_polylib)
148 AC_SUBST(POLYLIB_CPPFLAGS)
149 AC_SUBST(POLYLIB_LDFLAGS)
150 AC_SUBST(POLYLIB_LIBS)
151 if test "$with_polylib" = "bundled"; then
152 bv_configure_args="$bv_configure_args --with-polylib-builddir=../polylib"
153 POLYLIB_CPPFLAGS="-Ipolylib/include -I$srcdir/polylib/include"
155 POLYLIB_LIBS="-lpolylibgmp"
156 if test "x$with_polylib_prefix" != "x"; then
157 POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
158 POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
160 SAVE_CPPFLAGS="$CPPFLAGS"
161 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
162 AC_CHECK_HEADERS([polylib/polylibgmp.h], [], [
163 AC_MSG_ERROR(Need PolyLib)
165 CPPFLAGS="$SAVE_CPPFLAGS"
168 AM_CONDITIONAL(BUNDLED_POLYLIB, test $with_polylib = bundled)
171 [AS_HELP_STRING([--with-piplib=bundled|system],[Which piplib to use])])
172 AC_ARG_WITH(piplib_prefix,
173 [AS_HELP_STRING([--with-piplib-prefix=DIR],[Location of system piplib])])
175 if test "x$with_piplib_prefix" != "x"; then
179 AC_MSG_CHECKING([which piplib to use])
180 AC_MSG_RESULT($with_piplib)
182 AC_SUBST(PIPLIB_CPPFLAGS)
183 AC_SUBST(PIPLIB_LDFLAGS)
184 AC_SUBST(PIPLIB_LIBS)
185 if test "$with_piplib" = "bundled"; then
186 bv_configure_args="$bv_configure_args --with-piplib-builddir=../piplib"
187 bv_configure_args="$bv_configure_args --enable-mp-version"
188 PIPLIB_CPPFLAGS="-I$srcdir/piplib/include"
190 PIPLIB_LIBS="-lpiplibMP"
191 if test "x$with_piplib_prefix" != "x"; then
192 PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
193 PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
195 SAVE_CPPFLAGS="$CPPFLAGS"
196 SAVE_LDFLAGS="$LDFLAGS"
197 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
198 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
199 AC_CHECK_LIB(piplibMP, pip_solve,[
200 AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
201 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
202 ],[#include <stdio.h>
203 #include <piplib/piplibMP.h>])
205 AC_MSG_ERROR([Piplib not found])
207 CPPFLAGS="$SAVE_CPPFLAGS"
208 LDFLAGS="$SAVE_LDFLAGS"
210 AM_CONDITIONAL(BUNDLED_PIPLIB, test $with_piplib = bundled)
212 AC_MSG_CHECKING(if the fractional representation should be used)
213 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
214 [Don't use fractional representation])],
215 [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
216 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
217 [Don't use fractional representation])],
218 [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
219 AC_MSG_RESULT($bv_cv_modulo)
220 if test "x$bv_cv_modulo" != "xno" ; then
221 AC_DEFINE(USE_MODULO,[], [Use fractional representation])
224 AC_MSG_CHECKING(whether to use incremental algorithm)
225 AC_ARG_ENABLE(incremental,
226 [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
227 [Enable incremental algorithm [bf]])],
228 [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
229 AC_MSG_RESULT($bv_cv_incremental)
230 case $bv_cv_incremental in
232 AC_DEFINE(USE_INCREMENTAL_BF,[],
233 [Use breadth-first incremental algorithm])
236 AC_DEFINE(USE_INCREMENTAL_DF,[],
237 [Use depth-first incremental algorithm])
242 [ --with-ntl=DIR DIR Location of NTL],
243 [ echo "Package ntl : $withval" && ntl_package=$withval],
246 if test "$ntl_package" = "no"; then
247 AC_MSG_ERROR(Need ntl)
250 if test "$ntl_package" != "yes"; then
251 CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
252 LDFLAGS="-L$ntl_package/lib $LDFLAGS"
260 ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
262 AC_CHECK_LIB(ntl, main,[],[
263 AC_MSG_ERROR(Need ntl)
266 AC_MSG_CHECKING(whether to compile bernstein)
267 AC_ARG_WITH(bernstein,
268 [AS_HELP_STRING([--without-bernstein],[do not compile bernstein])],
269 [ with_bernstein=$withval], [ with_bernstein=yes ])
270 AC_MSG_RESULT($with_bernstein)
272 AC_ARG_WITH(ginac_prefix,
273 [AS_HELP_STRING([--with-ginac-prefix=DIR],[Installation prefix of GiNaC])])
274 if test "x$with_ginac_prefix" != "x"; then
275 export PKG_CONFIG_PATH=$with_ginac_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
278 AC_SUBST(bv_barvinok_maximize)
280 if test "$with_bernstein" != "no"; then
281 PKG_CHECK_EXISTS([ginac], [
282 PKG_CHECK_MODULES(ginac, ginac)
284 AC_DEFINE(HAVE_GINAC,[],[use GiNaC])
285 EXTRA_PACKAGE_LIBS="-lbernstein $EXTRA_PACKAGE_LIBS"
286 bv_barvinok_maximize="barvinok_maximize\$(EXEEXT)"
289 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
291 AC_MSG_CHECKING(whether to use Omega)
292 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
293 [ omega_package=$withval], [ omega_package=yes ])
294 AC_MSG_RESULT($omega_package)
296 AC_SUBST(OMEGA_CPPFLAGS)
297 AC_SUBST(OMEGA_LDFLAGS)
299 AC_SUBST(bv_omega_programs)
301 if test "$omega_package" != "no"; then
302 if test "x$omega_package" != "xyes"; then
303 OMEGA_CPPFLAGS="-I$omega_package/include/omega"
304 OMEGA_LDFLAGS="-L$omega_package/lib"
306 for i in /usr/include /usr/local/include; do
307 if test -f $i/omega/omega.h; then
308 OMEGA_CPPFLAGS="-I$i/omega"
314 SAVE_CPPFLAGS="$CPPFLAGS"
315 CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
316 AC_CHECK_HEADERS([omega.h],[
317 if test x$have_ginac = xtrue; then
318 bv_omega_programs="occ $bv_omega_programs"
320 AC_DEFINE(HAVE_OMEGA,[],[use omega])
321 OMEGA_LIBS="-lcode_gen -lomega"
323 ],[AC_MSG_WARN(Omega not found)])
324 CPPFLAGS="$SAVE_CPPFLAGS"
327 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
330 AC_MSG_CHECKING(whether to use cddlib)
331 AC_ARG_WITH(cddlib, [AS_HELP_STRING([--with-cddlib=DIR],[DIR Location of cddlib])],
332 [ cddlib_package=$withval], [ cddlib_package=yes ])
333 AC_MSG_RESULT($cddlib_package)
336 if test "$cddlib_package" != "no"; then
337 if test "x$cddlib_package" != "xyes"; then
338 CPPFLAGS="-I$cddlib_package/include $CPPFLAGS"
339 LDFLAGS="-L$cddlib_package/lib $LDFLAGS"
349 AC_CHECK_LIB(cddgmp, main,[],[have_cddlib=false])
352 AM_CONDITIONAL(HAVE_CDDLIB, test x$have_cddlib = xtrue)
356 AC_MSG_CHECKING(whether to use GLPK)
357 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
358 [ glpk_package=$withval], [ glpk_package=yes ])
359 AC_MSG_RESULT($glpk_package)
362 if test "$glpk_package" != "no"; then
363 if test "x$glpk_package" != "xyes"; then
364 CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
365 LDFLAGS="-L$glpk_package/lib $LDFLAGS"
367 AC_CHECK_HEADERS([glpk.h],[
369 AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
372 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
374 AC_MSG_CHECKING(location of TOPCOM)
375 AC_ARG_WITH(topcom, [AS_HELP_STRING([--with-topcom=DIR],[Location of TOPCOM])],
376 [topcom_package=$withval], [topcom_package=unspecified])
377 AC_MSG_RESULT($topcom_package)
379 if test "$topcom_package" != no; then
381 if test "$topcom_package" != unspecified; then
382 topcom_path="$topcom_package/bin"
384 AC_PATH_PROG([POINTS2TRIANGS], [points2triangs], [], [$topcom_path])
385 if test -n "$POINTS2TRIANGS"; then
387 AC_DEFINE_UNQUOTED(POINTS2TRIANGS_PATH, ["$POINTS2TRIANGS"],
388 [Path of points2triangs])
391 AM_CONDITIONAL(HAVE_TOPCOM, test x$have_topcom = xtrue)
393 AC_SUBST(GIT_HEAD_ID)
395 AC_SUBST(GIT_HEAD_VERSION)
396 if test -f $srcdir/.git/HEAD; then
397 GIT_HEAD="$srcdir/.git/index"
398 GIT_REPO="$srcdir/.git"
399 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
400 elif test -f $srcdir/GIT_HEAD_ID; then
401 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
403 mysrcdir=`(cd $srcdir; pwd)`
404 head=`basename $mysrcdir | sed -e 's/.*-//'`
405 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
406 head3=`echo $head2 | sed -e 's/........................................//'`
407 base=`basename $mysrcdir | sed -e 's/-.*//'`
408 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
409 GIT_HEAD_ID="barvinok-$VERSION-$head
410 elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
411 GIT_HEAD_ID="barvinok-$VERSION-$head
413 GIT_HEAD_ID="UNKNOWN"
416 if test -z "$GIT_REPO" ; then
417 GIT_HEAD_VERSION="$GIT_HEAD_ID"
419 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
421 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
428 suffix="normal", suffix="broken")
429 AC_CONFIG_COMMANDS([barvinok/set.h],
430 [cp $srcdir/barvinok/set.h.$suffix barvinok/set.h],
432 AC_CONFIG_COMMANDS([barvinok/NTL.h],
433 [cp $srcdir/barvinok/NTL.h.$suffix barvinok/NTL.h],
436 SAVE_CPPFLAGS="$CPPFLAGS"
437 CPPFLAGS="-I$srcdir $CPPFLAGS"
438 AC_TRY_COMPILE([#include "fdstream.h"],[],
439 [AC_DEFINE(USE_FDSTREAM,[],[use fdstream])
441 CPPFLAGS="$SAVE_CPPFLAGS"
443 AM_CONDITIONAL(USE_FDSTREAM, [test "$use_fdstream" = true])
445 PACKAGE_LIBS="-lbarvinok $EXTRA_PACKAGE_LIBS -lpolylibgmp -lpiplibMP"
446 AX_CREATE_PKGCONFIG_INFO
448 AC_CONFIG_HEADERS(config.h)
449 AC_CONFIG_FILES(Makefile lib/Makefile zsolve/Makefile doc/Makefile omega/Makefile)
450 if test $with_polylib = bundled; then
451 AC_CONFIG_SUBDIRS(polylib)
453 if test $with_piplib = bundled; then
454 AC_CONFIG_SUBDIRS(piplib)
456 if test x$have_ginac = xtrue; then
457 AC_CONFIG_SUBDIRS(bernstein)
459 AC_CONFIG_COMMANDS_POST([
460 dnl pass on arguments to subdir configures, but don't
461 dnl add them to config.status
462 ac_configure_args="$ac_configure_args $bv_configure_args"