build: install generated pkg-config files

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: I191ad5e3b153fb563256eba1aa695716f66db788
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6377
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jacek Kalwas 2021-02-10 10:28:48 -05:00 committed by Tomasz Zawadzki
parent e7f161a7d6
commit 6e2c2306f9
6 changed files with 48 additions and 9 deletions

View File

@ -128,7 +128,7 @@ mk/cc.mk:
false
build_dir: mk/cc.mk
$(Q)mkdir -p build/lib/pkgconfig
$(Q)mkdir -p build/lib/pkgconfig/tmp
$(Q)mkdir -p build/bin
$(Q)mkdir -p build/fio
$(Q)mkdir -p build/examples

View File

@ -48,9 +48,18 @@ include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
LIBDPDK_PKGCONFIG = $(call pkgconfig_filename,spdk_dpdklibs)
$(LIBDPDK_PKGCONFIG): $(PKGCONFIG)
$(LIBDPDK_PKGCONFIG): $(PKGCONFIG) $(PKGCONFIG_INST)
$(Q)$(SPDK_ROOT_DIR)/scripts/pc_libs.sh \
"-L$(DPDK_ABS_DIR)/lib $(DPDK_LIB_LIST:%=-l%)" "" DPDK spdk_dpdklibs > $@
$(Q)sed -i.bak '5s,.*,Requires: $(DEPDIRS-$(LIBNAME):%=spdk_%) spdk_dpdklibs,' $(PKGCONFIG) ; rm $(PKGCONFIG).bak
$(Q)sed -i.bak '5s,.*,Requires: $(DEPDIRS-$(LIBNAME):%=spdk_%) spdk_dpdklibs,' $(PKGCONFIG_INST) ; rm $(PKGCONFIG_INST).bak
_install_dpdklibs: $(LIBDPDK_PKGCONFIG)
@$(call pkgconfig_install,$(LIBDPDK_PKGCONFIG))
_uninstall_dpdklibs: $(LIBDPDK_PKGCONFIG)
@$(call pkgconfig_uninstall,$(LIBDPDK_PKGCONFIG))
all: $(LIBDPDK_PKGCONFIG)
install: _install_dpdklibs
uninstall: _uninstall_dpdklibs

View File

@ -369,6 +369,18 @@ UNINSTALL_LIB=\
rm -f "$(DESTDIR)$(libdir)/$(notdir $(LIB))"; \
if [ -d "$(DESTDIR)$(libdir)" ] && [ $$(ls -A "$(DESTDIR)$(libdir)" | wc -l) -eq 0 ]; then rm -rf "$(DESTDIR)$(libdir)"; fi
define pkgconfig_install
echo " INSTALL $(DESTDIR)$(libdir)/pkgconfig/$(notdir $(1))";
install -d -m 755 "$(DESTDIR)$(libdir)/pkgconfig";
install -m 644 "$(1)" "$(DESTDIR)$(libdir)/pkgconfig";
endef
define pkgconfig_uninstall
echo " UNINSTALL $(DESTDIR)$(libdir)/pkgconfig/$(notdir $(1))";
rm -f "$(DESTDIR)$(libdir)/pkgconfig/$(notdir $(1))";
if [ -d "$(DESTDIR)$(libdir)/pkgconfig" ] && [ $$(ls -A "$(DESTDIR)$(libdir)/pkgconfig" | wc -l) -eq 0 ]; then rm -rf "$(DESTDIR)$(libdir)/pkgconfig"; fi;
endef
ifeq ($(OS),FreeBSD)
INSTALL_REL_SYMLINK := install -l rs
else

View File

@ -54,13 +54,16 @@ SHARED_LINKED_LIB := $(LIB:.a=.so)
SHARED_REALNAME_LIB := $(SHARED_LINKED_LIB:.so=.so.$(SO_SUFFIX))
PKGCONFIG = $(call pkgconfig_filename,spdk_$(LIBNAME))
PKGCONFIG_INST = $(call pkgconfig_filename,tmp/spdk_$(LIBNAME))
ifeq ($(CONFIG_SHARED),y)
DEP := $(SHARED_LINKED_LIB) $(PKGCONFIG)
DEP := $(SHARED_LINKED_LIB)
else
DEP := $(LIB) $(PKGCONFIG)
DEP := $(LIB)
endif
DEP += $(PKGCONFIG) ${PKGCONFIG_INST}
ifeq ($(OS),FreeBSD)
LOCAL_SYS_LIBS += -L/usr/local/lib
endif
@ -104,22 +107,31 @@ $(SHARED_REALNAME_LIB): $(LIB)
$(Q)echo " SO $(notdir $@)"; \
$(call spdk_build_realname_shared_lib,$^,$(SPDK_MAP_FILE),$(LOCAL_SYS_LIBS),$(SPDK_DEP_LIBS))
$(PKGCONFIG): $(LIB)
$(Q)$(SPDK_ROOT_DIR)/scripts/pc.sh $(SPDK_ROOT_DIR) $(LIBNAME) $(SO_SUFFIX) \
define pkgconfig_create
$(Q)$(SPDK_ROOT_DIR)/scripts/pc.sh $(1) $(LIBNAME) $(SO_SUFFIX) \
"$(DEPDIRS-$(LIBNAME):%=spdk_%) $(MODULES-$(LIBNAME))" \
"" > $@
endef
$(PKGCONFIG): $(LIB)
$(call pkgconfig_create,$(SPDK_ROOT_DIR)/build)
$(PKGCONFIG_INST): $(LIB)
$(call pkgconfig_create,$(CONFIG_PREFIX))
$(LIB): $(OBJS)
$(LIB_C)
install: all
$(INSTALL_LIB)
@$(call pkgconfig_install,$(PKGCONFIG_INST))
ifeq ($(CONFIG_SHARED),y)
$(INSTALL_SHARED_LIB)
endif
uninstall: $(DIRS-y)
$(UNINSTALL_LIB)
@$(call pkgconfig_uninstall,$(PKGCONFIG_INST))
ifeq ($(CONFIG_SHARED),y)
$(UNINSTALL_SHARED_LIB)
endif

View File

@ -77,6 +77,12 @@ $(SYSLIBS_PKGCONFIG):
all: $(DIRS-y) $(MODULES_PKGCONFIG)
install: all
@$(foreach mod, $(MODULES_PKGCONFIG), $(call pkgconfig_install,$(mod)))
uninstall: $(DIRS-y)
@$(foreach mod, $(MODULES_PKGCONFIG), $(call pkgconfig_uninstall,$(mod)))
clean: $(DIRS-y)
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk

View File

@ -3,8 +3,8 @@ cat << EOF
Description: SPDK $2 library
Name: spdk_$2
Version: $3
Libs: -L$1/build/lib -lspdk_$2
Libs: -L$1/lib -lspdk_$2
Requires: $4
Libs.private: $5
Cflags: -I$1/build/include
Cflags: -I$1/include
EOF