blob: 46b920682d5e260afc1cdf59bf1c1e9469ad8a45 [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
18
19V ?= 0
20ifeq ($(V),0)
21 Q := @
22else
23 Q :=
24endif
25
26ifeq ($(DEBUG),1)
27 CFLAGS := -g
28 LDFLAGS := -g
29endif
30
31
32.PHONY: all clean distclean
33
34all: $(BUILD_DIR)/romlib.bin $(LIB_DIR)/libwrappers.a
35
36%.o: %.s
37 @echo " AS $@"
38 $(Q)$(AS) $(ASFLAGS) -o $@ $<
39
40$(BUILD_DIR)/%.o: %.s
41 @echo " AS $@"
42 $(Q)$(AS) $(ASFLAGS) -o $@ $<
43
44$(BUILD_DIR)/romlib.ld: romlib.ld.S
45 @echo " PP $@"
46 $(Q)$(CPP) $(PPFLAGS) -o $@ romlib.ld.S
47
48$(BUILD_DIR)/romlib.elf: $(OBJS) $(BUILD_DIR)/romlib.ld
49 @echo " LD $@"
50 $(Q)$(LD) -T $(BUILD_DIR)/romlib.ld -L$(LIB_DIR) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
51
52$(BUILD_DIR)/romlib.bin: $(BUILD_DIR)/romlib.elf
53 @echo " BIN $@"
54 $(Q)$(OC) -O binary $(BUILD_DIR)/romlib.elf $@
55
56$(WRAPPER_DIR)/jmpvar.s: $(BUILD_DIR)/romlib.elf
57 @echo " VAR $@"
58 $(Q)./genvar.sh -o $@ $(BUILD_DIR)/romlib.elf
59
60$(LIB_DIR)/libwrappers.a: jmptbl.i $(WRAPPER_DIR)/jmpvar.o
61 @echo " AR $@"
62 $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ jmptbl.i
63
64$(BUILD_DIR)/jmptbl.s: jmptbl.i
65 @echo " TBL $@"
66 $(Q)./gentbl.sh -o $@ jmptbl.i
67
68clean:
69 @rm -f $(BUILD_DIR)/*
70
71-include $(BUILD_DIR)/romlib.d