blob: 12fdfa8eaa82e25f9869d0d3c4cb6a15bac1f9ef [file] [log] [blame]
Roberto Vargase92111a2018-05-22 16:05:42 +01001#
John Tsichritzisaec19d32019-03-08 16:54:13 +00002# Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Roberto Vargase92111a2018-05-22 16:05:42 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7AS = $(CROSS_COMPILE)as
8LD = $(CROSS_COMPILE)ld
9OC = $(CROSS_COMPILE)objcopy
10CPP = $(CROSS_COMPILE)cpp
11BUILD_DIR = ../../$(BUILD_PLAT)/romlib
12LIB_DIR = ../../$(BUILD_PLAT)/lib
13WRAPPER_DIR = ../../$(BUILD_PLAT)/libwrapper
14LIBS = -lmbedtls -lfdt -lc
15INC = $(INCLUDES:-I%=-I../../%)
16PPFLAGS = $(INC) $(DEFINES) -P -D__ASSEMBLY__ -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld
17OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o
Sathees Balya34f2c3b2018-11-14 11:59:12 +000018MAPFILE = ../../$(BUILD_PLAT)/romlib/romlib.map
Roberto Vargase92111a2018-05-22 16:05:42 +010019
20V ?= 0
21ifeq ($(V),0)
22 Q := @
23else
24 Q :=
25endif
26
27ifeq ($(DEBUG),1)
28 CFLAGS := -g
Sathees Balya34f2c3b2018-11-14 11:59:12 +000029 LDFLAGS := -g --gc-sections -O1 -Map=$(MAPFILE)
Roberto Vargase92111a2018-05-22 16:05:42 +010030endif
31
32
33.PHONY: all clean distclean
34
35all: $(BUILD_DIR)/romlib.bin $(LIB_DIR)/libwrappers.a
36
37%.o: %.s
38 @echo " AS $@"
39 $(Q)$(AS) $(ASFLAGS) -o $@ $<
40
41$(BUILD_DIR)/%.o: %.s
42 @echo " AS $@"
43 $(Q)$(AS) $(ASFLAGS) -o $@ $<
44
45$(BUILD_DIR)/romlib.ld: romlib.ld.S
46 @echo " PP $@"
47 $(Q)$(CPP) $(PPFLAGS) -o $@ romlib.ld.S
48
49$(BUILD_DIR)/romlib.elf: $(OBJS) $(BUILD_DIR)/romlib.ld
50 @echo " LD $@"
51 $(Q)$(LD) -T $(BUILD_DIR)/romlib.ld -L$(LIB_DIR) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
52
53$(BUILD_DIR)/romlib.bin: $(BUILD_DIR)/romlib.elf
54 @echo " BIN $@"
55 $(Q)$(OC) -O binary $(BUILD_DIR)/romlib.elf $@
56
57$(WRAPPER_DIR)/jmpvar.s: $(BUILD_DIR)/romlib.elf
58 @echo " VAR $@"
59 $(Q)./genvar.sh -o $@ $(BUILD_DIR)/romlib.elf
60
John Tsichritzisaec19d32019-03-08 16:54:13 +000061$(LIB_DIR)/libwrappers.a: $(BUILD_DIR)/jmptbl.i $(WRAPPER_DIR)/jmpvar.o
Roberto Vargase92111a2018-05-22 16:05:42 +010062 @echo " AR $@"
Sathees Balyad6839ef2018-10-31 14:05:08 +000063 $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ $(BUILD_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010064
John Tsichritzisaec19d32019-03-08 16:54:13 +000065$(BUILD_DIR)/jmptbl.i: $(BUILD_DIR)/jmptbl.s
66
67$(BUILD_DIR)/jmptbl.s: ../../$(PLAT_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010068 @echo " TBL $@"
John Tsichritzisaec19d32019-03-08 16:54:13 +000069 $(Q)./gentbl.sh -o $@ -b $(BUILD_DIR) ../../$(PLAT_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010070
71clean:
72 @rm -f $(BUILD_DIR)/*
73
74-include $(BUILD_DIR)/romlib.d