Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | # |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame^] | 2 | # Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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 |
| 33 | ifdef V |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 34 | KBUILD_VERBOSE = ${V} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 35 | else |
| 36 | KBUILD_VERBOSE = 0 |
| 37 | endif |
| 38 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 39 | ifeq "${KBUILD_VERBOSE}" "0" |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 40 | Q=@ |
| 41 | else |
| 42 | Q= |
| 43 | endif |
| 44 | |
| 45 | DEBUG ?= 0 |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 46 | |
| 47 | ifneq (${DEBUG}, 0) |
| 48 | BUILD_TYPE := debug |
| 49 | else |
| 50 | BUILD_TYPE := release |
| 51 | endif |
| 52 | |
| 53 | BL_COMMON_OBJS := misc_helpers.o cache_helpers.o tlb_helpers.o \ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 54 | semihosting_call.o mmio.o pl011.o semihosting.o \ |
| 55 | std.o bl_common.o platform_helpers.o sysreg_helpers.o |
| 56 | |
| 57 | ARCH := aarch64 |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 58 | PLAT := fvp |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 59 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 60 | BUILD_BASE:=./build |
| 61 | BUILD:=${BUILD_BASE}/${PLAT}/${BUILD_TYPE} |
| 62 | BUILD_BL1:=${BUILD}/bl1 |
| 63 | BUILD_BL2:=${BUILD}/bl2 |
| 64 | BUILD_BL31:=${BUILD}/bl31 |
| 65 | BUILD_DIRS:=${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 66 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 67 | all: bl1 bl2 bl31 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 68 | |
| 69 | $(info Including bl1.mk) |
| 70 | include bl1/bl1.mk |
| 71 | |
| 72 | $(info Including bl2.mk) |
| 73 | include bl2/bl2.mk |
| 74 | |
| 75 | $(info Including bl31.mk) |
| 76 | include bl31/bl31.mk |
| 77 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 78 | .PHONY: dump clean realclean distclean bl1 bl2 bl31 |
| 79 | .SUFFIXES: |
| 80 | |
| 81 | |
| 82 | BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS}) |
| 83 | BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS}) |
| 84 | BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS}) |
| 85 | BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE}) |
| 86 | BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE}) |
| 87 | BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE}) |
| 88 | BL1_LINKERFILE := $(addprefix ${BUILD_BL1}/,${BL1_LINKERFILE}) |
| 89 | BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE}) |
| 90 | BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE}) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 91 | |
| 92 | INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \ |
| 93 | -Idrivers/arm/interconnect/cci-400/ \ |
| 94 | -Idrivers/arm/peripherals/pl011/ \ |
| 95 | -Iplat/fvp -Idrivers/power \ |
Harry Liebel | c81b1d0 | 2013-12-17 18:31:42 +0000 | [diff] [blame] | 96 | -Iarch/system/gic -Icommon/psci \ |
| 97 | -Iinclude/stdlib -Iinclude/stdlib/sys |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 98 | |
Harry Liebel | 0af6d64 | 2013-12-20 18:51:12 +0000 | [diff] [blame] | 99 | ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ |
| 100 | -D__ASSEMBLY__ ${INCLUDES} |
Harry Liebel | e22fb91 | 2014-01-03 14:18:15 +0000 | [diff] [blame] | 101 | CFLAGS := -nostdinc -pedantic -ffreestanding -Wall -Werror \ |
| 102 | -std=c99 -c -Os -DDEBUG=${DEBUG} ${INCLUDES} ${CFLAGS} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 103 | |
Sandrine Bailleux | 3e850a8 | 2013-11-20 11:50:48 +0000 | [diff] [blame] | 104 | LDFLAGS += --fatal-warnings -O1 |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 105 | BL1_LDFLAGS := -Map=${BL1_MAPFILE} --script ${BL1_LINKERFILE} --entry=${BL1_ENTRY_POINT} |
| 106 | BL2_LDFLAGS := -Map=${BL2_MAPFILE} --script ${BL2_LINKERFILE} --entry=${BL2_ENTRY_POINT} |
| 107 | BL31_LDFLAGS := -Map=${BL31_MAPFILE} --script ${BL31_LINKERFILE} --entry=${BL31_ENTRY_POINT} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 108 | |
| 109 | |
| 110 | vpath %.ld.S bl1:bl2:bl31 |
| 111 | vpath %.c bl1:bl2:bl31 |
| 112 | vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 113 | vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 114 | |
| 115 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 116 | ifneq (${DEBUG}, 0) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 117 | #CFLAGS += -g -O0 |
| 118 | CFLAGS += -g |
| 119 | # -save-temps -fverbose-asm |
| 120 | ASFLAGS += -g -Wa,--gdwarf-2 |
| 121 | endif |
| 122 | |
| 123 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 124 | CC := ${CROSS_COMPILE}gcc |
| 125 | CPP := ${CROSS_COMPILE}cpp |
| 126 | AS := ${CROSS_COMPILE}gcc |
| 127 | AR := ${CROSS_COMPILE}ar |
| 128 | LD := ${CROSS_COMPILE}ld |
| 129 | OC := ${CROSS_COMPILE}objcopy |
| 130 | OD := ${CROSS_COMPILE}objdump |
| 131 | NM := ${CROSS_COMPILE}nm |
| 132 | PP := ${CROSS_COMPILE}gcc -E ${CFLAGS} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 133 | |
| 134 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 135 | bl1: ${BUILD_BL1} ${BUILD}/bl1.bin |
| 136 | bl2: ${BUILD_BL2} ${BUILD}/bl2.bin |
| 137 | bl31: ${BUILD_BL31} ${BUILD}/bl31.bin |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 138 | |
| 139 | clean: |
| 140 | @echo " CLEAN" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 141 | ${Q}rm -rf ${BUILD} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 142 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 143 | realclean distclean: |
| 144 | @echo " REALCLEAN" |
| 145 | ${Q}rm -rf ${BUILD_BASE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 146 | |
| 147 | dump: |
| 148 | @echo " OBJDUMP" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 149 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 155 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 156 | |
| 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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 166 | @echo " AS $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 167 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 176 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 177 | ${BUILD_BL31}/%.o: %.c |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 178 | @echo " CC $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 179 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 188 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 189 | ${BUILD_BL31}/%.ld: %.ld.S |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 190 | @echo " LDS $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 191 | ${Q}${AS} ${ASFLAGS} -P -E $< -o $@ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 192 | |
| 193 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 194 | ${BUILD_BL1}/bl1.elf: ${BL1_OBJS} ${BL1_LINKERFILE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 195 | @echo " LD $@" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 196 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 201 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 202 | ${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 203 | @echo " LD $@" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 204 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 209 | @echo "Built $@ successfully" |
| 210 | @echo |
| 211 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 212 | ${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf |
| 213 | ${Q}${OC} -O binary $< $@ |
| 214 | @echo |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 215 | @echo "Built $@ successfully" |
| 216 | @echo |
| 217 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 218 | ${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf |
| 219 | ${Q}${OC} -O binary $< $@ |
| 220 | @echo |
| 221 | @echo "Built $@ successfully" |
| 222 | @echo |