build: Fix including WHOLE_STATIC_LIBRARIES in static libraries

Static libraries that include other static libraries were being incorrectly
built with .a files inside the top level .a file, as well as the .o files
that were extracted from the component .a files.  This patch fixes the
final ar call to only add .o files to the archive.

Change-Id: Ic1ff025129e3c379fa56b4da2f09e9f16ea3c4fb
diff --git a/core/definitions.mk b/core/definitions.mk
index 5768c6d..a80ae9b 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -949,7 +949,7 @@
 
 define extract-and-include-target-whole-static-libs
 $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
-	@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \
+	$(hide) echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \
 	ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\
 	rm -rf $$ldir; \
 	mkdir -p $$ldir; \
@@ -969,7 +969,8 @@
 @rm -f $@
 $(extract-and-include-target-whole-static-libs)
 @echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
-$(hide) echo $^ | xargs $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
+$(hide) echo $(filter %.o, $^) | \
+    xargs $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
 endef
 
 ###########################################################