13d8536b4Sopenharmony_ci# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 23d8536b4Sopenharmony_ci# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 33d8536b4Sopenharmony_ci# 43d8536b4Sopenharmony_ci# Redistribution and use in source and binary forms, with or without modification, 53d8536b4Sopenharmony_ci# are permitted provided that the following conditions are met: 63d8536b4Sopenharmony_ci# 73d8536b4Sopenharmony_ci# 1. Redistributions of source code must retain the above copyright notice, this list of 83d8536b4Sopenharmony_ci# conditions and the following disclaimer. 93d8536b4Sopenharmony_ci# 103d8536b4Sopenharmony_ci# 2. Redistributions in binary form must reproduce the above copyright notice, this list 113d8536b4Sopenharmony_ci# of conditions and the following disclaimer in the documentation and/or other materials 123d8536b4Sopenharmony_ci# provided with the distribution. 133d8536b4Sopenharmony_ci# 143d8536b4Sopenharmony_ci# 3. Neither the name of the copyright holder nor the names of its contributors may be used 153d8536b4Sopenharmony_ci# to endorse or promote products derived from this software without specific prior written 163d8536b4Sopenharmony_ci# permission. 173d8536b4Sopenharmony_ci# 183d8536b4Sopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 193d8536b4Sopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 203d8536b4Sopenharmony_ci# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 213d8536b4Sopenharmony_ci# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 223d8536b4Sopenharmony_ci# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 233d8536b4Sopenharmony_ci# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 243d8536b4Sopenharmony_ci# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 253d8536b4Sopenharmony_ci# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 263d8536b4Sopenharmony_ci# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 273d8536b4Sopenharmony_ci# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 283d8536b4Sopenharmony_ci# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 293d8536b4Sopenharmony_ci 303d8536b4Sopenharmony_ciLITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) 313d8536b4Sopenharmony_ciexport LITEOSTOPDIR 323d8536b4Sopenharmony_ci 333d8536b4Sopenharmony_ciLITEOS_TARGET = liteos 343d8536b4Sopenharmony_ciHIDE := @ 353d8536b4Sopenharmony_ciKCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config)) 363d8536b4Sopenharmony_ci 373d8536b4Sopenharmony_ciohos_kernel ?= liteos_m 383d8536b4Sopenharmony_ci$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line))) 393d8536b4Sopenharmony_ciifneq ($(ohos_kernel),liteos_m) 403d8536b4Sopenharmony_ci$(error The selected product ($(ohos_product)) is not a liteos_m kernel type product) 413d8536b4Sopenharmony_ciendif 423d8536b4Sopenharmony_ci 433d8536b4Sopenharmony_ciifeq ($(PRODUCT_PATH),) 443d8536b4Sopenharmony_ciPRODUCT_PATH:=$(ohos_product_path) 453d8536b4Sopenharmony_ciendif 463d8536b4Sopenharmony_ci 473d8536b4Sopenharmony_ciifeq ($(DEVICE_PATH),) 483d8536b4Sopenharmony_ciDEVICE_PATH:=$(ohos_device_path) 493d8536b4Sopenharmony_ciendif 503d8536b4Sopenharmony_ci 513d8536b4Sopenharmony_ciifeq ($(BOARD_COMPANY),) 523d8536b4Sopenharmony_ciBOARD_COMPANY:=$(ohos_device_company) 533d8536b4Sopenharmony_ciendif 543d8536b4Sopenharmony_ci 553d8536b4Sopenharmony_ciifeq ($(TEE:1=y),y) 563d8536b4Sopenharmony_citee = _tee 573d8536b4Sopenharmony_ciendif 583d8536b4Sopenharmony_ciifeq ($(RELEASE:1=y),y) 593d8536b4Sopenharmony_ciCONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config 603d8536b4Sopenharmony_cielse 613d8536b4Sopenharmony_ciCONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config 623d8536b4Sopenharmony_ciendif 633d8536b4Sopenharmony_ci 643d8536b4Sopenharmony_ciKCONFIG_CONFIG ?= $(CONFIG) 653d8536b4Sopenharmony_ciLITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h 663d8536b4Sopenharmony_ciLITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config 673d8536b4Sopenharmony_ci 683d8536b4Sopenharmony_ci# export los_config.mk related environment variables 693d8536b4Sopenharmony_ciexport LITEOS_MENUCONFIG_H 703d8536b4Sopenharmony_ciexport LITEOS_CONFIG_FILE 713d8536b4Sopenharmony_ciexport BOARD_COMPANY 723d8536b4Sopenharmony_ciexport DEVICE_PATH 733d8536b4Sopenharmony_ciexport PRODUCT_PATH 743d8536b4Sopenharmony_ci 753d8536b4Sopenharmony_ci# export kconfig related environment variables 763d8536b4Sopenharmony_ciexport CONFIG_=LOSCFG_ 773d8536b4Sopenharmony_ciexport srctree=$(LITEOSTOPDIR) 783d8536b4Sopenharmony_ci 793d8536b4Sopenharmony_ci-include $(LITEOS_CONFIG_FILE) 803d8536b4Sopenharmony_ci 813d8536b4Sopenharmony_cidefine HELP = 823d8536b4Sopenharmony_ciUsage: make [TARGET]... [PARAMETER=VALUE]... 833d8536b4Sopenharmony_ci 843d8536b4Sopenharmony_ciTargets: 853d8536b4Sopenharmony_ci help: display this help and exit 863d8536b4Sopenharmony_ci clean: clean compiled objects 873d8536b4Sopenharmony_ci cleanall: clean all build outputs 883d8536b4Sopenharmony_ci all: do build (Default target) 893d8536b4Sopenharmony_ci update_config: update product kernel config (use menuconfig) 903d8536b4Sopenharmony_ci xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS)) 913d8536b4Sopenharmony_ci 923d8536b4Sopenharmony_ciParameters: 933d8536b4Sopenharmony_ci TEE: boolean value(1 or y for true), enable tee 943d8536b4Sopenharmony_ci RELEASE: boolean value(1 or y for true), build release version 953d8536b4Sopenharmony_ci CONFIG: kernel config file to be use 963d8536b4Sopenharmony_ci args: arguments for xxconfig command 973d8536b4Sopenharmony_ciendef 983d8536b4Sopenharmony_ciexport HELP 993d8536b4Sopenharmony_ci 1003d8536b4Sopenharmony_ciall: 1013d8536b4Sopenharmony_ci $(HIDE)hb build -f --gn-args "liteos_kernel_only=true liteos_name=\"$(LITEOS_TARGET)\"" 1023d8536b4Sopenharmony_ci 1033d8536b4Sopenharmony_cihelp: 1043d8536b4Sopenharmony_ci $(HIDE)echo "$$HELP" 1053d8536b4Sopenharmony_ci 1063d8536b4Sopenharmony_ci$(filter-out menuconfig,$(KCONFIG_CMDS)): 1073d8536b4Sopenharmony_ci $(HIDE)$@ $(args) 1083d8536b4Sopenharmony_ci 1093d8536b4Sopenharmony_ci$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG) 1103d8536b4Sopenharmony_ci $(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H) 1113d8536b4Sopenharmony_ci 1123d8536b4Sopenharmony_ciupdate_config menuconfig: 1133d8536b4Sopenharmony_ci $(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)" 1143d8536b4Sopenharmony_ci 1153d8536b4Sopenharmony_ciclean: 1163d8536b4Sopenharmony_ci $(HIDE)hb clean 1173d8536b4Sopenharmony_ci $(HIDE)echo "clean $(LOSCFG_PLATFORM) finish" 1183d8536b4Sopenharmony_ci 1193d8536b4Sopenharmony_cicleanall: clean 1203d8536b4Sopenharmony_ci $(HIDE)echo "clean all done" 1213d8536b4Sopenharmony_ci 1223d8536b4Sopenharmony_ci.PHONY: all clean cleanall help update_config $(KCONFIG_CMDS) $(KCONFIG_CONFIG) 123