1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (C) 2019 Intel Corporation. 3# All rights reserved. 4# 5 6# OCF requires users to build with their sources 7# If SPDK is configured with OCF source directory, 8# we export its files and then compile SPDK LIB with them 9# Else if SPDK is configured with OCF precompiled library 10# we just use it as SPDK lib by copying it to /build/lib/ 11 12SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) 13OCFDIR=$(CONFIG_OCF_DIR) 14 15include $(SPDK_ROOT_DIR)/mk/spdk.common.mk 16 17LIBNAME := ocfenv 18 19CFLAGS += $(ENV_CFLAGS) -I$(CURDIR) -I$(CURDIR)/include -w -MMD 20C_SRCS = $(shell find -name \*.c) 21 22LIB = $(call spdk_lib_list_to_static_libs,$(LIBNAME)) 23 24 25ifeq ($(CONFIG_CUSTOMOCF),y) 26 27.PHONY: all clean install 28 29all: 30 $(Q)$(MAKE) $(LIB) 31 32clean: 33 $(Q)rm -f $(LIB) 34 35$(LIB): 36 cp $(CONFIG_OCF_PATH) $(LIB) 37 38install: 39 40uninstall: 41 $(UNINSTALL_LIB) 42 43else 44 45.PHONY: all clean install ocf_inc ocf_src ocf_distclean all exportlib 46 47all: ocf_inc ocf_src 48 $(Q)$(MAKE) $(LIB) 49 50ocf_inc: 51 $(Q)$(MAKE) -C "$(CONFIG_OCF_PATH)" inc O="$(SPDK_ROOT_DIR)/lib/env_ocf/" ENV= --quiet 52 53ocf_src: ocf_inc 54 $(Q)$(MAKE) -C "$(CONFIG_OCF_PATH)" src O="$(SPDK_ROOT_DIR)/lib/env_ocf/" CMD=cp ENV= --quiet 55 56ocf_distclean: 57 $(Q)$(MAKE) -C "$(CONFIG_OCF_PATH)" distclean O="$(SPDK_ROOT_DIR)/lib/env_ocf/" ENV= --quiet 58 59clean: ocf_distclean 60 $(Q)rm -rf "$(SPDK_ROOT_DIR)/lib/env_ocf/include" \ 61 "$(SPDK_ROOT_DIR)/lib/env_ocf/src" \ 62 $(LIB) $(OBJS); 63 64$(LIB): $(OBJS) 65 $(LIB_C) 66 67-include $(OBJS:.o=.d) 68 69install: 70 71uninstall: 72 $(UNINSTALL_LIB) 73 74endif 75 76exportlib: all 77 @ if [ -z $(O) ]; then echo "No output specified"; exit 1; fi 78 cp $(LIB) $(O) 79 80help: 81 @ echo "all Default" 82 @ echo "exportlib O=<outpath> Default build to specified outpath" 83