Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 1 | # |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 2 | # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 3 | # Copyright (c) 2020, Renesas Electronics Corporation. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 8 | toolchains := aarch64 |
| 9 | |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 10 | include ../../../make_helpers/common.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 11 | include ../../../make_helpers/toolchain.mk |
| 12 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 13 | ################################################### |
| 14 | # makefile |
| 15 | ################################################### |
| 16 | |
| 17 | #output file name |
| 18 | FILE_NAME_SA0 = bootparam_sa0 |
| 19 | FILE_NAME_SA6 = cert_header_sa6 |
| 20 | |
| 21 | OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf |
| 22 | OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf |
| 23 | |
| 24 | #object file name |
| 25 | OBJ_FILE_SA0 = sa0.o |
| 26 | OBJ_FILE_SA6 = sa6.o |
| 27 | |
| 28 | #linker script name |
| 29 | MEMORY_DEF_SA0 = sa0.ld.S |
| 30 | MEMORY_DEF_SA6 = sa6.ld.S |
| 31 | |
| 32 | ################################################### |
| 33 | # Convenience function for adding build definitions |
| 34 | # $(eval $(call add_define,FOO)) will have: |
| 35 | # -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise |
| 36 | define add_define |
| 37 | DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) |
| 38 | endef |
| 39 | |
| 40 | # Process RCAR_SA0_SIZE flag |
| 41 | ifndef RCAR_SA0_SIZE |
| 42 | RCAR_SA0_SIZE := 1 |
| 43 | else |
| 44 | ifeq (${RCAR_SA0_SIZE},0) |
| 45 | RCAR_SA0_SIZE := 0 |
| 46 | else |
| 47 | RCAR_SA0_SIZE := 1 |
| 48 | endif |
| 49 | endif |
| 50 | $(eval $(call add_define,RCAR_SA0_SIZE)) |
| 51 | |
| 52 | # Process RCAR_SA6_TYPE flag |
| 53 | ifndef RCAR_SA6_TYPE |
| 54 | RCAR_SA6_TYPE := 0 |
| 55 | else |
| 56 | ifeq (${RCAR_SA6_TYPE},0) |
| 57 | RCAR_SA6_TYPE := 0 |
| 58 | else |
| 59 | RCAR_SA6_TYPE := 1 |
| 60 | endif |
| 61 | endif |
| 62 | $(eval $(call add_define,RCAR_SA6_TYPE)) |
| 63 | |
| 64 | RCAR_VMA_ADJUST_ADDR := 0xE6320000 |
| 65 | $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR)) |
| 66 | |
| 67 | |
| 68 | ################################################### |
| 69 | |
| 70 | #c compiler |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 71 | CFLAGS += ${DEFINES} |
| 72 | CFLAGS += -nostdinc \ |
| 73 | -I../../../include/lib/libc \ |
| 74 | -I../../../include/lib/libc/aarch64 |
| 75 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 76 | #clean |
| 77 | CL = rm -f |
| 78 | |
| 79 | ################################################### |
| 80 | .SUFFIXES : .s .c .o |
| 81 | |
| 82 | ################################################### |
| 83 | # command |
| 84 | |
| 85 | .PHONY: all |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 86 | |
| 87 | all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin |
| 88 | all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin |
| 89 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 90 | ################################################### |
| 91 | # Linker |
| 92 | ################################################### |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 93 | |
| 94 | $(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) |
| 95 | $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 96 | |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 97 | $(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) |
| 98 | $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 99 | |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 100 | $(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) |
| 101 | $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map |
| 102 | |
| 103 | $(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) |
| 104 | $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec |
| 105 | |
| 106 | $(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) |
| 107 | $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 108 | |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame^] | 109 | $(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) |
| 110 | $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 111 | |
| 112 | ################################################### |
| 113 | # Compile |
| 114 | ################################################### |
| 115 | |
Chris Kay | 46d3ab3 | 2024-01-15 16:16:07 +0000 | [diff] [blame] | 116 | %.o: %.c |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 117 | $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 118 | |
| 119 | .PHONY: clean |
| 120 | clean: |
| 121 | $(CL) *.bin *.map *.srec *.elf *.o |