[CRIU] [PATCH 05/10] nmk: build.mk -- Drop any-match rule

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 24 11:25:37 PDT 2016


From: Cyrill Gorcunov <gorcunov at gmail.com>

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 scripts/nmk/scripts/build.mk | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/scripts/nmk/scripts/build.mk b/scripts/nmk/scripts/build.mk
index 472eb4ecf9f5..baf469283982 100644
--- a/scripts/nmk/scripts/build.mk
+++ b/scripts/nmk/scripts/build.mk
@@ -14,6 +14,7 @@ lib-name	:=
 ld_flags	:=
 cleanup-y	:=
 mrproper-y	:=
+objdirs		:=
 
 MAKECMDGOALS := $(call uniq,$(MAKECMDGOALS))
 
@@ -57,10 +58,6 @@ $(1).d: $(2).S $(3)
 	$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-asflags)) $(5) $$< -o $$@
 endef
 
-#
-# Expand early which matched all implicits.
-$(eval $(call gen-cc-rules,%,%))
-
 src-makefile	:= $(call objectify,$(makefile))
 include $(src-makefile)
 
@@ -103,6 +100,7 @@ ifneq ($(lib-y),)
         cleanup-y += $(call cleanify,$(lib-y))
         cleanup-y += $(lib-target)
         all-y += $(lib-target)
+        objdirs += $(dir $(lib-y))
 endif
 
 ifneq ($(obj-y),)
@@ -115,6 +113,7 @@ ifneq ($(obj-y),)
         cleanup-y += $(call cleanify,$(obj-y))
         cleanup-y += $(builtin-target)
         all-y += $(builtin-target)
+        objdirs += $(dir $(obj-y))
 endif
 
 #
@@ -163,6 +162,7 @@ define gen-custom-target-rule
                 all-y += $(obj)/$(1).built-in.o
                 cleanup-y += $(call cleanify,$(call objectify,$($(1)-obj-y)))
                 cleanup-y += $(obj)/$(1).built-in.o
+                objdirs += $(dir $(call objectify,$($(1)-obj-y)))
         endif
         ifneq ($($(1)-lib-y),)
                 $(eval $(call gen-ar-target-rule,                       \
@@ -175,12 +175,18 @@ define gen-custom-target-rule
                 all-y += $(obj)/$(1).lib.a
                 cleanup-y += $(call cleanify,$(call objectify,$($(1)-lib-y)))
                 cleanup-y += $(obj)/$(1).lib.a
+                objdirs += $(dir $(call objectify,$($(1)-lib-y)))
         endif
 endef
 
 $(foreach t,$(target),$(eval $(call gen-custom-target-rule,$(t))))
 
 #
+# Prepare rules for dirs other than (obj)/.
+objdirs := $(patsubst %/,%,$(filter-out $(obj)/,$(call uniq,$(objdirs))))
+$(foreach t,$(objdirs),$(eval $(call gen-cc-rules,$(t)/%,$(t)/%,$(src-makefile))))
+
+#
 # Figure out if the target we're building needs deps to include.
 define collect-deps
         ifneq ($(filter-out %.d,$(1)),)
-- 
2.5.5



More information about the CRIU mailing list