This new makefile will be used to build libraries that provides
"Makefile.common".

At some point, we will be converting Makefile in tools/ to "subdirmk"
and stubdom build will not be able to use those new makefiles, so we
will put the necessary information for stubdom to build the xen
libraries into a new Makefile.common and xenlibs.mk will use it.
We only need to build static libraries and don't need anything else.

The check for the presence of "Makefile.common" will go aways once
there is one for all libraries used by stubdom build.

Also remove DESTDIR= from "clean" targets, we don't do installation in
this recipe so the value of DESTDIR doesn't matter.

Signed-off-by: Anthony PERARD <[email protected]>
Reviewed-by: Samuel Thibault <[email protected]>
---

Notes:
    v2:
    - reviewed

 stubdom/Makefile   |  9 +++++++--
 stubdom/xenlibs.mk | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 stubdom/xenlibs.mk

diff --git a/stubdom/Makefile b/stubdom/Makefile
index 5fb5dbc341..fba4c977ef 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -346,6 +346,7 @@ define do_links
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
   ln -sf $(dir $<)*.[ch] .; \
+  [ -e $(dir $<)Makefile.common ] && ln -sf $(dir $<)Makefile.common . ||:; \
   ln -sf $(dir $<)Makefile .
   touch $@
 endef
@@ -355,10 +356,14 @@ define BUILD_lib
  libxen$(1): libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: $$(LIBDEPS_$(1)) $$(LIBDEP_$(1))
  libs-$$(XEN_TARGET_ARCH)/$(1)/libxen$(1).a: mk-headers-$$(XEN_TARGET_ARCH) 
$$(NEWLIB_STAMPFILE) .phony
-       CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) 
CONFIG_LIBXC_MINIOS=y -C $$(@D) $$(@F)
+       CPPFLAGS="$$(TARGET_CPPFLAGS)" CFLAGS="$$(TARGET_CFLAGS)" $$(MAKE) 
CONFIG_LIBXC_MINIOS=y $$(if $$(wildcard $$(@D)/Makefile.common),-f 
$(CURDIR)/xenlibs.mk) -C $$(@D) $$(@F)
 
  clean-libxen$(1):
-       [ ! -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ] || $$(MAKE) DESTDIR= -C 
libs-$$(XEN_TARGET_ARCH)/$(1) clean
+       if [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile.common ]; then \
+           $$(MAKE) -f $(CURDIR)/xenlibs.mk -C libs-$$(XEN_TARGET_ARCH)/$(1) 
clean; \
+       elif [ -e libs-$$(XEN_TARGET_ARCH)/$(1)/Makefile ]; then \
+           $$(MAKE) -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
+       fi
 
  libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile
        $$(do_links)
diff --git a/stubdom/xenlibs.mk b/stubdom/xenlibs.mk
new file mode 100644
index 0000000000..5c8742ccf9
--- /dev/null
+++ b/stubdom/xenlibs.mk
@@ -0,0 +1,13 @@
+include $(XEN_ROOT)/tools/Rules.mk
+
+include Makefile.common
+
+LIBNAME := $(notdir $(CURDIR))
+FILENAME_$(LIBNAME) ?= xen$(LIBNAME)
+LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
+
+lib$(LIB_FILE_NAME).a: $(OBJS-y)
+       $(AR) rc $@ $^
+
+clean::
+       rm -f $(OBJS-y) lib$(LIB_FILE_NAME).a
-- 
Anthony PERARD


Reply via email to