blob: e7e614ebd53a68fc646abe565100936f64917f48 [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
40CONFIGHEADER := $(BUILDDIR)/config.h
41
Subbaraman Narayanamurthy8bcd5fd2011-01-17 17:18:44 -080042#Initialize the command-line flag ENABLE_TRUSTZONE. Value for flag passed in at command-line will take precedence
43ENABLE_TRUSTZONE := 0
44
45ifeq ($(ENABLE_TRUSTZONE),1)
46 INPUT_TZ_BIN := tzbsp/tzbsp.bin
47 OUTPUT_TZ_BIN := $(BUILDDIR)/tzbsp_bin.o
48endif
49
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -070050INCLUDES := -I$(BUILDDIR) -Iinclude
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070051CFLAGS := -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include $(CONFIGHEADER)
52#CFLAGS += -Werror
David Ng025c1d92009-12-09 23:46:00 -080053ifeq ($(EMMC_BOOT),1)
54 CFLAGS += -D_EMMC_BOOT=1
55endif
Shashank Mittalcd98d472011-08-02 14:29:24 -070056
57ifeq ($(SIGNED_KERNEL),1)
58 CFLAGS += -D_SIGNED_KERNEL=1
59endif
60
wangxle5b14c02015-04-10 19:16:30 +080061#ifeq ($(TARGET_BUILD_VARIANT),user)
62# CFLAGS += -DDISABLE_FASTBOOT_CMDS=1
63#endif
Sridhar Parasuram901bb702014-10-24 14:06:03 -070064
Maria Yue2e80352014-05-28 15:57:51 +080065# setup toolchain prefix
66TOOLCHAIN_PREFIX ?= arm-eabi-
67CFLAGS += -fstack-protector-all
vijay kumar9b7c5332014-07-22 18:30:11 +053068CFLAGS += -fno-strict-overflow
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070069CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics
70#CPPFLAGS += -Weffc++
71ASMFLAGS := -DASSEMBLY
72LDFLAGS :=
73
74CFLAGS += -ffunction-sections -fdata-sections
75LDFLAGS += -gc-sections
76
77# top level rule
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -080078all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size APPSBOOTHEADER
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070079
80# the following three object lists are identical except for the ordering
81# which is bootobjs, kobjs, objs
82BOOTOBJS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070083OBJS :=
84
85# a linker script needs to be declared in one of the project/target/platform files
86LINKER_SCRIPT :=
87
88# anything you add here will be deleted in make clean
89GENERATED := $(CONFIGHEADER)
90
91# anything added to DEFINES will be put into $(BUILDDIR)/config.h
92DEFINES := LK=1
93
94# Anything added to SRCDEPS will become a dependency of every source file in the system.
95# Useful for header files that may be included by one or more source files.
96SRCDEPS := $(CONFIGHEADER)
97
Sridhar Parasuram1049ab22015-08-29 11:12:37 -070098ifeq ($(VERIFIED_BOOT),1)
99 DEFINES += VERIFIED_BOOT=1
100 DEFINES += _SIGNED_KERNEL=1
101 ifeq ($(DEFAULT_UNLOCK),true)
102 DEFINES += DEFAULT_UNLOCK=1
103 endif
104endif
105
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700106# these need to be filled out by the project/target/platform rules.mk files
107TARGET :=
108PLATFORM :=
109ARCH :=
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700110ALLMODULES :=
111MODULES :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700112
113# any rules you put here will also be built by the system before considered being complete
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700114EXTRA_BUILDDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700115
116# any rules you put here will be depended on in clean builds
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700117EXTRA_CLEANDEPS :=
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700118
Travis Geiselbrecht577036f2009-01-24 21:37:21 -0800119include project/$(PROJECT).mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700120include target/$(TARGET)/rules.mk
Chandan Uddarajua9b07bb2009-11-21 12:22:02 -0800121include target/$(TARGET)/tools/makefile
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700122include platform/$(PLATFORM)/rules.mk
123include arch/$(ARCH)/rules.mk
124include platform/rules.mk
125include target/rules.mk
126include kernel/rules.mk
127include dev/rules.mk
Travis Geiselbrecht68372232009-01-24 21:21:08 -0800128include app/rules.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700129
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700130# recursively include any modules in the MODULE variable, leaving a trail of included
131# modules in the ALLMODULES list
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800132include make/module.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700133
134# any extra top level build dependencies that someone declared
135all:: $(EXTRA_BUILDDEPS)
136
137ALLOBJS := \
138 $(BOOTOBJS) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700139 $(OBJS)
140
141# add some automatic configuration defines
142DEFINES += \
Subbaraman Narayanamurthyeb92bcc2010-07-20 14:32:46 -0700143 BOARD=$(PROJECT) \
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700144 PROJECT_$(PROJECT)=1 \
145 TARGET_$(TARGET)=1 \
146 PLATFORM_$(PLATFORM)=1 \
147 ARCH_$(ARCH)=1 \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700148 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES)))
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700149
150# debug build?
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700151ifneq ($(DEBUG),)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700152DEFINES += \
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700153 DEBUG=$(DEBUG)
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700154endif
155
156ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS))
157
158DEPS := $(ALLOBJS:%o=%d)
159
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700160# default to no ccache
161CCACHE ?=
162CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700163LD := $(TOOLCHAIN_PREFIX)ld
164OBJDUMP := $(TOOLCHAIN_PREFIX)objdump
165OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
166CPPFILT := $(TOOLCHAIN_PREFIX)c++filt
167SIZE := $(TOOLCHAIN_PREFIX)size
168NM := $(TOOLCHAIN_PREFIX)nm
169
Travis Geiselbrechtf54ab822008-09-05 04:14:40 -0700170# comment out or override if you want to see the full output of each command
171NOECHO ?= @
172
173# the logic to compile and link stuff is in here
Travis Geiselbrecht5bcbd9d2009-01-24 20:15:32 -0800174include make/build.mk
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700175
176clean: $(EXTRA_CLEANDEPS)
177 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst
178
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700179install: all
180 scp $(OUTBIN) 192.168.0.4:/tftproot
181
182# generate a config.h file with all of the DEFINES laid out in #define format
183configheader:
184
185$(CONFIGHEADER): configheader
186 @$(MKDIR)
187 @echo generating $@
188 @rm -f $(CONFIGHEADER).tmp; \
189 echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \
190 echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \
191 for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \
192 echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \
193 done; \
194 echo \#endif >> $(CONFIGHEADER).tmp; \
195 if [ -f "$(CONFIGHEADER)" ]; then \
196 if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \
197 rm -f $(CONFIGHEADER).tmp; \
198 else \
199 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
200 fi \
201 else \
202 mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \
203 fi
204
205# Empty rule for the .d files. The above rules will build .d files as a side
206# effect. Only works on gcc 3.x and above, however.
207%.d:
208
209ifeq ($(filter $(MAKECMDGOALS), clean), )
210-include $(DEPS)
211endif
212
213.PHONY: configheader
Brian Swetlandf1e5afd2009-01-24 22:09:30 -0800214endif
Travis Geiselbrecht78d0e6c2009-11-27 13:37:03 -0800215
216endif # make spotless