From 4b455d53c139c9aa660e3cb3ac0cabdc5d17e22c Mon Sep 17 00:00:00 2001 From: Dmitrijs Ledkovs Date: Fri, 5 Jul 2013 17:28:27 +0100 Subject: [PATCH 1/2] Prefer system-wide toolchain, over local prebuilt one. Signed-off-by: Dmitrijs Ledkovs --- core/combo/TARGET_linux-arm.mk | 5 +++++ core/dumpvar.mk | 4 ++++ envsetup.sh | 31 ++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index ba2f813..26e23e7 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -42,10 +42,15 @@ endif include $(TARGET_ARCH_SPECIFIC_MAKEFILE) # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else +ifneq (,$(wildcard /usr/bin/arm-linux-androideabi-*)) +TARGET_TOOLCHAIN_ROOT := /usr/bin +TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/arm-linux-androideabi- +else ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/linaro-4.7.2 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi- endif +endif # Only define these if there's actually a gcc in there. # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it. diff --git a/core/dumpvar.mk b/core/dumpvar.mk index 82fcaeb..f1d6ac3 100644 --- a/core/dumpvar.mk +++ b/core/dumpvar.mk @@ -11,6 +11,9 @@ endif # Add the ARM toolchain bin dir if it actually exists ifeq ($(TARGET_ARCH),arm) + ifneq ($(wildcard /usr/bin/arm-linux-androideabi-*),) + ABP:=$(ABP):/usr/bin + else ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin),) # this should be copied to HOST_OUT_EXECUTABLES instead ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin @@ -20,6 +23,7 @@ ifeq ($(TARGET_ARCH),arm) # this should be copied to HOST_OUT_EXECUTABLES instead ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/linaro-4.7.2/bin endif + endif else ifeq ($(TARGET_ARCH),x86) # Add the x86 toolchain bin dir if it actually exists diff --git a/envsetup.sh b/envsetup.sh index f6c719b..9541b10 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -154,13 +154,17 @@ function setpaths() if [ -d "$gccprebuiltdir/$toolchaindir" ]; then export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir fi - # Also check for the Linaro GCC 4.7.2 and use it as default if available + # Also check for system wide GCC or Linaro GCC 4.7.2 and use it as default if available if [ "$ARCH" == "arm" ]; then - toolchaindir=arm/linaro-4.7.2/bin - if [ -d "$gccprebuiltdir/$toolchaindir" ]; then - export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir - fi + if [ -x /usr/bin/arm-linux-androideabi-gcc ]; then + export ANDROID_EABI_TOOLCHAIN=/usr/bin + else + toolchaindir=arm/linaro-4.7.2/bin + if [ -d "$gccprebuiltdir/$toolchaindir" ]; then + export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir + fi + fi fi unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH @@ -178,14 +182,19 @@ function setpaths() # No need to set ARM_EABI_TOOLCHAIN for other ARCHs ;; esac - # Also check for the Linaro GCC 4.7.2 and use it as default if available + # Also check for system wide GCC or Linaro GCC 4.7.2 and use it as default if available if [ "$ARCH" == "arm" ]; then - toolchaindir=arm/linaro-4.7.2/bin - if [ -d "$gccprebuiltdir/$toolchaindir" ]; then - export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir" - ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir" - fi + if [ -x /usr/bin/arm-linux-androideabi-gcc ]; then + export ANDROID_EABI_TOOLCHAIN=/usr/bin + ARM_EABI_TOOLCHAIN_PATH=":/usr/bin" + else + toolchaindir=arm/linaro-4.7.2/bin + if [ -d "$gccprebuiltdir/$toolchaindir" ]; then + export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir" + ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir" + fi + fi fi export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN -- 1.8.3.2