OSDN Git Service

Move entry to correct ChangeLog file.
[pf3gnuchains/gcc-fork.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-backend,
41     [  --enable-cloog-backend[=backend]
42                                 isl: The cloog.org isl backend
43                                 ppl-legacy: The legacy ppl backend - default
44                                 ppl: The cloog.org ppl backend],
45     [ if   test "x${enableval}" = "xisl"; then
46         cloog_backend=isl
47       elif test "x${enableval}" = "xppl"; then
48         cloog_backend=ppl
49       else
50         cloog_backend=ppl-legacy
51       fi], cloog_backend=ppl-legacy)
52   AC_ARG_ENABLE(cloog-version-check,
53     [AS_HELP_STRING(
54       [--disable-cloog-version-check],
55       [disable check for CLooG version])],
56     ENABLE_CLOOG_CHECK=$enableval,
57     ENABLE_CLOOG_CHECK=yes)
58   
59   # Initialize clooglibs and clooginc.
60   case $with_cloog in
61     no)
62       clooglibs=
63       clooginc=
64       ;;
65     "" | yes)
66       ;;
67     *)
68       clooglibs="-L$with_cloog/lib"
69       clooginc="-I$with_cloog/include"
70       ;;
71   esac
72   if test "x${with_cloog_include}" != x ; then
73     clooginc="-I$with_cloog_include"
74   fi
75   if test "x${with_cloog_lib}" != x; then
76     clooglibs="-L$with_cloog_lib"
77   fi
78
79   dnl Flags needed for CLOOG
80   AC_SUBST(clooglibs)
81   AC_SUBST(clooginc)
82 ]
83 )
84
85 # CLOOG_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
86 # ----------------------------------------------------
87 # Provide actions for failed CLooG detection.
88 AC_DEFUN([CLOOG_REQUESTED],
89 [
90   AC_REQUIRE([CLOOG_INIT_FLAGS])
91
92   if test "x${with_cloog}" != x \
93     || test "x${with_cloog_include}" != x \
94     || test "x${with_cloog_lib}" != x ; then
95     $1
96   else
97     $2
98   fi
99 ]
100 )
101
102 # _CLOOG_ORG_PROG_ISL ()
103 # ------------------
104 # Helper for detecting CLooG.org's ISL backend.
105 m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
106   [#include "cloog/cloog.h" ],
107   [cloog_version ()])])
108
109 # _CLOOG_ORG_PROG_PPL ()
110 # ------------------
111 # Helper for detecting CLooG.org's PPL backend.
112 m4_define([_CLOOG_ORG_PROG_PPL],[AC_LANG_PROGRAM(
113   [#include "cloog/cloog.h"
114    #include "cloog/ppl/cloog.h"],
115   [cloog_version ()])])
116
117 # _CLOOG_PPL_LEGACY_PROG ()
118 # -------------------------
119 # Helper for detecting CLooG-Legacy (CLooG-PPL).
120 m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
121   [#include "cloog/cloog.h"],
122   [#ifndef CLOOG_PPL_BACKEND
123     choke me
124    #endif ])])
125
126 # CLOOG_FIND_FLAGS ()
127 # ------------------
128 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
129 # Only look for the CLooG backend type specified in --enable-cloog-backend
130 AC_DEFUN([CLOOG_FIND_FLAGS],
131 [
132   AC_REQUIRE([CLOOG_INIT_FLAGS])
133
134   _cloog_saved_CFLAGS=$CFLAGS
135   _cloog_saved_CPPFLAGS=$CPPFLAGS
136   _cloog_saved_LDFLAGS=$LDFLAGS
137   _cloog_saved_LIBS=$LIBS
138
139   _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
140  
141   dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
142   CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
143   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
144   LDFLAGS="${LDFLAGS} ${clooglibs}"
145
146   case $cloog_backend in
147     "ppl-legacy")
148     CFLAGS="${CFLAGS} ${pplinc}"
149     LDFLAGS="${LDFLAGS} ${ppllibs}"
150     AC_CACHE_CHECK([for installed CLooG PPL Legacy], [gcc_cv_cloog_type],
151       [LIBS="-lcloog ${_cloog_saved_LIBS}"
152       AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG], [gcc_cv_cloog_type="PPL Legacy"],
153                      [gcc_cv_cloog_type=no])])
154     ;;
155     "isl")
156     AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
157       [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
158       AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
159                      [gcc_cv_cloog_type=no])])
160     ;;
161     "ppl")
162     CFLAGS="${CFLAGS} ${pplinc}"
163     LDFLAGS="${LDFLAGS} ${ppllibs}"
164     AC_CACHE_CHECK([for installed CLooG PPL], [gcc_cv_cloog_type],
165       [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
166       AC_LINK_IFELSE([_CLOOG_ORG_PROG_PPL], [gcc_cv_cloog_type="PPL"],
167                      [gcc_cv_cloog_type=no])])
168     ;;
169     *)
170       gcc_cv_cloog_type=""
171   esac
172
173   case $gcc_cv_cloog_type in
174     "PPL Legacy")
175       clooginc="${clooginc}"
176       clooglibs="${clooglibs} -lcloog"
177       cloog_org=no
178       ;;
179     "ISL")
180       clooginc="${clooginc} ${_cloogorginc}"
181       clooglibs="${clooglibs} -lcloog-isl"
182       cloog_org=yes
183       ;;
184     "PPL")
185       clooginc="${clooginc} ${_cloogorginc}"
186       clooglibs="${clooglibs} -lcloog-ppl"
187       cloog_org=yes
188       ;;
189     *)
190       clooglibs=
191       clooginc=
192       cloog_org=
193       ;;
194   esac
195
196   LIBS=$_cloog_saved_LIBS
197   CFLAGS=$_cloog_saved_CFLAGS
198   CPPFLAGS=$_cloog_saved_CPPFLAGS
199   LDFLAGS=$_cloog_saved_LDFLAGS
200 ]
201 )
202
203 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
204 # --------------------------------------------
205 # Helper for verifying CLooG's compile time version.
206 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
207   [#include "cloog/cloog.h"],
208   [#if CLOOG_VERSION_MAJOR != $1 \
209     || CLOOG_VERSION_MINOR != $2 \
210     || CLOOG_VERSION_REVISION < $3
211     choke me
212    #endif])])
213
214 # _CLOOG_CHECK_RT_PROG ()
215 # -----------------------
216 # Helper for verifying that CLooG's compile time version
217 # matches the run time version.
218 m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
219   [#include "cloog/cloog.h"],
220   [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
221     && (cloog_version_minor () != CLOOG_VERSION_MINOR)
222     && (cloog_version_revision () != CLOOG_VERSION_REVISION))
223     {
224       return 1;
225     }])])
226
227 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
228 # ----------------------------------------------------------------
229 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
230 # REVISION.
231 # If we're using the old CLooG-PPL (Legacy), the old version check will
232 # be executed (Ignores the provided version information).
233 AC_DEFUN([CLOOG_CHECK_VERSION],
234 [
235   AC_REQUIRE([CLOOG_FIND_FLAGS])
236
237   if test "${ENABLE_CLOOG_CHECK}" = yes ; then
238     _cloog_saved_CFLAGS=$CFLAGS
239     _cloog_saved_LDFLAGS=$LDFLAGS
240
241     CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
242     LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
243
244     if test "${cloog_org}" = yes ; then
245       AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
246         [gcc_cv_cloog_ct_0_14_0],
247         [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
248           [gcc_cv_cloog_ct_0_14_0=yes],
249           [gcc_cv_cloog_ct_0_14_0=no])])
250     elif test "${cloog_org}" = no ; then
251       AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
252         [gcc_cv_cloog_ct_0_15_5],
253         [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
254           [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
255            [gcc_cv_cloog_ct_0_15_5=yes],
256             [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
257           [gcc_cv_cloog_ct_0_15_5=no])])
258     fi
259
260     CFLAGS=$_cloog_saved_CFLAGS
261     LDFLAGS=$_cloog_saved_LDFLAGS
262   fi
263 ]
264 )
265
266 # CLOOG_IF_FAILED (ACTION-IF-FAILED)
267 # ----------------------------------
268 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
269 # the checks failed.
270 AC_DEFUN([CLOOG_IF_FAILED],
271 [
272   CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
273   
274   if test "${gcc_cv_cloog_ct_0_14_0}" = no \
275     || test "${gcc_cv_cloog_rt_0_14_0}" = no \
276     || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
277     clooglibs=
278     clooginc=
279   fi
280
281   if test "${graphite_requested}" = yes \
282     && test "x${clooglibs}" = x \
283     && test "x${clooginc}" = x ; then
284     $1
285   fi
286 ]
287 )