blob: 7810c1e8b1dc9696fb144f681436a9498c304872 [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
Sridhar Parasurame94e8152014-10-24 14:06:03 -070063ifeq ($(TARGET_BUILD_VARIANT),user)
64 CFLAGS += -DDISABLE_FASTBOOT_CMDS=1
65endif
66
anisha agarwalebc52bc2016-07-08 15:50:00 -070067ifeq ($(APPEND_CMDLINE),1)
68 CFLAGS += -D_APPEND_CMDLINE=1
69endif
Himal Ghimirayc5d81212017-04-28 14:06:04 +053070ifeq ($(ENABLE_HARD_FPU),1)
71 CFLAGS += -mfloat-abi=hard -mfpu=neon
72endif
Sachin Prakash Gejjif557d222017-08-04 17:18:45 +053073
74ifeq ($(ENABLE_EARLY_ETHERNET),1)
75 CFLAGS += -DENABLE_EARLY_ETHERNET=1
76endif
77
Channagoud Kadabi02072a42014-02-28 19:15:40 -080078# setup toolchain prefix
79TOOLCHAIN_PREFIX ?= arm-eabi-
Maria Yud3200512014-05-28 15:57:51 +080080CFLAGS += -fstack-protector-all
vijay kumarc2119f12014-07-22 18:30:11 +053081CFLAGS += -fno-strict-overflow
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070082CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
83#CPPFLAGS += -Weffc++
84ASMFLAGS := -DASSEMBLY
85LDFLAGS :=
86
87CFLAGS += -ffunction-sections -fdata-sections
88LDFLAGS += -gc-sections
89
90# top level rule
Channagoud Kadabi02072a42014-02-28 19:15:40 -080091all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size $(OUTELF_STRIP) APPSBOOTHEADER
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070092
93# the following three object lists are identical except for the ordering
94# which is bootobjs, kobjs, objs
95BOOTOBJS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070096OBJS :=
97
98# a linker script needs to be declared in one of the project/target/platform files
99LINKER_SCRIPT :=
100
101# anything you add here will be deleted in make clean
102GENERATED := $(CONFIGHEADER)
103
104# anything added to DEFINES will be put into $(BUILDDIR)/config.h
105DEFINES := LK=1
106
107# Anything added to SRCDEPS will become a dependency of every source file in the system.
108# Useful for header files that may be included by one or more source files.
109SRCDEPS := $(CONFIGHEADER)
110
Shashank Mittale99a8d32014-09-11 19:51:06 -0700111ifeq ($(VERIFIED_BOOT),1)
112 DEFINES += VERIFIED_BOOT=1
113 DEFINES += _SIGNED_KERNEL=1
114 ifeq ($(DEFAULT_UNLOCK),true)
115 DEFINES += DEFAULT_UNLOCK=1
116 endif
117endif
118
AnilKumar Chimata46864322017-08-10 14:51:25 +0530119ifeq ($(VERIFIED_BOOT_LE),1)
120 DEFINES += VERIFIED_BOOT_LE=1
121 ifeq ($(DEFAULT_UNLOCK),true)
122 DEFINES += DEFAULT_UNLOCK=1
123 endif
124endif
Monika Singhae7e9642018-03-08 17:44:30 +0530125ifeq ($(VERIFIED_BOOT_2),1)
126 DEFINES += VERIFIED_BOOT_2=1
127 DEFINES += _SIGNED_KERNEL=1
128endif
AnilKumar Chimata46864322017-08-10 14:51:25 +0530129
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530130ifeq ($(OSVERSION_IN_BOOTIMAGE),1)
131 DEFINES += OSVERSION_IN_BOOTIMAGE=1
132endif
133
Mayank Grover02b160c2018-05-15 14:52:18 +0530134ifeq ($(HIBERNATION_SUPPORT),1)
135DEFINES += HIBERNATION_SUPPORT=1
136endif
137
Vijay Kumar Pendoti2f869052016-07-15 12:04:19 +0530138ifeq ($(ENABLE_VB_ATTEST),1)
139 DEFINES += ENABLE_VB_ATTEST=1
140endif
141
Channagoud Kadabi9071af32015-03-12 12:39:56 -0700142ifeq ($(USER_BUILD_VARIANT),true)
143 DEFINES += USER_BUILD_VARIANT=1
144endif
145
Hareesh Gautham49c6a612017-04-21 15:54:27 +0530146ifeq ($(USE_LE_SYSTEMD),true)
147 DEFINES += USE_LE_SYSTEMD=1
148else
149 DEFINES += USE_LE_SYSTEMD=0
150endif
151
zhaochen3e3b52f2018-02-06 19:25:27 +0800152ifeq ($(MOUNT_EMMC_LE),true)
153 DEFINES += MOUNT_EMMC_LE=1
154else
155 DEFINES += MOUNT_EMMC_LE=0
156endif
157
lijuangc43b2cb2017-12-07 14:45:23 +0800158#Enable kaslr seed support
159ifeq ($(ENABLE_KASLRSEED),1)
160 DEFINES += ENABLE_KASLRSEED_SUPPORT=1
161else
162 DEFINES += ENABLE_KASLRSEED_SUPPORT=0
163endif
164
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700165# these need to be filled out by the project/target/platform rules.mk files
166TARGET :=
167PLATFORM :=
168ARCH :=
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700169ALLMODULES :=
170MODULES :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700171
172# any rules you put here will also be built by the system before considered being complete
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700173EXTRA_BUILDDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700174
175# any rules you put here will be depended on in clean builds
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700176EXTRA_CLEANDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700177
Travis Geiselbrecht577036f2009-01-24 21:37:21 -0800178include project/$(PROJECT).mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700179include target/$(TARGET)/rules.mk
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -0800180include target/$(TARGET)/tools/makefile
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700181include platform/$(PLATFORM)/rules.mk
182include arch/$(ARCH)/rules.mk
183include platform/rules.mk
184include target/rules.mk
185include kernel/rules.mk
186include dev/rules.mk
Travis Geiselbrecht68372232009-01-24 21:21:08 -0800187include app/rules.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700188
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700189# recursively include any modules in the MODULE variable, leaving a trail of included
190# modules in the ALLMODULES list
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800191include make/module.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700192
193# any extra top level build dependencies that someone declared
194all:: $(EXTRA_BUILDDEPS)
195
196ALLOBJS := \
197 $(BOOTOBJS) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700198 $(OBJS)
199
200# add some automatic configuration defines
201DEFINES += \
lijuang42d0ec42015-12-04 17:36:51 +0800202 BOARD=$(BOARD_NAME) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700203 PROJECT_$(PROJECT)=1 \
204 TARGET_$(TARGET)=1 \
205 PLATFORM_$(PLATFORM)=1 \
206 ARCH_$(ARCH)=1 \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700207 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700208
209# debug build?
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700210ifneq ($(DEBUG),)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700211DEFINES += \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700212 DEBUG=$(DEBUG)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700213endif
214
215ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
216
217DEPS := $(ALLOBJS:%o=%d)
218
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700219# default to no ccache
220CCACHE ?=
221CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800222ifeq ($(LD),ld)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700223LD := $(TOOLCHAIN_PREFIX)ld
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800224endif
225STRIP := $(TOOLCHAIN_PREFIX)strip
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700226OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
227OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
228CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
229SIZE := $(TOOLCHAIN_PREFIX)size
230NM := $(TOOLCHAIN_PREFIX)nm
231
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700232# comment out or override if you want to see the full output of each command
233NOECHO ?= @
234
235# the logic to compile and link stuff is in here
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800236include make/build.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700237
238clean: $(EXTRA_CLEANDEPS)
Channagoud Kadabi02072a42014-02-28 19:15:40 -0800239 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst $(OUTELF_STRIP)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700240
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700241install: all
242 scp $(OUTBIN) 192.168.0.4:/tftproot
243
244# generate a config.h file with all of the DEFINES laid out in #define format
245configheader:
246
247$(CONFIGHEADER): configheader
248 @$(MKDIR)
249 @echo generating $@
250 @rm -f $(CONFIGHEADER).tmp; \
251 echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \
252 echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \
253 for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \
254 echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \
255 done; \
256 echo \#endif >> $(CONFIGHEADER).tmp; \
257 if [ -f "$(CONFIGHEADER)" ]; then \
258 if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \
259 rm -f $(CONFIGHEADER).tmp; \
260 else \
261 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
262 fi \
263 else \
264 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
265 fi
266
267# Empty rule for the .d files. The above rules will build .d files as a side
268# effect. Only works on gcc 3.x and above, however.
269%.d:
270
271ifeq ($(filter $(MAKECMDGOALS), clean), )
272-include $(DEPS)
273endif
274
275.PHONY: configheader
Brian Swetlandf1e5afd2009-01-24 22:09:30 -0800276endif
Travis Geiselbrecht78d0e6c2009-11-27 13:37:03 -0800277
278endif # make spotless