los_config.mk 22.3 KB
Newer Older
M
mamingshuai 已提交
1 2
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
W
wenjun 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#
# 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.

C
Caoruihong 已提交
30 31 32
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config

33
-include $(LITEOS_CONFIG_FILE)
W
wenjun 已提交
34

35 36
ifeq ($(ARCH),)
ARCH = $(error ARCH not set!)
W
wenjun 已提交
37 38
endif

39 40 41 42 43 44 45
## variable define ##
HIDE = @
RM = -rm -rf
OUT = $(or $(OUTDIR),$(LITEOSTOPDIR)/out/$(LOSCFG_PRODUCT_NAME:"%"=%))
MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk
LITEOS_SCRIPTPATH = $(LITEOSTOPDIR)/tools/scripts
LITEOSTHIRDPARTY = $(LITEOSTOPDIR)/../../third_party
W
wenjun 已提交
46

47 48 49 50 51
## compiler relative ##
get_compiler_path = $(or $(wildcard $(1)),$(dir $(shell which $(CROSS_COMPILE)as)))
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CROSS_COMPILE ?= llvm-
LITEOS_COMPILER_PATH ?= $(call get_compiler_path,$(LITEOSTOPDIR)/../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/)
C
Caoruihong 已提交
52
LLVM_TARGET = $(if $(LOSCFG_LLVM_TARGET:"%"=%),--target=$(LOSCFG_LLVM_TARGET:"%"=%),)
53 54 55 56 57 58 59 60 61 62 63 64
LLVM_SYSROOT = $(if $(SYSROOT_PATH),--sysroot=$(SYSROOT_PATH),)
CC  = $(LITEOS_COMPILER_PATH)clang $(LLVM_TARGET) $(LLVM_SYSROOT)
AS  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
AR  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ar
LD  = $(LITEOS_COMPILER_PATH)ld.lld
GPP = $(LITEOS_COMPILER_PATH)clang++ $(LLVM_TARGET) $(LLVM_SYSROOT)
OBJCOPY = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objcopy -R .bss
OBJDUMP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objdump
SIZE = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)size
NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
else ifeq ($(LOSCFG_COMPILER_GCC), y)
C
Caoruihong 已提交
65
CROSS_COMPILE ?= $(LOSCFG_CROSS_COMPILE:"%"=%)
66 67 68 69 70 71 72 73 74 75 76 77 78
LITEOS_COMPILER_PATH ?= $(call get_compiler_path,$(LITEOSTOPDIR)/../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin/)
CC  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)gcc
AS  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
AR  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ar
LD  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ld
GPP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)g++
OBJCOPY = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objcopy
OBJDUMP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objdump
SIZE = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)size
NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
else
CC  = echo $(info compiler type not set!)
C
Caoruihong 已提交
79
endif
80

W
wenjun 已提交
81 82 83 84 85 86 87 88 89 90
## c as cxx ld options ##
LITEOS_ASOPTS :=
LITEOS_COPTS_BASE :=
LITEOS_COPTS_EXTRA :=
LITEOS_COPTS_DEBUG :=
LITEOS_CXXOPTS :=
LITEOS_CXXOPTS_BASE :=
LITEOS_LD_OPTS :=
LITEOS_GCOV_OPTS :=
## macro define ##
91
LITEOS_CMACRO := -D__LITEOS__
W
wenjun 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
LITEOS_CXXMACRO :=
## head file path and ld path ##
LITEOS_PLATFORM_INCLUDE :=
LITEOS_CXXINCLUDE :=
LITEOS_LD_PATH :=
LITEOS_LD_SCRIPT :=
## c as cxx ld flags ##
LITEOS_ASFLAGS :=
LITEOS_CFLAGS :=
LITEOS_LDFLAGS :=
LITEOS_CXXFLAGS :=
## depended lib ##
LITEOS_BASELIB :=
LITEOS_LIBDEP :=
## directory ##
LIB_SUBDIRS :=

####################################### CPU Option Begin #########################################
include $(LITEOSTOPDIR)/arch/cpu.mk
####################################### CPU Option End #########################################

############################# Platform Option Begin#################################
include $(LITEOSTOPDIR)/platform/bsp.mk
############################# Platform Option End #################################

####################################### Kernel Option Begin ###########################################
LITEOS_BASELIB += -lbase
LIB_SUBDIRS       += kernel/base
120 121
LITEOS_KERNEL_INCLUDE   := -I $(LITEOSTOPDIR)/kernel/include \
                           -I $(LITEOSTOPDIR)/kernel/base/include
W
wenjun 已提交
122

A
arvinzzz 已提交
123 124 125 126 127 128 129 130 131 132
LITEOS_BASELIB += -lcommon
LIB_SUBDIRS       += kernel/common
LITEOS_KERNEL_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/common

ifeq ($(LOSCFG_KERNEL_CPPSUPPORT), y)
    LITEOS_BASELIB += -lcppsupport
    LIB_SUBDIRS       += kernel/extended/cppsupport
    LITEOS_CPPSUPPORT_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/cppsupport
endif

W
wenjun 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
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_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

C
Caoruihong 已提交
152
ifeq ($(LOSCFG_KERNEL_TRACE), y)
L
LiteOS2021 已提交
153
    LITEOS_BASELIB    += -ltrace
W
wenjun 已提交
154
    LIB_SUBDIRS       += kernel/extended/trace
L
LiteOS2021 已提交
155 156 157 158 159 160
endif

ifeq ($(LOSCFG_KERNEL_HOOK), y)
    LITEOS_BASELIB += -lhook
    LIB_SUBDIRS       += kernel/extended/hook
    LITEOS_HOOK_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/hook/include
C
Caoruihong 已提交
161
endif
W
wenjun 已提交
162

L
LiteOS2021 已提交
163 164 165 166 167 168
ifeq ($(LOSCFG_KERNEL_PERF), y)
    LITEOS_BASELIB        += -lperf
    LIB_SUBDIRS           += kernel/extended/perf
    LITEOS_PERF_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/perf
endif

L
LiteOS2021 已提交
169 170 171 172 173 174
ifeq ($(LOSCFG_KERNEL_LMS), y)
    LITEOS_BASELIB        += -llms
    LIB_SUBDIRS           += kernel/extended/lms
    LITEOS_LMS_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/lms
endif

W
wenjun 已提交
175 176 177 178 179 180 181 182
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
M
mamingshuai 已提交
183
    LIB_SUBDIRS           += kernel/extended/pipes
A
arvinzzz 已提交
184
    LITEOS_PIPE_INCLUDE   += -I $(LITEOSTOPDIR)/../../third_party/NuttX/drivers/pipes
W
wenjun 已提交
185
endif
Z
zhushengle 已提交
186 187 188 189

ifeq ($(LOSCFG_KERNEL_PM), y)
    LITEOS_BASELIB        += -lpower
    LIB_SUBDIRS           += kernel/extended/power
Z
zhushengle 已提交
190
    LITEOS_PM_INCLUDE      = -I $(LITEOSTOPDIR)/kernel/extended/power
Z
zhushengle 已提交
191 192
endif

A
arvinzzz 已提交
193 194 195 196
ifeq ($(LOSCFG_KERNEL_SYSCALL), y)
    LITEOS_BASELIB += -lsyscall
    LIB_SUBDIRS += syscall
endif
Z
zhushengle 已提交
197 198 199 200 201 202 203

ifeq ($(LOSCFG_KERNEL_PLIMITS), y)
    LITEOS_BASELIB        += -lplimit
    LIB_SUBDIRS           += kernel/extended/plimit
    LITEOS_PLIMITS_INCLUDE = -I $(LITEOSTOPDIR)/kernel/extended/plimit
endif

A
arvinzzz 已提交
204 205
LIB_SUBDIRS += kernel/user

W
wenjun 已提交
206 207 208
################################### Kernel Option End ################################

#################################### Lib Option Begin ###############################
A
arvinzzz 已提交
209 210 211 212
LITEOS_BASELIB   += -lscrew
LIB_SUBDIRS         += lib/libscrew
LITEOS_LIBSCREW_INCLUDE += -I $(LITEOSTOPDIR)/lib/libscrew/include

W
wenjun 已提交
213
ifeq ($(LOSCFG_LIB_LIBC), y)
214
    LIB_SUBDIRS           += lib/libc/musl
C
Caoruihong 已提交
215
    LITEOS_BASELIB        += -lc
W
wenjun 已提交
216
    LITEOS_LIBC_INCLUDE   += \
217
        -isystem $(LITEOSTHIRDPARTY)/musl/porting/liteos_a/kernel/include
C
Caoruihong 已提交
218 219 220 221

    LIB_SUBDIRS           += lib/libsec
    LITEOS_BASELIB        += -lsec
    LITEOS_LIBC_INCLUDE   += \
W
wenjun 已提交
222
        -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
223
    LITEOS_CMACRO         += -DSECUREC_IN_KERNEL=0
W
wenjun 已提交
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
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_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
M
mucor 已提交
259
    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/bch
W
wenjun 已提交
260
endif
M
mucor 已提交
261
    LIB_SUBDIRS       += fs/vfs drivers/mtd/multi_partition
M
mucor 已提交
262 263
    LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/include \
                            -I $(LITEOSTOPDIR)/fs/vfs/include
W
wenjun 已提交
264
    LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/vfs/include/operation
M
mucor 已提交
265
    LITEOS_VFS_MTD_INCLUDE := -I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include
W
wenjun 已提交
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
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
M
mucor 已提交
282
    LIB_SUBDIRS += $(LITEOSTOPDIR)/drivers/block/disk
A
arvinzzz 已提交
283
    LITEOS_VFS_DISK_INCLUDE := -I $(LITEOSTOPDIR)/drivers/block/disk/include
W
wenjun 已提交
284 285 286 287 288
endif

ifeq ($(LOSCFG_FS_FAT_CACHE), y)
    LITEOS_BASELIB  += -lbcache
    LIB_SUBDIRS     += fs/vfs/bcache
M
mucor 已提交
289
    LITEOS_FAT_CACHE_INCLUDE += -I $(LITEOSTOPDIR)/fs/vfs/include/bcache
W
wenjun 已提交
290 291 292 293 294 295 296 297
endif


ifeq ($(LOSCFG_FS_RAMFS), y)
    LITEOS_BASELIB  += -lramfs
    LIB_SUBDIRS     += fs/ramfs
endif

298 299 300 301 302
ifeq ($(LOSCFG_FS_ROMFS), y)
    LITEOS_BASELIB  += -lromfs
    LIB_SUBDIRS     += fs/romfs
endif

W
wenjun 已提交
303 304 305 306 307 308 309 310 311 312 313 314 315
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)
316 317
#    LITEOS_BASELIB  += -ljffs2
#    LIB_SUBDIRS     += fs/jffs2
W
wenjun 已提交
318
endif
M
mamingshuai 已提交
319

A
arvinzzz 已提交
320 321 322 323 324 325 326 327 328 329 330
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
    LITEOS_BASELIB  += -lrootfs
    LIB_SUBDIRS     += fs/rootfs
    LITEOS_PLATFORM_INCLUDE     += -I $(LITEOSTOPDIR)/fs/rootfs
endif

ifeq ($(LOSCFG_PLATFORM_PATCHFS), y)
    LITEOS_BASELIB  += -lpatchfs
    LIB_SUBDIRS     += fs/patchfs
endif

M
mamingshuai 已提交
331 332 333 334
ifeq ($(LOSCFG_FS_ZPFS), y)
    LITEOS_BASELIB  += -lzpfs
    LIB_SUBDIRS     += fs/zpfs
endif
W
wenjun 已提交
335 336 337 338 339 340 341 342 343 344 345 346 347
#################################### 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
M
mamingshuai 已提交
348
else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y)
349
    LWIPDIR := $(LITEOSTHIRDPARTY)/lwip_enhanced/src
M
mamingshuai 已提交
350 351 352 353 354
    LITEOS_BASELIB += -llwip
    LIB_SUBDIRS       += $(LWIPDIR)
    LITEOS_LWIP_SACK_INCLUDE   += \
        -I $(LWIPDIR)/include \
        -I $(LITEOSTOPDIR)/net/mac
C
Caoruihong 已提交
355
    LITEOS_CMACRO += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT
W
wenjun 已提交
356 357 358 359 360 361 362 363 364
else
    $(error "unknown lwip version")
endif
endif

#################################### Net Option End####################################
LITEOS_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../drivers/liteos
################################## Driver Option Begin #################################
ifeq ($(LOSCFG_DRIVERS_HDF), y)
365
include $(LITEOSTOPDIR)/../../drivers/hdf_core/adapter/khdf/liteos/hdf_lite.mk
W
wenjun 已提交
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
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_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
M
mamingshuai 已提交
382 383
    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/mem
    LITEOS_DEV_MEM_INCLUDE = -I $(LITEOSTOPDIR)/drivers/char/mem/include
W
wenjun 已提交
384 385
endif

L
LiteOS2021 已提交
386 387 388 389 390
ifeq ($(LOSCFG_DRIVERS_TRACE), y)
    LITEOS_BASELIB += -ltrace_dev
    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/trace
endif

L
LiteOS2021 已提交
391 392 393 394 395 396
ifeq ($(LOSCFG_DRIVERS_PERF), y)
    LITEOS_BASELIB            += -lperf_dev
    LIB_SUBDIRS               += $(LITEOSTOPDIR)/drivers/char/perf
    LITEOS_DEV_PERF_INCLUDE   += -I $(LITEOSTOPDIR)/drivers/char/perf/include
endif

397
ifeq ($(LOSCFG_DRIVERS_QUICKSTART), y)
M
mamingshuai 已提交
398 399
    LITEOS_BASELIB += -lquickstart
    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/quickstart
400
    LITEOS_DEV_QUICKSTART_INCLUDE = -I $(LITEOSTOPDIR)/drivers/char/quickstart/include
W
wenjun 已提交
401 402 403 404
endif

ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
    LITEOS_BASELIB += -lrandom
M
mamingshuai 已提交
405 406
    LIB_SUBDIRS    += $(LITEOSTOPDIR)/drivers/char/random
    LITEOS_RANDOM_INCLUDE += -I $(LITEOSTOPDIR)/drivers/char/random/include
W
wenjun 已提交
407 408 409 410 411 412
endif

ifeq ($(LOSCFG_DRIVERS_USB), y)
    LITEOS_BASELIB  += -lusb_base
    LIB_SUBDIRS     += $(LITEOSTOPDIR)/bsd/dev/usb
    LITEOS_USB_INCLUDE += -I $(LITEOSTOPDIR)/bsd/dev/usb
A
arvinzzz 已提交
413
    LITEOS_CMACRO   += -DUSB_DEBUG_VAR=5
W
wenjun 已提交
414 415 416 417
endif

ifeq ($(LOSCFG_DRIVERS_VIDEO), y)
    LITEOS_BASELIB += -lvideo
M
mamingshuai 已提交
418
    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/video
419
    LITEOS_VIDEO_INCLUDE += -I $(LITEOSTHIRDPARTY)/NuttX/include/nuttx/video
W
wenjun 已提交
420 421 422 423 424 425
endif

############################## Driver Option End #######################################

############################## Dfx Option Begin#######################################
ifeq ($(LOSCFG_BASE_CORE_HILOG), y)
A
arvinzzz 已提交
426 427 428
    LITEOS_BASELIB      += -lhilog
    LIB_SUBDIRS         += $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/frameworks/featured
    LIB_SUBDIRS         += $(LITEOSTOPDIR)/kernel/extended/hilog
M
mamingshuai 已提交
429 430
    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/interfaces/native/kits
    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog
A
arvinzzz 已提交
431
    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/hilog
W
wenjun 已提交
432
endif
Q
qidechun 已提交
433 434
ifeq ($(LOSCFG_BLACKBOX), y)
    LITEOS_BASELIB     += -lblackbox
A
arvinzzz 已提交
435 436
    LIB_SUBDIRS           += $(LITEOSTOPDIR)/kernel/extended/blackbox
    LITEOS_BLACKBOX_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/blackbox
Q
qidechun 已提交
437
endif
438 439
ifeq ($(LOSCFG_HIDUMPER), y)
    LITEOS_BASELIB     += -lhidumper
A
arvinzzz 已提交
440 441
    LIB_SUBDIRS           += $(LITEOSTOPDIR)/kernel/extended/hidumper
    LITEOS_HIDUMPER_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/hidumper
442
endif
W
wenjun 已提交
443 444 445 446 447 448 449 450
############################## Dfx Option End #######################################

############################# Tools && Debug Option Begin ##############################
ifeq ($(LOSCFG_COMPRESS), y)
    LITEOS_BASELIB    += -lcompress
    LIB_SUBDIRS       += tools/compress
endif

451 452 453 454
ifneq ($(LOSCFG_DEBUG_VERSION), y)
    LITEOS_COPTS_DEBUG  += -DNDEBUG
endif

W
wenjun 已提交
455
ifeq ($(LOSCFG_COMPILE_DEBUG), y)
C
Caoruihong 已提交
456
    LITEOS_COPTS_OPTIMIZE = -O0
W
wenjun 已提交
457
    LITEOS_COPTS_OPTION  = -g -gdwarf-2
C
Caoruihong 已提交
458 459 460 461 462
endif
ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y)
    LITEOS_COPTS_OPTIMIZE = -O2
endif
ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y)
W
wenjun 已提交
463
    ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
464 465 466 467 468 469 470 471
        LITEOS_COPTS_OPTIMIZE = -Oz
    else
        LITEOS_COPTS_OPTIMIZE = -Os
    endif
endif
ifeq ($(LOSCFG_COMPILE_LTO), y)
    ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
        LITEOS_COPTS_OPTIMIZE += -flto=thin
W
wenjun 已提交
472
    else
473
        LITEOS_COPTS_OPTIMIZE += -flto
W
wenjun 已提交
474 475
    endif
endif
C
Caoruihong 已提交
476 477
    LITEOS_COPTS_DEBUG  += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
    LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
W
wenjun 已提交
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
    LITEOS_ASOPTS   += $(LITEOS_COPTS_OPTION)

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
############################# 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)
A
arvinzzz 已提交
510 511
    LIB_SUBDIRS += security
    LITEOS_BASELIB += -lsecurity
W
wenjun 已提交
512
ifeq ($(LOSCFG_SECURITY_CAPABILITY), y)
A
arvinzzz 已提交
513
    LITEOS_SECURITY_CAP_INC := -I $(LITEOSTOPDIR)/security/cap
W
wenjun 已提交
514 515
endif
ifeq ($(LOSCFG_SECURITY_VID), y)
A
arvinzzz 已提交
516
    LITEOS_SECURITY_VID_INC := -I $(LITEOSTOPDIR)/security/vid
W
wenjun 已提交
517 518 519 520 521 522
endif
endif

############################# Security Option End ##############################

LITEOS_EXTKERNEL_INCLUDE   := $(LITEOS_CPPSUPPORT_INCLUDE) $(LITEOS_DYNLOAD_INCLUDE) \
L
LiteOS2021 已提交
523
                              $(LITEOS_TICKLESS_INCLUDE)   $(LITEOS_HOOK_INCLUDE)\
W
wenjun 已提交
524
                              $(LITEOS_VDSO_INCLUDE)       $(LITEOS_LITEIPC_INCLUDE) \
L
LiteOS2021 已提交
525
                              $(LITEOS_PIPE_INCLUDE)       $(LITEOS_CPUP_INCLUDE) \
Z
zhushengle 已提交
526
                              $(LITEOS_PERF_INCLUDE)       $(LITEOS_LMS_INCLUDE) \
Z
zhushengle 已提交
527
                              $(LITEOS_PM_INCLUDE)         $(LITEOS_PLIMITS_INCLUDE)
W
wenjun 已提交
528 529 530 531 532 533 534
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)
C
Caoruihong 已提交
535 536
LITEOS_LIB_INCLUDE         := $(LITEOS_LIBC_INCLUDE)       $(LITEOS_LIBM_INCLUDE) \
                              $(LITEOS_ZLIB_INCLUDE)       $(LITEOS_LIBSCREW_INCLUDE)
W
wenjun 已提交
537 538 539 540
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) \
M
mamingshuai 已提交
541
                              $(LITEOS_MTD_SPI_NOR_INCLUDE) $(LITEOS_MTD_NAND_INCLUDE) \
W
wenjun 已提交
542 543 544 545 546 547
                              $(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) \
M
mamingshuai 已提交
548
                              $(LITEOS_HIEVENT_INCLUDE)    $(LITEOS_DEV_MEM_INCLUDE) \
L
LiteOS2021 已提交
549
                              $(LITEOS_DEV_QUICKSTART_INCLUDE) $(LITEOS_DEV_PERF_INCLUDE)
Q
qidechun 已提交
550
LITEOS_DFX_INCLUDE    := $(LITEOS_HILOG_INCLUDE) \
551 552
                         $(LITEOS_BLACKBOX_INCLUDE) \
                         $(LITEOS_HIDUMPER_INCLUDE)
W
wenjun 已提交
553 554

LITEOS_SECURITY_INCLUDE    := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_INC)
C
Caoruihong 已提交
555
LITEOS_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE)  $(LITEOS_UART_INCLUDE) \
W
wenjun 已提交
556 557
                              $(LITEOS_TELNET_INCLUDE)

558
LITEOS_COMMON_OPTS  := -fno-pic -fno-builtin -nostdinc -nostdlib -Wall -Werror -fms-extensions -fno-omit-frame-pointer -Wno-address-of-packed-member -Winvalid-pch
C
Caoruihong 已提交
559 560 561 562

LITEOS_CXXOPTS_BASE += $(LITEOS_COMMON_OPTS) -std=c++11 -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit -frtti

LITEOS_COPTS_BASE   += $(LITEOS_COMMON_OPTS) $(LITEOS_SSP) -fno-strict-aliasing -fno-common -fsigned-char -mno-unaligned-access
W
wenjun 已提交
563
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
C
Caoruihong 已提交
564
LITEOS_COPTS_BASE   += -fno-aggressive-loop-optimizations
W
wenjun 已提交
565
endif
C
Caoruihong 已提交
566 567

LITEOS_COPTS_EXTRA  += -std=c99 -Wpointer-arith -Wstrict-prototypes -ffunction-sections -fdata-sections -fno-exceptions -fno-short-enums
G
guzhihao4 已提交
568 569
LITEOS_COPTS_EXTRA  += -Wno-strict-prototypes -Wno-deprecated-non-prototype -Wno-unused-but-set-variable

C
Caoruihong 已提交
570
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
W
wenjun 已提交
571
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
C
Caoruihong 已提交
572
LITEOS_COPTS_EXTRA  += -mthumb-interwork
W
wenjun 已提交
573 574
endif
endif
C
Caoruihong 已提交
575

W
wenjun 已提交
576
ifeq ($(LOSCFG_THUMB), y)
577 578
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_CFLAGS_INTERWORK := -mthumb -mimplicit-it=thumb
W
wenjun 已提交
579
else
580 581
LITEOS_CFLAGS_INTERWORK := -mthumb -Wa,-mimplicit-it=thumb
endif
W
wenjun 已提交
582 583
endif

584
# kernel configuration macros
585
LITEOS_CMACRO     += -imacros "$(LITEOS_MENUCONFIG_H)"
586

W
wenjun 已提交
587 588 589 590
ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LITEOS_LD_OPTS += -nostartfiles
endif
LITEOS_LD_OPTS += -static --gc-sections
C
Caoruihong 已提交
591
LITEOS_LD_PATH += -L$(OUT)/lib
W
wenjun 已提交
592 593 594 595 596 597 598

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

C
Caoruihong 已提交
599
##compiler##
C
Caoruihong 已提交
600 601
LITEOS_BASELIB     += $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-libgcc-file-name")
LITEOS_LIB_INCLUDE += -isystem $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-file-name=include")