1 AC_INIT([isl], [0.12.1], [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])
107 AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
108 AC_CHECK_DECLS(__builtin_ffs,[],[],[])
110 AC_SUBST(CLANG_CXXFLAGS)
111 AC_SUBST(CLANG_LDFLAGS)
113 AX_SUBMODULE(clang,system|no,no)
114 case "$with_clang" in
117 llvm_config="llvm-config"
118 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
119 if test "x$with_clang_prefix" != "x"; then
120 llvm_config="$with_clang_prefix/bin/llvm-config"
121 if test -x "$llvm_config"; then
122 llvm_config_found=yes
125 if test "$llvm_config_found" != yes; then
126 AC_MSG_ERROR([llvm-config not found])
128 CLANG_CXXFLAGS=`$llvm_config --cxxflags`
129 CLANG_LDFLAGS=`$llvm_config --ldflags`
130 targets=`$llvm_config --targets-built`
131 components="$targets asmparser bitreader support mc"
132 $llvm_config --components | $GREP option > /dev/null 2> /dev/null
133 if test $? -eq 0; then
134 components="$components option"
136 CLANG_LIBS=`$llvm_config --libs $components`
137 systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
138 if test $? -eq 0; then
139 CLANG_LIBS="$CLANG_LIBS $systemlibs"
141 CLANG_PREFIX=`$llvm_config --prefix`
142 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
143 [Clang installation prefix])
145 SAVE_CPPFLAGS="$CPPFLAGS"
146 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
148 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
149 [AC_ERROR([clang header file not found])])
150 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
151 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
152 [Define to getHostTriple for older versions of clang])])
153 AC_EGREP_HEADER([getExpansionLineNumber],
154 [clang/Basic/SourceLocation.h], [],
155 [AC_DEFINE([getExpansionLineNumber],
156 [getInstantiationLineNumber],
157 [Define to getInstantiationLineNumber for older versions of clang])])
158 AC_EGREP_HEADER([DiagnosticsEngine],
159 [clang/Basic/Diagnostic.h], [],
160 [AC_DEFINE([DiagnosticsEngine],
162 [Define to Diagnostic for older versions of clang])])
163 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
164 [AC_DEFINE([USE_ARRAYREF], [],
165 [Define if Driver::BuildCompilation takes ArrayRef])])
166 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
167 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
168 [Define if Driver constructor takes CXXIsProduction argument])])
169 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
170 [AC_DEFINE([HAVE_ISPRODUCTION], [],
171 [Define if Driver constructor takes IsProduction argument])])
172 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
173 [AC_DEFINE([HandleTopLevelDeclReturn], [void],
174 [Return type of HandleTopLevelDeclReturn])
175 AC_DEFINE([HandleTopLevelDeclContinue], [],
176 [Return type of HandleTopLevelDeclReturn])],
177 [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
178 [Return type of HandleTopLevelDeclReturn])
179 AC_DEFINE([HandleTopLevelDeclContinue], [true],
180 [Return type of HandleTopLevelDeclReturn])])
181 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
182 [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
183 [Define if clang/Basic/DiagnosticOptions.h exists])])
184 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
185 using namespace clang;
187 DiagnosticsEngine *Diags;
188 TargetInfo::CreateTargetInfo(*Diags, TO);
189 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
190 [Define if TargetInfo::CreateTargetInfo takes pointer])])
191 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
192 using namespace clang;
193 DiagnosticConsumer *client;
194 CompilerInstance *Clang;
195 Clang->createDiagnostics(client);
196 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
197 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
198 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
199 using namespace clang;
200 HeaderSearchOptions HSO;
201 HSO.AddPath("", frontend::Angled, false, false);
202 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
203 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
204 AC_EGREP_HEADER([getNumParams],
205 [clang/AST/CanonicalType.h],
206 [AC_DEFINE([getNumArgs], [getNumParams],
207 [Define to getNumParams for newer versions of clang])
208 AC_DEFINE([getArgType], [getParamType],
209 [Define to getParamType for newer versions of clang])])
210 AC_EGREP_HEADER([getReturnType],
211 [clang/AST/CanonicalType.h], [],
212 [AC_DEFINE([getReturnType], [getResultType],
213 [Define to getResultType for older versions of clang])])
215 CPPFLAGS="$SAVE_CPPFLAGS"
217 SAVE_LDFLAGS="$LDFLAGS"
218 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
219 AC_SUBST(LIB_CLANG_EDIT)
220 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
221 LDFLAGS="$SAVE_LDFLAGS"
224 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
228 AC_SUBST(WARNING_FLAGS)
230 PACKAGE_CFLAGS="$GMP_CPPFLAGS"
231 PACKAGE_LDFLAGS="$GMP_LDFLAGS"
232 PACKAGE_LIBS="-lisl -lgmp"
233 AX_CREATE_PKGCONFIG_INFO
236 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
238 AH_BOTTOM([#include <isl_config_post.h>])
239 AC_CONFIG_HEADERS(isl_config.h)
240 AC_CONFIG_HEADERS(include/isl/config.h)
241 AC_CONFIG_FILES(Makefile)
242 AC_CONFIG_FILES(doc/Makefile)
243 if test $with_clang = system; then
244 AC_CONFIG_FILES(interface/Makefile)
246 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
247 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
248 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
249 AC_CONFIG_COMMANDS_POST([
250 dnl pass on arguments to subdir configures, but don't
251 dnl add them to config.status
252 ac_configure_args="$ac_configure_args $isl_configure_args"