xref: /spdk/test/external_code/hello_world/Makefile (revision 2608d129d01ad9c57f31e59f35e4a5df7fd7f1fa)
1488570ebSJim Harris#  SPDX-License-Identifier: BSD-3-Clause
2a6dbe372Spaul luse#  Copyright (C) 2020 Intel Corporation.
3*2608d129SAlexey Marchuk#  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES
435093786SSeth Howell#  All rights reserved.
535093786SSeth Howell#
635093786SSeth Howell
779f9a7f5SJim HarrisPKG_CONFIG_PATH = $(SPDK_LIB_DIR)/pkgconfig
879f9a7f5SJim Harris
979f9a7f5SJim HarrisDPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_env_dpdk)
10af935f76SBen WalkerSPDK_EVENT_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event spdk_event_bdev)
11af935f76SBen WalkerSPDK_DPDK_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs spdk_event spdk_event_bdev spdk_env_dpdk)
1279f9a7f5SJim HarrisSYS_LIB := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs --static spdk_syslibs)
13d792356aSJim Harris
146b41a086SDarek Stojaczyk# Shows how to compile both an external bdev and an external application against the SPDK combined shared object and dpdk shared objects.
1535093786SSeth Howellbdev_shared_combo:
166b41a086SDarek Stojaczyk	$(CC) $(COMMON_CFLAGS) -L../passthru -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c -lpassthru_external \
17*2608d129SAlexey Marchuk	-lspdk $(DPDK_LIB) -Wl,--no-whole-archive $(SYS_LIB)
1835093786SSeth Howell
196b41a086SDarek Stojaczyk# Shows how to compile both an external bdev and an external application against the SPDK individual shared objects and dpdk shared objects.
2035093786SSeth Howellbdev_shared_iso:
2179f9a7f5SJim Harris	$(CC) $(COMMON_CFLAGS) -L../passthru -Wl,--no-as-needed -o hello_bdev ./hello_bdev.c \
22af935f76SBen Walker	-lpassthru_external $(SPDK_EVENT_LIB) \
23*2608d129SAlexey Marchuk	$(DPDK_LIB) $(SYS_LIB)
2435093786SSeth Howell
256b41a086SDarek Stojaczyk# Shows how to compile an external application against the SPDK combined shared object and dpdk shared objects.
2635093786SSeth Howellalone_shared_combo:
27*2608d129SAlexey Marchuk	$(CC) $(COMMON_CFLAGS) -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c -lspdk $(DPDK_LIB) $(SYS_LIB)
2835093786SSeth Howell
296b41a086SDarek Stojaczyk# Shows how to compile an external application against the SPDK individual shared objects and dpdk shared objects.
3035093786SSeth Howellalone_shared_iso:
3179f9a7f5SJim Harris	$(CC) $(COMMON_CFLAGS) -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c \
32*2608d129SAlexey Marchuk	$(SPDK_EVENT_LIB) $(DPDK_LIB) $(SYS_LIB)
3335093786SSeth Howell
3435093786SSeth Howell# Shows how to compile an external application against the SPDK archives.
3535093786SSeth Howellalone_static:
36f758833eSJacek Kalwas	$(CC) $(COMMON_CFLAGS) -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic \
37f758833eSJacek Kalwas	$(SPDK_DPDK_LIB) -Wl,--no-whole-archive,-Bdynamic $(SYS_LIB)
3835093786SSeth Howell
39c9c7c281SJosh Soref# Shows how to compile and external bdev and application against the SPDK archives.
4035093786SSeth Howellbdev_static:
41f758833eSJacek Kalwas	$(CC) $(COMMON_CFLAGS) -L../passthru -o hello_bdev ./hello_bdev.c -pthread -Wl,--whole-archive,-Bstatic -lpassthru_external $(SPDK_DPDK_LIB) \
4279f9a7f5SJim Harris	-Wl,--no-whole-archive,-Bdynamic $(SYS_LIB)
43