blob: cec94043dd23accd2d47c00656d70486c1581345 [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
Imre Kis2d137c52019-07-09 18:30:58 +02008AR = $(CROSS_COMPILE)ar
Roberto Vargase92111a2018-05-22 16:05:42 +01009LD = $(CROSS_COMPILE)ld
10OC = $(CROSS_COMPILE)objcopy
11CPP = $(CROSS_COMPILE)cpp
Imre Kis2d137c52019-07-09 18:30:58 +020012ROMLIB_GEN = ./romlib_generator.py
Roberto Vargase92111a2018-05-22 16:05:42 +010013BUILD_DIR = ../../$(BUILD_PLAT)/romlib
14LIB_DIR = ../../$(BUILD_PLAT)/lib
15WRAPPER_DIR = ../../$(BUILD_PLAT)/libwrapper
16LIBS = -lmbedtls -lfdt -lc
17INC = $(INCLUDES:-I%=-I../../%)
Julius Werner53456fc2019-07-09 13:49:11 -070018PPFLAGS = $(INC) $(DEFINES) -P -x assembler-with-cpp -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld
Roberto Vargase92111a2018-05-22 16:05:42 +010019OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o
Sathees Balya34f2c3b2018-11-14 11:59:12 +000020MAPFILE = ../../$(BUILD_PLAT)/romlib/romlib.map
Roberto Vargase92111a2018-05-22 16:05:42 +010021
Imre Kis2d137c52019-07-09 18:30:58 +020022ifneq ($(PLAT_DIR),)
23 WRAPPER_SOURCES = $(shell $(ROMLIB_GEN) genwrappers -b $(WRAPPER_DIR) --list ../../$(PLAT_DIR)/jmptbl.i)
24 WRAPPER_OBJS = $(WRAPPER_SOURCES:.s=.o)
25endif
26
Roberto Vargase92111a2018-05-22 16:05:42 +010027V ?= 0
28ifeq ($(V),0)
29 Q := @
30else
31 Q :=
32endif
33
Louis Mayencourt70d4c9c2019-04-29 16:35:30 +010034LDFLAGS := --gc-sections -O1
Roberto Vargase92111a2018-05-22 16:05:42 +010035ifeq ($(DEBUG),1)
Louis Mayencourt70d4c9c2019-04-29 16:35:30 +010036 LDFLAGS += -Map=$(MAPFILE)
Roberto Vargase92111a2018-05-22 16:05:42 +010037endif
38
John Tsichritzisf6ea99b2019-05-21 15:47:37 +010039ifeq (${ARM_ARCH_MINOR},0)
40 ASFLAGS = -march=armv8-a
41else
42 ASFLAGS = -march=armv8.${ARM_ARCH_MINOR}-a
43endif
Roberto Vargase92111a2018-05-22 16:05:42 +010044
45.PHONY: all clean distclean
46
47all: $(BUILD_DIR)/romlib.bin $(LIB_DIR)/libwrappers.a
48
49%.o: %.s
50 @echo " AS $@"
51 $(Q)$(AS) $(ASFLAGS) -o $@ $<
52
53$(BUILD_DIR)/%.o: %.s
54 @echo " AS $@"
55 $(Q)$(AS) $(ASFLAGS) -o $@ $<
56
57$(BUILD_DIR)/romlib.ld: romlib.ld.S
58 @echo " PP $@"
59 $(Q)$(CPP) $(PPFLAGS) -o $@ romlib.ld.S
60
61$(BUILD_DIR)/romlib.elf: $(OBJS) $(BUILD_DIR)/romlib.ld
62 @echo " LD $@"
63 $(Q)$(LD) -T $(BUILD_DIR)/romlib.ld -L$(LIB_DIR) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
64
65$(BUILD_DIR)/romlib.bin: $(BUILD_DIR)/romlib.elf
66 @echo " BIN $@"
67 $(Q)$(OC) -O binary $(BUILD_DIR)/romlib.elf $@
68
69$(WRAPPER_DIR)/jmpvar.s: $(BUILD_DIR)/romlib.elf
70 @echo " VAR $@"
Imre Kis2d137c52019-07-09 18:30:58 +020071 $(Q)$(ROMLIB_GEN) genvar --output $@ $<
Roberto Vargase92111a2018-05-22 16:05:42 +010072
Imre Kis2d137c52019-07-09 18:30:58 +020073$(LIB_DIR)/libwrappers.a: $(WRAPPER_DIR)/jmpvar.o $(WRAPPER_OBJS)
Roberto Vargase92111a2018-05-22 16:05:42 +010074 @echo " AR $@"
Imre Kis2d137c52019-07-09 18:30:58 +020075 $(Q)$(AR) -rc $@ $(WRAPPER_DIR)/jmpvar.o $(WRAPPER_OBJS)
76
77$(BUILD_DIR)/jmptbl.i: ../../$(PLAT_DIR)/jmptbl.i
78 @echo " PRE $@"
79 $(Q)$(ROMLIB_GEN) pre --output $@ --deps $(BUILD_DIR)/jmptbl.d $<
Roberto Vargase92111a2018-05-22 16:05:42 +010080
Imre Kis2d137c52019-07-09 18:30:58 +020081$(BUILD_DIR)/wrappers.stamp: $(BUILD_DIR)/jmptbl.i
82 @echo " WRP $<"
83 $(Q)$(ROMLIB_GEN) genwrappers --bti=$(ENABLE_BTI) -b $(WRAPPER_DIR) $<
84 @touch $@
John Tsichritzisaec19d32019-03-08 16:54:13 +000085
Imre Kis2d137c52019-07-09 18:30:58 +020086$(WRAPPER_SOURCES): $(BUILD_DIR)/wrappers.stamp
87
88$(WRAPPER_OBJS): $(WRAPPER_SOURCES) $(BUILD_DIR)/wrappers.stamp
89
90$(BUILD_DIR)/jmptbl.s: $(BUILD_DIR)/jmptbl.i
Roberto Vargase92111a2018-05-22 16:05:42 +010091 @echo " TBL $@"
Imre Kis2d137c52019-07-09 18:30:58 +020092 $(Q)$(ROMLIB_GEN) gentbl --output $@ --bti=$(ENABLE_BTI) $<
Roberto Vargase92111a2018-05-22 16:05:42 +010093
94clean:
95 @rm -f $(BUILD_DIR)/*
96
97-include $(BUILD_DIR)/romlib.d
Imre Kis2d137c52019-07-09 18:30:58 +020098-include $(BUILD_DIR)/jmptbl.d