1 AC_INIT([isl], [0.17.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)
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_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
181 [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
182 [Define if clang/Lex/PreprocessorOptions.h exists])],
183 [], [#include <clang/Basic/LLVM.h>])
184 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
185 using namespace clang;
186 std::shared_ptr<TargetOptions> TO;
187 DiagnosticsEngine *Diags;
188 TargetInfo::CreateTargetInfo(*Diags, TO);
189 ], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
190 [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
191 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
192 using namespace clang;
194 DiagnosticsEngine *Diags;
195 TargetInfo::CreateTargetInfo(*Diags, TO);
196 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
197 [Define if TargetInfo::CreateTargetInfo takes pointer])])
198 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
199 using namespace clang;
200 DiagnosticConsumer *client;
201 CompilerInstance *Clang;
202 Clang->createDiagnostics(client);
203 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
204 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
205 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
206 using namespace clang;
207 HeaderSearchOptions HSO;
208 HSO.AddPath("", frontend::Angled, false, false);
209 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
210 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
211 AC_EGREP_HEADER([getNumParams],
212 [clang/AST/CanonicalType.h],
213 [AC_DEFINE([getNumArgs], [getNumParams],
214 [Define to getNumParams for newer versions of clang])
215 AC_DEFINE([getArgType], [getParamType],
216 [Define to getParamType for newer versions of clang])])
217 AC_EGREP_HEADER([getReturnType],
218 [clang/AST/CanonicalType.h], [],
219 [AC_DEFINE([getReturnType], [getResultType],
220 [Define to getResultType for older versions of clang])])
221 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
222 using namespace clang;
223 CompilerInstance *Clang;
224 Clang->createPreprocessor(TU_Complete);
225 ], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
226 [Define if CompilerInstance::createPreprocessor takes
227 TranslationUnitKind])])
228 AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
229 [AC_DEFINE([HAVE_SETMAINFILEID], [],
230 [Define if SourceManager has a setMainFileID method])])
231 AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
232 [AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
233 [Define if llvm/ADT/OwningPtr.h exists])])
234 AC_EGREP_HEADER([initializeBuiltins],
235 [clang/Basic/Builtins.h], [],
236 [AC_DEFINE([initializeBuiltins], [InitializeBuiltins],
237 [Define to InitializeBuiltins for older versions of clang])])
239 #include <clang/Basic/TargetOptions.h>
240 #include <clang/Lex/PreprocessorOptions.h>
241 #include <clang/Frontend/CompilerInstance.h>
243 using namespace clang;
244 CompilerInstance *Clang;
246 llvm::Triple T(TO.Triple);
247 PreprocessorOptions PO;
248 CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C,
249 T, PO, LangStandard::lang_unspecified);
250 ], [AC_DEFINE([SETLANGDEFAULTS_TAKES_5_ARGUMENTS], [],
251 [Define if CompilerInvocation::setLangDefaults takes 5 arguments])])
253 CPPFLAGS="$SAVE_CPPFLAGS"
255 SAVE_LDFLAGS="$LDFLAGS"
256 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
257 AC_SUBST(LIB_CLANG_EDIT)
258 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
259 LDFLAGS="$SAVE_LDFLAGS"
262 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
266 AC_SUBST(WARNING_FLAGS)
268 PACKAGE_CFLAGS="$MP_CPPFLAGS"
269 PACKAGE_LDFLAGS="$MP_LDFLAGS"
270 PACKAGE_LIBS="-lisl $MP_LIBS"
271 AX_CREATE_PKGCONFIG_INFO
275 AH_BOTTOM([#include <isl_config_post.h>])
276 AC_CONFIG_HEADERS(isl_config.h)
277 AC_CONFIG_FILES(Makefile)
278 AC_CONFIG_FILES(doc/Makefile)
279 if test $with_clang = system; then
280 AC_CONFIG_FILES(interface/Makefile)
282 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
283 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
284 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
285 AC_CONFIG_COMMANDS_POST([
286 dnl pass on arguments to subdir configures, but don't
287 dnl add them to config.status
288 ac_configure_args="$ac_configure_args $isl_configure_args"