1# Copyright (C) 2022 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 17ifeq ($(CFG_PRODUCT_TYPE),liteos) 18#=============================================================================== 19#=============================================================================== 20ifndef LITEOSTOPDIR 21.EXPORT_ALL_VARIABLES: 22CUR_DIR=${PWD} 23SUB_DIR=/source/msp/drv/i2c 24TOP_DIR=$(subst $(SUB_DIR),,$(CUR_DIR)) 25SOURCE_DIR=$(TOP_DIR)/source 26include $(TOP_DIR)/base.mak 27endif 28 29depends := gpio_i2c 30depends += std_i2c 31 32############################################################################### 33# rules 34############################################################################### 35.PHONY: all clean $(depends) 36 37all: $(depends) 38 39$(depends): 40 make -C $@ 41 42clean: 43 for dir in $(depends); \ 44 do make -C $$dir clean || exit 1; \ 45 done 46else 47 48#======================================= 49# export variable 50#======================================= 51ifeq ($(CFG_HI_EXPORT_FLAG),) 52 ifneq ($(KERNELRELEASE),) 53 KERNEL_DIR := $(srctree) 54 55 SDK_DIR := $(KERNEL_DIR)/../../.. 56 else 57 SDK_DIR := $(CURDIR)/../../../.. 58 endif 59 60 ifneq ($(SDK_SOURCE_DIR),) 61 SDK_DIR := $(SDK_SOURCE_DIR)/.. 62 endif 63 64include $(SDK_DIR)/base.mak 65endif 66 67#======================================= 68# local variable 69#======================================= 70#objects:=${subst /,,${shell ls -d */}} 71objects := 72 73ifeq ($(CFG_HI_GPIOI2C_SUPPORT),y) 74CFG_HI_KMOD_CFLAGS += -DHI_GPIOI2C_SUPPORT 75objects += gpio_i2c 76endif 77 78objects += std_i2c 79 80objects_clean:=${addsuffix _clean,${objects}} 81objects_install:=${addsuffix _install,${objects}} 82objects_uninstall:=${addsuffix _uninstall,${objects}} 83 84ifeq ($(CFG_MSP_BUILDTYPE),y) 85obj-$(CFG_MSP_BUILDTYPE) += ${addsuffix /,${objects}} 86endif 87#================================================================= 88# rules 89#================================================================= 90 91.PHONY: all clean install uninstall ${objects} ${objects_clean} ${objects_install} ${objects_uninstall} 92 93all: ${objects} 94 95clean: ${objects_clean} 96 $(AT)rm -rf *.o 97 $(AT)rm -rf .*.o.cmd 98 $(AT)rm -rf modules.order modules.builtin 99 100install: ${objects_install} 101 102uninstall: ${objects_uninstall} 103 104${objects}: 105 make -C $@ 106 107${objects_clean}: 108 make -C ${patsubst %_clean,%,$@} clean 109 110${objects_install}: 111 make -C ${patsubst %_install,%,$@} install 112 113${objects_uninstall}: 114 make -C ${patsubst %_uninstall,%,$@} uninstall 115 116endif 117