• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
2# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without modification,
5# are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this list of
8#    conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice, this list
11#    of conditions and the following disclaimer in the documentation and/or other materials
12#    provided with the distribution.
13#
14# 3. Neither the name of the copyright holder nor the names of its contributors may be used
15#    to endorse or promote products derived from this software without specific prior written
16#    permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
31LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
32
33-include $(LITEOS_CONFIG_FILE)
34
35ifeq ($(ARCH),)
36ARCH = $(error ARCH not set!)
37endif
38
39## variable define ##
40HIDE = @
41RM = -rm -rf
42OUT = $(or $(OUTDIR),$(LITEOSTOPDIR)/out/$(LOSCFG_PRODUCT_NAME:"%"=%))
43MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk
44LITEOS_SCRIPTPATH = $(LITEOSTOPDIR)/tools/scripts
45LITEOSTHIRDPARTY = $(LITEOSTOPDIR)/../../third_party
46
47## compiler relative ##
48get_compiler_path = $(or $(wildcard $(1)),$(dir $(shell which $(CROSS_COMPILE)as)))
49ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
50CROSS_COMPILE ?= llvm-
51LITEOS_COMPILER_PATH ?= $(call get_compiler_path,$(LITEOSTOPDIR)/../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/)
52LLVM_TARGET = $(if $(LOSCFG_LLVM_TARGET:"%"=%),--target=$(LOSCFG_LLVM_TARGET:"%"=%),)
53LLVM_SYSROOT = $(if $(SYSROOT_PATH),--sysroot=$(SYSROOT_PATH),)
54CC  = $(LITEOS_COMPILER_PATH)clang $(LLVM_TARGET) $(LLVM_SYSROOT)
55AS  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
56AR  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ar
57LD  = $(LITEOS_COMPILER_PATH)ld.lld
58GPP = $(LITEOS_COMPILER_PATH)clang++ $(LLVM_TARGET) $(LLVM_SYSROOT)
59OBJCOPY = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objcopy -R .bss
60OBJDUMP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objdump
61SIZE = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)size
62NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
63STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
64else ifeq ($(LOSCFG_COMPILER_GCC), y)
65CROSS_COMPILE ?= $(LOSCFG_CROSS_COMPILE:"%"=%)
66LITEOS_COMPILER_PATH ?= $(call get_compiler_path,$(LITEOSTOPDIR)/../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin/)
67CC  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)gcc
68AS  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)as
69AR  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ar
70LD  = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)ld
71GPP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)g++
72OBJCOPY = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objcopy
73OBJDUMP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)objdump
74SIZE = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)size
75NM = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)nm
76STRIP = $(LITEOS_COMPILER_PATH)$(CROSS_COMPILE)strip
77else
78CC  = echo $(info compiler type not set!)
79endif
80
81## c as cxx ld options ##
82LITEOS_ASOPTS :=
83LITEOS_COPTS_BASE :=
84LITEOS_COPTS_EXTRA :=
85LITEOS_COPTS_DEBUG :=
86LITEOS_CXXOPTS :=
87LITEOS_CXXOPTS_BASE :=
88LITEOS_LD_OPTS :=
89LITEOS_GCOV_OPTS :=
90## macro define ##
91LITEOS_CMACRO := -D__LITEOS__
92LITEOS_CXXMACRO :=
93## head file path and ld path ##
94LITEOS_PLATFORM_INCLUDE :=
95LITEOS_CXXINCLUDE :=
96LITEOS_LD_PATH :=
97LITEOS_LD_SCRIPT :=
98## c as cxx ld flags ##
99LITEOS_ASFLAGS :=
100LITEOS_CFLAGS :=
101LITEOS_LDFLAGS :=
102LITEOS_CXXFLAGS :=
103## depended lib ##
104LITEOS_BASELIB :=
105LITEOS_LIBDEP :=
106## directory ##
107LIB_SUBDIRS :=
108
109####################################### CPU Option Begin #########################################
110include $(LITEOSTOPDIR)/arch/cpu.mk
111####################################### CPU Option End #########################################
112
113############################# Platform Option Begin#################################
114include $(LITEOSTOPDIR)/platform/bsp.mk
115############################# Platform Option End #################################
116
117####################################### Kernel Option Begin ###########################################
118LITEOS_BASELIB += -lbase
119LIB_SUBDIRS       += kernel/base
120LITEOS_KERNEL_INCLUDE   := -I $(LITEOSTOPDIR)/kernel/include \
121                           -I $(LITEOSTOPDIR)/kernel/base/include
122
123LITEOS_BASELIB += -lcommon
124LIB_SUBDIRS       += kernel/common
125LITEOS_KERNEL_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/common
126
127ifeq ($(LOSCFG_KERNEL_CPPSUPPORT), y)
128    LITEOS_BASELIB += -lcppsupport
129    LIB_SUBDIRS       += kernel/extended/cppsupport
130    LITEOS_CPPSUPPORT_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/cppsupport
131endif
132
133ifeq ($(LOSCFG_KERNEL_CPUP), y)
134    LITEOS_BASELIB   += -lcpup
135    LIB_SUBDIRS         += kernel/extended/cpup
136    LITEOS_CPUP_INCLUDE := -I $(LITEOSTOPDIR)/kernel/extended/cpup
137endif
138
139ifeq ($(LOSCFG_KERNEL_DYNLOAD), y)
140    LITEOS_BASELIB   += -ldynload
141    LIB_SUBDIRS      += kernel/extended/dynload
142    LITEOS_DYNLOAD_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/dynload/include
143endif
144
145ifeq ($(LOSCFG_KERNEL_VDSO), y)
146    LITEOS_BASELIB   += -lvdso
147    LIB_SUBDIRS      += kernel/extended/vdso/usr
148    LIB_SUBDIRS      += kernel/extended/vdso/src
149    LITEOS_VDSO_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/vdso/include
150endif
151
152ifeq ($(LOSCFG_KERNEL_TRACE), y)
153    LITEOS_BASELIB    += -ltrace
154    LIB_SUBDIRS       += kernel/extended/trace
155endif
156
157ifeq ($(LOSCFG_KERNEL_HOOK), y)
158    LITEOS_BASELIB += -lhook
159    LIB_SUBDIRS       += kernel/extended/hook
160    LITEOS_HOOK_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/hook/include
161endif
162
163ifeq ($(LOSCFG_KERNEL_PERF), y)
164    LITEOS_BASELIB        += -lperf
165    LIB_SUBDIRS           += kernel/extended/perf
166    LITEOS_PERF_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/perf
167endif
168
169ifeq ($(LOSCFG_KERNEL_LMS), y)
170    LITEOS_BASELIB        += -llms
171    LIB_SUBDIRS           += kernel/extended/lms
172    LITEOS_LMS_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/lms
173endif
174
175ifeq ($(LOSCFG_KERNEL_LITEIPC), y)
176    LITEOS_BASELIB     += -lliteipc
177    LIB_SUBDIRS           += kernel/extended/liteipc
178    LITEOS_LITEIPC_INCLUDE   += -I $(LITEOSTOPDIR)/kernel/extended/liteipc
179endif
180
181ifeq ($(LOSCFG_KERNEL_PIPE), y)
182    LITEOS_BASELIB     += -lpipes
183    LIB_SUBDIRS           += kernel/extended/pipes
184    LITEOS_PIPE_INCLUDE   += -I $(LITEOSTOPDIR)/../../third_party/NuttX/drivers/pipes
185endif
186
187ifeq ($(LOSCFG_KERNEL_PM), y)
188    LITEOS_BASELIB        += -lpower
189    LIB_SUBDIRS           += kernel/extended/power
190    LITEOS_PM_INCLUDE      = -I $(LITEOSTOPDIR)/kernel/extended/power
191endif
192
193ifeq ($(LOSCFG_KERNEL_SYSCALL), y)
194    LITEOS_BASELIB += -lsyscall
195    LIB_SUBDIRS += syscall
196endif
197
198ifeq ($(LOSCFG_KERNEL_PLIMITS), y)
199    LITEOS_BASELIB        += -lplimit
200    LIB_SUBDIRS           += kernel/extended/plimit
201    LITEOS_PLIMITS_INCLUDE = -I $(LITEOSTOPDIR)/kernel/extended/plimit
202endif
203
204LIB_SUBDIRS += kernel/user
205
206################################### Kernel Option End ################################
207
208#################################### Lib Option Begin ###############################
209LITEOS_BASELIB   += -lscrew
210LIB_SUBDIRS         += lib/libscrew
211LITEOS_LIBSCREW_INCLUDE += -I $(LITEOSTOPDIR)/lib/libscrew/include
212
213ifeq ($(LOSCFG_LIB_LIBC), y)
214    LIB_SUBDIRS           += lib/libc/musl
215    LITEOS_BASELIB        += -lc
216    LITEOS_LIBC_INCLUDE   += \
217        -isystem $(LITEOSTHIRDPARTY)/musl/porting/liteos_a/kernel/include
218
219    LIB_SUBDIRS           += lib/libsec
220    LITEOS_BASELIB        += -lsec
221    LITEOS_LIBC_INCLUDE   += \
222        -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
223    LITEOS_CMACRO         += -DSECUREC_IN_KERNEL=0
224endif
225
226ifeq ($(LOSCFG_LIB_ZLIB), y)
227    LITEOS_BASELIB += -lz
228    LIB_SUBDIRS    += lib/zlib
229    LITEOS_ZLIB_INCLUDE += -I $(LITEOSTHIRDPARTY)/zlib
230endif
231################################### Lib Option End ######################################
232
233####################################### Compat Option Begin #########################################
234ifeq ($(LOSCFG_COMPAT_POSIX), y)
235    LITEOS_BASELIB += -lposix
236    LIB_SUBDIRS       += compat/posix
237    LITEOS_POSIX_INCLUDE   += \
238        -I $(LITEOSTOPDIR)/compat/posix/include
239endif
240
241ifeq ($(LOSCFG_COMPAT_BSD), y)
242    LITEOS_BASELIB += -lbsd
243    LIB_SUBDIRS    += bsd
244    LITEOS_BSD_INCLUDE   += -I $(LITEOSTOPDIR)/bsd
245    LITEOS_BASELIB += -llinuxkpi
246    LIB_SUBDIRS       += bsd/compat/linuxkpi
247    LITEOS_LINUX_INCLUDE += -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include \
248                            -I $(LITEOSTOPDIR)/bsd \
249                            -I $(LITEOSTOPDIR)/bsd/kern
250endif
251######################################## Compat Option End ############################################
252
253
254#################################### FS Option Begin ##################################
255ifeq ($(LOSCFG_FS_VFS), y)
256    LITEOS_BASELIB += -lvfs -lmulti_partition
257ifeq ($(LOSCFG_FS_VFS_BLOCK_DEVICE), y)
258    LITEOS_BASELIB += -lbch
259    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/bch
260endif
261    LIB_SUBDIRS       += fs/vfs drivers/mtd/multi_partition
262    LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/include \
263                            -I $(LITEOSTOPDIR)/fs/vfs/include
264    LITEOS_VFS_INCLUDE   += -I $(LITEOSTOPDIR)/fs/vfs/include/operation
265    LITEOS_VFS_MTD_INCLUDE := -I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include
266endif
267
268ifeq ($(LOSCFG_FS_FAT), y)
269    LITEOS_BASELIB  += -lfat
270    LIB_SUBDIRS     += fs/fat
271    LITEOS_FAT_INCLUDE += -I $(LITEOSTHIRDPARTY)/FatFs/source
272endif
273
274ifeq ($(LOSCFG_FS_FAT_VIRTUAL_PARTITION), y)
275    LITEOS_BASELIB += -lvirpart
276    LIB_SUBDIRS += fs/fat/virpart
277    LITEOS_FAT_VIRPART_INCLUDE += -I $(LITEOSTOPDIR)/fs/fat/virpart/include
278endif
279
280ifeq ($(LOSCFG_FS_FAT_DISK), y)
281    LITEOS_BASELIB += -ldisk
282    LIB_SUBDIRS += $(LITEOSTOPDIR)/drivers/block/disk
283    LITEOS_VFS_DISK_INCLUDE := -I $(LITEOSTOPDIR)/drivers/block/disk/include
284endif
285
286ifeq ($(LOSCFG_FS_FAT_CACHE), y)
287    LITEOS_BASELIB  += -lbcache
288    LIB_SUBDIRS     += fs/vfs/bcache
289    LITEOS_FAT_CACHE_INCLUDE += -I $(LITEOSTOPDIR)/fs/vfs/include/bcache
290endif
291
292
293ifeq ($(LOSCFG_FS_RAMFS), y)
294    LITEOS_BASELIB  += -lramfs
295    LIB_SUBDIRS     += fs/ramfs
296endif
297
298ifeq ($(LOSCFG_FS_ROMFS), y)
299    LITEOS_BASELIB  += -lromfs
300    LIB_SUBDIRS     += fs/romfs
301endif
302
303ifeq ($(LOSCFG_FS_NFS), y)
304    LITEOS_BASELIB  += -lnfs
305    LIB_SUBDIRS     += fs/nfs
306endif
307
308ifeq ($(LOSCFG_FS_PROC), y)
309    LITEOS_BASELIB  += -lproc
310    LIB_SUBDIRS     += fs/proc
311    LITEOS_PROC_INCLUDE += -I $(LITEOSTOPDIR)/fs/proc/include
312endif
313
314
315ifeq ($(LOSCFG_FS_JFFS), y)
316#    LITEOS_BASELIB  += -ljffs2
317#    LIB_SUBDIRS     += fs/jffs2
318endif
319
320ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
321    LITEOS_BASELIB  += -lrootfs
322    LIB_SUBDIRS     += fs/rootfs
323    LITEOS_PLATFORM_INCLUDE     += -I $(LITEOSTOPDIR)/fs/rootfs
324endif
325
326ifeq ($(LOSCFG_PLATFORM_PATCHFS), y)
327    LITEOS_BASELIB  += -lpatchfs
328    LIB_SUBDIRS     += fs/patchfs
329endif
330
331ifeq ($(LOSCFG_FS_ZPFS), y)
332    LITEOS_BASELIB  += -lzpfs
333    LIB_SUBDIRS     += fs/zpfs
334endif
335#################################### FS Option End ##################################
336
337
338################################### Net Option Begin ###################################
339ifeq ($(LOSCFG_NET_LWIP_SACK), y)
340ifeq ($(LOSCFG_NET_LWIP_SACK_2_1), y)
341    LWIPDIR := $(LITEOSTHIRDPARTY)/lwip/src
342    LITEOS_BASELIB += -llwip
343    LIB_SUBDIRS       += net/lwip-2.1
344    LITEOS_LWIP_SACK_INCLUDE   += \
345        -I $(LITEOSTOPDIR)/net/lwip-2.1/porting/include \
346        -I $(LWIPDIR)/include \
347        -I $(LITEOSTOPDIR)/net/mac
348else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y)
349    LWIPDIR := $(LITEOSTHIRDPARTY)/lwip_enhanced/src
350    LITEOS_BASELIB += -llwip
351    LIB_SUBDIRS       += $(LWIPDIR)
352    LITEOS_LWIP_SACK_INCLUDE   += \
353        -I $(LWIPDIR)/include \
354        -I $(LITEOSTOPDIR)/net/mac
355    LITEOS_CMACRO += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT
356else
357    $(error "unknown lwip version")
358endif
359endif
360
361#################################### Net Option End####################################
362LITEOS_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../drivers/liteos
363################################## Driver Option Begin #################################
364ifeq ($(LOSCFG_DRIVERS_HDF), y)
365include $(LITEOSTOPDIR)/../../drivers/hdf_core/adapter/khdf/liteos/hdf_lite.mk
366endif
367
368ifeq ($(LOSCFG_DRIVERS_HIEVENT), y)
369    LITEOS_BASELIB     += -lhievent
370    LIB_SUBDIRS           += $(LITEOS_DRIVERS_BASE_PATH)/hievent
371    LITEOS_HIEVENT_INCLUDE   += -I $(LITEOS_DRIVERS_BASE_PATH)/hievent/include
372endif
373
374ifeq ($(LOSCFG_DRIVERS_TZDRIVER), y)
375    LITEOS_BASELIB   += -ltzdriver -lmbedtls
376    LIB_SUBDIRS         += $(LITEOS_DRIVERS_BASE_PATH)/tzdriver  $(LITEOSTOPDIR)/lib/libmbedtls
377    LITEOS_TZDRIVER_INCLUDE += -I $(LITEOS_DRIVERS_BASE_PATH)/tzdriver/include
378endif
379
380ifeq ($(LOSCFG_DRIVERS_MEM), y)
381    LITEOS_BASELIB += -lmem
382    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/mem
383    LITEOS_DEV_MEM_INCLUDE = -I $(LITEOSTOPDIR)/drivers/char/mem/include
384endif
385
386ifeq ($(LOSCFG_DRIVERS_TRACE), y)
387    LITEOS_BASELIB += -ltrace_dev
388    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/trace
389endif
390
391ifeq ($(LOSCFG_DRIVERS_PERF), y)
392    LITEOS_BASELIB            += -lperf_dev
393    LIB_SUBDIRS               += $(LITEOSTOPDIR)/drivers/char/perf
394    LITEOS_DEV_PERF_INCLUDE   += -I $(LITEOSTOPDIR)/drivers/char/perf/include
395endif
396
397ifeq ($(LOSCFG_DRIVERS_QUICKSTART), y)
398    LITEOS_BASELIB += -lquickstart
399    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/quickstart
400    LITEOS_DEV_QUICKSTART_INCLUDE = -I $(LITEOSTOPDIR)/drivers/char/quickstart/include
401endif
402
403ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
404    LITEOS_BASELIB += -lrandom
405    LIB_SUBDIRS    += $(LITEOSTOPDIR)/drivers/char/random
406    LITEOS_RANDOM_INCLUDE += -I $(LITEOSTOPDIR)/drivers/char/random/include
407endif
408
409ifeq ($(LOSCFG_DRIVERS_USB), y)
410    LITEOS_BASELIB  += -lusb_base
411    LIB_SUBDIRS     += $(LITEOSTOPDIR)/bsd/dev/usb
412    LITEOS_USB_INCLUDE += -I $(LITEOSTOPDIR)/bsd/dev/usb
413    LITEOS_CMACRO   += -DUSB_DEBUG_VAR=5
414endif
415
416ifeq ($(LOSCFG_DRIVERS_VIDEO), y)
417    LITEOS_BASELIB += -lvideo
418    LIB_SUBDIRS       += $(LITEOSTOPDIR)/drivers/char/video
419    LITEOS_VIDEO_INCLUDE += -I $(LITEOSTHIRDPARTY)/NuttX/include/nuttx/video
420endif
421
422############################## Driver Option End #######################################
423
424############################## Dfx Option Begin#######################################
425ifeq ($(LOSCFG_BASE_CORE_HILOG), y)
426    LITEOS_BASELIB      += -lhilog
427    LIB_SUBDIRS         += $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/frameworks/featured
428    LIB_SUBDIRS         += $(LITEOSTOPDIR)/kernel/extended/hilog
429    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/interfaces/native/kits
430    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/../../base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog
431    LITEOS_HILOG_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/hilog
432endif
433ifeq ($(LOSCFG_BLACKBOX), y)
434    LITEOS_BASELIB     += -lblackbox
435    LIB_SUBDIRS           += $(LITEOSTOPDIR)/kernel/extended/blackbox
436    LITEOS_BLACKBOX_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/blackbox
437endif
438ifeq ($(LOSCFG_HIDUMPER), y)
439    LITEOS_BASELIB     += -lhidumper
440    LIB_SUBDIRS           += $(LITEOSTOPDIR)/kernel/extended/hidumper
441    LITEOS_HIDUMPER_INCLUDE  += -I $(LITEOSTOPDIR)/kernel/extended/hidumper
442endif
443############################## Dfx Option End #######################################
444
445############################# Tools && Debug Option Begin ##############################
446ifeq ($(LOSCFG_COMPRESS), y)
447    LITEOS_BASELIB    += -lcompress
448    LIB_SUBDIRS       += tools/compress
449endif
450
451ifneq ($(LOSCFG_DEBUG_VERSION), y)
452    LITEOS_COPTS_DEBUG  += -DNDEBUG
453endif
454
455ifeq ($(LOSCFG_COMPILE_DEBUG), y)
456    LITEOS_COPTS_OPTIMIZE = -O0
457    LITEOS_COPTS_OPTION  = -g -gdwarf-2
458endif
459ifeq ($(LOSCFG_COMPILE_OPTIMIZE), y)
460    LITEOS_COPTS_OPTIMIZE = -O2
461endif
462ifeq ($(LOSCFG_COMPILE_OPTIMIZE_SIZE), y)
463    ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
464        LITEOS_COPTS_OPTIMIZE = -Oz
465    else
466        LITEOS_COPTS_OPTIMIZE = -Os
467    endif
468endif
469ifeq ($(LOSCFG_COMPILE_LTO), y)
470    ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
471        LITEOS_COPTS_OPTIMIZE += -flto=thin
472    else
473        LITEOS_COPTS_OPTIMIZE += -flto
474    endif
475endif
476    LITEOS_COPTS_DEBUG  += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
477    LITEOS_CXXOPTS_BASE += $(LITEOS_COPTS_OPTION) $(LITEOS_COPTS_OPTIMIZE)
478    LITEOS_ASOPTS   += $(LITEOS_COPTS_OPTION)
479
480ifeq ($(LOSCFG_SHELL), y)
481    LITEOS_BASELIB += -lshell
482    LIB_SUBDIRS       += shell
483    LITEOS_SHELL_INCLUDE  += -I $(LITEOSTOPDIR)/shell/full/include
484endif
485
486
487ifeq ($(LOSCFG_NET_TELNET), y)
488    LITEOS_BASELIB += -ltelnet
489    LIB_SUBDIRS       += net/telnet
490    LITEOS_TELNET_INCLUDE   += \
491        -I $(LITEOSTOPDIR)/net/telnet/include
492endif
493############################# Tools && Debug Option End #################################
494
495############################# Security Option Begin ##############################
496LITEOS_SSP = -fno-stack-protector
497ifeq ($(LOSCFG_CC_STACKPROTECTOR), y)
498    LITEOS_SSP = -fstack-protector --param ssp-buffer-size=4
499endif
500
501ifeq ($(LOSCFG_CC_STACKPROTECTOR_STRONG), y)
502    LITEOS_SSP = -fstack-protector-strong
503endif
504
505ifeq ($(LOSCFG_CC_STACKPROTECTOR_ALL), y)
506    LITEOS_SSP = -fstack-protector-all
507endif
508
509ifeq ($(LOSCFG_SECURITY), y)
510    LIB_SUBDIRS += security
511    LITEOS_BASELIB += -lsecurity
512ifeq ($(LOSCFG_SECURITY_CAPABILITY), y)
513    LITEOS_SECURITY_CAP_INC := -I $(LITEOSTOPDIR)/security/cap
514endif
515ifeq ($(LOSCFG_SECURITY_VID), y)
516    LITEOS_SECURITY_VID_INC := -I $(LITEOSTOPDIR)/security/vid
517endif
518endif
519
520############################# Security Option End ##############################
521
522LITEOS_EXTKERNEL_INCLUDE   := $(LITEOS_CPPSUPPORT_INCLUDE) $(LITEOS_DYNLOAD_INCLUDE) \
523                              $(LITEOS_TICKLESS_INCLUDE)   $(LITEOS_HOOK_INCLUDE)\
524                              $(LITEOS_VDSO_INCLUDE)       $(LITEOS_LITEIPC_INCLUDE) \
525                              $(LITEOS_PIPE_INCLUDE)       $(LITEOS_CPUP_INCLUDE) \
526                              $(LITEOS_PERF_INCLUDE)       $(LITEOS_LMS_INCLUDE) \
527                              $(LITEOS_PM_INCLUDE)         $(LITEOS_PLIMITS_INCLUDE)
528LITEOS_COMPAT_INCLUDE      := $(LITEOS_POSIX_INCLUDE) $(LITEOS_LINUX_INCLUDE) \
529                              $(LITEOS_BSD_INCLUDE)
530LITEOS_FS_INCLUDE          := $(LITEOS_VFS_INCLUDE)        $(LITEOS_FAT_CACHE_INCLUDE) \
531                              $(LITEOS_VFS_MTD_INCLUDE)    $(LITEOS_VFS_DISK_INCLUDE) \
532                              $(LITEOS_PROC_INCLUDE)       $(LITEOS_FAT_VIRPART_INCLUDE) \
533                              $(LITEOS_FAT_INCLUDE)
534LITEOS_NET_INCLUDE         := $(LITEOS_LWIP_SACK_INCLUDE)
535LITEOS_LIB_INCLUDE         := $(LITEOS_LIBC_INCLUDE)       $(LITEOS_LIBM_INCLUDE) \
536                              $(LITEOS_ZLIB_INCLUDE)       $(LITEOS_LIBSCREW_INCLUDE)
537LITEOS_DRIVERS_INCLUDE     := $(LITEOS_CELLWISE_INCLUDE)   $(LITEOS_GPIO_INCLUDE) \
538                              $(LITEOS_HIDMAC_INCLUDE)     $(LITEOS_HIETH_SF_INCLUDE) \
539                              $(LITEOS_HIGMAC_INCLUDE)     $(LITEOS_I2C_INCLUDE) \
540                              $(LITEOS_LCD_INCLUDE)        $(LITEOS_MMC_INCLUDE) \
541                              $(LITEOS_MTD_SPI_NOR_INCLUDE) $(LITEOS_MTD_NAND_INCLUDE) \
542                              $(LITEOS_RANDOM_INCLUDE)     $(LITEOS_RTC_INCLUDE) \
543                              $(LITEOS_SPI_INCLUDE)        $(LITEOS_USB_INCLUDE) \
544                              $(LITEOS_WTDG_INCLUDE)       $(LITEOS_DBASE_INCLUDE) \
545                              $(LITEOS_CPUFREQ_INCLUDE)    $(LITEOS_DEVFREQ_INCLUDE) \
546                              $(LITEOS_REGULATOR_INCLUDE)  $(LITEOS_VIDEO_INCLUDE) \
547                              $(LITEOS_DRIVERS_HDF_INCLUDE) $(LITEOS_TZDRIVER_INCLUDE) \
548                              $(LITEOS_HIEVENT_INCLUDE)    $(LITEOS_DEV_MEM_INCLUDE) \
549                              $(LITEOS_DEV_QUICKSTART_INCLUDE) $(LITEOS_DEV_PERF_INCLUDE)
550LITEOS_DFX_INCLUDE    := $(LITEOS_HILOG_INCLUDE) \
551                         $(LITEOS_BLACKBOX_INCLUDE) \
552                         $(LITEOS_HIDUMPER_INCLUDE)
553
554LITEOS_SECURITY_INCLUDE    := $(LITEOS_SECURITY_CAP_INC) $(LITEOS_SECURITY_VID_INC)
555LITEOS_TOOLS_DEBUG_INCLUDE := $(LITEOS_SHELL_INCLUDE)  $(LITEOS_UART_INCLUDE) \
556                              $(LITEOS_TELNET_INCLUDE)
557
558LITEOS_COMMON_OPTS  := -fno-pic -fno-builtin -nostdinc -nostdlib -Wall -Werror -fms-extensions -fno-omit-frame-pointer -Wno-address-of-packed-member -Winvalid-pch
559
560LITEOS_CXXOPTS_BASE += $(LITEOS_COMMON_OPTS) -std=c++11 -nostdinc++ -fexceptions -fpermissive -fno-use-cxa-atexit -frtti
561
562LITEOS_COPTS_BASE   += $(LITEOS_COMMON_OPTS) $(LITEOS_SSP) -fno-strict-aliasing -fno-common -fsigned-char -mno-unaligned-access
563ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
564LITEOS_COPTS_BASE   += -fno-aggressive-loop-optimizations
565endif
566
567LITEOS_COPTS_EXTRA  += -std=c99 -Wpointer-arith -Wstrict-prototypes -ffunction-sections -fdata-sections -fno-exceptions -fno-short-enums
568LITEOS_COPTS_EXTRA  += -Wno-strict-prototypes -Wno-deprecated-non-prototype -Wno-unused-but-set-variable
569
570ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
571ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
572LITEOS_COPTS_EXTRA  += -mthumb-interwork
573endif
574endif
575
576ifeq ($(LOSCFG_THUMB), y)
577ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
578LITEOS_CFLAGS_INTERWORK := -mthumb -mimplicit-it=thumb
579else
580LITEOS_CFLAGS_INTERWORK := -mthumb -Wa,-mimplicit-it=thumb
581endif
582endif
583
584# kernel configuration macros
585LITEOS_CMACRO     += -imacros "$(LITEOS_MENUCONFIG_H)"
586
587ifneq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
588LITEOS_LD_OPTS += -nostartfiles
589endif
590LITEOS_LD_OPTS += -static --gc-sections
591LITEOS_LD_PATH += -L$(OUT)/lib
592
593ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
594LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos_llvm.ld
595else
596LITEOS_LD_SCRIPT := -T$(LITEOSTOPDIR)/tools/build/liteos.ld
597endif
598
599##compiler##
600LITEOS_BASELIB     += $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-libgcc-file-name")
601LITEOS_LIB_INCLUDE += -isystem $(shell $(CC) $(LITEOS_CORE_COPTS) "-print-file-name=include")
602