鸿蒙移植i.mx6ull (七) Liteos-a的编译系统(下)

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: 鸿蒙移植i.mx6ull (七) Liteos-a的编译系统

1.3.1 Makfile中常用变量


1. LITEOSTOPDIR                        // kernel/liteos_a
2. LITEOSTHIRDPARTY               // third_party
3. LITEOS_MK_PATH                   // kernel/liteos_a/tools/build/mk
4. MK_PATH  = $(LITEOSTOPDIR)/tools/build/mk       // kernel/liteos_a/tools/build/mk


1.3.2 包含的文件


Makefile里使用include命令包含了很多文件,这些文件又包含了其他文件。


1. STM32MP157

Makefile
  -include $(LITEOSTOPDIR)/tools/build/config.mk
  -include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
    -include $(LITEOSTOPDIR)/.config
    include $(LITEOSTOPDIR)/arch/cpu.mk
    -include $(LITEOSTOPDIR)/arch/arm/arm.mk
    include $(LITEOSTOPDIR)/platform/bsp.mk
    include $(LITEOSTOPDIR)/../../vendor/st/stm32mp157/stm32mp157.mk
    include $(LITEOSTOPDIR)/../../drivers/hdf/lite/hdf_lite.mk
    include $(LITEOSTOPDIR)/../../vendor/st/hdf/hdf_vendor.mk
    -include $(LITEOSTOPDIR)/3rdParty/3rdParty.mk
  -include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
  -include $(LITEOS_MK_PATH)/dynload.mk


2. IMX6ULL

Makefile
  -include $(LITEOSTOPDIR)/tools/build/config.mk
  -include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
    -include $(LITEOSTOPDIR)/.config
    include $(LITEOSTOPDIR)/arch/cpu.mk
    -include $(LITEOSTOPDIR)/arch/arm/arm.mk
    include $(LITEOSTOPDIR)/platform/bsp.mk
    include $(LITEOSTOPDIR)/../../vendor/nxp/imx6ull/imx6ull.mk
    include $(LITEOSTOPDIR)/../../drivers/hdf/lite/hdf_lite.mk
    include $(LITEOSTOPDIR)/../../vendor/nxp/hdf/hdf_vendor.mk
    -include $(LITEOSTOPDIR)/3rdParty/3rdParty.mk
  -include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
  -include $(LITEOS_MK_PATH)/dynload.mk


两个板子的区别:

1671000558625.jpg


3. 展开Makefile

把Makefile里被包含的文件都展开,这样便于分析。

我们事先对STM32MP157、IMX6ULL展开了它们的Makefile,结果分别保存在这两个文件里:

Makefile_all_stm32mp157.txt
Makefile_all_imx6ull.txt


注意:-include表示有文件就包含,没有文件就不包含。


下面是Makefile_all_stm32mp157.txt

# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) export OS=$(shell uname -s) ifneq ($(OS), Linux) LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./) endif
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
export LITEOSTOPDIR export LITEOSTHIRDPARTY
# -include $(LITEOSTOPDIR)/tools/build/config.mk # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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 # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
#-include $(LITEOSTOPDIR)/.config # # Automatically generated file; DO NOT EDIT. # Huawei LiteOS Configuration #
# # Compiler # # LOSCFG_COMPILER_HIMIX_32 is not set LOSCFG_COMPILER_CLANG_LLVM=y
# # Platform # LOSCFG_PLATFORM="stm32mp157" # LOSCFG_PLATFORM_HI3516DV300 is not set # LOSCFG_PLATFORM_HI3518EV300 is not set LOSCFG_PLATFORM_STM32MP157=y # LOSCFG_PLATFORM_IMX6ULL is not set LOSCFG_PLATFORM_BSP_GIC_V2=y LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y LOSCFG_ARCH_ARM_VER="armv7-a" LOSCFG_ARCH_FPU_VFP_V4=y LOSCFG_ARCH_FPU_VFP_D32=y LOSCFG_ARCH_FPU_VFP_NEON=y LOSCFG_ARCH_FPU="neon-vfpv4" LOSCFG_ARCH_CORTEX_A7=y LOSCFG_ARCH_CPU="cortex-a7"
# # Extra Configurations # # LOSCFG_ARCH_FPU_DISABLE is not set LOSCFG_IRQ_USE_STANDALONE_STACK=y LOSCFG_PLATFORM_ROOTFS=y
# # Kernel # # LOSCFG_KERNEL_SMP is not set LOSCFG_KERNEL_EXTKERNEL=y LOSCFG_KERNEL_CPPSUPPORT=y LOSCFG_KERNEL_CPUP=y LOSCFG_CPUP_INCLUDE_IRQ=y LOSCFG_KERNEL_DYNLOAD=y LOSCFG_KERNEL_VDSO=y LOSCFG_KERNEL_TICKLESS=y # LOSCFG_KERNEL_TRACE is not set LOSCFG_KERNEL_LITEIPC=y LOSCFG_KERNEL_PIPE=y LOSCFG_BASE_CORE_HILOG=y
# # Lib # LOSCFG_LIB_LIBC=y LOSCFG_LIB_ZLIB=y
# # Compat # LOSCFG_COMPAT_POSIX=y LOSCFG_COMPAT_BSD=y
# # FileSystem # LOSCFG_FS_VFS=y LOSCFG_FS_VFS_BLOCK_DEVICE=y LOSCFG_FILE_MODE=y LOSCFG_FS_FAT=y LOSCFG_FS_FAT_CACHE=y LOSCFG_FS_FAT_CACHE_SYNC_THREAD=y LOSCFG_FS_FAT_CHINESE=y LOSCFG_FS_FAT_VIRTUAL_PARTITION=y LOSCFG_FS_FAT_VOLUMES=16 LOSCFG_FS_FAT_DISK=y LOSCFG_FS_RAMFS=y LOSCFG_FS_NFS=y LOSCFG_FS_PROC=y LOSCFG_FS_JFFS=y
# # Net # LOSCFG_NET_LWIP_SACK=y LOSCFG_NET_LWIP_SACK_2_1=y
# # Debug # # LOSCFG_COMPILE_DEBUG is not set LOSCFG_PLATFORM_ADAPT=y LOSCFG_ENABLE_OOM_LOOP_TASK=y LOSCFG_ENABLE_MAGICKEY=y # LOSCFG_THUMB is not set LOSCFG_DEBUG_VERSION=y # LOSCFG_DEBUG_KERNEL is not set LOSCFG_SHELL=y
# # Functionality of Shell # LOSCFG_SHELL_LK=y LOSCFG_SHELL_DMESG=y # LOSCFG_SHELL_EXCINFO is not set LOSCFG_NET_LWIP_SACK_TFTP=y LOSCFG_NET_TELNET=y # LOSCFG_EXC_INTERACTION is not set LOSCFG_USER_INIT_DEBUG=y LOSCFG_SHELL_CMD_DEBUG=y # LOSCFG_MEM_DEBUG is not set LOSCFG_NULL_ADDRESS_PROTECT=y LOSCFG_DRIVERS_HDF_PLATFORM_UART=y # LOSCFG_PLATFORM_UART_WITHOUT_VFS is not set # LOSCFG_PLATFORM_NO_UART is not set
# # Driver # LOSCFG_DRIVERS=y # LOSCFG_DRIVERS_USB is not set LOSCFG_DRIVERS_HDF=y LOSCFG_DRIVERS_HDF_PLATFORM=y LOSCFG_DRIVERS_HDF_PLATFORM_I2C=y # LOSCFG_DRIVERS_HDF_PLATFORM_SPI is not set # LOSCFG_DRIVERS_HDF_PLATFORM_GPIO is not set # LOSCFG_DRIVERS_HDF_PLATFORM_WATCHDOG is not set # LOSCFG_DRIVERS_HDF_PLATFORM_SDIO is not set # LOSCFG_DRIVERS_HDF_PLATFORM_RTC is not set # LOSCFG_DRIVERS_HDF_PLATFORM_HISI_SDK is not set # LOSCFG_DRIVERS_HDF_WIFI is not set # LOSCFG_DRIVERS_HDF_INPUT is not set # LOSCFG_DRIVERS_HDF_LCD is not set # LOSCFG_DRIVERS_HDF_USB is not set # LOSCFG_DRIVERS_NETDEV is not set LOSCFG_DRIVERS_MEM=y # LOSCFG_DRIVERS_MMC is not set LOSCFG_DRIVERS_MTD=y # LOSCFG_DRIVERS_MTD_SPI_NOR is not set # LOSCFG_DRIVERS_RANDOM is not set # LOSCFG_DRIVERS_VIDEO is not set LOSCFG_DRIVERS_HIEVENT=y
# # Security # LOSCFG_SECURITY=y LOSCFG_SECURITY_CAPABILITY=y LOSCFG_SECURITY_VID=y # LOSCFG_SECURITY_BOOT is not set
# # Stack Smashing Protector (SSP) Compiler Feature # # LOSCFG_CC_NO_STACKPROTECTOR is not set # LOSCFG_CC_STACKPROTECTOR is not set LOSCFG_CC_STACKPROTECTOR_STRONG=y # LOSCFG_CC_STACKPROTECTOR_ALL is not set
ifeq ($(LOSCFG_COMPILER_HIMIX_32), y) CROSS_COMPILE := arm-linux-ohoseabi- else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) CROSS_COMPILE := llvm- endif
HIDE := @ CC  := AS  := AR  := LD  := GPP := OBJCOPY := OBJDUMP := SIZE := NM := MKDIR = mkdir OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi RM = -rm -rf ECHO = echo ifeq ($(OS),) OS = $(shell uname -s) export OS endif COMPILE_NAME := $(patsubst %-,%,$(CROSS_COMPILE)) VERSION_NUM :=
ARFLAGS  := cr
## platform relative ## LITEOS_ARM_ARCH := LITEOS_CPU_TYPE := ## c as cxx ld options ## LITEOS_ASOPTS := LITEOS_COPTS_BASE := LITEOS_COPTS_EXTRA := LITEOS_COPTS_EXTRA_INTERWORK := LITEOS_COPTS_DEBUG := LITEOS_COPTS_NODEBUG := LITEOS_INTERWORK := LITEOS_CXXOPTS := LITEOS_CXXOPTS_BASE := LITEOS_LD_OPTS := LITEOS_GCOV_OPTS := ## dynload ld options ## LITEOS_DYNLOADOPTS := ## macro define ## LITEOS_CMACRO := LITEOS_CXXMACRO := ## head file path and ld path ## LITEOS_PLATFORM_INCLUDE := LITEOS_CXXINCLUDE := LITEOS_LD_PATH := LITEOS_LD_SCRIPT := LITEOS_MK_PATH := ## c as cxx ld flags ## LITEOS_ASFLAGS := LITEOS_CFLAGS := LITEOS_CFLAGS_INTERWORK := LITEOS_LDFLAGS := LITEOS_CXXFLAGS := ## depended lib ## 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 := LITEOS_VENDOR_DRIVERS_BASE_PATH :=
## variable define ## ifeq ($(LITEOSTHIRDPARTY),) LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party endif ifeq ($(OUTDIR),) OUT  = $(LITEOSTOPDIR)/out/$(LITEOS_PLATFORM) LITEOS_TARGET_DIR = $(OUT) else OUT = $(OUTDIR) LITEOS_TARGET_DIR = $(OUT)/../../../ endif BUILD  = $(OUT)/obj 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 LOSCFG_ENTRY_SRC    = $(LITEOSTOPDIR)/kernel/common/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_HIMIX100_64), 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__
WARNING_AS_ERROR   := -Wall -Werror
####################################### CPU Option Begin ######################################### # include $(LITEOSTOPDIR)/arch/cpu.mk # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
ifeq ($(LOSCFG_ARCH_ARM), y) # -include $(LITEOSTOPDIR)/arch/arm/arm.mk # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
# strip quotation mark in configuration
LOSCFG_ARCH_CPU_STRIP   := $(subst $\",,$(LOSCFG_ARCH_CPU)) LOSCFG_ARCH_CPU          = $(LOSCFG_ARCH_CPU_STRIP)
LOSCFG_ARCH_FPU_STRIP   := $(subst $\",,$(LOSCFG_ARCH_FPU)) LOSCFG_ARCH_FPU          = $(LOSCFG_ARCH_FPU_STRIP)
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y) LITEOS_ARCH_ARM         := arm else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y) LITEOS_ARCH_ARM         := endif
LITEOS_BASELIB          += -l$(LOSCFG_ARCH_CPU) LIB_SUBDIRS             += arch/arm/$(LITEOS_ARCH_ARM)
# CPU compile options ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y) ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y) EXTENSION               := +nofp endif endif LITEOS_CPU_OPTS         := -mcpu=$(LOSCFG_ARCH_CPU)$(EXTENSION)
# FPU compile options # -mfloat and -mfpu is ignored with AArch64 targets ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y) LITEOS_FLOAT_OPTS       := -mfloat-abi=softfp LITEOS_FPU_OPTS         := -mfpu=$(LOSCFG_ARCH_FPU) # gcc libc folder style is combine with core and fpu # for example, cortex-a7 with softfp abi and neon vfp4 is: a7_softfp_neon_vfp4 LITEOS_GCCLIB           := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU) endif
LITEOS_CORE_COPTS        = $(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS) LITEOS_INTERWORK        += $(LITEOS_CORE_COPTS) LITEOS_NODEBUG          += $(LITEOS_CORE_COPTS) LITEOS_ASOPTS           += $(LITEOS_CPU_OPTS) LITEOS_CXXOPTS_BASE     += $(LITEOS_CORE_COPTS)
ARCH_INCLUDE            := -I $(LITEOSTOPDIR)/arch/arm/include \
                           -I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_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) LITEOS_CMACRO       += -DLOSCFG_ARCH_FPU_DISABLE else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y) LITEOS_CMACRO       += -DLOSCFG_ARCH_FPU_VFP_D16 else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y) LITEOS_CMACRO       += -DLOSCFG_ARCH_FPU_VFP_D32 endif
# extra definition for other module LITEOS_CPU_TYPE          = $(LOSCFG_ARCH_CPU) LITEOS_ARM_ARCH         := -march=$(subst $\",,$(LOSCFG_ARCH_ARM_VER))
# linux style macros LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7 LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7 LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7 LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8 LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8 LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
AS_OBJS_LIBC_FLAGS      += $(LINUX_ARCH_y)
endif ####################################### CPU Option End #########################################
############################# Platform Option Begin################################# # include $(LITEOSTOPDIR)/platform/bsp.mk # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
############################# SRCs ################################# HWI_SRC     := MMU_SRC     := NET_SRC     := TIMER_SRC   := HRTIMER_SRC := UART_SRC    := USB_SRC     :=
############################# HI3516DV300 Options################################# ifeq ($(LOSCFG_PLATFORM_HI3516DV300), y) HWI_TYPE     := arm/interrupt/gic
    TIMER_TYPE   := arm/timer/arm_generic
    HRTIMER_TYPE := hisoc/hrtimer
    NET_TYPE     := hieth
    UART_TYPE    := amba_pl011
    USB_TYPE     := usb3.0_hi3516dv300
    LITEOS_CMACRO_TEST += -DTEST3516DV300
########################## HI3518EV300 Options############################## else ifeq ($(LOSCFG_PLATFORM_HI3518EV300), y) HWI_TYPE     := arm/interrupt/gic
    TIMER_TYPE   := hisoc/timer
    HRTIMER_TYPE := hisoc/hrtimer
    NET_TYPE     := hieth
    UART_TYPE    := amba_pl011
    USB_TYPE     := usb3.0_hi3518ev300
    LITEOS_CMACRO_TEST += -DTEST3518EV300 else ifeq ($(LOSCFG_PLATFORM_IMX6ULL), y) HWI_TYPE     := arm/interrupt/gic
    TIMER_TYPE   := arm/timer/arm_generic
    HRTIMER_TYPE := imx6ull/hrtimer else ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) HWI_TYPE     := arm/interrupt/gic
    TIMER_TYPE   := arm/timer/arm_generic
    HRTIMER_TYPE := stm32mp157/hrtimer endif
HWI_SRC     := hw/$(HWI_TYPE) TIMER_SRC   := hw/$(TIMER_TYPE) HRTIMER_SRC := hw/$(HRTIMER_TYPE) NET_SRC     := net/$(NET_TYPE) UART_SRC    := uart/$(UART_TYPE) USB_SRC     := usb/$(USB_TYPE)
LITEOS_BASELIB       += -lbsp
LITEOS_PLATFORM      := $(subst $\",,$(LOSCFG_PLATFORM))
PLATFORM_BSP_HISI_BASE := $(LITEOSTOPDIR)/platform
PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include \
                    -I $(PLATFORM_BSP_HISI_BASE)/../kernel/common \
                    -I $(PLATFORM_BSP_HISI_BASE)/../../../drivers/liteos/platform/pm \
                    -I $(PLATFORM_BSP_HISI_BASE)/hw/include \
                    -I $(PLATFORM_BSP_HISI_BASE)/include \
                    -I $(PLATFORM_BSP_HISI_BASE)/$(UART_SRC)
ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include/hisoc else ifeq ($(LOSCFG_PLATFORM_IMX6ULL),y) PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/nxp/imx6ull/board/include else ifeq ($(LOSCFG_PLATFORM_STM32MP157),y) PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/st/stm32mp157/board/include endif
# #-include $(LITEOSTOPDIR)/platform/bsp/board/$(LITEOS_PLATFORM)/board.mk #
LIB_SUBDIRS             += $(PLATFORM_BSP_HISI_BASE) LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE) LITEOS_CXXINCLUDE       += $(PLATFORM_INCLUDE)
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y) LITEOS_BASELIB  += -lrootfs
    LIB_SUBDIRS     += $(LITEOSTOPDIR)/kernel/common endif ############################# Platform Option End #################################
####################################### Kernel Option Begin ########################################### LITEOS_BASELIB += -lbase LIB_SUBDIRS       += kernel/base LITEOS_KERNEL_INCLUDE   := -I $(LITEOSTOPDIR)/kernel/include
ifeq ($(LITEOS_PLATFORM),imx6ull) include $(LITEOSTOPDIR)/../../vendor/nxp/imx6ull/imx6ull.mk endif
ifeq ($(LITEOS_PLATFORM),stm32mp157) # include $(LITEOSTOPDIR)/../../vendor/st/stm32mp157/stm32mp157.mk
STM32MP157_BASE_DIR  := $(LITEOSTOPDIR)/../../vendor/st/stm32mp157
LIB_SUBDIRS     += $(STM32MP157_BASE_DIR)/board LITEOS_BASELIB  += -lboard
LIB_SUBDIRS     += $(STM32MP157_BASE_DIR)/driver/mtd/common LITEOS_BASELIB  += -lmtd_common
LIB_SUBDIRS     += $(STM32MP157_BASE_DIR)/driver/mtd/spi_nor LITEOS_BASELIB  += -lspinor_flash
ifeq ($(LOSCFG_DRIVERS_VIDEO), y) LIB_SUBDIRS             += $(STM32MP157_BASE_DIR)/driver/stm32mp157-fb LITEOS_BASELIB  += -lstm32mp157-fb endif
LIB_SUBDIRS             += $(STM32MP157_BASE_DIR)/driver/stm32mp157-uart LITEOS_BASELIB  += -lstm32mp157-uart
LITEOS_MTD_SPI_NOR_INCLUDE +=   -I$(STM32MP157_BASE_DIR)/driver/mtd/common/include \
                                                                -I$(STM32MP157_BASE_DIR)/driver/mtd/spi_nor/include
endif
ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) LITEOS_BASELIB += -lhi35xx_bsp LIB_SUBDIRS += $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/ endif
ifeq ($(LOSCFG_KERNEL_CPUP), y) LITEOS_BASELIB   += -lcpup
    LIB_SUBDIRS         += kernel/extended/cpup
    LITEOS_CPUP_INCLUDE := -I $(LITEOSTOPDIR)/kernel/extended/cpup endif
ifeq ($(LOSCFG_KERNEL_SCHED_STATISTICS), y) LITEOS_CMACRO += -DLOSCFG_KERNEL_SCHED_STATISTICS=1 else LITEOS_CMACRO += -DLOSCFG_KERNEL_SCHED_STATISTICS=0 endif
ifeq ($(LOSCFG_KERNEL_DYNLOAD), y) LITEOS_BASELIB   += -ldynload
    LIB_SUBDIRS      += kernel/extended/dynload
    LITEOS_DYNLOAD_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/dynload/include endif
ifeq ($(LOSCFG_KERNEL_VDSO), y) LITEOS_BASELIB   += -lvdso
    LIB_SUBDIRS      += kernel/extended/vdso/usr
    LIB_SUBDIRS      += kernel/extended/vdso/src
    LITEOS_VDSO_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/vdso/include endif
ifeq ($(LOSCFG_KERNEL_TICKLESS), y) LITEOS_BASELIB += -ltickless
    LIB_SUBDIRS       += kernel/extended/tickless LITEOS_TICKLESS_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/tickless endif
ifeq ($(LOSCFG_KERNEL_TRACE), y) LITEOS_BASELIB += -ltrace
    LIB_SUBDIRS       += kernel/extended/trace
    LITEOS_TRACE_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/trace endif
ifeq ($(LOSCFG_KERNEL_LITEIPC), y) LITEOS_BASELIB     += -lliteipc
    LIB_SUBDIRS           += kernel/extended/liteipc LITEOS_LITEIPC_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/liteipc endif
ifeq ($(LOSCFG_KERNEL_PIPE), y) LITEOS_BASELIB     += -lpipes
    LIB_SUBDIRS           += kernel/extended/pipe
    LITEOS_PIPE_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/pipe endif ################################### Kernel Option End ################################
#################################### Lib Option Begin ############################### ifeq ($(LOSCFG_LIB_LIBC), y) LIB_SUBDIRS        += lib/libc
    LIB_SUBDIRS        += lib/libsec
    LITEOS_BASELIB  += -lc -lsec
    LITEOS_LIBC_INCLUDE   += \ $(LITEOS_LIBSCREW_INCLUDE) \
        -I $(LITEOSTOPDIR)/lib/libc/musl/include \
        -I $(LITEOSTOPDIR)/lib/libc/musl/obj/include \
        -I $(LITEOSTOPDIR)/lib/libc/musl/arch/arm \
        -I $(LITEOSTOPDIR)/lib/libc/musl/arch/generic \
        -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include endif
    LITEOS_BASELIB   += -lscrew
    LIB_SUBDIRS         += lib/libscrew
    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
ifeq ($(LOSCFG_LIB_ZLIB), y) LITEOS_BASELIB += -lz
    LIB_SUBDIRS    += lib/zlib
    LITEOS_ZLIB_INCLUDE += -I $(LITEOSTHIRDPARTY)/zlib endif ################################### Lib Option End ######################################
####################################### Compat Option Begin ######################################### ifeq ($(LOSCFG_COMPAT_POSIX), y) LITEOS_BASELIB += -lposix
    LIB_SUBDIRS       += compat/posix
    LITEOS_POSIX_INCLUDE   += \
        -I $(LITEOSTOPDIR)/compat/posix/include endif
ifeq ($(LOSCFG_COMPAT_BSD), y) LITEOS_BASELIB += -lbsd
    LIB_SUBDIRS    += bsd
    LITEOS_BSD_INCLUDE   += -I $(LITEOSTOPDIR)/bsd
    LITEOS_CMACRO += -DLOSCFG_COMPAT_LINUXKPI
    LITEOS_BASELIB += -llinuxkpi
    LIB_SUBDIRS       += bsd/compat/linuxkpi
    LITEOS_LINUX_INCLUDE += -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include \
                            -I $(LITEOSTOPDIR)/bsd \
                            -I $(LITEOSTOPDIR)/bsd/kern endif ######################################## Compat Option End ############################################
#################################### FS Option Begin ################################## ifeq ($(LOSCFG_FS_VFS), y) LITEOS_BASELIB += -lvfs -lmulti_partition ifeq ($(LOSCFG_FS_VFS_BLOCK_DEVICE), y) LITEOS_BASELIB += -lbch
    LIB_SUBDIRS       += fs/vfs fs/vfs/bch endif LIB_SUBDIRS       += fs/vfs fs/vfs/multi_partition
    LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/include LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/vfs/include/driver LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/vfs/include/operation LITEOS_VFS_MTD_INCLUDE := -I $(LITEOSTOPDIR)/fs/vfs/include/multi_partition LITEOS_VFS_DISK_INCLUDE := -I $(LITEOSTOPDIR)/fs/vfs/include/disk endif
ifeq ($(LOSCFG_FS_FAT), y) LITEOS_BASELIB  += -lfat
    LIB_SUBDIRS     += fs/fat
    LITEOS_FAT_INCLUDE += -I $(LITEOSTHIRDPARTY)/FatFs/source endif
ifeq ($(LOSCFG_FS_FAT_VIRTUAL_PARTITION), y) LITEOS_BASELIB += -lvirpart
    LIB_SUBDIRS += fs/fat/virpart
    LITEOS_FAT_VIRPART_INCLUDE += -I $(LITEOSTOPDIR)/fs/fat/virpart/include endif
ifeq ($(LOSCFG_FS_FAT_DISK), y) LITEOS_BASELIB += -ldisk
    LIB_SUBDIRS += fs/vfs/disk endif
ifeq ($(LOSCFG_FS_FAT_CACHE), y) LITEOS_BASELIB  += -lbcache
    LIB_SUBDIRS     += fs/vfs/bcache
    LITEOS_FAT_CACHE_INCLUDE += -I $(LITEOSTOPDIR)/fs/vfs/include/bcache endif
ifeq ($(LOSCFG_FS_RAMFS), y) LITEOS_BASELIB  += -lramfs
    LIB_SUBDIRS     += fs/ramfs endif
ifeq ($(LOSCFG_FS_NFS), y) LITEOS_BASELIB  += -lnfs
    LIB_SUBDIRS     += fs/nfs endif
ifeq ($(LOSCFG_FS_PROC), y) LITEOS_BASELIB  += -lproc
    LIB_SUBDIRS     += fs/proc
    LITEOS_PROC_INCLUDE += -I $(LITEOSTOPDIR)/fs/proc/include endif
ifeq ($(LOSCFG_FS_JFFS), y) LITEOS_BASELIB  += -ljffs2
    LIB_SUBDIRS     += fs/jffs2 endif #################################### FS Option End ##################################
################################### Net Option Begin ################################### ifeq ($(LOSCFG_NET_LWIP_SACK), y) ifeq ($(LOSCFG_NET_LWIP_SACK_2_1), y) LWIPDIR := $(LITEOSTHIRDPARTY)/lwip/src
    LITEOS_BASELIB += -llwip
    LIB_SUBDIRS       += net/lwip-2.1
    LITEOS_LWIP_SACK_INCLUDE   += \
        -I $(LITEOSTOPDIR)/net/lwip-2.1/porting/include \
        -I $(LWIPDIR)/include \
        -I $(LITEOSTOPDIR)/net/mac
    LITEOS_CMACRO     +=  $(LWIP_MACROS) else $(error "unknown lwip version") endif endif
#################################### Net Option End#################################### LITEOS_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../drivers/liteos LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/platform ################################## Driver Option Begin ################################# ifeq ($(LOSCFG_DRIVERS_HDF), y) # include $(LITEOSTOPDIR)/../../drivers/hdf/lite/hdf_lite.mk # Copyright (c) 2020 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
ifeq ($(LOSCFG_DRIVERS_HDF), y) LITEOS_BASELIB += --whole-archive
    LITEOS_DRIVERS_HDF := $(LITEOSTOPDIR)/../../drivers/hdf/lite LITEOS_SOURCE_ROOT := $(LITEOSTOPDIR)/../..
    LIB_SUBDIRS        += $(LITEOS_DRIVERS_HDF)
    HDF_FRAMEWORKS_PATH:= $(LITEOSTOPDIR)/../../drivers/hdf/frameworks LITEOS_BASELIB += -lhdf
    LITEOS_DRIVERS_HDF_INCLUDE += -I $(LITEOS_DRIVERS_HDF)/include/manager LITEOS_DRIVERS_HDF_INCLUDE += -I $(HDF_FRAMEWORKS_PATH)/support/platform/include LITEOS_DRIVERS_HDF_INCLUDE += -I $(HDF_FRAMEWORKS_PATH)/include/platform LITEOS_DRIVERS_HDF_INCLUDE += -I $(HDF_FRAMEWORKS_PATH)/include/utils
# models ifeq ($(LOSCFG_DRIVERS_HDF_WIFI), y) LITEOS_BASELIB += -lhdf_wifi_model
    LIB_SUBDIRS    +=  $(LITEOS_DRIVERS_HDF)/model/network/wifi endif
ifeq ($(LOSCFG_DRIVERS_HDF_USB), y) LITEOS_DRIVERS_HDF_INCLUDE += -I $(LITEOS_DRIVERS_HDF)/model/bus/usb/include LITEOS_BASELIB += -lhdf_usb
    LIB_SUBDIRS    +=  $(LITEOS_DRIVERS_HDF)/model/bus/usb endif
# vendor lib ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) include $(LITEOSTOPDIR)/../../vendor/huawei/hdf/hdf_vendor.mk endif
ifeq ($(LOSCFG_PLATFORM_IMX6ULL), y) include $(LITEOSTOPDIR)/../../vendor/nxp/hdf/hdf_vendor.mk endif
ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) # include $(LITEOSTOPDIR)/../../vendor/st/hdf/hdf_vendor.mk # Copyright (c) 2020 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
    LITEOS_BASELIB += -lhdf_config
    LIB_SUBDIRS += $(LITEOS_SOURCE_ROOT)/vendor/st/$(LITEOS_PLATFORM)/config
VENDOR_HDF_DRIVERS_ROOT := $(LITEOSTOPDIR)/../../vendor/st/hdf
ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) #LIB_SUBDIRS             += $(STM32MP157_BASE_DIR)/driver/stm32mp157-i2c #LITEOS_BASELIB  += -lstm32mp157-i2c endif
#LIB_SUBDIRS             += $(STM32MP157_BASE_DIR)/driver/touch #LITEOS_BASELIB  += -ltouch
LIB_SUBDIRS             += $(STM32MP157_BASE_DIR)/driver/hello LITEOS_BASELIB  += -lhello
# lib path LITEOS_LD_PATH += -L$(VENDOR_HDF_DRIVERS_ROOT)/libs/$(LITEOS_PLATFORM)
endif
    LITEOS_BASELIB += --no-whole-archive endif
endif
ifeq ($(LOSCFG_DRIVERS_HIEVENT), y) LITEOS_BASELIB     += -lhievent
    LIB_SUBDIRS           += $(LITEOS_DRIVERS_BASE_PATH)/hievent LITEOS_HIEVENT_INCLUDE   += -I $(LITEOS_DRIVERS_BASE_PATH)/hievent/include endif
ifeq ($(LOSCFG_DRIVERS_HIEDMAC), y) LITEOS_BASELIB    += -lhiedmac
    LITEOS_HIDMAC_INCLUDE   += -I $(LITEOS_VENDOR_DRIVERS_BASE_PATH)/hiedmac/include endif
ifeq ($(LOSCFG_DRIVERS_HIETH_SF), y) LITEOS_BASELIB    += -lhieth-sf
    LITEOS_HIETH_SF_INCLUDE += -I $(LITEOS_VENDOR_DRIVERS_BASE_PATH)/hieth-sf/include endif
ifeq ($(LOSCFG_DRIVERS_TZDRIVER), y) LITEOS_BASELIB   += -ltzdriver -lmbedtls
    LIB_SUBDIRS         += $(LITEOS_DRIVERS_BASE_PATH)/tzdriver  $(LITEOSTOPDIR)/lib/libmbedtls LITEOS_TZDRIVER_INCLUDE += -I $(LITEOS_DRIVERS_BASE_PATH)/tzdriver/include endif
ifeq ($(LOSCFG_DRIVERS_MEM), y) LITEOS_BASELIB += -lmem
    LIB_SUBDIRS       += $(LITEOS_DRIVERS_BASE_PATH)/mem endif
ifeq ($(LOSCFG_DRIVERS_MMC), y) MMC_HOST_DIR := himci
    LITEOS_BASELIB  += -lmmc
    LITEOS_MMC_INCLUDE += -I $(LITEOS_VENDOR_DRIVERS_BASE_PATH)/mmc/include endif
ifeq ($(LOSCFG_DRIVERS_MTD), y) LITEOS_BASELIB    += -lmtd_common
    LITEOS_MTD_SPI_NOR_INCLUDE  +=  -I $(LITEOS_VENDOR_DRIVERS_BASE_PATH)/mtd/common/include
    ifeq ($(LOSCFG_DRIVERS_MTD_SPI_NOR), y) ifeq ($(LOSCFG_DRIVERS_MTD_SPI_NOR_HISFC350), y) NOR_DRIVER_DIR := hisfc350 else ifeq ($(LOSCFG_DRIVERS_MTD_SPI_NOR_HIFMC100), y) NOR_DRIVER_DIR := hifmc100 endif
    LITEOS_BASELIB   += -lspinor_flash
    LITEOS_MTD_SPI_NOR_INCLUDE  +=  -I $(LITEOS_VENDOR_DRIVERS_BASE_PATH)/mtd/spi_nor/include
    endif endif
ifeq ($(LOSCFG_DRIVERS_RANDOM), y) LITEOS_BASELIB += -lrandom
    LIB_SUBDIRS    += $(LITEOS_DRIVERS_BASE_PATH)/random LITEOS_RANDOM_INCLUDE += -I $(LITEOS_DRIVERS_BASE_PATH)/random/include endif
ifeq ($(LOSCFG_DRIVERS_USB), y) LITEOS_BASELIB  += -lusb_base
    LIB_SUBDIRS     += $(LITEOSTOPDIR)/bsd/dev/usb
    LITEOS_USB_INCLUDE += -I $(LITEOSTOPDIR)/bsd/dev/usb ifeq ($(LOSCFG_USB_DEBUG), y) LITEOS_CMACRO   += -DLOSCFG_USB_DEBUG endif endif
ifeq ($(LOSCFG_DRIVERS_VIDEO), y) LITEOS_BASELIB += -lvideo
    LIB_SUBDIRS       += $(LITEOS_DRIVERS_BASE_PATH)/video LITEOS_VIDEO_INCLUDE += -I $(LITEOSTOPDIR)/../../third_party/NuttX/include/nuttx/video endif
############################## Driver Option End #######################################
############################## Dfx Option Begin####################################### ifeq ($(LOSCFG_BASE_CORE_HILOG), y) LITEOS_BASELIB     += -lhilog
    LIB_SUBDIRS           += $(LITEOSTOPDIR)/../../base/hiviewdfx/frameworks/hilog_lite/featured LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/../../base/hiviewdfx/interfaces/kits/hilog LITEOS_CMACRO += -DLOSCFG_BASE_CORE_HILOG endif ############################## Dfx Option End #######################################
############################# Tools && Debug Option Begin ############################## ifeq ($(LOSCFG_COMPRESS), y) LITEOS_BASELIB    += -lcompress
    LIB_SUBDIRS       += tools/compress endif
ifeq ($(LOSCFG_COMPILE_DEBUG), y) LITEOS_COPTS_OPTMIZE = -O0
    LITEOS_COPTS_OPTION  = -g -gdwarf-2 else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_COPTS_OPTMIZE = -Oz -flto else LITEOS_COPTS_OPTMIZE = -O2 endif
    LITEOS_COPTS_OPTMIZE_NODEBUG = -O0 endif LITEOS_COPTS_DEBUG  += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) LITEOS_INTERWORK += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTMIZE) LITEOS_ASOPTS   += $(LITEOS_COPTS_OPTION)
    LITEOS_NODEBUG  += $(LITEOS_COPTS_OPTMIZE_NODEBUG)
ifeq ($(LOSCFG_SHELL), y) LITEOS_BASELIB += -lshell
    LIB_SUBDIRS       += shell
    LITEOS_SHELL_INCLUDE  += -I $(LITEOSTOPDIR)/shell/full/include endif
ifeq ($(LOSCFG_NET_TELNET), y) LITEOS_BASELIB += -ltelnet
    LIB_SUBDIRS       += net/telnet
    LITEOS_TELNET_INCLUDE   += \
        -I $(LITEOSTOPDIR)/net/telnet/include endif
ifeq ($(LOSCFG_3RDPARTY), y)
    -include $(LITEOSTOPDIR)/3rdParty/3rdParty.mk endif
ifeq ($(LOSCFG_NULL_ADDRESS_PROTECT), y) LITEOS_CMACRO += -DLOSCFG_NULL_ADDRESS_PROTECT endif
LITEOS_BASELIB += -lsyscall LIB_SUBDIRS += syscall LIB_SUBDIRS += kernel/user
############################# Tools && Debug Option End #################################
############################# Security Option Begin ############################## LITEOS_SSP = -fno-stack-protector ifeq ($(LOSCFG_CC_STACKPROTECTOR), y) LITEOS_SSP = -fstack-protector --param ssp-buffer-size=4 endif
ifeq ($(LOSCFG_CC_STACKPROTECTOR_STRONG), y) LITEOS_SSP = -fstack-protector-strong endif
ifeq ($(LOSCFG_CC_STACKPROTECTOR_ALL), y) LITEOS_SSP = -fstack-protector-all endif
ifeq ($(LOSCFG_SECURITY), y) LIB_SUBDIRS += security LITEOS_BASELIB += -lsecurity ifeq ($(LOSCFG_SECURITY_CAPABILITY), y) LITEOS_SECURITY_CAP_INC := -I $(LITEOSTOPDIR)/security/cap endif ifeq ($(LOSCFG_SECURITY_VID), y) LITEOS_SECURITY_VID_INC := -I $(LITEOSTOPDIR)/security/vid endif endif
############################# Security Option End ##############################
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) ifeq ($(LITEOS_COMPILER_PATH),) LITEOS_COMPILER_PATH := $(shell $(LITEOSTOPDIR)/tools/build/mk/get_llvm_compiler_path.sh  $(CROSS_COMPILE) $(LITEOSTOPDIR)) export LITEOS_COMPILER_PATH endif CC  = $(LITEOS_COMPILER_PATH)/bin/clang AS  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)as AR  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)ar LD  = $(LITEOS_COMPILER_PATH)/bin/ld.lld GPP = $(LITEOS_COMPILER_PATH)/bin/clang++ OBJCOPY = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)objcopy -R .bss 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 else ifeq ($(LITEOS_COMPILER_PATH),) LITEOS_COMPILER_PATH := $(shell $(LITEOSTOPDIR)/tools/build/mk/get_compiler_path.sh  $(CROSS_COMPILE) $(LITEOSTOPDIR)) export LITEOS_COMPILER_PATH endif CC  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)gcc AS  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)as AR  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)ar LD  = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)ld GPP = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)g++ OBJCOPY = $(LITEOS_COMPILER_PATH)/bin/$(CROSS_COMPILE)objcopy 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/9.0.0/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4 LITEOS_COMPILER_GCC_INCLUDE = -I $(LITEOS_COMPILER_PATH)/lib/clang/9.0.0/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_HIMIX100_64), y) LITEOS_COMPILER_CXXLIB_PATH = $(LITEOS_COMPILER_PATH)/$(COMPILE_NAME)/lib64 LITEOS_COMPILER_GCCLIB_PATH = $(LITEOS_COMPILER_PATH)/lib/gcc/$(COMPILE_NAME)/$(VERSION_NUM) LITEOS_COMPILER_GCC_INCLUDE = -I $(LITEOS_COMPILER_PATH)/lib/gcc/aarch64-linux-android/$(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)/lib/libc/musl/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_HIMIX100_64), y) LITEOS_CXXINCLUDE += \
        -I $(LITEOS_COMPILER_CXX_PATH)/c++/$(VERSION_NUM)/aarch64-linux-android 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)
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)
LITEOS_EXTKERNEL_INCLUDE   := $(LITEOS_CPPSUPPORT_INCLUDE) $(LITEOS_DYNLOAD_INCLUDE) \ $(LITEOS_TICKLESS_INCLUDE)   $(LITEOS_TRACE_INCLUDE) \
                              $(LITEOS_VDSO_INCLUDE)       $(LITEOS_LITEIPC_INCLUDE) \ $(LITEOS_PIPE_INCLUDE) LITEOS_COMPAT_INCLUDE      := $(LITEOS_POSIX_INCLUDE) $(LITEOS_LINUX_INCLUDE) \ $(LITEOS_BSD_INCLUDE) LITEOS_FS_INCLUDE          := $(LITEOS_VFS_INCLUDE)        $(LITEOS_FAT_CACHE_INCLUDE) \ $(LITEOS_VFS_MTD_INCLUDE)    $(LITEOS_VFS_DISK_INCLUDE) \
                              $(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_DRIVERS_INCLUDE     := $(LITEOS_CELLWISE_INCLUDE)   $(LITEOS_GPIO_INCLUDE) \ $(LITEOS_HIDMAC_INCLUDE)     $(LITEOS_HIETH_SF_INCLUDE) \
                              $(LITEOS_HIGMAC_INCLUDE)     $(LITEOS_I2C_INCLUDE) \ $(LITEOS_LCD_INCLUDE)        $(LITEOS_MMC_INCLUDE) \
                              $(LITEOS_MTD_SPI_NOR_INCLUDE) \
                              $(LITEOS_RANDOM_INCLUDE)     $(LITEOS_RTC_INCLUDE) \ $(LITEOS_SPI_INCLUDE)        $(LITEOS_USB_INCLUDE) \
                              $(LITEOS_WTDG_INCLUDE)       $(LITEOS_DBASE_INCLUDE) \ $(LITEOS_CPUFREQ_INCLUDE)    $(LITEOS_DEVFREQ_INCLUDE) \
                              $(LITEOS_REGULATOR_INCLUDE)  $(LITEOS_VIDEO_INCLUDE) \ $(LITEOS_DRIVERS_HDF_INCLUDE) $(LITEOS_TZDRIVER_INCLUDE) \
                              $(LITEOS_HIEVENT_INCLUDE) LITEOS_DFX_INCLUDE    := $(LITEOS_HILOG_INCLUDE)
LITEOS_SECURITY_INCLUDE    := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_INC) LOSCFG_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE)  $(LITEOS_UART_INCLUDE) \ $(LITEOS_TELNET_INCLUDE)
FP = -fno-omit-frame-pointer LITEOS_COPTS_BASE  := -fno-pic -fno-builtin -nostdinc -nostdlib $(WARNING_AS_ERROR) $(LITEOS_SSP) $(LLVM_EXTRA_OPTS) -fno-strict-aliasing -fno-common -fsigned-char ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_COPTS_BASE += -fno-aggressive-loop-optimizations endif LITEOS_COPTS_EXTRA := -std=c99 -Wpointer-arith -Wstrict-prototypes -Winvalid-pch \
                      -ffunction-sections -fdata-sections -fno-exceptions $(FP) ifneq ($(LOSCFG_ARCH_ARM_AARCH64), y) ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_COPTS_BASE += -mno-unaligned-access LITEOS_COPTS_EXTRA += -mthumb-interwork endif endif LITEOS_COPTS_EXTRA += -fno-short-enums ifeq ($(LOSCFG_THUMB), y) LITEOS_COPTS_EXTRA_INTERWORK := $(LITEOS_COPTS_EXTRA) -mthumb LITEOS_CMACRO     += -DLOSCFG_INTERWORK_THUMB else LITEOS_COPTS_EXTRA_INTERWORK := $(LITEOS_COPTS_EXTRA) #-fno-inline endif
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y) 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) ifeq ($(LOSCFG_VENDOR) ,y) LITEOS_LD_PATH +=  -L$(OUT)/lib/rdk -L$(OUT)/lib/sdk \
                   -L$(OUT)/lib/main_server endif
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos_llvm.ld else LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld endif
# temporary LITEOS_PLATFORM_INCLUDE += \
        -I $(LITEOSTOPDIR)/kernel/base/include LITEOS_CXXINCLUDE += \ $(LITEOS_NET_INCLUDE) \
        -I $(LITEOSTOPDIR)/kernel/base/include
LITEOS_COPTS_NODEBUG    := $(LITEOS_NODEBUG) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA) LITEOS_COPTS_INTERWORK  := $(LITEOS_INTERWORK) $(LITEOS_COPTS_BASE) $(LITEOS_COPTS_EXTRA_INTERWORK) LITEOS_BASE_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_PLATFORM_INCLUDE) \ $(LITEOS_LIB_INCLUDE) $(LITEOS_FS_INCLUDE) \
                       $(LITEOS_EXTKERNEL_INCLUDE) \
                       $(LITEOS_COMPAT_INCLUDE) $(LITEOS_DRIVERS_INCLUDE) \ $(LOSCFG_TOOLS_DEBUG_INCLUDE) $(LITEOS_NET_INCLUDE) LITEOS_CFLAGS_INTERWORK := $(LITEOS_COPTS_INTERWORK) $(LITEOS_CMACRO) \ $(LITEOS_IMAGE_MACRO) $(LITEOS_BASE_INCLUDE) LITEOS_CFLAGS_NODEBUG := $(LITEOS_COPTS_NODEBUG) $(LITEOS_CMACRO) \ $(LITEOS_IMAGE_MACRO) $(LITEOS_BASE_INCLUDE)
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 # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
####Kernel command#### #task_shellcmd.c -utask_shellcmd #cpup_shellcmd.c -ucpup_shellcmd #shell_shellcmd.c -uhelp_shellcmd #mempt_shellcmd.c -ufree_shellcmd -umemcheck_shellcmd -uuname_shellcmd -ureadreg_shellcmd -uwritereg_shellcmd #sem_shellcmd.c -usem_shellcmd #sysinfo_shellcmd.c -usysteminfo_shellcmd #swtmr_shellcmd.c -uswtmr_shellcmd #hwi_shell.c -uhwi_shellcmd #dynload_shellcmd.c -uldinit_shellcmd -ucall_shellcmd -ufindsym_shellcmd -ulddrop_shellcmd -umclose_shellcmd -umopen_shellcmd LITEOS_TABLES_KERNEL_LDFLAGS := \
    -utask_shellcmd \
    -ug_usrVdsoDataPage\
    -uvm_shellcmd \
    -ucpup_shellcmd \
    -uhelp_shellcmd \
    -ufree_shellcmd \
    -usem_shellcmd \
    -umutex_shellcmd \
    -uqueue_shellcmd \
    -usysteminfo_shellcmd \
    -uswtmr_shellcmd \
    -uhwi_shellcmd \
    -ufindsym_shellcmd \
    -uzbar_scan_shellcmd \
    -udmesg_shellcmd \
    -udate_shellcmd \
    -ureadExcInfo_shellcmd \
    -uwatch_shellcmd \
    -udeadlock_shellcmd \
    -ukill_shellcmd \
    -upmm_shellcmd 
####Net command#### #api_shell.c -uarp_shellcmd -uifconfig_shellcmd -uping_shellcmd -utftp_shellcmd -unetstat_shellcmd -udns_shellcmd -untpdate_shellcmd #telnet_loop.c -utelnet_shellcmd LITEOS_TABLES_NET_LDFLAGS := \
    -uarp_shellcmd \
    -utelnet_shellcmd \
    -uping_shellcmd \
    -unetstat_shellcmd \
    -uifconfig_shellcmd
####FS command#### #vfs_shellcmd.c -ucd_shellcmd -ucat_shellcmd -uls_shellcmd -upwd_shellcmd -urm_shellcmd -urmdir_shellcmd -umkdir_shellcmd -utouch_shellcmd -uumount_shellcmd -umount_shellcmd -usync_shellcmd -ustatfs_shellcmd -ucp_shellcmd #fat_shellcmd.c -uformat_shellcmd #mtd_shellcmd.c -upartition_shellcmd #proc_shellcmd.c -uwriteproc_shellcmd #disk_shellcmd.c -upartinfo_shellcmd LITEOS_TABLES_FS_LDFLAGS := \
    -ucd_shellcmd \
    -uformat_shellcmd \
    -upartition_shellcmd \
    -uwriteproc_shellcmd \
    -upartinfo_shellcmd \
    -uumount_shellcmd -umount_shellcmd \
    -uvirstatfs_shellcmd \
    -ulsfd_shellcmd \
    -usu_shellcmd \
    -uchmod_shellcmd \
    -uchown_shellcmd \
    -uchgrp_shellcmd
####Tools command#### #iperf_shell.c -uiperf_shellcmd LITEOS_TABLES_TOOLS_LDFLAGS := \
    -uiperf_shellcmd \
    -ulwip_dump_shellcmd
####Extend command#### #reset_shell.c -ureset_shellcmd #bcm_wifi.c -ustartap_shellcmd -ustopap_shellcmd -ubcmwifi_shellcmd #ddrs_shell.c -uhiddrs_shellcmd #nand_shell.c -unand_bad_shellcmd #i2c_shell.c -ui2c_read_shellcmd -ui2c_write_shellcmd #spi_shell.c -ussp_read_shellcmd -ussp_write_shellcmd #uart_shell.c -uuart_config_shellcmd -uuart_write_shellcmd -uuart_read_shellcmd -uuart_close_shellcmd LITEOS_TABLES_EXTEND_LDFLAGS := \
    -ureset_shellcmd \
    -ustartap_shellcmd \
    -uhiddrs_shellcmd \
    -unand_bad_shellcmd \
    -ui2c_read_shellcmd \
    -ussp_read_shellcmd \
    -uuart_config_shellcmd\
    -uusb_debug_shellcmd
LITEOS_TABLES_DRIVER_LDFLAGS := \
    -ui2c_init \
    -ugpio_init \
    -uregulator_init \
    -uMtdInitList \
    -uhispi_init \
    -uhifmc100_init \
    -uhisfc350_init \
    -unand_hifmc100_init \
    -uhifmc100_parallel_init \
    -usd_mci_init \
    -uhi_mci_init \
    -upl011_init \
    -uhinfc620_init \
    -uhisnfc100_init \
    -uregulator_machine_init \
    -uhisimeidia_regulator_init \
    -ucpufreq_init  \
    -uhisilicon_cpufreq_init \
    -ucpufreq_machine_init  \
    -udevfreq_init \
    -umedia_devfreq_init \
    -udevfreq_machine_init\
    -uhieth_machine_init\
    -uhigmac_machine_init \
    -umachine_init
####FS MAP#### LITEOS_TABLES_FSMAP_LDFLAGS := \
    -uramfs_fsmap \
    -unfs_fsmap \
    -ufat_fsmap \
    -ujffs_fsmap \
    -uprocfs_fsmap \
    -ug_fsmap
LITEOS_TABLES_LDFLAGS := \ $(LITEOS_TABLES_KERNEL_LDFLAGS)\
    $(LITEOS_TABLES_NET_LDFLAGS) \
    $(LITEOS_TABLES_FS_LDFLAGS) \
    $(LITEOS_TABLES_TOOLS_LDFLAGS) \
    $(LITEOS_TABLES_EXTEND_LDFLAGS) \
    $(LITEOS_TABLES_FSMAP_LDFLAGS) \
    $(LITEOS_TABLES_DRIVER_LDFLAGS)
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_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)
RM = -rm -rf MAKE = make __LIBS = libs APPS = apps ROOTFSDIR = rootfsdir ROOTFS = rootfs
LITEOS_TARGET = liteos LITEOS_LIBS_TARGET = libs_target LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform LITEOS_PLATFORM_MENUCONFIG_H = $(LITEOS_PLATFORM_BASE)/include/menuconfig.h
ifeq ($(LOSCFG_PLATFORM_HI3518EV300), y) FSTYPE = jffs2 endif ifeq ($(LOSCFG_PLATFORM_HI3516DV300), y) FSTYPE = vfat endif ifeq ($(LOSCFG_PLATFORM_IMX6ULL), y) FSTYPE = jffs2 endif ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) FSTYPE = jffs2 ROOTFS_SIZE = 0xA00000 endif ROOTFS_DIR = $(OUT)/rootfs ROOTFS_ZIP = $(OUT)/rootfs.zip VERSION =
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS) lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
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 "-------------------------------------------------------"
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 dynload ##### # -include $(LITEOS_MK_PATH)/dynload.mk # Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2020, 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.
DYNLOADTESTDIR := $(LITEOSTOPDIR)/test/kernel/sample/kernel_extend/dynload export DYNLOADTESTDIR
##### command to test dynload #####
-include $(DYNLOADTESTDIR)/test_dynload.mk
#-----need move when make version-----# ##### make lib ##### $(__LIBS): $(OUT) $(CXX_INCLUDE)
ifeq ($(LOSCFG_PLATFORM_IMX6ULL),y) BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/nxp/imx6ull/board else ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/st/stm32mp157/board else BOARD_INCLUDE_DIR := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board endif
$(OUT): $(LITEOS_MENUCONFIG_H) $(HIDE)mkdir -p $(OUT)/lib
  $(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(BOARD_INCLUDE_DIR) \
  -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
  -o $(LITEOS_PLATFORM_BASE)/board.ld -P
$(BUILD): $(HIDE)mkdir -p $(BUILD)
$(LITEOS_LIBS_TARGET): $(__LIBS) $(HIDE)for dir in $(LIB_SUBDIRS); \ do $(MAKE) -C $$dir all || exit 1; \ done
  $(HIDE)echo "=============== make lib done  ==============="
##### make menuconfig ##### export CONFIG_=LOSCFG_ MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
menuconfig:$(MENUCONFIG_PATH)/mconf $< $(KCONFIG_FILE_PATH)
genconfig:$(MENUCONFIG_PATH)/conf $(HIDE)mkdir -p include/config include/generated
  $< --silentoldconfig $(KCONFIG_FILE_PATH)
  -mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H) ##### menuconfig end #######
$(LITEOS_MENUCONFIG_H): ifneq ($(LITEOS_PLATFORM_MENUCONFIG_H), $(wildcard $(LITEOS_PLATFORM_MENUCONFIG_H))) $(HIDE)$(MAKE) genconfig endif $(LITEOS_TARGET): $(__LIBS) $(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 ifeq ($(LOSCFG_PLATFORM_STM32MP157), y) mkimage.stm32 -T stm32image -a 0xC0100000 -e 0xC0100000 -d $(LITEOS_TARGET_DIR)/$@.bin $(LITEOS_TARGET_DIR)/liteos.stm32 mkimage.stm32 -A arm -O linux -T kernel -C none -a 0xC0100000 -e 0xC0100000 -n liteos-a -d $(LITEOS_TARGET_DIR)/$@.bin $(LITEOS_TARGET_DIR)/liteos_with_uboot_header.bin endif $(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
  $(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm #  $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
$(APPS): $(LITEOS_TARGET) $(HIDE)$(MAKE) -C apps all
prepare: $(HIDE)mkdir -p $(OUT)/musl ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) $(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl else $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl $(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl $(HIDE)cp -f $(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)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR)) ifneq ($(VERSION),) $(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)) endif
$(ROOTFS): $(ROOTFSDIR) $(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)  ${ROOTFS_SIZE}) $(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS) ifneq ($(OUT), $(LITEOS_TARGET_DIR)) $(HIDE)mv $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)rootfs endif
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) $(OUT) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~ $(HIDE)$(RM) $(LITEOS_PLATFORM_MENUCONFIG_H)
  $(HIDE)$(RM) include
  $(HIDE)$(MAKE) cleanrootfs
  $(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
cleanall: $(HIDE)$(RM) $(LITEOSTOPDIR)/out
  $(HIDE)find $(LITEOS_PLATFORM_BASE)/ -name board.ld -exec rm -rf {} \; $(HIDE)cd sample/sample_osdrv;make clean;cd ../..;
  $(HIDE)echo "clean all"
cleanrootfs: $(HIDE)$(RM) $(OUT)/rootfs
  $(HIDE)$(RM) $(OUT)/rootfs.zip
  $(HIDE)$(RM) $(OUT)/rootfs.img
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help


1.3.3 分析make过程


1. 第1个目标

all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)

2. 目标: OUT

OUT目标:


创建了目录:kernel/liteos_a/imx6ull/lib


把board.ld.S编译成了board.ld,这是链接文件。

# .config文件中, LOSCFG_PLATFORM="imx6ull"
OUT  = $(LITEOSTOPDIR)/out/$(LITEOS_PLATFORM)
$(OUT): $(LITEOS_MENUCONFIG_H)
  $(HIDE)mkdir -p $(OUT)/lib
  $(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(BOARD_INCLUDE_DIR) \
  -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
  -o $(LITEOS_PLATFORM_BASE)/board.ld -P


OUT的依赖:LITEOS_MENUCONFIG_H


配置内核,生成头文件autoconf.h。

LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
$(LITEOS_MENUCONFIG_H):
ifneq ($(LITEOS_PLATFORM_MENUCONFIG_H), $(wildcard $(LITEOS_PLATFORM_MENUCONFIG_H)))
  $(HIDE)$(MAKE) genconfig
endif
genconfig:$(MENUCONFIG_PATH)/conf
  $(HIDE)mkdir -p include/config include/generated
  $< --silentoldconfig $(KCONFIG_FILE_PATH)
  -mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H)


3. 目标: BUILD

创建目录 kernel/liteos_a/out/stm32mp157/obj或kernel/liteos_a/out/imx6ull/obj

OUT  = $(LITEOSTOPDIR)/out/$(LITEOS_PLATFORM)
BUILD  = $(OUT)/obj
$(BUILD):
  $(HIDE)mkdir -p $(BUILD)


4. 目标: LITEOS_TARGET

这是核心,进入子目录执行make,把子目录中的文件链接为一个库。


最后,把这些库链接为liteos内核。

LITEOS_TARGET = liteos
$(LITEOS_TARGET): $(__LIBS)
  $(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


目标:__LIBS

# 没做什么事

__LIBS = libs
$(__LIBS): $(OUT) $(CXX_INCLUDE)


命令:$(HIDE)touch $(LOSCFG_ENTRY_SRC)

每次都要编译los_config.c,touch一下

LOSCFG_ENTRY_SRC    = $(LITEOSTOPDIR)/kernel/common/los_config.c

命令:进入每个LITEOS_SUBDIRS,执行make

# LIB_SUBDIRS 等于一系列的目录
LIB_SUBDIRS :=
LIB_SUBDIRS             += arch/arm/$(LITEOS_ARCH_ARM)  # 就是arch/arm/arm
LIB_SUBDIRS             += $(PLATFORM_BSP_HISI_BASE)
LIB_SUBDIRS     += $(LITEOSTOPDIR)/kernel/common
LIB_SUBDIRS       += kernel/base
LIB_SUBDIRS     += $(IMX6ULL_BASE_DIR)/board
LIB_SUBDIRS     += $(IMX6ULL_BASE_DIR)/driver/mtd/common
LIB_SUBDIRS     += $(IMX6ULL_BASE_DIR)/driver/mtd/spi_nor
LIB_SUBDIRS             += $(IMX6ULL_BASE_DIR)/driver/imx6ull-fb
LIB_SUBDIRS             += $(IMX6ULL_BASE_DIR)/driver/imx6ull-uart
LIB_SUBDIRS         += kernel/extended/cpup
LIB_SUBDIRS        += lib/libc
LIB_SUBDIRS        += lib/libsec
LIB_SUBDIRS         += lib/libscrew
LIB_SUBDIRS     += fs/fat
LIB_SUBDIRS     += fs/jffs2
LITEOS_SUBDIRS   = $(LIB_SUBDIRS)
$(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

1671000730848.jpg

1671000741160.jpg


1.4 核心总结


1.4.1 生成内核的过程


配置内核时,配置信息放在.config里,比如:LOSCFG_FS_FAT=y


kernel/liteos_a/Makefile会包含很多文件,比如kernel/liteos_a/tools/build/mk/los_config.mk


它会看到LIB_SUBDIRS和LITEOS_BASELIB这两个变量


LIB_SUBDIRS表示要进入那个子目录编译


LITEOS_BASELIB表示要把哪些库链接进内核


比如:

```shell
ifeq ($(LOSCFG_FS_FAT), y)
    LITEOS_BASELIB  += -lfat
    LIB_SUBDIRS     += fs/fat
    LITEOS_FAT_INCLUDE += -I $(LITEOSTHIRDPARTY)/FatFs/source
endif
```


编译子目录:进入LIB_SUBDIRS指定的子目录,执行make all


对于子目录xxx的编译,一般是生成libxxx.a

链接内核 * 把 LITEOS_BASELIB指定的库都链接进内核


1.4.2 增加模块


在kernel/liteos_a/Makefile能包含的文件中,增加这2个变量:


LIB_SUBDIRS += 源码目录/xxx


LITEOS_BASELIB += -lxxx


在源码目录/xxx下仿照fs/fat/Makefile增加Makefile

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore &nbsp; &nbsp; ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库&nbsp;ECS 实例和一台目标数据库&nbsp;RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&amp;RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
1月前
|
JavaScript 前端开发 物联网
「Mac畅玩鸿蒙与硬件1」鸿蒙开发环境配置篇1 - 认识鸿蒙系统与开发工具
本篇将介绍鸿蒙操作系统(HarmonyOS)的基本概念以及在 Mac 环境下进行鸿蒙开发所需的工具。通过了解鸿蒙系统和开发工具的特点,为后续的学习和实践奠定基础。
99 1
「Mac畅玩鸿蒙与硬件1」鸿蒙开发环境配置篇1 - 认识鸿蒙系统与开发工具
|
2月前
|
存储 数据管理 调度
HarmonyOS架构理解:揭开鸿蒙系统的神秘面纱
【10月更文挑战第21天】华为的鸿蒙系统(HarmonyOS)以其独特的分布式架构备受关注。该架构包括分布式软总线、分布式数据管理和分布式任务调度。分布式软总线实现设备间的无缝连接;分布式数据管理支持跨设备数据共享;分布式任务调度则实现跨设备任务协同。这些特性为开发者提供了强大的工具,助力智能设备的未来发展。
134 1
|
2月前
|
安全 物联网 大数据
基于开元鸿蒙(OpenHarmony)的【智能药房与药品管理综合应用系统
基于开元鸿蒙(OpenHarmony)的【智能药房与药品管理综合应用系统
94 8
|
2月前
|
传感器 监控 算法
基于开源鸿蒙(OpenHarmony)的【智能家居综合应用】系统
基于开源鸿蒙(OpenHarmony)的【智能家居综合应用】系统
128 6
|
2月前
|
传感器 人工智能 监控
【基于开源鸿蒙(OpenHarmony)的智慧农业综合应用系统】
【基于开源鸿蒙(OpenHarmony)的智慧农业综合应用系统】
164 6
|
2月前
|
搜索推荐 物联网 开发工具
基于OpenHarmony(开源鸿蒙)的智慧医疗综合应用系统
基于OpenHarmony(开源鸿蒙)的智慧医疗综合应用系统
115 5
|
6月前
|
网络协议 安全 调度
阿里云公共DNS发布支持鸿蒙系统版的SDK
阿里云公共DNS发布支持鸿蒙系统版SDK,赋能鸿蒙开发者快速接入阿里云公共DNS服务。公共DNS将帮助接入的鸿蒙应用免除LocalDNS劫持困扰、解析加速、精准调度。
|
7月前
|
Android开发
【通讯录教程】苹果安卓鸿蒙系统通用,如何大批量导入手机号码到手机的通讯录,下面教你方法,只需1分钟搞定几万个号码的导入手机电话本
该文介绍了一种快速批量导入手机通讯录的方法,适用于处理大量手机号的需求,如微商管理、客户资料整理等。在QQ同步助手开始收费后,提供了免费的替代方案。步骤包括:下载批量导入软件(链接提供腾讯云盘和百度网盘地址),清空通讯录(非必需),制作符合格式的通讯录文件,并按操作系统(苹果、安卓或鸿蒙)进行导入。整个过程只需1分钟,简便快捷。
544 2
|
7月前
|
安全 开发工具 开发者
请说明鸿蒙操作系统的生态系统建设和开发者支持措施。
请说明鸿蒙操作系统的生态系统建设和开发者支持措施。
144 5