diff mbox

Support official CLooG.org versions.

Message ID 1284279887-23006-1-git-send-email-simbuerg@googlemail.com
State New
Headers show

Commit Message

Andreas Simbürger Sept. 12, 2010, 8:24 a.m. UTC
Add support for official CLooG releases.
CLooG's configuration gets detected within 2 stages:

Stage 1: Detect the installed CLooG version.
  This is done by linking test programs against the various
  CLooG libraries. As CLooG's library sonames depend on the
  used backend, this is sufficient to detect the used backend.

  We only detect this backends, in order:
    1) CLooG-PPL (Legacy): The "old" CLooG.
    2) CLooG-ISL: The "new" CLooG.
    3) CLooG-Parma: An alternative backend, to compare it with
    CLooG-ISL.

  CLooG-Poly is not detected, as the PolyLib may conflict
  with GCC's license.

Stage 2: Version checks.
  After detecting the right configuration, we finally check
  if the installed version is usable. There are 2 different
  checks: One for CLooG-PPL (Legacy) and one for CLooG-ISL.

  * CLooG-ISL:
    As the "new" CLooG provides methods to check for its version at
    both compile and run time, we use this feature. First
    we check for the constants to verify the header's compatibility.
    Finally we verify the compatibility of our headers with
    the library that will get linked with GCC.
    As stated in autoconf's documentation, the run time check
    is not usable when cross-compiling, so we skip this check
    then.

  * CLooG-PPL (Legacy):
    This version check provides the same semantics as before.
    As CLooG-PPL (Legacy) provides the same constants as the
    official CLooG, we can use the same test program for the
    compile time check.

Tested with CLooG-ISL and CLooG-PPL (Legacy).
As for now, CLooG-Parma fails to build.

2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>

	* configure.ac: Support official CLooG.org versions.
	* configure: Regenerate.
---
 ChangeLog.graphite |    5 +
 configure          |  352 +++++++++++++++++++++++++++++++++++++++++-----------
 configure.ac       |  165 ++++++++++++++++++++----
 3 files changed, 420 insertions(+), 102 deletions(-)

Comments

Konrad Trifunovic Sept. 12, 2010, 11:23 a.m. UTC | #1
Hi,

just a short comment/question:

> +  # Only fail if the user explicitly selected CLooG.
> +  cloog_allow_fail=no
> +  if test "${with_cloog+set}" = set \
> +    || test "${with_cloog_include+set}" = set \
> +    || test "${with_cloog_lib+set}" = set ; then
> +    cloog_allow_fail=yes
> +  fi

It seems that 'cloog_allow_fail' would be set to YES, if
we enable one of the flags. But if we enable all the
flags (with_cloog, with_cloog_include, with_cloog_lib)
then it would remain NO. Is this intended?

Konrad
Andreas Simbürger Sept. 12, 2010, 12:11 p.m. UTC | #2
On 09/12/2010 01:23 PM, Konrad Trifunovic wrote:
> Hi,
> 
> just a short comment/question:
> 
>> +  # Only fail if the user explicitly selected CLooG.
>> +  cloog_allow_fail=no
>> +  if test "${with_cloog+set}" = set \
>> +    || test "${with_cloog_include+set}" = set \
>> +    || test "${with_cloog_lib+set}" = set ; then
>> +    cloog_allow_fail=yes
>> +  fi
> 
> It seems that 'cloog_allow_fail' would be set to YES, if
> we enable one of the flags. But if we enable all the
> flags (with_cloog, with_cloog_include, with_cloog_lib)
> then it would remain NO. Is this intended?
> 

Hi Konrad,

AFAIK the ||-Operator is not exclusive, so matching all three works
fine.

../configure --prefix=$HOME/install/gcc
--with-ppl=$HOME/install/ppl-0.11 --enable-languages=c,c++,fortran
--with-cloog=$HOME/install/cloog-isl/
--with-cloog-lib=$HOME/install/cloog-isl/lib
--with-cloog-include=$HOME/install/cloog-isl/include/

...
checking for version 0.10 (or later revision) of PPL... yes
checking for installed CLooG type... ISL
checking for verison 0.14.0 of CLooG (compile time)... yes
checking for version 0.14.0 of CLooG (run time)... yes
...

> Konrad

Cheers,
Andreas
Konrad Trifunovic Sept. 12, 2010, 12:36 p.m. UTC | #3
Hi again,

it seems that I have a problem with the following scenario:

I have a cloog-ppl installed in /usr/local/lib (a legacy one).
Now, I have also a new cloog-isl installed in one of my home
directories (/home/konrad/cloog-isl).

I configure it with: ./configure --with-cloog=/home/konrad/cloog-isl/lib

Now, it seems I'm not able to override the order in which
a configuration script is looking for cloog libraries.

It first tries a legacy one (linking with -lcloog).
It finds that there is indeed a legacy cloog in /usr/local/lib
and it is not even trying "-lcloog-isl" with the value
--with-cloog=/home/konrad/cloog-isl/lib.

I think we need some prioritizing mechanism. Let's say, that if you could find
both legacy and isl-cloog then the priority should be given to the isl-cloog.
But, this is not a good solution either. It seems that if we can find multiple
valid cloog installations, an user should be able to manually override the
desired cloog version.

I'm not a configuration scripts expert.
I'm not sure whether this solution would be accepted by GCC community,
but I propose the following:

have a flag called "--with-cloog" that can take several values, for
example "auto", "isl", "ppl", "no" etc.

Then, have other flag called "--with-cloog-prefix" that gives a path
to the place where we should be looking for a cloog.

Konrad



2010/9/12 Konrad Trifunovic <konrad.trifunovic@gmail.com>:
> Hi,
>
> just a short comment/question:
>
>> +  # Only fail if the user explicitly selected CLooG.
>> +  cloog_allow_fail=no
>> +  if test "${with_cloog+set}" = set \
>> +    || test "${with_cloog_include+set}" = set \
>> +    || test "${with_cloog_lib+set}" = set ; then
>> +    cloog_allow_fail=yes
>> +  fi
>
> It seems that 'cloog_allow_fail' would be set to YES, if
> we enable one of the flags. But if we enable all the
> flags (with_cloog, with_cloog_include, with_cloog_lib)
> then it would remain NO. Is this intended?
>
> Konrad
>
Konrad Trifunovic Sept. 12, 2010, 12:46 p.m. UTC | #4
Hi,

you use this variable in the following code:

+  if test "${cloog_allow_fail}" = yes \
+    && test "${clooglibs:-null}" = null && test "${clooginc:-null}" =
null ; then
+    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
+  fi

I understand it as: "if you allow to fail and you cannot find a CLooG
then you would
fail the configuration script". I would rather rename this variable to
"cloog_disallow_fail". So the meaning would be:

"If you are not allowed to fail and you fail to find a CLooG, then I would
terminate the configuration script with an error".

You might think I'm picky, but it would be easier to follow the code for
non-experts ;)

Konrad


2010/9/12 Andreas Simbuerger <simbuerg@googlemail.com>:
> On 09/12/2010 01:23 PM, Konrad Trifunovic wrote:
>> Hi,
>>
>> just a short comment/question:
>>
>>> +  # Only fail if the user explicitly selected CLooG.
>>> +  cloog_allow_fail=no
>>> +  if test "${with_cloog+set}" = set \
>>> +    || test "${with_cloog_include+set}" = set \
>>> +    || test "${with_cloog_lib+set}" = set ; then
>>> +    cloog_allow_fail=yes
>>> +  fi
>>
>> It seems that 'cloog_allow_fail' would be set to YES, if
>> we enable one of the flags. But if we enable all the
>> flags (with_cloog, with_cloog_include, with_cloog_lib)
>> then it would remain NO. Is this intended?
>>
>
> Hi Konrad,
>
> AFAIK the ||-Operator is not exclusive, so matching all three works
> fine.
>
> ../configure --prefix=$HOME/install/gcc
> --with-ppl=$HOME/install/ppl-0.11 --enable-languages=c,c++,fortran
> --with-cloog=$HOME/install/cloog-isl/
> --with-cloog-lib=$HOME/install/cloog-isl/lib
> --with-cloog-include=$HOME/install/cloog-isl/include/
>
> ...
> checking for version 0.10 (or later revision) of PPL... yes
> checking for installed CLooG type... ISL
> checking for verison 0.14.0 of CLooG (compile time)... yes
> checking for version 0.14.0 of CLooG (run time)... yes
> ...
>
>> Konrad
>
> Cheers,
> Andreas
>
>
Konrad Trifunovic Sept. 12, 2010, 11:05 p.m. UTC | #5
Hi,
again, the similar scenario I have described before:
I have both PPL and old CLooG installed in:
/usr/local/lib
and the headers are in
/usr/local/include

I have a new cloog-isl in /home/konrad/cloog.isl.

Now, I have given the parameters:
--with-ppl=/usr/local #since I want to have a PPL that is
installed in one of my standard directories
--with-cloog-include=/home/konrad/cloog.isl/include

Now, since there is an old cloog in /usr/local/include,
and given the following order:


+  # Stage 2: Version check the found CLooG.
+  CFLAGS="${saved_cflags} ${gmpinc} ${pplinc} ${clooginc}"


it would produce a compilation flags as follows:
-I/usr/local/include -I/home/konrad/cloog.isl/include

Thus, it would use a cloog that is in -I/usr/local/include, which
is the old one, and not the one that I want. (The first path
comes from --with-ppl and the second from --with-cloog-include).

Now, this could be simply solved by reordering includes:

+  # Stage 2: Version check the found CLooG.
+  CFLAGS="${saved_cflags} ${gmpinc} ${clooginc}" ${pplinc}

Now, the --with-cloog-include is given a priority in searching
for include files.

I propose this to be changed.

regards,
konrad
Andreas Simbürger Sept. 13, 2010, 8:18 a.m. UTC | #6
On 09/13/2010 01:05 AM, Konrad Trifunovic wrote:
> Hi,
> again, the similar scenario I have described before:
> I have both PPL and old CLooG installed in:
> /usr/local/lib
> and the headers are in
> /usr/local/include
> 
> I have a new cloog-isl in /home/konrad/cloog.isl.
> 
> Now, I have given the parameters:
> --with-ppl=/usr/local #since I want to have a PPL that is
> installed in one of my standard directories
> --with-cloog-include=/home/konrad/cloog.isl/include
> 
> Now, since there is an old cloog in /usr/local/include,
> and given the following order:
> 
> 
> +  # Stage 2: Version check the found CLooG.
> +  CFLAGS="${saved_cflags} ${gmpinc} ${pplinc} ${clooginc}"
> 
> 
> it would produce a compilation flags as follows:
> -I/usr/local/include -I/home/konrad/cloog.isl/include
> 
> Thus, it would use a cloog that is in -I/usr/local/include, which
> is the old one, and not the one that I want. (The first path
> comes from --with-ppl and the second from --with-cloog-include).
> 
> Now, this could be simply solved by reordering includes:
> 
> +  # Stage 2: Version check the found CLooG.
> +  CFLAGS="${saved_cflags} ${gmpinc} ${clooginc}" ${pplinc}
> 
> Now, the --with-cloog-include is given a priority in searching
> for include files.
> 
> I propose this to be changed.
> 
> regards,
> konrad

I totally agree, i will send a new version. :-)

Andreas
Andreas Simbürger Sept. 13, 2010, 10:36 a.m. UTC | #7
On 09/12/2010 02:36 PM, Konrad Trifunovic wrote:
> Hi again,
> 
> it seems that I have a problem with the following scenario:
> 
> I have a cloog-ppl installed in /usr/local/lib (a legacy one).
> Now, I have also a new cloog-isl installed in one of my home
> directories (/home/konrad/cloog-isl).
> 
> I configure it with: ./configure --with-cloog=/home/konrad/cloog-isl/lib
> 
> Now, it seems I'm not able to override the order in which
> a configuration script is looking for cloog libraries.
> 
> It first tries a legacy one (linking with -lcloog).
> It finds that there is indeed a legacy cloog in /usr/local/lib
> and it is not even trying "-lcloog-isl" with the value
> --with-cloog=/home/konrad/cloog-isl/lib.
> 
> I think we need some prioritizing mechanism. Let's say, that if you could find
> both legacy and isl-cloog then the priority should be given to the isl-cloog.
> But, this is not a good solution either. It seems that if we can find multiple
> valid cloog installations, an user should be able to manually override the
> desired cloog version.
> 

I could add such an option if you need it, but this patch is just
intended for Graphite testing. After successfully testing CLooG-ISL
the CLooG-PPL (legacy) support and CLooG-PPL support will be removed.

With the recent include path changes you proposed it should be possible
to control the used backend with the --with-cloog* options.

> I'm not a configuration scripts expert.
> I'm not sure whether this solution would be accepted by GCC community,
> but I propose the following:
> 
> have a flag called "--with-cloog" that can take several values, for
> example "auto", "isl", "ppl", "no" etc.
> 
> Then, have other flag called "--with-cloog-prefix" that gives a path
> to the place where we should be looking for a cloog.
> 
> Konrad
> 
> 

Thanks for pointing this out :-)

Cheers,
Andreas
diff mbox

Patch

diff --git a/ChangeLog.graphite b/ChangeLog.graphite
index c5edc3a..58e30e3 100644
--- a/ChangeLog.graphite
+++ b/ChangeLog.graphite
@@ -1,3 +1,8 @@ 
+2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* configure.ac: Support official CLooG.org versions.
+	* configure: Regenerate.
+
 2010-08-24  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* Merge from mainline (160224:163495).
diff --git a/configure b/configure
index fc759d7..f629449 100755
--- a/configure
+++ b/configure
@@ -1816,6 +1816,48 @@  fi
 
 } # ac_fn_c_try_link
 
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  return $ac_retval
+
+} # ac_fn_c_try_run
+
 # ac_fn_c_try_cpp LINENO
 # ----------------------
 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1940,48 +1982,6 @@  fi
 
 } # ac_fn_c_check_header_mongrel
 
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
-
-} # ac_fn_c_try_run
-
 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
 # -------------------------------------------------------
 # Tests whether HEADER exists and can be compiled using the include files in
@@ -5885,8 +5885,6 @@  fi
 
 
 # Check for CLOOG
-clooglibs=" -lcloog "
-clooginc=" -DCLOOG_PPL_BACKEND "
 
 
 # Check whether --with-cloog was given.
@@ -5919,19 +5917,20 @@  case $with_cloog in
   "" | yes)
     ;;
   *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
+    clooglibs="-L$with_cloog/lib"
+    clooginc="-I$with_cloog/include"
     ;;
 esac
-if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
+if test "${with_cloog_include+set}" = set ; then
+  clooginc="-I$with_cloog_include"
 fi
-if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
+if test "${with_cloog_lib+set}" = set; then
+  clooglibs="-L$with_cloog_lib"
 fi
-if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
-  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
-  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
+if test "${with_cloog+set}" = set && test "${with_cloog_include+set}" = set \
+  && test "${with_cloog_lib+set}" = x && test -d ${srcdir}/cloog; then
+  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
+  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
   enable_cloog_version_check=no
 fi
 
@@ -5943,22 +5942,212 @@  else
 fi
 
 
-if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
-  saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
-$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
+if test "x$with_cloog" != "xno"; then
+
+
+
+
+
+
+  saved_cflags=$CFLAGS
+  saved_libs=$LIBS
+  saved_ldflags=$LDFLAGS
+
+  # Only fail if the user explicitly selected CLooG.
+  cloog_allow_fail=no
+  if test "${with_cloog+set}" = set \
+    || test "${with_cloog_include+set}" = set \
+    || test "${with_cloog_lib+set}" = set ; then
+    cloog_allow_fail=yes
+  fi
+
+  # Stage 1: Detect the available CLooG+backend combination.
+  clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+
+  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG type" >&5
+$as_echo_n "checking for installed CLooG type... " >&6; }
+if test "${gcc_cv_cloog_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  LIBS="-lcloog ${saved_libs}"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <cloog/cloog.h>
+int
+main ()
+{
+cloog_version ()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_cloog_type="PPL Legacy"
+else
+  LIBS="-lcloog-isl -lisl ${saved_libs}"
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <cloog/cloog.h>
+int
+main ()
+{
+cloog_version ()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_cloog_type=ISL
+else
+  LIBS="-lcloog-ppl ${saved_libs}"
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <cloog/cloog.h>
+int
+main ()
+{
+cloog_version ()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_cloog_type=PPL
+else
+  gcc_cv_cloog_type=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_type" >&5
+$as_echo "$gcc_cv_cloog_type" >&6; }
+
+  case $gcc_cv_cloog_type in
+    "PPL Legacy")
+      clooginc="${clooginc} ${clooglegacyinc}"
+      clooglibs="${clooglibs} -lcloog"
+      cloog_org=no
+      ;;
+    "ISL")
+      clooginc="${clooginc} ${cloogorginc}"
+      clooglibs="${clooglibs} -lcloog-isl"
+      cloog_org=yes
+      ;;
+    "PPL")
+      clooginc="${clooginc} ${cloogorginc}"
+      clooglibs="${clooglibs} -lcloog-ppl"
+      cloog_org=yes
+      ;;
+    *)
+      clooglibs=
+      clooginc=
+      ;;
+  esac
+
+  # Stage 2: Version check the found CLooG.
+  CFLAGS="${saved_cflags} ${gmpinc} ${pplinc} ${clooginc}"
+  LDFLAGS="${saved_ldflags} ${clooglibs}"
+
+  if test "${ENABLE_CLOOG_CHECK}" = yes \
+    && test "${cloog_org}" = yes ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for verison 0.14.0 of CLooG (compile time)" >&5
+$as_echo_n "checking for verison 0.14.0 of CLooG (compile time)... " >&6; }
+if test "${gcc_cv_cloog_ct_0_14_0+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "cloog/cloog.h"
 int
 main ()
 {
+#if CLOOG_VERSION_MAJOR != 0 \
+      || CLOOG_VERSION_MINOR != 14 \
+      || CLOOG_VERSION_REVISION < 0
+      choke me
+     #endif
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gcc_cv_cloog_ct_0_14_0=yes
+else
+  gcc_cv_cloog_ct_0_14_0=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_ct_0_14_0" >&5
+$as_echo "$gcc_cv_cloog_ct_0_14_0" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.14.0 of CLooG (run time)" >&5
+$as_echo_n "checking for version 0.14.0 of CLooG (run time)... " >&6; }
+if test "${gcc_cv_cloog_rt_0_14_0+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  gcc_cv_cloog_rt_0_14_0=guessing yes
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+     #include "cloog/cloog.h"
+int
+main ()
+{
+if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
+      && (cloog_version_minor () != CLOOG_VERSION_MINOR)
+      && (cloog_version_revision () != CLOOG_VERSION_REVISION))
+      {
+        exit (1);
+      }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gcc_cv_cloog_rt_0_14_0=yes
+else
+  gcc_cv_cloog_rt_0_14_0=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
 
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
-  choke me
-  #endif
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_rt_0_14_0" >&5
+$as_echo "$gcc_cv_cloog_rt_0_14_0" >&6; }
+  fi
 
+  # Version check for CLooG-PPL (Legacy).
+  if test "${ENABLE_CLOOG_CHECK}" = yes \
+    && test "${cloog_org}" = no ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
+$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
+if test "${gcc_cv_cloog_ct_0_15_5+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "cloog/cloog.h"
+int
+main ()
+{
+#if CLOOG_VERSION_MAJOR != 0 \
+      || CLOOG_VERSION_MINOR != 15 \
+      || CLOOG_VERSION_REVISION < 5
+      choke me
+     #endif
   ;
   return 0;
 }
@@ -5970,32 +6159,47 @@  if ac_fn_c_try_compile "$LINENO"; then :
 int
 main ()
 {
-
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
-  choke me
-  #endif
-
+#if CLOOG_VERSION_MAJOR != 0 \
+      || CLOOG_VERSION_MINOR != 15 \
+      || CLOOG_VERSION_REVISION < 9
+      choke me
+     #endif
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+  gcc_cv_cloog_ct_0_15_5=yes
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy but acceptable" >&5
-$as_echo "buggy but acceptable" >&6; }
+  gcc_cv_cloog_ct_0_15_5=buggy but acceptable
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }; clooglibs= ; clooginc=
+  gcc_cv_cloog_ct_0_15_5=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$saved_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_ct_0_15_5" >&5
+$as_echo "$gcc_cv_cloog_ct_0_15_5" >&6; }
+  fi
+
+  if test "${gcc_cv_cloog_ct_0_14_0}" = no \
+    || test "${gcc_cv_cloog_rt_0_14_0}" = no \
+    || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
+    clooglibs=
+    clooginc=
+  fi
+
+  if test "${cloog_allow_fail}" = yes \
+    && test "${clooglibs:-null}" = null && test "${clooginc:-null}" = null ; then
+    as_fn_error "Unable to find a usable CLooG. See config.log for details." "$LINENO" 5
+  fi
+
+  CFLAGS=$saved_cflags
+  LIBS=$saved_libs
+  LDFLAGS=$saved_ldflags
 fi
 
-# Flags needed for CLOOG
 
 
 
diff --git a/configure.ac b/configure.ac
index 3d969aa..721115a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1580,8 +1580,6 @@  AC_SUBST(pplinc)
 
 
 # Check for CLOOG
-clooglibs=" -lcloog "
-clooginc=" -DCLOOG_PPL_BACKEND "
 
 AC_ARG_WITH(cloog, [  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
                           Equivalent to --with-cloog-include=PATH/include
@@ -1593,7 +1591,7 @@  if test "x$with_ppl" = "xno"; then
   with_cloog=no
 fi
 
-case $with_cloog in 
+case $with_cloog in
   no)
     clooglibs=
     clooginc=
@@ -1601,19 +1599,20 @@  case $with_cloog in
   "" | yes)
     ;;
   *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
+    clooglibs="-L$with_cloog/lib"
+    clooginc="-I$with_cloog/include"
     ;;
 esac
-if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
+if test "${with_cloog_include+set}" = set ; then
+  clooginc="-I$with_cloog_include"
 fi
-if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
+if test "${with_cloog_lib+set}" = set; then
+  clooglibs="-L$with_cloog_lib"
 fi
-if test "x$with_cloog$with_cloog_include$with_cloog_lib" = x && test -d ${srcdir}/cloog; then
-  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' -lcloog '
-  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -DCLOOG_PPL_BACKEND '
+if test "${with_cloog+set}" = set && test "${with_cloog_include+set}" = set \
+  && test "${with_cloog_lib+set}" = x && test -d ${srcdir}/cloog; then
+  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
+  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
   enable_cloog_version_check=no
 fi
 
@@ -1622,24 +1621,134 @@  AC_ARG_ENABLE(cloog-version-check,
 ENABLE_CLOOG_CHECK=$enableval,
 ENABLE_CLOOG_CHECK=yes)
 
-if test "x$with_cloog" != "xno" -a "${ENABLE_CLOOG_CHECK}" = "yes"; then
-  saved_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS $clooginc $gmpinc $pplinc"
-  AC_MSG_CHECKING([for version 0.15.5 (or later revision) of CLooG])
-  AC_TRY_COMPILE([#include "cloog/cloog.h"],[
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 5
-  choke me
-  #endif
-  ], [AC_TRY_COMPILE([#include "cloog/cloog.h"],[
-  #if CLOOG_VERSION_MAJOR != 0 || CLOOG_VERSION_MINOR != 15 || CLOOG_VERSION_REVISION < 9
-  choke me
-  #endif
-  ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
-  [AC_MSG_RESULT([no]); clooglibs= ; clooginc= ])
-  CFLAGS="$saved_CFLAGS"
+if test "x$with_cloog" != "xno"; then
+  dnl CLooG configure test programs.
+  m4_define([CLOOG_BACKEND_PROG],[AC_LANG_PROGRAM(
+    [#include <cloog/cloog.h>],
+    [cloog_version ()])])
+
+  m4_define([CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
+    [#include "cloog/cloog.h"],
+    [#if CLOOG_VERSION_MAJOR != $1 \
+      || CLOOG_VERSION_MINOR != $2 \
+      || CLOOG_VERSION_REVISION < $3
+      choke me
+     #endif])])
+
+  m4_define([CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
+    [#include <stdlib.h>
+     #include "cloog/cloog.h"],
+    [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
+      && (cloog_version_minor () != CLOOG_VERSION_MINOR)
+      && (cloog_version_revision () != CLOOG_VERSION_REVISION))
+      {
+        exit (1);
+      }])])
+
+  saved_cflags=$CFLAGS
+  saved_libs=$LIBS
+  saved_ldflags=$LDFLAGS
+
+  # Only fail if the user explicitly selected CLooG.
+  cloog_allow_fail=no
+  if test "${with_cloog+set}" = set \
+    || test "${with_cloog_include+set}" = set \
+    || test "${with_cloog_lib+set}" = set ; then
+    cloog_allow_fail=yes
+  fi
+
+  # Stage 1: Detect the available CLooG+backend combination.
+  clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+
+  CFLAGS="${CFLAGS} ${gmpinc} ${pplinc} ${clooginc} ${cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  AC_CACHE_CHECK([for installed CLooG type],
+                 [gcc_cv_cloog_type],
+    [LIBS="-lcloog ${saved_libs}"
+     AC_LINK_IFELSE([CLOOG_BACKEND_PROG],
+      [gcc_cv_cloog_type="PPL Legacy"],
+      [LIBS="-lcloog-isl -lisl ${saved_libs}"
+       AC_LINK_IFELSE([CLOOG_BACKEND_PROG],
+        [gcc_cv_cloog_type=ISL],
+        [LIBS="-lcloog-ppl ${saved_libs}"
+         AC_LINK_IFELSE([CLOOG_BACKEND_PROG],
+          [gcc_cv_cloog_type=PPL],
+          [gcc_cv_cloog_type=no])])])])
+
+  case $gcc_cv_cloog_type in
+    "PPL Legacy")
+      clooginc="${clooginc} ${clooglegacyinc}"
+      clooglibs="${clooglibs} -lcloog"
+      cloog_org=no
+      ;;
+    "ISL")
+      clooginc="${clooginc} ${cloogorginc}"
+      clooglibs="${clooglibs} -lcloog-isl"
+      cloog_org=yes
+      ;;
+    "PPL")
+      clooginc="${clooginc} ${cloogorginc}"
+      clooglibs="${clooglibs} -lcloog-ppl"
+      cloog_org=yes
+      ;;
+    *)
+      clooglibs=
+      clooginc=
+      ;;
+  esac
+
+  # Stage 2: Version check the found CLooG.
+  CFLAGS="${saved_cflags} ${gmpinc} ${pplinc} ${clooginc}"
+  LDFLAGS="${saved_ldflags} ${clooglibs}"
+
+  if test "${ENABLE_CLOOG_CHECK}" = yes \
+    && test "${cloog_org}" = yes ; then
+    AC_CACHE_CHECK([for verison 0.14.0 of CLooG (compile time)],
+      [gcc_cv_cloog_ct_0_14_0],
+      [AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,14,0)],
+        [gcc_cv_cloog_ct_0_14_0=yes],
+        [gcc_cv_cloog_ct_0_14_0=no])])
+
+    AC_CACHE_CHECK([for version 0.14.0 of CLooG (run time)],
+      [gcc_cv_cloog_rt_0_14_0],
+      [AC_RUN_IFELSE([CLOOG_CHECK_RT_PROG],
+        [gcc_cv_cloog_rt_0_14_0=yes],
+        [gcc_cv_cloog_rt_0_14_0=no],
+        [gcc_cv_cloog_rt_0_14_0=guessing yes])])
+  fi
+
+  # Version check for CLooG-PPL (Legacy).
+  if test "${ENABLE_CLOOG_CHECK}" = yes \
+    && test "${cloog_org}" = no ; then
+    AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
+      [gcc_cv_cloog_ct_0_15_5],
+      [AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,5)],
+        [AC_COMPILE_IFELSE([CLOOG_CHECK_CT_PROG(0,15,9)],
+          [gcc_cv_cloog_ct_0_15_5=yes],
+          [gcc_cv_cloog_ct_0_15_5=buggy but acceptable])],
+        [gcc_cv_cloog_ct_0_15_5=no])])
+  fi
+
+  if test "${gcc_cv_cloog_ct_0_14_0}" = no \
+    || test "${gcc_cv_cloog_rt_0_14_0}" = no \
+    || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
+    clooglibs=
+    clooginc=
+  fi
+
+  if test "${cloog_allow_fail}" = yes \
+    && test "${clooglibs:-null}" = null && test "${clooginc:-null}" = null ; then
+    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])
+  fi
+
+  CFLAGS=$saved_cflags
+  LIBS=$saved_libs
+  LDFLAGS=$saved_ldflags
 fi
 
-# Flags needed for CLOOG
+dnl Flags needed for CLOOG
 AC_SUBST(clooglibs)
 AC_SUBST(clooginc)