update isl for change in isl_map_subtract
[pet.git] / configure.ac
blob88b50c806f3726d5459faaa57cb63a7fcc420250
1 AC_INIT([pet], [0.05], [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=5:0:0
9 AC_PROG_CC
10 AC_PROG_CXX
11 AC_PROG_GREP
12 AC_PROG_LIBTOOL
14 AC_SUBST(CLANG_CXXFLAGS)
15 AC_SUBST(CLANG_LDFLAGS)
16 AC_SUBST(CLANG_LIBS)
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
23                 llvm_config_found=yes
24         fi
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 systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
39 if test $? -eq 0; then
40         CLANG_LIBS="$CLANG_LIBS $systemlibs"
42 CLANG_PREFIX=`$llvm_config --prefix`
43 AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"], [Clang installation prefix])
45 SAVE_CPPFLAGS="$CPPFLAGS"
46 CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
47 AC_LANG_PUSH(C++)
48 AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
49         [AC_ERROR([clang header file not found])])
50 AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
51         [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
52         [Define to getHostTriple for older versions of clang])])
53 AC_EGREP_HEADER([getExpansionLineNumber], [clang/Basic/SourceLocation.h], [],
54         [AC_DEFINE([getExpansionLineNumber], [getInstantiationLineNumber],
55         [Define to getInstantiationLineNumber for older versions of clang])])
56 AC_EGREP_HEADER([getExpansionColumnNumber], [clang/Basic/SourceLocation.h], [],
57         [AC_DEFINE([getExpansionColumnNumber], [getInstantiationColumnNumber],
58         [Define to getInstantiationColumnNumber for older versions of clang])])
59 AC_EGREP_HEADER([getExpansionLoc], [clang/Basic/SourceManager.h], [],
60         [AC_DEFINE([getExpansionLoc], [getInstantiationLoc],
61         [Define to getInstantiationLoc for older versions of clang])])
62 AC_EGREP_HEADER([DiagnosticConsumer], [clang/Basic/Diagnostic.h], [],
63         [AC_DEFINE([DiagnosticConsumer], [DiagnosticClient],
64         [Define to DiagnosticClient for older versions of clang])])
65 AC_EGREP_HEADER([DiagnosticsEngine], [clang/Basic/Diagnostic.h],
66         [AC_DEFINE([DiagnosticInfo], [Diagnostic],
67         [Define to Diagnostic for newer versions of clang])],
68         [AC_DEFINE([DiagnosticsEngine], [Diagnostic],
69         [Define to Diagnostic for older versions of clang])])
70 AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
71         [AC_DEFINE([USE_ARRAYREF], [],
72                 [Define if Driver::BuildCompilation takes ArrayRef])])
73 AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
74         [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
75                 [Define if Driver constructor takes CXXIsProduction argument])])
76 AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
77         [AC_DEFINE([HAVE_ISPRODUCTION], [],
78                 [Define if Driver constructor takes IsProduction argument])])
79 AC_TRY_COMPILE([#include <clang/Driver/Driver.h>], [
80         using namespace clang;
81         DiagnosticsEngine *Diags;
82         new driver::Driver("", "", "", *Diags);
83 ], [AC_DEFINE([DRIVER_CTOR_TAKES_DEFAULTIMAGENAME], [],
84               [Define if Driver constructor takes default image name])])
85 AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
86         [AC_DEFINE([HandleTopLevelDeclReturn], [void],
87                    [Return type of HandleTopLevelDeclReturn])
88          AC_DEFINE([HandleTopLevelDeclContinue], [],
89                    [Return type of HandleTopLevelDeclReturn])],
90         [AC_DEFINE([HandleTopLevelDeclReturn], [bool],
91                    [Return type of HandleTopLevelDeclReturn])
92          AC_DEFINE([HandleTopLevelDeclContinue], [true],
93                    [Return type of HandleTopLevelDeclReturn])])
94 AC_EGREP_HEADER([isEnclosingLocal,], [clang/AST/Expr.h],
95         [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_BOOL], [],
96             [Define if DeclRefExpr::Create takes isEnclosingLocal argument])])
97 AC_EGREP_HEADER([HasTemplateKWAndArgsInfo], [clang/AST/Expr.h],
98         [AC_DEFINE([DECLREFEXPR_CREATE_REQUIRES_SOURCELOCATION], [],
99                 [Define if DeclRefExpr::Create takes SourceLocation argument])])
100 AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
101         [AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
102                    [Define if clang/Basic/DiagnosticOptions.h exists])])
103 AC_CHECK_HEADER([clang/Lex/HeaderSearchOptions.h],
104         [AC_DEFINE([HAVE_LEX_HEADERSEARCHOPTIONS_H], [],
105                    [Define if clang/Lex/HeaderSearchOptions.h exists])], [],
106         [#include <clang/Basic/LLVM.h>])
107 AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
108         [AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
109                    [Define if clang/Lex/PreprocessorOptions.h exists])], [],
110         [#include <clang/Basic/LLVM.h>])
111 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
112         using namespace clang;
113         std::shared_ptr<TargetOptions> TO;
114         DiagnosticsEngine *Diags;
115         TargetInfo::CreateTargetInfo(*Diags, TO);
116 ], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
117               [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
118 AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
119         using namespace clang;
120         TargetOptions *TO;
121         DiagnosticsEngine *Diags;
122         TargetInfo::CreateTargetInfo(*Diags, TO);
123 ], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
124               [Define if TargetInfo::CreateTargetInfo takes pointer])])
125 AC_EGREP_HEADER([getLangOpts], [clang/Lex/Preprocessor.h], [],
126         [AC_DEFINE([getLangOpts], [getLangOptions],
127         [Define to getLangOptions for older versions of clang])])
128 AC_EGREP_HEADER([findLocationAfterToken], [clang/Lex/Lexer.h],
129         [AC_DEFINE([HAVE_FINDLOCATIONAFTERTOKEN], [],
130         [Define if SourceManager has findLocationAfterToken method])])
131 AC_EGREP_HEADER([translateLineCol], [clang/Basic/SourceManager.h],
132         [AC_DEFINE([HAVE_TRANSLATELINECOL], [],
133         [Define if SourceManager has translateLineCol method])])
134 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
135         using namespace clang;
136         DiagnosticConsumer *client;
137         CompilerInstance *Clang;
138         Clang->createDiagnostics(client);
139 ], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
140         [Define if CompilerInstance::createDiagnostics takes argc and argv])])
141 AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
142         using namespace clang;
143         HeaderSearchOptions HSO;
144         HSO.AddPath("", frontend::Angled, false, false);
145 ], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
146         [Define if HeaderSearchOptions::AddPath takes 4 arguments])])
147 AC_EGREP_HEADER([getLocWithOffset], [clang/Basic/SourceLocation.h], [],
148         [AC_DEFINE([getLocWithOffset], [getFileLocWithOffset],
149         [Define to getFileLocWithOffset for older versions of clang])])
150 AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
151         using namespace clang;
152         CompilerInstance *Clang;
153         Clang->createPreprocessor(TU_Complete);
154 ], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
155 [Define if CompilerInstance::createPreprocessor takes TranslationUnitKind])])
156 AC_EGREP_HEADER([DecayedType], [clang/AST/Type.h],
157         [AC_DEFINE([HAVE_DECAYEDTYPE], [], [Define if DecayedType is defined])])
158 AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
159         [AC_DEFINE([HAVE_SETMAINFILEID], [],
160         [Define if SourceManager has a setMainFileID method])])
161 AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
162         [AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
163                    [Define if llvm/ADT/OwningPtr.h exists])])
164 AC_LANG_POP
165 CPPFLAGS="$SAVE_CPPFLAGS"
167 SAVE_LDFLAGS="$LDFLAGS"
168 LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
169 AC_SUBST(LIB_CLANG_EDIT)
170 AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
171 LDFLAGS="$SAVE_LDFLAGS"
173 AX_SUBMODULE(isl,build|bundled|system,bundled)
174 AM_CONDITIONAL(BUNDLED_ISL, test $with_isl = bundled)
176 AC_SUBST(ISL_CFLAGS)
177 AC_SUBST(ISL_LIBS)
178 AC_SUBST(ISL_SRCDIR)
179 case "$with_isl" in
180 bundled)
181         ISL_CFLAGS="-I\$(top_srcdir)/isl/include -I\$(top_builddir)/isl/include"
182         ISL_CFLAGS="$ISL_CFLAGS"
183         ISL_SRCDIR="$srcdir/isl"
184         ;;
185 build)
186         ISL_SRCDIR="$isl_srcdir"
187         ISL_BUILDDIR=`echo @abs_builddir@ | $with_isl_builddir/config.status --file=-`
188         ISL_CFLAGS="-I$isl_srcdir/include -I$ISL_BUILDDIR/include"
189         ISL_CFLAGS="$ISL_CFLAGS"
190         ISL_LIBS="$with_isl_builddir/libisl.la"
191         ;;
192 system)
193         PKG_CHECK_MODULES([ISL], [isl])
194         PACKAGE_CFLAGS_ISL="$ISL_CFLAGS"
195 esac
197 AX_SUBMODULE(libyaml,system|no,system)
198 AC_SUBST(LIBYAML_CPPFLAGS)
199 AC_SUBST(LIBYAML_LDFLAGS)
200 if test "x$with_libyaml_prefix" != "x"; then
201         LIBYAML_CPPFLAGS="-I$with_libyaml_prefix/include"
203 if test "x$with_libyaml_exec_prefix" != "x"; then
204         LIBYAML_LDFLAGS="-L$with_libyaml_exec_prefix/lib"
207 if test "$with_libyaml" = "system"; then
208         SAVE_CPPFLAGS=$CPPFLAGS
209         CPPFLAGS="$CPPFLAGS $LIBYAML_CPPFLAGS"
210         AC_CHECK_HEADER([yaml.h],[],[with_libyaml="no"])
211         CPPFLAGS="$SAVE_CPPFLAGS"
214 AC_SUBST(extra_bin_programs)
215 AC_SUBST(extra_noinst_programs)
216 AC_SUBST(extra_tests)
218 if test "$with_libyaml" != "no"; then
219         extra_bin_programs="pet"
220         extra_noinst_programs="pet_scop_cmp"
221         extra_tests="pet_test.sh"
223 if test "$with_isl" != "system"; then
224         extra_tests="$extra_tests codegen_test.sh"
227 PACKAGE_CFLAGS="$PACKAGE_CFLAGS_ISL"
228 PACKAGE_LIBS="-lpet -lisl"
229 AX_CREATE_PKGCONFIG_INFO
231 AX_DETECT_GIT_HEAD
232 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
234 AC_CONFIG_HEADERS(config.h)
235 AC_CONFIG_FILES(Makefile)
236 AC_CONFIG_FILES([pet_test.sh], [chmod +x pet_test.sh])
237 AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
238 if test $with_isl = bundled; then
239         AC_CONFIG_SUBDIRS(isl)
241 AC_OUTPUT