-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
146 lines (119 loc) · 4.38 KB
/
Makefile
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
#
# 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:=mpfs-icicle-kit-es
export BOARD
$(info INFO: BOARD not specified, defaulting to ${BOARD}) # default to icicle 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)
define main-build-target
$(ECHO) " LD $@";
$(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 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)