blob: b3af401c5dc99aafb86cc1d7caca0c17b45789e8 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001#
2# Copyright (c) 2015-2018, 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
12FILE_NAME_SA0 = bootparam_sa0
13FILE_NAME_SA6 = cert_header_sa6
14
15OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
16OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
17
18#object file name
19OBJ_FILE_SA0 = sa0.o
20OBJ_FILE_SA6 = sa6.o
21
22#linker script name
23MEMORY_DEF_SA0 = sa0.ld.S
24MEMORY_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
30define add_define
31DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
32endef
33
34# Process RCAR_SA0_SIZE flag
35ifndef RCAR_SA0_SIZE
36RCAR_SA0_SIZE := 1
37else
38ifeq (${RCAR_SA0_SIZE},0)
39RCAR_SA0_SIZE := 0
40else
41RCAR_SA0_SIZE := 1
42endif
43endif
44$(eval $(call add_define,RCAR_SA0_SIZE))
45
46# Process RCAR_SA6_TYPE flag
47ifndef RCAR_SA6_TYPE
48RCAR_SA6_TYPE := 0
49else
50ifeq (${RCAR_SA6_TYPE},0)
51RCAR_SA6_TYPE := 0
52else
53RCAR_SA6_TYPE := 1
54endif
55endif
56$(eval $(call add_define,RCAR_SA6_TYPE))
57
58###################################################
59
60#c compiler
61CC = $(CROSS_COMPILE)gcc
62CFLAGS += ${DEFINES}
63CFLAGS += -I../../include/lib/stdlib
64
65#Linker
66LD = $(CROSS_COMPILE)ld
67
68#objcopy
69objcopy = $(CROSS_COMPILE)objcopy
70
71#clean
72CL = rm -f
73
74###################################################
75.SUFFIXES : .s .c .o
76
77###################################################
78# command
79
80.PHONY: all
81all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6)
82###################################################
83# Linker
84###################################################
85$(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0)
86 $(LD) $(OBJ_FILE_SA0) \
87 -T $(MEMORY_DEF_SA0) \
88 -o $(OUTPUT_FILE_SA0) \
89 -Map $(FILE_NAME_SA0).map \
90
91 $(objcopy) -O srec --adjust-vma=0xE6320000 --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
92 $(objcopy) -O binary --adjust-vma=0xE6320000 --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
93
94$(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6)
95 $(LD) $(OBJ_FILE_SA6) \
96 -T $(MEMORY_DEF_SA6) \
97 -o $(OUTPUT_FILE_SA6) \
98 -Map $(FILE_NAME_SA6).map \
99
100 $(objcopy) -O srec --adjust-vma=0xE6320000 --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
101 $(objcopy) -O binary --adjust-vma=0xE6320000 --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
102
103###################################################
104# Compile
105###################################################
106
107%.o:../%.c
108 $(CC) -c -I $< -o $@
109
110.PHONY: clean
111clean:
112 $(CL) *.bin *.map *.srec *.elf *.o