1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (C) 2015 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 ut 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) 39SPDK_LIB_LIST += env_dpdk 40endif 41 42install: all 43 44all: $(APP) 45 @: 46 47$(APP) : $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS) 48 $(LINK_C) 49 50clean: 51 $(CLEAN_C) $(APP) 52 53include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk 54 55uninstall: 56 @: 57