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