add pet_expr_foreach_access_expr
[pet.git] / configure.ac
blob55f8983ecfb62b87c83a491d38de3d19771f2fc0
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])])
6 AC_SUBST(versioninfo)
7 versioninfo=4:0:0
9 AC_PROG_CC
10 AC_PROG_CXX
11 AC_PROG_LIBTOOL
13 AC_SUBST(CLANG_CXXFLAGS)
14 AC_SUBST(CLANG_LDFLAGS)
15 AC_SUBST(CLANG_LIBS)
16 AX_SUBMODULE(clang,system,system)
17 llvm_config="llvm-config"
18 AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
19 if test "x$with_clang_prefix" != "x"; then
20         llvm_config="$with_clang_prefix/bin/llvm-config"
21         if test -x "$llvm_config"; then
22                 llvm_config_found=yes
23         fi
25 if test "$llvm_config_found" != yes; then
26         AC_MSG_ERROR([llvm-config not found])
28 CLANG_CXXFLAGS=`$llvm_config --cxxflags`
29 CLANG_LDFLAGS=`$llvm_config --ldflags`
30 targets=`$llvm_config --targets-built`
31 CLANG_LIBS=`$llvm_config --libs $targets asmparser bitreader support mc`
32 CLANG_PREFIX=`$llvm_config --prefix`
33 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"], [Clang installation prefix])
35 SAVE_CPPFLAGS="$CPPFLAGS"
36 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
37 AC_LANG_PUSH(C++)
38 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
39         [AC_ERROR([clang header file not found])])
40 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
41         [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
42         [Define to getHostTriple for older versions of clang])])
43 AC_EGREP_HEADER([getExpansionLineNumber], [clang/Basic/SourceLocation.h], [],
44         [AC_DEFINE([getExpansionLineNumber], [getInstantiationLineNumber],
45         [Define to getInstantiationLineNumber for older versions of clang])])
46 AC_EGREP_HEADER([getExpansionColumnNumber], [clang/Basic/SourceLocation.h], [],
47         [AC_DEFINE([getExpansionColumnNumber], [getInstantiationColumnNumber],
48         [Define to getInstantiationColumnNumber for older versions of clang])])
49 AC_EGREP_HEADER([getExpansionLoc], [clang/Basic/SourceManager.h], [],
50         [AC_DEFINE([getExpansionLoc], [getInstantiationLoc],
51         [Define to getInstantiationLoc for older versions of clang])])
52 AC_EGREP_HEADER([DiagnosticConsumer], [clang/Basic/Diagnostic.h], [],
53         [AC_DEFINE([DiagnosticConsumer], [DiagnosticClient],
54         [Define to DiagnosticClient for older versions of clang])])
55 AC_EGREP_HEADER([DiagnosticsEngine], [clang/Basic/Diagnostic.h],
56         [AC_DEFINE([DiagnosticInfo], [Diagnostic],
57         [Define to Diagnostic for newer versions of clang])],
58         [AC_DEFINE([DiagnosticsEngine], [Diagnostic],
59         [Define to Diagnostic for older versions of clang])])
60 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
61         [AC_DEFINE([USE_ARRAYREF], [],
62                 [Define if Driver::BuildCompilation takes ArrayRef])])
63 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
64         [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
65                 [Define if Driver constructor takes CXXIsProduction argument])])
66 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
67         [AC_DEFINE([HAVE_ISPRODUCTION], [],
68                 [Define if Driver constructor takes IsProduction argument])])
69 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
70         [AC_DEFINE([HandleTopLevelDeclReturn], [void],
71                    [Return type of HandleTopLevelDeclReturn])
72          AC_DEFINE([HandleTopLevelDeclContinue], [],
73                    [Return type of HandleTopLevelDeclReturn])],
74         [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
75                    [Return type of HandleTopLevelDeclReturn])
76          AC_DEFINE([HandleTopLevelDeclContinue], [true],
77                    [Return type of HandleTopLevelDeclReturn])])
78 AC_EGREP_HEADER([isEnclosingLocal,], [clang/AST/Expr.h],
79         [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_BOOL], [],
80             [Define if DeclRefExpr::Create takes isEnclosingLocal argument])])
81 AC_EGREP_HEADER([HasTemplateKWAndArgsInfo], [clang/AST/Expr.h],
82         [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_SOURCELOCATION], [],
83                 [Define if DeclRefExpr::Create takes SourceLocation argument])])
84 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
85         [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
86                    [Define if clang/Basic/DiagnosticOptions.h exists])])
87 AC_CHECK_HEADER([clang/Lex/HeaderSearchOptions.h],
88         [AC_DEFINE([HAVE_LEX_HEADERSEARCHOPTIONS_H], [],
89                    [Define if clang/Lex/HeaderSearchOptions.h exists])], [],
90         [#include <clang/Basic/LLVM.h>])
91 AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
92         [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
93                    [Define if clang/Lex/PreprocessorOptions.h exists])], [],
94         [#include <clang/Basic/LLVM.h>])
95 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
96         using namespace clang;
97         TargetOptions *TO;
98         DiagnosticsEngine *Diags;
99         TargetInfo::CreateTargetInfo(*Diags, TO);
100 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
101               [Define if TargetInfo::CreateTargetInfo takes pointer])])
102 AC_EGREP_HEADER([getLangOpts], [clang/Lex/Preprocessor.h], [],
103         [AC_DEFINE([getLangOpts], [getLangOptions],
104         [Define to getLangOptions for older versions of clang])])
105 AC_EGREP_HEADER([findLocationAfterToken], [clang/Lex/Lexer.h],
106         [AC_DEFINE([HAVE_FINDLOCATIONAFTERTOKEN], [],
107         [Define if SourceManager has findLocationAfterToken method])])
108 AC_EGREP_HEADER([translateLineCol], [clang/Basic/SourceManager.h],
109         [AC_DEFINE([HAVE_TRANSLATELINECOL], [],
110         [Define if SourceManager has translateLineCol method])])
111 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
112         using namespace clang;
113         DiagnosticConsumer *client;
114         CompilerInstance *Clang;
115         Clang->createDiagnostics(client);
116 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
117         [Define if CompilerInstance::createDiagnostics takes argc and argv])])
118 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
119         using namespace clang;
120         HeaderSearchOptions HSO;
121         HSO.AddPath("", frontend::Angled, false, false);
122 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
123         [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
124 AC_EGREP_HEADER([getLocWithOffset], [clang/Basic/SourceLocation.h], [],
125         [AC_DEFINE([getLocWithOffset], [getFileLocWithOffset],
126         [Define to getFileLocWithOffset for older versions of clang])])
127 AC_LANG_POP
128 CPPFLAGS="$SAVE_CPPFLAGS"
130 SAVE_LDFLAGS="$LDFLAGS"
131 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
132 AC_SUBST(LIB_CLANG_EDIT)
133 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
134 LDFLAGS="$SAVE_LDFLAGS"
136 AX_SUBMODULE(gmp,system|build,system)
138 AC_SUBST(GMP_LDFLAGS)
139 AC_SUBST(GMP_LIBS)
140 case "$with_gmp" in
141 system)
142         if test "x$with_gmp_prefix" != "x"; then
143                 GMP_CPPFLAGS="-I$with_gmp_prefix/include"
144                 GMP_LDFLAGS="-L$with_gmp_prefix/lib"
145         fi
146         GMP_LIBS=-lgmp
147         ;;
148 build)
149         GMP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
150         GMP_LIBS="$with_gmp_builddir/libgmp.la"
151         ;;
152 esac
154 AX_SUBMODULE(isl,build|bundled|system,bundled)
155 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
157 AC_SUBST(ISL_CFLAGS)
158 AC_SUBST(ISL_LIBS)
159 AC_SUBST(ISL_SRCDIR)
160 case "$with_isl" in
161 bundled)
162         ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
163         ISL_CFLAGS="$ISL_CFLAGS $GMP_CPPFLAGS"
164         ISL_SRCDIR="$srcdir/isl"
165         ;;
166 build)
167         ISL_SRCDIR="$isl_srcdir"
168         ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
169         ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
170         ISL_CFLAGS="$ISL_CFLAGS $GMP_CPPFLAGS"
171         ISL_LIBS="$with_isl_builddir/libisl.la $GMP_LDFLAGS $GMP_LIBS"
172         ;;
173 system)
174         PKG_CHECK_MODULES([ISL], [isl])
175         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
176 esac
178 AX_SUBMODULE(libyaml,system|no,system)
179 AC_SUBST(LIBYAML_CPPFLAGS)
180 AC_SUBST(LIBYAML_LDFLAGS)
181 if test "x$with_libyaml_prefix" != "x"; then
182         LIBYAML_CPPFLAGS="-I$with_libyaml_prefix/include"
184 if test "x$with_libyaml_exec_prefix" != "x"; then
185         LIBYAML_LDFLAGS="-L$with_libyaml_exec_prefix/lib"
188 if test "$with_libyaml" = "system"; then
189         SAVE_CPPFLAGS=$CPPFLAGS
190         CPPFLAGS="$CPPFLAGS $LIBYAML_CPPFLAGS"
191         AC_CHECK_HEADER([yaml.h],[],[with_libyaml="no"])
192         CPPFLAGS="$SAVE_CPPFLAGS"
195 AC_SUBST(extra_bin_programs)
196 AC_SUBST(extra_noinst_programs)
197 AC_SUBST(extra_tests)
199 if test "$with_libyaml" != "no"; then
200         extra_bin_programs="pet"
201         extra_noinst_programs="pet_scop_cmp"
202         extra_tests="pet_test.sh"
204 if test "$with_isl" != "system"; then
205         extra_tests="$extra_tests codegen_test.sh"
208 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
209 PACKAGE_LIBS="-lpet -lisl"
210 AX_CREATE_PKGCONFIG_INFO
212 AX_DETECT_GIT_HEAD
213 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
215 AC_CONFIG_HEADERS(config.h)
216 AC_CONFIG_FILES(Makefile)
217 AC_CONFIG_FILES([pet_test.sh], [chmod +x pet_test.sh])
218 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
219 if test $with_isl = bundled; then
220         AC_CONFIG_SUBDIRS(isl)
222 AC_OUTPUT