1 AC_INIT([pet], [0.07], [isl-development@googlegroups.com])
2 AC_CONFIG_AUX_DIR([build-aux])
3 AC_CONFIG_MACRO_DIR([m4])
4 AM_INIT_AUTOMAKE([foreign])
5 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
15 AC_SUBST(CLANG_CXXFLAGS)
16 AC_SUBST(CLANG_LDFLAGS)
18 AX_SUBMODULE(clang,system,system)
19 llvm_config="llvm-config"
20 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
21 if test "x$with_clang_prefix" != "x"; then
22 llvm_config="$with_clang_prefix/bin/llvm-config"
23 if test -x "$llvm_config"; then
27 if test "$llvm_config_found" != yes; then
28 AC_MSG_ERROR([llvm-config not found])
30 CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
31 $SED -e 's/-Wcovered-switch-default//'`
32 CLANG_LDFLAGS=`$llvm_config --ldflags`
33 targets=`$llvm_config --targets-built`
34 components="$targets asmparser bitreader support mc"
35 $llvm_config --components | $GREP option > /dev/null 2> /dev/null
36 if test $? -eq 0; then
37 components="$components option"
39 CLANG_LIBS=`$llvm_config --libs $components`
40 systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
41 if test $? -eq 0; then
42 CLANG_LIBS="$CLANG_LIBS $systemlibs"
44 CLANG_PREFIX=`$llvm_config --prefix`
45 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"], [Clang installation prefix])
47 SAVE_CPPFLAGS="$CPPFLAGS"
48 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
50 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
51 [AC_ERROR([clang header file not found])])
52 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
53 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
54 [Define to getHostTriple for older versions of clang])])
55 AC_EGREP_HEADER([getExpansionLineNumber], [clang/Basic/SourceLocation.h], [],
56 [AC_DEFINE([getExpansionLineNumber], [getInstantiationLineNumber],
57 [Define to getInstantiationLineNumber for older versions of clang])])
58 AC_EGREP_HEADER([getExpansionColumnNumber], [clang/Basic/SourceLocation.h], [],
59 [AC_DEFINE([getExpansionColumnNumber], [getInstantiationColumnNumber],
60 [Define to getInstantiationColumnNumber for older versions of clang])])
61 AC_EGREP_HEADER([getExpansionLoc], [clang/Basic/SourceManager.h], [],
62 [AC_DEFINE([getExpansionLoc], [getInstantiationLoc],
63 [Define to getInstantiationLoc for older versions of clang])])
64 AC_EGREP_HEADER([DiagnosticConsumer], [clang/Basic/Diagnostic.h], [],
65 [AC_DEFINE([DiagnosticConsumer], [DiagnosticClient],
66 [Define to DiagnosticClient for older versions of clang])])
67 AC_EGREP_HEADER([DiagnosticsEngine], [clang/Basic/Diagnostic.h],
68 [AC_DEFINE([DiagnosticInfo], [Diagnostic],
69 [Define to Diagnostic for newer versions of clang])],
70 [AC_DEFINE([DiagnosticsEngine], [Diagnostic],
71 [Define to Diagnostic for older versions of clang])])
72 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
73 [AC_DEFINE([USE_ARRAYREF], [],
74 [Define if Driver::BuildCompilation takes ArrayRef])])
75 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
76 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
77 [Define if Driver constructor takes CXXIsProduction argument])])
78 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
79 [AC_DEFINE([HAVE_ISPRODUCTION], [],
80 [Define if Driver constructor takes IsProduction argument])])
81 AC_TRY_COMPILE([#include <clang/Driver/Driver.h>], [
82 using namespace clang;
83 DiagnosticsEngine *Diags;
84 new driver::Driver("", "", "", *Diags);
85 ], [AC_DEFINE([DRIVER_CTOR_TAKES_DEFAULTIMAGENAME], [],
86 [Define if Driver constructor takes default image name])])
87 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
88 [AC_DEFINE([HandleTopLevelDeclReturn], [void],
89 [Return type of HandleTopLevelDeclReturn])
90 AC_DEFINE([HandleTopLevelDeclContinue], [],
91 [Return type of HandleTopLevelDeclReturn])],
92 [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
93 [Return type of HandleTopLevelDeclReturn])
94 AC_DEFINE([HandleTopLevelDeclContinue], [true],
95 [Return type of HandleTopLevelDeclReturn])])
96 create_requires_bool=false
97 AC_EGREP_HEADER([isEnclosingLocal,], [clang/AST/Expr.h],
98 [create_requires_bool=true])
99 AC_EGREP_HEADER([RefersToEnclosingVariableOrCapture,], [clang/AST/Expr.h],
100 [create_requires_bool=true])
101 if test "$create_requires_bool" = "true"; then
102 AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_BOOL], [],
103 [Define if DeclRefExpr::Create takes
104 isEnclosingLocal/RefersToEnclosingVariableOrCapture argument])
106 AC_EGREP_HEADER([HasTemplateKWAndArgsInfo], [clang/AST/Expr.h],
107 [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_SOURCELOCATION], [],
108 [Define if DeclRefExpr::Create takes SourceLocation argument])])
109 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
110 [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
111 [Define if clang/Basic/DiagnosticOptions.h exists])])
112 AC_CHECK_HEADER([clang/Lex/HeaderSearchOptions.h],
113 [AC_DEFINE([HAVE_LEX_HEADERSEARCHOPTIONS_H], [],
114 [Define if clang/Lex/HeaderSearchOptions.h exists])], [],
115 [#include <clang/Basic/LLVM.h>])
116 AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
117 [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
118 [Define if clang/Lex/PreprocessorOptions.h exists])], [],
119 [#include <clang/Basic/LLVM.h>])
120 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
121 using namespace clang;
122 std::shared_ptr<TargetOptions> TO;
123 DiagnosticsEngine *Diags;
124 TargetInfo::CreateTargetInfo(*Diags, TO);
125 ], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
126 [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
127 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
128 using namespace clang;
130 DiagnosticsEngine *Diags;
131 TargetInfo::CreateTargetInfo(*Diags, TO);
132 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
133 [Define if TargetInfo::CreateTargetInfo takes pointer])])
134 AC_EGREP_HEADER([getLangOpts], [clang/Lex/Preprocessor.h], [],
135 [AC_DEFINE([getLangOpts], [getLangOptions],
136 [Define to getLangOptions for older versions of clang])])
137 AC_EGREP_HEADER([findLocationAfterToken], [clang/Lex/Lexer.h],
138 [AC_DEFINE([HAVE_FINDLOCATIONAFTERTOKEN], [],
139 [Define if SourceManager has findLocationAfterToken method])])
140 AC_EGREP_HEADER([translateLineCol], [clang/Basic/SourceManager.h],
141 [AC_DEFINE([HAVE_TRANSLATELINECOL], [],
142 [Define if SourceManager has translateLineCol method])])
143 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
144 using namespace clang;
145 DiagnosticConsumer *client;
146 CompilerInstance *Clang;
147 Clang->createDiagnostics(client);
148 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
149 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
150 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
151 using namespace clang;
152 HeaderSearchOptions HSO;
153 HSO.AddPath("", frontend::Angled, false, false);
154 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
155 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
156 AC_EGREP_HEADER([getLocWithOffset], [clang/Basic/SourceLocation.h], [],
157 [AC_DEFINE([getLocWithOffset], [getFileLocWithOffset],
158 [Define to getFileLocWithOffset for older versions of clang])])
159 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
160 using namespace clang;
161 CompilerInstance *Clang;
162 Clang->createPreprocessor(TU_Complete);
163 ], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
164 [Define if CompilerInstance::createPreprocessor takes TranslationUnitKind])])
165 AC_EGREP_HEADER([DecayedType], [clang/AST/Type.h],
166 [AC_DEFINE([HAVE_DECAYEDTYPE], [], [Define if DecayedType is defined])])
167 AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
168 [AC_DEFINE([HAVE_SETMAINFILEID], [],
169 [Define if SourceManager has a setMainFileID method])])
170 AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
171 [AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
172 [Define if llvm/ADT/OwningPtr.h exists])])
173 AC_EGREP_HEADER([TypeInfo getTypeInfo], [clang/AST/ASTContext.h],
174 [AC_DEFINE([GETTYPEINFORETURNSTYPEINFO], [],
175 [Define if getTypeInfo returns TypeInfo object])])
176 AC_EGREP_HEADER([TypedefNameDecl], [clang/AST/Type.h], [],
177 [AC_DEFINE([TypedefNameDecl], [TypedefDecl],
178 [Define to TypedefDecl for older versions of clang])
179 AC_DEFINE([getTypedefNameForAnonDecl], [getTypedefForAnonDecl],
180 [Define to getTypedefForAnonDecl for older versions of clang])])
181 AC_EGREP_HEADER([StmtRange], [clang/AST/StmtIterator.h],
182 [AC_DEFINE([HAVE_STMTRANGE], [],
183 [Define if StmtRange class is available])])
184 AC_EGREP_HEADER([initializeBuiltins],
185 [clang/Basic/Builtins.h], [],
186 [AC_DEFINE([initializeBuiltins], [InitializeBuiltins],
187 [Define to InitializeBuiltins for older versions of clang])])
189 CPPFLAGS="$SAVE_CPPFLAGS"
191 SAVE_LDFLAGS="$LDFLAGS"
192 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
193 AC_SUBST(LIB_CLANG_EDIT)
194 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
195 LDFLAGS="$SAVE_LDFLAGS"
197 AX_SUBMODULE(isl,build|bundled|system,bundled)
198 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
203 AC_SUBST(ISL_BUILDDIR)
206 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
207 ISL_CFLAGS="$ISL_CFLAGS"
208 ISL_SRCDIR="$srcdir/isl"
212 ISL_SRCDIR="$isl_srcdir"
213 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
214 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
215 ISL_CFLAGS="$ISL_CFLAGS"
216 ISL_LIBS="$with_isl_builddir/libisl.la"
219 PKG_CHECK_MODULES([ISL], [isl])
220 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
223 AX_SUBMODULE(libyaml,system|no,system)
224 AC_SUBST(LIBYAML_CPPFLAGS)
225 AC_SUBST(LIBYAML_LDFLAGS)
226 if test "x$with_libyaml_prefix" != "x"; then
227 LIBYAML_CPPFLAGS="-I$with_libyaml_prefix/include"
229 if test "x$with_libyaml_exec_prefix" != "x"; then
230 LIBYAML_LDFLAGS="-L$with_libyaml_exec_prefix/lib"
233 if test "$with_libyaml" = "system"; then
234 SAVE_CPPFLAGS=$CPPFLAGS
235 CPPFLAGS="$CPPFLAGS $LIBYAML_CPPFLAGS"
236 AC_CHECK_HEADER([yaml.h],[],[with_libyaml="no"])
237 CPPFLAGS="$SAVE_CPPFLAGS"
240 AC_SUBST(extra_bin_programs)
241 AC_SUBST(extra_noinst_programs)
242 AC_SUBST(extra_tests)
244 if test "$with_libyaml" != "no"; then
245 extra_bin_programs="pet"
246 extra_noinst_programs="pet_scop_cmp"
247 extra_tests="pet_test.sh"
249 if test "$with_isl" != "system"; then
250 extra_tests="$extra_tests codegen_test.sh"
253 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
254 PACKAGE_LIBS="-lpet -lisl"
255 AX_CREATE_PKGCONFIG_INFO
258 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
260 AC_CONFIG_HEADERS(config.h)
261 AC_CONFIG_FILES(Makefile)
262 AC_CONFIG_FILES([pet_test.sh], [chmod +x pet_test.sh])
263 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
264 if test $with_isl = bundled; then
265 AC_CONFIG_SUBDIRS(isl)
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 --with-clang=system"