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}" = xno; then
93 elif test "x${with_cloog}" != x \
94 || test "x${with_cloog_include}" != x \
95 || test "x${with_cloog_lib}" != x ; then
103 # _CLOOG_ORG_PROG_ISL ()
105 # Helper for detecting CLooG.org's ISL backend.
106 m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
107 [#include "cloog/cloog.h" ],
108 [cloog_version ()])])
110 # _CLOOG_ORG_PROG_PPL ()
112 # Helper for detecting CLooG.org's PPL backend.
113 m4_define([_CLOOG_ORG_PROG_PPL],[AC_LANG_PROGRAM(
114 [#include "cloog/cloog.h"
115 #include "cloog/ppl/cloog.h"],
116 [cloog_version ()])])
118 # _CLOOG_PPL_LEGACY_PROG ()
119 # -------------------------
120 # Helper for detecting CLooG-Legacy (CLooG-PPL).
121 m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
122 [#include "cloog/cloog.h"],
123 [#ifndef CLOOG_PPL_BACKEND
127 # CLOOG_FIND_FLAGS ()
129 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
130 # Only look for the CLooG backend type specified in --enable-cloog-backend
131 AC_DEFUN([CLOOG_FIND_FLAGS],
133 AC_REQUIRE([CLOOG_INIT_FLAGS])
135 _cloog_saved_CFLAGS=$CFLAGS
136 _cloog_saved_CPPFLAGS=$CPPFLAGS
137 _cloog_saved_LDFLAGS=$LDFLAGS
138 _cloog_saved_LIBS=$LIBS
140 _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
142 dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
143 CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
144 CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
145 LDFLAGS="${LDFLAGS} ${clooglibs}"
147 case $cloog_backend in
149 CFLAGS="${CFLAGS} ${pplinc}"
150 LDFLAGS="${LDFLAGS} ${ppllibs}"
151 AC_CACHE_CHECK([for installed CLooG PPL Legacy], [gcc_cv_cloog_type],
152 [LIBS="-lcloog ${_cloog_saved_LIBS}"
153 AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG], [gcc_cv_cloog_type="PPL Legacy"],
154 [gcc_cv_cloog_type=no])])
157 AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
158 [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
159 AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
160 [gcc_cv_cloog_type=no])])
163 CFLAGS="${CFLAGS} ${pplinc}"
164 LDFLAGS="${LDFLAGS} ${ppllibs}"
165 AC_CACHE_CHECK([for installed CLooG PPL], [gcc_cv_cloog_type],
166 [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
167 AC_LINK_IFELSE([_CLOOG_ORG_PROG_PPL], [gcc_cv_cloog_type="PPL"],
168 [gcc_cv_cloog_type=no])])
174 case $gcc_cv_cloog_type in
176 clooginc="${clooginc}"
177 clooglibs="${clooglibs} -lcloog"
181 clooginc="${clooginc} ${_cloogorginc}"
182 clooglibs="${clooglibs} -lcloog-isl"
186 clooginc="${clooginc} ${_cloogorginc}"
187 clooglibs="${clooglibs} -lcloog-ppl"
197 LIBS=$_cloog_saved_LIBS
198 CFLAGS=$_cloog_saved_CFLAGS
199 CPPFLAGS=$_cloog_saved_CPPFLAGS
200 LDFLAGS=$_cloog_saved_LDFLAGS
204 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
205 # --------------------------------------------
206 # Helper for verifying CLooG's compile time version.
207 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
208 [#include "cloog/cloog.h"],
209 [#if CLOOG_VERSION_MAJOR != $1 \
210 || CLOOG_VERSION_MINOR != $2 \
211 || CLOOG_VERSION_REVISION < $3
215 # _CLOOG_CHECK_RT_PROG ()
216 # -----------------------
217 # Helper for verifying that CLooG's compile time version
218 # matches the run time version.
219 m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
220 [#include "cloog/cloog.h"],
221 [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
222 && (cloog_version_minor () != CLOOG_VERSION_MINOR)
223 && (cloog_version_revision () != CLOOG_VERSION_REVISION))
228 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
229 # ----------------------------------------------------------------
230 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
232 # If we're using the old CLooG-PPL (Legacy), the old version check will
233 # be executed (Ignores the provided version information).
234 AC_DEFUN([CLOOG_CHECK_VERSION],
236 AC_REQUIRE([CLOOG_FIND_FLAGS])
238 if test "${ENABLE_CLOOG_CHECK}" = yes ; then
239 _cloog_saved_CFLAGS=$CFLAGS
240 _cloog_saved_LDFLAGS=$LDFLAGS
242 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
243 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
245 if test "${cloog_org}" = yes ; then
246 AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
247 [gcc_cv_cloog_ct_0_14_0],
248 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
249 [gcc_cv_cloog_ct_0_14_0=yes],
250 [gcc_cv_cloog_ct_0_14_0=no])])
251 elif test "${cloog_org}" = no ; then
252 AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
253 [gcc_cv_cloog_ct_0_15_5],
254 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
255 [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
256 [gcc_cv_cloog_ct_0_15_5=yes],
257 [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
258 [gcc_cv_cloog_ct_0_15_5=no])])
261 CFLAGS=$_cloog_saved_CFLAGS
262 LDFLAGS=$_cloog_saved_LDFLAGS
267 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
268 # ----------------------------------
269 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
271 AC_DEFUN([CLOOG_IF_FAILED],
273 CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
275 if test "${gcc_cv_cloog_ct_0_14_0}" = no \
276 || test "${gcc_cv_cloog_rt_0_14_0}" = no \
277 || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
282 if test "${graphite_requested}" = yes \
283 && test "x${clooglibs}" = x \
284 && test "x${clooginc}" = x ; then