grab common EFI source files in arch specific dir

Rather than preparing the efi source file, we will make the symbolic
link as needed from the build location.

The `ln` command is run every time to allow to update the link in case
the source tree change location.

This patch also introduce "efi_common.mk" which allow to reuse the
common make instructions without having to duplicate them into each
arch.

And now that we have a list of common source file, we can start to
remove the links to the source files on clean.

Signed-off-by: Anthony PERARD <anthony.per...@citrix.com>
---

Notes:
    v8:
    - use symbolic link instead of making a copy of the source
    - introduce efi_common.mk
    - remove links to source file on clean
    - use -iquote for "efi.h" headers in common/efi

 xen/Makefile                 |  5 -----
 xen/arch/arm/efi/Makefile    |  4 ++--
 xen/arch/x86/Makefile        |  1 +
 xen/arch/x86/efi/Makefile    |  5 +----
 xen/common/efi/efi_common.mk | 12 ++++++++++++
 5 files changed, 16 insertions(+), 11 deletions(-)
 create mode 100644 xen/common/efi/efi_common.mk

diff --git a/xen/Makefile b/xen/Makefile
index 90e8191f51ce..2a809d577fc3 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -447,11 +447,6 @@ $(TARGET).gz: $(TARGET)
 $(TARGET): FORCE
        $(Q)$(MAKE) $(build)=tools
        $(Q)$(MAKE) $(build)=. include/xen/compile.h
-       [ -e arch/$(TARGET_ARCH)/efi ] && for f in $$(cd common/efi; echo 
*.[ch]); 
-               do test -r arch/$(TARGET_ARCH)/efi/$$f || 
-                  ln -nsf ../../../common/efi/$$f arch/$(TARGET_ARCH)/efi/; 
-               done; 
-               true
        $(Q)$(MAKE) $(build)=include all
        $(Q)$(MAKE) $(build)=arch/$(TARGET_ARCH) include
        $(Q)$(MAKE) $(build)=. arch/$(TARGET_ARCH)/include/asm/asm-offsets.h
diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile
index 1b1ed06feddc..57616a17cb03 100644
--- a/xen/arch/arm/efi/Makefile
+++ b/xen/arch/arm/efi/Makefile
@@ -1,4 +1,4 @@
-CFLAGS-y += -fshort-wchar
+include $(srctree)/common/efi/efi_common.mk
 
-obj-y += boot.init.o pe.init.o ebmalloc.o runtime.o
+obj-y += $(EFIOBJ-y)
 obj-$(CONFIG_ACPI) +=  efi-dom0.init.o
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index e8151bf4b111..eabd8d3919a4 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -79,6 +79,7 @@ endif
 
 # Allows "clean" to descend into boot/
 subdir- += boot
+subdir- += efi
 
 extra-y += asm-macros.i
 extra-y += xen.lds
diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
index ac815f02cb5e..81fda12a70ea 100644
--- a/xen/arch/x86/efi/Makefile
+++ b/xen/arch/x86/efi/Makefile
@@ -1,4 +1,4 @@
-CFLAGS-y += -fshort-wchar
+include $(srctree)/common/efi/efi_common.mk
 
 quiet_cmd_objcopy_o_ihex = OBJCOPY $@
 cmd_objcopy_o_ihex = $(OBJCOPY) -I ihex -O binary $< $@
@@ -8,9 +8,6 @@ $(obj)/%.o: $(src)/%.ihex FORCE
 
 $(obj)/boot.init.o: $(obj)/buildid.o
 
-EFIOBJ-y := boot.init.o pe.init.o ebmalloc.o runtime.o
-EFIOBJ-$(CONFIG_COMPAT) += compat.o
-
 $(call cc-option-add,cflags-stack-boundary,CC,-mpreferred-stack-boundary=4)
 $(addprefix $(obj)/,$(EFIOBJ-y)): CFLAGS-stack-boundary := 
$(cflags-stack-boundary)
 
diff --git a/xen/common/efi/efi_common.mk b/xen/common/efi/efi_common.mk
new file mode 100644
index 000000000000..d2845fd6b3c8
--- /dev/null
+++ b/xen/common/efi/efi_common.mk
@@ -0,0 +1,12 @@
+EFIOBJ-y := boot.init.o pe.init.o ebmalloc.o runtime.o
+EFIOBJ-$(CONFIG_COMPAT) += compat.o
+
+CFLAGS-y += -fshort-wchar
+CFLAGS-y += -iquote $(srctree)/common/efi
+
+$(obj)/%.c: $(abs_srctree)/common/efi/%.c FORCE
+       $(Q)ln -nfs $< $@
+
+clean-files += $(patsubst %.o,%.c, $(EFIOBJ-y:.init.o=.o) $(EFIOBJ-))
+
+.PRECIOUS: $(obj)/%.c
-- 
Anthony PERARD


Read more here: Source link