blob: bc05d0fa8439be620f1452452daa52a2a6d11f85 [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
Louis Mayencourt70d4c9c2019-04-29 16:35:30 +010027LDFLAGS := --gc-sections -O1
Roberto Vargase92111a2018-05-22 16:05:42 +010028ifeq ($(DEBUG),1)
Louis Mayencourt70d4c9c2019-04-29 16:35:30 +010029 LDFLAGS += -Map=$(MAPFILE)
Roberto Vargase92111a2018-05-22 16:05:42 +010030endif
31
John Tsichritzisf6ea99b2019-05-21 15:47:37 +010032ifeq (${ARM_ARCH_MINOR},0)
33 ASFLAGS = -march=armv8-a
34else
35 ASFLAGS = -march=armv8.${ARM_ARCH_MINOR}-a
36endif
Roberto Vargase92111a2018-05-22 16:05:42 +010037
38.PHONY: all clean distclean
39
40all: $(BUILD_DIR)/romlib.bin $(LIB_DIR)/libwrappers.a
41
42%.o: %.s
43 @echo " AS $@"
44 $(Q)$(AS) $(ASFLAGS) -o $@ $<
45
46$(BUILD_DIR)/%.o: %.s
47 @echo " AS $@"
48 $(Q)$(AS) $(ASFLAGS) -o $@ $<
49
50$(BUILD_DIR)/romlib.ld: romlib.ld.S
51 @echo " PP $@"
52 $(Q)$(CPP) $(PPFLAGS) -o $@ romlib.ld.S
53
54$(BUILD_DIR)/romlib.elf: $(OBJS) $(BUILD_DIR)/romlib.ld
55 @echo " LD $@"
56 $(Q)$(LD) -T $(BUILD_DIR)/romlib.ld -L$(LIB_DIR) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
57
58$(BUILD_DIR)/romlib.bin: $(BUILD_DIR)/romlib.elf
59 @echo " BIN $@"
60 $(Q)$(OC) -O binary $(BUILD_DIR)/romlib.elf $@
61
62$(WRAPPER_DIR)/jmpvar.s: $(BUILD_DIR)/romlib.elf
63 @echo " VAR $@"
64 $(Q)./genvar.sh -o $@ $(BUILD_DIR)/romlib.elf
65
John Tsichritzisaec19d32019-03-08 16:54:13 +000066$(LIB_DIR)/libwrappers.a: $(BUILD_DIR)/jmptbl.i $(WRAPPER_DIR)/jmpvar.o
Roberto Vargase92111a2018-05-22 16:05:42 +010067 @echo " AR $@"
John Tsichritzisf6ea99b2019-05-21 15:47:37 +010068 $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ --bti=$(ENABLE_BTI) --asflags=$(ASFLAGS) $(BUILD_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010069
John Tsichritzisaec19d32019-03-08 16:54:13 +000070$(BUILD_DIR)/jmptbl.i: $(BUILD_DIR)/jmptbl.s
71
72$(BUILD_DIR)/jmptbl.s: ../../$(PLAT_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010073 @echo " TBL $@"
John Tsichritzisf6ea99b2019-05-21 15:47:37 +010074 $(Q)./gentbl.sh -o $@ -b $(BUILD_DIR) --bti=$(ENABLE_BTI) ../../$(PLAT_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010075
76clean:
77 @rm -f $(BUILD_DIR)/*
78
79-include $(BUILD_DIR)/romlib.d