blob: 1f009a51536a732bdc1895029754db67d35cbb16 [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
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 \
Harry Liebelc81b1d02013-12-17 18:31:42 +000096 -Iarch/system/gic -Icommon/psci \
97 -Iinclude/stdlib -Iinclude/stdlib/sys
Achin Gupta4f6ad662013-10-25 09:08:21 +010098
Harry Liebel0af6d642013-12-20 18:51:12 +000099ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
100 -D__ASSEMBLY__ ${INCLUDES}
Harry Liebele22fb912014-01-03 14:18:15 +0000101CFLAGS := -nostdinc -pedantic -ffreestanding -Wall -Werror \
102 -std=c99 -c -Os -DDEBUG=${DEBUG} ${INCLUDES} ${CFLAGS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100103
Sandrine Bailleux3e850a82013-11-20 11:50:48 +0000104LDFLAGS += --fatal-warnings -O1
James Morrisseyeaaeece2013-11-01 13:56:59 +0000105BL1_LDFLAGS := -Map=${BL1_MAPFILE} --script ${BL1_LINKERFILE} --entry=${BL1_ENTRY_POINT}
106BL2_LDFLAGS := -Map=${BL2_MAPFILE} --script ${BL2_LINKERFILE} --entry=${BL2_ENTRY_POINT}
107BL31_LDFLAGS := -Map=${BL31_MAPFILE} --script ${BL31_LINKERFILE} --entry=${BL31_ENTRY_POINT}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108
109
110vpath %.ld.S bl1:bl2:bl31
111vpath %.c bl1:bl2:bl31
112vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
113vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
114
115
James Morrisseyeaaeece2013-11-01 13:56:59 +0000116ifneq (${DEBUG}, 0)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100117#CFLAGS += -g -O0
118CFLAGS += -g
119# -save-temps -fverbose-asm
120ASFLAGS += -g -Wa,--gdwarf-2
121endif
122
123
James Morrisseyeaaeece2013-11-01 13:56:59 +0000124CC := ${CROSS_COMPILE}gcc
125CPP := ${CROSS_COMPILE}cpp
126AS := ${CROSS_COMPILE}gcc
127AR := ${CROSS_COMPILE}ar
128LD := ${CROSS_COMPILE}ld
129OC := ${CROSS_COMPILE}objcopy
130OD := ${CROSS_COMPILE}objdump
131NM := ${CROSS_COMPILE}nm
132PP := ${CROSS_COMPILE}gcc -E ${CFLAGS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100133
134
James Morrisseyeaaeece2013-11-01 13:56:59 +0000135bl1: ${BUILD_BL1} ${BUILD}/bl1.bin
136bl2: ${BUILD_BL2} ${BUILD}/bl2.bin
137bl31: ${BUILD_BL31} ${BUILD}/bl31.bin
Achin Gupta4f6ad662013-10-25 09:08:21 +0100138
139clean:
140 @echo " CLEAN"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000141 ${Q}rm -rf ${BUILD}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100142
James Morrisseyeaaeece2013-11-01 13:56:59 +0000143realclean distclean:
144 @echo " REALCLEAN"
145 ${Q}rm -rf ${BUILD_BASE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100146
147dump:
148 @echo " OBJDUMP"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000149 ${Q}${OD} -d ${BUILD_BL1}/bl1.elf > ${BUILD_BL1}/bl1.dump
150 ${Q}${OD} -d ${BUILD_BL2}/bl2.elf > ${BUILD_BL2}/bl2.dump
151 ${Q}${OD} -d ${BUILD_BL31}/bl31.elf > ${BUILD_BL31}/bl31.dump
152
153${BUILD_DIRS}:
154 ${Q}mkdir -p "$@"
Achin Gupta4f6ad662013-10-25 09:08:21 +0100155
James Morrisseyeaaeece2013-11-01 13:56:59 +0000156
157${BUILD_BL1}/%.o: %.S
158 @echo " AS $<"
159 ${Q}${AS} ${ASFLAGS} -c $< -o $@
160
161${BUILD_BL2}/%.o: %.S
162 @echo " AS $<"
163 ${Q}${AS} ${ASFLAGS} -c $< -o $@
164
165${BUILD_BL31}/%.o: %.S
Achin Gupta4f6ad662013-10-25 09:08:21 +0100166 @echo " AS $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000167 ${Q}${AS} ${ASFLAGS} -c $< -o $@
168
169${BUILD_BL1}/%.o: %.c
170 @echo " CC $<"
171 ${Q}${CC} ${CFLAGS} -c $< -o $@
172
173${BUILD_BL2}/%.o: %.c
174 @echo " CC $<"
175 ${Q}${CC} ${CFLAGS} -c $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100176
James Morrisseyeaaeece2013-11-01 13:56:59 +0000177${BUILD_BL31}/%.o: %.c
Achin Gupta4f6ad662013-10-25 09:08:21 +0100178 @echo " CC $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000179 ${Q}${CC} ${CFLAGS} -c $< -o $@
180
181${BUILD_BL1}/%.ld: %.ld.S
182 @echo " LDS $<"
183 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
184
185${BUILD_BL2}/%.ld: %.ld.S
186 @echo " LDS $<"
187 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100188
James Morrisseyeaaeece2013-11-01 13:56:59 +0000189${BUILD_BL31}/%.ld: %.ld.S
Achin Gupta4f6ad662013-10-25 09:08:21 +0100190 @echo " LDS $<"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000191 ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
Achin Gupta4f6ad662013-10-25 09:08:21 +0100192
193
James Morrisseyeaaeece2013-11-01 13:56:59 +0000194${BUILD_BL1}/bl1.elf: ${BL1_OBJS} ${BL1_LINKERFILE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100195 @echo " LD $@"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000196 ${Q}${LD} -o $@ ${LDFLAGS} ${BL1_LDFLAGS} ${BL1_OBJS}
197
198${BUILD_BL2}/bl2.elf: ${BL2_OBJS} ${BL2_LINKERFILE}
199 @echo " LD $@"
200 ${Q}${LD} -o $@ ${LDFLAGS} ${BL2_LDFLAGS} ${BL2_OBJS}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100201
James Morrisseyeaaeece2013-11-01 13:56:59 +0000202${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE}
Achin Gupta4f6ad662013-10-25 09:08:21 +0100203 @echo " LD $@"
James Morrisseyeaaeece2013-11-01 13:56:59 +0000204 ${Q}${LD} -o $@ ${LDFLAGS} ${BL31_LDFLAGS} ${BL31_OBJS}
205
206${BUILD}/bl1.bin: ${BUILD_BL1}/bl1.elf
207 ${Q}${OC} -O binary $< $@
208 @echo
Achin Gupta4f6ad662013-10-25 09:08:21 +0100209 @echo "Built $@ successfully"
210 @echo
211
James Morrisseyeaaeece2013-11-01 13:56:59 +0000212${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf
213 ${Q}${OC} -O binary $< $@
214 @echo
Achin Gupta4f6ad662013-10-25 09:08:21 +0100215 @echo "Built $@ successfully"
216 @echo
217
James Morrisseyeaaeece2013-11-01 13:56:59 +0000218${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf
219 ${Q}${OC} -O binary $< $@
220 @echo
221 @echo "Built $@ successfully"
222 @echo