De-duplicate kernel module names

If BOARD_KERNEL_MODULES_16K contains duplicate kernel modules under
different directories, build will fail with 'multiple overriding
commands error' . To fix it, de-dup BOARD_KERNEL_MODULES_16K base on the
basename of kernel modules files.

Test: th
Change-Id: I45d850d5b3804c54b9ec0133d3a657c2db5adb17
diff --git a/core/Makefile b/core/Makefile
index a190a3d..d371fb8 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1065,6 +1065,18 @@
 
 endif
 
+# BOARD_KERNEL_MODULES_16K might contain duplicate modules under different path.
+# for example, foo/bar/wifi.ko and foo/wifi.ko . To avoid build issues, de-dup
+# module list on basename first.
+BOARD_KERNEL_MODULES_16K := $(foreach \
+  pattern,\
+  $(sort $(foreach \
+    path,\
+    $(BOARD_KERNEL_MODULES_16K),\
+    %/$(notdir $(path)))\
+  ),\
+  $(firstword $(filter $(pattern),$(BOARD_KERNEL_MODULES_16K))) \
+)
 # For non-GKI modules, strip them before install. As debug symbols take up
 # significant space.
 $(foreach \