1 AC_INIT([pet], [0.04], [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])])
14 AC_SUBST(CLANG_CXXFLAGS)
15 AC_SUBST(CLANG_LDFLAGS)
17 AX_SUBMODULE(clang,system,system)
18 llvm_config="llvm-config"
19 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
20 if test "x$with_clang_prefix" != "x"; then
21 llvm_config="$with_clang_prefix/bin/llvm-config"
22 if test -x "$llvm_config"; then
26 if test "$llvm_config_found" != yes; then
27 AC_MSG_ERROR([llvm-config not found])
29 CLANG_CXXFLAGS=`$llvm_config --cxxflags`
30 CLANG_LDFLAGS=`$llvm_config --ldflags`
31 targets=`$llvm_config --targets-built`
32 components="$targets asmparser bitreader support mc"
33 $llvm_config --components | $GREP option > /dev/null 2> /dev/null
34 if test $? -eq 0; then
35 components="$components option"
37 CLANG_LIBS=`$llvm_config --libs $components`
38 CLANG_PREFIX=`$llvm_config --prefix`
39 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"], [Clang installation prefix])
41 SAVE_CPPFLAGS="$CPPFLAGS"
42 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
44 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
45 [AC_ERROR([clang header file not found])])
46 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
47 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
48 [Define to getHostTriple for older versions of clang])])
49 AC_EGREP_HEADER([getExpansionLineNumber], [clang/Basic/SourceLocation.h], [],
50 [AC_DEFINE([getExpansionLineNumber], [getInstantiationLineNumber],
51 [Define to getInstantiationLineNumber for older versions of clang])])
52 AC_EGREP_HEADER([getExpansionColumnNumber], [clang/Basic/SourceLocation.h], [],
53 [AC_DEFINE([getExpansionColumnNumber], [getInstantiationColumnNumber],
54 [Define to getInstantiationColumnNumber for older versions of clang])])
55 AC_EGREP_HEADER([getExpansionLoc], [clang/Basic/SourceManager.h], [],
56 [AC_DEFINE([getExpansionLoc], [getInstantiationLoc],
57 [Define to getInstantiationLoc for older versions of clang])])
58 AC_EGREP_HEADER([DiagnosticConsumer], [clang/Basic/Diagnostic.h], [],
59 [AC_DEFINE([DiagnosticConsumer], [DiagnosticClient],
60 [Define to DiagnosticClient for older versions of clang])])
61 AC_EGREP_HEADER([DiagnosticsEngine], [clang/Basic/Diagnostic.h],
62 [AC_DEFINE([DiagnosticInfo], [Diagnostic],
63 [Define to Diagnostic for newer versions of clang])],
64 [AC_DEFINE([DiagnosticsEngine], [Diagnostic],
65 [Define to Diagnostic for older versions of clang])])
66 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
67 [AC_DEFINE([USE_ARRAYREF], [],
68 [Define if Driver::BuildCompilation takes ArrayRef])])
69 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
70 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
71 [Define if Driver constructor takes CXXIsProduction argument])])
72 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
73 [AC_DEFINE([HAVE_ISPRODUCTION], [],
74 [Define if Driver constructor takes IsProduction argument])])
75 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
76 [AC_DEFINE([HandleTopLevelDeclReturn], [void],
77 [Return type of HandleTopLevelDeclReturn])
78 AC_DEFINE([HandleTopLevelDeclContinue], [],
79 [Return type of HandleTopLevelDeclReturn])],
80 [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
81 [Return type of HandleTopLevelDeclReturn])
82 AC_DEFINE([HandleTopLevelDeclContinue], [true],
83 [Return type of HandleTopLevelDeclReturn])])
84 AC_EGREP_HEADER([isEnclosingLocal,], [clang/AST/Expr.h],
85 [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_BOOL], [],
86 [Define if DeclRefExpr::Create takes isEnclosingLocal argument])])
87 AC_EGREP_HEADER([HasTemplateKWAndArgsInfo], [clang/AST/Expr.h],
88 [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_SOURCELOCATION], [],
89 [Define if DeclRefExpr::Create takes SourceLocation argument])])
90 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
91 [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
92 [Define if clang/Basic/DiagnosticOptions.h exists])])
93 AC_CHECK_HEADER([clang/Lex/HeaderSearchOptions.h],
94 [AC_DEFINE([HAVE_LEX_HEADERSEARCHOPTIONS_H], [],
95 [Define if clang/Lex/HeaderSearchOptions.h exists])], [],
96 [#include <clang/Basic/LLVM.h>])
97 AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
98 [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
99 [Define if clang/Lex/PreprocessorOptions.h exists])], [],
100 [#include <clang/Basic/LLVM.h>])
101 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
102 using namespace clang;
104 DiagnosticsEngine *Diags;
105 TargetInfo::CreateTargetInfo(*Diags, TO);
106 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
107 [Define if TargetInfo::CreateTargetInfo takes pointer])])
108 AC_EGREP_HEADER([getLangOpts], [clang/Lex/Preprocessor.h], [],
109 [AC_DEFINE([getLangOpts], [getLangOptions],
110 [Define to getLangOptions for older versions of clang])])
111 AC_EGREP_HEADER([findLocationAfterToken], [clang/Lex/Lexer.h],
112 [AC_DEFINE([HAVE_FINDLOCATIONAFTERTOKEN], [],
113 [Define if SourceManager has findLocationAfterToken method])])
114 AC_EGREP_HEADER([translateLineCol], [clang/Basic/SourceManager.h],
115 [AC_DEFINE([HAVE_TRANSLATELINECOL], [],
116 [Define if SourceManager has translateLineCol method])])
117 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
118 using namespace clang;
119 DiagnosticConsumer *client;
120 CompilerInstance *Clang;
121 Clang->createDiagnostics(client);
122 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
123 [Define if CompilerInstance::createDiagnostics takes argc and argv])])
124 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
125 using namespace clang;
126 HeaderSearchOptions HSO;
127 HSO.AddPath("", frontend::Angled, false, false);
128 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
129 [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
130 AC_EGREP_HEADER([getLocWithOffset], [clang/Basic/SourceLocation.h], [],
131 [AC_DEFINE([getLocWithOffset], [getFileLocWithOffset],
132 [Define to getFileLocWithOffset for older versions of clang])])
134 CPPFLAGS="$SAVE_CPPFLAGS"
136 SAVE_LDFLAGS="$LDFLAGS"
137 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
138 AC_SUBST(LIB_CLANG_EDIT)
139 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
140 LDFLAGS="$SAVE_LDFLAGS"
142 AX_SUBMODULE(gmp,system|build,system)
144 AC_SUBST(GMP_LDFLAGS)
148 if test "x$with_gmp_prefix" != "x"; then
149 GMP_CPPFLAGS="-I$with_gmp_prefix/include"
150 GMP_LDFLAGS="-L$with_gmp_prefix/lib"
155 GMP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
156 GMP_LIBS="$with_gmp_builddir/libgmp.la"
160 AX_SUBMODULE(isl,build|bundled|system,bundled)
161 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
168 ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
169 ISL_CFLAGS="$ISL_CFLAGS $GMP_CPPFLAGS"
170 ISL_SRCDIR="$srcdir/isl"
173 ISL_SRCDIR="$isl_srcdir"
174 ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
175 ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
176 ISL_CFLAGS="$ISL_CFLAGS $GMP_CPPFLAGS"
177 ISL_LIBS="$with_isl_builddir/libisl.la $GMP_LDFLAGS $GMP_LIBS"
180 PKG_CHECK_MODULES([ISL], [isl])
181 PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
184 AX_SUBMODULE(libyaml,system|no,system)
185 AC_SUBST(LIBYAML_CPPFLAGS)
186 AC_SUBST(LIBYAML_LDFLAGS)
187 if test "x$with_libyaml_prefix" != "x"; then
188 LIBYAML_CPPFLAGS="-I$with_libyaml_prefix/include"
190 if test "x$with_libyaml_exec_prefix" != "x"; then
191 LIBYAML_LDFLAGS="-L$with_libyaml_exec_prefix/lib"
194 if test "$with_libyaml" = "system"; then
195 SAVE_CPPFLAGS=$CPPFLAGS
196 CPPFLAGS="$CPPFLAGS $LIBYAML_CPPFLAGS"
197 AC_CHECK_HEADER([yaml.h],[],[with_libyaml="no"])
198 CPPFLAGS="$SAVE_CPPFLAGS"
201 AC_SUBST(extra_bin_programs)
202 AC_SUBST(extra_noinst_programs)
203 AC_SUBST(extra_tests)
205 if test "$with_libyaml" != "no"; then
206 extra_bin_programs="pet"
207 extra_noinst_programs="pet_scop_cmp"
208 extra_tests="pet_test.sh"
210 if test "$with_isl" != "system"; then
211 extra_tests="$extra_tests codegen_test.sh"
214 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
215 PACKAGE_LIBS="-lpet -lisl"
216 AX_CREATE_PKGCONFIG_INFO
219 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
221 AC_CONFIG_HEADERS(config.h)
222 AC_CONFIG_FILES(Makefile)
223 AC_CONFIG_FILES([pet_test.sh], [chmod +x pet_test.sh])
224 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
225 if test $with_isl = bundled; then
226 AC_CONFIG_SUBDIRS(isl)