[CRIU] [PATCH 2/2] nmk: recompile/regenerate on Makefile changes
Dmitry Safonov
dsafonov at virtuozzo.com
Tue Jan 31 05:56:31 PST 2017
Now changes in top-Makefile, middle-Makefile will result in a correct
recompiling, as it's expected:
[criu]$ touch criu/Makefile
[criu]$ make
<...>
DEP criu/arch/x86/sigframe.d
DEP criu/arch/x86/sigaction_compat.d
DEP criu/arch/x86/crtools.d
DEP criu/arch/x86/cpu.d
DEP criu/arch/x86/call32.d
CC criu/arch/x86/call32.o
CC criu/arch/x86/cpu.o
CC criu/arch/x86/crtools.o
<...>
Reported-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
scripts/nmk/scripts/build.mk | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/scripts/nmk/scripts/build.mk b/scripts/nmk/scripts/build.mk
index 1a92ea78fc2b..e5706afa161c 100644
--- a/scripts/nmk/scripts/build.mk
+++ b/scripts/nmk/scripts/build.mk
@@ -24,6 +24,13 @@ ifndef obj
$(error obj is undefined)
endif
+ifndef __nmk-makefile-deps
+ # Add top-make - it isn't included into this build.mk
+ __nmk-makefile-deps := Makefile
+endif
+__nmk-makefile-deps += $(src-makefile)
+export __nmk-makefile-deps
+
#
# Filter out any -Wl,XXX option: some of build farms
# assumes that we're using $(CC) for building built-in
@@ -50,25 +57,25 @@ endef
#
# General rules.
define gen-cc-rules
-$(1).o: $(2).c $(src-makefile)
+$(1).o: $(2).c $(__nmk-makefile-deps)
$$(call msg-cc, $$@)
$$(Q) $$(CC) -c $$(strip $$(nmk-ccflags)) $$< -o $$@
-$(1).i: $(2).c $(src-makefile)
+$(1).i: $(2).c $(__nmk-makefile-deps)
$$(call msg-cc, $$@)
$$(Q) $$(CC) -E $$(strip $$(nmk-ccflags)) $$< -o $$@
-$(1).s: $(2).c $(src-makefile)
+$(1).s: $(2).c $(__nmk-makefile-deps)
$$(call msg-cc, $$@)
$$(Q) $$(CC) -S -fverbose-asm $$(strip $$(nmk-ccflags)) $$< -o $$@
-$(1).d: $(2).c $(src-makefile)
+$(1).d: $(2).c $(__nmk-makefile-deps)
$$(call msg-dep, $$@)
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-ccflags)) $$< -o $$@
-$(1).o: $(2).S $(src-makefile)
+$(1).o: $(2).S $(__nmk-makefile-deps)
$$(call msg-cc, $$@)
$$(Q) $$(CC) -c $$(strip $$(nmk-asflags)) $$< -o $$@
-$(1).i: $(2).S $(src-makefile)
+$(1).i: $(2).S $(__nmk-makefile-deps)
$$(call msg-cc, $$@)
$$(Q) $$(CC) -E $$(strip $$(nmk-asflags)) $$< -o $$@
-$(1).d: $(2).S $(src-makefile)
+$(1).d: $(2).S $(__nmk-makefile-deps)
$$(call msg-dep, $$@)
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-asflags)) $$< -o $$@
endef
@@ -150,7 +157,7 @@ ifdef builtin-target
$(eval $(call gen-ld-target-rule, \
$(builtin-target), \
$(ld_flags), \
- $(obj-y) $(src-makefile), \
+ $(obj-y) $(__nmk-makefile-deps), \
$(obj-y) $(call objectify,$(obj-e))))
endif
@@ -158,7 +165,7 @@ ifdef lib-target
$(eval $(call gen-ar-target-rule, \
$(lib-target), \
$(ARFLAGS) $(arflags-y), \
- $(lib-y) $(src-makefile), \
+ $(lib-y) $(__nmk-makefile-deps), \
$(lib-y) $(call objectify,$(lib-e))))
endif
@@ -170,7 +177,7 @@ define gen-custom-target-rule
$(obj)/$(1).built-in.o, \
$(ld_flags) $(LDFLAGS_$(1)), \
$(call objectify,$($(1)-obj-y)) \
- $(src-makefile), \
+ $(__nmk-makefile-deps), \
$(call objectify,$($(1)-obj-y)) \
$(call objectify,$($(1)-obj-e))))
all-y += $(obj)/$(1).built-in.o
@@ -183,7 +190,7 @@ define gen-custom-target-rule
$(obj)/$(1).lib.a, \
$(ARFLAGS) $($(1)-arflags-y), \
$(call objectify,$($(1)-lib-y)) \
- $(src-makefile), \
+ $(__nmk-makefile-deps), \
$(call objectify,$($(1)-lib-y))) \
$(call objectify,$($(1)-lib-e)))
all-y += $(obj)/$(1).lib.a
@@ -203,16 +210,16 @@ $(foreach t,$(objdirs),$(eval $(call gen-cc-rules,$(t)/%,$(t)/%)))
#
# Host programs.
define gen-host-cc-rules
-$(addprefix $(obj)/,$(1)): $(obj)/%.o: $(obj)/%.c $(src-makefile)
+$(addprefix $(obj)/,$(1)): $(obj)/%.o: $(obj)/%.c $(__nmk-makefile-deps)
$$(call msg-host-cc, $$@)
$$(Q) $$(HOSTCC) -c $$(strip $$(nmk-host-ccflags)) $$< -o $$@
-$(patsubst %.o,%.i,$(addprefix $(obj)/,$(1))): $(obj)/%.i: $(obj)/%.c $(src-makefile)
+$(patsubst %.o,%.i,$(addprefix $(obj)/,$(1))): $(obj)/%.i: $(obj)/%.c $(__nmk-makefile-deps)
$$(call msg-host-cc, $$@)
$$(Q) $$(HOSTCC) -E $$(strip $$(nmk-host-ccflags)) $$< -o $$@
-$(patsubst %.o,%.s,$(addprefix $(obj)/,$(1))): $(obj)/%.s: $(obj)/%.c $(src-makefile)
+$(patsubst %.o,%.s,$(addprefix $(obj)/,$(1))): $(obj)/%.s: $(obj)/%.c $(__nmk-makefile-deps)
$$(call msg-host-cc, $$@)
$$(Q) $$(HOSTCC) -S -fverbose-asm $$(strip $$(nmk-host-ccflags)) $$< -o $$@
-$(patsubst %.o,%.d,$(addprefix $(obj)/,$(1))): $(obj)/%.d: $(obj)/%.c $(src-makefile)
+$(patsubst %.o,%.d,$(addprefix $(obj)/,$(1))): $(obj)/%.d: $(obj)/%.c $(__nmk-makefile-deps)
$$(call msg-host-dep, $$@)
$$(Q) $$(HOSTCC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-host-ccflags)) $$< -o $$@
endef
@@ -221,7 +228,7 @@ define gen-host-rules
$(eval $(call gen-host-cc-rules,$($(1)-objs)))
all-y += $(addprefix $(obj)/,$($(1)-objs))
cleanup-y += $(call cleanify,$(addprefix $(obj)/,$($(1)-objs)))
-$(obj)/$(1): $(addprefix $(obj)/,$($(1)-objs)) $(src-makefile)
+$(obj)/$(1): $(addprefix $(obj)/,$($(1)-objs)) $(__nmk-makefile-deps)
$$(call msg-host-link, $$@)
$$(Q) $$(HOSTCC) $$(HOSTCFLAGS) $(addprefix $(obj)/,$($(1)-objs)) $$(HOSTLDFLAGS) $$(HOSTLDFLAGS_$$(@F)) -o $$@
all-y += $(obj)/$(1)
@@ -232,7 +239,7 @@ $(foreach t,$(hostprogs-y),$(eval $(call gen-host-rules,$(t))))
#
# Dynamic library linking.
define gen-so-link-rules
-$(call objectify,$(1)).so: $(call objectify,$($(1)-objs)) $(src-makefile)
+$(call objectify,$(1)).so: $(call objectify,$($(1)-objs)) $(__nmk-makefile-deps)
$$(call msg-link, $$@)
$$(Q) $$(CC) -shared $$(ldflags-so) $$(LDFLAGS) $$(LDFLAGS_$$(@F)) -o $$@ $(call objectify,$($(1)-objs))
all-y += $(call objectify,$(1)).so
--
2.11.0
More information about the CRIU
mailing list