[CRIU] [PATCH 03/10] nmk: build.mk -- Squash gen-rule-x into gen-cc-rules
Pavel Emelyanov
xemul at virtuozzo.com
Thu Mar 24 07:47:29 PDT 2016
On 03/22/2016 10:15 PM, Cyrill Gorcunov wrote:
> 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 | 44 ++++++++++----------------------------------
> 1 file changed, 10 insertions(+), 34 deletions(-)
>
> diff --git a/scripts/nmk/scripts/build.mk b/scripts/nmk/scripts/build.mk
> index 8006e73ef23a..db0f7cd8581f 100644
> --- a/scripts/nmk/scripts/build.mk
> +++ b/scripts/nmk/scripts/build.mk
> @@ -32,51 +32,33 @@ endef
>
> #
> # General rules.
> -define gen-rule-o-from-c-by-name
> +define gen-cc-rules
> $(1).o: $(2).c $(3)
> $$(call msg-cc, $$@)
> $$(Q) $$(CC) -c $$(strip $$(nmk-ccflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-i-from-c-by-name
> $(1).i: $(2).c $(3)
> $$(call msg-cc, $$@)
> $$(Q) $$(CC) -E $$(strip $$(nmk-ccflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-s-from-c-by-name
> $(1).s: $(2).c $(3)
> $$(call msg-cc, $$@)
> $$(Q) $$(CC) -S -fverbose-asm $$(strip $$(nmk-ccflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-o-from-S-by-name
> -$(1).o: $(2).S $(3)
> - $$(call msg-cc, $$@)
> - $$(Q) $$(CC) -c $$(strip $$(nmk-asflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-d-from-c-by-name
> $(1).d: $(2).c $(3)
> $$(call msg-dep, $$@)
> $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-ccflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-d-from-S-by-name
> -$(1).d: $(2).S $(3)
> - $$(call msg-dep, $$@)
> - $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-asflags)) $(4) $$< -o $$@
> -endef
> -define gen-rule-i-from-S-by-name
> +$(1).o: $(2).S $(3)
> + $$(call msg-cc, $$@)
> + $$(Q) $$(CC) -c $$(strip $$(nmk-asflags)) $(5) $$< -o $$@
> $(1).i: $(2).S $(3)
> $$(call msg-cc, $$@)
> - $$(Q) $$(CC) -E $$(strip $$(nmk-asflags)) $(4) $$< -o $$@
> + $$(Q) $$(CC) -E $$(strip $$(nmk-asflags)) $(5) $$< -o $$@
> +$(1).d: $(2).S $(3)
> + $$(call msg-dep, $$@)
> + $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(strip $$(nmk-asflags)) $(5) $$< -o $$@
> endef
>
> #
> # Expand early which matched all implicits.
> -$(eval $(call gen-rule-o-from-c-by-name,%,%))
> -$(eval $(call gen-rule-i-from-c-by-name,%,%))
> -$(eval $(call gen-rule-s-from-c-by-name,%,%))
> -$(eval $(call gen-rule-o-from-S-by-name,%,%))
> -$(eval $(call gen-rule-d-from-c-by-name,%,%))
> -$(eval $(call gen-rule-d-from-S-by-name,%,%))
> -$(eval $(call gen-rule-i-from-S-by-name,%,%))
> +$(eval $(call gen-cc-rules,%,%))
>
> src-makefile := $(call objectify,$(makefile))
> include $(src-makefile)
> @@ -106,13 +88,7 @@ ld_flags := $(strip $(LDFLAGS) $(ldflags-y))
>
> #
> # $(obj) related rules.
> -$(eval $(call gen-rule-o-from-c-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-i-from-c-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-s-from-c-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-o-from-S-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-d-from-c-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-d-from-S-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> -$(eval $(call gen-rule-i-from-S-by-name,$(obj)/%,$(obj)/%,$(src-makefile)))
> +$(eval $(call gen-cc-rules,$(obj)/%,$(obj)/%,$(src-makefile)))
Isn't it better keep the rules independently and introduce one that sticks
them all together.
More information about the CRIU
mailing list