| Travis Geiselbrecht | 78d0e6c | 2009-11-27 13:37:03 -0800 | [diff] [blame] | 1 | ifeq ($(MAKECMDGOALS),spotless) | 
 | 2 | spotless: | 
 | 3 | 	rm -rf build-* | 
 | 4 | else | 
 | 5 |  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 6 | -include local.mk | 
| Travis Geiselbrecht | 5bcbd9d | 2009-01-24 20:15:32 -0800 | [diff] [blame] | 7 | include make/macros.mk | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 8 |  | 
| Brian Swetland | f1e5afd | 2009-01-24 22:09:30 -0800 | [diff] [blame] | 9 | # 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 |  | 
 | 13 | project-name := $(firstword $(MAKECMDGOALS)) | 
 | 14 |  | 
 | 15 | ifneq ($(project-name),) | 
 | 16 | ifneq ($(wildcard project/$(project-name).mk),) | 
 | 17 | do-nothing := 1 | 
 | 18 | $(MAKECMDGOALS) _all: make-make | 
 | 19 | make-make: | 
 | 20 | 	@PROJECT=$(project-name) $(MAKE) $(filter-out $(project-name), $(MAKECMDGOALS)) | 
 | 21 | endif | 
 | 22 | endif | 
 | 23 |  | 
 | 24 | ifeq ($(do-nothing),) | 
 | 25 |  | 
 | 26 | ifeq ($(PROJECT),) | 
 | 27 | $(error No project specified.  Use "make projectname" or put "PROJECT := projectname" in local.mk) | 
 | 28 | endif | 
 | 29 |  | 
| Chandan Uddaraju | 40b227d | 2010-08-03 19:25:41 -0700 | [diff] [blame] | 30 | DEBUG ?= 0 | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 31 |  | 
| Chandan Uddaraju | a9b07bb | 2009-11-21 12:22:02 -0800 | [diff] [blame] | 32 | ifndef $(BOOTLOADER_OUT) | 
 | 33 | BOOTLOADER_OUT := . | 
 | 34 | endif | 
 | 35 |  | 
| Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 36 | LK_TOP_DIR:= . | 
| Chandan Uddaraju | a9b07bb | 2009-11-21 12:22:02 -0800 | [diff] [blame] | 37 | BUILDDIR := $(BOOTLOADER_OUT)/build-$(PROJECT) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 38 | OUTBIN := $(BUILDDIR)/lk.bin | 
 | 39 | OUTELF := $(BUILDDIR)/lk | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 40 | OUTELF_STRIP := $(BUILDDIR)/lk_s.elf | 
 | 41 |  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 42 | CONFIGHEADER := $(BUILDDIR)/config.h | 
 | 43 |  | 
| Subbaraman Narayanamurthy | 8bcd5fd | 2011-01-17 17:18:44 -0800 | [diff] [blame] | 44 | #Initialize the command-line flag ENABLE_TRUSTZONE. Value for flag passed in at command-line will take precedence | 
 | 45 | ENABLE_TRUSTZONE := 0 | 
 | 46 |  | 
 | 47 | ifeq ($(ENABLE_TRUSTZONE),1) | 
 | 48 | 	INPUT_TZ_BIN := tzbsp/tzbsp.bin | 
 | 49 | 	OUTPUT_TZ_BIN := $(BUILDDIR)/tzbsp_bin.o | 
 | 50 | endif | 
 | 51 |  | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 52 | INCLUDES := -I$(BUILDDIR) -Iinclude | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 53 | CFLAGS := -O2 -g -fno-builtin -finline -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -include $(CONFIGHEADER) | 
 | 54 | #CFLAGS += -Werror | 
| David Ng | 025c1d9 | 2009-12-09 23:46:00 -0800 | [diff] [blame] | 55 | ifeq ($(EMMC_BOOT),1) | 
 | 56 |   CFLAGS += -D_EMMC_BOOT=1 | 
 | 57 | endif | 
| Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 58 |  | 
 | 59 | ifeq ($(SIGNED_KERNEL),1) | 
 | 60 |   CFLAGS += -D_SIGNED_KERNEL=1 | 
 | 61 | endif | 
 | 62 |  | 
| Sridhar Parasuram | e94e815 | 2014-10-24 14:06:03 -0700 | [diff] [blame] | 63 | ifeq ($(TARGET_BUILD_VARIANT),user) | 
 | 64 |   CFLAGS += -DDISABLE_FASTBOOT_CMDS=1 | 
 | 65 | endif | 
 | 66 |  | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 67 | # setup toolchain prefix | 
 | 68 | TOOLCHAIN_PREFIX ?= arm-eabi- | 
| Maria Yu | d320051 | 2014-05-28 15:57:51 +0800 | [diff] [blame] | 69 | CFLAGS += -fstack-protector-all | 
| vijay kumar | c2119f1 | 2014-07-22 18:30:11 +0530 | [diff] [blame] | 70 | CFLAGS += -fno-strict-overflow | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 71 | CPPFLAGS := -fno-exceptions -fno-rtti -fno-threadsafe-statics | 
 | 72 | #CPPFLAGS += -Weffc++ | 
 | 73 | ASMFLAGS := -DASSEMBLY | 
 | 74 | LDFLAGS :=  | 
 | 75 |  | 
 | 76 | CFLAGS += -ffunction-sections -fdata-sections | 
 | 77 | LDFLAGS += -gc-sections | 
 | 78 |  | 
 | 79 | # top level rule | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 80 | all:: $(OUTBIN) $(OUTELF).lst $(OUTELF).debug.lst $(OUTELF).sym $(OUTELF).size $(OUTELF_STRIP) APPSBOOTHEADER | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 81 |  | 
 | 82 | # the following three object lists are identical except for the ordering | 
 | 83 | # which is bootobjs, kobjs, objs | 
 | 84 | BOOTOBJS :=	 | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 85 | OBJS := | 
 | 86 |  | 
 | 87 | # a linker script needs to be declared in one of the project/target/platform files | 
 | 88 | LINKER_SCRIPT := 			 | 
 | 89 |  | 
 | 90 | # anything you add here will be deleted in make clean | 
 | 91 | GENERATED := $(CONFIGHEADER) | 
 | 92 |  | 
 | 93 | # anything added to DEFINES will be put into $(BUILDDIR)/config.h | 
 | 94 | DEFINES := LK=1				 | 
 | 95 |  | 
 | 96 | # Anything added to SRCDEPS will become a dependency of every source file in the system. | 
 | 97 | # Useful for header files that may be included by one or more source files. | 
 | 98 | SRCDEPS := $(CONFIGHEADER) | 
 | 99 |  | 
| Shashank Mittal | e99a8d3 | 2014-09-11 19:51:06 -0700 | [diff] [blame^] | 100 | ifeq ($(VERIFIED_BOOT),1) | 
 | 101 |   DEFINES += VERIFIED_BOOT=1 | 
 | 102 |   DEFINES += _SIGNED_KERNEL=1 | 
 | 103 |   ifeq ($(DEFAULT_UNLOCK),true) | 
 | 104 |     DEFINES += DEFAULT_UNLOCK=1 | 
 | 105 |   endif | 
 | 106 | endif | 
 | 107 |  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 108 | # these need to be filled out by the project/target/platform rules.mk files | 
 | 109 | TARGET := | 
 | 110 | PLATFORM := | 
 | 111 | ARCH := | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 112 | ALLMODULES := | 
 | 113 | MODULES := | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 114 |  | 
 | 115 | # any rules you put here will also be built by the system before considered being complete | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 116 | EXTRA_BUILDDEPS :=  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 117 |  | 
 | 118 | # any rules you put here will be depended on in clean builds | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 119 | EXTRA_CLEANDEPS :=  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 120 |  | 
| Travis Geiselbrecht | 577036f | 2009-01-24 21:37:21 -0800 | [diff] [blame] | 121 | include project/$(PROJECT).mk | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 122 | include target/$(TARGET)/rules.mk | 
| Chandan Uddaraju | a9b07bb | 2009-11-21 12:22:02 -0800 | [diff] [blame] | 123 | include target/$(TARGET)/tools/makefile | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 124 | include platform/$(PLATFORM)/rules.mk | 
 | 125 | include arch/$(ARCH)/rules.mk | 
 | 126 | include platform/rules.mk | 
 | 127 | include target/rules.mk | 
 | 128 | include kernel/rules.mk | 
 | 129 | include dev/rules.mk | 
| Travis Geiselbrecht | 6837223 | 2009-01-24 21:21:08 -0800 | [diff] [blame] | 130 | include app/rules.mk | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 131 |  | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 132 | # recursively include any modules in the MODULE variable, leaving a trail of included | 
 | 133 | # modules in the ALLMODULES list | 
| Travis Geiselbrecht | 5bcbd9d | 2009-01-24 20:15:32 -0800 | [diff] [blame] | 134 | include make/module.mk | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 135 |  | 
 | 136 | # any extra top level build dependencies that someone declared | 
 | 137 | all:: $(EXTRA_BUILDDEPS) | 
 | 138 |  | 
 | 139 | ALLOBJS := \ | 
 | 140 | 	$(BOOTOBJS) \ | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 141 | 	$(OBJS) | 
 | 142 |  | 
 | 143 | # add some automatic configuration defines | 
 | 144 | DEFINES += \ | 
| Subbaraman Narayanamurthy | eb92bcc | 2010-07-20 14:32:46 -0700 | [diff] [blame] | 145 | 	BOARD=$(PROJECT) \ | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 146 | 	PROJECT_$(PROJECT)=1 \ | 
 | 147 | 	TARGET_$(TARGET)=1 \ | 
 | 148 | 	PLATFORM_$(PLATFORM)=1 \ | 
 | 149 | 	ARCH_$(ARCH)=1 \ | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 150 | 	$(addsuffix =1,$(addprefix WITH_,$(ALLMODULES))) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 151 |  | 
 | 152 | # debug build? | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 153 | ifneq ($(DEBUG),) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 154 | DEFINES += \ | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 155 | 	DEBUG=$(DEBUG) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 156 | endif | 
 | 157 |  | 
 | 158 | ALLOBJS := $(addprefix $(BUILDDIR)/,$(ALLOBJS)) | 
 | 159 |  | 
 | 160 | DEPS := $(ALLOBJS:%o=%d) | 
 | 161 |  | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 162 | # default to no ccache | 
 | 163 | CCACHE ?=  | 
 | 164 | CC := $(CCACHE) $(TOOLCHAIN_PREFIX)gcc | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 165 | ifeq ($(LD),ld) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 166 | LD := $(TOOLCHAIN_PREFIX)ld | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 167 | endif | 
 | 168 | STRIP := $(TOOLCHAIN_PREFIX)strip | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 169 | OBJDUMP := $(TOOLCHAIN_PREFIX)objdump | 
 | 170 | OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy | 
 | 171 | CPPFILT := $(TOOLCHAIN_PREFIX)c++filt | 
 | 172 | SIZE := $(TOOLCHAIN_PREFIX)size | 
 | 173 | NM := $(TOOLCHAIN_PREFIX)nm | 
 | 174 |  | 
| Travis Geiselbrecht | f54ab82 | 2008-09-05 04:14:40 -0700 | [diff] [blame] | 175 | # comment out or override if you want to see the full output of each command | 
 | 176 | NOECHO ?= @ | 
 | 177 |  | 
 | 178 | # the logic to compile and link stuff is in here | 
| Travis Geiselbrecht | 5bcbd9d | 2009-01-24 20:15:32 -0800 | [diff] [blame] | 179 | include make/build.mk | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 180 |  | 
 | 181 | clean: $(EXTRA_CLEANDEPS) | 
| Channagoud Kadabi | 02072a4 | 2014-02-28 19:15:40 -0800 | [diff] [blame] | 182 | 	rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).lst $(OUTELF_STRIP) | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 183 |  | 
| Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 184 | install: all | 
 | 185 | 	scp $(OUTBIN) 192.168.0.4:/tftproot | 
 | 186 |  | 
 | 187 | # generate a config.h file with all of the DEFINES laid out in #define format | 
 | 188 | configheader: | 
 | 189 |  | 
 | 190 | $(CONFIGHEADER): configheader | 
 | 191 | 	@$(MKDIR) | 
 | 192 | 	@echo generating $@ | 
 | 193 | 	@rm -f $(CONFIGHEADER).tmp; \ | 
 | 194 | 	echo \#ifndef __CONFIG_H > $(CONFIGHEADER).tmp; \ | 
 | 195 | 	echo \#define __CONFIG_H >> $(CONFIGHEADER).tmp; \ | 
 | 196 | 	for d in `echo $(DEFINES) | tr [:lower:] [:upper:]`; do \ | 
 | 197 | 		echo "#define $$d" | sed "s/=/\ /g;s/-/_/g;s/\//_/g" >> $(CONFIGHEADER).tmp; \ | 
 | 198 | 	done; \ | 
 | 199 | 	echo \#endif >> $(CONFIGHEADER).tmp; \ | 
 | 200 | 	if [ -f "$(CONFIGHEADER)" ]; then \ | 
 | 201 | 		if cmp "$(CONFIGHEADER).tmp" "$(CONFIGHEADER)"; then \ | 
 | 202 | 			rm -f $(CONFIGHEADER).tmp; \ | 
 | 203 | 		else \ | 
 | 204 | 			mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \ | 
 | 205 | 		fi \ | 
 | 206 | 	else \ | 
 | 207 | 		mv $(CONFIGHEADER).tmp $(CONFIGHEADER); \ | 
 | 208 | 	fi | 
 | 209 |  | 
 | 210 | # Empty rule for the .d files. The above rules will build .d files as a side | 
 | 211 | # effect. Only works on gcc 3.x and above, however. | 
 | 212 | %.d: | 
 | 213 |  | 
 | 214 | ifeq ($(filter $(MAKECMDGOALS), clean), ) | 
 | 215 | -include $(DEPS) | 
 | 216 | endif | 
 | 217 |  | 
 | 218 | .PHONY: configheader | 
| Brian Swetland | f1e5afd | 2009-01-24 22:09:30 -0800 | [diff] [blame] | 219 | endif | 
| Travis Geiselbrecht | 78d0e6c | 2009-11-27 13:37:03 -0800 | [diff] [blame] | 220 |  | 
 | 221 | endif # make spotless |