Separate SYSROOT into SYSROOT_INC and SYSROOT_LINK

SYSROOT_INC for headers, and SYSROOT_LINK for libraries.
They point to the same directory, for now.

Also remove unused TARGET_CRTBEGIN*_O and TARGET_CRTEND*_O

Change-Id: Ifb60fb45cc19b2572d3497bcc1d224531a0817a1
diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk
index 1fa3021..e6710f2 100644
--- a/build/core/build-binary.mk
+++ b/build/core/build-binary.mk
@@ -284,11 +284,11 @@
 #
 
 # If LOCAL_LDLIBS contains anything like -l<library> then
-# prepend a -L$(SYSROOT)/usr/lib to it to ensure that the linker
+# prepend a -L$(SYSROOT_LINK)/usr/lib to it to ensure that the linker
 # looks in the right location
 #
 ifneq ($(filter -l%,$(LOCAL_LDLIBS)),)
-    LOCAL_LDLIBS := -L$(call host-path,$(SYSROOT)/usr/lib) $(LOCAL_LDLIBS)
+    LOCAL_LDLIBS := -L$(call host-path,$(SYSROOT_LINK)/usr/lib) $(LOCAL_LDLIBS)
 endif
 
 # When LOCAL_SHORT_COMMANDS is defined to 'true' we are going to write the
@@ -315,7 +315,7 @@
 $(LOCAL_BUILT_MODULE): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
 $(LOCAL_BUILT_MODULE): PRIVATE_CXX := $(TARGET_CXX)
 $(LOCAL_BUILT_MODULE): PRIVATE_CC := $(TARGET_CC)
-$(LOCAL_BUILT_MODULE): PRIVATE_SYSROOT := $(SYSROOT)
+$(LOCAL_BUILT_MODULE): PRIVATE_SYSROOT_LINK := $(SYSROOT_LINK)
 
 ifeq ($(call module-get-class,$(LOCAL_MODULE)),STATIC_LIBRARY)
 
diff --git a/build/core/default-build-commands.mk b/build/core/default-build-commands.mk
index d31bc60..c0fa87b 100644
--- a/build/core/default-build-commands.mk
+++ b/build/core/default-build-commands.mk
@@ -66,7 +66,7 @@
 $(PRIVATE_CXX) \
     -Wl,-soname,$(notdir $(LOCAL_BUILT_MODULE)) \
     -shared \
-    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT_LINK)) \
     $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
     $(PRIVATE_LDFLAGS) \
     $(PRIVATE_LDLIBS) \
@@ -77,7 +77,7 @@
 $(PRIVATE_CXX) \
     -Wl,--gc-sections \
     -Wl,-z,nocopyreloc \
-    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT_LINK)) \
     $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
     $(PRIVATE_LDFLAGS) \
     $(PRIVATE_LDLIBS) \
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index 6397772..482e45b 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -89,22 +89,14 @@
 
 TARGET_ABI := $(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)
 
-# setup sysroot-related variables. The SYSROOT point to a directory
-# that contains all public header files for a given platform, plus
-# some libraries and object files used for linking the generated
-# target files properly.
+# setup sysroot variable.
+# SYSROOT_INC points to a directory that contains all public header
+# files for a given platform, and
+# SYSROOT_LIB points to libraries and object files used for linking
+# the generated target files properly.
 #
-SYSROOT := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-$(TARGET_ARCH)
-
-TARGET_CRTBEGIN_STATIC_O  := $(SYSROOT)/usr/lib/crtbegin_static.o
-TARGET_CRTBEGIN_DYNAMIC_O := $(SYSROOT)/usr/lib/crtbegin_dynamic.o
-TARGET_CRTEND_O           := $(SYSROOT)/usr/lib/crtend_android.o
-
-# crtbegin_so.o and crtend_so.o are not available for all platforms, so
-# only define them if they are in the sysroot
-#
-TARGET_CRTBEGIN_SO_O := $(strip $(wildcard $(SYSROOT)/usr/lib/crtbegin_so.o))
-TARGET_CRTEND_SO_O   := $(strip $(wildcard $(SYSROOT)/usr/lib/crtend_so.o))
+SYSROOT_INC := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-$(TARGET_ARCH)
+SYSROOT_LINK := $(SYSROOT_INC)
 
 TARGET_PREBUILT_SHARED_LIBRARIES :=
 
@@ -166,7 +158,7 @@
 
 $(NDK_APP_GDBSETUP): PRIVATE_DST := $(NDK_APP_GDBSETUP)
 $(NDK_APP_GDBSETUP): PRIVATE_SOLIB_PATH := $(TARGET_OUT)
-$(NDK_APP_GDBSETUP): PRIVATE_SRC_DIRS := $(SYSROOT)/usr/include
+$(NDK_APP_GDBSETUP): PRIVATE_SRC_DIRS := $(SYSROOT_INC)/usr/include
 
 $(NDK_APP_GDBSETUP):
 	@ $(HOST_ECHO) "Gdbsetup       : $(call pretty-dir,$(PRIVATE_DST))"
diff --git a/toolchains/arm-linux-androideabi-4.4.3/setup.mk b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
index 2b8d344..76dbddf 100644
--- a/toolchains/arm-linux-androideabi-4.4.3/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
@@ -32,7 +32,7 @@
 TARGET_LDFLAGS :=
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
     TARGET_CFLAGS += -march=armv7-a \
diff --git a/toolchains/arm-linux-androideabi-4.6/setup.mk b/toolchains/arm-linux-androideabi-4.6/setup.mk
index ae18a4d..87129f3 100644
--- a/toolchains/arm-linux-androideabi-4.6/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.6/setup.mk
@@ -33,7 +33,7 @@
 TARGET_LDFLAGS := -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
     TARGET_CFLAGS += -march=armv7-a \
diff --git a/toolchains/arm-linux-androideabi-4.7/setup.mk b/toolchains/arm-linux-androideabi-4.7/setup.mk
index 4c343b0..ebb4774 100644
--- a/toolchains/arm-linux-androideabi-4.7/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.7/setup.mk
@@ -33,7 +33,7 @@
 TARGET_LDFLAGS := -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
     TARGET_CFLAGS += -march=armv7-a \
diff --git a/toolchains/arm-linux-androideabi-clang3.1/setup.mk b/toolchains/arm-linux-androideabi-clang3.1/setup.mk
index 9316dbb..4501bd7 100644
--- a/toolchains/arm-linux-androideabi-clang3.1/setup.mk
+++ b/toolchains/arm-linux-androideabi-clang3.1/setup.mk
@@ -59,7 +59,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
     LLVM_TRIPLE := armv7-none-linux-androideabi
diff --git a/toolchains/arm-linux-androideabi-clang3.2/setup.mk b/toolchains/arm-linux-androideabi-clang3.2/setup.mk
index 312774c..0b80829 100644
--- a/toolchains/arm-linux-androideabi-clang3.2/setup.mk
+++ b/toolchains/arm-linux-androideabi-clang3.2/setup.mk
@@ -59,7 +59,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
     LLVM_TRIPLE := armv7-none-linux-androideabi
diff --git a/toolchains/mipsel-linux-android-4.4.3/setup.mk b/toolchains/mipsel-linux-android-4.4.3/setup.mk
index 38d114d..c4c61b9 100644
--- a/toolchains/mipsel-linux-android-4.4.3/setup.mk
+++ b/toolchains/mipsel-linux-android-4.4.3/setup.mk
@@ -38,7 +38,7 @@
 TARGET_LDFLAGS :=
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
                               -g \
diff --git a/toolchains/mipsel-linux-android-4.6/setup.mk b/toolchains/mipsel-linux-android-4.6/setup.mk
index c764e92..375344c 100644
--- a/toolchains/mipsel-linux-android-4.6/setup.mk
+++ b/toolchains/mipsel-linux-android-4.6/setup.mk
@@ -39,7 +39,7 @@
 TARGET_LDFLAGS := -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
                               -g \
diff --git a/toolchains/mipsel-linux-android-4.7/setup.mk b/toolchains/mipsel-linux-android-4.7/setup.mk
index fbff3b0..0164159 100644
--- a/toolchains/mipsel-linux-android-4.7/setup.mk
+++ b/toolchains/mipsel-linux-android-4.7/setup.mk
@@ -39,7 +39,7 @@
 TARGET_LDFLAGS := -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
                               -g \
diff --git a/toolchains/mipsel-linux-android-clang3.1/setup.mk b/toolchains/mipsel-linux-android-clang3.1/setup.mk
index fb7d396..ab6a9a6 100644
--- a/toolchains/mipsel-linux-android-clang3.1/setup.mk
+++ b/toolchains/mipsel-linux-android-clang3.1/setup.mk
@@ -65,7 +65,7 @@
         -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
                               -g \
diff --git a/toolchains/mipsel-linux-android-clang3.2/setup.mk b/toolchains/mipsel-linux-android-clang3.2/setup.mk
index 84793d2..f1d96f3 100644
--- a/toolchains/mipsel-linux-android-clang3.2/setup.mk
+++ b/toolchains/mipsel-linux-android-clang3.2/setup.mk
@@ -65,7 +65,7 @@
         -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
                               -g \
diff --git a/toolchains/x86-4.4.3/setup.mk b/toolchains/x86-4.4.3/setup.mk
index 6de857e..32beac6 100644
--- a/toolchains/x86-4.4.3/setup.mk
+++ b/toolchains/x86-4.4.3/setup.mk
@@ -31,7 +31,7 @@
     -funwind-tables
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 # Add and LDFLAGS for the target here
 # TARGET_LDFLAGS :=
diff --git a/toolchains/x86-4.6/setup.mk b/toolchains/x86-4.6/setup.mk
index c52bcad..e7ebb35 100644
--- a/toolchains/x86-4.6/setup.mk
+++ b/toolchains/x86-4.6/setup.mk
@@ -32,7 +32,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 # Add and LDFLAGS for the target here
 TARGET_LDFLAGS := -no-canonical-prefixes
diff --git a/toolchains/x86-4.7/setup.mk b/toolchains/x86-4.7/setup.mk
index da26fa3..37f9735 100644
--- a/toolchains/x86-4.7/setup.mk
+++ b/toolchains/x86-4.7/setup.mk
@@ -32,7 +32,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 # Add and LDFLAGS for the target here
 TARGET_LDFLAGS := -no-canonical-prefixes
diff --git a/toolchains/x86-clang3.1/setup.mk b/toolchains/x86-clang3.1/setup.mk
index 50d0a8c..dc84db8 100644
--- a/toolchains/x86-clang3.1/setup.mk
+++ b/toolchains/x86-clang3.1/setup.mk
@@ -54,7 +54,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 # Add and LDFLAGS for the target here
 TARGET_LDFLAGS := \
diff --git a/toolchains/x86-clang3.2/setup.mk b/toolchains/x86-clang3.2/setup.mk
index e95135e..e8fd776 100644
--- a/toolchains/x86-clang3.2/setup.mk
+++ b/toolchains/x86-clang3.2/setup.mk
@@ -54,7 +54,7 @@
     -no-canonical-prefixes
 
 TARGET_C_INCLUDES := \
-    $(SYSROOT)/usr/include
+    $(SYSROOT_INC)/usr/include
 
 # Add and LDFLAGS for the target here
 TARGET_LDFLAGS := \