1# Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public License
5# as published by the Free Software Foundation; either version 2
6# of the License, or (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17CIPHER_DRV_OBJS += drv/cipher_initdevice.o
18
19OBJS := $(CIPHER_API_OBJS)
20
21TARGET := hi_cipher
22obj-m := hi_cipher.o
23hi_cipher-y += $(CIPHER_DRV_OBJS) $(MBEDTLS_LIB)
24
25#*************************************************************************
26.PHONY: all clean build_env mbedtls_prepare mbedtls_clean
27
28all: build_env
29	@cp $(MBEDTLS_DIR)/lib.a $(MBEDTLS_LIB)
30	@make -C $(KERNEL_ROOT) M=$(PWD) $(COMPILER_TRIPLE) modules
31	@mkdir -p $(REL_KO) && cp -rf $(TARGET).ko $(REL_KO)
32
33clean :
34	@rm -f *.asm
35	@rm -f $(OBJS)
36	@rm -f $(CIPHER_REL_INC)
37	@rm -f $(REL_KO)/$(TARGET).ko
38	@make -C $(KERNEL_ROOT) M=$(PWD) $(COMPILER_TRIPLE) clean
39
40mbedtls_prepare:
41	@cd $(MBEDTLS_DIR) && make mbedtls_patch && make
42
43mbedtls_clean:
44	@cd $(MBEDTLS_DIR) && make clean
45
46build_env:
47	@echo -e "\e[0;32;1m... Configs as follow:\e[0;36;1m"
48	@echo ---- CROSS=$(CROSS)
49	@echo ---- HIARCH=$(HIARCH), HICHIP=$(HICHIP), CVER=$(CVER), DBG=$(HIDBG), HI_FPGA=$(HI_FPGA)
50	@echo ---- CPU_TYPE=$(CPU_TYPE)
51	@echo ---- MPP_CFLAGS=$(MPP_CFLAGS)
52	@echo ---- SDK_PATH=$(SDK_PATH) , PARAM_FILE=$(PARAM_FILE)
53	@echo ---- KERNEL_ROOT=$(KERNEL_ROOT)
54	@echo ---- ARCH_ROOT=$(ARCH_ROOT), ARCH_HAL=$(ARCH_HAL)
55	@echo -e "\e[0m"
56
57