diff mbox

[android/toolchain/build] Add --enable-graphite option to build script

Message ID AANLkTimmZ+ZC7VUXKMzF54cQ4AtxGd=eW90BA8ULL7Bx@mail.gmail.com
State New
Headers show

Commit Message

Jim Huang March 28, 2011, 10:34 p.m. UTC
GCC 4.5 and up supports graphite optimization, and cloog and ppl
are required. This change attempts to support some combinations
of ppl and cloog/cloog-ppl libraries. Since cloog and ppl are
written in C++, it implies we might suffer from C++ ABI breakage
problems when host environment changes, that is a well-known issue
in GNU/Linux distributions. Thus, we have to drop runtime libstdc++
dependency by statically linking libstdc++.

Code Review:
    https://review.source.android.com//#change,22033

PS: The attachment contains the patch against HEAD in Linaro's
android/toolchain/build.git, but please make yours comments via gerrit
since this change is generic in upstream.

Comments

Jim Huang April 6, 2011, 6:29 a.m. UTC | #1
On 29 March 2011 06:34, Jim Huang <jim.huang@linaro.org> wrote:
> GCC 4.5 and up supports graphite optimization, and cloog and ppl
> are required. This change attempts to support some combinations
> of ppl and cloog/cloog-ppl libraries. Since cloog and ppl are
> written in C++, it implies we might suffer from C++ ABI breakage
> problems when host environment changes, that is a well-known issue
> in GNU/Linux distributions. Thus, we have to drop runtime libstdc++
> dependency by statically linking libstdc++.

Code Review:
     https://review.source.android.com//#change,22157

Merged in linaro tree.
Jim Huang April 7, 2011, 6:51 p.m. UTC | #2
On 6 April 2011 14:29, Jim Huang <jim.huang@linaro.org> wrote:
> On 29 March 2011 06:34, Jim Huang <jim.huang@linaro.org> wrote:
>> GCC 4.5 and up supports graphite optimization, and cloog and ppl
>> are required. This change attempts to support some combinations
>> of ppl and cloog/cloog-ppl libraries. Since cloog and ppl are
>> written in C++, it implies we might suffer from C++ ABI breakage
>> problems when host environment changes, that is a well-known issue
>> in GNU/Linux distributions. Thus, we have to drop runtime libstdc++
>> dependency by statically linking libstdc++.
>
> Code Review:
>     https://review.source.android.com//#change,22157

Merged in AOSP:
    http://android.git.kernel.org/?p=toolchain/build.git;a=commitdiff;h=50adde9d855b73b5b9e5532ceed6272807b34701

> Merged in linaro tree.
diff mbox

Patch

diff --git a/Makefile.in b/Makefile.in
index 2f8aa2d..2179f18 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -51,6 +51,7 @@  TOPLEVEL_CONFIGURE_ARGUMENTS:=@TOPLEVEL_CONFIGURE_ARGUMENTS@
 baseargs = @baseargs@
 GCC_MIN_VERSION_4_3_0:=@GCC_MIN_VERSION_4_3_0@
 GCC_MIN_VERSION_4_5_0:=@GCC_MIN_VERSION_4_5_0@
+ENABLE_GRAPHITE:=@ENABLE_GRAPHITE@
 PACKAGE_TO_SRCDIR:=@package_to_srcdir@
 BUILD_ANDROID_GCC:=@BUILD_ANDROID_GCC@
 GDB_TARGET:=@GDB_TARGET@
@@ -67,10 +68,14 @@  NEWLIB_VERSION=newlib-@NEWLIB_VERSION@
 GMP_VERSION=gmp-@GMP_VERSION@
 MPFR_VERSION=mpfr-@MPFR_VERSION@
 MPC_VERSION=mpc-@MPC_VERSION@
+PPL_VERSION=ppl-@PPL_VERSION@
+CLOOG_VERSION=cloog-@CLOOG_VERSION@
 GDB_VERSION=gdb-@GDB_VERSION@
 HAVE_MPC=@have_mpc@
 HAVE_MPFR=@have_mpfr@
 HAVE_GMP=@have_gmp@
+HAVE_PPL=@have_ppl@
+HAVE_CLOOG=@have_cloog@
 STAMP=touch
 
 TARGET_BINUTILS_BUILDDIR=$(abs_builddir)/$(BINUTILS_VERSION)
@@ -89,6 +94,14 @@  ifeq ($(HAVE_GMP),no)
   GMP_DIR=$(TEMP_INSTALLDIR)
 endif
 
+ifeq ($(HAVE_PPL), no)
+  PPL_DIR=$(TEMP_INSTALLDIR)
+endif
+
+ifeq ($(HAVE_CLOOG), no)
+  CLOOG_DIR=$(TEMP_INSTALLDIR)
+endif
+
 # Figure out where to find the ld binary.
 FIND_TARGET_LD=\
 	`[ -d $(TARGET_BINUTILS_BUILDDIR)/gold ] && echo "gold" || echo "ld"`
@@ -183,6 +196,9 @@  endif
 all: build
 
 # top level
+ifeq ($(ENABLE_GRAPHITE),yes)
+build: install-host-cloog
+endif
 build: build-target-binutils build-host-libbfd build-target-gcc \
 	build-target-gdb
 
@@ -251,6 +267,14 @@  config-target-binutils: stmp-config-target-binutils
 BINUTILS_CONFIG_ARGS=--prefix=$(prefix) \
 	--target=${cur_target} --host=${cur_host} --build=${cur_build} \
 	$(baseargs) --disable-shared --disable-werror
+ifeq ($(ENABLE_GRAPHITE),yes)
+BINUTILS_CONFIG_ARGS+= --with-cloog=${CLOOG_DIR} --with-gmp=${GMP_DIR} \
+	--disable-ppl-version-check --disable-cloog-version-check
+# drop runtime libstdc++ dependency to avoid C++ ABI breakage
+BINUTILS_CONFIG_ARGS+= \
+	'--with-host-libstdcxx=-static-libgcc \
+	 -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
+endif
 stmp-config-target-binutils: config.status $(canadian_stmp)
 	([ -d ${BINUTILS_VERSION} ] || \
 	  mkdir ${BINUTILS_VERSION}) && \
@@ -342,6 +366,16 @@  stmp-config-target-gcc: stmp-install-host-mpc
 GCC_CONFIG_ARGS += --with-mpc=$(MPC_DIR)
 endif
 
+# For gcc 4.5+ with graphite optimization, cloog and ppl are required.
+ifeq ($(ENABLE_GRAPHITE),yes)
+GCC_CONFIG_ARGS += --with-cloog=${CLOOG_DIR} --with-ppl=${PPL_DIR} \
+	--disable-ppl-version-check --disable-cloog-version-check
+# drop runtime libstdc++ dependency to avoid C++ ABI breakage
+GCC_CONFIG_ARGS += \
+	'--with-host-libstdcxx=-static-libgcc \
+	 -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
+endif
+
 # Add Android specific gcc options.
 # FIXME: These should be overridable by configure options.
 
@@ -444,6 +478,11 @@  install-target-newlib: stmp-build-target-newlib
 config-host-gmp: stmp-config-host-gmp
 GMP_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
 	  --host=${cur_host} --build=${cur_build}
+
+ifeq ($(ENABLE_GRAPHITE),yes)
+GMP_CONFIG_ARGS+= --enable-cxx
+endif
+
 stmp-config-host-gmp: config.status $(canadian_stmp)
 	([ -d ${GMP_VERSION} ] || \
 	  mkdir ${GMP_VERSION}) && \
@@ -517,6 +556,70 @@  stmp-install-host-mpc:
 endif
 install-host-mpc: stmp-install-host-mpc
 
+# host ppl rules
+.PHONY: config-host-ppl build-host-ppl install-host-ppl
+config-host-ppl: stmp-config-host-ppl
+PPL_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
+		--target=${target_alias} \
+		--host=${host} --build=${build} \
+		--disable-nls --with-gmp-prefix=$(GMP_DIR) \
+		--disable-watchdog \
+		--disable-ppl_lcdd --disable-ppl_lpsol --disable-ppl_pips
+stmp-config-host-ppl: config.status stmp-install-host-gmp
+	([ -d ${PPL_VERSION} ] || \
+	 mkdir ${PPL_VERSION}) && \
+	($(canadian_env) \
+	 cd ${PPL_VERSION} ; \
+	$(call find-package-srcdir, ${PPL_VERSION})/configure \
+	 $(PPL_CONFIG_ARGS)) && \
+	$(STAMP) $@
+stmp-build-host-ppl: stmp-config-host-ppl
+	$(MAKE) -C ${PPL_VERSION} && $(STAMP) $@
+build-host-ppl: stmp-build-host-ppl
+stmp-install-host-ppl: stmp-build-host-ppl
+	$(MAKE) -C ${PPL_VERSION} install && \
+	$(STAMP) $@
+install-host-ppl: stmp-install-host-ppl
+
+# host cloog rules
+.PHONY: config-host-cloog build-host-cloog install-host-cloog
+config-host-cloog: stmp-config-host-cloog
+CLOOG_CONFIG_ARGS=$(baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
+       --target=${target_alias} \
+       --host=${host} --build=${build} \
+       --disable-nls \
+       --with-gmp=$(GMP_DIR)
+# for cloog-ppl version 0.15.x, ppl is required.
+ifneq ($(findstring ppl-,$(CLOOG_VERSION)),)
+stmp-config-host-cloog: config.status stmp-install-host-ppl \
+			stmp-install-host-ppl-workaround
+stmp-install-host-ppl-workaround:
+	# cloog 0.15.9 is unable to detect newer versions of ppl.
+	# Thus we modify the version definition in header file to satisfy.
+	sed -i -e 's/PPL_VERSION_MINOR 11/PPL_VERSION_MINOR 10/' \
+	 $(PPL_DIR)/include/ppl_c.h
+	$(STAMP) $@
+CLOOG_CONFIG_ARGS+= --with-ppl=$(PPL_DIR)
+endif
+stmp-config-host-cloog: config.status stmp-install-host-gmp
+	([ -d ${CLOOG_VERSION} ] || \
+	 mkdir ${CLOOG_VERSION}) && \
+	($(canadian_env) \
+	 cd ${CLOOG_VERSION} ; \
+	$(call find-package-srcdir, ${CLOOG_VERSION})/configure \
+	 $(CLOOG_CONFIG_ARGS)) && \
+	$(STAMP) $@
+stmp-build-host-cloog: stmp-config-host-cloog
+	# Ignore the generation of cloog utilities
+	$(MAKE) -C ${CLOOG_VERSION} libcloog.la && \
+	$(STAMP) $@
+build-host-cloog: stmp-build-host-cloog
+stmp-install-host-cloog: stmp-build-host-cloog
+	$(MAKE) -C ${CLOOG_VERSION} install-libLTLIBRARIES \
+		install-pkgincludeHEADERS && \
+	$(STAMP) $@
+install-host-cloog: stmp-install-host-cloog
+
 # target gdb rules
 .PHONY: config-target-gdb build-target-gdb install-target-gdb
 ifeq ($(GDB_VERSION),gdb-none)
diff --git a/configure b/configure
index 32756c4..fe84ded 100755
--- a/configure
+++ b/configure
@@ -271,7 +271,7 @@  PACKAGE_VERSION='2.0'
 PACKAGE_STRING='android-tools 2.0'
 PACKAGE_BUGREPORT=''
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os BUILD_ANDROID_GCC GDB_TARGET TOPLEVEL_CONFIGURE_ARGUMENTS baseargs gold_baseargs package_to_srcdir BINUTILS_VERSION GOLD_VERSION GCC_VERSION GCC_MIN_VERSION_4_3_0 GCC_MIN_VERSION_4_5_0 NEWLIB_VERSION GMP_VERSION MPFR_VERSION MPC_VERSION GDB_VERSION sysroot have_mpc have_mpfr have_gmp LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os BUILD_ANDROID_GCC GDB_TARGET TOPLEVEL_CONFIGURE_ARGUMENTS baseargs gold_baseargs ENABLE_GRAPHITE package_to_srcdir BINUTILS_VERSION GOLD_VERSION GCC_VERSION GCC_MIN_VERSION_4_3_0 GCC_MIN_VERSION_4_5_0 NEWLIB_VERSION GMP_VERSION MPFR_VERSION MPC_VERSION PPL_VERSION CLOOG_VERSION GDB_VERSION sysroot have_mpc have_mpfr have_gmp have_ppl have_cloog LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -791,6 +791,11 @@  if test -n "$ac_init_help"; then
    esac
   cat <<\_ACEOF
 
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-graphite       Enable Graphite optimization [default=yes]
+
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
@@ -808,6 +813,10 @@  Optional Packages:
                           use mpfr-VERSION (default is 2.3.0)
   --with-mpc-version=VERSION
                           use mpc-VERSION (default is 0.8.1)
+  --with-ppl-version=VERSION
+                          use ppl-VERSION (default is 0.11.2)
+  --with-cloog-version=VERSION
+                          use cloog-VERSION (default is 0.15.9)
   --with-gdb-version=VERSION
                           use gdb-VERSION (default is 6.6)
   --with-sysroot=DIR
@@ -818,6 +827,10 @@  Optional Packages:
                           specify prefix directory for installed MPFR package.
   --with-gmp=PATH
                           specify prefix directory for the installed GMP package.
+  --with-ppl=PATH
+                          specify prefix directory for the installed PPL package.
+  --with-cloog=PATH
+                          specify prefix directory for the installed CLooG package.
 
 _ACEOF
 fi
@@ -1563,6 +1576,21 @@  done
 
 
 
+ENABLE_GRAPHITE=no
+# Check whether --enable-graphite or --disable-graphite was given.
+if test "${enable_graphite+set}" = set; then
+  enableval="$enable_graphite"
+
+fi;
+if test x${enableval} != yno; then
+  graphite=yes
+fi
+if test "$GCC_MIN_VERSION_4_5_0" == "no"; then
+  graphite=no
+fi
+ENABLE_GRAPHITE=$graphite
+
+
 # package to source path
 case $srcdir in
  /* | A-Za-z:*) package_to_srcdir=$srcdir ;;
@@ -1910,6 +1938,107 @@  fi
 fi
 
 
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# ppl version (default is 0.11.2)
+# ppl is only used for gcc 4.5+ with graphite optimization.
+echo "$as_me:$LINENO: checking ppl version" >&5
+echo $ECHO_N "checking ppl version... $ECHO_C" >&6
+
+# Check whether --with-ppl-version or --without-ppl-version was given.
+if test "${with_ppl_version+set}" = set; then
+  withval="$with_ppl_version"
+  if test x"$withval" != x ; then
+     PPL_VERSION="$withval"
+   fi
+else
+  PPL_VERSION="0.11.2"
+fi;
+echo "$as_me:$LINENO: result: $PPL_VERSION" >&5
+echo "${ECHO_T}$PPL_VERSION" >&6
+x=ppl-${PPL_VERSION}; tool=$(echo "$x" | sed -e 's/-.*//'); version=$(echo "$x" | sed -e 's/[^-]*-//'); \
+if test \( ! -d $srcdir/../$tool/ppl-${PPL_VERSION} \) -a \( x"$version" != x"none"  \) ; then
+  if test -f $srcdir/../$tool/ppl-${PPL_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/ppl-${PPL_VERSION}.tar
+  elif test -f $srcdir/../$tool/ppl-${PPL_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/ppl-${PPL_VERSION}.tar.gz
+  elif test -f $srcdir/../$tool/ppl-${PPL_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/ppl-${PPL_VERSION}.tgz
+  elif test -f $srcdir/../$tool/ppl-${PPL_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/ppl-${PPL_VERSION}.tar.bz2
+  elif test -f $srcdir/../tarballs/ppl-${PPL_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../tarballs/ppl-${PPL_VERSION}.tar
+  elif test -f $srcdir/../tarballs/ppl-${PPL_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/ppl-${PPL_VERSION}.tar.gz
+  elif test -f $srcdir/../tarballs/ppl-${PPL_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/ppl-${PPL_VERSION}.tgz
+  elif test -f $srcdir/../tarballs/ppl-${PPL_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../tarballs/ppl-${PPL_VERSION}.tar.bz2
+  else
+    { { echo "$as_me:$LINENO: error: 'package ppl-${PPL_VERSION} does not exist.'" >&5
+echo "$as_me: error: 'package ppl-${PPL_VERSION} does not exist.'" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+fi
+fi
+
+
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# cloog-ppl or cloog version (default is 0.15.9)
+# cloog is only used for gcc 4.5+ with graphite optimization.
+echo "$as_me:$LINENO: checking cloog version" >&5
+echo $ECHO_N "checking cloog version... $ECHO_C" >&6
+
+# Check whether --with-cloog-version or --without-cloog-version was given.
+if test "${with_cloog_version+set}" = set; then
+  withval="$with_cloog_version"
+  if test x"$withval" != x ; then
+     CLOOG_VERSION="$withval"
+   fi
+else
+  CLOOG_VERSION="0.15.9"
+fi;
+echo "$as_me:$LINENO: result: $CLOOG_VERSION" >&5
+echo "${ECHO_T}$CLOOG_VERSION" >&6
+case $CLOOG_VERSION in
+  0.15*)
+    # CLooG/PPL relies on the PPL for version 0.15.x
+    CLOOG_VERSION="ppl-$CLOOG_VERSION"
+    ;;
+  0.16*)
+    # CLooG 0.16.x has its own embedded polyhedral library
+    ;;
+  *)
+    { { echo "$as_me:$LINENO: error: Unsupported cloog version" >&5
+echo "$as_me: error: Unsupported cloog version" >&2;}
+   { (exit 1); exit 1; }; };
+esac
+x=cloog-${CLOOG_VERSION}; tool=$(echo "$x" | sed -e 's/-.*//'); version=$(echo "$x" | sed -e 's/[^-]*-//'); \
+if test \( ! -d $srcdir/../$tool/cloog-${CLOOG_VERSION} \) -a \( x"$version" != x"none"  \) ; then
+  if test -f $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar
+  elif test -f $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar.gz
+  elif test -f $srcdir/../$tool/cloog-${CLOOG_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/cloog-${CLOOG_VERSION}.tgz
+  elif test -f $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/cloog-${CLOOG_VERSION}.tar.bz2
+  elif test -f $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar
+  elif test -f $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar.gz
+  elif test -f $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tgz
+  elif test -f $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../tarballs/cloog-${CLOOG_VERSION}.tar.bz2
+  else
+    { { echo "$as_me:$LINENO: error: 'package cloog-${CLOOG_VERSION} does not exist.'" >&5
+echo "$as_me: error: 'package cloog-${CLOOG_VERSION} does not exist.'" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+fi
+fi
+
+
 # gdb version (default is 6.6)
 echo "$as_me:$LINENO: checking target gdb version to build" >&5
 echo $ECHO_N "checking target gdb version to build... $ECHO_C" >&6
@@ -2040,6 +2169,44 @@  else
 fi;
 
 
+# Specify a location for ppl
+
+# Check whether --with-ppl or --without-ppl was given.
+if test "${with_ppl+set}" = set; then
+  withval="$with_ppl"
+  if test -d "$withval" ; then
+     have_ppl="$withval"
+   elif test x"$withval" != x"no"; then
+     { { echo "$as_me:$LINENO: error: invalid value for --with-ppl" >&5
+echo "$as_me: error: invalid value for --with-ppl" >&2;}
+   { (exit 1); exit 1; }; }
+   else
+     have_ppl=no
+   fi
+else
+  have_ppl=no
+fi;
+
+
+# Specify a location for cloog
+
+# Check whether --with-cloog or --without-cloog was given.
+if test "${with_cloog+set}" = set; then
+  withval="$with_cloog"
+  if test -d "$withval" ; then
+     have_cloog="$withval"
+   elif test x"$withval" != x"no"; then
+     { { echo "$as_me:$LINENO: error: invalid value for --with-cloog" >&5
+echo "$as_me: error: invalid value for --with-cloog" >&2;}
+   { (exit 1); exit 1; }; }
+   else
+     have_cloog=no
+   fi
+else
+  have_cloog=no
+fi;
+
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -2691,6 +2858,7 @@  s,@GDB_TARGET@,$GDB_TARGET,;t t
 s,@TOPLEVEL_CONFIGURE_ARGUMENTS@,$TOPLEVEL_CONFIGURE_ARGUMENTS,;t t
 s,@baseargs@,$baseargs,;t t
 s,@gold_baseargs@,$gold_baseargs,;t t
+s,@ENABLE_GRAPHITE@,$ENABLE_GRAPHITE,;t t
 s,@package_to_srcdir@,$package_to_srcdir,;t t
 s,@BINUTILS_VERSION@,$BINUTILS_VERSION,;t t
 s,@GOLD_VERSION@,$GOLD_VERSION,;t t
@@ -2701,11 +2869,15 @@  s,@NEWLIB_VERSION@,$NEWLIB_VERSION,;t t
 s,@GMP_VERSION@,$GMP_VERSION,;t t
 s,@MPFR_VERSION@,$MPFR_VERSION,;t t
 s,@MPC_VERSION@,$MPC_VERSION,;t t
+s,@PPL_VERSION@,$PPL_VERSION,;t t
+s,@CLOOG_VERSION@,$CLOOG_VERSION,;t t
 s,@GDB_VERSION@,$GDB_VERSION,;t t
 s,@sysroot@,$sysroot,;t t
 s,@have_mpc@,$have_mpc,;t t
 s,@have_mpfr@,$have_mpfr,;t t
 s,@have_gmp@,$have_gmp,;t t
+s,@have_ppl@,$have_ppl,;t t
+s,@have_cloog@,$have_cloog,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
diff --git a/configure.ac b/configure.ac
index 3de117e..cd2d75a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,19 @@  done
 
 AC_SUBST(gold_baseargs)
 
+ENABLE_GRAPHITE=no
+AC_ARG_ENABLE([graphite],
+              AC_HELP_STRING([--enable-graphite],
+                             [Enable Graphite optimization @<:@default=yes@:>@]))
+if test x${enableval} != yno; then
+  graphite=yes
+fi
+if test "$GCC_MIN_VERSION_4_5_0" == "no"; then
+  graphite=no
+fi
+ENABLE_GRAPHITE=$graphite
+AC_SUBST(ENABLE_GRAPHITE)
+
 # package to source path
 case $srcdir in
  /* | [A-Za-z]:*) package_to_srcdir=$srcdir ;;
@@ -364,6 +377,49 @@  ANDROID_CHECK_PACKAGE(mpc-${MPC_VERSION})
 fi
 AC_SUBST(MPC_VERSION)
 
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# ppl version (default is 0.11.2)
+# ppl is only used for gcc 4.5+ with graphite optimization.
+AC_MSG_CHECKING([ppl version])
+AC_ARG_WITH([ppl-version],
+  [  --with-ppl-version=VERSION
+                          use ppl-VERSION (default is 0.11.2)],
+  [if test x"$withval" != x ; then
+     PPL_VERSION="$withval"
+   fi],
+[PPL_VERSION="0.11.2"])
+AC_MSG_RESULT($PPL_VERSION)
+ANDROID_CHECK_PACKAGE(ppl-${PPL_VERSION})
+fi
+AC_SUBST(PPL_VERSION)
+
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# cloog-ppl or cloog version (default is 0.15.9)
+# cloog is only used for gcc 4.5+ with graphite optimization.
+AC_MSG_CHECKING([cloog version])
+AC_ARG_WITH([cloog-version],
+  [  --with-cloog-version=VERSION
+                          use cloog-VERSION (default is 0.15.9)],
+  [if test x"$withval" != x ; then
+     CLOOG_VERSION="$withval"
+   fi],
+[CLOOG_VERSION="0.15.9"])
+AC_MSG_RESULT($CLOOG_VERSION)
+case $CLOOG_VERSION in
+  0.15*)
+    # CLooG/PPL relies on the PPL for version 0.15.x
+    CLOOG_VERSION="ppl-$CLOOG_VERSION"
+    ;;
+  0.16*)
+    # CLooG 0.16.x has its own embedded polyhedral library
+    ;;
+  *)
+    AC_MSG_ERROR(Unsupported cloog version);
+esac
+ANDROID_CHECK_PACKAGE(cloog-${CLOOG_VERSION})
+fi
+AC_SUBST(CLOOG_VERSION)
+
 # gdb version (default is 6.6)
 AC_MSG_CHECKING([target gdb version to build])
 AC_ARG_WITH([gdb-version],
@@ -441,4 +497,30 @@  AC_ARG_WITH(gmp, [  --with-gmp=PATH
   [have_gmp=no])
 AC_SUBST(have_gmp)
 
+# Specify a location for ppl
+AC_ARG_WITH(ppl, [  --with-ppl=PATH
+                          specify prefix directory for the installed PPL package.],
+  [if test -d "$withval" ; then
+     have_ppl="$withval"
+   elif test x"$withval" != x"no"; then
+     AC_MSG_ERROR(invalid value for --with-ppl)
+   else
+     have_ppl=no
+   fi],
+  [have_ppl=no])
+AC_SUBST(have_ppl)
+
+# Specify a location for cloog
+AC_ARG_WITH(cloog, [  --with-cloog=PATH
+                          specify prefix directory for the installed CLooG package.],
+  [if test -d "$withval" ; then
+     have_cloog="$withval"
+   elif test x"$withval" != x"no"; then
+     AC_MSG_ERROR(invalid value for --with-cloog)
+   else
+     have_cloog=no
+   fi],
+  [have_cloog=no])
+AC_SUBST(have_cloog)
+
 AC_OUTPUT