stubdom: introduce xenlibs.mk
authorAnthony PERARD <anthony.perard@citrix.com>
Fri, 25 Feb 2022 15:13:16 +0000 (15:13 +0000)
committerJulien Grall <jgrall@amazon.com>
Thu, 16 Jun 2022 15:58:50 +0000 (16:58 +0100)
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 <anthony.perard@citrix.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
stubdom/Makefile
stubdom/xenlibs.mk [new file with mode: 0644]

index 5fb5dbc341c94089b0db20231f91716ca1f641dd..fba4c977ef12b2ba0755ee191af95b8089c7921a 100644 (file)
@@ -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 (file)
index 0000000..5c8742c
--- /dev/null
@@ -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