mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-17 01:54:22 +00:00

This commit streamlines directory creation by introducing a single pattern rule to automatically make directories for which there is a dependency. We currently use several macros to generate rules to create directories upon dependence, which is a significant amount of code and a lot of redundancy. The rule introduced by this change represents a catch-all: any rule dependency on a path ending in a forward slash is automatically created. Now, rules can rely on an unordered dependency (`|`) on `$$(@D)/` which, when secondary expansion is enabled, expands to the directory of the target being built, e.g.: build/main.o: main.c | $$(@D)/ # automatically creates `build/` Change-Id: I7e554efa2ac850e779bb302fd9c7fbb239886c9f Signed-off-by: Chris Kay <chris.kay@arm.com>
122 lines
3.3 KiB
Makefile
122 lines
3.3 KiB
Makefile
#
|
|
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
|
|
# Copyright (c) 2020, Renesas Electronics Corporation. All rights reserved.
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
#
|
|
|
|
toolchains := aarch64
|
|
|
|
include ../../../make_helpers/build-rules.mk
|
|
include ../../../make_helpers/common.mk
|
|
include ../../../make_helpers/toolchain.mk
|
|
|
|
###################################################
|
|
# makefile
|
|
###################################################
|
|
|
|
#output file name
|
|
FILE_NAME_SA0 = bootparam_sa0
|
|
FILE_NAME_SA6 = cert_header_sa6
|
|
|
|
OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
|
|
OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
|
|
|
|
#object file name
|
|
OBJ_FILE_SA0 = sa0.o
|
|
OBJ_FILE_SA6 = sa6.o
|
|
|
|
#linker script name
|
|
MEMORY_DEF_SA0 = sa0.ld.S
|
|
MEMORY_DEF_SA6 = sa6.ld.S
|
|
|
|
###################################################
|
|
# Convenience function for adding build definitions
|
|
# $(eval $(call add_define,FOO)) will have:
|
|
# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
|
|
define add_define
|
|
DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
|
|
endef
|
|
|
|
# Process RCAR_SA0_SIZE flag
|
|
ifndef RCAR_SA0_SIZE
|
|
RCAR_SA0_SIZE := 1
|
|
else
|
|
ifeq (${RCAR_SA0_SIZE},0)
|
|
RCAR_SA0_SIZE := 0
|
|
else
|
|
RCAR_SA0_SIZE := 1
|
|
endif
|
|
endif
|
|
$(eval $(call add_define,RCAR_SA0_SIZE))
|
|
|
|
# Process RCAR_SA6_TYPE flag
|
|
ifndef RCAR_SA6_TYPE
|
|
RCAR_SA6_TYPE := 0
|
|
else
|
|
ifeq (${RCAR_SA6_TYPE},0)
|
|
RCAR_SA6_TYPE := 0
|
|
else
|
|
RCAR_SA6_TYPE := 1
|
|
endif
|
|
endif
|
|
$(eval $(call add_define,RCAR_SA6_TYPE))
|
|
|
|
RCAR_VMA_ADJUST_ADDR := 0xE6320000
|
|
$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
|
|
|
|
|
|
###################################################
|
|
|
|
#c compiler
|
|
CFLAGS += ${DEFINES}
|
|
CFLAGS += -nostdinc \
|
|
-I../../../include/lib/libc \
|
|
-I../../../include/lib/libc/aarch64
|
|
|
|
#clean
|
|
CL = rm -f
|
|
|
|
###################################################
|
|
.SUFFIXES : .s .c .o
|
|
|
|
###################################################
|
|
# command
|
|
|
|
.PHONY: all
|
|
|
|
all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin
|
|
all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin
|
|
|
|
###################################################
|
|
# Linker
|
|
###################################################
|
|
|
|
$(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) | $$(@D)/
|
|
$(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
|
|
|
|
$(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/
|
|
$(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
|
|
|
|
$(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/
|
|
$(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map
|
|
|
|
$(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/
|
|
$(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
|
|
|
|
$(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/
|
|
$(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
|
|
|
|
$(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/
|
|
$(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map
|
|
|
|
###################################################
|
|
# Compile
|
|
###################################################
|
|
|
|
%.o: %.c | $$(@D)/
|
|
$(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
$(CL) *.bin *.map *.srec *.elf *.o
|