xref: /spdk/mk/spdk.unittest.mk (revision 18c8b52afa69f39481ebb75711b2f30b11693f9d)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (c) Intel Corporation.
3#  All rights reserved.
4#
5
6include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
7include $(SPDK_ROOT_DIR)/mk/spdk.app_vars.mk
8include $(SPDK_ROOT_DIR)/mk/spdk.mock.unittest.mk
9
10# We don't want to run scan-build against the unit tests
11# because it can't understand our mock function macros and
12# throws false positives because of them.
13
14# Scan-build inserts a phony compiler by overriding the value
15# of CC, so we store the original CC under DEFAULT_CC and
16# re-assign it here.
17override CC=$(DEFAULT_CC)
18
19C_SRCS = $(TEST_FILE)
20
21CFLAGS += -I$(SPDK_ROOT_DIR)/lib
22CFLAGS += -I$(SPDK_ROOT_DIR)/module
23CFLAGS += -I$(SPDK_ROOT_DIR)/test
24CFLAGS += -ffunction-sections
25CFLAGS += -DSPDK_UNIT_TEST=1
26LDFLAGS += -Wl,--gc-sections
27
28SPDK_LIB_LIST += thread trace util log
29
30LIBS += -lcunit $(SPDK_STATIC_LIB_LINKER_ARGS)
31
32APP = $(TEST_FILE:.c=)$(EXEEXT)
33
34ifneq ($(UNIT_TEST_LINK_ENV),1)
35ENV_LINKER_ARGS =
36else
37# Rewrite the env linker args to be static.
38ENV_DPDK_FILE = $(call spdk_lib_list_to_static_libs,env_dpdk)
39endif
40
41install: all
42
43all: $(APP)
44	@:
45
46$(APP) : $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS)
47	$(LINK_C)
48
49clean:
50	$(CLEAN_C) $(APP)
51
52include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
53
54uninstall:
55	@:
56