tools: generate pkg-config files from make variables

For each library built two variants of pkg-config files are created
from a per-library template: an "official" one for installation on
the user's system, and one used for building internal tools, like e.g.
qemu.

Instead of the template which is looking very similar for all libraries
generate the pkg-config files directly from make variables.

This will reduce the need to specify some pkg-config file entries in
the templates, as the contents can easily be generated from available
data (e.g. "Version:" and "Requires.private:" entries).

Especially the variant used for building internal tools needs to gain
additional runtime link parameters for the internally used libraries,
as otherwise those won't be found by the users (e.g. qemu).

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
This commit is contained in:
Juergen Gross authored and Wei Liu committed 2020-09-09 10:57:16 +00:00
1 parent 1e2d3be2e5
commit 52dbd6f07c
24 files changed
+97 -176

No files matched your search

-1
View File
@@ -342,7 +342,6 @@ define do_links
cd $(dir $@); \
ln -sf $(dir $<)include/*.h include/; \
ln -sf $(dir $<)*.[ch] .; \
ln -sf $(dir $<)*.pc.in .; \
ln -sf $(dir $<)Makefile .
touch $@
endef
+28 -22
View File
@@ -209,27 +209,33 @@ endif
PKG_CONFIG_DIR ?= $(XEN_ROOT)/tools/pkg-config
PKG_CONFIG_FILTER = $(foreach l,$(PKG_CONFIG_REMOVE),-e 's!\([ ,]\)$(l),!\1!g' -e 's![ ,]$(l)$$!!g')
$(PKG_CONFIG_DIR)/%.pc: %.pc.in Makefile $(XEN_ROOT)/tools/Rules.mk
$(PKG_CONFIG_DIR):
mkdir -p $(PKG_CONFIG_DIR)
@sed -e 's!@@version@@!$(PKG_CONFIG_VERSION)!g' \
-e 's!@@prefix@@!$(PKG_CONFIG_PREFIX)!g' \
-e 's!@@incdir@@!$(PKG_CONFIG_INCDIR)!g' \
-e 's!@@libdir@@!$(PKG_CONFIG_LIBDIR)!g' \
-e 's!@@firmwaredir@@!$(XENFIRMWAREDIR)!g' \
-e 's!@@libexecbin@@!$(LIBEXEC_BIN)!g' \
-e 's!@@cflagslocal@@!$(PKG_CONFIG_CFLAGS_LOCAL)!g' \
-e 's!@@libsflag@@\([^ ]*\)!-L\1 -Wl,-rpath-link=\1!g' \
$(PKG_CONFIG_FILTER) < $< > $@
%.pc: %.pc.in Makefile $(XEN_ROOT)/tools/Rules.mk
@sed -e 's!@@version@@!$(PKG_CONFIG_VERSION)!g' \
-e 's!@@prefix@@!$(PKG_CONFIG_PREFIX)!g' \
-e 's!@@incdir@@!$(PKG_CONFIG_INCDIR)!g' \
-e 's!@@libdir@@!$(PKG_CONFIG_LIBDIR)!g' \
-e 's!@@firmwaredir@@!$(XENFIRMWAREDIR)!g' \
-e 's!@@libexecbin@@!$(LIBEXEC_BIN)!g' \
-e 's!@@cflagslocal@@!!g' \
-e 's!@@libsflag@@!-L!g' \
$(PKG_CONFIG_FILTER) < $< > $@
$(PKG_CONFIG_DIR)/%.pc: Makefile $(XEN_ROOT)/tools/Rules.mk $(PKG_CONFIG_DIR)
$(file >$@,prefix=$(PKG_CONFIG_PREFIX))
$(file >>$@,includedir=$(PKG_CONFIG_INCDIR))
$(file >>$@,libdir=$(PKG_CONFIG_LIBDIR))
$(foreach var,$(PKG_CONFIG_VARS),$(file >>$@,$(var)))
$(file >>$@,)
$(file >>$@,Name: $(PKG_CONFIG_NAME))
$(file >>$@,Description: $(PKG_CONFIG_DESC))
$(file >>$@,Version: $(PKG_CONFIG_VERSION))
$(file >>$@,Cflags: -I$${includedir} $(CFLAGS_xeninclude))
$(file >>$@,Libs: -L$${libdir} $(PKG_CONFIG_USELIBS) -l$(PKG_CONFIG_LIB))
$(file >>$@,Libs.private: $(PKG_CONFIG_LIBSPRIV))
$(file >>$@,Requires.private: $(PKG_CONFIG_REQPRIV))
%.pc: Makefile $(XEN_ROOT)/tools/Rules.mk
$(file >$@,prefix=$(PKG_CONFIG_PREFIX))
$(file >>$@,includedir=$(PKG_CONFIG_INCDIR))
$(file >>$@,libdir=$(PKG_CONFIG_LIBDIR))
$(foreach var,$(PKG_CONFIG_VARS),$(file >>$@,$(var)))
$(file >>$@,)
$(file >>$@,Name: $(PKG_CONFIG_NAME))
$(file >>$@,Description: $(PKG_CONFIG_DESC))
$(file >>$@,Version: $(PKG_CONFIG_VERSION))
$(file >>$@,Cflags: -I$${includedir})
$(file >>$@,Libs: -L$${libdir} -l$(PKG_CONFIG_LIB))
$(file >>$@,Libs.private: $(PKG_CONFIG_LIBSPRIV))
$(file >>$@,Requires.private: $(PKG_CONFIG_REQPRIV))
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xencall
Description: The Xencall library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxencall
Requires.private: xentoollog,xentoolcore
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xendevicemodel
Description: The Xendevicemodel library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxendevicemodel
Requires.private: xentoolcore,xentoollog,xencall
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenevtchn
Description: The Xenevtchn library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxenevtchn
Requires.private: xentoollog
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenforeignmemory
Description: The Xenforeignmemory library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxenforeignmemory
Requires.private: xentoollog,xentoolcore
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xengnttab
Description: The Xengnttab library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxengnttab
Requires.private: xentoollog,xentoolcore
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenhypfs
Description: The Xenhypfs library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxenhypfs
Requires.private: xentoolcore,xentoollog,xencall,zlib
+8
View File
@@ -25,8 +25,16 @@ ifneq ($(nosharedlibs),y)
LIB += libxen$(LIBNAME).so
endif
comma:= ,
empty:=
space:= $(empty) $(empty)
PKG_CONFIG ?= xen$(LIBNAME).pc
PKG_CONFIG_NAME ?= Xen$(LIBNAME)
PKG_CONFIG_DESC ?= The $(PKG_CONFIG_NAME) library for Xen hypervisor
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
PKG_CONFIG_USELIBS := $(SHLIB_libxen$(LIBNAME))
PKG_CONFIG_LIB := xen$(LIBNAME)
PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(USELIBS_$(LIBNAME)),xen$(lib))))
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
+1
View File
@@ -9,6 +9,7 @@ SRCS-y += handlereg.c
include $(XEN_ROOT)/tools/libs/libs.mk
PKG_CONFIG_DESC := Central support for Xen Hypervisor userland libraries
$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxentoolcore)/include
$(LIB_OBJS): $(AUTOINCS)
-9
View File
@@ -1,9 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xentoolcore
Description: Central support for Xen Hypervisor userland libraries
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxentoolcore
-9
View File
@@ -1,9 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xentoollog
Description: The Xentoollog library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxentoollog
+5
View File
@@ -23,7 +23,12 @@ CFLAGS += -I../include -I.
io.o io.opic: CFLAGS += $(CFLAGS_libxenctrl) # for xen_mb et al
PKG_CONFIG := xenvchan.pc
PKG_CONFIG_NAME := Xenvchan
PKG_CONFIG_DESC := The Xenvchan library for Xen hypervisor
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
PKG_CONFIG_USELIBS := $(SHLIB_libxenvchan)
PKG_CONFIG_LIB := xenvchan
PKG_CONFIG_REQPRIV := xentoollog,xenstore,xenevtchn,xengnttab
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenvchan
Description: The Xenvchan library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxenvchan
Requires.private: xentoollog,xenstore,xenevtchn,xengnttab
+22
View File
@@ -158,6 +158,28 @@ $(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h
PKG_CONFIG := xencontrol.pc xenguest.pc
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
xencontrol.pc: PKG_CONFIG_LIB = xenctrl
xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
xenguest.pc: PKG_CONFIG_NAME = Xenguest
xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
xenguest.pc: PKG_CONFIG_LIB = xenguest
xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_LIB = xenctrl
$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_NAME = Xenguest
$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_LIB = xenguest
$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xencontrol
Description: The Xencontrol library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxenctrl
Requires.private: xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenguest
Description: The Xenguest library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxenguest
Requires.private: xentoollog,xencall,xenforeignmemory,xenevtchn
+22
View File
@@ -195,8 +195,19 @@ PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
xenlight.pc: PKG_CONFIG_NAME = Xenlight
xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
xenlight.pc: PKG_CONFIG_LIB = xenlight
xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
xlutil.pc: PKG_CONFIG_NAME = Xlutil
xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
xlutil.pc: PKG_CONFIG_LIB = xlutil
xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
@@ -204,8 +215,19 @@ endif
PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_NAME = Xenlight
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_LIB = xenlight
$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_NAME = Xlutil
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_LIB = xlutil
$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(CURDIR)
$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
-12
View File
@@ -1,12 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
xenfirmwaredir=@@firmwaredir@@
libexec_bin=@@libexecbin@@
Name: Xenlight
Description: The Xenlight library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxenlight
Requires.private: xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xlutil
Description: The xl utility library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxlutil
Requires.private: xenlight
+5
View File
@@ -38,7 +38,12 @@ LDLIBS-y = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -lyajl
LDLIBS-$(CONFIG_SunOS) += -lkstat
PKG_CONFIG := xenstat.pc
PKG_CONFIG_NAME := Xenstat
PKG_CONFIG_DESC := The Xenstat library for Xen hypervisor
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
PKG_CONFIG_USELIBS := $(SHLIB_libxenstat)
PKG_CONFIG_LIB := xenstat
PKG_CONFIG_REQPRIV := xencontrol,xenstore
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
-10
View File
@@ -1,10 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenstat
Description: The Xenstat library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir}
Libs: @@libsflag@@${libdir} -lxenstat
Requires.private: xencontrol,xenstore
+6 -2
View File
@@ -105,8 +105,7 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
ifeq ($(CONFIG_Linux),y)
xs.opic: CFLAGS += -DUSE_DLSYM
libxenstore.so.$(MAJOR).$(MINOR): APPEND_LDFLAGS += -ldl
else
PKG_CONFIG_REMOVE += -ldl
PKG_CONFIG_LIBSPRIV := -ldl
endif
libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
@@ -116,7 +115,12 @@ libxenstore.a: xs.o xs_lib.o
$(AR) rcs $@ $^
PKG_CONFIG := xenstore.pc
PKG_CONFIG_NAME := Xenstore
PKG_CONFIG_DESC := The Xenstore library for Xen hypervisor
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
PKG_CONFIG_USELIBS := $(SHLIB_libxenstore)
PKG_CONFIG_LIB := xenstore
PKG_CONFIG_REQPRIV := xenevtchn,xencontrol,xengnttab,xentoolcore
ifneq ($(CONFIG_LIBXC_MINIOS),y)
PKG_CONFIG_INST := $(PKG_CONFIG)
-11
View File
@@ -1,11 +0,0 @@
prefix=@@prefix@@
includedir=@@incdir@@
libdir=@@libdir@@
Name: Xenstore
Description: The Xenstore library for Xen hypervisor
Version: @@version@@
Cflags: -I${includedir} @@cflagslocal@@
Libs: @@libsflag@@${libdir} -lxenstore
Libs.private: -ldl
Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.