blob: 86a4878afd50bdd6ecaf10a3d37342f839d396c9 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
Dan Handleye83b0ca2014-01-14 18:17:09 +00002# Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# Redistributions of source code must retain the above copyright notice, this
8# list of conditions and the following disclaimer.
9#
10# Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# Neither the name of ARM nor the names of its contributors may be used
15# to endorse or promote products derived from this software without specific
16# prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010031#
32# Default values for build configurations
33#
34
35# Build verbosity
36V := 0
37# Debug build
38DEBUG := 0
39# Build architecture
40ARCH := aarch64
41# Build platform
42DEFAULT_PLAT := fvp
43PLAT := ${DEFAULT_PLAT}
44# SPD choice
45SPD := none
46# Base commit to perform code check on
47BASE_COMMIT := origin/master
Jeenu Viswambharan2da8d8b2014-05-12 15:28:47 +010048# NS timer register save and restore
49NS_TIMER_SWITCH := 0
Vikram Kanigiridbad1ba2014-04-24 11:02:16 +010050# By default, Bl1 acts as the reset handler, not BL31
51RESET_TO_BL31 := 0
Juan Castillo0f21c542014-06-25 17:26:36 +010052# Include FP registers in cpu context
53CTX_INCLUDE_FPREGS := 0
Sandrine Bailleux2b98e782014-07-17 17:23:14 +010054# Determine the version of ARM GIC architecture to use for interrupt management
55# in EL3. The platform port can change this value if needed.
56ARM_GIC_ARCH := 2
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010057
Achin Gupta4f6ad662013-10-25 09:08:21 +010058
Achin Gupta7421b462014-02-01 18:53:26 +000059# Checkpatch ignores
60CHECK_IGNORE = --ignore COMPLEX_MACRO
61
62CHECKPATCH_ARGS = --no-tree --no-signoff ${CHECK_IGNORE}
63CHECKCODE_ARGS = --no-patch --no-tree --no-signoff ${CHECK_IGNORE}
Ian Spray36eaaf32014-01-30 17:25:28 +000064
Jeenu Viswambharane35c4042014-05-15 14:40:58 +010065ifeq (${V},0)
Achin Gupta4f6ad662013-10-25 09:08:21 +010066 Q=@
Ian Spray36eaaf32014-01-30 17:25:28 +000067 CHECKCODE_ARGS += --no-summary --terse
Achin Gupta4f6ad662013-10-25 09:08:21 +010068else
69 Q=
70endif
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000071export Q
72
James Morrisseyeaaeece2013-11-01 13:56:59 +000073ifneq (${DEBUG}, 0)
74 BUILD_TYPE := debug
75else
76 BUILD_TYPE := release
77endif
78
Dan Handleybee82412014-04-15 18:20:09 +010079BL_COMMON_SOURCES := common/bl_common.c \
Soby Mathewa43d4312014-04-07 15:28:55 +010080 common/debug.c \
Soby Mathewb79af932014-06-12 17:23:58 +010081 common/tf_printf.c \
Dan Handleybee82412014-04-15 18:20:09 +010082 lib/aarch64/cache_helpers.S \
83 lib/aarch64/misc_helpers.S \
Dan Handleybee82412014-04-15 18:20:09 +010084 lib/aarch64/xlat_helpers.c \
85 lib/stdlib/std.c \
86 lib/io_storage.c \
87 plat/common/aarch64/platform_helpers.S
Ryan Harkind7a6b0f2014-01-13 14:40:13 +000088
Ryan Harkin25cff832014-01-13 12:37:03 +000089BUILD_BASE := ./build
90BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
Achin Gupta4f6ad662013-10-25 09:08:21 +010091
Ryan Harkin25cff832014-01-13 12:37:03 +000092PLATFORMS := $(shell ls -I common plat/)
Achin Gupta375f5382014-02-18 18:12:48 +000093SPDS := $(shell ls -I none services/spd)
Ryan Harkin72ee3312014-01-15 16:55:07 +000094HELP_PLATFORMS := $(shell echo ${PLATFORMS} | sed 's/ /|/g')
95
Jeenu Viswambharan289e0da2014-05-16 11:38:10 +010096# Convenience function for adding build definitions
97# $(eval $(call add_define,FOO)) will have:
98# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
99define add_define
100DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
101endef
102
103# Convenience function for verifying option has a boolean value
104# $(eval $(call assert_boolean,FOO)) will assert FOO is 0 or 1
105define assert_boolean
106$(and $(patsubst 0,,$(value $(1))),$(patsubst 1,,$(value $(1))),$(error $(1) must be boolean))
107endef
108
Ryan Harkin25cff832014-01-13 12:37:03 +0000109ifeq (${PLAT},)
110 $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform.")
111endif
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000112ifeq ($(findstring ${PLAT},${PLATFORMS}),)
Ryan Harkin25cff832014-01-13 12:37:03 +0000113 $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
114endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100115
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000116all: msg_start
Achin Gupta4f6ad662013-10-25 09:08:21 +0100117
Ryan Harkin25cff832014-01-13 12:37:03 +0000118msg_start:
119 @echo "Building ${PLAT}"
Achin Gupta4f6ad662013-10-25 09:08:21 +0100120
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000121include plat/${PLAT}/platform.mk
Achin Gupta4f6ad662013-10-25 09:08:21 +0100122
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000123ifdef BL1_SOURCES
124NEED_BL1 := yes
125include bl1/bl1.mk
126endif
127
128ifdef BL2_SOURCES
129NEED_BL2 := yes
130include bl2/bl2.mk
131endif
132
133ifdef BL31_SOURCES
134NEED_BL31 := yes
135include bl31/bl31.mk
Ryan Harkin25cff832014-01-13 12:37:03 +0000136endif
137
Achin Gupta375f5382014-02-18 18:12:48 +0000138# Include SPD Makefile if one has been specified
139ifneq (${SPD},none)
140 # We expect to locate an spd.mk under the specified SPD directory
141 SPD_MAKE := $(shell m="services/spd/${SPD}/${SPD}.mk"; [ -f "$$m" ] && echo "$$m")
142
143 ifeq (${SPD_MAKE},)
144 $(error Error: No services/spd/${SPD}/${SPD}.mk located)
145 endif
146 $(info Including ${SPD_MAKE})
147 include ${SPD_MAKE}
148
149 # If there's BL32 companion for the chosen SPD, and the SPD wants to build the
150 # BL2 from source, we expect that the SPD's Makefile would set NEED_BL32
151 # variable to "yes"
152endif
153
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +0000154.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip
James Morrisseyeaaeece2013-11-01 13:56:59 +0000155.SUFFIXES:
156
Sandrine Bailleuxa0df63e2014-06-23 13:37:53 +0100157INCLUDES += -Iinclude/bl31 \
Dan Handley4ecca332014-04-09 12:48:25 +0100158 -Iinclude/bl31/services \
159 -Iinclude/bl32 \
160 -Iinclude/bl32/payloads \
161 -Iinclude/common \
162 -Iinclude/drivers \
163 -Iinclude/drivers/arm \
164 -Iinclude/lib \
165 -Iinclude/lib/aarch64 \
Dan Handley5f0cdb02014-05-14 17:44:19 +0100166 -Iinclude/plat/common \
Ryan Harkind7a6b0f2014-01-13 14:40:13 +0000167 -Iinclude/stdlib \
168 -Iinclude/stdlib/sys \
Achin Gupta375f5382014-02-18 18:12:48 +0000169 ${PLAT_INCLUDES} \
170 ${SPD_INCLUDES}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100171
Jeenu Viswambharane35c4042014-05-15 14:40:58 +0100172# Process DEBUG flag
173$(eval $(call assert_boolean,DEBUG))
174$(eval $(call add_define,DEBUG))
175ifeq (${DEBUG},0)
176 $(eval $(call add_define,NDEBUG))
177else
178CFLAGS += -g
179ASFLAGS += -g -Wa,--gdwarf-2
180endif
181
Jeenu Viswambharan2da8d8b2014-05-12 15:28:47 +0100182# Process NS_TIMER_SWITCH flag
183$(eval $(call assert_boolean,NS_TIMER_SWITCH))
184$(eval $(call add_define,NS_TIMER_SWITCH))
185
Vikram Kanigiridbad1ba2014-04-24 11:02:16 +0100186# Process RESET_TO_BL31 flag
187$(eval $(call assert_boolean,RESET_TO_BL31))
188$(eval $(call add_define,RESET_TO_BL31))
189
Juan Castillo0f21c542014-06-25 17:26:36 +0100190# Process CTX_INCLUDE_FPREGS flag
191$(eval $(call assert_boolean,CTX_INCLUDE_FPREGS))
192$(eval $(call add_define,CTX_INCLUDE_FPREGS))
193
Sandrine Bailleux2b98e782014-07-17 17:23:14 +0100194# Process ARM_GIC_ARCH flag
195$(eval $(call add_define,ARM_GIC_ARCH))
196
197
Harry Liebel0af6d642013-12-20 18:51:12 +0000198ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
Sandrine Bailleuxa0df63e2014-06-23 13:37:53 +0100199 -Werror -Wmissing-include-dirs \
Jeenu Viswambharane35c4042014-05-15 14:40:58 +0100200 -mgeneral-regs-only -D__ASSEMBLY__ \
201 ${DEFINES} ${INCLUDES}
202CFLAGS += -nostdinc -pedantic -ffreestanding -Wall \
Sandrine Bailleuxa0df63e2014-06-23 13:37:53 +0100203 -Werror -Wmissing-include-dirs \
204 -mgeneral-regs-only -std=c99 -c -Os \
Jeenu Viswambharane35c4042014-05-15 14:40:58 +0100205 ${DEFINES} ${INCLUDES}
Andrew Thoelkedccc5372014-03-18 07:13:52 +0000206CFLAGS += -ffunction-sections -fdata-sections
Achin Gupta4f6ad662013-10-25 09:08:21 +0100207
Sandrine Bailleux3e850a82013-11-20 11:50:48 +0000208LDFLAGS += --fatal-warnings -O1
Andrew Thoelkedccc5372014-03-18 07:13:52 +0000209LDFLAGS += --gc-sections
Achin Gupta4f6ad662013-10-25 09:08:21 +0100210
211
James Morrisseyeaaeece2013-11-01 13:56:59 +0000212CC := ${CROSS_COMPILE}gcc
213CPP := ${CROSS_COMPILE}cpp
214AS := ${CROSS_COMPILE}gcc
215AR := ${CROSS_COMPILE}ar
216LD := ${CROSS_COMPILE}ld
217OC := ${CROSS_COMPILE}objcopy
218OD := ${CROSS_COMPILE}objdump
219NM := ${CROSS_COMPILE}nm
220PP := ${CROSS_COMPILE}gcc -E ${CFLAGS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100221
Harry Liebelf58ad362014-01-10 18:00:33 +0000222# Variables for use with Firmware Image Package
223FIPTOOLPATH ?= tools/fip_create
Achin Gupta375f5382014-02-18 18:12:48 +0000224FIPTOOL ?= ${FIPTOOLPATH}/fip_create
Harry Liebelf58ad362014-01-10 18:00:33 +0000225fiptool: ${FIPTOOL}
226fip: ${BUILD_PLAT}/fip.bin
227
Ian Spray36eaaf32014-01-30 17:25:28 +0000228locate-checkpatch:
229ifndef CHECKPATCH
230 $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/script/checkpatch.pl")
231else
232ifeq (,$(wildcard ${CHECKPATCH}))
233 $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/script/checkpatch.pl")
234endif
235endif
236
Achin Gupta4f6ad662013-10-25 09:08:21 +0100237clean:
238 @echo " CLEAN"
Ryan Harkin25cff832014-01-13 12:37:03 +0000239 ${Q}rm -rf ${BUILD_PLAT}
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +0000240 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +0100241
James Morrisseyeaaeece2013-11-01 13:56:59 +0000242realclean distclean:
243 @echo " REALCLEAN"
244 ${Q}rm -rf ${BUILD_BASE}
Joakim Bech35fab8c2014-01-23 14:51:49 +0100245 ${Q}rm -f ${CURDIR}/cscope.*
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +0000246 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
Achin Gupta4f6ad662013-10-25 09:08:21 +0100247
Ian Spray36eaaf32014-01-30 17:25:28 +0000248checkcodebase: locate-checkpatch
249 @echo " CHECKING STYLE"
250 @if test -d .git ; then \
Juan Castillo4f2104f2014-06-13 17:05:10 +0100251 git ls-files | grep -v stdlib | while read GIT_FILE ; do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; done ; \
Ian Spray36eaaf32014-01-30 17:25:28 +0000252 else \
Juan Castillo4f2104f2014-06-13 17:05:10 +0100253 find . -type f -not -iwholename "*.git*" -not -iwholename "*build*" -not -iwholename "*stdlib*" -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
Ian Spray36eaaf32014-01-30 17:25:28 +0000254 fi
255
256checkpatch: locate-checkpatch
257 @echo " CHECKING STYLE"
258 @git format-patch --stdout ${BASE_COMMIT} | ${CHECKPATCH} ${CHECKPATCH_ARGS} - || true
259
Harry Liebelf58ad362014-01-10 18:00:33 +0000260${FIPTOOL}:
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +0000261 ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH}
Harry Liebelf58ad362014-01-10 18:00:33 +0000262 @echo
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +0000263 @echo "Built $@ successfully"
Harry Liebelf58ad362014-01-10 18:00:33 +0000264 @echo
265
Jon Medhurst6d55d102014-02-12 15:54:48 +0000266define match_goals
267$(strip $(foreach goal,$(1),$(filter $(goal),$(MAKECMDGOALS))))
268endef
James Morrisseyeaaeece2013-11-01 13:56:59 +0000269
Sandrine Bailleux8d2296f2014-03-21 14:17:51 +0000270# List of rules that involve building things
271BUILD_TARGETS := all bl1 bl2 bl31 bl32 fip
James Morrisseyeaaeece2013-11-01 13:56:59 +0000272
Sandrine Bailleux8d2296f2014-03-21 14:17:51 +0000273# Does the list of goals specified on the command line include a build target?
274ifneq ($(call match_goals,${BUILD_TARGETS}),)
275IS_ANYTHING_TO_BUILD := 1
276endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100277
Jon Medhurst6d55d102014-02-12 15:54:48 +0000278define MAKE_C
James Morrisseyeaaeece2013-11-01 13:56:59 +0000279
Jon Medhurst6d55d102014-02-12 15:54:48 +0000280$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
281$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ)))
James Morrisseyeaaeece2013-11-01 13:56:59 +0000282
Jon Medhurst6d55d102014-02-12 15:54:48 +0000283$(OBJ) : $(2)
284 @echo " CC $$<"
285 $$(Q)$$(CC) $$(CFLAGS) -c $$< -o $$@
James Morrisseyeaaeece2013-11-01 13:56:59 +0000286
Achin Gupta4f6ad662013-10-25 09:08:21 +0100287
Jon Medhurst6d55d102014-02-12 15:54:48 +0000288$(PREREQUISITES) : $(2)
289 @echo " DEPS $$@"
290 @mkdir -p $(1)
291 $$(Q)$$(CC) $$(CFLAGS) -M -MT $(OBJ) -MF $$@ $$<
Achin Gupta4f6ad662013-10-25 09:08:21 +0100292
Sandrine Bailleux8d2296f2014-03-21 14:17:51 +0000293ifdef IS_ANYTHING_TO_BUILD
Jon Medhurst6d55d102014-02-12 15:54:48 +0000294-include $(PREREQUISITES)
295endif
296
297endef
298
299
300define MAKE_S
301
302$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
303$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ)))
304
305$(OBJ) : $(2)
306 @echo " AS $$<"
307 $$(Q)$$(AS) $$(ASFLAGS) -c $$< -o $$@
308
309$(PREREQUISITES) : $(2)
310 @echo " DEPS $$@"
311 @mkdir -p $(1)
312 $$(Q)$$(AS) $$(ASFLAGS) -M -MT $(OBJ) -MF $$@ $$<
313
Sandrine Bailleux8d2296f2014-03-21 14:17:51 +0000314ifdef IS_ANYTHING_TO_BUILD
Jon Medhurst6d55d102014-02-12 15:54:48 +0000315-include $(PREREQUISITES)
316endif
317
318endef
319
320
321define MAKE_LD
322
323$(eval PREREQUISITES := $(1).d)
324
325$(1) : $(2)
326 @echo " PP $$<"
327 $$(Q)$$(AS) $$(ASFLAGS) -P -E -o $$@ $$<
328
329$(PREREQUISITES) : $(2)
330 @echo " DEPS $$@"
331 @mkdir -p $$(dir $$@)
332 $$(Q)$$(AS) $$(ASFLAGS) -M -MT $(1) -MF $$@ $$<
333
Sandrine Bailleux8d2296f2014-03-21 14:17:51 +0000334ifdef IS_ANYTHING_TO_BUILD
Jon Medhurst6d55d102014-02-12 15:54:48 +0000335-include $(PREREQUISITES)
336endif
337
338endef
339
340
341define MAKE_OBJS
342 $(eval C_OBJS := $(filter %.c,$(2)))
343 $(eval REMAIN := $(filter-out %.c,$(2)))
344 $(eval $(foreach obj,$(C_OBJS),$(call MAKE_C,$(1),$(obj))))
345
346 $(eval S_OBJS := $(filter %.S,$(REMAIN)))
347 $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
348 $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S,$(1),$(obj))))
349
350 $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
351endef
352
353
354# NOTE: The line continuation '\' is required in the next define otherwise we
355# end up with a line-feed characer at the end of the last c filename.
356# Also bare this issue in mind if extending the list of supported filetypes.
357define SOURCES_TO_OBJS
358 $(notdir $(patsubst %.c,%.o,$(filter %.c,$(1)))) \
359 $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1))))
360endef
361
362define MAKE_BL
363 $(eval BUILD_DIR := ${BUILD_PLAT}/bl$(1))
364 $(eval SOURCES := $(BL$(1)_SOURCES) $(BL_COMMON_SOURCES) $(PLAT_BL_COMMON_SOURCES))
365 $(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
366 $(eval LINKERFILE := $(BUILD_DIR)/bl$(1).ld)
367 $(eval MAPFILE := $(BUILD_DIR)/bl$(1).map)
368 $(eval ELF := $(BUILD_DIR)/bl$(1).elf)
369 $(eval DUMP := $(BUILD_DIR)/bl$(1).dump)
370 $(eval BIN := $(BUILD_PLAT)/bl$(1).bin)
371
372 $(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES)))
373 $(eval $(call MAKE_LD,$(LINKERFILE),$(BL$(1)_LINKERFILE)))
374
375$(BUILD_DIR) :
376 $$(Q)mkdir -p "$$@"
377
378$(ELF) : $(OBJS) $(LINKERFILE)
379 @echo " LD $$@"
Jon Medhurstfb052462014-02-17 12:18:24 +0000380 @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__;' | \
381 $$(CC) $$(CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o
Jon Medhurst6d55d102014-02-12 15:54:48 +0000382 $$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \
Jeenu Viswambharan9f98aa12014-03-11 11:06:45 +0000383 $(BUILD_DIR)/build_message.o $(OBJS)
Jon Medhurst6d55d102014-02-12 15:54:48 +0000384
385$(DUMP) : $(ELF)
386 @echo " OD $$@"
387 $${Q}$${OD} -dx $$< > $$@
388
389$(BIN) : $(ELF)
390 @echo " BIN $$@"
391 $$(Q)$$(OC) -O binary $$< $$@
392 @echo
393 @echo "Built $$@ successfully"
394 @echo
395
396.PHONY : bl$(1)
397bl$(1) : $(BUILD_DIR) $(BIN) $(DUMP)
398
399all : bl$(1)
400
401$(eval FIP_DEPS += $(if $2,$(BIN),))
402$(eval FIP_ARGS += $(if $2,--bl$(1) $(BIN),))
403
404endef
405
406
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000407ifeq (${NEED_BL1},yes)
Jon Medhurst6d55d102014-02-12 15:54:48 +0000408$(eval $(call MAKE_BL,1))
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000409endif
Jon Medhurst6d55d102014-02-12 15:54:48 +0000410
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000411ifeq (${NEED_BL2},yes)
Jon Medhurst6d55d102014-02-12 15:54:48 +0000412$(eval $(call MAKE_BL,2,in_fip))
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000413endif
Jon Medhurst6d55d102014-02-12 15:54:48 +0000414
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000415ifeq (${NEED_BL31},yes)
Jon Medhurst6d55d102014-02-12 15:54:48 +0000416BL31_SOURCES += ${SPD_SOURCES}
417$(eval $(call MAKE_BL,31,in_fip))
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000418endif
Jon Medhurst6d55d102014-02-12 15:54:48 +0000419
420ifeq (${NEED_BL32},yes)
421$(eval $(call MAKE_BL,32,in_fip))
422endif
Ryan Harkin72ee3312014-01-15 16:55:07 +0000423
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100424ifeq (${NEED_BL30},yes)
425FIP_DEPS += ${BL30}
426FIP_ARGS += --bl30 ${BL30}
427endif
428
429ifeq (${NEED_BL30},yes)
430# If BL3-0 is needed by the platform then 'BL30' variable must be defined.
431check_bl30:
432 $(if ${BL30},,$(error "To build a FIP for platform ${PLAT}, please set BL30 to point to the SCP firmware"))
433else
434# If BL3-0 is not needed by the platform but the user still specified the path
435# to a BL3-0 image then warn him that it will be ignored.
436check_bl30:
437 $(if ${BL30},$(warning "BL3-0 is not supported on platform ${PLAT}, it will just be ignored"),)
438endif
439
440${BUILD_PLAT}/fip.bin: ${FIP_DEPS} ${BL33} ${FIPTOOL} check_bl30
Jon Medhurst4bfc2d22014-02-13 15:19:28 +0000441 $(if ${BL33},,$(error "To build a FIP, please set BL33 to point to the Normal World binary, eg: BL33=../uefi/FVP_AARCH64_EFI.fd"))
Harry Liebelf58ad362014-01-10 18:00:33 +0000442 ${Q}${FIPTOOL} --dump \
Achin Gupta375f5382014-02-18 18:12:48 +0000443 ${FIP_ARGS} \
Jon Medhurst6d55d102014-02-12 15:54:48 +0000444 --bl33 ${BL33} \
Harry Liebelf58ad362014-01-10 18:00:33 +0000445 $@
446 @echo
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +0000447 @echo "Built $@ successfully"
448 @echo
Harry Liebelf58ad362014-01-10 18:00:33 +0000449
450
Joakim Bech35fab8c2014-01-23 14:51:49 +0100451cscope:
452 @echo " CSCOPE"
453 ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
454 ${Q}cscope -b -q -k
455
Ryan Harkin72ee3312014-01-15 16:55:07 +0000456help:
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +0000457 @echo "usage: ${MAKE} PLAT=<${HELP_PLATFORMS}> <all|bl1|bl2|bl31|distclean|clean|checkcodebase|checkpatch>"
Ryan Harkin72ee3312014-01-15 16:55:07 +0000458 @echo ""
459 @echo "PLAT is used to specify which platform you wish to build."
Sandrine Bailleux08c7ed02014-03-21 13:16:35 +0000460 @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
Ryan Harkin72ee3312014-01-15 16:55:07 +0000461 @echo ""
462 @echo "Supported Targets:"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +0000463 @echo " all Build the BL1, BL2 and BL31 binaries"
Ian Spray36eaaf32014-01-30 17:25:28 +0000464 @echo " bl1 Build the BL1 binary"
Jeenu Viswambharan8aa559c2014-02-21 11:42:08 +0000465 @echo " bl2 Build the BL2 binary"
Ian Spray36eaaf32014-01-30 17:25:28 +0000466 @echo " bl31 Build the BL31 binary"
467 @echo " checkcodebase Check the coding style of the entire source tree"
468 @echo " checkpatch Check the coding style on changes in the current"
469 @echo " branch against BASE_COMMIT (default origin/master)"
470 @echo " clean Clean the build for the selected platform"
Harry Liebelf58ad362014-01-10 18:00:33 +0000471 @echo " cscope Generate cscope index"
Ian Spray36eaaf32014-01-30 17:25:28 +0000472 @echo " distclean Remove all build artifacts for all platforms"
Harry Liebelf58ad362014-01-10 18:00:33 +0000473 @echo " fiptool Build the Firmware Image Package(FIP) creation tool"
Ryan Harkin72ee3312014-01-15 16:55:07 +0000474 @echo ""
475 @echo "note: most build targets require PLAT to be set to a specific platform."
476 @echo ""
477 @echo "example: build all targets for the FVP platform:"
478 @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"