blob: 0e5d447524a19de7aa6859b8fd538ca0d37fd102 [file] [log] [blame]
Roberto Vargase92111a2018-05-22 16:05:42 +01001#
2# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3#
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
61$(LIB_DIR)/libwrappers.a: jmptbl.i $(WRAPPER_DIR)/jmpvar.o
62 @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
65$(BUILD_DIR)/jmptbl.s: jmptbl.i
66 @echo " TBL $@"
Sathees Balyad6839ef2018-10-31 14:05:08 +000067 if [ -e "../../$(PLAT_DIR)/jmptbl.i" ] ; \
68 then \
69 $(Q)./gentbl.sh -o $@ -b $(BUILD_DIR) ../../$(PLAT_DIR)/jmptbl.i; \
70 else \
71 @echo "USE_ROMLIB=1 requires jump table list file: jmptbl.i in platform directory"; \
72 fi
Roberto Vargase92111a2018-05-22 16:05:42 +010073
74clean:
75 @rm -f $(BUILD_DIR)/*
76
77-include $(BUILD_DIR)/romlib.d