Merge branch 'master' into bernstein
[barvinok.git] / configure.in
blobd5453e944e784c7ac4dc255b65ba323a74649a2b
1 AC_INIT
2 AM_INIT_AUTOMAKE(barvinok, 0.21)
3 AC_PROG_CXX
4 AM_PROG_LEX
5 AC_PROG_YACC
6 AC_SUBST(versioninfo)
7 versioninfo=11:1:1
9 AC_CANONICAL_HOST
10 AC_LIBTOOL_WIN32_DLL
11 AC_SUBST(BV_LDFLAGS)
12 case $host in
13         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
14         if test "$enable_shared" = yes; then
15                 BV_LDFLAGS="-no-undefined" 
16         fi
17         ;;
18 esac
20 AC_PROG_LIBTOOL
22 AC_CHECK_HEADERS(getopt.h)
23 AC_CHECK_HEADERS(sys/times.h)
25 dnl Check for GMP library
26 AC_MSG_CHECKING(whether to use GMP)
27 AC_ARG_WITH(libgmp, 
28         [  --with-libgmp           DIR Location of the GMP Distribution], 
29         gmp_package=$withval, gmp_package=yes)
30 if test "x$gmp_package" = "xno"; then
31         AC_MSG_RESULT(no)
32         AC_MSG_ERROR(Need gmp)
33 else
34         AC_MSG_RESULT(yes)
35         if test "x$gmp_package" != "xyes"; then
36             GMP_DIR=$gmp_package
37             if test ! -d "$GMP_DIR"; then
38                 AC_ERROR(Directory given for GMP Distribution is not a directory)
39             fi
40             CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
41             LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
42         fi
43         poly_cv_gmpfatal="no"
44         AC_CHECK_HEADER(gmp.h,
45                 [AC_CHECK_LIB(gmp,main,
46                     [],
47                     [poly_cv_gmpfatal="yes"])],
48                 [poly_cv_gmpfatal="yes"])
49         if test "$poly_cv_gmpfatal" = "yes"; then
50                 AC_MSG_ERROR([GMP not found])
51         fi
53 AC_CHECK_DECL(mpz_divisible_p,[],[AC_LIBOBJ(mpz_divisible_p)],[#include <gmp.h>])
55 AC_ARG_WITH(polylib,
56             [  --with-polylib=DIR      DIR Location of PolyLib],
57             [ echo "Package polylib : $withval" && polylib_package=$withval],  
58             [ polylib_package=yes ])
60 if test "$polylib_package" = "no"; then
61     AC_MSG_ERROR(Need polylib)
64 if test "$polylib_package" != "yes"; then
65     CPPFLAGS="-I$polylib_package/include $CPPFLAGS"
66     LDFLAGS="-L$polylib_package/lib $LDFLAGS"
67     LD_LIBRARY_PATH="$polylib_package/lib:$LD_LIBRARY_PATH"
68     export LD_LIBRARY_PATH
71 AC_CHECK_LIB(polylibgmp, PolyhedronTSort,[],[
72     AC_MSG_ERROR(Need polylib)
74 AC_CHECK_FUNCS(Enumeration_Free)
75 AC_CHECK_FUNCS(compress_parms)
76 AC_SUBST(bv_extra_programs)
77 AC_CHECK_FUNCS(LexSmaller,[
78         bv_extra_programs="verify_lexsmaller $bv_extra_programs"
79     ])
80 AC_REPLACE_FUNCS(DomainConstraintSimplify)
81 AC_TRY_RUN([
82 #include <polylib/polylibgmp.h>
84 int main()
86     int i, j;
87     Polyhedron *P;
88     Matrix *M = Matrix_Alloc(6,5);
89     for (i = 0; i < 6; ++i) {
90         value_set_si(M->p[i][0], 1);
91         for (j = 1; j < 4; ++j)
92             value_set_si(M->p[i][j], (j-1 == i/2) * (1-2*(i%2)));
93         value_set_si(M->p[i][4], i%2);
94     }
95     P = Constraints2Polyhedron(M, 6);
96     return !(P->NbRays == 8);
99 [AC_DEFINE(HAVE_GROWING_CHERNIKOVA,[],
100           [PolyLib automatically grows the Chernikova table space])],
101 AC_MSG_WARN([This version of PolyLib does not automatically])
102 AC_MSG_WARN([enlarge the Chernikova table space]),
103 AC_MSG_WARN([Unable to determine whether PolyLib automatically])
104 AC_MSG_WARN([grows the Chernikova table space]))
106 AC_TRY_RUN([
107 #include <polylib/polylibgmp.h>
109 int main()
111     enode *en = new_enode(polynomial, 1, 1);
112     return !(en->arr[0].x.p == NULL);
115 AC_MSG_WARN([This version of polylib leaks]),[true])
117 AC_TRY_RUN([
118 #include <stdio.h>
119 #include <polylib/polylibgmp.h>
121 int main()
123     Matrix *M;
124     Polyhedron *P, *C;
125     Param_Polyhedron *PP;
126     int i;
127     Param_Vertices *V;
129     freopen("$srcdir/tests/ehrhart/t12.in", "r", stdin);
130     M = Matrix_Read();
131     P = Constraints2Polyhedron(M, 1024);
132     M = Matrix_Read();
133     C = Constraints2Polyhedron(M, 1024);
134     PP = Polyhedron2Param_Domain(P, C, 1024);
135     for (i = 0, V = PP->V; V; ++i, V = V->next)
136         ;
137     return !(i == 10);
140 [AC_DEFINE(HAVE_CORRECT_VERTICES,[],
141           [PolyLib computes correct vertices])],
142 AC_MSG_WARN([This version of polylib produces incorrect vertices.]),
143 AC_MSG_WARN([Unable to determine whether PolyLib computes correct vertices]))
145 AC_MSG_CHECKING([number of arguments of Polyhedron_Enumerate])
146 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
147                [Polyhedron_Enumerate(NULL,NULL,0,NULL)],
148                [AC_MSG_RESULT(4)
149                 AC_DEFINE(HAVE_ENUMERATE4,[],
150                           [Polyhedron_Enumerate takes four arguments])],
151                [AC_MSG_RESULT(3)])
153 AC_MSG_CHECKING([number of arguments of count_points])
154 AC_TRY_COMPILE([#include <polylib/polylibgmp.h>], 
155                [count_points(0,NULL,NULL,NULL)],
156                [AC_MSG_RESULT(4)
157                 AC_DEFINE(HAVE_COUNT_POINTS4,[],
158                           [count_points takes four arguments])],
159                [AC_MSG_RESULT(3)])
161 AC_MSG_CHECKING([for value_subtract macro])
162 AC_EGREP_CPP(yes, [
163     #include <polylib/polylibgmp.h>
164     #ifdef value_subtract
165     yes
166     #endif
167     ],[AC_MSG_RESULT(yes)],
168     [AC_MSG_RESULT(no)
169      AC_DEFINE(value_subtract,value_substract,
170                 [define to value_substract if missing from PolyLib])])
172 AC_ARG_WITH(piplib,
173             [  --with-piplib=DIR       DIR Location of PIP],
174             [ echo "Package piplib : $withval" && piplib_package=$withval],  
175             [ piplib_package=yes ])
177 have_piplib=false
178 if test "$piplib_package" != "no"; then
179     SAVE_CPPFLAGS="$CPPFLAGS"
180     SAVE_LDFLAGS="$LDFLAGS"
181     if test "$piplib_package" != "yes"; then
182         CPPFLAGS="-I$piplib_package/include $CPPFLAGS"
183         LDFLAGS="-L$piplib_package/lib $LDFLAGS"
184     fi
186     bv_cv_piplibfatal="no"
187     AC_CHECK_LIB(piplibMP, pip_solve,[
188         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
189             AC_MSG_WARN([Piplib too old; please install version 1.3.6 or newer])
190             bv_cv_piplibfatal="yes"
191         ],[#include <stdio.h>
192            #include <piplib/piplibMP.h>])
193     ],[
194         AC_MSG_WARN([Piplib not found])
195         bv_cv_piplibfatal="yes"
196     ])
197     if test "$bv_cv_piplibfatal" = "no"; then
198         AC_DEFINE(HAVE_PIPLIB,[],[use piplib])
199         LIBS="-lpiplibMP $LIBS"
200         AC_LIBOBJ(piputil)
201         bv_extra_programs="piptest $bv_extra_programs"
202         have_piplib=true
203     else
204         CPPFLAGS="$SAVE_CPPFLAGS"
205         LDFLAGS="$SAVE_LDFLAGS"
206     fi
208 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
210 AC_MSG_CHECKING(if the fractional representation should be used)
211 AC_ARG_ENABLE(fractional, [AS_HELP_STRING([--disable-fractional],
212                                           [Don't use fractional representation])],
213             [bv_cv_fractional=$enableval], [bv_cv_fractional="yes"])
214 AC_ARG_ENABLE(modulo, [AS_HELP_STRING([--disable-modulo],
215                                       [Don't use fractional representation])],
216             [bv_cv_modulo=$enableval], [bv_cv_modulo="$bv_cv_fractional"])
217 AC_MSG_RESULT($bv_cv_modulo)
218 if test "x$bv_cv_modulo" != "xno" ; then
219         AC_DEFINE(USE_MODULO,[], [Use fractional representation])
222 AC_MSG_CHECKING(whether to use incremental algorithm)
223 AC_ARG_ENABLE(incremental,
224         [AS_HELP_STRING([--enable-incremental@<:@=bf|df@:>@],
225                         [Enable incremental algorithm [bf]])],
226         [bv_cv_incremental=$enableval], [bv_cv_incremental="no"])
227 AC_MSG_RESULT($bv_cv_incremental)
228 case $bv_cv_incremental in
229         yes | bf)
230                 AC_DEFINE(USE_INCREMENTAL_BF,[], 
231                           [Use breadth-first incremental algorithm])
232         ;;
233         df)
234                 AC_DEFINE(USE_INCREMENTAL_DF,[], 
235                           [Use depth-first incremental algorithm])
236         ;;
237 esac
239 AC_ARG_WITH(ntl,
240             [  --with-ntl=DIR          DIR Location of NTL],
241             [ echo "Package ntl : $withval" && ntl_package=$withval],  
242             [ ntl_package=yes ])
244 if test "$ntl_package" = "no"; then
245     AC_MSG_ERROR(Need ntl)
248 if test "$ntl_package" != "yes"; then
249     CPPFLAGS="-I$ntl_package/include $CPPFLAGS"
250     LDFLAGS="-L$ntl_package/lib $LDFLAGS"
253 AC_EGREP_CPP(yes, [
254     #include <NTL/ZZ.h>
255     #ifdef NTL_GMP_LIP
256     yes
257     #endif
258     ],:,AC_MSG_ERROR(ntl not compiled with gmp support))
260 AC_CHECK_LIB(ntl, main,[],[
261     AC_MSG_ERROR(Need ntl)
264 AC_LANG_PUSH(C++)
265 have_ginac=false
266 AM_PATH_GINAC(1.3.3, [have_ginac=true])
267 AC_LANG_POP
268 AM_CONDITIONAL(HAVE_GINAC, test x$have_ginac = xtrue)
270 AC_MSG_CHECKING(whether to use Omega)
271 AC_ARG_WITH(omega, [AS_HELP_STRING([--with-omega=DIR],[DIR Location of Omega])],
272             [ omega_package=$withval],  [ omega_package=yes ])
273 AC_MSG_RESULT($omega_package)
275 AC_SUBST(OMEGA_CPPFLAGS)
276 AC_SUBST(OMEGA_LDFLAGS)
277 AC_SUBST(OMEGA_LIBS)
278 AC_SUBST(bv_omega_programs)
279 have_omega=false
280 if test "$omega_package" != "no"; then
281     if test "x$omega_package" != "xyes"; then
282         OMEGA_CPPFLAGS="-I$omega_package/include/omega"
283         OMEGA_LDFLAGS="-L$omega_package/lib"
284     else
285         for i in /usr/include /usr/local/include; do
286             if test -f $i/omega/omega.h; then
287                 OMEGA_CPPFLAGS="-I$i/omega"
288             fi
289         done
290     fi
292     AC_LANG_PUSH(C++)
293     SAVE_CPPFLAGS="$CPPFLAGS"
294     CPPFLAGS="$OMEGA_CPPFLAGS $CPPFLAGS"
295     AC_CHECK_HEADERS([omega.h],[
296         if test x$have_ginac = xtrue; then
297             bv_omega_programs="occ $bv_omega_programs"
298         fi
299         AC_DEFINE(HAVE_OMEGA,[],[use omega])
300         OMEGA_LIBS="-lcode_gen -lomega"
301         have_omega=true
302     ],[AC_MSG_WARN(Omega not found)])
303     CPPFLAGS="$SAVE_CPPFLAGS"
304     AC_LANG_POP
306 AM_CONDITIONAL(HAVE_OMEGA, test x$have_omega = xtrue)
308 AC_MSG_CHECKING(whether to use GLPK)
309 AC_ARG_WITH(glpk, [AS_HELP_STRING([--with-glpk=DIR],[DIR Location of GLPK])],
310             [ glpk_package=$withval],  [ glpk_package=yes ])
311 AC_MSG_RESULT($glpk_package)
313 have_glpk=false
314 if test "$glpk_package" != "no"; then
315     if test "x$glpk_package" != "xyes"; then
316         CPPFLAGS="-I$glpk_package/include $CPPFLAGS"
317         LDFLAGS="-L$glpk_package/lib $LDFLAGS"
318     fi
319     AC_CHECK_HEADERS([glpk.h],[
320         have_glpk=true
321         AC_CHECK_LIB(glpk, main,[],[have_glpk=false])
322     ])
324 AM_CONDITIONAL(HAVE_GLPK, test x$have_glpk = xtrue)
326 if test "$have_glpk" = "true"; then
327     AC_LIBOBJ(basis_reduction)
328     AC_LIBOBJ(sample)
329     bv_extra_programs="polyhedron_sample 4coins lexmin $bv_extra_programs"
332 AC_SUBST(GIT_HEAD_ID)
333 AC_SUBST(GIT_HEAD)
334 AC_SUBST(GIT_HEAD_VERSION)
335 if test -f $srcdir/.git/HEAD; then
336     GIT_HEAD="$srcdir/.git/index"
337     GIT_REPO="$srcdir/.git"
338     GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
339 elif test -f $srcdir/GIT_HEAD_ID; then
340     GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
341 else
342     mysrcdir=`(cd $srcdir; pwd)`
343     head=`basename $mysrcdir | sed -e 's/.*-//'`
344     head2=`echo $head | sed -e 's/[^0-9a-f]//'`
345     head3=`echo $head2 | sed -e 's/........................................//'`
346     base=`basename $mysrcdir | sed -e 's/-.*//'`
347     if test "x$head3" = "x" -a "x$head" = "x$head2"; then
348         GIT_HEAD="barvinok-$VERSION-$head
349     elif test "x$base" = "xbarvinok-$VERSION" -a "x$head" != "x"; then
350         GIT_HEAD="barvinok-$VERSION-$head
351     else
352         GIT_HEAD_ID="UNKNOWN"
353     fi
355 if test -z "$GIT_REPO" ; then
356     GIT_HEAD_VERSION="$GIT_HEAD_ID"
357 else
358     GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"
360 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > version.h
362 AX_CREATE_PKGCONFIG_INFO
364 AC_CONFIG_HEADERS(config.h)
365 AC_CONFIG_FILES(Makefile doc/Makefile omega/Makefile)
366 AC_CONFIG_SUBDIRS(bernstein)
367 AC_OUTPUT