]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
tools: generate most contents of library make variables
authorJuergen Gross <jgross@suse.com>
Sun, 23 Aug 2020 08:00:11 +0000 (10:00 +0200)
committerWei Liu <wl@xen.org>
Thu, 27 Aug 2020 12:59:46 +0000 (12:59 +0000)
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. Those definitions
are put into an own file in order to make it possible to include it
from various Makefiles, especially for stubdom.

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>
Acked-by: Wei Liu <wl@xen.org>
tools/Rules.mk
tools/libs/call/Makefile
tools/libs/devicemodel/Makefile
tools/libs/evtchn/Makefile
tools/libs/foreignmemory/Makefile
tools/libs/gnttab/Makefile
tools/libs/hypfs/Makefile
tools/libs/libs.mk
tools/libs/toolcore/Makefile
tools/libs/toollog/Makefile
tools/libs/uselibs.mk [new file with mode: 0644]

index 5d699cfd399431c95bae45d15a686577c4c56e1b..7e019a8a65fd152e9513a5155c6c38b754a7a4e8 100644 (file)
@@ -12,14 +12,9 @@ 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
+
+include $(XEN_ROOT)/tools/libs/uselibs.mk
+
 XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
 # Currently libxenguest lives in the same directory as libxenctrl
 XEN_libxenguest    = $(XEN_libxenctrl)
@@ -99,45 +94,15 @@ 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)
+define LIB_defs =
+ XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
+ CFLAGS_libxen$(1) = -I$$(XEN_libxen$(1))/include $$(CFLAGS_xeninclude)
+ SHDEPS_libxen$(1) = $$(foreach use,$$(USELIBS_$(1)),$$(SHLIB_libxen$$(use)))
+ LDLIBS_libxen$(1) = $$(SHDEPS_libxen$(1)) $$(XEN_libxen$(1))/libxen$(1)$$(libextension)
+ SHLIB_libxen$(1) = $$(SHDEPS_libxen$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
+endef
+
+$(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
 
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
index 7994b411fa1946ba390fa338f636c878ccb9f36d..81c7478efd65a206cd372b2db09c93db817f2881 100644 (file)
@@ -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
index d9d1d1b850ff5cfe608e33d497e9ed45b5024451..42417958f21b3ad065d39283eb0d33206419767c 100644 (file)
@@ -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
index d7aa4d402ff162473fa71abfc0f9108583ec4456..aec76641e8e0804cce83713ed8488f29f7526766 100644 (file)
@@ -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
index 823989681d2bc85dd435c1eb0da6bb477dbefda8..cf444d3c1a37ca8717be79682a4d6207f5d2f940 100644 (file)
@@ -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
index c0fffdac719df781fd6df4c142d14fd5aa51c7d4..d8d4d55e27bf02f71e76898401be9c493e6bc446 100644 (file)
@@ -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
index b4c41f6189d7b4cc4b0be4cd5a1ed9711548c930..668d68853f140a4096fc3af97074ca7e45e812b7 100644 (file)
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 0
-LIBNAME  := hypfs
-USELIBS  := toollog toolcore call
 
 APPEND_LDFLAGS += -lz
 
index 764f5441e24242702ff66df0efb6abe0e8468553..19efc5e74322ee36140177426cf4bb138e185538 100644 (file)
@@ -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)
index 85ff2b26fd1e2e89e20417e4732cfa6b5591abd4..34b08a42360a1b82a298b2953cf502e51a29256f 100644 (file)
@@ -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
index 2d3ae4e6279ffc10fe18371b7f09cb77589d4381..3f986835d6db9dcfd06d989ff880b673b6e1f7ab 100644 (file)
@@ -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
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
new file mode 100644 (file)
index 0000000..db73fe3
--- /dev/null
@@ -0,0 +1,18 @@
+# Libraries below tools/libs/ and their dependencies
+
+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