1# 2# Copyright (c) 2020-2021 Huawei Device 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 18 19SOURCE_ROOT:=$(abspath ../../../../../) 20 21HC_GEN_DIR := $(abspath $(SOURCE_ROOT)/drivers/framework/tools/hc-gen) 22HC_GEN := $(HC_GEN_DIR)/build/hc-gen 23LOCAL_HCS_ROOT := $(abspath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) 24 25HCS_DIR := $(LOCAL_HCS_ROOT) 26 27ifneq ($(TARGET_BOARD_PLATFORM),) 28 HCS_DIR := $(LOCAL_HCS_ROOT)/$(TARGET_BOARD_PLATFORM) 29else 30 ifneq ($(CONFIG_ARCH_HI3516DV300),) 31 HCS_DIR := $(LOCAL_HCS_ROOT) 32 endif 33 ifneq ($(CONFIG_ARCH_HI3518EV300),) 34 HCS_DIR := $(LOCAL_HCS_ROOT) 35 endif 36endif 37$(info HCS_DIR = $(HCS_DIR)) 38HCB_FLAGS := -b -i -a 39 40HCS_OBJ := hdf_hcs_hex.o 41HCS_OBJ_SRC := $(subst .o,.c,$(notdir $(HCS_OBJ))) 42 43CONFIG_GEN_HEX_SRC := $(addprefix $(LOCAL_HCS_ROOT)/, $(HCS_OBJ_SRC)) 44CONFIG_HCS_SRC := $(subst _hcs_hex.o,.hcs,$(addprefix $(HCS_DIR)/, $(HCS_OBJ))) 45 46$(obj)/$(HCS_OBJ): $(CONFIG_GEN_HEX_SRC) 47 $(Q)$(CC) $(c_flags) -c -o $@ $< 48 $(Q)rm -f $< 49 50$(CONFIG_GEN_HEX_SRC): $(LOCAL_HCS_ROOT)/%_hcs_hex.c: $(HCS_DIR)/%.hcs | $(HC_GEN) 51 $(Q)echo gen hdf built-in config 52 $(Q)if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 53 $(Q)$(HC_GEN) $(HCB_FLAGS) -o $(subst _hex.c,,$(@)) $< 54 55$(CONFIG_GEN_SRCS): $(CONFIG_OUT_DIR)%.c: $(HCS_DIR)/%.hcs | $(HC_GEN) 56 $(Q)echo gen hdf driver config 57 $(Q)if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi 58 $(Q)$(HC_GEN) -t -o $@ $< 59 60$(HC_GEN): 61 $(HIDE)make -C $(HC_GEN_DIR) 62 63obj-$(CONFIG_DRIVERS_HDF) += $(HCS_OBJ) 64