1# 2# Copyright (c) 2020-2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3# 4# This software is licensed under the terms of the GNU General Public 5# License version 2, as published by the Free Software Foundation, and 6# may be copied, distributed, and modified under those terms. 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# 14 15ifeq ($(LOCAL_HCS_ROOT),) 16 LOCAL_HCS_ROOT := $(PRODUCT_PATH) 17endif 18CURRENT_DIR := $(abspath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 19SOURCE_ROOT := $(abspath $(CURRENT_DIR)/../../../../../) 20 21HC_GEN_DIR := $(abspath $(SOURCE_ROOT)/drivers/hdf_core/framework/tools/hc-gen) 22ifneq ($(OUT_DIR),) 23HC_GEN := $(OUT_DIR)/kernel/OBJ/${KERNEL_VERSION}/drivers/hdf/khdf/hc_gen_build/hc-gen 24else 25HC_GEN := $(HC_GEN_DIR)/build/hc-gen 26endif 27LOCAL_HCS_ROOT := $(CURRENT_DIR) 28 29HCS_DIR := $(LOCAL_HCS_ROOT) 30 31ifneq ($(TARGET_BOARD_PLATFORM),) 32 HCS_DIR := $(LOCAL_HCS_ROOT)/$(TARGET_BOARD_PLATFORM) 33else 34 ifneq ($(CONFIG_ARCH_HI3516DV300),) 35 HCS_DIR := $(LOCAL_HCS_ROOT) 36 endif 37 ifneq ($(CONFIG_ARCH_HI3518EV300),) 38 HCS_DIR := $(LOCAL_HCS_ROOT) 39 endif 40endif 41$(info HCS_DIR = $(HCS_DIR)) 42HCB_FLAGS := -b -i -a 43 44HCS_OBJ := hdf_hcs_hex.o 45HCS_OBJ_SRC := $(subst .o,.c,$(notdir $(HCS_OBJ))) 46 47CONFIG_GEN_HEX_SRC := $(addprefix $(LOCAL_HCS_ROOT)/, $(HCS_OBJ_SRC)) 48CONFIG_HCS_SRC := $(subst _hcs_hex.o,.hcs,$(addprefix $(HCS_DIR)/, $(HCS_OBJ))) 49 50$(obj)/$(HCS_OBJ): $(CONFIG_GEN_HEX_SRC) 51 $(Q)$(CC) $(c_flags) -c -o $@ $< 52 $(Q)rm -f $< 53 54$(CONFIG_GEN_HEX_SRC): $(LOCAL_HCS_ROOT)/%_hcs_hex.c: $(HCS_DIR)/%.hcs | $(HC_GEN) 55 $(Q)echo gen hdf built-in config 56 $(Q)if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 57 $(Q)$(HC_GEN) $(HCB_FLAGS) -o $(subst _hex.c,,$(@)) $< 58 59$(CONFIG_GEN_SRCS): $(CONFIG_OUT_DIR)%.c: $(HCS_DIR)/%.hcs | $(HC_GEN) 60 $(Q)echo gen hdf driver config 61 $(Q)if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 62 $(Q)$(HC_GEN) -t -o $@ $< 63 64$(HC_GEN): 65 $(HIDE)make -C $(HC_GEN_DIR) BUILD_DIR=$(dir $@) 66 67obj-$(CONFIG_DRIVERS_HDF) += $(HCS_OBJ) 68