All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH I v2 0/6] tools: streamline tools/libs/ building
@ 2020-08-15 13:03 Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 1/6] stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS Juergen Gross
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Samuel Thibault, Ian Jackson, Wei Liu,
	George Dunlap, Nick Rosbrook, Andrew Cooper, Jan Beulich,
	Julien Grall, Stefano Stabellini, Anthony PERARD

Generate many make variables automatically instead of having to
reiterate common patterns multiple times.

This is part I of a larger series. The previous version included the
move of multiple other libraries below tools/libs. In V2 I have
decided to split the series up, as this makes it easier to commit
some parts early.

Part I just contains some cleanup work and the automatic generation
of the make variables, without moving any other libraries under
tools/libs.

Patches 1-5 can go in independently from each other, just patch 6
depends on some of the first 5 patches.

The other parts will be sent out later, moving more libraries.

Changes in V2:
- split series up in multiple parts, part I containing only patches
  1-5 and 12 of the series V1
- eliminate the LIBNAME variable from tools/libs/*/Makefile (patch 6)

Juergen Gross (6):
  stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS
  tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*)
  tools: add a copy of library headers in tools/include
  tools: don't call make recursively from libs.mk
  tools: define ROUNDUP() in tools/include/xen-tools/libs.h
  tools: generate most contents of library make variables

 .gitignore                        |   1 +
 stubdom/mini-os.mk                |  17 ++++
 tools/Rules.mk                    | 134 ++++++++++++------------------
 tools/console/daemon/io.c         |   6 +-
 tools/golang/xenlight/Makefile    |   4 +-
 tools/include/xen-tools/libs.h    |   4 +
 tools/libs/call/Makefile          |   4 +-
 tools/libs/call/buffer.c          |   3 +-
 tools/libs/devicemodel/Makefile   |   4 +-
 tools/libs/evtchn/Makefile        |   4 +-
 tools/libs/foreignmemory/Makefile |   4 +-
 tools/libs/foreignmemory/linux.c  |   3 +-
 tools/libs/gnttab/Makefile        |   4 +-
 tools/libs/gnttab/private.h       |   3 -
 tools/libs/hypfs/Makefile         |   4 +-
 tools/libs/libs.mk                |  37 +++++++--
 tools/libs/toolcore/Makefile      |   3 +-
 tools/libs/toollog/Makefile       |   3 +-
 tools/libvchan/Makefile           |   2 +-
 tools/libxc/Makefile              |   2 +-
 tools/libxc/xg_private.h          |   1 -
 tools/libxl/libxl_internal.h      |   3 -
 tools/xenstat/libxenstat/Makefile |   2 +-
 tools/xenstore/Makefile           |   2 +-
 tools/xenstore/xenstored_core.c   |   2 -
 25 files changed, 119 insertions(+), 137 deletions(-)
 create mode 100644 stubdom/mini-os.mk

-- 
2.26.2



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH I v2 1/6] stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*) Juergen Gross
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Samuel Thibault

stubdom/mini-os.mk should contain paths used by Mini-OS when built as
stubdom.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 stubdom/mini-os.mk | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 stubdom/mini-os.mk

diff --git a/stubdom/mini-os.mk b/stubdom/mini-os.mk
new file mode 100644
index 0000000000..32528bb91f
--- /dev/null
+++ b/stubdom/mini-os.mk
@@ -0,0 +1,17 @@
+# Included by Mini-OS stubdom builds to set variables depending on Xen
+# internal paths.
+#
+# Input variables are:
+# XEN_ROOT
+# MINIOS_TARGET_ARCH
+
+XENSTORE_CPPFLAGS = -isystem $(XEN_ROOT)/tools/xenstore/include
+TOOLCORE_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toolcore
+TOOLLOG_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog
+EVTCHN_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn
+GNTTAB_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab
+CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
+FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
+DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
+CTRL_PATH = $(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH)
+GUEST_PATH = $(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*)
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 1/6] stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-27 10:14   ` Wei Liu
  2020-08-15 13:03 ` [PATCH I v2 3/6] tools: add a copy of library headers in tools/include Juergen Gross
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Ian Jackson, Wei Liu, George Dunlap, Nick Rosbrook

In order to harmonize names of library related make variables switch
XEN_LIBXEN* names to XEN_libxen*, as all other related variables (e.g.
CFLAGS_libxen*, SHDEPS_libxen*, ...) already use this pattern.

Rename XEN_LIBXC to XEN_libxenctrl, XEN_XENSTORE to XEN_libxenstore,
XEN_XENLIGHT to XEN_libxenlight, XEN_XLUTIL to XEN_libxlutil, and
XEN_LIBVCHAN to XEN_libxenvchan for the same reason.

Introduce XEN_libxenguest with the same value as XEN_libxenctrl.

No functional change.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/Rules.mk                    | 120 +++++++++++++++---------------
 tools/golang/xenlight/Makefile    |   4 +-
 tools/libs/call/Makefile          |   2 +-
 tools/libs/devicemodel/Makefile   |   2 +-
 tools/libs/evtchn/Makefile        |   2 +-
 tools/libs/foreignmemory/Makefile |   2 +-
 tools/libs/gnttab/Makefile        |   2 +-
 tools/libs/hypfs/Makefile         |   2 +-
 tools/libs/toolcore/Makefile      |   2 +-
 tools/libs/toollog/Makefile       |   2 +-
 tools/libvchan/Makefile           |   2 +-
 tools/libxc/Makefile              |   2 +-
 tools/xenstat/libxenstat/Makefile |   2 +-
 tools/xenstore/Makefile           |   2 +-
 14 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 5ed5664bf7..b42e50ebf6 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -12,21 +12,23 @@ INSTALL = $(XEN_ROOT)/tools/cross-install
 LDFLAGS += $(PREPEND_LDFLAGS_XEN_TOOLS)
 
 XEN_INCLUDE        = $(XEN_ROOT)/tools/include
-XEN_LIBXENTOOLCORE  = $(XEN_ROOT)/tools/libs/toolcore
-XEN_LIBXENTOOLLOG  = $(XEN_ROOT)/tools/libs/toollog
-XEN_LIBXENEVTCHN   = $(XEN_ROOT)/tools/libs/evtchn
-XEN_LIBXENGNTTAB   = $(XEN_ROOT)/tools/libs/gnttab
-XEN_LIBXENCALL     = $(XEN_ROOT)/tools/libs/call
-XEN_LIBXENFOREIGNMEMORY = $(XEN_ROOT)/tools/libs/foreignmemory
-XEN_LIBXENDEVICEMODEL = $(XEN_ROOT)/tools/libs/devicemodel
-XEN_LIBXENHYPFS    = $(XEN_ROOT)/tools/libs/hypfs
-XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
-XEN_XENLIGHT       = $(XEN_ROOT)/tools/libxl
+XEN_libxentoolcore = $(XEN_ROOT)/tools/libs/toolcore
+XEN_libxentoollog  = $(XEN_ROOT)/tools/libs/toollog
+XEN_libxenevtchn   = $(XEN_ROOT)/tools/libs/evtchn
+XEN_libxengnttab   = $(XEN_ROOT)/tools/libs/gnttab
+XEN_libxencall     = $(XEN_ROOT)/tools/libs/call
+XEN_libxenforeignmemory = $(XEN_ROOT)/tools/libs/foreignmemory
+XEN_libxendevicemodel = $(XEN_ROOT)/tools/libs/devicemodel
+XEN_libxenhypfs    = $(XEN_ROOT)/tools/libs/hypfs
+XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
+# Currently libxenguest lives in the same directory as libxenctrl
+XEN_libxenguest    = $(XEN_libxenctrl)
+XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
-XEN_XLUTIL         = $(XEN_XENLIGHT)
-XEN_XENSTORE       = $(XEN_ROOT)/tools/xenstore
-XEN_LIBXENSTAT     = $(XEN_ROOT)/tools/xenstat/libxenstat/src
-XEN_LIBVCHAN       = $(XEN_ROOT)/tools/libvchan
+XEN_libxlutil      = $(XEN_libxenlight)
+XEN_libxenstore    = $(XEN_ROOT)/tools/xenstore
+XEN_libxenstat     = $(XEN_ROOT)/tools/xenstat/libxenstat/src
+XEN_libxenvchan    = $(XEN_ROOT)/tools/libvchan
 
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
@@ -97,75 +99,75 @@ endif
 # Consumers of libfoo should not directly use $(SHDEPS_libfoo) or
 # $(SHLIB_libfoo)
 
-CFLAGS_libxentoollog = -I$(XEN_LIBXENTOOLLOG)/include $(CFLAGS_xeninclude)
+CFLAGS_libxentoollog = -I$(XEN_libxentoollog)/include $(CFLAGS_xeninclude)
 SHDEPS_libxentoollog =
-LDLIBS_libxentoollog = $(SHDEPS_libxentoollog) $(XEN_LIBXENTOOLLOG)/libxentoollog$(libextension)
-SHLIB_libxentoollog  = $(SHDEPS_libxentoollog) -Wl,-rpath-link=$(XEN_LIBXENTOOLLOG)
+LDLIBS_libxentoollog = $(SHDEPS_libxentoollog) $(XEN_libxentoollog)/libxentoollog$(libextension)
+SHLIB_libxentoollog  = $(SHDEPS_libxentoollog) -Wl,-rpath-link=$(XEN_libxentoollog)
 
-CFLAGS_libxentoolcore = -I$(XEN_LIBXENTOOLCORE)/include $(CFLAGS_xeninclude)
+CFLAGS_libxentoolcore = -I$(XEN_libxentoolcore)/include $(CFLAGS_xeninclude)
 SHDEPS_libxentoolcore =
-LDLIBS_libxentoolcore = $(SHDEPS_libxentoolcore) $(XEN_LIBXENTOOLCORE)/libxentoolcore$(libextension)
-SHLIB_libxentoolcore  = $(SHDEPS_libxentoolcore) -Wl,-rpath-link=$(XEN_LIBXENTOOLCORE)
+LDLIBS_libxentoolcore = $(SHDEPS_libxentoolcore) $(XEN_libxentoolcore)/libxentoolcore$(libextension)
+SHLIB_libxentoolcore  = $(SHDEPS_libxentoolcore) -Wl,-rpath-link=$(XEN_libxentoolcore)
 
-CFLAGS_libxenevtchn = -I$(XEN_LIBXENEVTCHN)/include $(CFLAGS_xeninclude)
+CFLAGS_libxenevtchn = -I$(XEN_libxenevtchn)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenevtchn = $(SHLIB_libxentoolcore)
-LDLIBS_libxenevtchn = $(SHDEPS_libxenevtchn) $(XEN_LIBXENEVTCHN)/libxenevtchn$(libextension)
-SHLIB_libxenevtchn  = $(SHDEPS_libxenevtchn) -Wl,-rpath-link=$(XEN_LIBXENEVTCHN)
+LDLIBS_libxenevtchn = $(SHDEPS_libxenevtchn) $(XEN_libxenevtchn)/libxenevtchn$(libextension)
+SHLIB_libxenevtchn  = $(SHDEPS_libxenevtchn) -Wl,-rpath-link=$(XEN_libxenevtchn)
 
-CFLAGS_libxengnttab = -I$(XEN_LIBXENGNTTAB)/include $(CFLAGS_xeninclude)
+CFLAGS_libxengnttab = -I$(XEN_libxengnttab)/include $(CFLAGS_xeninclude)
 SHDEPS_libxengnttab = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore)
-LDLIBS_libxengnttab = $(SHDEPS_libxengnttab) $(XEN_LIBXENGNTTAB)/libxengnttab$(libextension)
-SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link=$(XEN_LIBXENGNTTAB)
+LDLIBS_libxengnttab = $(SHDEPS_libxengnttab) $(XEN_libxengnttab)/libxengnttab$(libextension)
+SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link=$(XEN_libxengnttab)
 
-CFLAGS_libxencall = -I$(XEN_LIBXENCALL)/include $(CFLAGS_xeninclude)
+CFLAGS_libxencall = -I$(XEN_libxencall)/include $(CFLAGS_xeninclude)
 SHDEPS_libxencall = $(SHLIB_libxentoolcore)
-LDLIBS_libxencall = $(SHDEPS_libxencall) $(XEN_LIBXENCALL)/libxencall$(libextension)
-SHLIB_libxencall  = $(SHDEPS_libxencall) -Wl,-rpath-link=$(XEN_LIBXENCALL)
+LDLIBS_libxencall = $(SHDEPS_libxencall) $(XEN_libxencall)/libxencall$(libextension)
+SHLIB_libxencall  = $(SHDEPS_libxencall) -Wl,-rpath-link=$(XEN_libxencall)
 
-CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xeninclude)
+CFLAGS_libxenforeignmemory = -I$(XEN_libxenforeignmemory)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenforeignmemory = $(SHLIB_libxentoolcore)
-LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension)
-SHLIB_libxenforeignmemory  = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY)
+LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_libxenforeignmemory)/libxenforeignmemory$(libextension)
+SHLIB_libxenforeignmemory  = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_libxenforeignmemory)
 
-CFLAGS_libxendevicemodel = -I$(XEN_LIBXENDEVICEMODEL)/include $(CFLAGS_xeninclude)
+CFLAGS_libxendevicemodel = -I$(XEN_libxendevicemodel)/include $(CFLAGS_xeninclude)
 SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
-LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension)
-SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL)
+LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_libxendevicemodel)/libxendevicemodel$(libextension)
+SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_libxendevicemodel)
 
-CFLAGS_libxenhypfs = -I$(XEN_LIBXENHYPFS)/include $(CFLAGS_xeninclude)
+CFLAGS_libxenhypfs = -I$(XEN_libxenhypfs)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenhypfs = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
-LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_LIBXENHYPFS)/libxenhypfs$(libextension)
-SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_LIBXENHYPFS)
+LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_libxenhypfs)/libxenhypfs$(libextension)
+SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_libxenhypfs)
 
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
-CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
+CFLAGS_libxenctrl = -I$(XEN_libxenctrl)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
 SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) $(SHLIB_libxendevicemodel)
-LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension)
-SHLIB_libxenctrl  = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC)
+LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_libxenctrl)/libxenctrl$(libextension)
+SHLIB_libxenctrl  = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_libxenctrl)
 
-CFLAGS_libxenguest = -I$(XEN_LIBXC)/include $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude)
+CFLAGS_libxenguest = -I$(XEN_libxenguest)/include $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude)
 SHDEPS_libxenguest = $(SHLIB_libxenevtchn)
-LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_LIBXC)/libxenguest$(libextension)
-SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_LIBXC)
+LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_libxenguest)/libxenguest$(libextension)
+SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_libxenguest)
 
-CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
+CFLAGS_libxenstore = -I$(XEN_libxenstore)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
-LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
-SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
+LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_libxenstore)/libxenstore$(libextension)
+SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_libxenstore)
 ifeq ($(CONFIG_Linux),y)
 LDLIBS_libxenstore += -ldl
 endif
 
-CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
+CFLAGS_libxenstat  = -I$(XEN_libxenstat)
 SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
-LDLIBS_libxenstat  = $(SHDEPS_libxenstat) $(XEN_LIBXENSTAT)/libxenstat$(libextension)
-SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_LIBXENSTAT)
+LDLIBS_libxenstat  = $(SHDEPS_libxenstat) $(XEN_libxenstat)/libxenstat$(libextension)
+SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_libxenstat)
 
-CFLAGS_libxenvchan = -I$(XEN_LIBVCHAN) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
+CFLAGS_libxenvchan = -I$(XEN_libxenvchan) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
 SHDEPS_libxenvchan = $(SHLIB_libxentoollog) $(SHLIB_libxenstore) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab)
-LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_LIBVCHAN)/libxenvchan$(libextension)
-SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
+LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_libxenvchan)/libxenvchan$(libextension)
+SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_libxenvchan)
 
 ifeq ($(debug),y)
 # Disable optimizations
@@ -176,15 +178,15 @@ else
 CFLAGS += -O2 -fomit-frame-pointer
 endif
 
-CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
+CFLAGS_libxenlight = -I$(XEN_libxenlight) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
 SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libxenhypfs)
-LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_XENLIGHT)/libxenlight$(libextension)
-SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_XENLIGHT)
+LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_libxenlight)/libxenlight$(libextension)
+SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_libxenlight)
 
-CFLAGS_libxlutil = -I$(XEN_XLUTIL)
+CFLAGS_libxlutil = -I$(XEN_libxlutil)
 SHDEPS_libxlutil = $(SHLIB_libxenlight)
-LDLIBS_libxlutil = $(SHDEPS_libxlutil) $(XEN_XLUTIL)/libxlutil$(libextension)
-SHLIB_libxlutil  = $(SHDEPS_libxlutil) -Wl,-rpath-link=$(XEN_XLUTIL)
+LDLIBS_libxlutil = $(SHDEPS_libxlutil) $(XEN_libxlutil)/libxlutil$(libextension)
+SHLIB_libxlutil  = $(SHDEPS_libxlutil) -Wl,-rpath-link=$(XEN_libxlutil)
 
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
index eac9dbf12a..a83fff7573 100644
--- a/tools/golang/xenlight/Makefile
+++ b/tools/golang/xenlight/Makefile
@@ -30,11 +30,11 @@ idl-gen: $(GOXL_GEN_FILES)
 #
 # NB that because the users of this library need to be able to
 # recompile the library from source, it needs to include '-lxenlight'
-# in the LDFLAGS; and thus we need to add -L$(XEN_XENLIGHT) here
+# in the LDFLAGS; and thus we need to add -L$(XEN_libxenlight) here
 # so that it can find the actual library.
 .PHONY: build
 build: xenlight.go $(GOXL_GEN_FILES)
-	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_XENLIGHT) -L$(XEN_LIBXENTOOLLOG)" $(GO) build -x
+	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog)" $(GO) build -x
 
 .PHONY: install
 install: build
diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
index 7f6dc3fcbd..7994b411fa 100644
--- a/tools/libs/call/Makefile
+++ b/tools/libs/call/Makefile
@@ -15,5 +15,5 @@ SRCS-$(CONFIG_MiniOS)  += minios.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENCALL)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxencall)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index 61bfa35273..d9d1d1b850 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -15,5 +15,5 @@ SRCS-$(CONFIG_MiniOS)  += compat.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENDEVICEMODEL)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxendevicemodel)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
index 9206f622ef..d7aa4d402f 100644
--- a/tools/libs/evtchn/Makefile
+++ b/tools/libs/evtchn/Makefile
@@ -15,4 +15,4 @@ SRCS-$(CONFIG_MiniOS)  += minios.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENEVTCHN)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenevtchn)/include
diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
index 28f1bddc96..823989681d 100644
--- a/tools/libs/foreignmemory/Makefile
+++ b/tools/libs/foreignmemory/Makefile
@@ -15,5 +15,5 @@ SRCS-$(CONFIG_MiniOS)  += minios.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENFOREIGNMEMORY)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenforeignmemory)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index 2da8fbbb7f..c0fffdac71 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -17,5 +17,5 @@ SRCS-$(CONFIG_NetBSD)  += gnttab_unimp.c gntshr_unimp.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENGNTTAB)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxengnttab)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
diff --git a/tools/libs/hypfs/Makefile b/tools/libs/hypfs/Makefile
index 06dd449929..b4c41f6189 100644
--- a/tools/libs/hypfs/Makefile
+++ b/tools/libs/hypfs/Makefile
@@ -12,5 +12,5 @@ SRCS-y                 += core.c
 
 include ../libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENHYPFS)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenhypfs)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
index 9c5a92d93f..85ff2b26fd 100644
--- a/tools/libs/toolcore/Makefile
+++ b/tools/libs/toolcore/Makefile
@@ -10,7 +10,7 @@ SRCS-y	+= handlereg.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENTOOLCORE)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxentoolcore)/include
 
 $(LIB_OBJS): $(AUTOINCS)
 $(PIC_OBJS): $(AUTOINCS)
diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
index 9156e5d08e..2d3ae4e627 100644
--- a/tools/libs/toollog/Makefile
+++ b/tools/libs/toollog/Makefile
@@ -10,4 +10,4 @@ SRCS-y	+= xtl_logger_stdio.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENTOOLLOG)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxentoollog)/include
diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile
index d99a6137e1..a5441162a0 100644
--- a/tools/libvchan/Makefile
+++ b/tools/libvchan/Makefile
@@ -35,7 +35,7 @@ endif
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBVCHAN)
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenvchan)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
 
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 955cd5ab18..c1e41a8ee9 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -168,7 +168,7 @@ endif
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXC)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenctrl)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
 
diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile
index ab980852da..b5e623b155 100644
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -50,7 +50,7 @@ endif
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENSTAT)
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstat)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
 .PHONY: all
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 445e9911b2..0a64ac1571 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -128,7 +128,7 @@ endif
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_XENSTORE)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstore)/include
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH I v2 3/6] tools: add a copy of library headers in tools/include
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 1/6] stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*) Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 4/6] tools: don't call make recursively from libs.mk Juergen Gross
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu

The headers.chk target in tools/Rules.mk tries to compile all headers
stand alone for testing them not to include any internal header.

Unfortunately the headers tested against are not complete, as any
header for a Xen library is not included in the include path of the
test compile run, resulting in a failure in case any of the tested
headers in including an official Xen library header.

Fix that by copying the official headers located in
tools/libs/*/include to tools/include.

In order to support libraries with header name other than xen<lib>.h
or with multiple headers add a LIBHEADER make variable a lib specific
Makefile can set in that case.

Move the headers.chk target from Rules.mk to libs.mk as it is used
for libraries in tools/libs only.

Add NO_HEADERS_CHK variable to skip checking headers as this will be
needed e.g. for libxenctrl.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 .gitignore         |  1 +
 tools/Rules.mk     |  8 --------
 tools/libs/libs.mk | 26 +++++++++++++++++++++++---
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index 36ce2ea104..5ea48af818 100644
--- a/.gitignore
+++ b/.gitignore
@@ -188,6 +188,7 @@ tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
 tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/acpi
+tools/include/*.h
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
diff --git a/tools/Rules.mk b/tools/Rules.mk
index b42e50ebf6..5d699cfd39 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -225,14 +225,6 @@ INSTALL_PYTHON_PROG = \
 %.opic: %.S
 	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
 
-headers.chk:
-	for i in $(filter %.h,$^); do \
-	    $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
-	          -S -o /dev/null $$i || exit 1; \
-	    echo $$i; \
-	done >$@.new
-	mv $@.new $@
-
 subdirs-all subdirs-clean subdirs-install subdirs-distclean subdirs-uninstall: .phony
 	@set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
 		$(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 8027ae7400..8045c00e9a 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -34,6 +34,10 @@ endif
 
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
+LIBHEADER ?= xen$(LIBNAME).h
+LIBHEADERS = $(foreach h, $(LIBHEADER), include/$(h))
+LIBHEADERSGLOB = $(foreach h, $(LIBHEADER), $(XEN_ROOT)/tools/include/$(h))
+
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
@@ -47,7 +51,22 @@ build:
 .PHONY: libs
 libs: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
 
-headers.chk: $(wildcard include/*.h) $(AUTOINCS)
+ifneq ($(NO_HEADERS_CHK),y)
+headers.chk:
+	for i in $(filter %.h,$^); do \
+	    $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
+	          -S -o /dev/null $$i || exit 1; \
+	    echo $$i; \
+	done >$@.new
+	mv $@.new $@
+else
+.PHONY: headers.chk
+endif
+
+headers.chk: $(LIBHEADERSGLOB) $(AUTOINCS)
+
+$(LIBHEADERSGLOB): $(LIBHEADERS)
+	for i in $(realpath $(LIBHEADERS)); do ln -sf $$i $(XEN_ROOT)/tools/include; done
 
 libxen$(LIBNAME).a: $(LIB_OBJS)
 	$(AR) rc $@ $^
@@ -68,13 +87,13 @@ install: build
 	$(INSTALL_DATA) libxen$(LIBNAME).a $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
 	$(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
-	$(INSTALL_DATA) include/xen$(LIBNAME).h $(DESTDIR)$(includedir)
+	for i in $(LIBHEADERS); do $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); done
 	$(INSTALL_DATA) xen$(LIBNAME).pc $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
 uninstall:
 	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xen$(LIBNAME).pc
-	rm -f $(DESTDIR)$(includedir)/xen$(LIBNAME).h
+	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
 	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
 	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR).$(MINOR)
@@ -90,6 +109,7 @@ clean:
 	rm -f libxen$(LIBNAME).so.$(MAJOR).$(MINOR) libxen$(LIBNAME).so.$(MAJOR)
 	rm -f headers.chk
 	rm -f xen$(LIBNAME).pc
+	rm -f $(LIBHEADERSGLOB)
 
 .PHONY: distclean
 distclean: clean
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH I v2 4/6] tools: don't call make recursively from libs.mk
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
                   ` (2 preceding siblings ...)
  2020-08-15 13:03 ` [PATCH I v2 3/6] tools: add a copy of library headers in tools/include Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h Juergen Gross
  2020-08-15 13:03 ` [PATCH I v2 6/6] tools: generate most contents of library make variables Juergen Gross
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

During build of a xen library make is called again via libs.mk. This is
not necessary as the same can be achieved by a simple dependency.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/libs/libs.mk | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 8045c00e9a..764f5441e2 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -45,8 +45,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 all: build
 
 .PHONY: build
-build:
-	$(MAKE) libs
+build: libs
 
 .PHONY: libs
 libs: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
                   ` (3 preceding siblings ...)
  2020-08-15 13:03 ` [PATCH I v2 4/6] tools: don't call make recursively from libs.mk Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-27 10:13   ` Wei Liu
  2020-08-15 13:03 ` [PATCH I v2 6/6] tools: generate most contents of library make variables Juergen Gross
  5 siblings, 1 reply; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

Today there are multiple copies of the ROUNDUP() macro in various
sources and headers. Define it once in tools/include/xen-tools/libs.h.

Using xen-tools/libs.h enables removing copies of MIN() and MAX(), too.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/console/daemon/io.c        | 6 +-----
 tools/include/xen-tools/libs.h   | 4 ++++
 tools/libs/call/buffer.c         | 3 +--
 tools/libs/foreignmemory/linux.c | 3 +--
 tools/libs/gnttab/private.h      | 3 ---
 tools/libxc/xg_private.h         | 1 -
 tools/libxl/libxl_internal.h     | 3 ---
 tools/xenstore/xenstored_core.c  | 2 --
 8 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index a43c57edad..4af27ffc5d 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -49,9 +49,7 @@
 #include <sys/ioctl.h>
 #include <libutil.h>
 #endif
-
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#include <xen-tools/libs.h>
 
 /* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
 #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
@@ -80,8 +78,6 @@ static struct pollfd  *fds;
 static unsigned int current_array_size;
 static unsigned int nr_fds;
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 struct buffer {
 	char *data;
 	size_t consumed;
diff --git a/tools/include/xen-tools/libs.h b/tools/include/xen-tools/libs.h
index cc7dfc8c64..a16e0c3807 100644
--- a/tools/include/xen-tools/libs.h
+++ b/tools/include/xen-tools/libs.h
@@ -59,4 +59,8 @@
     })
 #endif
 
+#ifndef ROUNDUP
+#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
+#endif
+
 #endif	/* __XEN_TOOLS_LIBS__ */
diff --git a/tools/libs/call/buffer.c b/tools/libs/call/buffer.c
index 0b6af2db60..085674d882 100644
--- a/tools/libs/call/buffer.c
+++ b/tools/libs/call/buffer.c
@@ -16,14 +16,13 @@
 #include <errno.h>
 #include <string.h>
 #include <pthread.h>
+#include <xen-tools/libs.h>
 
 #include "private.h"
 
 #define DBGPRINTF(_m...) \
     xtl_log(xcall->logger, XTL_DEBUG, -1, "xencall:buffer", _m)
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void cache_lock(xencall_handle *xcall)
diff --git a/tools/libs/foreignmemory/linux.c b/tools/libs/foreignmemory/linux.c
index 8daa5828e3..fe73d5ab72 100644
--- a/tools/libs/foreignmemory/linux.c
+++ b/tools/libs/foreignmemory/linux.c
@@ -25,11 +25,10 @@
 
 #include <sys/mman.h>
 #include <sys/ioctl.h>
+#include <xen-tools/libs.h>
 
 #include "private.h"
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 #endif
diff --git a/tools/libs/gnttab/private.h b/tools/libs/gnttab/private.h
index c5e23639b1..eb6a6abe54 100644
--- a/tools/libs/gnttab/private.h
+++ b/tools/libs/gnttab/private.h
@@ -5,9 +5,6 @@
 #include <xentoolcore_internal.h>
 #include <xengnttab.h>
 
-/* Set of macros/defines used by both Linux and FreeBSD */
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 #define GTERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gnttab", _f)
 #define GSERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gntshr", _f)
 
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index f0a4b2c616..40b5baecde 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -95,7 +95,6 @@ typedef uint64_t x86_pgentry_t;
 #define PAGE_SIZE_X86           (1UL << PAGE_SHIFT_X86)
 #define PAGE_MASK_X86           (~(PAGE_SIZE_X86-1))
 
-#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
 #define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
 
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 94a23179d3..c63d0686fd 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -132,9 +132,6 @@
 #define MB(_mb)     (_AC(_mb, ULL) << 20)
 #define GB(_gb)     (_AC(_gb, ULL) << 30)
 
-#define ROUNDUP(_val, _order)                                           \
-    (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
-
 #define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d))
 
 #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 7bd959f28b..9700772d40 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -73,8 +73,6 @@ static unsigned int nr_fds;
 static int sock = -1;
 static int ro_sock = -1;
 
-#define ROUNDUP(_x, _w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
-
 static bool verbose = false;
 LIST_HEAD(connections);
 int tracefd = -1;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH I v2 6/6] tools: generate most contents of library make variables
  2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
                   ` (4 preceding siblings ...)
  2020-08-15 13:03 ` [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h Juergen Gross
@ 2020-08-15 13:03 ` Juergen Gross
  2020-08-16 11:47   ` Jürgen Groß
  5 siblings, 1 reply; 10+ messages in thread
From: Juergen Gross @ 2020-08-15 13:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Library related make variables (CFLAGS_lib*, SHDEPS_lib*, LDLIBS_lib*
and SHLIB_lib*) mostly have a common pattern for their values. Generate
most of this content automatically by adding a new per-library variable
defining on which other libraries a lib is depending.

This in turn makes it possible to drop the USELIB variable from each
library Makefile.

The LIBNAME variable can be dropped, too, as it can be derived from the
directory name the library is residing in.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/Rules.mk                    | 70 ++++++++++---------------------
 tools/libs/call/Makefile          |  2 -
 tools/libs/devicemodel/Makefile   |  2 -
 tools/libs/evtchn/Makefile        |  2 -
 tools/libs/foreignmemory/Makefile |  2 -
 tools/libs/gnttab/Makefile        |  2 -
 tools/libs/hypfs/Makefile         |  2 -
 tools/libs/libs.mk                |  8 ++--
 tools/libs/toolcore/Makefile      |  1 -
 tools/libs/toollog/Makefile       |  1 -
 10 files changed, 27 insertions(+), 65 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 5d699cfd39..06827ad1d8 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -12,14 +12,24 @@ INSTALL = $(XEN_ROOT)/tools/cross-install
 LDFLAGS += $(PREPEND_LDFLAGS_XEN_TOOLS)
 
 XEN_INCLUDE        = $(XEN_ROOT)/tools/include
-XEN_libxentoolcore = $(XEN_ROOT)/tools/libs/toolcore
-XEN_libxentoollog  = $(XEN_ROOT)/tools/libs/toollog
-XEN_libxenevtchn   = $(XEN_ROOT)/tools/libs/evtchn
-XEN_libxengnttab   = $(XEN_ROOT)/tools/libs/gnttab
-XEN_libxencall     = $(XEN_ROOT)/tools/libs/call
-XEN_libxenforeignmemory = $(XEN_ROOT)/tools/libs/foreignmemory
-XEN_libxendevicemodel = $(XEN_ROOT)/tools/libs/devicemodel
-XEN_libxenhypfs    = $(XEN_ROOT)/tools/libs/hypfs
+
+LIBS_LIBS += toolcore
+USELIBS_toolcore :=
+LIBS_LIBS += toollog
+USELIBS_toollog :=
+LIBS_LIBS += evtchn
+USELIBS_evtchn := toollog toolcore
+LIBS_LIBS += gnttab
+USELIBS_gnttab := toollog toolcore
+LIBS_LIBS += call
+USELIBS_call := toollog toolcore
+LIBS_LIBS += foreignmemory
+USELIBS_foreignmemory := toollog toolcore
+LIBS_LIBS += devicemodel
+USELIBS_devicemodel := toollog toolcore call
+LIBS_LIBS += hypfs
+USELIBS_hypfs := toollog toolcore call
+
 XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
 # Currently libxenguest lives in the same directory as libxenctrl
 XEN_libxenguest    = $(XEN_libxenctrl)
@@ -99,45 +109,11 @@ endif
 # Consumers of libfoo should not directly use $(SHDEPS_libfoo) or
 # $(SHLIB_libfoo)
 
-CFLAGS_libxentoollog = -I$(XEN_libxentoollog)/include $(CFLAGS_xeninclude)
-SHDEPS_libxentoollog =
-LDLIBS_libxentoollog = $(SHDEPS_libxentoollog) $(XEN_libxentoollog)/libxentoollog$(libextension)
-SHLIB_libxentoollog  = $(SHDEPS_libxentoollog) -Wl,-rpath-link=$(XEN_libxentoollog)
-
-CFLAGS_libxentoolcore = -I$(XEN_libxentoolcore)/include $(CFLAGS_xeninclude)
-SHDEPS_libxentoolcore =
-LDLIBS_libxentoolcore = $(SHDEPS_libxentoolcore) $(XEN_libxentoolcore)/libxentoolcore$(libextension)
-SHLIB_libxentoolcore  = $(SHDEPS_libxentoolcore) -Wl,-rpath-link=$(XEN_libxentoolcore)
-
-CFLAGS_libxenevtchn = -I$(XEN_libxenevtchn)/include $(CFLAGS_xeninclude)
-SHDEPS_libxenevtchn = $(SHLIB_libxentoolcore)
-LDLIBS_libxenevtchn = $(SHDEPS_libxenevtchn) $(XEN_libxenevtchn)/libxenevtchn$(libextension)
-SHLIB_libxenevtchn  = $(SHDEPS_libxenevtchn) -Wl,-rpath-link=$(XEN_libxenevtchn)
-
-CFLAGS_libxengnttab = -I$(XEN_libxengnttab)/include $(CFLAGS_xeninclude)
-SHDEPS_libxengnttab = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore)
-LDLIBS_libxengnttab = $(SHDEPS_libxengnttab) $(XEN_libxengnttab)/libxengnttab$(libextension)
-SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link=$(XEN_libxengnttab)
-
-CFLAGS_libxencall = -I$(XEN_libxencall)/include $(CFLAGS_xeninclude)
-SHDEPS_libxencall = $(SHLIB_libxentoolcore)
-LDLIBS_libxencall = $(SHDEPS_libxencall) $(XEN_libxencall)/libxencall$(libextension)
-SHLIB_libxencall  = $(SHDEPS_libxencall) -Wl,-rpath-link=$(XEN_libxencall)
-
-CFLAGS_libxenforeignmemory = -I$(XEN_libxenforeignmemory)/include $(CFLAGS_xeninclude)
-SHDEPS_libxenforeignmemory = $(SHLIB_libxentoolcore)
-LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_libxenforeignmemory)/libxenforeignmemory$(libextension)
-SHLIB_libxenforeignmemory  = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_libxenforeignmemory)
-
-CFLAGS_libxendevicemodel = -I$(XEN_libxendevicemodel)/include $(CFLAGS_xeninclude)
-SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
-LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_libxendevicemodel)/libxendevicemodel$(libextension)
-SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_libxendevicemodel)
-
-CFLAGS_libxenhypfs = -I$(XEN_libxenhypfs)/include $(CFLAGS_xeninclude)
-SHDEPS_libxenhypfs = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
-LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_libxenhypfs)/libxenhypfs$(libextension)
-SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_libxenhypfs)
+$(foreach lib,$(LIBS_LIBS),$(eval XEN_libxen$(lib) = $(XEN_ROOT)/tools/libs/$(lib)))
+$(foreach lib,$(LIBS_LIBS),$(eval CFLAGS_libxen$(lib) = -I$(XEN_libxen$(lib))/include $(CFLAGS_xeninclude)))
+$(foreach lib,$(LIBS_LIBS),$(eval SHDEPS_libxen$(lib) = $(foreach use,$(USELIBS_$(lib)),$(SHLIB_libxen$(use)))))
+$(foreach lib,$(LIBS_LIBS),$(eval LDLIBS_libxen$(lib) = $(SHDEPS_libxen$(lib)) $(XEN_libxen$(lib))/libxen$(lib)$(libextension)))
+$(foreach lib,$(LIBS_LIBS),$(eval SHLIB_libxen$(lib) = $(SHDEPS_libxen$(lib)) -Wl,-rpath-link=$(XEN_libxen$(lib))))
 
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
index 7994b411fa..81c7478efd 100644
--- a/tools/libs/call/Makefile
+++ b/tools/libs/call/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 2
-LIBNAME  := call
-USELIBS  := toollog toolcore
 
 SRCS-y                 += core.c buffer.c
 SRCS-$(CONFIG_Linux)   += linux.c
diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index d9d1d1b850..42417958f2 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 3
-LIBNAME  := devicemodel
-USELIBS  := toollog toolcore call
 
 SRCS-y                 += core.c
 SRCS-$(CONFIG_Linux)   += linux.c
diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
index d7aa4d402f..aec76641e8 100644
--- a/tools/libs/evtchn/Makefile
+++ b/tools/libs/evtchn/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 1
-LIBNAME  := evtchn
-USELIBS  := toollog toolcore
 
 SRCS-y                 += core.c
 SRCS-$(CONFIG_Linux)   += linux.c
diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
index 823989681d..cf444d3c1a 100644
--- a/tools/libs/foreignmemory/Makefile
+++ b/tools/libs/foreignmemory/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 3
-LIBNAME  := foreignmemory
-USELIBS  := toollog toolcore
 
 SRCS-y                 += core.c
 SRCS-$(CONFIG_Linux)   += linux.c
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index c0fffdac71..d8d4d55e27 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 2
-LIBNAME  := gnttab
-USELIBS  := toollog toolcore
 
 SRCS-GNTTAB            += gnttab_core.c
 SRCS-GNTSHR            += gntshr_core.c
diff --git a/tools/libs/hypfs/Makefile b/tools/libs/hypfs/Makefile
index b4c41f6189..668d68853f 100644
--- a/tools/libs/hypfs/Makefile
+++ b/tools/libs/hypfs/Makefile
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 0
-LIBNAME  := hypfs
-USELIBS  := toollog toolcore call
 
 APPEND_LDFLAGS += -lz
 
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 764f5441e2..19efc5e743 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -1,18 +1,18 @@
 # Common Makefile for building a lib.
 #
 # Variables taken as input:
-#   LIBNAME: name of lib to build, will be prepended with "libxen"
 #   MAJOR:   major version of lib
 #   MINOR:   minor version of lib
-#   USELIBS: xen libs to use (e.g. "toolcore toollog")
+
+LIBNAME := $(notdir $(CURDIR))
 
 SHLIB_LDFLAGS += -Wl,--version-script=libxen$(LIBNAME).map
 
 CFLAGS   += -Werror -Wmissing-prototypes
 CFLAGS   += -I./include $(CFLAGS_xeninclude)
-CFLAGS   += $(foreach lib, $(USELIBS), $(CFLAGS_libxen$(lib)))
+CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
-LDUSELIBS = $(foreach lib, $(USELIBS), $(LDLIBS_libxen$(lib)))
+LDUSELIBS = $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 
 LIB_OBJS := $(SRCS-y:.c=.o)
 PIC_OBJS := $(SRCS-y:.c=.opic)
diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
index 85ff2b26fd..34b08a4236 100644
--- a/tools/libs/toolcore/Makefile
+++ b/tools/libs/toolcore/Makefile
@@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR	= 1
 MINOR	= 0
-LIBNAME  := toolcore
 AUTOINCS := include/_xentoolcore_list.h
 
 SRCS-y	+= handlereg.c
diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
index 2d3ae4e627..3f986835d6 100644
--- a/tools/libs/toollog/Makefile
+++ b/tools/libs/toollog/Makefile
@@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR	= 1
 MINOR	= 0
-LIBNAME  := toollog
 
 SRCS-y	+= xtl_core.c
 SRCS-y	+= xtl_logger_stdio.c
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH I v2 6/6] tools: generate most contents of library make variables
  2020-08-15 13:03 ` [PATCH I v2 6/6] tools: generate most contents of library make variables Juergen Gross
@ 2020-08-16 11:47   ` Jürgen Groß
  0 siblings, 0 replies; 10+ messages in thread
From: Jürgen Groß @ 2020-08-16 11:47 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Wei Liu

On 15.08.20 15:03, Juergen Gross wrote:
> Library related make variables (CFLAGS_lib*, SHDEPS_lib*, LDLIBS_lib*
> and SHLIB_lib*) mostly have a common pattern for their values. Generate
> most of this content automatically by adding a new per-library variable
> defining on which other libraries a lib is depending.
> 
> This in turn makes it possible to drop the USELIB variable from each
> library Makefile.
> 
> The LIBNAME variable can be dropped, too, as it can be derived from the
> directory name the library is residing in.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Uh, this patch has a bug. The other 5 are fine, though. Will send an
updated version of this one soon.


Juergen

> ---
>   tools/Rules.mk                    | 70 ++++++++++---------------------
>   tools/libs/call/Makefile          |  2 -
>   tools/libs/devicemodel/Makefile   |  2 -
>   tools/libs/evtchn/Makefile        |  2 -
>   tools/libs/foreignmemory/Makefile |  2 -
>   tools/libs/gnttab/Makefile        |  2 -
>   tools/libs/hypfs/Makefile         |  2 -
>   tools/libs/libs.mk                |  8 ++--
>   tools/libs/toolcore/Makefile      |  1 -
>   tools/libs/toollog/Makefile       |  1 -
>   10 files changed, 27 insertions(+), 65 deletions(-)
> 
> diff --git a/tools/Rules.mk b/tools/Rules.mk
> index 5d699cfd39..06827ad1d8 100644
> --- a/tools/Rules.mk
> +++ b/tools/Rules.mk
> @@ -12,14 +12,24 @@ INSTALL = $(XEN_ROOT)/tools/cross-install
>   LDFLAGS += $(PREPEND_LDFLAGS_XEN_TOOLS)
>   
>   XEN_INCLUDE        = $(XEN_ROOT)/tools/include
> -XEN_libxentoolcore = $(XEN_ROOT)/tools/libs/toolcore
> -XEN_libxentoollog  = $(XEN_ROOT)/tools/libs/toollog
> -XEN_libxenevtchn   = $(XEN_ROOT)/tools/libs/evtchn
> -XEN_libxengnttab   = $(XEN_ROOT)/tools/libs/gnttab
> -XEN_libxencall     = $(XEN_ROOT)/tools/libs/call
> -XEN_libxenforeignmemory = $(XEN_ROOT)/tools/libs/foreignmemory
> -XEN_libxendevicemodel = $(XEN_ROOT)/tools/libs/devicemodel
> -XEN_libxenhypfs    = $(XEN_ROOT)/tools/libs/hypfs
> +
> +LIBS_LIBS += toolcore
> +USELIBS_toolcore :=
> +LIBS_LIBS += toollog
> +USELIBS_toollog :=
> +LIBS_LIBS += evtchn
> +USELIBS_evtchn := toollog toolcore
> +LIBS_LIBS += gnttab
> +USELIBS_gnttab := toollog toolcore
> +LIBS_LIBS += call
> +USELIBS_call := toollog toolcore
> +LIBS_LIBS += foreignmemory
> +USELIBS_foreignmemory := toollog toolcore
> +LIBS_LIBS += devicemodel
> +USELIBS_devicemodel := toollog toolcore call
> +LIBS_LIBS += hypfs
> +USELIBS_hypfs := toollog toolcore call
> +
>   XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
>   # Currently libxenguest lives in the same directory as libxenctrl
>   XEN_libxenguest    = $(XEN_libxenctrl)
> @@ -99,45 +109,11 @@ endif
>   # Consumers of libfoo should not directly use $(SHDEPS_libfoo) or
>   # $(SHLIB_libfoo)
>   
> -CFLAGS_libxentoollog = -I$(XEN_libxentoollog)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxentoollog =
> -LDLIBS_libxentoollog = $(SHDEPS_libxentoollog) $(XEN_libxentoollog)/libxentoollog$(libextension)
> -SHLIB_libxentoollog  = $(SHDEPS_libxentoollog) -Wl,-rpath-link=$(XEN_libxentoollog)
> -
> -CFLAGS_libxentoolcore = -I$(XEN_libxentoolcore)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxentoolcore =
> -LDLIBS_libxentoolcore = $(SHDEPS_libxentoolcore) $(XEN_libxentoolcore)/libxentoolcore$(libextension)
> -SHLIB_libxentoolcore  = $(SHDEPS_libxentoolcore) -Wl,-rpath-link=$(XEN_libxentoolcore)
> -
> -CFLAGS_libxenevtchn = -I$(XEN_libxenevtchn)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxenevtchn = $(SHLIB_libxentoolcore)
> -LDLIBS_libxenevtchn = $(SHDEPS_libxenevtchn) $(XEN_libxenevtchn)/libxenevtchn$(libextension)
> -SHLIB_libxenevtchn  = $(SHDEPS_libxenevtchn) -Wl,-rpath-link=$(XEN_libxenevtchn)
> -
> -CFLAGS_libxengnttab = -I$(XEN_libxengnttab)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxengnttab = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore)
> -LDLIBS_libxengnttab = $(SHDEPS_libxengnttab) $(XEN_libxengnttab)/libxengnttab$(libextension)
> -SHLIB_libxengnttab  = $(SHDEPS_libxengnttab) -Wl,-rpath-link=$(XEN_libxengnttab)
> -
> -CFLAGS_libxencall = -I$(XEN_libxencall)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxencall = $(SHLIB_libxentoolcore)
> -LDLIBS_libxencall = $(SHDEPS_libxencall) $(XEN_libxencall)/libxencall$(libextension)
> -SHLIB_libxencall  = $(SHDEPS_libxencall) -Wl,-rpath-link=$(XEN_libxencall)
> -
> -CFLAGS_libxenforeignmemory = -I$(XEN_libxenforeignmemory)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxenforeignmemory = $(SHLIB_libxentoolcore)
> -LDLIBS_libxenforeignmemory = $(SHDEPS_libxenforeignmemory) $(XEN_libxenforeignmemory)/libxenforeignmemory$(libextension)
> -SHLIB_libxenforeignmemory  = $(SHDEPS_libxenforeignmemory) -Wl,-rpath-link=$(XEN_libxenforeignmemory)
> -
> -CFLAGS_libxendevicemodel = -I$(XEN_libxendevicemodel)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
> -LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_libxendevicemodel)/libxendevicemodel$(libextension)
> -SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_libxendevicemodel)
> -
> -CFLAGS_libxenhypfs = -I$(XEN_libxenhypfs)/include $(CFLAGS_xeninclude)
> -SHDEPS_libxenhypfs = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_libxencall)
> -LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_libxenhypfs)/libxenhypfs$(libextension)
> -SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_libxenhypfs)
> +$(foreach lib,$(LIBS_LIBS),$(eval XEN_libxen$(lib) = $(XEN_ROOT)/tools/libs/$(lib)))
> +$(foreach lib,$(LIBS_LIBS),$(eval CFLAGS_libxen$(lib) = -I$(XEN_libxen$(lib))/include $(CFLAGS_xeninclude)))
> +$(foreach lib,$(LIBS_LIBS),$(eval SHDEPS_libxen$(lib) = $(foreach use,$(USELIBS_$(lib)),$(SHLIB_libxen$(use)))))
> +$(foreach lib,$(LIBS_LIBS),$(eval LDLIBS_libxen$(lib) = $(SHDEPS_libxen$(lib)) $(XEN_libxen$(lib))/libxen$(lib)$(libextension)))
> +$(foreach lib,$(LIBS_LIBS),$(eval SHLIB_libxen$(lib) = $(SHDEPS_libxen$(lib)) -Wl,-rpath-link=$(XEN_libxen$(lib))))
>   
>   # code which compiles against libxenctrl get __XEN_TOOLS__ and
>   # therefore sees the unstable hypercall interfaces.
> diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
> index 7994b411fa..81c7478efd 100644
> --- a/tools/libs/call/Makefile
> +++ b/tools/libs/call/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 2
> -LIBNAME  := call
> -USELIBS  := toollog toolcore
>   
>   SRCS-y                 += core.c buffer.c
>   SRCS-$(CONFIG_Linux)   += linux.c
> diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
> index d9d1d1b850..42417958f2 100644
> --- a/tools/libs/devicemodel/Makefile
> +++ b/tools/libs/devicemodel/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 3
> -LIBNAME  := devicemodel
> -USELIBS  := toollog toolcore call
>   
>   SRCS-y                 += core.c
>   SRCS-$(CONFIG_Linux)   += linux.c
> diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
> index d7aa4d402f..aec76641e8 100644
> --- a/tools/libs/evtchn/Makefile
> +++ b/tools/libs/evtchn/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 1
> -LIBNAME  := evtchn
> -USELIBS  := toollog toolcore
>   
>   SRCS-y                 += core.c
>   SRCS-$(CONFIG_Linux)   += linux.c
> diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
> index 823989681d..cf444d3c1a 100644
> --- a/tools/libs/foreignmemory/Makefile
> +++ b/tools/libs/foreignmemory/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 3
> -LIBNAME  := foreignmemory
> -USELIBS  := toollog toolcore
>   
>   SRCS-y                 += core.c
>   SRCS-$(CONFIG_Linux)   += linux.c
> diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
> index c0fffdac71..d8d4d55e27 100644
> --- a/tools/libs/gnttab/Makefile
> +++ b/tools/libs/gnttab/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 2
> -LIBNAME  := gnttab
> -USELIBS  := toollog toolcore
>   
>   SRCS-GNTTAB            += gnttab_core.c
>   SRCS-GNTSHR            += gntshr_core.c
> diff --git a/tools/libs/hypfs/Makefile b/tools/libs/hypfs/Makefile
> index b4c41f6189..668d68853f 100644
> --- a/tools/libs/hypfs/Makefile
> +++ b/tools/libs/hypfs/Makefile
> @@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR    = 1
>   MINOR    = 0
> -LIBNAME  := hypfs
> -USELIBS  := toollog toolcore call
>   
>   APPEND_LDFLAGS += -lz
>   
> diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
> index 764f5441e2..19efc5e743 100644
> --- a/tools/libs/libs.mk
> +++ b/tools/libs/libs.mk
> @@ -1,18 +1,18 @@
>   # Common Makefile for building a lib.
>   #
>   # Variables taken as input:
> -#   LIBNAME: name of lib to build, will be prepended with "libxen"
>   #   MAJOR:   major version of lib
>   #   MINOR:   minor version of lib
> -#   USELIBS: xen libs to use (e.g. "toolcore toollog")
> +
> +LIBNAME := $(notdir $(CURDIR))
>   
>   SHLIB_LDFLAGS += -Wl,--version-script=libxen$(LIBNAME).map
>   
>   CFLAGS   += -Werror -Wmissing-prototypes
>   CFLAGS   += -I./include $(CFLAGS_xeninclude)
> -CFLAGS   += $(foreach lib, $(USELIBS), $(CFLAGS_libxen$(lib)))
> +CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
>   
> -LDUSELIBS = $(foreach lib, $(USELIBS), $(LDLIBS_libxen$(lib)))
> +LDUSELIBS = $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
>   
>   LIB_OBJS := $(SRCS-y:.c=.o)
>   PIC_OBJS := $(SRCS-y:.c=.opic)
> diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
> index 85ff2b26fd..34b08a4236 100644
> --- a/tools/libs/toolcore/Makefile
> +++ b/tools/libs/toolcore/Makefile
> @@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR	= 1
>   MINOR	= 0
> -LIBNAME  := toolcore
>   AUTOINCS := include/_xentoolcore_list.h
>   
>   SRCS-y	+= handlereg.c
> diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
> index 2d3ae4e627..3f986835d6 100644
> --- a/tools/libs/toollog/Makefile
> +++ b/tools/libs/toollog/Makefile
> @@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
>   
>   MAJOR	= 1
>   MINOR	= 0
> -LIBNAME  := toollog
>   
>   SRCS-y	+= xtl_core.c
>   SRCS-y	+= xtl_logger_stdio.c
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h
  2020-08-15 13:03 ` [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h Juergen Gross
@ 2020-08-27 10:13   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2020-08-27 10:13 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Ian Jackson, Wei Liu, Anthony PERARD

On Sat, Aug 15, 2020 at 03:03:40PM +0200, Juergen Gross wrote:
> Today there are multiple copies of the ROUNDUP() macro in various
> sources and headers. Define it once in tools/include/xen-tools/libs.h.
> 
> Using xen-tools/libs.h enables removing copies of MIN() and MAX(), too.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wl@xen.org>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*)
  2020-08-15 13:03 ` [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*) Juergen Gross
@ 2020-08-27 10:14   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2020-08-27 10:14 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, Ian Jackson, Wei Liu, George Dunlap, Nick Rosbrook

On Sat, Aug 15, 2020 at 03:03:37PM +0200, Juergen Gross wrote:
> In order to harmonize names of library related make variables switch
> XEN_LIBXEN* names to XEN_libxen*, as all other related variables (e.g.
> CFLAGS_libxen*, SHDEPS_libxen*, ...) already use this pattern.
> 
> Rename XEN_LIBXC to XEN_libxenctrl, XEN_XENSTORE to XEN_libxenstore,
> XEN_XENLIGHT to XEN_libxenlight, XEN_XLUTIL to XEN_libxlutil, and
> XEN_LIBVCHAN to XEN_libxenvchan for the same reason.
> 
> Introduce XEN_libxenguest with the same value as XEN_libxenctrl.
> 
> No functional change.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wl@xen.org>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-27 10:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-15 13:03 [PATCH I v2 0/6] tools: streamline tools/libs/ building Juergen Gross
2020-08-15 13:03 ` [PATCH I v2 1/6] stubdom: add stubdom/mini-os.mk for Xen paths used by Mini-OS Juergen Gross
2020-08-15 13:03 ` [PATCH I v2 2/6] tools: switch XEN_LIBXEN* make variables to lower case (XEN_libxen*) Juergen Gross
2020-08-27 10:14   ` Wei Liu
2020-08-15 13:03 ` [PATCH I v2 3/6] tools: add a copy of library headers in tools/include Juergen Gross
2020-08-15 13:03 ` [PATCH I v2 4/6] tools: don't call make recursively from libs.mk Juergen Gross
2020-08-15 13:03 ` [PATCH I v2 5/6] tools: define ROUNDUP() in tools/include/xen-tools/libs.h Juergen Gross
2020-08-27 10:13   ` Wei Liu
2020-08-15 13:03 ` [PATCH I v2 6/6] tools: generate most contents of library make variables Juergen Gross
2020-08-16 11:47   ` Jürgen Groß

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.