Support official CLooG.org versions.
[gcc.git] / config / cloog.m4
1 # This file is part of GCC.
2 #
3 # GCC is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU General Public License as published by the Free
5 # Software Foundation; either version 3, or (at your option) any later
6 # version.
7 #
8 # GCC is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 # for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
16 #
17 # Contributed by Andreas Simbuerger <simbuerg@fim.uni-passau.de>
18
19 # CLOOG_INIT_FLAGS ()
20 # -------------------------
21 # Provide configure switches for CLooG support.
22 # Initialize clooglibs/clooginc according to the user input.
23 AC_DEFUN([CLOOG_INIT_FLAGS],
24 [
25 AC_ARG_WITH(cloog,
26 [AS_HELP_STRING(
27 [--with-cloog=PATH],
28 [Specify prefix directory for the installed CLooG-PPL package.
29 Equivalent to --with-cloog-include=PATH/include
30 plus --with-cloog-lib=PATH/lib])])
31 AC_ARG_WITH(cloog_include,
32 [AS_HELP_STRING(
33 [--with-cloog-include=PATH],
34 [Specify directory for installed CLooG include files])])
35 AC_ARG_WITH(cloog_lib,
36 [AS_HELP_STRING(
37 [--with-cloog-lib=PATH],
38 [Specify the directory for the installed CLooG library])])
39
40 AC_ARG_ENABLE(cloog-version-check,
41 [AS_HELP_STRING(
42 [--disable-cloog-version-check],
43 [disable check for CLooG version])],
44 ENABLE_CLOOG_CHECK=$enableval,
45 ENABLE_CLOOG_CHECK=yes)
46
47 # Initialize clooglibs and clooginc.
48 case $with_cloog in
49 no)
50 clooglibs=
51 clooginc=
52 ;;
53 "" | yes)
54 ;;
55 *)
56 clooglibs="-L$with_cloog/lib"
57 clooginc="-I$with_cloog/include"
58 ;;
59 esac
60 if test "x${with_cloog_include}" != x ; then
61 clooginc="-I$with_cloog_include"
62 fi
63 if test "x${with_cloog_lib}" != x; then
64 clooglibs="-L$with_cloog_lib"
65 fi
66
67 dnl Flags needed for CLOOG
68 AC_SUBST(clooglibs)
69 AC_SUBST(clooginc)
70 ]
71 )
72
73 # CLOOG_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
74 # ----------------------------------------------------
75 # Provide actions for failed CLooG detection.
76 AC_DEFUN([CLOOG_REQUESTED],
77 [
78 AC_REQUIRE([CLOOG_INIT_FLAGS])
79
80 if test "x${with_cloog}" != x \
81 || test "x${with_cloog_include}" != x \
82 || test "x${with_cloog_lib}" != x ; then
83 $1
84 else
85 $2
86 fi
87 ]
88 )
89
90 # _CLOOG_ORG_PROG ()
91 # ------------------
92 # Helper for detecting CLooG.org's backend.
93 m4_define([_CLOOG_ORG_PROG],[AC_LANG_PROGRAM(
94 [#include <cloog/cloog.h>],
95 [cloog_version ()])])
96
97 # _CLOOG_PPL_LEGACY_PROG ()
98 # -------------------------
99 # Helper for detecting CLooG-Legacy (CLooG-PPL).
100 m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
101 [#include <cloog/cloog.h>],
102 [ppl_version_major ()])])
103
104 # CLOOG_FIND_FLAGS ()
105 # ------------------
106 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
107 # Preference: CLooG-PPL (Legacy) > CLooG-ISL > CLooG-PPL
108 AC_DEFUN([CLOOG_FIND_FLAGS],
109 [
110 AC_REQUIRE([CLOOG_INIT_FLAGS])
111
112 _cloog_saved_CFLAGS=$CFLAGS
113 _cloog_saved_CPPFLAGS=$CPPFLAGS
114 _cloog_saved_LDFLAGS=$LDFLAGS
115 _cloog_saved_LIBS=$LIBS
116
117 _clooglegacyinc="-DCLOOG_PPL_BACKEND"
118 _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
119
120 dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
121 CFLAGS="${CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
122 CPPFLAGS="${CPPFLAGS} ${_clooglegacyinc} ${_cloogorginc}"
123 LDFLAGS="${LDFLAGS} ${clooglibs}"
124
125 AC_CACHE_CHECK([for installed CLooG],
126 [gcc_cv_cloog_type],
127 [LIBS="-lcloog ${_cloog_saved_LIBS}"
128 AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG],
129 [gcc_cv_cloog_type="PPL Legacy"],
130 [LIBS="-lcloog-isl -lisl ${_cloog_saved_LIBS}"
131 AC_LINK_IFELSE([_CLOOG_ORG_PROG],
132 [gcc_cv_cloog_type=ISL],
133 [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
134 AC_LINK_IFELSE([_CLOOG_ORG_PROG],
135 [gcc_cv_cloog_type=PPL],
136 [gcc_cv_cloog_type=no])])])])
137
138 case $gcc_cv_cloog_type in
139 "PPL Legacy")
140 clooginc="${clooginc} ${_clooglegacyinc}"
141 clooglibs="${clooglibs} -lcloog"
142 cloog_org=no
143 ;;
144 "ISL")
145 clooginc="${clooginc} ${_cloogorginc}"
146 clooglibs="${clooglibs} -lcloog-isl"
147 cloog_org=yes
148 ;;
149 "PPL")
150 clooginc="${clooginc} ${_cloogorginc}"
151 clooglibs="${clooglibs} -lcloog-ppl"
152 cloog_org=yes
153 ;;
154 *)
155 clooglibs=
156 clooginc=
157 cloog_org=
158 ;;
159 esac
160
161 LIBS=$_cloog_saved_LIBS
162 CFLAGS=$_cloog_saved_CFLAGS
163 CPPFLAGS=$_cloog_saved_CPPFLAGS
164 LDFLAGS=$_cloog_saved_LDFLAGS
165 ]
166 )
167
168 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
169 # --------------------------------------------
170 # Helper for verifying CLooG's compile time version.
171 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
172 [#include "cloog/cloog.h"],
173 [#if CLOOG_VERSION_MAJOR != $1 \
174 || CLOOG_VERSION_MINOR != $2 \
175 || CLOOG_VERSION_REVISION < $3
176 choke me
177 #endif])])
178
179 # _CLOOG_CHECK_RT_PROG ()
180 # -----------------------
181 # Helper for verifying that CLooG's compile time version
182 # matches the run time version.
183 m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
184 [#include "cloog/cloog.h"],
185 [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
186 && (cloog_version_minor () != CLOOG_VERSION_MINOR)
187 && (cloog_version_revision () != CLOOG_VERSION_REVISION))
188 {
189 return 1;
190 }])])
191
192 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
193 # ----------------------------------------------------------------
194 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
195 # REVISION.
196 # If we're using the old CLooG-PPL (Legacy), the old version check will
197 # be executed (Ignores the provided version information).
198 AC_DEFUN([CLOOG_CHECK_VERSION],
199 [
200 AC_REQUIRE([CLOOG_FIND_FLAGS])
201
202 if test "${ENABLE_CLOOG_CHECK}" = yes ; then
203 _cloog_saved_CFLAGS=$CFLAGS
204 _cloog_saved_LDFLAGS=$LDFLAGS
205
206 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
207 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs}"
208
209 if test "${cloog_org}" = yes ; then
210 AC_CACHE_CHECK([for verison $1.$2.$3 of CLooG],
211 [gcc_cv_cloog_ct_0_14_0],
212 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
213 [gcc_cv_cloog_ct_0_14_0=yes],
214 [gcc_cv_cloog_ct_0_14_0=no])])
215 elif test "${cloog_org}" = no ; then
216 AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
217 [gcc_cv_cloog_ct_0_15_5],
218 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
219 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
220 [gcc_cv_cloog_ct_0_15_5=yes],
221 [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
222 [gcc_cv_cloog_ct_0_15_5=no])])
223 fi
224
225 CFLAGS=$_cloog_saved_CFLAGS
226 LDFLAGS=$_cloog_saved_LDFLAGS
227 fi
228 ]
229 )
230
231 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
232 # ----------------------------------
233 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
234 # the checks failed.
235 AC_DEFUN([CLOOG_IF_FAILED],
236 [
237 CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
238
239 if test "${gcc_cv_cloog_ct_0_14_0}" = no \
240 || test "${gcc_cv_cloog_rt_0_14_0}" = no \
241 || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
242 clooglibs=
243 clooginc=
244 fi
245
246 if test "${graphite_requested}" = yes \
247 && test "x${clooglibs}" = x \
248 && test "x${clooginc}" = x ; then
249 $1
250 fi
251 ]
252 )