blob: 9e1e2be999e405e99ba8f634f3f68bdb5bbcab4d [file] [log] [blame]
Travis Geiselbrecht78d0e6c2009-11-27 13:37:03 -08001ifeq ($(MAKECMDGOALS),spotless)
2spotless:
3 rm -rf build-*
4else
5
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07006-include local.mk
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -08007include make/macros.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07008
Brian Swetlandf1e5afd2009-01-24 22:09:30 -08009# If one of our goals (from the commandline) happens to have a
10# matching project/goal.mk, then we should re-invoke make with
11# that project name specified...
12
13project-name := $(firstword $(MAKECMDGOALS))
14
15ifneq ($(project-name),)
16ifneq ($(wildcard project/$(project-name).mk),)
17do-nothing := 1
18$(MAKECMDGOALS) _all: make-make
19make-make:
20 @PROJECT=$(project-name) $(MAKE) $(filter-out $(project-name), $(MAKECMDGOALS))
21endif
22endif
23
24ifeq ($(do-nothing),)
25
26ifeq ($(PROJECT),)
27$(error No project specified. Use "make projectname" or put "PROJECT := projectname" in local.mk)
28endif
29
Chandan Uddaraju40b227d2010-08-03 19:25:41 -070030DEBUG ?= 0
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070031
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -080032ifndef $(BOOTLOADER_OUT)
33BOOTLOADER_OUT := .
34endif
35
Chandan Uddaraju885e4db2009-12-03 22:45:26 -080036LK_TOP_DIR:= .
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -080037BUILDDIR := $(BOOTLOADER_OUT)/build-$(PROJECT)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070038OUTBIN := $(BUILDDIR)/lk.bin
39OUTELF := $(BUILDDIR)/lk
Channagoud Kadabi02072a42014-02-28 19:15:40 -080040OUTELF_STRIP := $(BUILDDIR)/lk_s.elf
41
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070042CONFIGHEADER := $(BUILDDIR)/config.h
43
Subbaraman Narayanamurthy8bcd5fd2011-01-17 17:18:44 -080044#Initialize the command-line flag ENABLE_TRUSTZONE. Value for flag passed in at command-line will take precedence
45ENABLE_TRUSTZONE := 0
46
47ifeq ($(ENABLE_TRUSTZONE),1)
48 INPUT_TZ_BIN := tzbsp/tzbsp.bin
49 OUTPUT_TZ_BIN := $(BUILDDIR)/tzbsp_bin.o
50endif
51
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070052INCLUDES := -I$(BUILDDIR) -Iinclude
S A Muqthyard8d0ed02018-03-14 13:13:59 +053053CFLAGS := -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function $(LKLE_CFLAGS) -include $(CONFIGHEADER)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070054#CFLAGS += -Werror
David Ng025c1d92009-12-09 23:46:00 -080055ifeq ($(EMMC_BOOT),1)
56 CFLAGS += -D_EMMC_BOOT=1
57endif
Shashank Mittalcd98d472011-08-02 14:29:24 -070058
59ifeq ($(SIGNED_KERNEL),1)
60 CFLAGS += -D_SIGNED_KERNEL=1
61endif
62
jessicatseng8db2f602020-05-06 19:02:18 +080063#//<2020/05/06-JessicaTseng, Enable fastboot command in user build
64#ifeq ($(TARGET_BUILD_VARIANT),user)
65# CFLAGS += -DDISABLE_FASTBOOT_CMDS=1
66#endif
67#//>2020/05/06-JessicaTseng
Sridhar Parasurame94e8152014-10-24 14:06:03 -070068
anisha agarwalebc52bc2016-07-08 15:50:00 -070069ifeq ($(APPEND_CMDLINE),1)
70 CFLAGS += -D_APPEND_CMDLINE=1
71endif
Himal Ghimirayc5d81212017-04-28 14:06:04 +053072ifeq ($(ENABLE_HARD_FPU),1)
73 CFLAGS += -mfloat-abi=hard -mfpu=neon
74endif
Sachin Prakash Gejjif557d222017-08-04 17:18:45 +053075
76ifeq ($(ENABLE_EARLY_ETHERNET),1)
77 CFLAGS += -DENABLE_EARLY_ETHERNET=1
78endif
79
jhchen7a504d12020-04-24 15:45:57 +080080# [Arima_8910][jhchen] add fuse check property 20181031 begin
81CFLAGS += -DENABLE_FUSE_CHECK=1
82# [Arima_8910][jhchen] 20181031 end
83
tracychuid184b912020-06-05 17:31:38 +080084#[20200605][TracyChui] Implement get Serial Number start
85CFLAGS += -DENABLE_PRODINFO_ACCESS=1
86#[20200605][TracyChui] Implement get Serial Number end
87
tracychui5cfe4432020-09-21 16:15:16 +080088#[TracyChui] Disable lock/unlock commend on user mode 20200921 start
tracychui8fd71dc2020-06-11 10:17:13 +080089#[TracyChui] Add lock unlock fastboot commnad to skip ui check 20200611 start
tracychui5cfe4432020-09-21 16:15:16 +080090ifneq ($(TARGET_BUILD_VARIANT),user)
tracychui8fd71dc2020-06-11 10:17:13 +080091CFLAGS += -DENABLE_LOCK_UNLOCK_SKIP_UI_CHECK=1
tracychui5cfe4432020-09-21 16:15:16 +080092endif
tracychui8fd71dc2020-06-11 10:17:13 +080093#[TracyChui] Add lock unlock fastboot commnad to skip ui check 20200611 end
tracychui5cfe4432020-09-21 16:15:16 +080094#[TracyChui] Disable lock/unlock commend on user mode 20200921 end
tracychui8fd71dc2020-06-11 10:17:13 +080095
Channagoud Kadabi02072a42014-02-28 19:15:40 -080096# setup toolchain prefix
97TOOLCHAIN_PREFIX ?= arm-eabi-
Maria Yud3200512014-05-28 15:57:51 +080098CFLAGS += -fstack-protector-all
vijay kumarc2119f12014-07-22 18:30:11 +053099CFLAGS += -fno-strict-overflow
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700100CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
101#CPPFLAGS += -Weffc++
102ASMFLAGS := -DASSEMBLY
103LDFLAGS :=
104
105CFLAGS += -ffunction-sections -fdata-sections
106LDFLAGS += -gc-sections
107
108# top level rule
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800109all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size $(OUTELF_STRIP) APPSBOOTHEADER
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700110
111# the following three object lists are identical except for the ordering
112# which is bootobjs, kobjs, objs
113BOOTOBJS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700114OBJS :=
115
116# a linker script needs to be declared in one of the project/target/platform files
117LINKER_SCRIPT :=
118
119# anything you add here will be deleted in make clean
120GENERATED := $(CONFIGHEADER)
121
122# anything added to DEFINES will be put into $(BUILDDIR)/config.h
123DEFINES := LK=1
124
125# Anything added to SRCDEPS will become a dependency of every source file in the system.
126# Useful for header files that may be included by one or more source files.
127SRCDEPS := $(CONFIGHEADER)
128
Shashank Mittale99a8d32014-09-11 19:51:06 -0700129ifeq ($(VERIFIED_BOOT),1)
130 DEFINES += VERIFIED_BOOT=1
131 DEFINES += _SIGNED_KERNEL=1
132 ifeq ($(DEFAULT_UNLOCK),true)
133 DEFINES += DEFAULT_UNLOCK=1
134 endif
135endif
136
AnilKumar Chimata46864322017-08-10 14:51:25 +0530137ifeq ($(VERIFIED_BOOT_LE),1)
138 DEFINES += VERIFIED_BOOT_LE=1
139 ifeq ($(DEFAULT_UNLOCK),true)
140 DEFINES += DEFAULT_UNLOCK=1
141 endif
142endif
Monika Singhae7e9642018-03-08 17:44:30 +0530143ifeq ($(VERIFIED_BOOT_2),1)
144 DEFINES += VERIFIED_BOOT_2=1
145 DEFINES += _SIGNED_KERNEL=1
146endif
AnilKumar Chimata46864322017-08-10 14:51:25 +0530147
Monika Singh4d659d22019-12-05 16:38:04 +0530148ifeq ($(VB1_KEY_USED),1)
149 DEFINES += VB1_KEY_USED=1
150endif
151
Mayank Groverc8a46c42019-04-25 11:46:00 +0530152ifeq ($(DYNAMIC_PARTITION_SUPPORT),1)
153 DEFINES += DYNAMIC_PARTITION_SUPPORT=1
154endif
155
Jiten Patel3f6e7012018-08-22 12:46:20 +0530156ifeq ($(TARGET_DTBO_NOT_SUPPORTED),1)
157 DEFINES += TARGET_DTBO_NOT_SUPPORTED=1
158endif
159
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530160ifeq ($(OSVERSION_IN_BOOTIMAGE),1)
161 DEFINES += OSVERSION_IN_BOOTIMAGE=1
162endif
163
Mayank Grover02b160c2018-05-15 14:52:18 +0530164ifeq ($(HIBERNATION_SUPPORT),1)
165DEFINES += HIBERNATION_SUPPORT=1
166endif
167
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530168ifeq ($(ENABLE_VB_ATTEST),1)
169 DEFINES += ENABLE_VB_ATTEST=1
170endif
171
Channagoud Kadabi9071af32015-03-12 12:39:56 -0700172ifeq ($(USER_BUILD_VARIANT),true)
173 DEFINES += USER_BUILD_VARIANT=1
174endif
175
Hareesh Gautham49c6a612017-04-21 15:54:27 +0530176ifeq ($(USE_LE_SYSTEMD),true)
177 DEFINES += USE_LE_SYSTEMD=1
178else
179 DEFINES += USE_LE_SYSTEMD=0
180endif
181
zhaochen3e3b52f2018-02-06 19:25:27 +0800182ifeq ($(MOUNT_EMMC_LE),true)
183 DEFINES += MOUNT_EMMC_LE=1
184else
185 DEFINES += MOUNT_EMMC_LE=0
186endif
187
lijuangc43b2cb2017-12-07 14:45:23 +0800188#Enable kaslr seed support
189ifeq ($(ENABLE_KASLRSEED),1)
190 DEFINES += ENABLE_KASLRSEED_SUPPORT=1
191else
192 DEFINES += ENABLE_KASLRSEED_SUPPORT=0
193endif
194
Mayank Grover44180df2018-05-09 12:13:12 +0530195ifeq ($(TARGET_USE_SYSTEM_AS_ROOT_IMAGE),1)
196 DEFINES += TARGET_USE_SYSTEM_AS_ROOT_IMAGE=1
197else
198 DEFINES += TARGET_USE_SYSTEM_AS_ROOT_IMAGE=0
199endif
200
tracychuid184b912020-06-05 17:31:38 +0800201#[20200605][TracyChui]Show SW and modem version and internal storage size on fastboot screen start
tracychui5cfe4432020-09-21 16:15:16 +0800202DEFINES += ARIMA_BOOTLOADER_VERSION=\"8901.3.val.0001-SS.20200819\"
203DEFINES += ARIMA_BASEBAND_VERSION=\"MPSS.TA.3.1.c1-00021-8953_GEN_PACK-2\"
tracychuid184b912020-06-05 17:31:38 +0800204#[20200605][TracyChui]Show SW and modem version and internal storage size on fastboot screen end
205
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700206# these need to be filled out by the project/target/platform rules.mk files
207TARGET :=
208PLATFORM :=
209ARCH :=
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700210ALLMODULES :=
211MODULES :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700212
213# any rules you put here will also be built by the system before considered being complete
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700214EXTRA_BUILDDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700215
216# any rules you put here will be depended on in clean builds
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700217EXTRA_CLEANDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700218
Travis Geiselbrecht577036f2009-01-24 21:37:21 -0800219include project/$(PROJECT).mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700220include target/$(TARGET)/rules.mk
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -0800221include target/$(TARGET)/tools/makefile
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700222include platform/$(PLATFORM)/rules.mk
223include arch/$(ARCH)/rules.mk
224include platform/rules.mk
225include target/rules.mk
226include kernel/rules.mk
227include dev/rules.mk
Travis Geiselbrecht68372232009-01-24 21:21:08 -0800228include app/rules.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700229
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700230# recursively include any modules in the MODULE variable, leaving a trail of included
231# modules in the ALLMODULES list
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800232include make/module.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700233
234# any extra top level build dependencies that someone declared
235all:: $(EXTRA_BUILDDEPS)
236
237ALLOBJS := \
238 $(BOOTOBJS) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700239 $(OBJS)
240
241# add some automatic configuration defines
242DEFINES += \
243 PROJECT_$(PROJECT)=1 \
244 TARGET_$(TARGET)=1 \
245 PLATFORM_$(PLATFORM)=1 \
246 ARCH_$(ARCH)=1 \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700247 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700248
Mayank Grover9ca6d482018-05-30 18:10:16 +0530249# Add MEMRWOFF as . for targets this is not declared.
250# . will be replaced as string in linker file.
251ifeq ($(MEMRWOFF),)
252MEMRWOFF:= .
253DEFINES += MEMRWOFF=$(MEMRWOFF)
254endif
255
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700256# debug build?
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700257ifneq ($(DEBUG),)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700258DEFINES += \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700259 DEBUG=$(DEBUG)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700260endif
261
262ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
263
264DEPS := $(ALLOBJS:%o=%d)
265
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700266# default to no ccache
267CCACHE ?=
268CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800269ifeq ($(LD),ld)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700270LD := $(TOOLCHAIN_PREFIX)ld
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800271endif
272STRIP := $(TOOLCHAIN_PREFIX)strip
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700273OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
274OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
275CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
276SIZE := $(TOOLCHAIN_PREFIX)size
277NM := $(TOOLCHAIN_PREFIX)nm
278
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700279# comment out or override if you want to see the full output of each command
280NOECHO ?= @
281
282# the logic to compile and link stuff is in here
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800283include make/build.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700284
285clean: $(EXTRA_CLEANDEPS)
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800286 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst $(OUTELF_STRIP)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700287
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700288install: all
289 scp $(OUTBIN) 192.168.0.4:/tftproot
290
291# generate a config.h file with all of the DEFINES laid out in #define format
292configheader:
293
294$(CONFIGHEADER): configheader
295 @$(MKDIR)
296 @echo generating $@
297 @rm -f $(CONFIGHEADER).tmp; \
298 echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \
299 echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \
Mayank Grover88647b52018-06-11 16:40:02 +0530300 echo \#define BOARD $(BOARD_NAME) >> $(CONFIGHEADER).tmp; \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700301 for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \
302 echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \
303 done; \
304 echo \#endif >> $(CONFIGHEADER).tmp; \
305 if [ -f "$(CONFIGHEADER)" ]; then \
306 if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \
307 rm -f $(CONFIGHEADER).tmp; \
308 else \
309 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
310 fi \
311 else \
312 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
313 fi
314
315# Empty rule for the .d files. The above rules will build .d files as a side
316# effect. Only works on gcc 3.x and above, however.
317%.d:
318
319ifeq ($(filter $(MAKECMDGOALS), clean), )
320-include $(DEPS)
321endif
322
323.PHONY: configheader
Brian Swetlandf1e5afd2009-01-24 22:09:30 -0800324endif
Travis Geiselbrecht78d0e6c2009-11-27 13:37:03 -0800325
326endif # make spotless