diff mbox series

[RFC,XEN,13/23] convert common/libelf/Makefile to kbuild makefile

Message ID 20191023164837.2700240-14-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series Kconfig update + WIP of using Kbuild | expand

Commit Message

Anthony PERARD Oct. 23, 2019, 4:48 p.m. UTC
Use existing command line of objcopy and ld instead of writing new one
and simply edit the flags.

`targets' is to let know kbuild that other files beside the one
declared in obj-bin-y will be built.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/common/libelf/Makefile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 9a433f01fbd4..2be9ea82b241 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -4,9 +4,14 @@  nocov-y += libelf.o
 SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
 
 ccflags-y += -Wno-pointer-sign
+ldflags-y += -r
+OBJCOPYFLAGS += $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
 
-libelf.o: libelf-temp.o Makefile
-	$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+libelf-temp-objs := libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
+targets += $(libelf-temp-objs) libelf-temp.o
 
-libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
-	$(LD) $(LDFLAGS) -r -o $@ $^
+$(obj)/libelf.o: $(obj)/libelf-temp.o FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/libelf-temp.o: $(addprefix $(obj)/,$(libelf-temp-objs)) FORCE
+	$(call if_changed,ld)