diff mbox series

[XEN,v2,25/29] tools/libs: create Makefile.common to be used by stubdom build system

Message ID 20220225151321.44126-26-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series Toolstack build system improvement, toward non-recursive makefiles | expand

Commit Message

Anthony PERARD Feb. 25, 2022, 3:13 p.m. UTC
This new "Makefile.common" is intended to be used by both tools/ and
stubdom/ build system without stubdom needed to use tools/ build
system.

It should contain the necessary list of objects and CFLAGS needed to
build a static library.

Change stubdom/ to check Makefile.common, for the linkfarm.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
---

Notes:
    v2:
    - reviewed

 stubdom/Makefile                         |  2 +-
 tools/libs/call/Makefile                 |  7 +-
 tools/libs/ctrl/Makefile                 | 45 +-----------
 tools/libs/devicemodel/Makefile          |  7 +-
 tools/libs/evtchn/Makefile               |  7 +-
 tools/libs/foreignmemory/Makefile        |  7 +-
 tools/libs/gnttab/Makefile               |  9 +--
 tools/libs/guest/Makefile                | 90 +-----------------------
 tools/libs/toolcore/Makefile             |  2 +-
 tools/libs/toollog/Makefile              |  3 +-
 tools/libs/call/Makefile.common          |  6 ++
 tools/libs/ctrl/Makefile.common          | 44 ++++++++++++
 tools/libs/devicemodel/Makefile.common   |  6 ++
 tools/libs/evtchn/Makefile.common        |  6 ++
 tools/libs/foreignmemory/Makefile.common |  6 ++
 tools/libs/gnttab/Makefile.common        |  8 +++
 tools/libs/guest/Makefile.common         | 84 ++++++++++++++++++++++
 tools/libs/toolcore/Makefile.common      |  1 +
 tools/libs/toollog/Makefile.common       |  2 +
 19 files changed, 174 insertions(+), 168 deletions(-)
 create mode 100644 tools/libs/call/Makefile.common
 create mode 100644 tools/libs/ctrl/Makefile.common
 create mode 100644 tools/libs/devicemodel/Makefile.common
 create mode 100644 tools/libs/evtchn/Makefile.common
 create mode 100644 tools/libs/foreignmemory/Makefile.common
 create mode 100644 tools/libs/gnttab/Makefile.common
 create mode 100644 tools/libs/guest/Makefile.common
 create mode 100644 tools/libs/toolcore/Makefile.common
 create mode 100644 tools/libs/toollog/Makefile.common
diff mbox series

Patch

diff --git a/stubdom/Makefile b/stubdom/Makefile
index fba4c977ef..fbc63a5063 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -365,7 +365,7 @@  define BUILD_lib
 	    $$(MAKE) -C libs-$$(XEN_TARGET_ARCH)/$(1) clean; \
 	fi
 
- libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile
+ libs-$$(XEN_TARGET_ARCH)/$(1)/stamp: $$(XEN_ROOT)/tools/libs/$(1)/Makefile.common
 	$$(do_links)
 endef
 
diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
index e5cb7c937c..103f5ad360 100644
--- a/tools/libs/call/Makefile
+++ b/tools/libs/call/Makefile
@@ -4,11 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 3
 
-OBJS-y                 += core.o buffer.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile
index 5fd06949f1..93442ab389 100644
--- a/tools/libs/ctrl/Makefile
+++ b/tools/libs/ctrl/Makefile
@@ -1,50 +1,7 @@ 
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-OBJS-y       += xc_altp2m.o
-OBJS-y       += xc_cpupool.o
-OBJS-y       += xc_domain.o
-OBJS-y       += xc_evtchn.o
-OBJS-y       += xc_gnttab.o
-OBJS-y       += xc_misc.o
-OBJS-y       += xc_flask.o
-OBJS-y       += xc_physdev.o
-OBJS-y       += xc_private.o
-OBJS-y       += xc_csched.o
-OBJS-y       += xc_csched2.o
-OBJS-y       += xc_arinc653.o
-OBJS-y       += xc_rt.o
-OBJS-y       += xc_tbuf.o
-OBJS-y       += xc_pm.o
-OBJS-y       += xc_cpu_hotplug.o
-OBJS-y       += xc_vm_event.o
-OBJS-y       += xc_vmtrace.o
-OBJS-y       += xc_monitor.o
-OBJS-y       += xc_mem_paging.o
-OBJS-y       += xc_mem_access.o
-OBJS-y       += xc_memshr.o
-OBJS-y       += xc_hcall_buf.o
-OBJS-y       += xc_foreign_memory.o
-OBJS-y       += xc_kexec.o
-OBJS-y       += xc_resource.o
-OBJS-$(CONFIG_X86) += xc_psr.o
-OBJS-$(CONFIG_X86) += xc_pagetab.o
-OBJS-$(CONFIG_Linux) += xc_linux.o
-OBJS-$(CONFIG_FreeBSD) += xc_freebsd.o
-OBJS-$(CONFIG_SunOS) += xc_solaris.o
-OBJS-$(CONFIG_NetBSD) += xc_netbsd.o
-OBJS-$(CONFIG_NetBSDRump) += xc_netbsd.o
-OBJS-$(CONFIG_MiniOS) += xc_minios.o
-OBJS-y       += xc_evtchn_compat.o
-OBJS-y       += xc_gnttab_compat.o
-OBJS-y       += xc_devicemodel_compat.o
-
-CFLAGS   += -D__XEN_TOOLS__
-CFLAGS	+= $(PTHREAD_CFLAGS)
-CFLAGS += -include $(XEN_ROOT)/tools/config.h
-
-# Needed for posix_fadvise64() in xc_linux.c
-CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
+include Makefile.common
 
 LIBHEADER := xenctrl.h xenctrl_compat.h
 PKG_CONFIG := xencontrol.pc
diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index a0a2d24f99..b70dd774e4 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -4,11 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += common.o
-OBJS-$(CONFIG_FreeBSD) += common.o
-OBJS-$(CONFIG_SunOS)   += compat.o
-OBJS-$(CONFIG_NetBSD)  += compat.o
-OBJS-$(CONFIG_MiniOS)  += compat.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
index 8208ecf650..3dad3840c6 100644
--- a/tools/libs/evtchn/Makefile
+++ b/tools/libs/evtchn/Makefile
@@ -4,11 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
index 4427435932..b70dd774e4 100644
--- a/tools/libs/foreignmemory/Makefile
+++ b/tools/libs/foreignmemory/Makefile
@@ -4,11 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 4
 
-OBJS-y                 += core.o
-OBJS-$(CONFIG_Linux)   += linux.o
-OBJS-$(CONFIG_FreeBSD) += freebsd.o
-OBJS-$(CONFIG_SunOS)   += compat.o solaris.o
-OBJS-$(CONFIG_NetBSD)  += netbsd.o
-OBJS-$(CONFIG_MiniOS)  += minios.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index 7d7aeeadff..3dad3840c6 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -4,13 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR    = 1
 MINOR    = 2
 
-OBJS-GNTTAB            += gnttab_core.o
-OBJS-GNTSHR            += gntshr_core.o
-
-OBJS-$(CONFIG_Linux)   += $(OBJS-GNTTAB) $(OBJS-GNTSHR) linux.o
-OBJS-$(CONFIG_MiniOS)  += $(OBJS-GNTTAB) gntshr_unimp.o minios.o
-OBJS-$(CONFIG_FreeBSD) += $(OBJS-GNTTAB) $(OBJS-GNTSHR) freebsd.o
-OBJS-$(CONFIG_NetBSD)  += $(OBJS-GNTTAB) $(OBJS-GNTSHR) netbsd.o
-OBJS-$(CONFIG_SunOS)   += gnttab_unimp.o gntshr_unimp.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile
index 4f2373101f..19d3ff2fdb 100644
--- a/tools/libs/guest/Makefile
+++ b/tools/libs/guest/Makefile
@@ -1,97 +1,11 @@ 
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-ifeq ($(CONFIG_LIBXC_MINIOS),y)
-# Save/restore of a domain is currently incompatible with a stubdom environment
-override CONFIG_MIGRATE := n
-endif
-
-OBJS-y += xg_private.o
-OBJS-y += xg_domain.o
-OBJS-y += xg_suspend.o
-OBJS-y += xg_resume.o
-ifeq ($(CONFIG_MIGRATE),y)
-OBJS-y += xg_sr_common.o
-OBJS-$(CONFIG_X86) += xg_sr_common_x86.o
-OBJS-$(CONFIG_X86) += xg_sr_common_x86_pv.o
-OBJS-$(CONFIG_X86) += xg_sr_restore_x86_pv.o
-OBJS-$(CONFIG_X86) += xg_sr_restore_x86_hvm.o
-OBJS-$(CONFIG_X86) += xg_sr_save_x86_pv.o
-OBJS-$(CONFIG_X86) += xg_sr_save_x86_hvm.o
-OBJS-y += xg_sr_restore.o
-OBJS-y += xg_sr_save.o
-OBJS-y += xg_offline_page.o
-else
-OBJS-y += xg_nomigrate.o
-endif
-OBJS-y       += xg_core.o
-OBJS-$(CONFIG_X86) += xg_core_x86.o
-OBJS-$(CONFIG_ARM) += xg_core_arm.o
-
-vpath %.c ../../../xen/common/libelf
-
-LIBELF_OBJS += libelf-tools.o libelf-loader.o
-LIBELF_OBJS += libelf-dominfo.o
-
-OBJS-y += $(LIBELF_OBJS)
-
-ifeq ($(CONFIG_X86),y) # Add libx86 to the build
-vpath %.c ../../../xen/lib/x86
-
-OBJS-y                 += cpuid.o msr.o policy.o
-endif
-
-# new domain builder
-OBJS-y                 += xg_dom_core.o
-OBJS-y                 += xg_dom_boot.o
-OBJS-y                 += xg_dom_elfloader.o
-OBJS-$(CONFIG_X86)     += xg_dom_bzimageloader.o
-OBJS-$(CONFIG_X86)     += xg_dom_decompress_lz4.o
-OBJS-$(CONFIG_X86)     += xg_dom_hvmloader.o
-OBJS-$(CONFIG_ARM)     += xg_dom_armzimageloader.o
-OBJS-y                 += xg_dom_binloader.o
-OBJS-y                 += xg_dom_compat_linux.o
-
-OBJS-$(CONFIG_X86)     += xg_dom_x86.o
-OBJS-$(CONFIG_X86)     += xg_cpuid_x86.o
-OBJS-$(CONFIG_ARM)     += xg_dom_arm.o
-
-ifeq ($(CONFIG_LIBXC_MINIOS),y)
-OBJS-y                 += xg_dom_decompress_unsafe.o
-OBJS-y                 += xg_dom_decompress_unsafe_bzip2.o
-OBJS-y                 += xg_dom_decompress_unsafe_lzma.o
-OBJS-y                 += xg_dom_decompress_unsafe_lzo1x.o
-OBJS-y                 += xg_dom_decompress_unsafe_xz.o
-OBJS-y                 += xg_dom_decompress_unsafe_zstd.o
-endif
-
-CFLAGS += -D__XEN_TOOLS__
-CFLAGS += -include $(XEN_ROOT)/tools/config.h
-CFLAGS += -iquote ../../../xen/common/libelf
-
-# To be able to include xc_private.h
-CFLAGS += -iquote $(XEN_libxenctrl)
-
-# Needed for posix_fadvise64() in xc_linux.c
-CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
-
-CFLAGS	+= $(PTHREAD_CFLAGS)
-CFLAGS	+= $(CFLAGS_libxentoollog)
-CFLAGS	+= $(CFLAGS_libxenevtchn)
-CFLAGS	+= $(CFLAGS_libxendevicemodel)
-
-# libxenguest includes xc_private.h, so needs this despite not using
-# this functionality directly.
-CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
-
-ifeq ($(CONFIG_MiniOS),y)
-ZLIB_CFLAGS :=
-ZLIB_LIBS :=
-endif
+include Makefile.common
 
 xg_dom_bzimageloader.o xg_dom_bzimageloader.opic: CFLAGS += $(ZLIB_CFLAGS)
 
-$(LIBELF_OBJS) $(LIBELF_OBJS:.o=.opic): CFLAGS += -Wno-pointer-sign
+$(LIBELF_OBJS:.o=.opic): CFLAGS += -Wno-pointer-sign
 
 LIBHEADER := xenguest.h
 
diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
index ce417ea648..0d92b68b3b 100644
--- a/tools/libs/toolcore/Makefile
+++ b/tools/libs/toolcore/Makefile
@@ -6,7 +6,7 @@  MINOR	= 0
 
 LIBHEADER := xentoolcore.h
 
-OBJS-y	+= handlereg.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
index c09aa02ba5..2361b8cbf1 100644
--- a/tools/libs/toollog/Makefile
+++ b/tools/libs/toollog/Makefile
@@ -4,7 +4,6 @@  include $(XEN_ROOT)/tools/Rules.mk
 MAJOR	= 1
 MINOR	= 0
 
-OBJS-y	+= xtl_core.o
-OBJS-y	+= xtl_logger_stdio.o
+include Makefile.common
 
 include $(XEN_ROOT)/tools/libs/libs.mk
diff --git a/tools/libs/call/Makefile.common b/tools/libs/call/Makefile.common
new file mode 100644
index 0000000000..85e608f8ad
--- /dev/null
+++ b/tools/libs/call/Makefile.common
@@ -0,0 +1,6 @@ 
+OBJS-y                 += core.o buffer.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
diff --git a/tools/libs/ctrl/Makefile.common b/tools/libs/ctrl/Makefile.common
new file mode 100644
index 0000000000..0a09c28fd3
--- /dev/null
+++ b/tools/libs/ctrl/Makefile.common
@@ -0,0 +1,44 @@ 
+OBJS-y       += xc_altp2m.o
+OBJS-y       += xc_cpupool.o
+OBJS-y       += xc_domain.o
+OBJS-y       += xc_evtchn.o
+OBJS-y       += xc_gnttab.o
+OBJS-y       += xc_misc.o
+OBJS-y       += xc_flask.o
+OBJS-y       += xc_physdev.o
+OBJS-y       += xc_private.o
+OBJS-y       += xc_csched.o
+OBJS-y       += xc_csched2.o
+OBJS-y       += xc_arinc653.o
+OBJS-y       += xc_rt.o
+OBJS-y       += xc_tbuf.o
+OBJS-y       += xc_pm.o
+OBJS-y       += xc_cpu_hotplug.o
+OBJS-y       += xc_vm_event.o
+OBJS-y       += xc_vmtrace.o
+OBJS-y       += xc_monitor.o
+OBJS-y       += xc_mem_paging.o
+OBJS-y       += xc_mem_access.o
+OBJS-y       += xc_memshr.o
+OBJS-y       += xc_hcall_buf.o
+OBJS-y       += xc_foreign_memory.o
+OBJS-y       += xc_kexec.o
+OBJS-y       += xc_resource.o
+OBJS-$(CONFIG_X86) += xc_psr.o
+OBJS-$(CONFIG_X86) += xc_pagetab.o
+OBJS-$(CONFIG_Linux) += xc_linux.o
+OBJS-$(CONFIG_FreeBSD) += xc_freebsd.o
+OBJS-$(CONFIG_SunOS) += xc_solaris.o
+OBJS-$(CONFIG_NetBSD) += xc_netbsd.o
+OBJS-$(CONFIG_NetBSDRump) += xc_netbsd.o
+OBJS-$(CONFIG_MiniOS) += xc_minios.o
+OBJS-y       += xc_evtchn_compat.o
+OBJS-y       += xc_gnttab_compat.o
+OBJS-y       += xc_devicemodel_compat.o
+
+CFLAGS   += -D__XEN_TOOLS__
+CFLAGS	+= $(PTHREAD_CFLAGS)
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+
+# Needed for posix_fadvise64() in xc_linux.c
+CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
diff --git a/tools/libs/devicemodel/Makefile.common b/tools/libs/devicemodel/Makefile.common
new file mode 100644
index 0000000000..a7bf7c35bb
--- /dev/null
+++ b/tools/libs/devicemodel/Makefile.common
@@ -0,0 +1,6 @@ 
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += common.o
+OBJS-$(CONFIG_FreeBSD) += common.o
+OBJS-$(CONFIG_SunOS)   += compat.o
+OBJS-$(CONFIG_NetBSD)  += compat.o
+OBJS-$(CONFIG_MiniOS)  += compat.o
diff --git a/tools/libs/evtchn/Makefile.common b/tools/libs/evtchn/Makefile.common
new file mode 100644
index 0000000000..20629f521a
--- /dev/null
+++ b/tools/libs/evtchn/Makefile.common
@@ -0,0 +1,6 @@ 
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
diff --git a/tools/libs/foreignmemory/Makefile.common b/tools/libs/foreignmemory/Makefile.common
new file mode 100644
index 0000000000..ff3b1d4f3e
--- /dev/null
+++ b/tools/libs/foreignmemory/Makefile.common
@@ -0,0 +1,6 @@ 
+OBJS-y                 += core.o
+OBJS-$(CONFIG_Linux)   += linux.o
+OBJS-$(CONFIG_FreeBSD) += freebsd.o
+OBJS-$(CONFIG_SunOS)   += compat.o solaris.o
+OBJS-$(CONFIG_NetBSD)  += netbsd.o
+OBJS-$(CONFIG_MiniOS)  += minios.o
diff --git a/tools/libs/gnttab/Makefile.common b/tools/libs/gnttab/Makefile.common
new file mode 100644
index 0000000000..759e36e1cb
--- /dev/null
+++ b/tools/libs/gnttab/Makefile.common
@@ -0,0 +1,8 @@ 
+OBJS-GNTTAB            += gnttab_core.o
+OBJS-GNTSHR            += gntshr_core.o
+
+OBJS-$(CONFIG_Linux)   += $(OBJS-GNTTAB) $(OBJS-GNTSHR) linux.o
+OBJS-$(CONFIG_MiniOS)  += $(OBJS-GNTTAB) gntshr_unimp.o minios.o
+OBJS-$(CONFIG_FreeBSD) += $(OBJS-GNTTAB) $(OBJS-GNTSHR) freebsd.o
+OBJS-$(CONFIG_NetBSD)  += $(OBJS-GNTTAB) $(OBJS-GNTSHR) netbsd.o
+OBJS-$(CONFIG_SunOS)   += gnttab_unimp.o gntshr_unimp.o
diff --git a/tools/libs/guest/Makefile.common b/tools/libs/guest/Makefile.common
new file mode 100644
index 0000000000..a026a2f662
--- /dev/null
+++ b/tools/libs/guest/Makefile.common
@@ -0,0 +1,84 @@ 
+ifeq ($(CONFIG_LIBXC_MINIOS),y)
+# Save/restore of a domain is currently incompatible with a stubdom environment
+override CONFIG_MIGRATE := n
+endif
+
+OBJS-y += xg_private.o
+OBJS-y += xg_domain.o
+OBJS-y += xg_suspend.o
+OBJS-y += xg_resume.o
+ifeq ($(CONFIG_MIGRATE),y)
+OBJS-y += xg_sr_common.o
+OBJS-$(CONFIG_X86) += xg_sr_common_x86.o
+OBJS-$(CONFIG_X86) += xg_sr_common_x86_pv.o
+OBJS-$(CONFIG_X86) += xg_sr_restore_x86_pv.o
+OBJS-$(CONFIG_X86) += xg_sr_restore_x86_hvm.o
+OBJS-$(CONFIG_X86) += xg_sr_save_x86_pv.o
+OBJS-$(CONFIG_X86) += xg_sr_save_x86_hvm.o
+OBJS-y += xg_sr_restore.o
+OBJS-y += xg_sr_save.o
+OBJS-y += xg_offline_page.o
+else
+OBJS-y += xg_nomigrate.o
+endif
+OBJS-y       += xg_core.o
+OBJS-$(CONFIG_X86) += xg_core_x86.o
+OBJS-$(CONFIG_ARM) += xg_core_arm.o
+
+vpath %.c ../../../xen/common/libelf
+
+LIBELF_OBJS += libelf-tools.o libelf-loader.o
+LIBELF_OBJS += libelf-dominfo.o
+
+OBJS-y += $(LIBELF_OBJS)
+
+ifeq ($(CONFIG_X86),y) # Add libx86 to the build
+vpath %.c ../../../xen/lib/x86
+
+OBJS-y                 += cpuid.o msr.o policy.o
+endif
+
+# new domain builder
+OBJS-y                 += xg_dom_core.o
+OBJS-y                 += xg_dom_boot.o
+OBJS-y                 += xg_dom_elfloader.o
+OBJS-$(CONFIG_X86)     += xg_dom_bzimageloader.o
+OBJS-$(CONFIG_X86)     += xg_dom_decompress_lz4.o
+OBJS-$(CONFIG_X86)     += xg_dom_hvmloader.o
+OBJS-$(CONFIG_ARM)     += xg_dom_armzimageloader.o
+OBJS-y                 += xg_dom_binloader.o
+OBJS-y                 += xg_dom_compat_linux.o
+
+OBJS-$(CONFIG_X86)     += xg_dom_x86.o
+OBJS-$(CONFIG_X86)     += xg_cpuid_x86.o
+OBJS-$(CONFIG_ARM)     += xg_dom_arm.o
+
+ifeq ($(CONFIG_LIBXC_MINIOS),y)
+OBJS-y                 += xg_dom_decompress_unsafe.o
+OBJS-y                 += xg_dom_decompress_unsafe_bzip2.o
+OBJS-y                 += xg_dom_decompress_unsafe_lzma.o
+OBJS-y                 += xg_dom_decompress_unsafe_lzo1x.o
+OBJS-y                 += xg_dom_decompress_unsafe_xz.o
+OBJS-y                 += xg_dom_decompress_unsafe_zstd.o
+endif
+
+CFLAGS += -D__XEN_TOOLS__
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+CFLAGS += -iquote ../../../xen/common/libelf
+
+# To be able to include xc_private.h
+CFLAGS += -iquote $(XEN_libxenctrl)
+
+# Needed for posix_fadvise64() in xc_linux.c
+CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
+
+CFLAGS	+= $(PTHREAD_CFLAGS)
+CFLAGS	+= $(CFLAGS_libxentoollog)
+CFLAGS	+= $(CFLAGS_libxenevtchn)
+CFLAGS	+= $(CFLAGS_libxendevicemodel)
+
+# libxenguest includes xc_private.h, so needs this despite not using
+# this functionality directly.
+CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
+
+$(LIBELF_OBJS): CFLAGS += -Wno-pointer-sign
diff --git a/tools/libs/toolcore/Makefile.common b/tools/libs/toolcore/Makefile.common
new file mode 100644
index 0000000000..9ade6c12bf
--- /dev/null
+++ b/tools/libs/toolcore/Makefile.common
@@ -0,0 +1 @@ 
+OBJS-y	+= handlereg.o
diff --git a/tools/libs/toollog/Makefile.common b/tools/libs/toollog/Makefile.common
new file mode 100644
index 0000000000..c053ac6a73
--- /dev/null
+++ b/tools/libs/toollog/Makefile.common
@@ -0,0 +1,2 @@ 
+OBJS-y	+= xtl_core.o
+OBJS-y	+= xtl_logger_stdio.o