build: combine env_dpdk / event_bdev so pkgconfig can de-duplicate deps

- it shows nice feature and usage of pkg-config
- it also prevents from duplicate symbols issue for static build in
case listed libs have a common dependencies

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: I1f470d202ea7efe03e354dca472fd50e97bca747
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6406
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jacek Kalwas 2021-02-12 13:28:04 -05:00 committed by Tomasz Zawadzki
parent 9b18966796
commit f758833ef8

View File

@ -35,6 +35,7 @@ PKG_CONFIG_PATH = $(SPDK_LIB_DIR)/pkgconfig
DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_env_dpdk) DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_env_dpdk)
SPDK_BDEV_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event_bdev) SPDK_BDEV_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event_bdev)
SPDK_DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event_bdev spdk_env_dpdk)
SYS_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs --static spdk_syslibs) SYS_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs --static spdk_syslibs)
# Shows how to compile both an external bdev and an external application against the SPDK combined shared object and dpdk shared objects. # Shows how to compile both an external bdev and an external application against the SPDK combined shared object and dpdk shared objects.
@ -59,10 +60,10 @@ alone_shared_iso:
# Shows how to compile an external application against the SPDK archives. # Shows how to compile an external application against the SPDK archives.
alone_static: alone_static:
$(CC) $(COMMON_CFLAGS) -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic $(SPDK_BDEV_LIB) \ $(CC) $(COMMON_CFLAGS) -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic \
$(DPDK_LIB) -Wl,--no-whole-archive,-Bdynamic $(SYS_LIB) $(SPDK_DPDK_LIB) -Wl,--no-whole-archive,-Bdynamic $(SYS_LIB)
# Shows how to compile and external bdev and application sgainst the SPDK archives. # Shows how to compile and external bdev and application sgainst the SPDK archives.
bdev_static: bdev_static:
$(CC) $(COMMON_CFLAGS) -L../passthru -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic -lpassthru_external $(SPDK_BDEV_LIB) $(DPDK_LIB) \ $(CC) $(COMMON_CFLAGS) -L../passthru -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic -lpassthru_external $(SPDK_DPDK_LIB) \
-Wl,--no-whole-archive,-Bdynamic $(SYS_LIB) -Wl,--no-whole-archive,-Bdynamic $(SYS_LIB)