fix memory leak in clast construction
[cloog.git] / configure.in
blob7be2ba08608c9662339dcaed2710f18d4855572f
2 dnl /**-------------------------------------------------------------------**
3 dnl  **                              CLooG                                **
4 dnl  **-------------------------------------------------------------------**
5 dnl  **                           configure.in                            **
6 dnl  **-------------------------------------------------------------------**
7 dnl  **                   First version: august 7th 2002                  **
8 dnl  **-------------------------------------------------------------------**/
9 dnl
10 dnl Input file for autoconf to build a configuration shellscript.
11 dnl To build the configure script from the CLooG's top-level directory, use
12 dnl autoconf -l autoconf autoconf/configure.in > configure
13 dnl if it doesn't work (invalid option -l) try -I instead
14 dnl autoconf -I autoconf autoconf/configure.in > configure
16 dnl /**************************************************************************
17 dnl *               CLooG : the Chunky Loop Generator (experimental)          *
18 dnl ***************************************************************************
19 dnl *                                                                         *
20 dnl * Copyright (C) 2001 Cedric Bastoul                                       *
21 dnl *                                                                         *
22 dnl * This is free software; you can redistribute it and/or modify it under   *
23 dnl * the terms of the GNU General Public License as published by the Free    *
24 dnl * Software Foundation; either version 2 of the License, or (at your       *
25 dnl * option) any later version.                                              *
26 dnl *                                                                         *
27 dnl * This software is distributed in the hope that it will be useful, but    *
28 dnl * WITHOUT ANY WARRANTY; without even the implied warranty of              *
29 dnl * MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
30 dnl * General Public License for more details.                                *
31 dnl *                                                                         *
32 dnl * You should have received a copy of the GNU General Public License along *
33 dnl * with software; if not, write to the Free Software Foundation, Inc.,     *
34 dnl * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA                  *
35 dnl *                                                                         *
36 dnl * CLooG, the Chunky Loop Generator                                        *
37 dnl * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                      *
38 dnl *                                                                         *
39 dnl ***************************************************************************/
41 AC_PREREQ(2.13)
42 AC_INIT(source/cloog.c)
43 AC_CONFIG_AUX_DIR(autoconf)
44 AM_INIT_AUTOMAKE(cloog, 0.14.0)
45 dnl default version
46 BITS="64"
48 dnl /**************************************************************************
49 dnl  *                              Checking                                  *
50 dnl  **************************************************************************/
52 dnl Checks for programs.
53 AC_PROG_CC
54 AC_PROG_LN_S
55 AC_PROG_MAKE_SET
56 AC_CHECK_PROG(CD, cd)
57 dnl Configure needs an empty install.sh file with this, i HATE that...
58 AC_PROG_INSTALL
59 AC_PROG_LIBTOOL
60 AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, [])
61 AM_CONDITIONAL(HAVE_TEXI2DVI, test -n "$TEXI2DVI")
64 dnl Checks for typedefs, structures, and compiler characteristics.
65 AC_C_CONST
66 AC_TYPE_SIZE_T
70 dnl Checks for header files.
71 AC_HEADER_STDC
74 dnl Checks for library functions.
75 AC_CHECK_FUNCS(strtol)
78 dnl /**************************************************************************
79 dnl  *                             Option setting                             *
80 dnl  **************************************************************************/
82 dnl Some default values cause I'm not sure whether autoconf set them, while
83 dnl documentation says it does...
84 gmp_package="yes"
85 gmp_include_package="yes"
86 gmp_library_package="yes"
88 MP_BITS="MP"
89 MP_DFLAGS=-DLINEAR_VALUE_IS_MP
90 NEED_MP="no"
92 dnl --with-polylib=polylib-path
93 AC_ARG_WITH(polylib_prefix,
94             [AS_HELP_STRING([--with-polylib-prefix=DIR],
95                             [Prefix of PolyLib installation])])
96 AC_ARG_WITH(polylib_exec_prefix,
97             [AS_HELP_STRING([--with-polylib-exec-prefix=DIR],
98                             [Exec prefix of PolyLib installation])])
99 AC_ARG_WITH(polylib_builddir,
100             [AS_HELP_STRING([--with-polylib-builddir=DIR],
101                             [Location of PolyLib builddir])])
102 AC_ARG_WITH(bits,
103             [  --with-bits=32|64|gmp   PolyLib library type to use],
104             [ echo "polylib$withval"; BITS=$withval ])
106 dnl --with-gmp=gmp-path
107 AC_ARG_WITH(gmp,
108         [  --with-gmp=DIR          DIR where the gmp package is installed],
109         [ echo "Package gmp : $withval" &&
110           gmp_package=$withval &&
111           GMP_INC=$gmp_package/include &&
112           GMP_LIB=$gmp_package/lib &&
113           NEED_MP="yes"])
115 AC_ARG_WITH(gmp-include,
116         [  --with-gmp-include=DIR  DIR where gmp.h is installed],
117         [ echo "Package gmp-include : $withval" &&
118           gmp_include_package=$withval &&
119           GMP_INC=$gmp_include_package &&
120           NEED_MP="yes"])
122 AC_ARG_WITH(gmp-library,
123         [  --with-gmp-library=DIR  DIR where the gmp library is installed],
124         [ echo "Package gmp-library : $withval" &&
125           gmp_library_package=$withval &&
126           GMP_LIB=$gmp_library_package &&
127           NEED_MP="yes"])
130 dnl /**************************************************************************
131 dnl  *                            Where is GMP?                               *
132 dnl  **************************************************************************/
135 dnl Checking for gmp
136 AC_MSG_CHECKING(whether gmp works)
137 if test "$gmp_package" = "no"; then
138   echo "GMP package not defined"
139   AC_MSG_RESULT(no)
140   TO_BUILD_MP=""
141 else
142   if test "$NEED_MP" = "no"; then
143     echo "Mode normal GMP"
144     TO_BUILD="$TO_BUILD MP"
145     AC_CHECK_HEADER(gmp.h,
146                     [AC_CHECK_LIB(gmp,
147                                   __gmpz_init,
148                                   [LIBS="$LIBS -lgmp"],
149                                   [echo "Can't find gmp library." &&
150                                    echo "MP version will not be builded." &&
151                                    TO_BUILD_MP=""])],
152                     [echo "Can't find gmp headers." &&
153                      echo "MP version will not be builded." &&
154                      TO_BUILD_MP=""])
155   else
156     dnl Default given by --with-X is "yes", --without-X is "no". We also
157     dnl initialized manually all gmp_package* variables to "yes" (thus they are
158     dnl supposed to be "yes" except if the user set them himself).
159     
160     if test "$gmp_package" != "yes" ; then
161       echo "(GMP path has been set by user)"
162       GMP_DIR=$gmp_package
163       dnl Useful for AC_CHECK_X to find what we want.
164       CPPFLAGS="-I$GMP_DIR/include $CPPFLAGS"
165       LDFLAGS="-L$GMP_DIR/lib $LDFLAGS"
166     fi
167     
168     if test "$gmp_include_package" != "yes" ; then
169       CPPFLAGS="-I$GMP_INC $CPPFLAGS"
170     fi
171     
172     if test "$gmp_library_package" != "yes" ; then
173       LDFLAGS="-L$GMP_LIB $LDFLAGS"
174     fi
175      
176     AC_CHECK_HEADER(gmp.h,
177                     [],
178                     [AC_MSG_ERROR(Can't find gmp headers.)])
179     AC_CHECK_LIB(gmp,
180                  __gmpz_init,
181                  [LIBS="$LIBS -lgmp"],
182                  [AC_MSG_ERROR(Can't find gmp library.)])
183     
184     AC_MSG_RESULT(yes)
185   fi
189 dnl /**************************************************************************
190 dnl  *                          Where is PolyLib?                             *
191 dnl  **************************************************************************/
193 polylibs="64 32"
194 case "$BITS" in
195     32|64|gmp)
196         polylibs=$BITS
197     ;;
198 esac
200 dnl Checking for PolyLib
201 AC_SUBST(cl_cv_polylib)
202 AC_SUBST(POLYLIB_CPPFLAGS)
203 AC_SUBST(POLYLIB_LDFLAGS)
204 AC_SUBST(POLYLIB_LIBS)
206 if test "x$with_polylib_prefix" != "x" -a "x$with_polylib_exec_prefix" = "x"
207 then
208         with_polylib_exec_prefix=$with_polylib_prefix
210 if test "x$with_polylib_prefix" != "x" -a "x$with_polylib_builddir" != "x"; then
211         AC_MSG_ERROR(
212         [--with-polylib-prefix and --with-polylib-builddir are mutually exclusive])
215 AC_MSG_CHECKING(for location of PolyLib)
216 if test "x$with_polylib_builddir" != "x"; then
217         AC_MSG_RESULT(built in $with_polylib_builddir)
218         polylib_srcdir=`echo @abs_srcdir@ | $with_polylib_builddir/config.status --file=-`
219         AC_MSG_NOTICE(PolyLib sources in $polylib_srcdir)
220         polylib_polylibs=`echo @polylibs@ | $with_polylib_builddir/config.status --file=-`
221         AC_MSG_NOTICE(Configured polylibs: $polylib_polylibs)
222         CPPFLAGS="-I$with_polylib_builddir/include -I$polylib_srcdir/include $CPPFLAGS"
223         for BITS in $polylibs; do
224                 cl_cv_polylib=missing
225                 for PL in $polylib_polylibs; do
226                         if test "libpolylib$BITS.la" = $PL; then
227                                 cl_cv_polylib="polylib$BITS"
228                                 break;
229                         fi
230                 done
231                 if test "$cl_cv_polylib" != "missing"; then
232                         LIBS="$with_polylib_builddir/lib$cl_cv_polylib.la $LIBS"
233                         break;
234                 fi
235         done
236 else
237         if test "x$with_polylib_prefix" != "x"; then
238                 AC_MSG_RESULT(installed in $with_polylib_exec_prefix)
239                 CPPFLAGS="-I$with_polylib_prefix/include $CPPFLAGS"
240                 LDFLAGS="-L$with_polylib_exec_prefix/lib $LDFLAGS"
241                 LD_LIBRARY_PATH="$with_polylib_exec_prefix/lib:$LD_LIBRARY_PATH"
242                 export LD_LIBRARY_PATH
243         else
244                 AC_MSG_RESULT(installed in standard location)
245         fi
246         for BITS in $polylibs; do
247                 cl_cv_polylib="polylib$BITS"
248                 AC_CHECK_HEADER(polylib/$cl_cv_polylib.h,[
249                         AC_CHECK_LIB($cl_cv_polylib,PolyhedronTSort,[
250                                 LIBS="-l$cl_cv_polylib $LIBS"
251                                 break
252                         ])
253                 ])
254                 cl_cv_polylib=missing
255         done
257 if test "$cl_cv_polylib" = "missing"; then
258         AC_MSG_ERROR(Can't find PolyLib.)
261 AC_SUBST(GIT_INDEX)
262 if test -f $srcdir/.git/HEAD; then
263         GIT_INDEX="\$(top_srcdir)/.git/index"
267 dnl /**************************************************************************
268 dnl  *                            Substitutions                               *
269 dnl  **************************************************************************/
272 dnl Substitutions to do in Makefile.in.
273 AC_SUBST(target)
274 AC_SUBST(CC)
275 AC_SUBST(LN_S)
276 AC_SUBST(SHEXT)
278 AC_SUBST(prefix)
279 AC_SUBST(exec_prefix)
280 AC_SUBST(INSTALL)
282 AC_SUBST(BITS)
284 AC_CONFIG_FILES(Makefile test/Makefile include/cloog/cloog.h autoconf/Doxyfile)
285 AC_CONFIG_FILES(doc/Makefile)
286 AC_CONFIG_FILES(source/version.c)
287 AC_CONFIG_FILES([genversion.sh], [chmod +x genversion.sh])
288 AC_CONFIG_COMMANDS([version.h],
289         [echo '#define CLOOG_HEAD "'`./genversion.sh`'"' > version.h])
290 AC_CONFIG_COMMANDS([doc/gitversion.texi],
291         [echo '@set VERSION '`./genversion.sh`'' > doc/gitversion.texi])
292 AC_OUTPUT
295 echo "             /*-----------------------------------------------*"
296 echo "              *           CLooG configuration is OK           *"
297 echo "              *-----------------------------------------------*/"
298 echo "It appears that your system is OK to start CLooG compilation. You need"
299 echo "now to type \"make\". After compilation, you should check CLooG by typing"
300 echo "\"make check\". If no problem occur, you can type \"make uninstall\" if"
301 echo "you are upgrading an old version. Lastly type \"make install\" to install"
302 echo "CLooG on your system (log as root if necessary)."