2021-03-11 18:43:57 +08:00
|
|
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
|
|
|
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
2020-09-08 10:21:39 +08:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
# are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
# conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
# of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
|
# provided with the distribution.
|
|
|
|
#
|
|
|
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
|
|
# to endorse or promote products derived from this software without specific prior written
|
|
|
|
# permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
|
2020-09-08 10:21:39 +08:00
|
|
|
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
|
|
|
|
|
|
|
|
export LITEOSTOPDIR
|
|
|
|
export LITEOSTHIRDPARTY
|
|
|
|
|
|
|
|
APPS = apps
|
|
|
|
ROOTFS = rootfs
|
|
|
|
LITEOS_TARGET = liteos
|
2021-08-17 19:59:32 +08:00
|
|
|
LITEOS_LIBS_TARGET = libs
|
|
|
|
|
|
|
|
# by the following eval, we would got some variables like these:
|
|
|
|
# ohos_root_path=/xx
|
|
|
|
# ohos_board=hispark_taurus
|
|
|
|
# ohos_kernel=liteos_a
|
|
|
|
# ohos_product=ipcamera_hispark_taurus
|
|
|
|
# ohos_product_path=/xx/vendor/hisilicon/hispark_taurus
|
|
|
|
# ohos_device_path=/xx/device/hisilicon/hispark_taurus/sdk_liteos
|
|
|
|
ohos_kernel ?= liteos_a
|
|
|
|
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
|
|
|
|
|
|
|
ifneq ($(ohos_kernel),liteos_a)
|
|
|
|
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
|
|
|
endif
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-03-11 18:43:57 +08:00
|
|
|
export CONFIG_=LOSCFG_
|
2021-08-17 19:59:32 +08:00
|
|
|
export srctree=$(LITEOSTOPDIR)
|
|
|
|
|
|
|
|
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
|
|
|
|
export SYSROOT_PATH
|
|
|
|
|
|
|
|
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
|
|
|
|
export LITEOS_MENUCONFIG_H
|
|
|
|
|
|
|
|
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
|
|
|
export CONFIG_FILE
|
|
|
|
|
2021-07-07 20:20:09 +08:00
|
|
|
ifeq ($(PRODUCT_PATH),)
|
2021-08-17 19:59:32 +08:00
|
|
|
PRODUCT_PATH:=$(ohos_product_path)
|
2021-07-13 23:57:39 +08:00
|
|
|
endif
|
2021-08-17 19:59:32 +08:00
|
|
|
export PRODUCT_PATH
|
|
|
|
|
2021-07-13 23:57:39 +08:00
|
|
|
ifeq ($(DEVICE_PATH),)
|
2021-08-17 19:59:32 +08:00
|
|
|
DEVICE_PATH:=$(ohos_device_path)
|
2021-07-13 23:57:39 +08:00
|
|
|
endif
|
2021-08-17 19:59:32 +08:00
|
|
|
export DEVICE_PATH
|
2021-07-13 23:57:39 +08:00
|
|
|
|
|
|
|
ifeq ($(TEE:1=y),y)
|
|
|
|
tee = _tee
|
|
|
|
endif
|
|
|
|
ifeq ($(RELEASE:1=y),y)
|
2021-08-03 10:46:30 +08:00
|
|
|
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
|
2021-07-13 23:57:39 +08:00
|
|
|
else
|
2021-08-03 10:46:30 +08:00
|
|
|
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
|
2021-03-11 18:43:57 +08:00
|
|
|
endif
|
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
KCONFIG_CONFIG ?= $(CONFIG)
|
|
|
|
export KCONFIG_CONFIG
|
2021-03-11 18:43:57 +08:00
|
|
|
|
|
|
|
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
|
|
|
|
|
|
|
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
2020-09-08 10:21:39 +08:00
|
|
|
FSTYPE = jffs2
|
|
|
|
endif
|
2021-03-11 18:43:57 +08:00
|
|
|
ifeq ($(LOSCFG_STORAGE_EMMC), y)
|
2020-09-08 10:21:39 +08:00
|
|
|
FSTYPE = vfat
|
|
|
|
endif
|
2021-03-11 18:43:57 +08:00
|
|
|
ifeq ($(LOSCFG_STORAGE_SPINAND), y)
|
|
|
|
FSTYPE = yaffs2
|
|
|
|
endif
|
2020-10-08 17:09:23 +08:00
|
|
|
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
2021-03-11 18:43:57 +08:00
|
|
|
FSTYPE = jffs2
|
2020-10-08 17:09:23 +08:00
|
|
|
endif
|
2020-09-08 10:21:39 +08:00
|
|
|
ROOTFS_DIR = $(OUT)/rootfs
|
|
|
|
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
define HELP =
|
|
|
|
-------------------------------------------------------
|
|
|
|
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
|
|
|
|
|
|
|
Targets:
|
|
|
|
help: display this help and exit
|
|
|
|
clean: clean compiled objects
|
|
|
|
cleanall: clean all build outputs
|
|
|
|
all: make liteos kernel image and rootfs image (Default target)
|
|
|
|
rootfs: make a original rootfs image
|
|
|
|
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
|
|
|
$(LITEOS_TARGET): make liteos kernel image
|
|
|
|
update_config: update product kernel config (use menuconfig)
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
|
|
|
TEE: boolean value(1 or y for true), enable tee
|
|
|
|
RELEASE: boolean value(1 or y for true), build release version
|
|
|
|
CONFIG: kernel config file to be use
|
|
|
|
-------------------------------------------------------
|
|
|
|
endef
|
|
|
|
export HELP
|
|
|
|
|
|
|
|
all: $(LITEOS_TARGET) $(ROOTFS)
|
2020-09-08 10:21:39 +08:00
|
|
|
|
|
|
|
help:
|
2021-08-17 19:59:32 +08:00
|
|
|
$(HIDE)echo "$$HELP"
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-06-30 17:41:05 +08:00
|
|
|
sysroot:
|
|
|
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
|
|
|
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
|
|
|
|
$(HIDE)$(MAKE) -C $(SYSROOT_PATH)/build TARGETS=liteos_a_user
|
|
|
|
endif
|
|
|
|
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
|
|
|
endif
|
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
2021-07-30 10:08:25 +08:00
|
|
|
$(KCONFIG_CMDS):
|
|
|
|
$(HIDE)$@ $(args)
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
$(LITEOS_MENUCONFIG_H) $(CONFIG_FILE): $(KCONFIG_CONFIG)
|
|
|
|
$(HIDE)genconfig --config-out $(CONFIG_FILE) --header-path $(LITEOS_MENUCONFIG_H) $(args)
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
update_config:
|
|
|
|
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
prepare: $(LITEOS_MENUCONFIG_H)
|
|
|
|
$(HIDE)mkdir -p $(OUT)/musl $(OUT)/lib $(BUILD)
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
$(LITEOS_LIBS_TARGET): prepare
|
|
|
|
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
|
|
|
|
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
|
|
|
|
|
|
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
|
|
|
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
|
|
|
$(LITEOS_TARGET): $(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin
|
|
|
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
|
|
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
|
|
|
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
|
|
|
|
|
|
|
$(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
|
|
|
|
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) -Map=$@.map -o $@ --start-group $(LITEOS_LIBDEP) --end-group
|
|
|
|
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
|
|
|
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
|
|
|
$(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(OBJDUMP) -t $< |sort >$@
|
|
|
|
$(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(OBJDUMP) -d $< >$@
|
|
|
|
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
|
|
|
$(NM) -S --size-sort $< >$@
|
|
|
|
|
|
|
|
$(APPS): prepare
|
2020-09-08 10:21:39 +08:00
|
|
|
$(HIDE)$(MAKE) -C apps all
|
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
$(ROOTFS): $(APPS)
|
2020-09-08 10:21:39 +08:00
|
|
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
2021-08-05 22:10:03 +08:00
|
|
|
$(HIDE)cp -fp $$($(CC) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
|
|
|
$(HIDE)cp -fp $$($(GPP) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
|
2020-09-08 10:21:39 +08:00
|
|
|
else
|
2021-08-17 19:59:32 +08:00
|
|
|
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
|
|
|
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
|
|
|
|
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
2020-09-08 10:21:39 +08:00
|
|
|
endif
|
2021-08-17 19:59:32 +08:00
|
|
|
$(STRIP) $(OUT)/musl/*
|
2021-07-20 14:37:27 +08:00
|
|
|
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
2020-09-08 10:21:39 +08:00
|
|
|
ifneq ($(VERSION),)
|
2021-03-25 11:11:15 +08:00
|
|
|
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
2020-09-08 10:21:39 +08:00
|
|
|
endif
|
2020-10-19 16:18:59 +08:00
|
|
|
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
2020-09-08 10:21:39 +08:00
|
|
|
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
|
|
|
|
|
|
|
|
clean:
|
2021-08-17 19:59:32 +08:00
|
|
|
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
|
2020-09-08 10:21:39 +08:00
|
|
|
$(HIDE)$(MAKE) -C apps clean
|
2021-08-17 19:59:32 +08:00
|
|
|
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H) $(CONFIG_FILE)
|
|
|
|
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-04-12 21:56:12 +08:00
|
|
|
cleanall: clean
|
2021-08-17 19:59:32 +08:00
|
|
|
$(HIDE)$(RM) $(LITEOSTOPDIR)/out
|
2021-04-12 21:56:12 +08:00
|
|
|
$(HIDE)echo "clean all done"
|
2020-09-08 10:21:39 +08:00
|
|
|
|
2021-08-17 19:59:32 +08:00
|
|
|
.PHONY: all clean cleanall prepare sysroot help update_config
|
|
|
|
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET)
|