diff --git a/.gitignore b/.gitignore index 23b64f81..7f3188ff 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,9 @@ tags # Menuconfig temp files /config.h -.config -.config.old +/defconfig +/.config +/.config.old # Build temp files -/platform/board.ld /out diff --git a/Makefile b/Makefile index 9459f113..980d0713 100644 --- a/Makefile +++ b/Makefile @@ -27,35 +27,52 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) -export OS=$(shell uname -s) -ifneq ($(OS), Linux) -LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./) -endif - +LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))) LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party export LITEOSTOPDIR export LITEOSTHIRDPARTY -RM = -rm -rf -MAKE = make -__LIBS = libs APPS = apps -ROOTFSDIR = rootfsdir ROOTFS = rootfs - LITEOS_TARGET = liteos -LITEOS_LIBS_TARGET = libs_target -LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform +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 export CONFIG_=LOSCFG_ +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 + ifeq ($(PRODUCT_PATH),) -export PRODUCT_PATH=$(shell hb env|grep "product path:"|sed 's/.*: //g') +PRODUCT_PATH:=$(ohos_product_path) endif +export PRODUCT_PATH + ifeq ($(DEVICE_PATH),) -export DEVICE_PATH=$(shell hb env|grep "device path:"|sed 's/.*: //g') +DEVICE_PATH:=$(ohos_device_path) endif +export DEVICE_PATH ifeq ($(TEE:1=y),y) tee = _tee @@ -66,7 +83,8 @@ else CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config endif -$(shell env CONFIG_=$(CONFIG_) DEVICE_PATH=$(DEVICE_PATH) olddefconfig >/dev/null) +KCONFIG_CONFIG ?= $(CONFIG) +export KCONFIG_CONFIG -include $(LITEOSTOPDIR)/tools/build/config.mk @@ -86,41 +104,36 @@ ROOTFS_DIR = $(OUT)/rootfs ROOTFS_ZIP = $(OUT)/rootfs.zip VERSION = -SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot -export SYSROOT_PATH +define HELP = +------------------------------------------------------- +Usage: make [TARGET]... [PARAMETER=VALUE]... -all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS) -lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET) +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) + test: make the testsuits_app and put it into the rootfs dir + test_apps: make a rootfs img with the testsuits_app in it + +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) help: - $(HIDE)echo "-------------------------------------------------------" - $(HIDE)echo "1.====make help: get help infomation of make" - $(HIDE)echo "2.====make: make a debug version based the .config" - $(HIDE)echo "3.====make debug: make a debug version based the .config" - $(HIDE)echo "4.====make release: make a release version for all platform" - $(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx" - $(HIDE)echo "6.====make rootfsdir: make a original rootfs dir" - $(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img" - $(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir" - $(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it" - $(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)" - $(HIDE)echo "*** should be one of (jffs2)" - $(HIDE)echo "-------------------------------------------------------" + $(HIDE)echo "$$HELP" -debug: - $(HIDE)echo "=============== make a debug version ===============" - $(HIDE) $(MAKE) all - -release: -ifneq ($(PLATFORM),) - $(HIDE)echo "=============== make a release version for platform $(PLATFORM) ===============" - $(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM) -else - $(HIDE)echo "================make a release version for all platform ===============" - $(HIDE)$(SCRIPTS_PATH)/mklibversion.sh -endif - -##### make sysroot ##### sysroot: ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),) @@ -129,105 +142,74 @@ endif $(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH)) endif -##### make dynload ##### --include $(LITEOS_MK_PATH)/dynload.mk - -#-----need move when make version-----# -##### make lib ##### -$(__LIBS): $(OUT) $(CXX_INCLUDE) - -$(OUT): $(LITEOS_MENUCONFIG_H) - $(HIDE)mkdir -p $(OUT)/lib - $(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \ - -I$(LITEOS_PLATFORM_BASE)/include -imacros $< -E $(LITEOS_PLATFORM_BASE)/board.ld.S \ - -o $(LITEOS_PLATFORM_BASE)/board.ld -P - -$(BUILD): - $(HIDE)mkdir -p $(BUILD) - -$(LITEOS_LIBS_TARGET): $(__LIBS) sysroot - $(HIDE)for dir in $(LIB_SUBDIRS); \ - do $(MAKE) -C $$dir all || exit 1; \ - done - $(HIDE)echo "=============== make lib done ===============" - -##### make menuconfig ##### -KCONFIG_CMDS = $(notdir $(wildcard $(dir $(shell which menuconfig))*config)) +KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config)) $(KCONFIG_CMDS): $(HIDE)$@ $(args) -##### menuconfig end ####### -$(LITEOS_MENUCONFIG_H): .config - $(HIDE)genconfig - -$(LITEOS_TARGET): $(__LIBS) sysroot - $(HIDE)touch $(LOSCFG_ENTRY_SRC) - - $(HIDE)for dir in $(LITEOS_SUBDIRS); \ - do $(MAKE) -C $$dir all || exit 1; \ - done - - $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group -# $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize - $(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin - $(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted - $(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm -# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size - -$(APPS): $(LITEOS_TARGET) sysroot - $(HIDE)$(MAKE) -C apps all - -prepare: - $(HIDE)mkdir -p $(OUT)/musl -ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) - $(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 -else - $(HIDE)cp -fp $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl - $(HIDE)cp -fp $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl - $(HIDE)cp -fp $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl - $(STRIP) $(OUT)/musl/* -endif - -$(ROOTFSDIR): prepare $(APPS) - $(HIDE)$(MAKE) clean -C apps - $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR) -ifneq ($(VERSION),) - $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR) -endif - -$(ROOTFS): $(ROOTFSDIR) - $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE) - $(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS) - -clean: - $(HIDE)for dir in $(LITEOS_SUBDIRS); \ - do $(MAKE) -C $$dir clean|| exit 1; \ - done - $(HIDE)$(MAKE) -C apps clean - $(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~ - $(HIDE)$(RM) include/config include/generated - $(HIDE)$(MAKE) cleanrootfs - $(HIDE)echo "clean $(LITEOS_PLATFORM) finish" - -cleanall: clean - $(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_PLATFORM_BASE)/board.ld - $(HIDE)echo "clean all done" - -cleanrootfs: - $(HIDE)$(RM) $(OUT)/rootfs - $(HIDE)$(RM) $(OUT)/rootfs.zip - $(HIDE)$(RM) $(OUT)/rootfs.img - -update_all_config: - $(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \ - do \ - echo updating $$f; \ - test -f $$f && cp $$f .config && olddefconfig && savedefconfig --out $$f; \ - done +$(LITEOS_MENUCONFIG_H) $(CONFIG_FILE): $(KCONFIG_CONFIG) + $(HIDE)genconfig --config-out $(CONFIG_FILE) --header-path $(LITEOS_MENUCONFIG_H) $(args) update_config: $(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)" -.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config update_config -.PHONY: prepare sysroot cleanrootfs $(ROOTFS) $(ROOTFSDIR) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(__LIBS) $(OUT) +prepare: $(LITEOS_MENUCONFIG_H) + $(HIDE)mkdir -p $(OUT)/musl $(OUT)/lib $(BUILD) + +$(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 + $(HIDE)$(MAKE) -C apps all + +$(ROOTFS): $(APPS) +ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) + $(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 +else + $(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 +endif + $(STRIP) $(OUT)/musl/* + $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR) +ifneq ($(VERSION),) + $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR) +endif + $(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE) + $(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS) + +clean: + $(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done + $(HIDE)$(MAKE) -C apps clean + $(HIDE)$(RM) $(LITEOS_MENUCONFIG_H) $(CONFIG_FILE) + $(HIDE)echo "clean $(LOSCFG_PLATFORM) finish" + +cleanall: clean + $(HIDE)$(RM) $(LITEOSTOPDIR)/out + $(HIDE)echo "clean all done" + +.PHONY: all clean cleanall prepare sysroot help update_config +.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) diff --git a/apps/Makefile b/apps/Makefile index e2254341..94fcbb09 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -27,7 +27,7 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -LITEOSTOPDIR = $(shell pwd)/../ +LITEOSTOPDIR := $(shell pwd)/../ include $(LITEOSTOPDIR)/.config include ./config.mk diff --git a/arch/arm/arm.mk b/arch/arm/arm.mk index ddfbf4cf..2236d916 100644 --- a/arch/arm/arm.mk +++ b/arch/arm/arm.mk @@ -76,7 +76,6 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \ -I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE) -LITEOS_CXXINCLUDE += $(ARCH_INCLUDE) # expose FPU info to assembly code ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y) diff --git a/build.sh b/build.sh index 79c21b74..5afaf6f2 100755 --- a/build.sh +++ b/build.sh @@ -46,8 +46,8 @@ device_path=${12} echo "${board_name}" "${device_company}" echo "sh param:" "$@" +destination="defconfig" function main() { - destination=".config" tee="" if [ "${tee_enable}" = "true" ]; then tee="_tee" @@ -85,10 +85,12 @@ if [ "x" != "x${arch_cflags}" ]; then export ARCH_CFLAGS="${arch_cflags}" fi -export OUTDIR="${outdir}" export PRODUCT_PATH="${product_path}" export DEVICE_PATH="${device_path}" +OUTDIR="${outdir}" +CONFIG="$(realpath ${destination})" + main && \ -make clean && \ -make -j rootfs VERSION="${ohos_version}" +make clean CONFIG="$CONFIG" OUTDIR="$OUTDIR" && \ +make -j all VERSION="${ohos_version}" CONFIG="$CONFIG" OUTDIR="$OUTDIR" diff --git a/config.mk b/config.mk deleted file mode 100644 index 50fd8877..00000000 --- a/config.mk +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. -# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. -# -# 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. - -############### this is a makefile that you can config it ############### --include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk - -TOP_LD_PATH = $(LITEOSTOPDIR) -SCRIPTS_PATH = $(LITEOS_SCRIPTPATH) -LITEOS_MK_PATH = $(MK_PATH) -LITEOS_SUBDIRS = $(LIB_SUBDIRS) -LIB_BIGODIR = $(LITEOS_LIB_BIGODIR) - -##### liteos tables -u ldflags ##### --include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk - - -LITEOS_COPTS := $(LITEOS_COPTS_DEBUG) $(LITEOS_COPTS_BASE) \ - $(LITEOS_COPTS_EXTRA) $(LITEOS_CORE_COPTS) -LITEOS_CXXOPTS := $(LITEOS_CXXOPTS_BASE) -LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \ - $(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \ - $(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \ - $(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \ - $(LITEOS_PLATFORM_INCLUDE) $(LITEOS_DFX_INCLUDE) \ - $(LITEOS_SECURITY_INCLUDE) -LITEOS_LIBDEP := $(LITEOS_BASELIB) -LITEOS_ASFLAGS := $(LITEOS_ASOPTS) $(LITEOS_INCLUDE) -LITEOS_CFLAGS := $(LITEOS_COPTS) $(LITEOS_CMACRO) \ - $(LITEOS_CMACRO_TEST) $(LITEOS_IMAGE_MACRO) \ - $(LITEOS_INCLUDE) -LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \ - $(LITEOS_CMACRO) $(LITEOS_CXXINCLUDE) -LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \ - $(LITEOS_LD_SCRIPT) - diff --git a/config.mk b/config.mk new file mode 120000 index 00000000..9dcbbc33 --- /dev/null +++ b/config.mk @@ -0,0 +1 @@ +tools/build/config.mk \ No newline at end of file diff --git a/kernel/base/Makefile b/kernel/base/Makefile index 9381318f..d20fc229 100644 --- a/kernel/base/Makefile +++ b/kernel/base/Makefile @@ -48,4 +48,4 @@ LOCAL_INCLUDE := \ LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS) -include $(HDF_DRIVER) +include $(MODULE) diff --git a/kernel/user/Makefile b/kernel/user/Makefile index 6dc3fc56..00ddca85 100644 --- a/kernel/user/Makefile +++ b/kernel/user/Makefile @@ -28,10 +28,8 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include $(LITEOSTOPDIR)/config.mk -OBJOUT := $(OUT)/obj/kernel/user MODULE_NAME := userinit -LIBA := $(OUT)/lib/lib$(MODULE_NAME).O LOCAL_INCLUDE := \ -I $(LITEOSTOPDIR)/kernel/base/include\ @@ -49,27 +47,19 @@ LOCAL_INCLUDE := \ LOCAL_SRCS := $(wildcard src/*.c) \ $(wildcard src/*.S) -LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS)) -LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS)) - -LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS)) -LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS)) -LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_ASMOBJS) - LOCAL_FLAGS := $(LOCAL_INCLUDE) -all : $(LIBA) +include $(MODULE) -$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ +LIBO := $(OUT)/lib/lib$(MODULE_NAME).O -$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ +$(LIBO): $(LIBA) + $(HIDE) $(LD) -r -o $@ --whole-archive $< --no-whole-archive + $(HIDE) $(RM) $< -$(LIBA): $(LOCAL_OBJS) - $(HIDE) $(LD) -r -o $@ $^ +clean2: + $(HIDE) $(RM) $(LIBO) -clean: - $(HIDE) rm -rf $(LOCAL_OBJS) $(LIBA) +all: $(LIBO) +clean: clean2 +.PHONY: clean2 diff --git a/platform/Kconfig b/platform/Kconfig index 5f6e78c5..afe9171d 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -5,7 +5,7 @@ config PLATFORM default "virt" if PLATFORM_QEMU_ARM_VIRT_CA7 config PRODUCT_NAME - string "unknown" + string "product name" default "ipcamera_hi3516dv300_liteos" if PRODUCT_IPCAMERA_HI3516DV300_LITEOS default "ipcamera_hi3518ev300_liteos" if PRODUCT_IPCAMERA_HI3518EV300_LITEOS default "hispark_taurus" if PRODUCT_HISPARK_TAURUS @@ -13,7 +13,7 @@ config PRODUCT_NAME default "arm_virt" if PRODUCT_QEMU_ARM config DEVICE_COMPANY - string "unknown" + string "vendor name" default "hisilicon" if PLATFORM_HI3516DV300 default "hisilicon" if PLATFORM_HI3518EV300 default "qemu" if PLATFORM_QEMU_ARM_VIRT_CA7 @@ -22,11 +22,11 @@ choice prompt "Chip" default PLATFORM_HI3516DV300 help - IPC has several chips: - hi3516dv300 - hi3518ev300 + IP Camera has several chips: + - hi3516dv300 + - hi3518ev300 Qemu ARM Virt variants (based on different CPU types): - qemu_arm_virt_ca7 + - qemu_arm_virt_ca7 config PLATFORM_HI3516DV300 bool "hi3516dv300" diff --git a/platform/Makefile b/platform/Makefile index 94f9dd24..57951cb2 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -61,10 +61,22 @@ LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/vdso/include endif ALL_ASSRCS := $(wildcard *.S) -ASSRCS := $(subst board.ld.S,,$(ALL_ASSRCS)) +ASSRCS := $(filter-out board.ld.S,$(ALL_ASSRCS)) LOCAL_SRCS += $(ASSRCS) LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS) +BOARD_LD = $(OUT)/lib/board.ld +$(BOARD_LD): board.ld.S $(LITEOS_MENUCONFIG_H) + $(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) -I. \ + -imacros $(LITEOS_MENUCONFIG_H) -P -E $< -o $@ + +.PHONY: rm_board_ld +rm_board_ld: + $(HIDE)$(RM) $(BOARD_LD) + +all: $(BOARD_LD) +clean: rm_board_ld + include $(MODULE) diff --git a/platform/bsp.mk b/platform/bsp.mk index 0d1fe022..9d13ac32 100644 --- a/platform/bsp.mk +++ b/platform/bsp.mk @@ -43,8 +43,6 @@ USB_SRC := LITEOS_BASELIB += -lbsp -LITEOS_PLATFORM := $(subst $\",,$(LOSCFG_PLATFORM)) - PLATFORM_BSP_BASE := $(LITEOSTOPDIR)/platform PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \ @@ -55,10 +53,5 @@ PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \ -I $(PLATFORM_BSP_BASE)/hw/include \ -I $(PLATFORM_BSP_BASE)/include -# -#-include $(LITEOSTOPDIR)/platform/bsp/board/$(LITEOS_PLATFORM)/board.mk -# - LIB_SUBDIRS += $(PLATFORM_BSP_BASE) LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE) -LITEOS_CXXINCLUDE += $(PLATFORM_INCLUDE) diff --git a/tools/build/config.mk b/tools/build/config.mk index 6b468487..eb4e6f0e 100644 --- a/tools/build/config.mk +++ b/tools/build/config.mk @@ -34,7 +34,6 @@ TOP_LD_PATH = $(LITEOSTOPDIR) SCRIPTS_PATH = $(LITEOS_SCRIPTPATH) LITEOS_MK_PATH = $(MK_PATH) LITEOS_SUBDIRS = $(LIB_SUBDIRS) -LIB_BIGODIR = $(LITEOS_LIB_BIGODIR) ##### liteos tables -u ldflags ##### -include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk @@ -47,7 +46,8 @@ LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \ $(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \ $(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \ $(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \ - $(LITEOS_PLATFORM_INCLUDE) + $(LITEOS_PLATFORM_INCLUDE) $(LITEOS_DFX_INCLUDE) \ + $(LITEOS_SECURITY_INCLUDE) LITEOS_LIBDEP := $(LITEOS_BASELIB) LITEOS_ASFLAGS := $(LITEOS_ASOPTS) $(LITEOS_INCLUDE) LITEOS_CFLAGS := $(LITEOS_COPTS) $(LITEOS_CMACRO) \ diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index 2d273619..9ea202d9 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -54,7 +54,7 @@ OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi RM = -rm -rf ECHO = echo ifeq ($(OS),) -OS = $(shell uname -s) +OS := $(shell uname -s) export OS endif COMPILE_NAME := $(patsubst %-,%,$(CROSS_COMPILE)) @@ -98,21 +98,15 @@ LITEOS_CXXFLAGS := LITEOS_BASELIB := LITEOS_LIBDEP := ## directory ## -LIB_BIGODIR := LIB_SUBDIRS := -##compiler## -LITEOS_COMPILER_CXX_PATH := -LITEOS_COMPILER_CXXLIB_PATH := -LITEOS_COMPILER_GCCLIB_PATH := -LITEOS_COMPILER_GCC_INCLUDE := -LITEOS_DRIVERS_BASE_PATH := ## variable define ## ifeq ($(LITEOSTHIRDPARTY),) LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party endif +LITEOS_PLATFORM := $(LOSCFG_PLATFORM:"%"=%) ifeq ($(OUTDIR),) -OUT = $(LITEOSTOPDIR)/out/$(LITEOS_PLATFORM) +OUT = $(LITEOSTOPDIR)/out/$(LITEOS_PLATFORM) LITEOS_TARGET_DIR = $(OUT) KERNEL_COMPILE_ONLY = y else @@ -125,27 +119,12 @@ MK_PATH = $(LITEOSTOPDIR)/tools/build/mk CXX_PATH = $(LITEOSTOPDIR)/lib/cxxstl JFFS_PATH = $(LITEOSTOPDIR)/fs/jffs2 LITEOS_SCRIPTPATH ?= $(LITEOSTOPDIR)/tools/scripts -LITEOS_LIB_BIGODIR = $(OUT)/lib/obj LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h LOSCFG_ENTRY_SRC = $(LITEOSTOPDIR)/platform/los_config.c ### include variable MODULE = $(MK_PATH)/module.mk -ifeq ($(LOSCFG_COMPILER_HIMIX_32), y) -LITEOS_CMACRO += -D__COMPILER_HUAWEILITEOS__ -else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) -LITEOS_CMACRO += -D__COMPILER_HUAWEILITEOS__ -else ifeq ($(LOSCFG_COMPILER_HCC_64), y) -LITEOS_CMACRO += -D__COMPILER_HUAWEILITEOS__ -endif LITEOS_CMACRO += -D__LITEOS__ -DSECUREC_IN_KERNEL=0 -ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) -LITEOS_BASELIB += -lclang_rt.builtins -LITEOS_BASELIB += -lunwind --no-dependent-libraries -else -LITEOS_BASELIB += -lgcc -LITEOS_BASELIB += -lgcc_eh -endif AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__ ifeq ($(LOSCFG_QUICK_START), y) @@ -231,14 +210,15 @@ endif #################################### Lib Option Begin ############################### ifeq ($(LOSCFG_LIB_LIBC), y) - LIB_SUBDIRS += lib/libc - LIB_SUBDIRS += lib/libsec - - LITEOS_BASELIB += -lc -lsec + LIB_SUBDIRS += lib/libc + LITEOS_BASELIB += -lc LITEOS_LIBC_INCLUDE += \ - $(LITEOS_LIBSCREW_INCLUDE) \ -I $(LITEOSTOPDIR)/lib/libc/include \ -I $(LITEOSTHIRDPARTY)/musl/porting/liteos_a/kernel/include \ + + LIB_SUBDIRS += lib/libsec + LITEOS_BASELIB += -lsec + LITEOS_LIBC_INCLUDE += \ -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include endif @@ -247,13 +227,7 @@ endif LITEOS_LIBSCREW_INCLUDE += -I $(LITEOSTOPDIR)/lib/libscrew/include ifeq ($(LOSCFG_KERNEL_CPPSUPPORT), y) -ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) - LITEOS_BASELIB += -lc++ -lc++abi LITEOS_BASELIB += -lcppsupport -else - LITEOS_BASELIB += -lsupc++ - LITEOS_BASELIB += -lcppsupport -lstdc++ -endif LIB_SUBDIRS += kernel/extended/cppsupport LITEOS_CPPSUPPORT_INCLUDE += -I $(LITEOSTOPDIR)/kernel/extended/cppsupport endif @@ -551,10 +525,6 @@ OBJDUMP = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)objdump SIZE = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)size NM = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)nm STRIP = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)strip - -VERSION_NUM := v1 -LITEOS_COMPILER_CXX_PATH = $(LITEOS_COMPILER_PATH)/include - LLVM_TARGET := arm-liteos LLVM_EXTRA_OPTS := -target $(LLVM_TARGET) -fms-extensions -Wno-address-of-packed-member LLVM_EXTRA_LD_OPTS := -fuse-ld=lld --rtlib=compiler-rt @@ -573,55 +543,8 @@ OBJDUMP = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)objdump SIZE = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)size NM = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)nm STRIP = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)strip - -ifeq ($(VERSION_NUM),) -VERSION_NUM := $(shell $(CC) -dumpversion) -export VERSION_NUM endif -LITEOS_COMPILER_CXX_PATH = $(LITEOS_COMPILER_PATH)/$(COMPILE_NAME)/include -endif - -ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) -LITEOS_COMPILER_CXXLIB_PATH = $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4 -LITEOS_COMPILER_GCCLIB_PATH = $(LITEOS_COMPILER_PATH)/lib/clang/current/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4 -LITEOS_COMPILER_GCC_INCLUDE = -I $(LITEOS_COMPILER_PATH)/lib/clang/current/include -else ifeq ($(LOSCFG_COMPILER_HIMIX_32), y) -LITEOS_COMPILER_CXXLIB_PATH = $(LITEOS_COMPILER_PATH)/$(COMPILE_NAME)/lib -LITEOS_COMPILER_GCCLIB_PATH = $(LITEOS_COMPILER_PATH)/lib/gcc/$(COMPILE_NAME)/$(VERSION_NUM) -LITEOS_COMPILER_GCC_INCLUDE = -I $(LITEOS_COMPILER_PATH)/lib/gcc/arm-linux-ohoseabi/$(VERSION_NUM)/include -else ifeq ($(LOSCFG_COMPILER_HCC_64), y) -LITEOS_COMPILER_CXXLIB_PATH = $(LITEOS_COMPILER_PATH)/$(COMPILE_NAME)/lib64 -LITEOS_COMPILER_GCCLIB_PATH = $(LITEOS_COMPILER_PATH)/lib64/gcc/$(COMPILE_NAME)/$(VERSION_NUM) -LITEOS_COMPILER_GCC_INCLUDE = -I $(LITEOS_COMPILER_PATH)/lib64/gcc/aarch64-linux-gnu/$(VERSION_NUM)/include -endif - -LITEOS_CXXINCLUDE += \ - -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM) \ - -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/ext \ - -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/backward \ - -I $(LITEOSTOPDIR)/compat/posix/include \ - -I $(LITEOSTOPDIR)/fs/include \ - -I $(LITEOSTOPDIR)/kernel/include \ - $(LITEOS_LIBC_INCLUDE) - -ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y) -LITEOS_CXXINCLUDE += -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/backward -endif - -ifeq ($(LOSCFG_COMPILER_HIMIX_32), y) - LITEOS_CXXINCLUDE += \ - -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/arm-linux-ohoseabi - LITEOS_CXXMACRO += -DLOSCFG_KERNEL_CPP_EXCEPTIONS_SUPPORT - LITEOS_CMACRO += -DLOSCFG_KERNEL_CPP_EXCEPTIONS_SUPPORT -else ifeq ($(LOSCFG_COMPILER_HCC_64), y) - LITEOS_CXXINCLUDE += \ - -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/aarch64-linux-gnu - LITEOS_CXXMACRO += -DLOSCFG_KERNEL_CPP_EXCEPTIONS_SUPPORT - LITEOS_CMACRO += -DLOSCFG_KERNEL_CPP_EXCEPTIONS_SUPPORT -endif - -LITEOS_CXXINCLUDE += $(LITEOS_COMPILER_GCC_INCLUDE) FP = -fno-omit-frame-pointer LITEOS_CXXOPTS_BASE += -std=c++11 -nostdlib -nostdinc -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit \ -fno-builtin -frtti -fno-pic -Winvalid-pch $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(FP) @@ -638,9 +561,8 @@ LITEOS_FS_INCLUDE := $(LITEOS_VFS_INCLUDE) $(LITEOS_FAT_CACHE_IN $(LITEOS_PROC_INCLUDE) $(LITEOS_FAT_VIRPART_INCLUDE) \ $(LITEOS_FAT_INCLUDE) LITEOS_NET_INCLUDE := $(LITEOS_LWIP_SACK_INCLUDE) -LITEOS_LIB_INCLUDE := $(LITEOS_LIBC_INCLUDE) $(LITEOS_LIBM_INCLUDE) \ - $(LITEOS_ZLIB_INCLUDE) $(LITEOS_COMPILER_GCC_INCLUDE) \ - $(LITEOS_LIBSCREW_INCLUDE) +LITEOS_LIB_INCLUDE := $(LITEOS_LIBC_INCLUDE) $(LITEOS_LIBM_INCLUDE) \ + $(LITEOS_ZLIB_INCLUDE) $(LITEOS_LIBSCREW_INCLUDE) LITEOS_DRIVERS_INCLUDE := $(LITEOS_CELLWISE_INCLUDE) $(LITEOS_GPIO_INCLUDE) \ $(LITEOS_HIDMAC_INCLUDE) $(LITEOS_HIETH_SF_INCLUDE) \ $(LITEOS_HIGMAC_INCLUDE) $(LITEOS_I2C_INCLUDE) \ @@ -692,8 +614,7 @@ LITEOS_LD_OPTS += -nostartfiles endif LITEOS_LD_OPTS += -static --gc-sections LITEOS_LD_OPTS += $(LITEOS_DYNLOADOPTS) -LITEOS_LD_PATH += -L$(LITEOS_SCRIPTPATH)/ld -L$(LITEOSTOPDIR)/platform -L$(OUT)/lib -L$(LITEOS_LIB_BIGODIR) -L$(LITEOSTOPDIR)/tools/build -LITEOS_LD_PATH += -L$(LITEOS_COMPILER_GCCLIB_PATH) -L$(LITEOS_COMPILER_CXXLIB_PATH) +LITEOS_LD_PATH += -L$(OUT)/lib ifeq ($(LOSCFG_VENDOR) ,y) LITEOS_LD_PATH += -L$(OUT)/lib/rdk -L$(OUT)/lib/sdk \ -L$(OUT)/lib/main_server @@ -705,15 +626,24 @@ else LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld endif +##compiler## +ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) +_CC = $(CC) $(LLVM_EXTRA_OPTS) $(LLVM_EXTRA_LD_OPTS) $(LITEOS_CORE_COPTS) +LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libunwind.a") --no-dependent-libraries +else +_CC = $(CC) $(LITEOS_CORE_COPTS) +LITEOS_BASELIB += $(shell $(_CC) "-print-file-name=libgcc_eh.a") +endif +LITEOS_BASELIB += $(shell $(_CC) "-print-libgcc-file-name") +LITEOS_LIB_INCLUDE += -isystem $(shell $(_CC) "-print-file-name=include") + # temporary LITEOS_PLATFORM_INCLUDE += \ -I $(LITEOSTOPDIR)/kernel/base/include \ -I $(LITEOSTOPDIR)/kernel/extended/cpup \ -I $(LITEOSTOPDIR)/kernel/extended/trace -LITEOS_CXXINCLUDE += \ - $(LITEOS_NET_INCLUDE) \ - -I $(LITEOSTOPDIR)/kernel/base/include +LITEOS_CXXINCLUDE = $(LITEOS_INCLUDE) LITEOS_COPTS_NODEBUG := $(LITEOS_NODEBUG) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA) LITEOS_COPTS_INTERWORK := $(LITEOS_INTERWORK) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA_INTERWORK) diff --git a/tools/scripts/make_rootfs/rootfsdir.sh b/tools/scripts/make_rootfs/rootfsdir.sh index 269f097f..cb9f260e 100755 --- a/tools/scripts/make_rootfs/rootfsdir.sh +++ b/tools/scripts/make_rootfs/rootfsdir.sh @@ -53,7 +53,7 @@ fi cp -f ${LIB_DIR}/* ${ROOTFS_DIR}/lib cp -u ${LIB_DIR}/* ${OUT_DIR}/libs -if [ -e ${ETC_DIR} ]; then +if [ -e ${ETC_DIR}/.mkshrc ]; then cp -f ${ETC_DIR}/.mkshrc ${ROOTFS_DIR}/etc cp -u ${ETC_DIR}/.mkshrc ${OUT_DIR}/etc fi