update piplib for change in configure arguments
[platform/upstream/isl.git] / configure.ac
1 AC_INIT
2 AC_CONFIG_MACRO_DIR([m4])
3 AM_INIT_AUTOMAKE(isl, 0.00)
4
5 AC_PROG_CC
6
7 AC_PROG_LIBTOOL
8
9 AX_CREATE_STDINT_H(include/isl_stdint.h)
10
11 AC_ARG_WITH(gmp_prefix,
12         [AS_HELP_STRING([--with-gmp-prefix=DIR],
13                         [Location of GMP installation])])
14
15 AC_SUBST(GMP_CPPFLAGS)
16 AC_SUBST(GMP_LDFLAGS)
17 if test "x$with_gmp_prefix" != "x"; then
18         isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
19         GMP_CPPFLAGS="-I$with_gmp_prefix/include"
20         GMP_LDFLAGS="-L$with_gmp_prefix/lib"
21 fi
22 SAVE_CPPFLAGS="$CPPFLAGS"
23 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
24 need_get_memory_functions=false
25 AC_CHECK_DECLS(mp_get_memory_functions,[],[
26         need_get_memory_functions=true
27 ],[#include <gmp.h>])
28 CPPFLAGS="$SAVE_CPPFLAGS"
29 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
30
31 AC_DEFUN([ISL_SUBMODULE],[
32         AC_ARG_WITH($1_prefix,
33                 [AS_HELP_STRING([--with-$1-prefix=DIR],
34                                 [Location of system $1])])
35         AC_ARG_WITH($1_builddir,
36                     [AS_HELP_STRING([--with-$1-builddir=DIR],
37                                     [Location of $1 builddir])])
38         if test "x$with_$1_prefix" != "x"; then
39                 if test "x$with_$1" != "x" -a "x$with_$1" != "xsystem"; then
40                         AC_MSG_ERROR([Setting $with_$1_prefix implies use of system $1])
41                 fi
42                 with_$1="system"
43         fi
44         if test "x$with_$1_builddir" != "x"; then
45                 if test "x$with_$1" != "x" -a "x$with_$1" != "xbuild"; then
46                         AC_MSG_ERROR([Setting $with_$1_builddir implies use of build $1])
47                 fi
48                 with_$1="build"
49                 $1_srcdir=`echo @abs_srcdir@ | $with_$1_builddir/config.status --file=-`
50                 AC_MSG_NOTICE($1 sources in $$1_srcdir)
51         fi
52         case "$with_$1" in
53         no|bundled|system|build)
54                 ;;
55         *)
56                 if test -d $srcdir/.git -a \
57                         -d $srcdir/$1 -a \
58                         ! -d $srcdir/$1/.git; then
59                         AC_MSG_WARN(
60 [git repo detected, but submodule $1 not initialized])
61                         AC_MSG_WARN([You may want to run])
62                         AC_MSG_WARN([   git submodule init])
63                         AC_MSG_WARN([   git submodule update])
64                         AC_MSG_WARN([   sh autogen.sh])
65                 fi
66                 if test -f $srcdir/$1/configure; then
67                         with_$1="bundled"
68                 fi
69                 ;;
70         esac
71 ])
72
73 AC_ARG_WITH(polylib,
74         [AS_HELP_STRING([--with-polylib=build|system|no],
75                         [Which PolyLib to use])])
76 ISL_SUBMODULE(polylib)
77 if test "x$with_polylib" = "x"; then
78         with_polylib="no"
79 fi
80 AC_MSG_CHECKING([which polylib to use])
81 AC_MSG_RESULT($with_polylib)
82
83 have_polylib=false
84 AC_SUBST(POLYLIB_CPPFLAGS)
85 AC_SUBST(POLYLIB_LDFLAGS)
86 AC_SUBST(POLYLIB_LIBS)
87 case "$with_polylib" in
88         build)
89                 polylibs=`echo @polylibs@ | $with_polylib_builddir/config.status --file=-`
90                 AC_MSG_NOTICE(Configured polylibs: $polylibs)
91                 isl_cv_polylib=missing
92                 for bits in $polylibs; do
93                         if test "$bits" = "libpolylibgmp.la"; then
94                                 isl_cv_polylib=ok
95                         fi
96                 done
97                 if test "$isl_cv_polylib" = "missing"; then
98                         AC_MSG_ERROR(no gmp polylib configured)
99                 fi
100                 POLYLIB_CPPFLAGS="-I$with_polylib_builddir/include -I$polylib_srcdir/include"
101                 POLYLIB_LIBS="$with_polylib_builddir/libpolylibgmp.la"
102         ;;
103         system)
104                 POLYLIB_LIBS="-lpolylibgmp"
105                 if test "x$with_polylib_prefix" != "x"; then
106                         POLYLIB_CPPFLAGS="-I$with_polylib_prefix/include"
107                         POLYLIB_LDFLAGS="-L$with_polylib_prefix/lib"
108                 fi
109                 SAVE_CPPFLAGS="$CPPFLAGS"
110                 SAVE_LDFLAGS="$LDFLAGS"
111                 CPPFLAGS="$POLYLIB_CPPFLAGS $CPPFLAGS"
112                 LDFLAGS="$POLYLIB_LDFLAGS $LDFLAGS"
113                 AC_CHECK_LIB(polylibgmp, PolyhedronTSort,[ true ],[
114                         AC_MSG_ERROR(Need polylib)
115                 ])
116                 CPPFLAGS="$SAVE_CPPFLAGS"
117                 LDFLAGS="$SAVE_LDFLAGS"
118         ;;
119         no)
120         ;;
121         *)
122                 AC_MSG_ERROR(unsupported)
123         ;;
124 esac
125 if test "$with_polylib" != "no"; then
126         AC_DEFINE(ISL_POLYLIB,,polylib is available)
127         have_polylib=true
128 fi
129 AM_CONDITIONAL(HAVE_POLYLIB, test x$have_polylib = xtrue)
130
131 AC_ARG_WITH(piplib,
132         [AS_HELP_STRING([--with-piplib=build|bundled|system|no],
133                         [Which piplib to use])])
134 ISL_SUBMODULE(piplib)
135 if test "x$with_piplib" = "x"; then
136         with_piplib="system"
137 fi
138 AC_MSG_CHECKING([which piplib to use])
139 AC_MSG_RESULT($with_piplib)
140
141 have_piplib=false
142 AC_SUBST(PIPLIB_CPPFLAGS)
143 AC_SUBST(PIPLIB_LDFLAGS)
144 AC_SUBST(PIPLIB_LIBS)
145 case "$with_piplib" in
146         bundled)
147                 PIPLIB_CPPFLAGS="-I$srcdir/piplib/include"
148                 isl_configure_args="$isl_configure_args --with-bits=gmp"
149         ;;
150         build)
151                 PIPLIB_CPPFLAGS="-I$piplib_srcdir/include"
152                 PIPLIB_LIBS="$with_piplib_builddir/libpiplibMP.la"
153         ;;
154         system)
155                 PIPLIB_LIBS="-lpiplibMP"
156                 if test "x$with_piplib_prefix" != "x"; then
157                         PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
158                         PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
159                 fi
160                 SAVE_CPPFLAGS="$CPPFLAGS"
161                 SAVE_LDFLAGS="$LDFLAGS"
162                 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
163                 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
164                 AC_CHECK_LIB(piplibMP, pip_solve,[
165                         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
166                                 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
167                         ],[#include <piplib/piplibMP.h>])
168                 ],[
169                         AC_MSG_ERROR([Piplib not found])
170                 ])
171                 CPPFLAGS="$SAVE_CPPFLAGS"
172                 LDFLAGS="$SAVE_LDFLAGS"
173         ;;
174         no)
175         ;;
176         *)
177                 AC_MSG_ERROR(unsupported)
178         ;;
179 esac
180 if test "$with_piplib" != "no"; then
181         AC_DEFINE(ISL_PIPLIB,,piplib is available)
182         have_piplib=true
183 fi
184 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
185 AM_CONDITIONAL(BUNDLED_PIPLIB, test $with_piplib = bundled)
186
187 AC_CONFIG_HEADERS(config.h)
188 AC_CONFIG_HEADERS(include/isl_ctx.h)
189 AC_CONFIG_FILES(Makefile)
190 if test $with_piplib = bundled; then
191         AC_CONFIG_SUBDIRS(piplib)
192 fi
193 AC_CONFIG_COMMANDS_POST([
194         dnl pass on arguments to subdir configures, but don't
195         ac_configure_args="$ac_configure_args $isl_configure_args"
196         ac_configure_args="$ac_configure_args $isl_configure_args"
197 ])
198 AC_OUTPUT