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 |
| 18 | |
| 19 | V ?= 0 |
| 20 | ifeq ($(V),0) |
| 21 | Q := @ |
| 22 | else |
| 23 | Q := |
| 24 | endif |
| 25 | |
| 26 | ifeq ($(DEBUG),1) |
| 27 | CFLAGS := -g |
| 28 | LDFLAGS := -g |
| 29 | endif |
| 30 | |
| 31 | |
| 32 | .PHONY: all clean distclean |
| 33 | |
| 34 | all: $(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 | |
| 68 | clean: |
| 69 | @rm -f $(BUILD_DIR)/* |
| 70 | |
| 71 | -include $(BUILD_DIR)/romlib.d |