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 [#ifndef CLOOG_PPL_BACKEND
106 # CLOOG_FIND_FLAGS ()
108 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
109 # Preference: CLooG-PPL (Legacy) > CLooG-ISL > CLooG-PPL
110 AC_DEFUN([CLOOG_FIND_FLAGS],
112 AC_REQUIRE([CLOOG_INIT_FLAGS])
114 _cloog_saved_CFLAGS=$CFLAGS
115 _cloog_saved_CPPFLAGS=$CPPFLAGS
116 _cloog_saved_LDFLAGS=$LDFLAGS
117 _cloog_saved_LIBS=$LIBS
119 _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
121 dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
122 CFLAGS="${CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
123 CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
124 LDFLAGS="${LDFLAGS} ${clooglibs} ${ppllibs}"
126 AC_CACHE_CHECK([for installed CLooG],
128 [LIBS="-lcloog ${_cloog_saved_LIBS}"
129 AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG],
130 [gcc_cv_cloog_type="PPL Legacy"],
131 [LIBS="-lcloog-isl -lisl ${_cloog_saved_LIBS}"
132 AC_LINK_IFELSE([_CLOOG_ORG_PROG],
133 [gcc_cv_cloog_type=ISL],
134 [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
135 AC_LINK_IFELSE([_CLOOG_ORG_PROG],
136 [gcc_cv_cloog_type=PPL],
137 [gcc_cv_cloog_type=no])])])])
139 case $gcc_cv_cloog_type in
141 clooginc="${clooginc}"
142 clooglibs="${clooglibs} -lcloog"
146 clooginc="${clooginc} ${_cloogorginc}"
147 clooglibs="${clooglibs} -lcloog-isl"
151 clooginc="${clooginc} ${_cloogorginc}"
152 clooglibs="${clooglibs} -lcloog-ppl"
162 LIBS=$_cloog_saved_LIBS
163 CFLAGS=$_cloog_saved_CFLAGS
164 CPPFLAGS=$_cloog_saved_CPPFLAGS
165 LDFLAGS=$_cloog_saved_LDFLAGS
169 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
170 # --------------------------------------------
171 # Helper for verifying CLooG's compile time version.
172 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
173 [#include "cloog/cloog.h"],
174 [#if CLOOG_VERSION_MAJOR != $1 \
175 || CLOOG_VERSION_MINOR != $2 \
176 || CLOOG_VERSION_REVISION < $3
180 # _CLOOG_CHECK_RT_PROG ()
181 # -----------------------
182 # Helper for verifying that CLooG's compile time version
183 # matches the run time version.
184 m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
185 [#include "cloog/cloog.h"],
186 [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
187 && (cloog_version_minor () != CLOOG_VERSION_MINOR)
188 && (cloog_version_revision () != CLOOG_VERSION_REVISION))
193 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
194 # ----------------------------------------------------------------
195 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
197 # If we're using the old CLooG-PPL (Legacy), the old version check will
198 # be executed (Ignores the provided version information).
199 AC_DEFUN([CLOOG_CHECK_VERSION],
201 AC_REQUIRE([CLOOG_FIND_FLAGS])
203 if test "${ENABLE_CLOOG_CHECK}" = yes ; then
204 _cloog_saved_CFLAGS=$CFLAGS
205 _cloog_saved_LDFLAGS=$LDFLAGS
207 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
208 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
210 if test "${cloog_org}" = yes ; then
211 AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
212 [gcc_cv_cloog_ct_0_14_0],
213 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
214 [gcc_cv_cloog_ct_0_14_0=yes],
215 [gcc_cv_cloog_ct_0_14_0=no])])
216 elif test "${cloog_org}" = no ; then
217 AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
218 [gcc_cv_cloog_ct_0_15_5],
219 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
220 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
221 [gcc_cv_cloog_ct_0_15_5=yes],
222 [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
223 [gcc_cv_cloog_ct_0_15_5=no])])
226 CFLAGS=$_cloog_saved_CFLAGS
227 LDFLAGS=$_cloog_saved_LDFLAGS
232 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
233 # ----------------------------------
234 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
236 AC_DEFUN([CLOOG_IF_FAILED],
238 CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
240 if test "${gcc_cv_cloog_ct_0_14_0}" = no \
241 || test "${gcc_cv_cloog_rt_0_14_0}" = no \
242 || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
247 if test "${graphite_requested}" = yes \
248 && test "x${clooglibs}" = x \
249 && test "x${clooginc}" = x ; then