Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 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 | |
| 27 | ifeq ($(DEBUG),1) |
| 28 | CFLAGS := -g |
Sathees Balya | 34f2c3b | 2018-11-14 11:59:12 +0000 | [diff] [blame] | 29 | LDFLAGS := -g --gc-sections -O1 -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 | |
| 61 | $(LIB_DIR)/libwrappers.a: jmptbl.i $(WRAPPER_DIR)/jmpvar.o |
| 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 | |
| 65 | $(BUILD_DIR)/jmptbl.s: jmptbl.i |
| 66 | @echo " TBL $@" |
Sathees Balya | d6839ef | 2018-10-31 14:05:08 +0000 | [diff] [blame] | 67 | 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 Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 73 | |
| 74 | clean: |
| 75 | @rm -f $(BUILD_DIR)/* |
| 76 | |
| 77 | -include $(BUILD_DIR)/romlib.d |