forked from polarfire-soc/hart-software-services
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (170 loc) · 6.89 KB
/
Makefile
File metadata and controls
210 lines (170 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#
# MPFS HSS Embedded Software
#
# Copyright 2019-2021 Microchip Corporation.
#
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
#
# Toplevel HSS Makefile
#
SHELL=/bin/sh
BINDIR=build
DOT_CONFIG=.config
CONFIG_H=config.h
#
# To build the HSS under SoftConsole on Windows, we need to use SoftConsole-provided
# tools, and potentially to modify paths
#
.ONESHELL:
include application/os.mk
include application/Makefile
include $(DOT_CONFIG)
ifneq ("$(wildcard boards/${BOARD}/Makefile)","")
include boards/${BOARD}/Makefile
else
ifndef BOARD
BOARD:=scai-navc
export BOARD
$(info INFO: BOARD not specified, defaulting to ${BOARD}) # default to navc if nothing found
include boards/${BOARD}/Makefile
else
$(error Board >>${BOARD}<< not found)
endif
endif
#ifeq ("$(wildcard $(BINDIR))", "")
# $(info INFO: mkdir -p $(BINDIR))
# #$(shell mkdir -p $(BINDIR))
#endif
CORE_CFLAGS+=-DBOARD=${BOARD}
MCMODEL=-mcmodel=medany
include application/rules.mk
include application/targets.mk
include init/Makefile
include baremetal/Makefile
include services/Makefile
include modules/Makefile
ifdef CONFIG_USE_USER_CRYPTO
LIBS = ./services/crypto/mpfs-rv64imac-user-crypto-lib.a
else
LIBS =
endif
#$(info $$INCLUDES is [${INCLUDES}])
ifdef CONFIG_CC_USE_MAKEDEP
DEPENDENCIES=$(addprefix $(BINDIR)/, $(SRCS-y:.c=.d) $(EXTRA_SRCS-y:.c=.d) $(TEST_SRCS:.c=.d) $(ASM_SRCS:.S=.d) $(ASM_SRCS-y:.S=.d))
.PHONY: dep
dep: $(DEPENDENCIES)
-include $(DEPENDENCIES)
endif
ifdef CONFIG_DISPLAY_TOOL_VERSIONS
include/tool_versions.h:
echo \#define CC_VERSION_STRING \"`$(CC) --version | head -n 1`\" > include/tool_versions.h
echo \#define LD_VERSION_STRING \"`$(LD) --version | head -n 1`\" >> include/tool_versions.h
DEPENDENCIES+=include/tool_versions.h
endif
include envm-wrapper/Makefile
################################################################################################
#
# Main Build Targets
#
OBJS-envm = $(OBJS)
EXTRA_OBJS-envm = $(EXTRA_OBJS)
OBJS-l2scratch = $(OBJS)
EXTRA_OBJS-l2scratch = $(EXTRA_OBJS)
ifdef CONFIG_DEBUG_HOSTENV_INFO
EXTRA_OBJS-l2scratch += $(HOSTENV_FILE).o
endif
ifdef CONFIG_DEBUG_HOSTENV_INFO
define hostenv-prepare
$(ECHO) "$$ date //build date for this binary" > $(HOSTENV_FILE).txt
date >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ pwd" >> $(HOSTENV_FILE).txt
pwd >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ hostname" >> $(HOSTENV_FILE).txt
hostname >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ whoami" >> $(HOSTENV_FILE).txt
whoami >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ ifconfig" >> $(HOSTENV_FILE).txt
ifconfig >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ git config --list" >> $(HOSTENV_FILE).txt
git config --list >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ git branch -a" >> $(HOSTENV_FILE).txt
git branch -a >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ git show --no-patch" >> $(HOSTENV_FILE).txt
git show --no-patch >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ git status" >> $(HOSTENV_FILE).txt
git status >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ git diff" >> $(HOSTENV_FILE).txt
git diff >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$$ diff -u boards/${BOARD}/def_config .config" >> $(HOSTENV_FILE).txt
diff -u boards/${BOARD}/def_config .config >> $(HOSTENV_FILE).txt
$(ECHO) "\n\n\n" >> $(HOSTENV_FILE).txt
$(ECHO) "$(OBJCOPY) -I binary -O elf64-littleriscv --binary-architecture riscv $(HOSTENV_FILE).txt $(HOSTENV_FILE).o"
$(OBJCOPY) -I binary -O elf64-littleriscv --binary-architecture riscv $(HOSTENV_FILE).txt $(HOSTENV_FILE).o
$(NM) -n $(HOSTENV_FILE).o
$(ECHO) "EXTRA_OBJS-l2scratch : $(EXTRA_OBJS-l2scratch)"
endef
else
define hostenv-prepare
$(ECHO) "CONFIG_DEBUG_HOSTENV_INFO feature is disabled..."
$(ECHO) "EXTRA_OBJS-l2scratch : $(EXTRA_OBJS-l2scratch)"
endef
endif
define main-build-target
$(ECHO) " LD $@";
$(ECHO) "$(CC) -T $(LINKER_SCRIPT-$(1)) $(CFLAGS_GCCEXT) $(OPT-y) -static -nostdlib -nostartfiles -nodefaultlibs -Wl,--build-id -Wl,-Map=$(BINDIR)/output-$(1).map -Wl,--gc-sections -o $(BINDIR)/$@ $(OBJS-$(1)) $(EXTRA_OBJS-$(1)) $(LIBS) $(LIBS-y)"
$(CC) -T $(LINKER_SCRIPT-$(1)) $(CFLAGS_GCCEXT) $(OPT-y) \
-static -nostdlib -nostartfiles -nodefaultlibs \
-Wl,--build-id -Wl,-Map=$(BINDIR)/output-$(1).map -Wl,--gc-sections \
-o $(BINDIR)/$@ $(OBJS-$(1)) $(EXTRA_OBJS-$(1)) $(LIBS) $(LIBS-y)
$(ECHO) " NM `basename $@ .elf`.sym";
$(NM) -n $(BINDIR)/$@ > $(BINDIR)/`basename $@ .elf`.sym
endef
#
# Build Targets
#
$(TARGET-envm): $(OBJS) $(EXTRA_OBJS) $(CONFIG_H) $(DEPENDENCIES) $(LINKER_SCRIPT-envm) $(LIBS)
$(call main-build-target,envm)
$(ECHO) " BIN `basename $@ .elf`.bin"
$(OBJCOPY) -O binary $(BINDIR)/$@ $(BINDIR)/`basename $@ .elf`.bin
$(ECHO) " HEX `basename $@ .elf`.hex";
$(OBJCOPY) -O ihex $(BINDIR)/$@ $(BINDIR)/`basename $@ .elf`.hex
$(SIZE) $(BINDIR)/$(TARGET-envm) 2>/dev/null
$(TARGET-l2scratch): $(OBJS) $(EXTRA_OBJS) $(CONFIG_H) $(DEPENDENCIES) $(LINKER_SCRIPT-l2scratch) $(LIBS) $(LIBS-y)
$(call hostenv-prepare)
$(call main-build-target,l2scratch)
$(ECHO) " BIN `basename $@ .elf`.bin"
$(OBJCOPY) -O binary $(BINDIR)/$@ $(BINDIR)/`basename $@ .elf`.bin
$(SIZE) $(BINDIR)/$(TARGET-l2scratch) 2>/dev/null
$(BINDIR)/$(TARGET-envm): $(TARGET-envm)
$(BINDIR)/$(TARGET-l2scratch): $(TARGET-l2scratch)
$(TARGET-ddr): $(OBJS) $(EXTRA_OBJS) $(CONFIG_H) $(DEPENDENCIES) $(LINKER_SCRIPT-ddr) $(LIBS)
$(call main-build-target,ddr)