Make the duplicate header copy warning more explicit
So that it's easier to understand which makefile is actually being used,
and which ones are being ignored.
Test: manually check the warnings on a device that sets BUILD_BROKEN_DUP_COPY_HEADERS
Change-Id: If9e29458eaa655b28e6b770d194d1da867cb8d16
diff --git a/core/Makefile b/core/Makefile
index e723ef8..32df3d4 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -75,11 +75,17 @@
has_dup_copy_headers :=
$(foreach dest,$(ALL_COPIED_HEADERS), \
$(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
- $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \
+ $(eval _src := $(lastword $(_srcs))) \
$(if $(call streq,$(_src),$(_srcs)),, \
$(warning Duplicate header copy: $(dest)) \
- $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)) \
- $(eval has_dup_copy_headers := true)) \
+ $(warning _ Using $(_src)) \
+ $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
+ $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
+ $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
+ $(warning _ Ignoring $(src)) \
+ $(warning __ from $(firstword $(_makefiles))) \
+ $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
+ $(eval has_dup_copy_headers := true)) \
$(eval $(call copy-one-header,$(_src),$(dest))))
all_copied_headers: $(ALL_COPIED_HEADERS)