1 AC_INIT([isl], [0.17], [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)
39 [AS_HELP_STRING([--with-int=gmp|imath|imath-32],
40 [Which package to use to represent
41 multi-precision integers [default=gmp]])],
48 [bad value ${withval} for --with-int (use gmp, imath or imath-32)])
62 if test "x$with_int" = "ximath-32" -a "x$GCC" = "xyes"; then
63 MP_CPPFLAGS="-std=gnu99 $MP_CPPFLAGS"
66 AM_CONDITIONAL(IMATH_FOR_MP, test x$with_int = ximath -o x$with_int = ximath-32)
67 AM_CONDITIONAL(GMP_FOR_MP, test x$with_int = xgmp)
69 AM_CONDITIONAL(SMALL_INT_OPT, test "x$with_int" == "ximath-32")
70 AS_IF([test "x$with_int" == "ximath-32"], [
71 AC_DEFINE([USE_SMALL_INT_OPT], [], [Use small integer optimization])
74 AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
75 AC_CHECK_DECLS(__builtin_ffs,[],[],[])
76 AC_CHECK_DECLS([_BitScanForward],[],[],[#include <intrin.h>])
77 if test "x$ac_cv_have_decl_ffs" = xno -a \
78 "x$ac_cv_have_decl___builtin_ffs" = xno -a \
79 "x$ac_cv_have_decl__BitScanForward" = xno; then
80 AC_MSG_ERROR([No ffs implementation found])
82 AC_CHECK_DECLS([strcasecmp,strncasecmp],[],[],[#include <strings.h>])
83 AC_CHECK_DECLS([_stricmp,_strnicmp],[],[],[#include <string.h>])
84 if test "x$ac_cv_have_decl_strcasecmp" = xno -a \
85 "x$ac_cv_have_decl__stricmp" = xno; then
86 AC_MSG_ERROR([No strcasecmp implementation found])
88 if test "x$ac_cv_have_decl_strncasecmp" = xno -a \
89 "x$ac_cv_have_decl__strnicmp" = xno; then
90 AC_MSG_ERROR([No strncasecmp implementation found])
92 AC_CHECK_DECLS([snprintf,_snprintf],[],[],[#include <stdio.h>])
93 if test "x$ac_cv_have_decl_snprintf" = xno -a \
94 "x$ac_cv_have_decl__snprintf" = xno; then
95 AC_MSG_ERROR([No snprintf implementation found])
98 AC_SUBST(CLANG_CXXFLAGS)
99 AC_SUBST(CLANG_LDFLAGS)
101 AX_SUBMODULE(clang,system|no,no)
102 case "$with_clang" in
106 llvm_config="llvm-config"
107 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
108 if test "x$with_clang_prefix" != "x"; then
109 llvm_config="$with_clang_prefix/bin/llvm-config"
110 if test -x "$llvm_config"; then
111 llvm_config_found=yes
114 if test "$llvm_config_found" != yes; then
115 AC_MSG_ERROR([llvm-config not found])
117 CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
118 $SED -e 's/-Wcovered-switch-default//'`
119 CLANG_LDFLAGS=`$llvm_config --ldflags`
120 targets=`$llvm_config --targets-built`
121 components="$targets asmparser bitreader support mc"
122 $llvm_config --components | $GREP option > /dev/null 2> /dev/null
123 if test $? -eq 0; then
124 components="$components option"
126 CLANG_LIBS=`$llvm_config --libs $components`
127 systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
128 if test $? -eq 0; then
129 CLANG_LIBS="$CLANG_LIBS $systemlibs"
131 CLANG_PREFIX=`$llvm_config --prefix`
132 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
133 [Clang installation prefix])
135 SAVE_CPPFLAGS="$CPPFLAGS"
136 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
138 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
139 [AC_ERROR([clang header file not found])])
140 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
141 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
142 [Define to getHostTriple for older versions of clang])])
143 AC_EGREP_HEADER([getExpansionLineNumber],
144 [clang/Basic/SourceLocation.h], [],
145 [AC_DEFINE([getExpansionLineNumber],
146 [getInstantiationLineNumber],
147 [Define to getInstantiationLineNumber for older versions of clang])])
148 AC_EGREP_HEADER([DiagnosticsEngine],
149 [clang/Basic/Diagnostic.h], [],
150 [AC_DEFINE([DiagnosticsEngine],
152 [Define to Diagnostic for older versions of clang])])
153 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
154 [AC_DEFINE([USE_ARRAYREF], [],
155 [Define if Driver::BuildCompilation takes ArrayRef])])
156 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
157 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
158 [Define if Driver constructor takes CXXIsProduction argument])])
159 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
160 [AC_DEFINE([HAVE_ISPRODUCTION], [],
161 [Define if Driver constructor takes IsProduction argument])])
162 AC_TRY_COMPILE([#include <clang/Driver/Driver.h>], [
163 using namespace clang;
164 DiagnosticsEngine *Diags;
165 new driver::Driver("", "", "", *Diags);
166 ], [AC_DEFINE([DRIVER_CTOR_TAKES_DEFAULTIMAGENAME], [],
167 [Define if Driver constructor takes default image name])])
168 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
169 [AC_DEFINE([HandleTopLevelDeclReturn], [void],
170 [Return type of HandleTopLevelDeclReturn])
171 AC_DEFINE([HandleTopLevelDeclContinue], [],
172 [Return type of HandleTopLevelDeclReturn])],
173 [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
174 [Return type of HandleTopLevelDeclReturn])
175 AC_DEFINE([HandleTopLevelDeclContinue], [true],
176 [Return type of HandleTopLevelDeclReturn])])
177 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
178 [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
179 [Define if clang/Basic/DiagnosticOptions.h exists])])
180 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
181 using namespace clang;
182 std::shared_ptr<TargetOptions> TO;
183 DiagnosticsEngine *Diags;
184 TargetInfo::CreateTargetInfo(*Diags, TO);
185 ], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
186 [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
187 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
188 using namespace clang;
190 DiagnosticsEngine *Diags;
191 TargetInfo::CreateTargetInfo(*Diags, TO);
192 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
193 [Define if TargetInfo::CreateTargetInfo takes pointer])])
194 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
195 using namespace clang;
196 DiagnosticConsumer *client;
197 CompilerInstance *Clang;
198 Clang->createDiagnostics(client);
199 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
200 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
201 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
202 using namespace clang;
203 HeaderSearchOptions HSO;
204 HSO.AddPath("", frontend::Angled, false, false);
205 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
206 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
207 AC_EGREP_HEADER([getNumParams],
208 [clang/AST/CanonicalType.h],
209 [AC_DEFINE([getNumArgs], [getNumParams],
210 [Define to getNumParams for newer versions of clang])
211 AC_DEFINE([getArgType], [getParamType],
212 [Define to getParamType for newer versions of clang])])
213 AC_EGREP_HEADER([getReturnType],
214 [clang/AST/CanonicalType.h], [],
215 [AC_DEFINE([getReturnType], [getResultType],
216 [Define to getResultType for older versions of clang])])
217 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
218 using namespace clang;
219 CompilerInstance *Clang;
220 Clang->createPreprocessor(TU_Complete);
221 ], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
222 [Define if CompilerInstance::createPreprocessor takes
223 TranslationUnitKind])])
224 AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
225 [AC_DEFINE([HAVE_SETMAINFILEID], [],
226 [Define if SourceManager has a setMainFileID method])])
227 AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
228 [AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
229 [Define if llvm/ADT/OwningPtr.h exists])])
230 AC_EGREP_HEADER([initializeBuiltins],
231 [clang/Basic/Builtins.h], [],
232 [AC_DEFINE([initializeBuiltins], [InitializeBuiltins],
233 [Define to InitializeBuiltins for older versions of clang])])
235 CPPFLAGS="$SAVE_CPPFLAGS"
237 SAVE_LDFLAGS="$LDFLAGS"
238 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
239 AC_SUBST(LIB_CLANG_EDIT)
240 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
241 LDFLAGS="$SAVE_LDFLAGS"
244 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
248 AC_SUBST(WARNING_FLAGS)
250 PACKAGE_CFLAGS="$MP_CPPFLAGS"
251 PACKAGE_LDFLAGS="$MP_LDFLAGS"
252 PACKAGE_LIBS="-lisl $MP_LIBS"
253 AX_CREATE_PKGCONFIG_INFO
257 AH_BOTTOM([#include <isl_config_post.h>])
258 AC_CONFIG_HEADERS(isl_config.h)
259 AC_CONFIG_FILES(Makefile)
260 AC_CONFIG_FILES(doc/Makefile)
261 if test $with_clang = system; then
262 AC_CONFIG_FILES(interface/Makefile)
264 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
265 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
266 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
267 AC_CONFIG_COMMANDS_POST([
268 dnl pass on arguments to subdir configures, but don't
269 dnl add them to config.status
270 ac_configure_args="$ac_configure_args $isl_configure_args"