forked from pulp-platform/gvsoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vp_models.mk
154 lines (91 loc) · 4.52 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
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=g++
CC=gcc
VP_COMP_PYBIND_FLAGS := $(shell python3-config --includes)
VP_COMP_CFLAGS=-MMD -MP -O2 -g -fpic -D__GVSOC__=1 -I$(INSTALL_DIR)/include $(VP_COMP_PYBIND_FLAGS)
ifdef ARCHI_DIR
VP_COMP_CFLAGS += -I$(ARCHI_DIR)
endif
VP_COMP_CPPFLAGS=-std=c++11
VP_COMP_LDFLAGS=-O2 -g -shared -L$(INSTALL_DIR)/lib
VP_COMP_STD_LDFLAGS=-lpulpvp
VP_COMP_DBG_LDFLAGS=-lpulpvp-debug
VP_COMP_CFLAGS += -Werror -Wfatal-errors
VP_COMP_LDFLAGS += -Werror -Wfatal-errors
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)
@mkdir -p `dirname $$@`
$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CFLAGS) $(VP_COMP_CPPFLAGS)
$(VP_BUILD_DIR)/$(1)/%.o: %.cc $($(1)_DEPS)
@mkdir -p `dirname $$@`
$(CPP) -c $$< -o $$@ $($(1)_CFLAGS) $($(1)_CPPFLAGS) $(VP_COMP_CFLAGS) $(VP_COMP_CPPFLAGS)
$(VP_BUILD_DIR)/$(1)/%.o: %.c $($(1)_DEPS)
@mkdir -p `dirname $$@`
$(CC) -c $$< -o $$@ $($(1)_CFLAGS) $(VP_COMP_CFLAGS)
$(VP_BUILD_DIR)/$(1)$(VP_COMP_EXT): $($(1)_OBJS) $($(1)_DEPS)
@mkdir -p `dirname $$@`
$(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)
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)
@mkdir -p `dirname $$@`
$(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)
@mkdir -p `dirname $$@`
$(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)
@mkdir -p `dirname $$@`
$(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)
@mkdir -p `dirname $$@`
$(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)
install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/debug/$(1)$(VP_COMP_EXT)
endef
define declare_component
$(VP_PY_INSTALL_PATH)/$(1).py: $(1).py
install -D $$^ $$@
VP_INSTALL_TARGETS += $(VP_PY_INSTALL_PATH)/$(1).py
endef
define declareInstallFile
$(INSTALL_DIR)/include/$(1): $(1)
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 component, $(COMPONENTS), $(eval $(call declare_component,$(component))))
$(foreach file, $(VP_HEADERS), $(eval $(call declareInstallFile,$(file))))
vp_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)