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