Remove TARGET_LIBGCC/LIBATOMIC/LIBGCOV

Instead, use the libgcc/libatomic/libgcov from the static libraries dir,
which is provided by Soong. Copy the libraries using the Soong script if
Soong is disabled - this can be removed once USE_SOONG is removed.

Change-Id: Iad2ad20ad5c3cfc48bf1e46e594a482609098d7a
diff --git a/core/definitions.mk b/core/definitions.mk
index 57aa7b6..abc6209 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2602,6 +2602,35 @@
 
 
 ###########################################################
+## Commands to copy toolchain libraries
+###########################################################
+ifneq ($(USE_SOONG),true)
+# Used when Soong isn't defining our toolchain libraries
+# $(1): Name of library (libgcc, etc)
+define copy-toolchain-library
+$(call copy-toolchain-library-internal,\
+  $(call intermediates-dir-for,STATIC_LIBRARIES,$(1))/$(1).a,,$(1))
+ifdef TARGET_2ND_ARCH
+$(call copy-toolchain-library-internal,\
+  $(call intermediates-dir-for,STATIC_LIBRARIES,$(1),,,2ND_)/$(1).a,2ND_,$(1))
+endif
+endef
+
+# $(1): the intermediates library path
+# $(2): whether this is the 2nd target architecture
+# $(3): the name of the library without the extension
+define copy-toolchain-library-internal
+$(1): build/soong/scripts/copygcclib.sh $($(2)TARGET_CC)
+	@echo "Toolchain library: $(3)"
+	@mkdir -p $$(dir $$@)
+	$$(hide) rm -f $$@
+	$$(hide) build/soong/scripts/copygcclib.sh $$@ $($(2)TARGET_CC) $($(2)TARGET_GLOBAL_CFLAGS) -print-file-name=$(3).a
+
+$(call include-depfile,$(1).d,$(1))
+endef
+endif
+
+###########################################################
 ## Commands to call Proguard
 ###########################################################
 define transform-jar-to-proguard