blob: 9a683f41c417e014c12ea7d04cc5780deebddb4b [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001#
2# Copyright (c) 2013, ARM Limited. All rights reserved.
3#
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
31# Decrease the verbosity of the make script
32# can be made verbose by passing V=1 at the make command line
33ifdef V
James Morrisseyeaaeece2013-11-01 13:56:59 +000034 KBUILD_VERBOSE = ${V}
Achin Gupta4f6ad662013-10-25 09:08:21 +010035else
36 KBUILD_VERBOSE = 0
37endif
38
James Morrisseyeaaeece2013-11-01 13:56:59 +000039ifeq "${KBUILD_VERBOSE}" "0"
Achin Gupta4f6ad662013-10-25 09:08:21 +010040 Q=@
41else
42 Q=
43endif
44
45DEBUG ?= 0
James Morrisseyeaaeece2013-11-01 13:56:59 +000046
47ifneq (${DEBUG}, 0)
48 BUILD_TYPE := debug
49else
50 BUILD_TYPE := release
51endif
52
53BL_COMMON_OBJS := misc_helpers.o cache_helpers.o tlb_helpers.o \
Achin Gupta4f6ad662013-10-25 09:08:21 +010054 semihosting_call.o mmio.o pl011.o semihosting.o \
55 std.o bl_common.o platform_helpers.o sysreg_helpers.o
56
57ARCH := aarch64
James Morrisseyeaaeece2013-11-01 13:56:59 +000058PLAT := fvp
Achin Gupta4f6ad662013-10-25 09:08:21 +010059
James Morrisseyeaaeece2013-11-01 13:56:59 +000060BUILD_BASE:=./build
61BUILD:=${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
62BUILD_BL1:=${BUILD}/bl1
63BUILD_BL2:=${BUILD}/bl2
64BUILD_BL31:=${BUILD}/bl31
65BUILD_DIRS:=${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31}
Achin Gupta4f6ad662013-10-25 09:08:21 +010066
James Morrisseyeaaeece2013-11-01 13:56:59 +000067all: bl1 bl2 bl31
Achin Gupta4f6ad662013-10-25 09:08:21 +010068
69$(info Including bl1.mk)
70include bl1/bl1.mk
71
72$(info Including bl2.mk)
73include bl2/bl2.mk
74
75$(info Including bl31.mk)
76include bl31/bl31.mk
77
James Morrisseyeaaeece2013-11-01 13:56:59 +000078.PHONY: dump clean realclean distclean bl1 bl2 bl31
79.SUFFIXES:
80
81
82BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS})
83BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS})
84BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS})
85BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE})
86BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE})
87BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE})
88BL1_LINKERFILE := $(addprefix ${BUILD_BL1}/,${BL1_LINKERFILE})
89BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE})
90BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE})
Achin Gupta4f6ad662013-10-25 09:08:21 +010091
92INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \
93 -Idrivers/arm/interconnect/cci-400/ \
94 -Idrivers/arm/peripherals/pl011/ \
95 -Iplat/fvp -Idrivers/power \
96 -Iarch/system/gic -Icommon/psci
97
98ASFLAGS += -D__ASSEMBLY__ $(INCLUDES)
99CFLAGS := -Wall -std=c99 -c -Os -DDEBUG=$(DEBUG) $(INCLUDES) ${CFLAGS}
100
101LDFLAGS += -O1
James Morrisseyeaaeece2013-11-01 13:56:59 +0000102BL1_LDFLAGS := -Map=${BL1_MAPFILE} --script ${BL1_LINKERFILE} --entry=${BL1_ENTRY_POINT}
103BL2_LDFLAGS := -Map=${BL2_MAPFILE} --script ${BL2_LINKERFILE} --entry=${BL2_ENTRY_POINT}
104BL31_LDFLAGS := -Map=${BL31_MAPFILE} --script ${BL31_LINKERFILE} --entry=${BL31_ENTRY_POINT}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100105
106
107vpath %.ld.S bl1:bl2:bl31
108vpath %.c bl1:bl2:bl31
109vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
110vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
111
112
James Morrisseyeaaeece2013-11-01 13:56:59 +0000113ifneq (${DEBUG}, 0)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100114#CFLAGS += -g -O0
115CFLAGS += -g
116# -save-temps -fverbose-asm
117ASFLAGS += -g -Wa,--gdwarf-2
118endif
119
120
James Morrisseyeaaeece2013-11-01 13:56:59 +0000121CC := ${CROSS_COMPILE}gcc
122CPP := ${CROSS_COMPILE}cpp
123AS := ${CROSS_COMPILE}gcc
124AR := ${CROSS_COMPILE}ar
125LD := ${CROSS_COMPILE}ld
126OC := ${CROSS_COMPILE}objcopy
127OD := ${CROSS_COMPILE}objdump
128NM := ${CROSS_COMPILE}nm
129PP := ${CROSS_COMPILE}gcc -E ${CFLAGS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100130
131
James Morrisseyeaaeece2013-11-01 13:56:59 +0000132bl1: ${BUILD_BL1} ${BUILD}/bl1.bin
133bl2: ${BUILD_BL2} ${BUILD}/bl2.bin
134bl31: ${BUILD_BL31} ${BUILD}/bl31.bin
Achin Gupta4f6ad662013-10-25 09:08:21 +0100135
136clean:
137 @echo " CLEAN"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000138 ${Q}rm -rf ${BUILD}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100139
James Morrisseyeaaeece2013-11-01 13:56:59 +0000140realclean distclean:
141 @echo " REALCLEAN"
142 ${Q}rm -rf ${BUILD_BASE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100143
144dump:
145 @echo " OBJDUMP"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000146 ${Q}${OD} -d ${BUILD_BL1}/bl1.elf > ${BUILD_BL1}/bl1.dump
147 ${Q}${OD} -d ${BUILD_BL2}/bl2.elf > ${BUILD_BL2}/bl2.dump
148 ${Q}${OD} -d ${BUILD_BL31}/bl31.elf > ${BUILD_BL31}/bl31.dump
149
150${BUILD_DIRS}:
151 ${Q}mkdir -p "$@"
Achin Gupta4f6ad662013-10-25 09:08:21 +0100152
James Morrisseyeaaeece2013-11-01 13:56:59 +0000153
154${BUILD_BL1}/%.o: %.S
155 @echo " AS $<"
156 ${Q}${AS} ${ASFLAGS} -c $< -o $@
157
158${BUILD_BL2}/%.o: %.S
159 @echo " AS $<"
160 ${Q}${AS} ${ASFLAGS} -c $< -o $@
161
162${BUILD_BL31}/%.o: %.S
Achin Gupta4f6ad662013-10-25 09:08:21 +0100163 @echo " AS $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000164 ${Q}${AS} ${ASFLAGS} -c $< -o $@
165
166${BUILD_BL1}/%.o: %.c
167 @echo " CC $<"
168 ${Q}${CC} ${CFLAGS} -c $< -o $@
169
170${BUILD_BL2}/%.o: %.c
171 @echo " CC $<"
172 ${Q}${CC} ${CFLAGS} -c $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100173
James Morrisseyeaaeece2013-11-01 13:56:59 +0000174${BUILD_BL31}/%.o: %.c
Achin Gupta4f6ad662013-10-25 09:08:21 +0100175 @echo " CC $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000176 ${Q}${CC} ${CFLAGS} -c $< -o $@
177
178${BUILD_BL1}/%.ld: %.ld.S
179 @echo " LDS $<"
180 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
181
182${BUILD_BL2}/%.ld: %.ld.S
183 @echo " LDS $<"
184 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100185
James Morrisseyeaaeece2013-11-01 13:56:59 +0000186${BUILD_BL31}/%.ld: %.ld.S
Achin Gupta4f6ad662013-10-25 09:08:21 +0100187 @echo " LDS $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000188 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100189
190
James Morrisseyeaaeece2013-11-01 13:56:59 +0000191${BUILD_BL1}/bl1.elf: ${BL1_OBJS} ${BL1_LINKERFILE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100192 @echo " LD $@"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000193 ${Q}${LD} -o $@ ${LDFLAGS} ${BL1_LDFLAGS} ${BL1_OBJS}
194
195${BUILD_BL2}/bl2.elf: ${BL2_OBJS} ${BL2_LINKERFILE}
196 @echo " LD $@"
197 ${Q}${LD} -o $@ ${LDFLAGS} ${BL2_LDFLAGS} ${BL2_OBJS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100198
James Morrisseyeaaeece2013-11-01 13:56:59 +0000199${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100200 @echo " LD $@"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000201 ${Q}${LD} -o $@ ${LDFLAGS} ${BL31_LDFLAGS} ${BL31_OBJS}
202
203${BUILD}/bl1.bin: ${BUILD_BL1}/bl1.elf
204 ${Q}${OC} -O binary $< $@
205 @echo
Achin Gupta4f6ad662013-10-25 09:08:21 +0100206 @echo "Built $@ successfully"
207 @echo
208
James Morrisseyeaaeece2013-11-01 13:56:59 +0000209${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf
210 ${Q}${OC} -O binary $< $@
211 @echo
Achin Gupta4f6ad662013-10-25 09:08:21 +0100212 @echo "Built $@ successfully"
213 @echo
214
James Morrisseyeaaeece2013-11-01 13:56:59 +0000215${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf
216 ${Q}${OC} -O binary $< $@
217 @echo
218 @echo "Built $@ successfully"
219 @echo