blob: ac825df7420f129f11fe61f7c0794bf23ca8b668 [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
tracychui8fd71dc2020-06-11 10:17:13 +080088#[TracyChui] Add lock unlock fastboot commnad to skip ui check 20200611 start
89CFLAGS += -DENABLE_LOCK_UNLOCK_SKIP_UI_CHECK=1
90#[TracyChui] Add lock unlock fastboot commnad to skip ui check 20200611 end
91
Channagoud Kadabi02072a42014-02-28 19:15:40 -080092# setup toolchain prefix
93TOOLCHAIN_PREFIX ?= arm-eabi-
Maria Yud3200512014-05-28 15:57:51 +080094CFLAGS += -fstack-protector-all
vijay kumarc2119f12014-07-22 18:30:11 +053095CFLAGS += -fno-strict-overflow
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070096CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
97#CPPFLAGS += -Weffc++
98ASMFLAGS := -DASSEMBLY
99LDFLAGS :=
100
101CFLAGS += -ffunction-sections -fdata-sections
102LDFLAGS += -gc-sections
103
104# top level rule
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800105all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size $(OUTELF_STRIP) APPSBOOTHEADER
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700106
107# the following three object lists are identical except for the ordering
108# which is bootobjs, kobjs, objs
109BOOTOBJS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700110OBJS :=
111
112# a linker script needs to be declared in one of the project/target/platform files
113LINKER_SCRIPT :=
114
115# anything you add here will be deleted in make clean
116GENERATED := $(CONFIGHEADER)
117
118# anything added to DEFINES will be put into $(BUILDDIR)/config.h
119DEFINES := LK=1
120
121# Anything added to SRCDEPS will become a dependency of every source file in the system.
122# Useful for header files that may be included by one or more source files.
123SRCDEPS := $(CONFIGHEADER)
124
Shashank Mittale99a8d32014-09-11 19:51:06 -0700125ifeq ($(VERIFIED_BOOT),1)
126 DEFINES += VERIFIED_BOOT=1
127 DEFINES += _SIGNED_KERNEL=1
128 ifeq ($(DEFAULT_UNLOCK),true)
129 DEFINES += DEFAULT_UNLOCK=1
130 endif
131endif
132
AnilKumar Chimata46864322017-08-10 14:51:25 +0530133ifeq ($(VERIFIED_BOOT_LE),1)
134 DEFINES += VERIFIED_BOOT_LE=1
135 ifeq ($(DEFAULT_UNLOCK),true)
136 DEFINES += DEFAULT_UNLOCK=1
137 endif
138endif
Monika Singhae7e9642018-03-08 17:44:30 +0530139ifeq ($(VERIFIED_BOOT_2),1)
140 DEFINES += VERIFIED_BOOT_2=1
141 DEFINES += _SIGNED_KERNEL=1
142endif
AnilKumar Chimata46864322017-08-10 14:51:25 +0530143
Monika Singh4d659d22019-12-05 16:38:04 +0530144ifeq ($(VB1_KEY_USED),1)
145 DEFINES += VB1_KEY_USED=1
146endif
147
Mayank Groverc8a46c42019-04-25 11:46:00 +0530148ifeq ($(DYNAMIC_PARTITION_SUPPORT),1)
149 DEFINES += DYNAMIC_PARTITION_SUPPORT=1
150endif
151
Jiten Patel3f6e7012018-08-22 12:46:20 +0530152ifeq ($(TARGET_DTBO_NOT_SUPPORTED),1)
153 DEFINES += TARGET_DTBO_NOT_SUPPORTED=1
154endif
155
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530156ifeq ($(OSVERSION_IN_BOOTIMAGE),1)
157 DEFINES += OSVERSION_IN_BOOTIMAGE=1
158endif
159
Mayank Grover02b160c2018-05-15 14:52:18 +0530160ifeq ($(HIBERNATION_SUPPORT),1)
161DEFINES += HIBERNATION_SUPPORT=1
162endif
163
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530164ifeq ($(ENABLE_VB_ATTEST),1)
165 DEFINES += ENABLE_VB_ATTEST=1
166endif
167
Channagoud Kadabi9071af32015-03-12 12:39:56 -0700168ifeq ($(USER_BUILD_VARIANT),true)
169 DEFINES += USER_BUILD_VARIANT=1
170endif
171
Hareesh Gautham49c6a612017-04-21 15:54:27 +0530172ifeq ($(USE_LE_SYSTEMD),true)
173 DEFINES += USE_LE_SYSTEMD=1
174else
175 DEFINES += USE_LE_SYSTEMD=0
176endif
177
zhaochen3e3b52f2018-02-06 19:25:27 +0800178ifeq ($(MOUNT_EMMC_LE),true)
179 DEFINES += MOUNT_EMMC_LE=1
180else
181 DEFINES += MOUNT_EMMC_LE=0
182endif
183
lijuangc43b2cb2017-12-07 14:45:23 +0800184#Enable kaslr seed support
185ifeq ($(ENABLE_KASLRSEED),1)
186 DEFINES += ENABLE_KASLRSEED_SUPPORT=1
187else
188 DEFINES += ENABLE_KASLRSEED_SUPPORT=0
189endif
190
Mayank Grover44180df2018-05-09 12:13:12 +0530191ifeq ($(TARGET_USE_SYSTEM_AS_ROOT_IMAGE),1)
192 DEFINES += TARGET_USE_SYSTEM_AS_ROOT_IMAGE=1
193else
194 DEFINES += TARGET_USE_SYSTEM_AS_ROOT_IMAGE=0
195endif
196
tracychuid184b912020-06-05 17:31:38 +0800197#[20200605][TracyChui]Show SW and modem version and internal storage size on fastboot screen start
198DEFINES += ARIMA_BOOTLOADER_VERSION=\"$(ARIMA_SW_VERSION_ABOOT)\"
199DEFINES += ARIMA_BASEBAND_VERSION=\"$(MODEM_BUILDID)\"
200#[20200605][TracyChui]Show SW and modem version and internal storage size on fastboot screen end
201
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700202# these need to be filled out by the project/target/platform rules.mk files
203TARGET :=
204PLATFORM :=
205ARCH :=
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700206ALLMODULES :=
207MODULES :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700208
209# any rules you put here will also be built by the system before considered being complete
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700210EXTRA_BUILDDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700211
212# any rules you put here will be depended on in clean builds
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700213EXTRA_CLEANDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700214
Travis Geiselbrecht577036f2009-01-24 21:37:21 -0800215include project/$(PROJECT).mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700216include target/$(TARGET)/rules.mk
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -0800217include target/$(TARGET)/tools/makefile
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700218include platform/$(PLATFORM)/rules.mk
219include arch/$(ARCH)/rules.mk
220include platform/rules.mk
221include target/rules.mk
222include kernel/rules.mk
223include dev/rules.mk
Travis Geiselbrecht68372232009-01-24 21:21:08 -0800224include app/rules.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700225
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700226# recursively include any modules in the MODULE variable, leaving a trail of included
227# modules in the ALLMODULES list
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800228include make/module.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700229
230# any extra top level build dependencies that someone declared
231all:: $(EXTRA_BUILDDEPS)
232
233ALLOBJS := \
234 $(BOOTOBJS) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700235 $(OBJS)
236
237# add some automatic configuration defines
238DEFINES += \
239 PROJECT_$(PROJECT)=1 \
240 TARGET_$(TARGET)=1 \
241 PLATFORM_$(PLATFORM)=1 \
242 ARCH_$(ARCH)=1 \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700243 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700244
Mayank Grover9ca6d482018-05-30 18:10:16 +0530245# Add MEMRWOFF as . for targets this is not declared.
246# . will be replaced as string in linker file.
247ifeq ($(MEMRWOFF),)
248MEMRWOFF:= .
249DEFINES += MEMRWOFF=$(MEMRWOFF)
250endif
251
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700252# debug build?
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700253ifneq ($(DEBUG),)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700254DEFINES += \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700255 DEBUG=$(DEBUG)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700256endif
257
258ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
259
260DEPS := $(ALLOBJS:%o=%d)
261
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700262# default to no ccache
263CCACHE ?=
264CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800265ifeq ($(LD),ld)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700266LD := $(TOOLCHAIN_PREFIX)ld
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800267endif
268STRIP := $(TOOLCHAIN_PREFIX)strip
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700269OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
270OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
271CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
272SIZE := $(TOOLCHAIN_PREFIX)size
273NM := $(TOOLCHAIN_PREFIX)nm
274
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700275# comment out or override if you want to see the full output of each command
276NOECHO ?= @
277
278# the logic to compile and link stuff is in here
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800279include make/build.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700280
281clean: $(EXTRA_CLEANDEPS)
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800282 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst $(OUTELF_STRIP)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700283
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700284install: all
285 scp $(OUTBIN) 192.168.0.4:/tftproot
286
287# generate a config.h file with all of the DEFINES laid out in #define format
288configheader:
289
290$(CONFIGHEADER): configheader
291 @$(MKDIR)
292 @echo generating $@
293 @rm -f $(CONFIGHEADER).tmp; \
294 echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \
295 echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \
Mayank Grover88647b52018-06-11 16:40:02 +0530296 echo \#define BOARD $(BOARD_NAME) >> $(CONFIGHEADER).tmp; \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700297 for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \
298 echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \
299 done; \
300 echo \#endif >> $(CONFIGHEADER).tmp; \
301 if [ -f "$(CONFIGHEADER)" ]; then \
302 if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \
303 rm -f $(CONFIGHEADER).tmp; \
304 else \
305 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
306 fi \
307 else \
308 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
309 fi
310
311# Empty rule for the .d files. The above rules will build .d files as a side
312# effect. Only works on gcc 3.x and above, however.
313%.d:
314
315ifeq ($(filter $(MAKECMDGOALS), clean), )
316-include $(DEPS)
317endif
318
319.PHONY: configheader
Brian Swetlandf1e5afd2009-01-24 22:09:30 -0800320endif
Travis Geiselbrecht78d0e6c2009-11-27 13:37:03 -0800321
322endif # make spotless