OSDN Git Service

am 366ac666: am 2b3b1409: am 6873be9e: am 5d2265cb: am ed5ea12b: am f09c7628: am...
[android-x86/build.git] / core / distdir.mk
index e04938b..51ec46e 100644 (file)
@@ -41,6 +41,11 @@ $(2): $(1)
        $$(copy-file-to-new-target-with-cp)
 endef
 
+# A global variable to remember all dist'ed src:dst pairs.
+# So if a src:dst is already dist'ed by another goal,
+# we should just establish the dependency and don't really call the
+# copy-one-dist-file to avoid multiple rules for the same target.
+_all_dist_src_dst_pairs :=
 # Other parts of the system should use this function to associate
 # certain files with certain goals.  When those goals are built
 # and "dist" is specified, the marked files will be copied to DIST_DIR.
@@ -56,14 +61,13 @@ $(foreach file,$(2), \
   $(eval src := $(word 1,$(fw))) \
   $(eval dst := $(word 2,$(fw))) \
   $(eval dst := $(if $(dst),$(dst),$(notdir $(src)))) \
-  $(eval \
-      $(call copy-one-dist-file, \
-          $(src), \
-          $(DIST_DIR)/$(dst), \
-         $(1) \
-       ) \
-   ) \
- )
+  $(if $(filter $(_all_dist_src_dst_pairs),$(src):$(dst)),\
+    $(eval $(call add-dependency,$(1),$(DIST_DIR)/$(dst))),\
+    $(eval $(call copy-one-dist-file,\
+      $(src),$(DIST_DIR)/$(dst),$(1)))\
+      $(eval _all_dist_src_dst_pairs += $(src):$(dst))\
+  )\
+)
 endef
 
 else # !dist_goal