Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 1 | # |
John Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 2 | # Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | AS = $(CROSS_COMPILE)as |
| 8 | LD = $(CROSS_COMPILE)ld |
| 9 | OC = $(CROSS_COMPILE)objcopy |
| 10 | CPP = $(CROSS_COMPILE)cpp |
| 11 | BUILD_DIR = ../../$(BUILD_PLAT)/romlib |
| 12 | LIB_DIR = ../../$(BUILD_PLAT)/lib |
| 13 | WRAPPER_DIR = ../../$(BUILD_PLAT)/libwrapper |
| 14 | LIBS = -lmbedtls -lfdt -lc |
| 15 | INC = $(INCLUDES:-I%=-I../../%) |
| 16 | PPFLAGS = $(INC) $(DEFINES) -P -D__ASSEMBLY__ -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld |
| 17 | OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o |
Sathees Balya | 34f2c3b | 2018-11-14 11:59:12 +0000 | [diff] [blame] | 18 | MAPFILE = ../../$(BUILD_PLAT)/romlib/romlib.map |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 19 | |
| 20 | V ?= 0 |
| 21 | ifeq ($(V),0) |
| 22 | Q := @ |
| 23 | else |
| 24 | Q := |
| 25 | endif |
| 26 | |
Louis Mayencourt | 70d4c9c | 2019-04-29 16:35:30 +0100 | [diff] [blame] | 27 | LDFLAGS := --gc-sections -O1 |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 28 | ifeq ($(DEBUG),1) |
Louis Mayencourt | 70d4c9c | 2019-04-29 16:35:30 +0100 | [diff] [blame] | 29 | LDFLAGS += -Map=$(MAPFILE) |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 30 | endif |
| 31 | |
| 32 | |
| 33 | .PHONY: all clean distclean |
| 34 | |
| 35 | all: $(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 Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 61 | $(LIB_DIR)/libwrappers.a: $(BUILD_DIR)/jmptbl.i $(WRAPPER_DIR)/jmpvar.o |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 62 | @echo " AR $@" |
Sathees Balya | d6839ef | 2018-10-31 14:05:08 +0000 | [diff] [blame] | 63 | $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ $(BUILD_DIR)/jmptbl.i |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 64 | |
John Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 65 | $(BUILD_DIR)/jmptbl.i: $(BUILD_DIR)/jmptbl.s |
| 66 | |
| 67 | $(BUILD_DIR)/jmptbl.s: ../../$(PLAT_DIR)/jmptbl.i |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 68 | @echo " TBL $@" |
John Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 69 | $(Q)./gentbl.sh -o $@ -b $(BUILD_DIR) ../../$(PLAT_DIR)/jmptbl.i |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 70 | |
| 71 | clean: |
| 72 | @rm -f $(BUILD_DIR)/* |
| 73 | |
| 74 | -include $(BUILD_DIR)/romlib.d |