1 # This file is part of GCC.
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
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
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/>.
17 # Contributed by Andreas Simbuerger <simbuerg@fim.uni-passau.de>
20 # -------------------------
21 # Provide configure switches for CLooG support.
22 # Initialize clooglibs/clooginc according to the user input.
23 AC_DEFUN([CLOOG_INIT_FLAGS],
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],
33 [--with-cloog-include=PATH],
34 [Specify directory for installed CLooG include files])])
35 AC_ARG_WITH([cloog-lib],
37 [--with-cloog-lib=PATH],
38 [Specify the directory for the installed CLooG library])])
40 AC_ARG_ENABLE(cloog-backend,
42 [--enable-cloog-backend[[=BACKEND]]],
43 [set the CLooG BACKEND used to either isl, ppl or ppl-legacy (default)])],
44 [ if test "x${enableval}" = "xisl"; then
46 elif test "x${enableval}" = "xppl"; then
49 cloog_backend=ppl-legacy
50 fi], cloog_backend=ppl-legacy)
51 AC_ARG_ENABLE(cloog-version-check,
53 [--disable-cloog-version-check],
54 [disable check for CLooG version])],
55 ENABLE_CLOOG_CHECK=$enableval,
56 ENABLE_CLOOG_CHECK=yes)
58 # Initialize clooglibs and clooginc.
67 clooglibs="-L$with_cloog/lib"
68 clooginc="-I$with_cloog/include"
71 if test "x${with_cloog_include}" != x ; then
72 clooginc="-I$with_cloog_include"
74 if test "x${with_cloog_lib}" != x; then
75 clooglibs="-L$with_cloog_lib"
78 dnl Flags needed for CLOOG
84 # CLOOG_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
85 # ----------------------------------------------------
86 # Provide actions for failed CLooG detection.
87 AC_DEFUN([CLOOG_REQUESTED],
89 AC_REQUIRE([CLOOG_INIT_FLAGS])
91 if test "x${with_cloog}" != x \
92 || test "x${with_cloog_include}" != x \
93 || test "x${with_cloog_lib}" != x ; then
101 # _CLOOG_ORG_PROG_ISL ()
103 # Helper for detecting CLooG.org's ISL backend.
104 m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
105 [#include "cloog/cloog.h" ],
106 [cloog_version ()])])
108 # _CLOOG_ORG_PROG_PPL ()
110 # Helper for detecting CLooG.org's PPL backend.
111 m4_define([_CLOOG_ORG_PROG_PPL],[AC_LANG_PROGRAM(
112 [#include "cloog/cloog.h"
113 #include "cloog/ppl/cloog.h"],
114 [cloog_version ()])])
116 # _CLOOG_PPL_LEGACY_PROG ()
117 # -------------------------
118 # Helper for detecting CLooG-Legacy (CLooG-PPL).
119 m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
120 [#include "cloog/cloog.h"],
121 [#ifndef CLOOG_PPL_BACKEND
125 # CLOOG_FIND_FLAGS ()
127 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
128 # Only look for the CLooG backend type specified in --enable-cloog-backend
129 AC_DEFUN([CLOOG_FIND_FLAGS],
131 AC_REQUIRE([CLOOG_INIT_FLAGS])
133 _cloog_saved_CFLAGS=$CFLAGS
134 _cloog_saved_CPPFLAGS=$CPPFLAGS
135 _cloog_saved_LDFLAGS=$LDFLAGS
136 _cloog_saved_LIBS=$LIBS
138 _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
140 dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
141 CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
142 CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
143 LDFLAGS="${LDFLAGS} ${clooglibs}"
145 case $cloog_backend in
147 CFLAGS="${CFLAGS} ${pplinc}"
148 LDFLAGS="${LDFLAGS} ${ppllibs}"
149 AC_CACHE_CHECK([for installed CLooG PPL Legacy], [gcc_cv_cloog_type],
150 [LIBS="-lcloog ${_cloog_saved_LIBS}"
151 AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG], [gcc_cv_cloog_type="PPL Legacy"],
152 [gcc_cv_cloog_type=no])])
155 AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
156 [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
157 AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
158 [gcc_cv_cloog_type=no])])
161 CFLAGS="${CFLAGS} ${pplinc}"
162 LDFLAGS="${LDFLAGS} ${ppllibs}"
163 AC_CACHE_CHECK([for installed CLooG PPL], [gcc_cv_cloog_type],
164 [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
165 AC_LINK_IFELSE([_CLOOG_ORG_PROG_PPL], [gcc_cv_cloog_type="PPL"],
166 [gcc_cv_cloog_type=no])])
172 case $gcc_cv_cloog_type in
174 clooginc="${clooginc}"
175 clooglibs="${clooglibs} -lcloog"
179 clooginc="${clooginc} ${_cloogorginc}"
180 clooglibs="${clooglibs} -lcloog-isl"
184 clooginc="${clooginc} ${_cloogorginc}"
185 clooglibs="${clooglibs} -lcloog-ppl"
195 LIBS=$_cloog_saved_LIBS
196 CFLAGS=$_cloog_saved_CFLAGS
197 CPPFLAGS=$_cloog_saved_CPPFLAGS
198 LDFLAGS=$_cloog_saved_LDFLAGS
202 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
203 # --------------------------------------------
204 # Helper for verifying CLooG's compile time version.
205 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
206 [#include "cloog/cloog.h"],
207 [#if CLOOG_VERSION_MAJOR != $1 \
208 || CLOOG_VERSION_MINOR != $2 \
209 || CLOOG_VERSION_REVISION < $3
213 # _CLOOG_CHECK_RT_PROG ()
214 # -----------------------
215 # Helper for verifying that CLooG's compile time version
216 # matches the run time version.
217 m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
218 [#include "cloog/cloog.h"],
219 [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
220 && (cloog_version_minor () != CLOOG_VERSION_MINOR)
221 && (cloog_version_revision () != CLOOG_VERSION_REVISION))
226 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
227 # ----------------------------------------------------------------
228 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
230 # If we're using the old CLooG-PPL (Legacy), the old version check will
231 # be executed (Ignores the provided version information).
232 AC_DEFUN([CLOOG_CHECK_VERSION],
234 AC_REQUIRE([CLOOG_FIND_FLAGS])
236 if test "${ENABLE_CLOOG_CHECK}" = yes ; then
237 _cloog_saved_CFLAGS=$CFLAGS
238 _cloog_saved_LDFLAGS=$LDFLAGS
240 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
241 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
243 if test "${cloog_org}" = yes ; then
244 AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
245 [gcc_cv_cloog_ct_0_14_0],
246 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
247 [gcc_cv_cloog_ct_0_14_0=yes],
248 [gcc_cv_cloog_ct_0_14_0=no])])
249 elif test "${cloog_org}" = no ; then
250 AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
251 [gcc_cv_cloog_ct_0_15_5],
252 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
253 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
254 [gcc_cv_cloog_ct_0_15_5=yes],
255 [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
256 [gcc_cv_cloog_ct_0_15_5=no])])
259 CFLAGS=$_cloog_saved_CFLAGS
260 LDFLAGS=$_cloog_saved_LDFLAGS
265 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
266 # ----------------------------------
267 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
269 AC_DEFUN([CLOOG_IF_FAILED],
271 CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
273 if test "${gcc_cv_cloog_ct_0_14_0}" = no \
274 || test "${gcc_cv_cloog_rt_0_14_0}" = no \
275 || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
280 if test "${graphite_requested}" = yes \
281 && test "x${clooglibs}" = x \
282 && test "x${clooginc}" = x ; then