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 | |
| 7 | ################################################### |
| 8 | # makefile |
| 9 | ################################################### |
| 10 | |
| 11 | #output file name |
| 12 | FILE_NAME_SA0 = bootparam_sa0 |
| 13 | FILE_NAME_SA6 = cert_header_sa6 |
| 14 | |
| 15 | OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf |
| 16 | OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf |
| 17 | |
| 18 | #object file name |
| 19 | OBJ_FILE_SA0 = sa0.o |
| 20 | OBJ_FILE_SA6 = sa6.o |
| 21 | |
| 22 | #linker script name |
| 23 | MEMORY_DEF_SA0 = sa0.ld.S |
| 24 | MEMORY_DEF_SA6 = sa6.ld.S |
| 25 | |
| 26 | ################################################### |
| 27 | # Convenience function for adding build definitions |
| 28 | # $(eval $(call add_define,FOO)) will have: |
| 29 | # -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise |
| 30 | define add_define |
| 31 | DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) |
| 32 | endef |
| 33 | |
| 34 | # Process RCAR_SA0_SIZE flag |
| 35 | ifndef RCAR_SA0_SIZE |
| 36 | RCAR_SA0_SIZE := 1 |
| 37 | else |
| 38 | ifeq (${RCAR_SA0_SIZE},0) |
| 39 | RCAR_SA0_SIZE := 0 |
| 40 | else |
| 41 | RCAR_SA0_SIZE := 1 |
| 42 | endif |
| 43 | endif |
| 44 | $(eval $(call add_define,RCAR_SA0_SIZE)) |
| 45 | |
| 46 | # Process RCAR_SA6_TYPE flag |
| 47 | ifndef RCAR_SA6_TYPE |
| 48 | RCAR_SA6_TYPE := 0 |
| 49 | else |
| 50 | ifeq (${RCAR_SA6_TYPE},0) |
| 51 | RCAR_SA6_TYPE := 0 |
| 52 | else |
| 53 | RCAR_SA6_TYPE := 1 |
| 54 | endif |
| 55 | endif |
| 56 | $(eval $(call add_define,RCAR_SA6_TYPE)) |
| 57 | |
| 58 | RCAR_VMA_ADJUST_ADDR := 0xE6320000 |
| 59 | $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR)) |
| 60 | |
| 61 | |
| 62 | ################################################### |
| 63 | |
| 64 | #c compiler |
| 65 | CC = $(CROSS_COMPILE)gcc |
| 66 | CFLAGS += ${DEFINES} |
| 67 | CFLAGS += -nostdinc \ |
| 68 | -I../../../include/lib/libc \ |
| 69 | -I../../../include/lib/libc/aarch64 |
| 70 | |
| 71 | #Linker |
| 72 | LD = $(CROSS_COMPILE)ld |
| 73 | |
| 74 | #objcopy |
| 75 | objcopy = $(CROSS_COMPILE)objcopy |
| 76 | |
| 77 | #clean |
| 78 | CL = rm -f |
| 79 | |
| 80 | ################################################### |
| 81 | .SUFFIXES : .s .c .o |
| 82 | |
| 83 | ################################################### |
| 84 | # command |
| 85 | |
| 86 | .PHONY: all |
| 87 | all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6) |
| 88 | ################################################### |
| 89 | # Linker |
| 90 | ################################################### |
| 91 | $(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) |
| 92 | $(LD) $(OBJ_FILE_SA0) \ |
| 93 | -T $(MEMORY_DEF_SA0) \ |
| 94 | -o $(OUTPUT_FILE_SA0) \ |
| 95 | -Map $(FILE_NAME_SA0).map \ |
| 96 | |
| 97 | $(objcopy) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec |
| 98 | $(objcopy) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin |
| 99 | |
| 100 | $(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) |
| 101 | $(LD) $(OBJ_FILE_SA6) \ |
| 102 | -T $(MEMORY_DEF_SA6) \ |
| 103 | -o $(OUTPUT_FILE_SA6) \ |
| 104 | -Map $(FILE_NAME_SA6).map \ |
| 105 | |
| 106 | $(objcopy) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec |
| 107 | $(objcopy) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin |
| 108 | |
| 109 | ################################################### |
| 110 | # Compile |
| 111 | ################################################### |
| 112 | |
| 113 | %.o:../%.c |
| 114 | $(CC) -c -I $< -o $@ |
| 115 | |
| 116 | .PHONY: clean |
| 117 | clean: |
| 118 | $(CL) *.bin *.map *.srec *.elf *.o |