blob: 5aa9ee8787126a90bc8c9f4dd593a342f50506ad [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
34 KBUILD_VERBOSE = $(V)
35else
36 KBUILD_VERBOSE = 0
37endif
38
39ifeq "$(KBUILD_VERBOSE)" "0"
40 Q=@
41else
42 Q=
43endif
44
45DEBUG ?= 0
46BL_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
50ARCH := aarch64
51
52all: $(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)
60include bl1/bl1.mk
61
62$(info Including bl2.mk)
63include bl2/bl2.mk
64
65$(info Including bl31.mk)
66include bl31/bl31.mk
67
68OBJS += $(BL_COMMON_OBJS)
69
70INCLUDES += -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
76ASFLAGS += -D__ASSEMBLY__ $(INCLUDES)
77CFLAGS := -Wall -std=c99 -c -Os -DDEBUG=$(DEBUG) $(INCLUDES) ${CFLAGS}
78
79LDFLAGS += -O1
80BL1_LDFLAGS := -Map=$(BL1_MAPFILE) --script $(BL1_LINKERFILE) --entry=$(BL1_ENTRY_POINT)
81BL2_LDFLAGS := -Map=$(BL2_MAPFILE) --script $(BL2_LINKERFILE) --entry=$(BL2_ENTRY_POINT)
82BL31_LDFLAGS := -Map=$(BL31_MAPFILE) --script $(BL31_LINKERFILE) --entry=$(BL31_ENTRY_POINT)
83
84
85vpath %.ld.S bl1:bl2:bl31
86vpath %.c bl1:bl2:bl31
87vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
88vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
89
90
91ifneq ($(DEBUG), 0)
92#CFLAGS += -g -O0
93CFLAGS += -g
94# -save-temps -fverbose-asm
95ASFLAGS += -g -Wa,--gdwarf-2
96endif
97
98
99CC = $(CROSS_COMPILE)gcc
100CPP = $(CROSS_COMPILE)cpp
101AS = $(CROSS_COMPILE)gcc
102AR = $(CROSS_COMPILE)ar
103LD = $(CROSS_COMPILE)ld
104OC = $(CROSS_COMPILE)objcopy
105OD = $(CROSS_COMPILE)objdump
106NM = $(CROSS_COMPILE)nm
107PP = $(CROSS_COMPILE)gcc -E $(CFLAGS)
108
109
110distclean: 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
125clean:
126 @echo " CLEAN"
127 $(Q)rm -f *.o *.ld
128
129.PHONY: dump
130
131dump:
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
150bl1.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
156bl2.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
162bl31.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 $< $@