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-version-check,
42 [--disable-cloog-version-check],
43 [disable check for CLooG version])],
44 ENABLE_CLOOG_CHECK=$enableval,
45 ENABLE_CLOOG_CHECK=yes)
47 # Initialize clooglibs and clooginc.
56 clooglibs="-L$with_cloog/lib"
57 clooginc="-I$with_cloog/include"
60 if test "x${with_cloog_include}" != x ; then
61 clooginc="-I$with_cloog_include"
63 if test "x${with_cloog_lib}" != x; then
64 clooglibs="-L$with_cloog_lib"
67 dnl Flags needed for CLOOG
73 # CLOOG_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
74 # ----------------------------------------------------
75 # Provide actions for failed CLooG detection.
76 AC_DEFUN([CLOOG_REQUESTED],
78 AC_REQUIRE([CLOOG_INIT_FLAGS])
80 if test "x${with_cloog}" != x \
81 || test "x${with_cloog_include}" != x \
82 || test "x${with_cloog_lib}" != x ; then
92 # Helper for detecting CLooG.org's backend.
93 m4_define([_CLOOG_ORG_PROG],[AC_LANG_PROGRAM(
94 [#include <cloog/cloog.h>],
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 ()])])
104 # CLOOG_FIND_FLAGS ()
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],
110 AC_REQUIRE([CLOOG_INIT_FLAGS])
112 _cloog_saved_CFLAGS=$CFLAGS
113 _cloog_saved_CPPFLAGS=$CPPFLAGS
114 _cloog_saved_LDFLAGS=$LDFLAGS
115 _cloog_saved_LIBS=$LIBS
117 _clooglegacyinc="-DCLOOG_PPL_BACKEND"
118 _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
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}"
125 AC_CACHE_CHECK([for installed CLooG],
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])])])])
138 case $gcc_cv_cloog_type in
140 clooginc="${clooginc} ${_clooglegacyinc}"
141 clooglibs="${clooglibs} -lcloog"
145 clooginc="${clooginc} ${_cloogorginc}"
146 clooglibs="${clooglibs} -lcloog-isl"
150 clooginc="${clooginc} ${_cloogorginc}"
151 clooglibs="${clooglibs} -lcloog-ppl"
161 LIBS=$_cloog_saved_LIBS
162 CFLAGS=$_cloog_saved_CFLAGS
163 CPPFLAGS=$_cloog_saved_CPPFLAGS
164 LDFLAGS=$_cloog_saved_LDFLAGS
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
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))
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
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],
200 AC_REQUIRE([CLOOG_FIND_FLAGS])
202 if test "${ENABLE_CLOOG_CHECK}" = yes ; then
203 _cloog_saved_CFLAGS=$CFLAGS
204 _cloog_saved_LDFLAGS=$LDFLAGS
206 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
207 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs}"
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])])
225 CFLAGS=$_cloog_saved_CFLAGS
226 LDFLAGS=$_cloog_saved_LDFLAGS
231 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
232 # ----------------------------------
233 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
235 AC_DEFUN([CLOOG_IF_FAILED],
237 CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
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
246 if test "${graphite_requested}" = yes \
247 && test "x${clooglibs}" = x \
248 && test "x${clooginc}" = x ; then