-
Notifications
You must be signed in to change notification settings - Fork 10
/
vp_models.mk
220 lines (138 loc) · 6.54 KB
/
vp_models.mk
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
211
212
213
214
215
216
217
218
219
220
ROOT_VP_BUILD_DIR ?= build
VP_BUILD_DIR = $(ROOT_VP_BUILD_DIR)/models
VP_INSTALL_PATH ?= $(INSTALL_DIR)/lib
VP_PY_INSTALL_PATH ?= $(INSTALL_DIR)/python
VP_MAKEFILE_LIST = $(addsuffix /Makefile,$(VP_DIRS))
CPP=$(CXX)
# CC=$(CC)
ifndef VERBOSE
V = @
endif
VP_COMP_PYBIND_FLAGS := $(shell python3-config --includes)
VP_COMP_CFLAGS=-MMD -MP -O2 -g -fpic -DGVSOC_OLD_BUILD=1 -D__GVSOC__=1 -I$(INSTALL_DIR)/include $(VP_COMP_PYBIND_FLAGS)
$(foreach dir, $(GVSOC_INC_PATHS), $(eval VP_COMP_CFLAGS += -I$(dir)))
ifdef ARCHI_DIR
VP_COMP_CFLAGS += -I$(ARCHI_DIR)
endif
VP_COMP_CPPFLAGS=-std=c++14
VP_COMP_LDFLAGS=-O2 -g -shared -L$(INSTALL_DIR)/lib
VP_COMP_STD_LDFLAGS=-lpulpvp
VP_COMP_DBG_LDFLAGS=-lpulpvp-debug
VP_COMP_SV_LDFLAGS=-lpulpvp-sv
VP_COMP_CFLAGS += -Werror -Wfatal-errors
VP_COMP_LDFLAGS += -Werror -Wfatal-errors
ifdef VP_USE_SYSTEMV
VP_COMP_CFLAGS += -D__VP_USE_SYSTEMV
endif
ifdef VP_USE_SYSTEMC
VP_COMP_CFLAGS += -D__VP_USE_SYSTEMC -I$(SYSTEMC_HOME)/include
ifdef VP_USE_SYSTEMC_DRAMSYS
DRAMSYS = $(PWD)/platform/gvsoc/models/memory/dram.sys
VP_COMP_CFLAGS += -D__VP_USE_SYSTEMC_DRAMSYS
VP_COMP_CFLAGS += -D__DRAMSYS_PATH=\"$(DRAMSYS)\"
VP_COMP_CFLAGS += -I$(DRAMSYS)/DRAMSys/library/src/simulation
VP_COMP_CFLAGS += -I$(DRAMSYS)/DRAMSys/library/src/common/third_party/DRAMPower/src
VP_COMP_CFLAGS += -I$(DRAMSYS)/DRAMSys/library/src/common/third_party/DRAMPower/src/libdrampower
VP_COMP_LDFLAGS += -L$(DRAMSYS)/build/library -lDRAMSys
VP_COMP_LDFLAGS += -L$(DRAMSYS)/DRAMSys/library/src/common/third_party/DRAMPower/src -ldrampower
VP_COMP_LDFLAGS += -lsqlite3
endif # VP_USE_SYSTEMC_DRAMSYS
endif # VP_USE_SYSTEMC
export PYTHONPATH := $(VP_INSTALL_PATH):$(INSTALL_DIR)/lib:$(PYTHONPATH)
VP_COMP_EXT := .so
#$(shell python3-config --extension-suffix)
include $(VP_MAKEFILE_LIST)
define declare_implementation
$(eval $(1)_OBJS = $(patsubst %.cc, $(VP_BUILD_DIR)/$(1)/%.o, $(patsubst %.c, $(VP_BUILD_DIR)/$(1)/%.o, $(patsubst %.cpp, $(VP_BUILD_DIR)/$(1)/%.o, $($(1)_SRCS)))))
-include $($(1)_OBJS:.o=.d)
$(VP_BUILD_DIR)/$(1)/%.o: %.cpp $($(1)_DEPS)
@echo "CXX $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CFLAGS) $(VP_COMP_CPPFLAGS)
$(VP_BUILD_DIR)/$(1)/%.o: %.cc $($(1)_DEPS)
@echo "CXX $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CFLAGS) $(VP_COMP_CPPFLAGS)
$(VP_BUILD_DIR)/$(1)/%.o: %.c $($(1)_DEPS)
@echo "CC $$<"
@mkdir -p `dirname $$@`
$(V)$(CC) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS)
$(VP_BUILD_DIR)/$(1)$(VP_COMP_EXT): $($(1)_OBJS) $($(1)_DEPS) $(INSTALL_DIR)/lib/libpulpvp.so
@echo "LD $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) $($(1)_OBJS) -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_LDFLAGS) $(VP_COMP_LDFLAGS) $(VP_COMP_STD_LDFLAGS)
$(VP_PY_INSTALL_PATH)/$(1)$(VP_COMP_EXT): $(VP_BUILD_DIR)/$(1)$(VP_COMP_EXT)
@echo "CP $$<"
$(V)install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/$(1)$(VP_COMP_EXT)
endef
define declare_debug_implementation
$(eval $(1)_DBG_OBJS = $(patsubst %.cc, $(VP_BUILD_DIR)/$(1)/debug/%.o, $(patsubst %.c, $(VP_BUILD_DIR)/$(1)/debug/%.o, $(patsubst %.cpp, $(VP_BUILD_DIR)/$(1)/debug/%.o, $($(1)_SRCS)))))
-include $($(1)_DBG_OBJS:.o=.d)
$(VP_BUILD_DIR)/$(1)/debug/%.o: %.cpp $($(1)_DEPS)
@echo "CXX DBG $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CPPFLAGS) -DVP_TRACE_ACTIVE=1
$(VP_BUILD_DIR)/$(1)/debug/%.o: %.cc $($(1)_DEPS)
@echo "CXX DBG $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CPPFLAGS) -DVP_TRACE_ACTIVE=1
$(VP_BUILD_DIR)/$(1)/debug/%.o: %.c $($(1)_DEPS)
@echo "CC DBG $$<"
@mkdir -p `dirname $$@`
$(V)$(CC) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) -DVP_TRACE_ACTIVE=1
$(VP_BUILD_DIR)/debug/$(1)$(VP_COMP_EXT): $($(1)_DBG_OBJS) $($(1)_DEPS) $(INSTALL_DIR)/lib/libpulpvp-debug.so
@echo "LD DBG $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) $($(1)_DBG_OBJS) -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_LDFLAGS) $(VP_COMP_LDFLAGS) $(VP_COMP_DBG_LDFLAGS)
$(VP_PY_INSTALL_PATH)/debug/$(1)$(VP_COMP_EXT): $(VP_BUILD_DIR)/debug/$(1)$(VP_COMP_EXT)
@echo "CP DBG $$<"
$(V)install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/debug/$(1)$(VP_COMP_EXT)
endef
define declare_sv_implementation
$(eval $(1)_SV_OBJS = $(patsubst %.cc, $(VP_BUILD_DIR)/$(1)/sv/%.o, $(patsubst %.c, $(VP_BUILD_DIR)/$(1)/sv/%.o, $(patsubst %.cpp, $(VP_BUILD_DIR)/$(1)/sv/%.o, $($(1)_SRCS)))))
-include $($(1)_SV_OBJS:.o=.d)
$(VP_BUILD_DIR)/$(1)/sv/%.o: %.cpp $($(1)_DEPS)
@echo "CXX SV $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CPPFLAGS) -DVP_TRACE_ACTIVE=1 -D__VP_USE_SYSTEMV=1
$(VP_BUILD_DIR)/$(1)/sv/%.o: %.cc $($(1)_DEPS)
@echo "CXX SV $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CPPFLAGS) -DVP_TRACE_ACTIVE=1 -D__VP_USE_SYSTEMV=1
$(VP_BUILD_DIR)/$(1)/sv/%.o: %.c $($(1)_DEPS)
@echo "CC SV $$<"
@mkdir -p `dirname $$@`
$(V)$(CC) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) -DVP_TRACE_ACTIVE=1
$(VP_BUILD_DIR)/sv/$(1)$(VP_COMP_EXT): $($(1)_SV_OBJS) $($(1)_DEPS) $(INSTALL_DIR)/lib/libpulpvp-sv.so
@echo "LD SV $$<"
@mkdir -p `dirname $$@`
$(V)$(CPP) $($(1)_SV_OBJS) -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS) $($(1)_LDFLAGS) $(VP_COMP_LDFLAGS) $(VP_COMP_SV_LDFLAGS)
$(VP_PY_INSTALL_PATH)/sv/$(1)$(VP_COMP_EXT): $(VP_BUILD_DIR)/sv/$(1)$(VP_COMP_EXT)
@echo "CP SV $$<"
$(V)install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/sv/$(1)$(VP_COMP_EXT)
endef
define declare_component
$(VP_PY_INSTALL_PATH)/$(1).py: $(1).py
@echo "CP $<"
$(V)install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/$(1).py
endef
define declareInstallFile
$(INSTALL_DIR)/include/$(1): $(1)
@echo "CP $<"
$(V)install -D $(1) $$@
VP_INSTALL_HEADERS += $(INSTALL_DIR)/include/$(1)
endef
$(foreach implementation, $(IMPLEMENTATIONS), $(eval $(call declare_implementation,$(implementation))))
$(foreach implementation, $(IMPLEMENTATIONS), $(eval $(call declare_debug_implementation,$(implementation))))
$(foreach implementation, $(IMPLEMENTATIONS), $(eval $(call declare_sv_implementation,$(implementation))))
$(foreach component, $(COMPONENTS), $(eval $(call declare_component,$(component))))
$(foreach file, $(VP_HEADERS), $(eval $(call declareInstallFile,$(file))))
build: $(VP_INSTALL_HEADERS) $(VP_INSTALL_TARGETS)
find $(VP_PY_INSTALL_PATH) -type d -exec touch {}/__init__.py \;
vp_clean:
rm -rf $(VP_BUILD_DIR)
.PHONY: vp_clean build