Add LLVM/CLANG-3.2 toolchain

1. Download/build llvm-3.2 clang/llvm
2. New NDK_TOOLCHAIN_VERSION=clang3.2, or simply
   NDK_TOOLCHAIN_VERSION=clang to picks up the most recent
   version of clang/llvm (3.2 at this moment)
3. Add toolchain/*clang-3.2

Change-Id: I37d250addc17f6a2499982819c4952110be18394
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index fcc74d9..d05341a 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -20,7 +20,7 @@
 $(call assert-defined,TARGET_PLATFORM TARGET_ARCH TARGET_ARCH_ABI)
 $(call assert-defined,NDK_APPS NDK_APP_STL)
 
-LLVM_VERSION_LIST := 2.6 2.7 2.8 2.9 3.0 3.1
+LLVM_VERSION_LIST := 2.6 2.7 2.8 2.9 3.0 3.1 3.2
 
 # Check that we have a toolchain that supports the current ABI.
 # NOTE: If NDK_TOOLCHAIN is defined, we're going to use it.
@@ -50,6 +50,10 @@
     # suffix with it.
     #
     ifdef NDK_TOOLCHAIN_VERSION
+        # Replace "clang" with the most recent verion
+        ifeq ($(NDK_TOOLCHAIN_VERSION),clang)
+            NDK_TOOLCHAIN_VERSION=clang$(lastword $(LLVM_VERSION_LIST))
+        fi
         # We assume the toolchain name uses dashes (-) as separators and doesn't
         # contain any space. The following is a bit subtle, but essentially
         # does the following:
diff --git a/build/tools/build-llvm.sh b/build/tools/build-llvm.sh
index 2d61a5c..98ae68a 100755
--- a/build/tools/build-llvm.sh
+++ b/build/tools/build-llvm.sh
@@ -28,7 +28,7 @@
 
 Where <src-dir> is the location of toolchain sources, <ndk-dir> is
 the top-level NDK installation path and <toolchain> is the name of
-the toolchain to use (e.g. llvm-3.1)."
+the toolchain to use (e.g. llvm-3.2)."
 
 RELEASE=`date +%Y%m%d`
 BUILD_OUT=/tmp/ndk-$USER/build/toolchain
@@ -162,6 +162,11 @@
     POLLY=no
 fi
 
+if [ "$POLLY" = "yes" -a ! -d "$SRC_DIR/$TOOLCHAIN/polly" ] ; then
+    dump "Disable polly because $SRC_DIR/$TOOLCHAIN/polly doesn't exist"
+    POLLY=no
+fi
+
 EXTRA_CONFIG_FLAGS=
 rm -rf $SRC_DIR/$TOOLCHAIN/llvm/tools/polly
 if [ "$POLLY" = "yes" ]; then
@@ -269,10 +274,10 @@
 rm -rf $TOOLCHAIN_BUILD_PREFIX/share
 
 UNUSED_LLVM_EXECUTABLES="
-bugpoint c-index-test clang-tblgen lli llvm-ar llvm-as llvm-bcanalyzer
-llvm-config llvm-cov llvm-diff llvm-dwarfdump llvm-extract llvm-ld llvm-mc
-llvm-nm llvm-objdump llvm-prof llvm-ranlib llvm-readobj llvm-rtdyld llvm-size
-llvm-stress llvm-stub llvm-tblgen macho-dump cloog"
+bugpoint c-index-test clang-check clang-tblgen lli llvm-ar llvm-as llvm-bcanalyzer
+llvm-config llvm-config-host llvm-cov llvm-diff llvm-dwarfdump llvm-extract llvm-ld
+llvm-mc llvm-nm llvm-mcmarkup llvm-objdump llvm-prof llvm-ranlib llvm-readobj llvm-rtdyld
+llvm-size llvm-stress llvm-stub llvm-tblgen macho-dump cloog"
 
 for i in $UNUSED_LLVM_EXECUTABLES; do
     rm -f $TOOLCHAIN_BUILD_PREFIX/bin/$i
diff --git a/build/tools/dev-defaults.sh b/build/tools/dev-defaults.sh
index 5b6c0e3..4203442 100644
--- a/build/tools/dev-defaults.sh
+++ b/build/tools/dev-defaults.sh
@@ -62,7 +62,7 @@
 DEFAULT_ARCH_TOOLCHAIN_PREFIX_mips=mipsel-linux-android
 
 # The space-separated list of all LLVM versions we support in NDK
-DEFAULT_LLVM_VERSION_LIST="3.1"
+DEFAULT_LLVM_VERSION_LIST="3.2 3.1"
 
 # The default LLVM version (first item in the list)
 DEFAULT_LLVM_VERSION=$(echo "$DEFAULT_LLVM_VERSION_LIST" | tr ' ' '\n' | head -n 1)
diff --git a/build/tools/download-toolchain-sources.sh b/build/tools/download-toolchain-sources.sh
index ef14b5a..c1cdd70 100755
--- a/build/tools/download-toolchain-sources.sh
+++ b/build/tools/download-toolchain-sources.sh
@@ -109,7 +109,6 @@
 
 # Normalize the parameters
 LLVM_VERSION_LIST=$(commas_to_spaces $LLVM_VERSION_LIST)
-LLVM_URL=${LLVM_URL%"/"}
 
 # Create temp directory where everything will be copied first
 #
@@ -173,7 +172,12 @@
     fi
     (mkdir -p $TMPDIR/$SUBDIR/$NAME && cd $TMPDIR/$SUBDIR/$NAME && run git $GITOPTS checkout $REVISION "$@")
     fail_panic "Could not checkout $NAME / $@ ?"
-    (printf "%-32s " "toolchain/$NAME.git"; git $GITOPTS log -1 --format=oneline $REVISION) >> $SOURCES_LIST
+    if [ "$BRANCH" = "master" ]; then
+        BRANCH=
+    else
+        BRANCH="($BRANCH)"
+    fi
+    (printf "%-32s " "toolchain/$NAME.git $BRANCH"; git $GITOPTS log -1 --format=oneline $REVISION) >> $SOURCES_LIST
 }
 
 cd $TMPDIR
@@ -221,10 +225,11 @@
     #    will only create symbolic link when --with-polly is specified.
     (cd "$TMPDIR/llvm-$LLVM_VERSION/llvm" && \
         ln -s ../../clang tools && \
-        mv tools/polly ..)
+        test -d tools/polly && mv tools/polly ..)
     # In polly/utils/cloog_src, touch Makefile.in, aclocal.m4, and configure to
     # make sure they are not regenerated.
-    (cd "$TMPDIR/llvm-$LLVM_VERSION/polly" && \
+    (test -d "$TMPDIR/llvm-$LLVM_VERSION/polly" && \
+     cd "$TMPDIR/llvm-$LLVM_VERSION/polly" && \
         find . -name "Makefile.in" -exec touch {} \; && \
         find . -name "aclocal.m4" -exec touch {} \; && \
         find . -name "configure" -exec touch {} \; )
diff --git a/toolchains/arm-linux-androideabi-clang3.2/config.mk b/toolchains/arm-linux-androideabi-clang3.2/config.mk
new file mode 100644
index 0000000..6b0bf2b
--- /dev/null
+++ b/toolchains/arm-linux-androideabi-clang3.2/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the arm llvm-3.2 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := arm
+TOOLCHAIN_ABIS := armeabi armeabi-v7a
diff --git a/toolchains/arm-linux-androideabi-clang3.2/setup.mk b/toolchains/arm-linux-androideabi-clang3.2/setup.mk
new file mode 100644
index 0000000..312774c
--- /dev/null
+++ b/toolchains/arm-linux-androideabi-clang3.2/setup.mk
@@ -0,0 +1,140 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the arm clang-3.2
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+#
+# Override the toolchain prefix
+#
+
+LLVM_VERSION := 3.2
+LLVM_NAME := llvm-$(LLVM_VERSION)
+LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME)
+LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(LLVM_TOOLCHAIN_ROOT))
+LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
+
+TOOLCHAIN_VERSION := 4.6
+TOOLCHAIN_NAME := arm-linux-androideabi-$(TOOLCHAIN_VERSION)
+TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
+TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
+TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi-
+
+TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
+TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
+
+#
+# CFLAGS and LDFLAGS
+#
+
+TARGET_CFLAGS := \
+    -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+    -fpic \
+    -ffunction-sections \
+    -funwind-tables \
+    -fstack-protector \
+    -no-canonical-prefixes
+
+TARGET_LDFLAGS := \
+    -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+    -no-canonical-prefixes
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
+    LLVM_TRIPLE := armv7-none-linux-androideabi
+
+    TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
+                     -march=armv7-a \
+                     -mfloat-abi=softfp \
+                     -mfpu=vfpv3-d16
+
+    TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \
+                      -Wl,--fix-cortex-a8
+else
+    LLVM_TRIPLE := armv5te-none-linux-androideabi
+
+    TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
+                     -march=armv5te \
+                     -mtune=xscale \
+                     -msoft-float
+
+    TARGET_LDFLAGS += -target $(LLVM_TRIPLE)
+endif
+
+TARGET_CFLAGS.neon := -mfpu=neon
+
+TARGET_arm_release_CFLAGS :=  -O2 \
+                              -g \
+                              -DNDEBUG \
+                              -fomit-frame-pointer \
+                              -fstrict-aliasing
+
+TARGET_thumb_release_CFLAGS := -mthumb \
+                               -Os \
+                               -g \
+                               -DNDEBUG \
+                               -fomit-frame-pointer \
+                               -fno-strict-aliasing
+
+# When building for debug, compile everything as arm.
+TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
+                           -fno-omit-frame-pointer \
+                           -fno-strict-aliasing
+
+TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -O0 \
+                             -UNDEBUG \
+                             -marm \
+                             -fno-omit-frame-pointer
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+#
+TARGET-process-src-files-tags = \
+$(eval __arm_sources := $(call get-src-files-with-tag,arm)) \
+$(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, \
+    $(call set_intersection,$(__arm_sources),$(__debug_sources)), \
+    $(TARGET_arm_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__arm_sources),$(__release_sources)),\
+    $(TARGET_arm_release_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__arm_sources),$(__debug_sources)),\
+    $(TARGET_arm_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__thumb_sources),$(__release_sources)),\
+    $(TARGET_thumb_release_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\
+    $(TARGET_thumb_debug_CFLAGS)) \
+$(call add-src-files-target-cflags,\
+    $(call get-src-files-with-tag,neon),\
+    $(TARGET_CFLAGS.neon)) \
+$(call set-src-files-text,$(__arm_sources),arm$(space)$(space)) \
+$(call set-src-files-text,$(__thumb_sources),thumb)
diff --git a/toolchains/mipsel-linux-android-clang3.2/config.mk b/toolchains/mipsel-linux-android-clang3.2/config.mk
new file mode 100644
index 0000000..34e354b
--- /dev/null
+++ b/toolchains/mipsel-linux-android-clang3.2/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the mipsel llvm-3.2 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := mips
+TOOLCHAIN_ABIS := mips
diff --git a/toolchains/mipsel-linux-android-clang3.2/setup.mk b/toolchains/mipsel-linux-android-clang3.2/setup.mk
new file mode 100644
index 0000000..84793d2
--- /dev/null
+++ b/toolchains/mipsel-linux-android-clang3.2/setup.mk
@@ -0,0 +1,92 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the mipsel llvm-3.2
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+#
+# Override the toolchain prefix
+#
+
+LLVM_VERSION := 3.2
+LLVM_NAME := llvm-$(LLVM_VERSION)
+LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME)
+LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(LLVM_TOOLCHAIN_ROOT))
+LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
+
+TOOLCHAIN_VERSION := 4.6
+TOOLCHAIN_NAME := mipsel-linux-android-$(TOOLCHAIN_VERSION)
+TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
+TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
+TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/mipsel-linux-android-
+
+TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
+TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
+
+#
+# CFLAGS, C_INCLUDES, and LDFLAGS
+#
+
+LLVM_TRIPLE := mipsel-none-linux-android
+
+TARGET_CFLAGS := \
+        -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+        -target $(LLVM_TRIPLE) \
+        -fpic \
+        -fno-strict-aliasing \
+        -finline-functions \
+        -ffunction-sections \
+        -funwind-tables \
+        -fmessage-length=0 \
+        -no-canonical-prefixes
+
+TARGET_LDFLAGS := \
+        -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+        -target $(LLVM_TRIPLE) \
+        -no-canonical-prefixes
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+TARGET_mips_release_CFLAGS := -O2 \
+                              -g \
+                              -DNDEBUG \
+                              -fomit-frame-pointer
+
+TARGET_mips_debug_CFLAGS := -O0 \
+                            -g \
+                            -fno-omit-frame-pointer
+
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+TARGET-process-src-files-tags = \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, \
+    $(__debug_sources),\
+    $(TARGET_mips_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(__release_sources),\
+    $(TARGET_mips_release_CFLAGS)) \
+$(call set-src-files-text,$(__debug_sources),mips$(space)) \
+$(call set-src-files-text,$(__release_sources),mips$(space)) \
diff --git a/toolchains/x86-clang3.2/config.mk b/toolchains/x86-clang3.2/config.mk
new file mode 100644
index 0000000..ccae85f
--- /dev/null
+++ b/toolchains/x86-clang3.2/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the x86 clang-3.2 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := x86
+TOOLCHAIN_ABIS := x86
diff --git a/toolchains/x86-clang3.2/setup.mk b/toolchains/x86-clang3.2/setup.mk
new file mode 100644
index 0000000..e95135e
--- /dev/null
+++ b/toolchains/x86-clang3.2/setup.mk
@@ -0,0 +1,90 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the x86 llvm-3.2
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+#
+# Override the toolchain prefix
+#
+
+LLVM_VERSION := 3.2
+LLVM_NAME := llvm-$(LLVM_VERSION)
+LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME)
+LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(LLVM_TOOLCHAIN_ROOT))
+LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
+
+TOOLCHAIN_VERSION := 4.6
+TOOLCHAIN_NAME := x86-$(TOOLCHAIN_VERSION)
+TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
+TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
+TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/i686-linux-android-
+
+TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
+TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
+
+LLVM_TRIPLE := i686-none-linux-android
+
+TARGET_CFLAGS := \
+    -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+    -target $(LLVM_TRIPLE) \
+    -ffunction-sections \
+    -funwind-tables \
+    -fstack-protector \
+    -fPIC \
+    -no-canonical-prefixes
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+# Add and LDFLAGS for the target here
+TARGET_LDFLAGS := \
+    -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
+    -target $(LLVM_TRIPLE) \
+    -no-canonical-prefixes
+
+TARGET_x86_release_CFLAGS := -O2 \
+                             -g \
+                             -DNDEBUG \
+                             -fomit-frame-pointer \
+                             -fstrict-aliasing
+
+# When building for debug, compile everything as x86.
+TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
+                           -fno-omit-frame-pointer \
+                           -fno-strict-aliasing
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+#
+TARGET-process-src-files-tags = \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_x86_debug_CFLAGS)) \
+$(call set-src-files-target-cflags, $(__release_sources),$(TARGET_x86_release_CFLAGS)) \
+$(call set-src-files-text,$(LOCAL_SRC_FILES),x86$(space)$(space)) \
+
+# The ABI-specific sub-directory that the SDK tools recognize for
+# this toolchain's generated binaries
+TARGET_ABI_SUBDIR := x86