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 |
| 34 | KBUILD_VERBOSE = $(V) |
| 35 | else |
| 36 | KBUILD_VERBOSE = 0 |
| 37 | endif |
| 38 | |
| 39 | ifeq "$(KBUILD_VERBOSE)" "0" |
| 40 | Q=@ |
| 41 | else |
| 42 | Q= |
| 43 | endif |
| 44 | |
| 45 | DEBUG ?= 0 |
| 46 | BL_COMMON_OBJS = misc_helpers.o cache_helpers.o tlb_helpers.o \ |
| 47 | semihosting_call.o mmio.o pl011.o semihosting.o \ |
| 48 | std.o bl_common.o platform_helpers.o sysreg_helpers.o |
| 49 | |
| 50 | ARCH := aarch64 |
| 51 | |
| 52 | all: $(patsubst %,%.bin,bl1 bl2 bl31) ; |
| 53 | |
| 54 | |
| 55 | #$(info $(filter bl2.%, $(MAKECMDGOALS))) |
| 56 | #$(info $(filter bl1.%, $(MAKECMDGOALS))) |
| 57 | #$(info $(MAKECMDGOALS)) |
| 58 | |
| 59 | $(info Including bl1.mk) |
| 60 | include bl1/bl1.mk |
| 61 | |
| 62 | $(info Including bl2.mk) |
| 63 | include bl2/bl2.mk |
| 64 | |
| 65 | $(info Including bl31.mk) |
| 66 | include bl31/bl31.mk |
| 67 | |
| 68 | OBJS += $(BL_COMMON_OBJS) |
| 69 | |
| 70 | INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \ |
| 71 | -Idrivers/arm/interconnect/cci-400/ \ |
| 72 | -Idrivers/arm/peripherals/pl011/ \ |
| 73 | -Iplat/fvp -Idrivers/power \ |
| 74 | -Iarch/system/gic -Icommon/psci |
| 75 | |
| 76 | ASFLAGS += -D__ASSEMBLY__ $(INCLUDES) |
| 77 | CFLAGS := -Wall -std=c99 -c -Os -DDEBUG=$(DEBUG) $(INCLUDES) ${CFLAGS} |
| 78 | |
| 79 | LDFLAGS += -O1 |
| 80 | BL1_LDFLAGS := -Map=$(BL1_MAPFILE) --script $(BL1_LINKERFILE) --entry=$(BL1_ENTRY_POINT) |
| 81 | BL2_LDFLAGS := -Map=$(BL2_MAPFILE) --script $(BL2_LINKERFILE) --entry=$(BL2_ENTRY_POINT) |
| 82 | BL31_LDFLAGS := -Map=$(BL31_MAPFILE) --script $(BL31_LINKERFILE) --entry=$(BL31_ENTRY_POINT) |
| 83 | |
| 84 | |
| 85 | vpath %.ld.S bl1:bl2:bl31 |
| 86 | vpath %.c bl1:bl2:bl31 |
| 87 | vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 88 | vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH} |
| 89 | |
| 90 | |
| 91 | ifneq ($(DEBUG), 0) |
| 92 | #CFLAGS += -g -O0 |
| 93 | CFLAGS += -g |
| 94 | # -save-temps -fverbose-asm |
| 95 | ASFLAGS += -g -Wa,--gdwarf-2 |
| 96 | endif |
| 97 | |
| 98 | |
| 99 | CC = $(CROSS_COMPILE)gcc |
| 100 | CPP = $(CROSS_COMPILE)cpp |
| 101 | AS = $(CROSS_COMPILE)gcc |
| 102 | AR = $(CROSS_COMPILE)ar |
| 103 | LD = $(CROSS_COMPILE)ld |
| 104 | OC = $(CROSS_COMPILE)objcopy |
| 105 | OD = $(CROSS_COMPILE)objdump |
| 106 | NM = $(CROSS_COMPILE)nm |
| 107 | PP = $(CROSS_COMPILE)gcc -E $(CFLAGS) |
| 108 | |
| 109 | |
| 110 | distclean: clean |
| 111 | @echo " DISTCLEAN" |
| 112 | $(Q)rm -rf *.zi |
| 113 | $(Q)rm -rf *.dump |
| 114 | $(Q)rm -rf *.bin |
| 115 | $(Q)rm -f *.axf |
| 116 | $(Q)rm -f *.i *.s |
| 117 | $(Q)rm -f *.ar |
| 118 | $(Q)rm -f *.map |
| 119 | $(Q)rm -f *.scf |
| 120 | $(Q)rm -f *.txt |
| 121 | $(Q)rm -f *.elf |
| 122 | $(Q)rm -rf *.bin |
| 123 | $(Q)rm -f $(LISTFILE) |
| 124 | |
| 125 | clean: |
| 126 | @echo " CLEAN" |
| 127 | $(Q)rm -f *.o *.ld |
| 128 | |
| 129 | .PHONY: dump |
| 130 | |
| 131 | dump: |
| 132 | @echo " OBJDUMP" |
| 133 | $(OD) -d bl1.elf > bl1.dump |
| 134 | $(OD) -d bl2.elf > bl2.dump |
| 135 | $(OD) -d bl31.elf > bl31.dump |
| 136 | |
| 137 | %.o: %.S |
| 138 | @echo " AS $<" |
| 139 | $(Q)$(AS) $(ASFLAGS) -c $< -o $@ |
| 140 | |
| 141 | %.o: %.c |
| 142 | @echo " CC $<" |
| 143 | $(Q)$(CC) $(CFLAGS) -c $< -o $@ |
| 144 | |
| 145 | %.ld: %.ld.S |
| 146 | @echo " LDS $<" |
| 147 | $(Q)$(AS) $(ASFLAGS) -P -E $< -o $@ |
| 148 | |
| 149 | |
| 150 | bl1.elf: $(OBJS) $(BL1_OBJS) bl1.ld |
| 151 | @echo " LD $@" |
| 152 | $(Q)$(LD) -o $@ $(LDFLAGS) $(BL1_LDFLAGS) $(OBJS) $(BL1_OBJS) |
| 153 | @echo "Built $@ successfully" |
| 154 | @echo |
| 155 | |
| 156 | bl2.elf: $(OBJS) $(BL2_OBJS) bl2.ld |
| 157 | @echo " LD $@" |
| 158 | $(Q)$(LD) -o $@ $(LDFLAGS) $(BL2_LDFLAGS) $(OBJS) $(BL2_OBJS) |
| 159 | @echo "Built $@ successfully" |
| 160 | @echo |
| 161 | |
| 162 | bl31.elf: $(OBJS) $(BL31_OBJS) bl31.ld |
| 163 | @echo " LD $@" |
| 164 | $(Q)$(LD) -o $@ $(LDFLAGS) $(BL31_LDFLAGS) $(OBJS) $(BL31_OBJS) |
| 165 | @echo "Built $@ successfully" |
| 166 | @echo |
| 167 | |
| 168 | %.bin: %.elf |
| 169 | $(OC) -O binary $< $@ |