Commit 764f0781 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

make: Extend rules macros to pick sources from variable

This will allow us to generate rules where source
for object file is laying in some extenal directory
but compiled one is to be kept in some other directory.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 74070c84
......@@ -17,19 +17,19 @@ include $(obj)/$(makefile)
##
## Generate a bundle of rules for C files
define gen-target-c-bundle
$(eval $(call gen-rule-o-from-c-by-name,$(1),$(2)))
$(eval $(call gen-rule-i-from-c-by-name,$(1),$(2)))
$(eval $(call gen-rule-d-from-c-by-name,$(1),$(2)))
$(eval $(call gen-rule-s-from-c-by-name,$(1),$(2)))
$(eval $(call gen-rule-o-from-c-by-name,$(1),$(2),$(3)))
$(eval $(call gen-rule-i-from-c-by-name,$(1),$(2),$(3)))
$(eval $(call gen-rule-d-from-c-by-name,$(1),$(2),$(3)))
$(eval $(call gen-rule-s-from-c-by-name,$(1),$(2),$(3)))
endef
##
##
## Generate a bundle of rules for S files
define gen-target-S-bundle
$(eval $(call gen-rule-o-from-S-by-name,$(1),$(2)))
$(eval $(call gen-rule-d-from-S-by-name,$(1),$(2)))
$(eval $(call gen-rule-i-from-S-by-name,$(1),$(2)))
$(eval $(call gen-rule-o-from-S-by-name,$(1),$(2),$(3)))
$(eval $(call gen-rule-d-from-S-by-name,$(1),$(2),$(3)))
$(eval $(call gen-rule-i-from-S-by-name,$(1),$(2),$(3)))
endef
##
......@@ -41,7 +41,7 @@ $(foreach file, \
$(obj-y), \
$(eval \
$(call gen-target-c-bundle, \
$(file:.o=))))
$(file:.o=),$(file:.o=))))
all-objs += $(obj-y)
deps += $(obj-y:.o=.d)
endif
......@@ -51,7 +51,7 @@ $(foreach file, \
$(obj-e), \
$(eval \
$(call gen-target-c-bundle, \
$(file:.o=))))
$(file:.o=),$(file:.o=))))
all-objs += $(obj-e)
deps += $(obj-e:.o=.d)
endif
......@@ -62,7 +62,7 @@ $(foreach file, \
$(asm-y), \
$(eval \
$(call gen-target-S-bundle, \
$(file:.o=))))
$(file:.o=),$(file:.o=))))
all-objs += $(asm-y)
deps += $(asm-y:.o=.d)
endif
......@@ -72,7 +72,7 @@ $(foreach file, \
$(asm-e), \
$(eval \
$(call gen-target-S-bundle, \
$(file:.o=))))
$(file:.o=),$(file:.o=))))
all-objs += $(asm-e)
deps += $(asm-e:.o=.d)
endif
......@@ -89,6 +89,7 @@ ifneq ($($(1)-obj-y),)
$($(1)-obj-y), \
$(eval \
$(call gen-target-c-bundle, \
$(obj)/$(file:.o=), \
$(obj)/$(file:.o=), \
$($(1)-obj-y-cflags))))
$(1)-all-objs += $$(addprefix $(obj)/, $($(1)-obj-y))
......@@ -100,6 +101,7 @@ ifneq ($($(1)-obj-e),)
$($(1)-obj-e), \
$(eval \
$(call gen-target-c-bundle, \
$(file:.o=), \
$(file:.o=), \
$($(1)-obj-e-cflags))))
$(1)-all-objs += $$($(1)-obj-e)
......@@ -111,6 +113,7 @@ ifneq ($($(1)-asm-y),)
$($(1)-asm-y), \
$(eval \
$(call gen-target-S-bundle, \
$(obj)/$(file:.o=), \
$(obj)/$(file:.o=), \
$($(1)-asm-y-asmflags))))
$(1)-all-objs += $$(addprefix $(obj)/, $($(1)-asm-y))
......@@ -122,6 +125,7 @@ ifneq ($($(1)-asm-e),)
$($(1)-asm-e), \
$(eval \
$(call gen-target-S-bundle, \
$(file:.o=), \
$(file:.o=), \
$($(1)-asm-e-asmflags))))
$(1)-all-objs += $$($(1)-asm-e)
......
......@@ -3,45 +3,45 @@
## These are per-file generators.
##
define gen-rule-o-from-c-by-name
$(1).o: $(1).c
$(2).o: $(1).c
$$(E) " CC " $$@
$$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@
$$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(3) $$< -o $$@
endef
define gen-rule-i-from-c-by-name
$(1).i: $(1).c
$(2).i: $(1).c
$$(E) " CC " $$@
$$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@
$$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(3) $$< -o $$@
endef
define gen-rule-s-from-c-by-name
$(1).s: $(1).c
$(2).s: $(1).c
$$(E) " CC " $$@
$$(Q) $$(CC) -S $$(CFLAGS) $$(cflags-y) $(2) -fverbose-asm $$< -o $$@
$$(Q) $$(CC) -S $$(CFLAGS) $$(cflags-y) $(3) -fverbose-asm $$< -o $$@
endef
define gen-rule-o-from-S-by-name
$(1).o: $(1).S
$(2).o: $(1).S
$$(E) " CC " $$@
$$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(2) $$(ASMFLAGS) $(3) $$< -o $$@
$$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(3) $$(ASMFLAGS) $(4) $$< -o $$@
endef
define gen-rule-d-from-c-by-name
$(1).d: $(1).c
$(2).d: $(1).c
$$(E) " DEP " $$@
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(3) $$< -o $$@
endef
define gen-rule-d-from-S-by-name
$(1).d: $(1).S
$(2).d: $(1).S
$$(E) " DEP " $$@
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@
$$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(3) $$< -o $$@
endef
define gen-rule-i-from-S-by-name
$(1).i: $(1).S
$(2).i: $(1).S
$$(E) " CC " $$@
$$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@
$$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(3) $$< -o $$@
endef
##
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment