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 |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 8 | AR = $(CROSS_COMPILE)ar |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 9 | LD = $(CROSS_COMPILE)ld |
| 10 | OC = $(CROSS_COMPILE)objcopy |
| 11 | CPP = $(CROSS_COMPILE)cpp |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 12 | ROMLIB_GEN = ./romlib_generator.py |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 13 | BUILD_DIR = ../../$(BUILD_PLAT)/romlib |
| 14 | LIB_DIR = ../../$(BUILD_PLAT)/lib |
| 15 | WRAPPER_DIR = ../../$(BUILD_PLAT)/libwrapper |
| 16 | LIBS = -lmbedtls -lfdt -lc |
| 17 | INC = $(INCLUDES:-I%=-I../../%) |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 18 | PPFLAGS = $(INC) $(DEFINES) -P -x assembler-with-cpp -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 19 | OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o |
Sathees Balya | 34f2c3b | 2018-11-14 11:59:12 +0000 | [diff] [blame] | 20 | MAPFILE = ../../$(BUILD_PLAT)/romlib/romlib.map |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 21 | |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 22 | ifneq ($(PLAT_DIR),) |
| 23 | WRAPPER_SOURCES = $(shell $(ROMLIB_GEN) genwrappers -b $(WRAPPER_DIR) --list ../../$(PLAT_DIR)/jmptbl.i) |
| 24 | WRAPPER_OBJS = $(WRAPPER_SOURCES:.s=.o) |
| 25 | endif |
| 26 | |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 27 | V ?= 0 |
| 28 | ifeq ($(V),0) |
| 29 | Q := @ |
| 30 | else |
| 31 | Q := |
| 32 | endif |
| 33 | |
Louis Mayencourt | 70d4c9c | 2019-04-29 16:35:30 +0100 | [diff] [blame] | 34 | LDFLAGS := --gc-sections -O1 |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 35 | ifeq ($(DEBUG),1) |
Louis Mayencourt | 70d4c9c | 2019-04-29 16:35:30 +0100 | [diff] [blame] | 36 | LDFLAGS += -Map=$(MAPFILE) |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 37 | endif |
| 38 | |
John Tsichritzis | f6ea99b | 2019-05-21 15:47:37 +0100 | [diff] [blame] | 39 | ifeq (${ARM_ARCH_MINOR},0) |
| 40 | ASFLAGS = -march=armv8-a |
| 41 | else |
| 42 | ASFLAGS = -march=armv8.${ARM_ARCH_MINOR}-a |
| 43 | endif |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 44 | |
| 45 | .PHONY: all clean distclean |
| 46 | |
| 47 | all: $(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 Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 71 | $(Q)$(ROMLIB_GEN) genvar --output $@ $< |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 72 | |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 73 | $(LIB_DIR)/libwrappers.a: $(WRAPPER_DIR)/jmpvar.o $(WRAPPER_OBJS) |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 74 | @echo " AR $@" |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 75 | $(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 Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 80 | |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 81 | $(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 Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 85 | |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 86 | $(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 Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 91 | @echo " TBL $@" |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 92 | $(Q)$(ROMLIB_GEN) gentbl --output $@ --bti=$(ENABLE_BTI) $< |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 93 | |
| 94 | clean: |
| 95 | @rm -f $(BUILD_DIR)/* |
| 96 | |
| 97 | -include $(BUILD_DIR)/romlib.d |
Imre Kis | 2d137c5 | 2019-07-09 18:30:58 +0200 | [diff] [blame] | 98 | -include $(BUILD_DIR)/jmptbl.d |