Fix for GCC 4.8 with graphite

GCC 4.8 needs cloog-0.18.0 and isl-0.11.1 for graphite
framework.

Change-Id: I45a6f34f9981a489d65cc23a0f20e439c11100b2
diff --git a/Makefile.in b/Makefile.in
index 8f34a69..43fe553 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -57,6 +57,7 @@
 host_baseargs = @host_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@
+GCC_MIN_VERSION_4_8_0:=@GCC_MIN_VERSION_4_8_0@
 GDB_MIN_VERSION_7_2:=@GDB_MIN_VERSION_7_2@
 BINUTILS_MIN_VERSION_2_21:=@BINUTILS_MIN_VERSION_2_21@
 GOLD_MIN_VERSION_2_21:=@GOLD_MIN_VERSION_2_21@
@@ -80,6 +81,7 @@
 MPC_VERSION=mpc-@MPC_VERSION@
 PPL_VERSION=ppl-@PPL_VERSION@
 CLOOG_VERSION=cloog-@CLOOG_VERSION@
+ISL_VERSION=isl-@ISL_VERSION@
 GDB_VERSION=gdb-@GDB_VERSION@
 EXPAT_VERSION=expat-@EXPAT_VERSION@
 HAVE_MPC=@have_mpc@
@@ -87,6 +89,7 @@
 HAVE_GMP=@have_gmp@
 HAVE_PPL=@have_ppl@
 HAVE_CLOOG=@have_cloog@
+HAVE_ISL=@have_isl@
 HAVE_EXPAT=@have_expat@
 ENABLE_GOLD=@enable_gold@
 ENABLE_LD_DEFAULT=@enable_ld_default@
@@ -116,6 +119,10 @@
   CLOOG_DIR=$(TEMP_INSTALLDIR)
 endif
 
+ifeq ($(HAVE_ISL), no)
+  ISL_DIR=$(TEMP_INSTALLDIR)
+endif
+
 ifeq ($(HAVE_EXPAT),no)
   EXPAT_DIR=$(TEMP_INSTALLDIR)
 endif
@@ -293,8 +300,8 @@
 	--target=${cur_target} --host=${cur_host} --build=${cur_build} \
 	$(baseargs) --disable-shared --disable-nls
 ifeq ($(ENABLE_GRAPHITE),yes)
-BINUTILS_CONFIG_ARGS+= --with-cloog=${CLOOG_DIR} --with-gmp=${GMP_DIR} \
-	--disable-ppl-version-check --disable-cloog-version-check $(CLOOG_BACKEND)
+BINUTILS_CONFIG_ARGS+= --with-cloog=${CLOOG_DIR} --with-isl=${ISL_DIR} --with-isl=${ISL_DIR} --with-gmp=${GMP_DIR} \
+	--disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check $(CLOOG_BACKEND)
 # links to the static C++ runtime to avoid depending on the host version
 ifneq ($(host_os),darwin)
 BINUTILS_CONFIG_ARGS+= \
@@ -323,7 +330,7 @@
 endif
 endif
 endif
-stmp-config-target-binutils: config.status stmp-install-host-ppl $(canadian_stmp)
+stmp-config-target-binutils: config.status stmp-install-host-ppl stmp-install-host-isl $(canadian_stmp)
 	([ -d ${BINUTILS_VERSION} ] || \
 	  mkdir ${BINUTILS_VERSION}) && \
 	($(canadian_env) \
@@ -433,10 +440,11 @@
 GCC_CONFIG_ARGS += --with-mpc=$(MPC_DIR)
 endif
 
-# For gcc 4.5+ with graphite optimization, cloog and ppl are required.
+# For gcc 4.5 and 4.6 with graphite optimization, cloog and ppl are required.
+# For gcc 4.8+ with graphite optimization, cloog and isl 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 $(CLOOG_BACKEND)
+GCC_CONFIG_ARGS += --with-cloog=${CLOOG_DIR} --with-isl=${ISL_DIR} --with-ppl=${PPL_DIR} \
+	--disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check $(CLOOG_BACKEND)
 # links to the static C++ runtime to avoid depending on the host version
 ifneq ($(host_os),darwin)
 GCC_CONFIG_ARGS += \
@@ -449,8 +457,8 @@
 GCC_CONFIG_ARGS += '--with-host-libstdcxx=-static-libgcc -lstdc++ -lm'
 endif
 else
-# Disable ppl and cloog just in case the host have them install.
-GCC_CONFIG_ARGS += --without-ppl --without-cloog
+# Disable ppl, isl and cloog just in case the host have them install.
+GCC_CONFIG_ARGS += --without-ppl --without-cloog --without-isl
 endif
 
 # Add Android specific gcc options.
@@ -491,7 +499,7 @@
 endif
 
 # We have to add -mandroid in target CFLAGS and CXXFLAGS
-stmp-config-target-gcc: config.status stmp-install-host-ppl stmp-build-target-binutils
+stmp-config-target-gcc: config.status stmp-install-host-ppl stmp-install-host-isl stmp-install-host-cloog stmp-build-target-binutils
 	([ -d ${GCC_VERSION} ] || \
 	  mkdir ${GCC_VERSION}) && \
 	($(canadian_env) \
@@ -679,6 +687,38 @@
 endif
 install-host-ppl: stmp-install-host-ppl
 
+# host isl rules
+.PHONY: config-host-isl build-host-isl install-host-isl
+config-host-isl: stmp-config-host-isl
+ISL_CONFIG_ARGS=$(host_baseargs) --prefix=$(TEMP_INSTALLDIR) --disable-shared \
+	  --target=${target_alias} \
+	  --host=${host} --build=${build} \
+	  --disable-nls
+stmp-config-host-isl: config.status stmp-install-host-gmp
+	([ -d ${ISL_VERSION} ] || \
+	 mkdir ${ISL_VERSION}) && \
+	($(canadian_env) \
+	 cd ${ISL_VERSION} ; \
+         export CFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
+         export CXXFLAGS="${CFLAGS} -I$(GMP_DIR)/include" ; \
+         export LDFLAGS="${LDFLAGS} -L$(GMP_DIR)/lib" ; \
+	$(call find-package-srcdir, ${ISL_VERSION})/configure \
+	 $(ISL_CONFIG_ARGS)) && \
+	$(STAMP) $@
+stmp-build-host-isl: stmp-config-host-isl
+	$(MAKE) -C ${ISL_VERSION} && $(STAMP) $@
+build-host-isl: stmp-build-host-isl
+
+ifeq ($(ENABLE_GRAPHITE)$(GCC_MIN_VERSION_4_8_0),yesyes)
+stmp-install-host-isl: stmp-build-host-isl
+	$(MAKE) -C ${ISL_VERSION} install && \
+	$(STAMP) $@
+else
+stmp-install-host-isl:
+	$(STAMP) $@
+endif
+install-host-isl: stmp-install-host-isl
+
 # host cloog rules
 .PHONY: config-host-cloog build-host-cloog install-host-cloog
 config-host-cloog: stmp-config-host-cloog
@@ -715,6 +755,8 @@
 	$(MAKE) -C ${CLOOG_VERSION} $(CLOOG_TARGET) && \
 	$(STAMP) $@
 build-host-cloog: stmp-build-host-cloog
+
+ifeq ($(ENABLE_GRAPHITE),yes)
 stmp-install-host-cloog: stmp-build-host-cloog
 	$(MAKE) -C ${CLOOG_VERSION} install-libLTLIBRARIES \
 		install-pkgincludeHEADERS
@@ -722,7 +764,14 @@
 	$(MAKE) -C ${CLOOG_VERSION}/isl install-libLTLIBRARIES \
 		install-pkgincludeHEADERS
 endif
+ifeq ($(GCC_MIN_VERSION_4_8_0),yes)
+	$(MAKE) -C ${CLOOG_VERSION} install
+endif
 	$(STAMP) $@
+else
+stmp-install-host-cloog:
+	$(STAMP) $@
+endif
 install-host-cloog: stmp-install-host-cloog
 
 # host expat rules
diff --git a/configure b/configure
index 56bc66a..5c81f66 100755
--- a/configure
+++ b/configure
@@ -554,6 +554,7 @@
 LIBOBJS
 have_expat
 have_cloog
+have_isl
 have_ppl
 have_gmp
 have_mpfr
@@ -564,11 +565,13 @@
 GDB_VERSION
 CLOOG_VERSION
 CLOOG_BACKEND
+ISL_VERSION
 PPL_VERSION
 MPC_VERSION
 MPFR_VERSION
 GMP_VERSION
 NEWLIB_VERSION
+GCC_MIN_VERSION_4_8_0
 GCC_MIN_VERSION_4_5_0
 GCC_MIN_VERSION_4_3_0
 GCC_VERSION
@@ -651,6 +654,7 @@
 with_mpc_version
 with_ppl_version
 with_cloog_version
+with_isl_version
 with_gdb_version
 with_expat_version
 with_sysroot
@@ -659,6 +663,7 @@
 with_gmp
 with_ppl
 with_cloog
+with_isl
 with_expat
 '
       ac_precious_vars='build_alias
@@ -1304,9 +1309,11 @@
   --with-mpc-version=VERSION
                           use mpc-VERSION (default is 0.8.1)
   --with-ppl-version=VERSION
-                         use ppl-VERSION (default is 0.11.2)
+                          use ppl-VERSION (default is 0.11.2)
   --with-cloog-version=VERSION
-                           use cloog-VERSION (default is 0.15.9)
+                          use cloog-VERSION (default is 0.15.9)
+  --with-isl-version=VERSION
+                          use isl-VERSION (default is 0.11.1)
   --with-gdb-version=VERSION
                           use gdb-VERSION (default is 6.6)
   --with-expat-version=VERSION
@@ -1323,6 +1330,8 @@
                           specify prefix directory for the installed PPL package.
   --with-cloog=PATH
                           specify prefix directory for the installed CLooG package.
+  --with-isl=PATH
+                          specify prefix directory for the installed ISL package.
   --with-expat=PATH
                           specify prefix directory for the installed EXPAT package.
 
@@ -2423,10 +2432,17 @@
   else
     GCC_MIN_VERSION_4_5_0="no"
   fi
+  if test "$GCC_MAJOR" -gt 4 -o \
+              \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 8 \) ; then
+    GCC_MIN_VERSION_4_8_0="yes"
+  else
+    GCC_MIN_VERSION_4_8_0="no"
+  fi
 else
   # No version file, assume it is trunk
   GCC_MIN_VERSION_4_3_0="yes"
   GCC_MIN_VERSION_4_5_0="yes"
+  GCC_MIN_VERSION_4_8_0="yes"
 fi
 
 
@@ -2600,7 +2616,7 @@
 
 if test "$ENABLE_GRAPHITE" == "yes"; then
 # ppl version (default is 0.11.2)
-# ppl is only used for gcc 4.5+ with graphite optimization.
+# ppl is only used for gcc 4.5 and 4.6 with graphite optimization.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking ppl version" >&5
 $as_echo_n "checking ppl version... " >&6; }
 
@@ -2662,7 +2678,7 @@
     # CLooG/PPL relies on the PPL for version 0.15.x
     CLOOG_VERSION="ppl-$CLOOG_VERSION"
     ;;
-  0.16*|0.17*)
+  0.16*|0.17*|0.18*)
     # CLooG 0.16+ has its own embedded polyhedral library
     CLOOG_BACKEND="--enable-cloog-backend=isl"
     ;;
@@ -2694,6 +2710,49 @@
 fi
 
 
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# isl version (default is 0.11.1)
+# isl is only used for gcc 4.8+ with graphite optimization.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking isl version" >&5
+$as_echo_n "checking isl version... " >&6; }
+
+# Check whether --with-isl-version was given.
+if test "${with_isl_version+set}" = set; then :
+  withval=$with_isl_version; if test x"$withval" != x ; then
+     ISL_VERSION="$withval"
+   fi
+else
+  ISL_VERSION="0.11.1"
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ISL_VERSION" >&5
+$as_echo "$ISL_VERSION" >&6; }
+x=isl-${ISL_VERSION}; tool=$(echo "$x" | sed -e 's/-.*//'); version=$(echo "$x" | sed -e 's/[^-]*-//'); \
+if test \( ! -d $srcdir/../$tool/isl-${ISL_VERSION} \) -a \( x"$version" != x"none"  \) ; then
+  if test -f $srcdir/../$tool/isl-${ISL_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/isl-${ISL_VERSION}.tar
+  elif test -f $srcdir/../$tool/isl-${ISL_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/isl-${ISL_VERSION}.tar.gz
+  elif test -f $srcdir/../$tool/isl-${ISL_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/isl-${ISL_VERSION}.tgz
+  elif test -f $srcdir/../$tool/isl-${ISL_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/isl-${ISL_VERSION}.tar.bz2
+  elif test -f $srcdir/../tarballs/isl-${ISL_VERSION}.tar ; then
+    mkdir -p temp-src && tar -C temp-src -xf $srcdir/../tarballs/isl-${ISL_VERSION}.tar
+  elif test -f $srcdir/../tarballs/isl-${ISL_VERSION}.tar.gz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/isl-${ISL_VERSION}.tar.gz
+  elif test -f $srcdir/../tarballs/isl-${ISL_VERSION}.tgz ; then
+    mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/isl-${ISL_VERSION}.tgz
+  elif test -f $srcdir/../tarballs/isl-${ISL_VERSION}.tar.bz2 ; then
+    mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../tarballs/isl-${ISL_VERSION}.tar.bz2
+  else
+    as_fn_error "'package isl-${ISL_VERSION} does not exist.'" "$LINENO" 5
+  fi
+fi
+fi
+
+
+
 # gdb version (default is 6.6)
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking target gdb version to build" >&5
 $as_echo_n "checking target gdb version to build... " >&6; }
@@ -2918,6 +2977,23 @@
 
 
 
+# Specify a location for isl
+
+# Check whether --with-isl was given.
+if test "${with_isl+set}" = set; then :
+  withval=$with_isl; if test -d "$withval" ; then
+     have_isl="$withval"
+   elif test x"$withval" != x"no"; then
+     as_fn_error "invalid value for --with-isl" "$LINENO" 5
+   else
+     have_isl=no
+   fi
+else
+  have_isl=no
+fi
+
+
+
 # Specify a location for expat
 
 # Check whether --with-expat was given.
diff --git a/configure.ac b/configure.ac
index 03c5128..99e353a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -372,13 +372,21 @@
   else
     GCC_MIN_VERSION_4_5_0="no"
   fi
+  if test "$GCC_MAJOR" -gt 4 -o \
+              \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 8 \) ; then
+    GCC_MIN_VERSION_4_8_0="yes"
+  else
+    GCC_MIN_VERSION_4_8_0="no"
+  fi
 else
   # No version file, assume it is trunk
   GCC_MIN_VERSION_4_3_0="yes"
   GCC_MIN_VERSION_4_5_0="yes"
+  GCC_MIN_VERSION_4_8_0="yes"
 fi
 AC_SUBST(GCC_MIN_VERSION_4_3_0)
 AC_SUBST(GCC_MIN_VERSION_4_5_0)
+AC_SUBST(GCC_MIN_VERSION_4_8_0)
 
 # newlib version (default is 1.16.0)
 # newlib is only used for arm-newlib-eabi for testing
@@ -445,7 +453,7 @@
 
 if test "$ENABLE_GRAPHITE" == "yes"; then
 # ppl version (default is 0.11.2)
-# ppl is only used for gcc 4.5+ with graphite optimization.
+# ppl is only used for gcc 4.5 and 4.6 with graphite optimization.
 AC_MSG_CHECKING([ppl version])
 AC_ARG_WITH([ppl-version],
   [  --with-ppl-version=VERSION
@@ -476,7 +484,7 @@
     # CLooG/PPL relies on the PPL for version 0.15.x
     CLOOG_VERSION="ppl-$CLOOG_VERSION"
     ;;
-  0.16*|0.17*)
+  0.16*|0.17*|0.18*)
     # CLooG 0.16+ has its own embedded polyhedral library
     CLOOG_BACKEND="--enable-cloog-backend=isl"
     ;;
@@ -488,6 +496,22 @@
 fi
 AC_SUBST(CLOOG_VERSION)
 
+if test "$ENABLE_GRAPHITE" == "yes"; then
+# isl version (default is 0.11.1)
+# isl is only used for gcc 4.8+ with graphite optimization.
+AC_MSG_CHECKING([isl version])
+AC_ARG_WITH([isl-version],
+  [  --with-isl-version=VERSION
+                         use isl-VERSION (default is 0.11.1)],
+  [if test x"$withval" != x ; then
+     ISL_VERSION="$withval"
+   fi],
+[ISL_VERSION="0.11.1"])
+AC_MSG_RESULT($ISL_VERSION)
+ANDROID_CHECK_PACKAGE(isl-${ISL_VERSION})
+fi
+AC_SUBST(ISL_VERSION)
+
 # gdb version (default is 6.6)
 AC_MSG_CHECKING([target gdb version to build])
 AC_ARG_WITH([gdb-version],
@@ -637,6 +661,19 @@
   [have_cloog=no])
 AC_SUBST(have_cloog)
 
+# Specify a location for isl
+AC_ARG_WITH(isl, [  --with-isl=PATH
+                          specify prefix directory for the installed ISL package.],
+  [if test -d "$withval" ; then
+     have_isl="$withval"
+   elif test x"$withval" != x"no"; then
+     AC_MSG_ERROR(invalid value for --with-isl)
+   else
+     have_isl=no
+   fi],
+  [have_isl=no])
+AC_SUBST(have_isl)
+
 # Specify a location for expat
 AC_ARG_WITH(expat, [  --with-expat=PATH
                           specify prefix directory for the installed EXPAT package.],