1 AC_INIT([isl], [0.12], [isl-development@googlegroups.com])
3 AC_CONFIG_MACRO_DIR([m4])
4 AM_INIT_AUTOMAKE([foreign])
5 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
9 if test "x$prefix" != "xNONE"; then
10 prefix_wd=`cd $prefix && pwd`
11 srcdir_wd=`cd $srcdir && pwd`
13 if test "x$prefix_wd" = "x$srcdir_wd"; then
14 AC_MSG_ERROR(Installation in source directory not supported)
16 if test "x$prefix_wd" = "x$wd"; then
17 AC_MSG_ERROR(Installation in build directory not supported)
25 AX_GCC_WARN_UNUSED_RESULT
30 AC_CHECK_PROG(PERL, perl, perl, [])
31 AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex, [])
32 AC_CHECK_PROG(POD2HTML, pod2html, pod2html, [])
34 AM_CONDITIONAL(GENERATE_DOC, test -n "$PERL" -a -n "$PDFLATEX" -a -n "$POD2HTML")
36 AX_CREATE_STDINT_H(include/isl/stdint.h)
38 AX_SUBMODULE(gmp,system|build,system)
40 AC_SUBST(GMP_CPPFLAGS)
45 if test "x$with_gmp_prefix" != "x"; then
46 isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
47 GMP_CPPFLAGS="-I$with_gmp_prefix/include"
48 GMP_LDFLAGS="-L$with_gmp_prefix/lib"
51 SAVE_CPPFLAGS="$CPPFLAGS"
52 SAVE_LDFLAGS="$LDFLAGS"
54 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
55 LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
56 LIBS="$GMP_LIBS $LIBS"
57 AC_CHECK_HEADER([gmp.h], [], [AC_ERROR([gmp.h header not found])])
58 AC_CHECK_LIB([gmp], [main], [], [AC_ERROR([gmp library not found])])
59 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
61 if (mpz_divisible_p(n, d))
62 mpz_divexact_ui(n, n, 4);
63 ]])], [], [AC_ERROR([gmp library too old])])
64 CPPFLAGS="$SAVE_CPPFLAGS"
65 LDFLAGS="$SAVE_LDFLAGS"
69 GMP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
70 GMP_LIBS="$with_gmp_builddir/libgmp.la"
73 SAVE_CPPFLAGS="$CPPFLAGS"
74 SAVE_LDFLAGS="$LDFLAGS"
76 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
77 LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
78 LIBS="$GMP_LIBS $LIBS"
79 need_get_memory_functions=false
80 AC_CHECK_DECLS(mp_get_memory_functions,[],[
81 need_get_memory_functions=true
83 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
92 mpz_gcdext(g, a, b, x, y);
93 if (mpz_get_si(a) == -1 && mpz_get_si(b) == 0)
97 ]])], [need_normalized_gcdext=false], [need_normalized_gcdext=true],
98 [need_normalized_gcdext=true])
99 CPPFLAGS="$SAVE_CPPFLAGS"
100 LDFLAGS="$SAVE_LDFLAGS"
102 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
103 if test $need_normalized_gcdext = true; then
104 AC_DEFINE([GMP_NORMALIZE_GCDEXT], [],
105 [result of mpz_gcdext needs to be normalized])
108 AX_SUBMODULE(piplib,no|system|build,no)
111 AC_SUBST(PIPLIB_CPPFLAGS)
112 AC_SUBST(PIPLIB_LDFLAGS)
113 AC_SUBST(PIPLIB_LIBS)
114 case "$with_piplib" in
116 PIPLIB_CPPFLAGS="-I$piplib_srcdir/include"
117 PIPLIB_LIBS="$with_piplib_builddir/libpiplibMP.la"
120 PIPLIB_LIBS="-lpiplibMP"
121 if test "x$with_piplib_prefix" != "x"; then
122 PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
123 PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
125 SAVE_CPPFLAGS="$CPPFLAGS"
126 SAVE_LDFLAGS="$LDFLAGS"
127 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
128 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
129 AC_CHECK_LIB(piplibMP, pip_solve,[
130 AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
131 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
132 ],[#include <piplib/piplibMP.h>])
134 AC_MSG_ERROR([Piplib not found])
136 CPPFLAGS="$SAVE_CPPFLAGS"
137 LDFLAGS="$SAVE_LDFLAGS"
142 AC_MSG_ERROR(unsupported)
145 if test "$with_piplib" != "no"; then
146 AC_DEFINE(ISL_PIPLIB,,piplib is available)
149 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
151 AC_SUBST(CLANG_CXXFLAGS)
152 AC_SUBST(CLANG_LDFLAGS)
154 AX_SUBMODULE(clang,system|no,no)
155 case "$with_clang" in
157 llvm_config="llvm-config"
158 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
159 if test "x$with_clang_prefix" != "x"; then
160 llvm_config="$with_clang_prefix/bin/llvm-config"
161 if test -x "$llvm_config"; then
162 llvm_config_found=yes
165 if test "$llvm_config_found" != yes; then
166 AC_MSG_ERROR([llvm-config not found])
168 CLANG_CXXFLAGS=`$llvm_config --cxxflags`
169 CLANG_LDFLAGS=`$llvm_config --ldflags`
170 targets=`$llvm_config --targets-built`
171 CLANG_LIBS=`$llvm_config --libs $targets asmparser bitreader support mc`
172 CLANG_PREFIX=`$llvm_config --prefix`
173 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
174 [Clang installation prefix])
176 SAVE_CPPFLAGS="$CPPFLAGS"
177 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
179 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
180 [AC_ERROR([clang header file not found])])
181 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
182 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
183 [Define to getHostTriple for older versions of clang])])
184 AC_EGREP_HEADER([getExpansionLineNumber],
185 [clang/Basic/SourceLocation.h], [],
186 [AC_DEFINE([getExpansionLineNumber],
187 [getInstantiationLineNumber],
188 [Define to getInstantiationLineNumber for older versions of clang])])
189 AC_EGREP_HEADER([DiagnosticsEngine],
190 [clang/Basic/Diagnostic.h], [],
191 [AC_DEFINE([DiagnosticsEngine],
193 [Define to Diagnostic for older versions of clang])])
194 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
195 [AC_DEFINE([USE_ARRAYREF], [],
196 [Define if Driver::BuildCompilation takes ArrayRef])])
197 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
198 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
199 [Define if Driver constructor takes CXXIsProduction argument])])
200 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
201 [AC_DEFINE([HAVE_ISPRODUCTION], [],
202 [Define if Driver constructor takes IsProduction argument])])
203 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
204 [AC_DEFINE([HandleTopLevelDeclReturn], [void],
205 [Return type of HandleTopLevelDeclReturn])
206 AC_DEFINE([HandleTopLevelDeclContinue], [],
207 [Return type of HandleTopLevelDeclReturn])],
208 [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
209 [Return type of HandleTopLevelDeclReturn])
210 AC_DEFINE([HandleTopLevelDeclContinue], [true],
211 [Return type of HandleTopLevelDeclReturn])])
212 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
213 [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
214 [Define if clang/Basic/DiagnosticOptions.h exists])])
215 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
216 using namespace clang;
218 DiagnosticsEngine *Diags;
219 TargetInfo::CreateTargetInfo(*Diags, TO);
220 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
221 [Define if TargetInfo::CreateTargetInfo takes pointer])])
222 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
223 using namespace clang;
224 DiagnosticConsumer *client;
225 CompilerInstance *Clang;
226 Clang->createDiagnostics(client);
227 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
228 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
229 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
230 using namespace clang;
231 HeaderSearchOptions HSO;
232 HSO.AddPath("", frontend::Angled, false, false);
233 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
234 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
236 CPPFLAGS="$SAVE_CPPFLAGS"
238 SAVE_LDFLAGS="$LDFLAGS"
239 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
240 AC_SUBST(LIB_CLANG_EDIT)
241 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
242 LDFLAGS="$SAVE_LDFLAGS"
245 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
249 AC_SUBST(WARNING_FLAGS)
251 PACKAGE_CFLAGS="$GMP_CPPFLAGS"
252 PACKAGE_LDFLAGS="$GMP_LDFLAGS"
253 PACKAGE_LIBS="-lisl -lgmp"
254 AX_CREATE_PKGCONFIG_INFO
257 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
259 AH_BOTTOM([#include <isl_config_post.h>])
260 AC_CONFIG_HEADERS(isl_config.h)
261 AC_CONFIG_HEADERS(include/isl/config.h)
262 AC_CONFIG_FILES(Makefile)
263 AC_CONFIG_FILES(doc/Makefile)
264 if test $with_clang = system; then
265 AC_CONFIG_FILES(interface/Makefile)
267 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
268 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
269 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
270 AC_CONFIG_COMMANDS_POST([
271 dnl pass on arguments to subdir configures, but don't
272 dnl add them to config.status
273 ac_configure_args="$ac_configure_args $isl_configure_args"