diff --git a/ChangeLog.graphite b/ChangeLog.graphite
index 46f1290..d067200 100644
--- a/ChangeLog.graphite
+++ b/ChangeLog.graphite
@@ -1,3 +1,9 @@
+2010-08-11  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
+
+	* configure.ac: Support official CLooG.org versions.
+	* configure: Regenerate.
+	* config/cloog.m4: New.
+
 2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* Merge from mainline (164578:165734).
diff --git a/config/cloog.m4 b/config/cloog.m4
new file mode 100644
index 0000000..d042bfa
--- /dev/null
+++ b/config/cloog.m4
@@ -0,0 +1,252 @@
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3, or (at your option) any later
+# version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+# Contributed by Andreas Simbuerger <simbuerg@fim.uni-passau.de>
+
+# CLOOG_INIT_FLAGS ()
+# -------------------------
+# Provide configure switches for CLooG support.
+# Initialize clooglibs/clooginc according to the user input.
+AC_DEFUN([CLOOG_INIT_FLAGS],
+[
+  AC_ARG_WITH(cloog, 
+    [AS_HELP_STRING(
+      [--with-cloog=PATH],
+      [Specify prefix directory for the installed CLooG-PPL package.
+       Equivalent to --with-cloog-include=PATH/include
+       plus --with-cloog-lib=PATH/lib])])
+  AC_ARG_WITH(cloog_include,
+    [AS_HELP_STRING(
+      [--with-cloog-include=PATH],
+      [Specify directory for installed CLooG include files])])
+  AC_ARG_WITH(cloog_lib,
+    [AS_HELP_STRING(
+      [--with-cloog-lib=PATH],
+      [Specify the directory for the installed CLooG library])])
+  
+  AC_ARG_ENABLE(cloog-version-check,
+    [AS_HELP_STRING(
+      [--disable-cloog-version-check],
+      [disable check for CLooG version])],
+    ENABLE_CLOOG_CHECK=$enableval,
+    ENABLE_CLOOG_CHECK=yes)
+  
+  # Initialize clooglibs and clooginc.
+  case $with_cloog in
+    no)
+      clooglibs=
+      clooginc=
+      ;;
+    "" | yes)
+      ;;
+    *)
+      clooglibs="-L$with_cloog/lib"
+      clooginc="-I$with_cloog/include"
+      ;;
+  esac
+  if test "x${with_cloog_include}" != x ; then
+    clooginc="-I$with_cloog_include"
+  fi
+  if test "x${with_cloog_lib}" != x; then
+    clooglibs="-L$with_cloog_lib"
+  fi
+  if test "x${with_cloog}" != x && test "x${with_cloog_include}" != x \
+    && test "x${with_cloog_lib}" != 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
+]
+)
+
+# CLOOG_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
+# ----------------------------------------------------
+# Provide actions for failed CLooG detection.
+AC_DEFUN([CLOOG_REQUESTED],
+[
+  AC_REQUIRE([CLOOG_INIT_FLAGS])
+
+  if test "x${with_cloog}" != x \
+    || test "x${with_cloog_include}" != x \
+    || test "x${with_cloog_lib}" != x ; then
+    $1
+  else
+    $2
+  fi
+]
+)
+
+# _CLOOG_ORG_PROG ()
+# ------------------
+# Helper for detecting CLooG.org's backend.
+m4_define([_CLOOG_ORG_PROG],[AC_LANG_PROGRAM(
+  [#include <cloog/cloog.h>],
+  [cloog_version ()])])
+
+# _CLOOG_PPL_LEGACY_PROG ()
+# -------------------------
+# Helper for detecting CLooG-Legacy (CLooG-PPL).
+m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
+  [#include <cloog/cloog.h>],
+  [ppl_version_major ()])])
+
+# CLOOG_FIND_FLAGS ()
+# ------------------
+# Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
+# Preference: CLooG-PPL (Legacy) > CLooG-ISL > CLooG-PPL
+AC_DEFUN([CLOOG_FIND_FLAGS],
+[
+  AC_REQUIRE([CLOOG_INIT_FLAGS])
+
+  _saved_cflags=$CFLAGS
+  _saved_cppflags=$CPPFLAGS
+  _saved_ldflags=$LDFLAGS
+  _saved_libs=$LIBS
+
+  _clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+ 
+  dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
+  CFLAGS="${CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
+  CPPFLAGS="${CPPFLAGS} ${_clooglegacyinc} ${_cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  AC_CACHE_CHECK([for installed CLooG],
+                 [gcc_cv_cloog_type],
+    [LIBS="-lcloog ${saved_libs}"
+     AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG],
+      [gcc_cv_cloog_type="PPL Legacy"],
+      [LIBS="-lcloog-isl -lisl ${saved_libs}"
+       AC_LINK_IFELSE([_CLOOG_ORG_PROG],
+        [gcc_cv_cloog_type=ISL],
+        [LIBS="-lcloog-ppl ${saved_libs}"
+         AC_LINK_IFELSE([_CLOOG_ORG_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=
+      cloog_org=
+      ;;
+  esac
+
+  LIBS=$_saved_libs
+  CFLAGS=$_saved_cflags
+  CPPFLAGS=$_saved_cppflags
+  LDFLAGS=$_saved_ldflags
+]
+)
+
+# _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
+# --------------------------------------------
+# Helper for verifying CLooG's compile time 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])])
+
+# _CLOOG_CHECK_RT_PROG ()
+# -----------------------
+# Helper for verifying that CLooG's compile time version
+# matches the run time version.
+m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
+  [#include "cloog/cloog.h"],
+  [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
+    && (cloog_version_minor () != CLOOG_VERSION_MINOR)
+    && (cloog_version_revision () != CLOOG_VERSION_REVISION))
+    {
+      return 1;
+    }])])
+
+# CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
+# ----------------------------------------------------------------
+# Test the found CLooG to be exact of version MAJOR.MINOR and at least
+# REVISION.
+# If we're using the old CLooG-PPL (Legacy), the old version check will
+# be executed (Ignores the provided version information).
+AC_DEFUN([CLOOG_CHECK_VERSION],
+[
+  AC_REQUIRE([CLOOG_FIND_FLAGS])
+
+  _saved_CFLAGS=$CFLAGS
+  _saved_LDFLAGS=$LDFLAGS
+
+  CFLAGS="${saved_cflags} ${clooginc} ${pplinc} ${gmpinc}"
+  LDFLAGS="${saved_ldflags} ${clooglibs}"
+
+  if test "${cloog_org}" = yes ; then
+    AC_CACHE_CHECK([for verison $1.$2.$3 of CLooG],
+      [gcc_cv_cloog_ct_0_14_0],
+      [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
+        [gcc_cv_cloog_ct_0_14_0=yes],
+        [gcc_cv_cloog_ct_0_14_0=no])])
+  elif 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
+
+  CFLAGS=$_saved_CFLAGS
+  LDFLAGS=$_saved_LDFLAGS
+]
+)
+
+# CLOOG_IF_FAILED (ACTION-IF-FAILED)
+# ----------------------------------
+# Executes ACTION-IF-FAILED, if GRAPHITE was requested and
+# the checks failed.
+AC_DEFUN([CLOOG_IF_FAILED],
+[
+  CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
+  
+  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 "${graphite_requested}" = yes \
+    && test "x${clooglibs}" = x \
+    && test "x${clooginc}" = x ; then
+    $1
+  fi
+]
+)
diff --git a/configure b/configure
index b1fbfaa..60ae15e 100755
--- a/configure
+++ b/configure
@@ -833,6 +833,9 @@ LIBS
 CPPFLAGS
 CXX
 CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
 CCC
 CPP
 build_configargs
@@ -1491,7 +1494,8 @@ Optional Features:
   --enable-libssp         build libssp directory
   --enable-build-with-cxx build with C++ compiler instead of C compiler
   --disable-ppl-version-check    disable check for PPL version
-  --disable-cloog-version-check  disable check for CLooG version
+  --disable-cloog-version-check
+                          disable check for CLooG version
   --enable-lto            enable link time optimization support
   --enable-stage1-languages[=all]   choose additional languages to build during
                           stage1.  Mostly useful for compiler development.
@@ -1542,11 +1546,14 @@ Optional Packages:
                           plus --with-ppl-lib=PATH/lib
   --with-ppl-include=PATH Specify directory for installed PPL include files
   --with-ppl-lib=PATH     Specify the directory for the installed PPL library
-  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL package
-                          Equivalent to --with-cloog-include=PATH/include
-                          plus --with-cloog-lib=PATH/lib
-  --with-cloog-include=PATH Specify directory for installed CLooG include files
-  --with-cloog-lib=PATH   Specify the directory for the installed CLooG library
+  --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL
+                          package. Equivalent to
+                          --with-cloog-include=PATH/include plus
+                          --with-cloog-lib=PATH/lib
+  --with-cloog-include=PATH
+                          Specify directory for installed CLooG include files
+  --with-cloog-lib=PATH   Specify the directory for the installed CLooG
+                          library
   --with-libelf=PATH       Specify prefix directory for the installed libelf package
                           Equivalent to --with-libelf-include=PATH/include
                           plus --with-libelf-lib=PATH/lib
@@ -5894,8 +5901,7 @@ fi
 
 
 # Check for CLOOG
-clooglibs=" -lcloog "
-clooginc=" -DCLOOG_PPL_BACKEND "
+
 
 
 # Check whether --with-cloog was given.
@@ -5916,58 +5922,212 @@ if test "${with_cloog_lib+set}" = set; then :
 fi
 
 
+  # Check whether --enable-cloog-version-check was given.
+if test "${enable_cloog_version_check+set}" = set; then :
+  enableval=$enable_cloog_version_check; ENABLE_CLOOG_CHECK=$enableval
+else
+  ENABLE_CLOOG_CHECK=yes
+fi
+
+
+  # Initialize clooglibs and clooginc.
+  case $with_cloog in
+    no)
+      clooglibs=
+      clooginc=
+      ;;
+    "" | yes)
+      ;;
+    *)
+      clooglibs="-L$with_cloog/lib"
+      clooginc="-I$with_cloog/include"
+      ;;
+  esac
+  if test "x${with_cloog_include}" != x ; then
+    clooginc="-I$with_cloog_include"
+  fi
+  if test "x${with_cloog_lib}" != x; then
+    clooglibs="-L$with_cloog_lib"
+  fi
+  if test "x${with_cloog}" != x && test "x${with_cloog_include}" != x \
+    && test "x${with_cloog_lib}" != 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
+
+
+
 if test "x$with_ppl" = "xno"; then
   with_cloog=no
 fi
 
-case $with_cloog in
-  no)
-    clooglibs=
-    clooginc=
-    ;;
-  "" | yes)
-    ;;
-  *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
-    ;;
-esac
-if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
+if test "x$with_cloog" != "xno"; then
+                          if test "${ENABLE_CLOOG_CHECK}" ; then
+
+
+
+  _saved_cflags=$CFLAGS
+  _saved_cppflags=$CPPFLAGS
+  _saved_ldflags=$LDFLAGS
+  _saved_libs=$LIBS
+
+  _clooglegacyinc="-DCLOOG_PPL_BACKEND"
+  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+
+    CFLAGS="${CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
+  CPPFLAGS="${CPPFLAGS} ${_clooglegacyinc} ${_cloogorginc}"
+  LDFLAGS="${LDFLAGS} ${clooglibs}"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG" >&5
+$as_echo_n "checking for installed CLooG... " >&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 ()
+{
+ppl_version_major ()
+  ;
+  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
-if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 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 '
-  enable_cloog_version_check=no
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 fi
-
-# Check whether --enable-cloog-version-check was given.
-if test "${enable_cloog_version_check+set}" = set; then :
-  enableval=$enable_cloog_version_check; ENABLE_CLOOG_CHECK=$enableval
-else
-  ENABLE_CLOOG_CHECK=yes
+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=
+      cloog_org=
+      ;;
+  esac
 
-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
+  LIBS=$_saved_libs
+  CFLAGS=$_saved_cflags
+  CPPFLAGS=$_saved_cppflags
+  LDFLAGS=$_saved_ldflags
+
+
+
+
+
+  _saved_CFLAGS=$CFLAGS
+  _saved_LDFLAGS=$LDFLAGS
+
+  CFLAGS="${saved_cflags} ${clooginc} ${pplinc} ${gmpinc}"
+  LDFLAGS="${saved_ldflags} ${clooglibs}"
+
+  if test "${cloog_org}" = yes ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for verison 0.14.0 of CLooG" >&5
+$as_echo_n "checking for verison 0.14.0 of CLooG... " >&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; }
+  elif 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
-
+#if CLOOG_VERSION_MAJOR != 0 \
+    || CLOOG_VERSION_MINOR != 15 \
+    || CLOOG_VERSION_REVISION < 5
+    choke me
+   #endif
   ;
   return 0;
 }
@@ -5979,29 +6139,65 @@ 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
+
+  CFLAGS=$_saved_CFLAGS
+  LDFLAGS=$_saved_LDFLAGS
+
+
+  fi
+
+
+
+
+
+  if test "x${with_cloog}" != x \
+    || test "x${with_cloog_include}" != x \
+    || test "x${with_cloog_lib}" != x ; then
+    graphite_requested=yes
+  else
+    graphite_requested=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 "${graphite_requested}" = yes \
+    && test "x${clooglibs}" = x \
+    && test "x${clooginc}" = x ; then
+
+    as_fn_error "Unable to find a usable CLooG. See config.log for details." "$LINENO" 5
+  fi
+
+
 fi
 
 # Flags needed for CLOOG
diff --git a/configure.ac b/configure.ac
index bf5fe3a..5d7d0d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@ m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
 m4_include([ltversion.m4])
 m4_include([lt~obsolete.m4])
+m4_include([config/cloog.m4])
 
 AC_INIT(move-if-change)
 AC_PREREQ(2.64)
@@ -1580,63 +1581,36 @@ 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
-                          plus --with-cloog-lib=PATH/lib])
-AC_ARG_WITH(cloog_include, [  --with-cloog-include=PATH Specify directory for installed CLooG include files])
-AC_ARG_WITH(cloog_lib, [  --with-cloog-lib=PATH   Specify the directory for the installed CLooG library])
+dnl Provide configure switches and initialize clooginc & clooglibs
+dnl with user input.
+CLOOG_INIT_FLAGS()
 
 if test "x$with_ppl" = "xno"; then
   with_cloog=no
 fi
 
-case $with_cloog in 
-  no)
-    clooglibs=
-    clooginc=
-    ;;
-  "" | yes)
-    ;;
-  *)
-    clooglibs="-L$with_cloog/lib -lcloog"
-    clooginc="-I$with_cloog/include -DCLOOG_PPL_BACKEND "
-    ;;
-esac
-if test "x$with_cloog_include" != x; then
-  clooginc="-I$with_cloog_include -DCLOOG_PPL_BACKEND "
-fi
-if test "x$with_cloog_lib" != x; then
-  clooglibs="-L$with_cloog_lib -lcloog"
-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 '
-  enable_cloog_version_check=no
-fi
-
-AC_ARG_ENABLE(cloog-version-check,
-[  --disable-cloog-version-check  disable check for CLooG version],
-ENABLE_CLOOG_CHECK=$enableval,
-ENABLE_CLOOG_CHECK=yes)
+if test "x$with_cloog" != "xno"; then
+  dnl Version check for CLooG-Org
+  dnl As long as there is no new release of CLooG,
+  dnl we will check for 0.14.0.
+  dnl 
+  dnl The first git revision that will work with
+  dnl GCC is: bd91b845a65805c290d43fc1bef8139864a163fb
+  dnl This is enforced implictly, as this is the commit that
+  dnl introduced the versioning information used within our
+  dnl checks.
+  dnl
+  dnl If we're using CLooG-Legacy, the provided version information
+  dnl will be ignored.
+  if test "${ENABLE_CLOOG_CHECK}" ; then
+    CLOOG_CHECK_VERSION(0,14,0)
+  fi
 
-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"
+  dnl Only execute fail-action, if CLooG has been
+  dnl requested.
+  CLOOG_IF_FAILED([
+    AC_MSG_ERROR([Unable to find a usable CLooG. See config.log for details.])])
 fi
 
 # Flags needed for CLOOG
