Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | # |
| 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 |
| 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 \ |
| 96 | -Iarch/system/gic -Icommon/psci |
| 97 | |
Sandrine Bailleux | 3e850a8 | 2013-11-20 11:50:48 +0000 | [diff] [blame] | 98 | ASFLAGS += -Wa,--fatal-warnings -D__ASSEMBLY__ ${INCLUDES} |
| 99 | CFLAGS := -Wall -Werror -std=c99 -c -Os -DDEBUG=${DEBUG} ${INCLUDES} ${CFLAGS} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 100 | |
Sandrine Bailleux | 3e850a8 | 2013-11-20 11:50:48 +0000 | [diff] [blame] | 101 | LDFLAGS += --fatal-warnings -O1 |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 102 | BL1_LDFLAGS := -Map=${BL1_MAPFILE} --script ${BL1_LINKERFILE} --entry=${BL1_ENTRY_POINT} |
| 103 | BL2_LDFLAGS := -Map=${BL2_MAPFILE} --script ${BL2_LINKERFILE} --entry=${BL2_ENTRY_POINT} |
| 104 | BL31_LDFLAGS := -Map=${BL31_MAPFILE} --script ${BL31_LINKERFILE} --entry=${BL31_ENTRY_POINT} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 105 | |
| 106 | |
| 107 | vpath %.ld.S bl1:bl2:bl31 |
| 108 | vpath %.c bl1:bl2:bl31 |
| 109 | vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 110 | vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 111 | |
| 112 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 113 | ifneq (${DEBUG}, 0) |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 114 | #CFLAGS += -g -O0 |
| 115 | CFLAGS += -g |
| 116 | # -save-temps -fverbose-asm |
| 117 | ASFLAGS += -g -Wa,--gdwarf-2 |
| 118 | endif |
| 119 | |
| 120 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 121 | CC := ${CROSS_COMPILE}gcc |
| 122 | CPP := ${CROSS_COMPILE}cpp |
| 123 | AS := ${CROSS_COMPILE}gcc |
| 124 | AR := ${CROSS_COMPILE}ar |
| 125 | LD := ${CROSS_COMPILE}ld |
| 126 | OC := ${CROSS_COMPILE}objcopy |
| 127 | OD := ${CROSS_COMPILE}objdump |
| 128 | NM := ${CROSS_COMPILE}nm |
| 129 | PP := ${CROSS_COMPILE}gcc -E ${CFLAGS} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 130 | |
| 131 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 132 | bl1: ${BUILD_BL1} ${BUILD}/bl1.bin |
| 133 | bl2: ${BUILD_BL2} ${BUILD}/bl2.bin |
| 134 | bl31: ${BUILD_BL31} ${BUILD}/bl31.bin |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 135 | |
| 136 | clean: |
| 137 | @echo " CLEAN" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 138 | ${Q}rm -rf ${BUILD} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 139 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 140 | realclean distclean: |
| 141 | @echo " REALCLEAN" |
| 142 | ${Q}rm -rf ${BUILD_BASE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 143 | |
| 144 | dump: |
| 145 | @echo " OBJDUMP" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 146 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 152 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 153 | |
| 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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 163 | @echo " AS $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 164 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 173 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 174 | ${BUILD_BL31}/%.o: %.c |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 175 | @echo " CC $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 176 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 185 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 186 | ${BUILD_BL31}/%.ld: %.ld.S |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 187 | @echo " LDS $<" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 188 | ${Q}${AS} ${ASFLAGS} -P -E $< -o $@ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 189 | |
| 190 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 191 | ${BUILD_BL1}/bl1.elf: ${BL1_OBJS} ${BL1_LINKERFILE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 192 | @echo " LD $@" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 193 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 198 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 199 | ${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE} |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 200 | @echo " LD $@" |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 201 | ${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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 206 | @echo "Built $@ successfully" |
| 207 | @echo |
| 208 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 209 | ${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf |
| 210 | ${Q}${OC} -O binary $< $@ |
| 211 | @echo |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 212 | @echo "Built $@ successfully" |
| 213 | @echo |
| 214 | |
James Morrissey | eaaeece | 2013-11-01 13:56:59 +0000 | [diff] [blame] | 215 | ${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf |
| 216 | ${Q}${OC} -O binary $< $@ |
| 217 | @echo |
| 218 | @echo "Built $@ successfully" |
| 219 | @echo |