forked from plasma-umass/Mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
215 lines (157 loc) · 7.05 KB
/
GNUmakefile
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
-include config.mk
ifeq ($(VERSION),)
all:
@echo "run ./configure before running make."
@exit 1
else
ifeq ($(OS),Windows_NT)
LIB = libmesh.dll
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LIB = libmesh.dylib
else
LIB = libmesh$(LIB_SUFFIX).so
SHARED_LIB = $(LIB)
endif
endif
PREFIX = /usr
ARCH = x86_64
COMMON_SRCS = src/thread_local_heap.cc src/global_heap.cc src/runtime.cc src/real.cc src/meshable_arena.cc src/d_assert.cc src/measure_rss.cc
LIB_SRCS = $(COMMON_SRCS) src/libmesh.cc
LIB_OBJS = $(addprefix build/,$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(LIB_SRCS:.cc=.o))))
GTEST_SRCS = src/vendor/googletest/googletest/src/gtest-all.cc \
src/vendor/googletest/googletest/src/gtest_main.cc
UNIT_SRCS = $(wildcard src/unit/*.cc) $(GTEST_SRCS) $(COMMON_SRCS)
UNIT_OBJS = $(addprefix build/,$(patsubst %.c,%.o,$(UNIT_SRCS:.cc=.o)))
UNIT_CXXFLAGS = -isystem src/vendor/googletest/googletest/include -Isrc/vendor/googletest/googletest $(filter-out -Wextra,$(CXXFLAGS:-Wundef=)) -Wno-unused-const-variable -DGTEST_HAS_PTHREAD=1
UNIT_LDFLAGS = $(LIBS)
UNIT_BIN = unit.test
BENCH_SRCS = src/meshing_benchmark.cc $(COMMON_SRCS)
BENCH_OBJS = $(addprefix build/,$(patsubst %.c,%.o,$(BENCH_SRCS:.cc=.o)))
BENCH_BIN = meshing-benchmark
FRAG_SRCS = src/fragmenter.cc src/measure_rss.cc
FRAG_OBJS = $(addprefix build/,$(patsubst %.c,%.o,$(FRAG_SRCS:.cc=.o)))
FRAG_BIN = fragmenter
ALL_OBJS = $(LIB_OBJS) $(UNIT_OBJS) $(BENCH_OBJS) $(FRAG_OBJS)
# reference files in each subproject to ensure git fully checks the project out
HEAP_LAYERS = src/vendor/Heap-Layers/heaplayers.h
GTEST = src/vendor/googletest/googletest/include/gtest/gtest.h
COV_DIR = coverage
ALL_SUBMODULES = $(HEAP_LAYERS) $(GTEST)
CONFIG = GNUmakefile Makefile config.mk
# quiet output, but allow us to look at what commands are being
# executed by passing 'V=1' to make, without requiring temporarily
# editing the Makefile.
ifneq ($V, 1)
MAKEFLAGS += -s
endif
.SUFFIXES:
.SUFFIXES: .cc .c .o .d .test
all: test $(LIB) $(FRAG_BIN)
build:
mkdir -p build
mkdir -p $(basename $(ALL_OBJS))
test_frag: $(FRAG_BIN) $(LIB)
@echo " GLIBC MALLOC"
# ./$(FRAG_BIN)
@echo ""
@echo ""
@echo " TCMALLOC MALLOC"
# LD_PRELOAD=libtcmalloc_minimal.so ./$(FRAG_BIN)
@echo ""
@echo ""
@echo " MESH MALLOC"
LD_PRELOAD=./$(LIB) ./$(FRAG_BIN)
$(ALL_SUBMODULES):
@echo " GIT $@"
git submodule update --init
touch -c $@
build/src/vendor/googletest/%.o: src/vendor/googletest/%.cc build $(CONFIG)
@echo " CXX $@"
$(CXX) $(UNIT_CXXFLAGS) -MMD -o $@ -c $<
build/src/%.o: src/%.S build $(CONFIG)
@echo " AS $@"
$(CC) -O$(O) $(ASFLAGS) -o $@ -c $<
build/src/%.o: src/%.c build $(CONFIG)
@echo " CC $@"
$(CC) $(CFLAGS) -MMD -o $@ -c $<
build/src/%.o: src/%.cc build $(CONFIG)
@echo " CXX $@"
$(CXX) $(CXXFLAGS) -MMD -o $@ -c $<
build/src/unit/%.o: src/unit/%.cc build $(CONFIG)
@echo " CXX $@"
$(CXX) $(UNIT_CXXFLAGS) -MMD -o $@ -c $<
$(SHARED_LIB): $(HEAP_LAYERS) $(LIB_OBJS) $(CONFIG)
@echo " LD $@"
$(CXX) -shared $(LDFLAGS) -o $@ $(LIB_OBJS) $(LIBS)
libmesh.dylib: $(HEAP_LAYERS) $(LIB_OBJS) $(CONFIG)
@echo " LD $@"
$(CXX) -compatibility_version 1 -current_version 1 -dynamiclib $(LDFLAGS) -o $@ $(LIB_OBJS) $(LIBS)
$(BENCH_BIN): $(HEAP_LAYERS) $(BENCH_OBJS) $(CONFIG)
@echo " LD $@"
$(CXX) $(LDFLAGS) -o $@ $(BENCH_OBJS) $(LIBS)
$(FRAG_BIN): $(GFLAGS_LIB) $(FRAG_OBJS) $(CONFIG)
@echo " LD $@"
$(CXX) $(LDFLAGS) -o $@ $(FRAG_OBJS) $(LIBS)
$(UNIT_BIN): $(CONFIG) $(UNIT_OBJS)
@echo " LD $@"
$(CXX) -O0 $(LDFLAGS) -o $@ $(UNIT_OBJS) $(UNIT_LDFLAGS)
test check: $(UNIT_BIN)
./$(UNIT_BIN)
install: $(LIB)
install -c -m 0755 $(LIB) $(PREFIX)/lib/$(LIB)
ldconfig
mkdir -p $(PREFIX)/include/plasma
install -c -m 0755 src/plasma/mesh.h $(PREFIX)/include/plasma/mesh.h
lib: $(LIB)
paper:
$(MAKE) -C paper
coverage: $(UNIT_BIN) $(LIB) $(CONFIG)
mkdir -p "$(COV_DIR)"
cd "$(COV_DIR)" && lcov --base-directory .. --directory ../build/src --capture --output-file app.info
cd "$(COV_DIR)" && genhtml app.info
clang-coverage: $(UNIT_BIN) $(LIB) $(CONFIG)
mkdir -p "$(COV_DIR)"
rm -f "$(COV_DIR)/unit.test.profdata"
cd "$(COV_DIR)" && llvm-profdata merge -sparse ../default.profraw -o unit.test.profdata
cd "$(COV_DIR)" && llvm-cov show -format=html -instr-profile=unit.test.profdata ../unit.test -ignore-filename-regex='.*(vendor|unit)/.*' >index.html
cd "$(COV_DIR)" && llvm-cov report -instr-profile=unit.test.profdata ../unit.test -ignore-filename-regex='.*(vendor|unit)/.*' -use-color
rm -f default.profraw
src/test/fork-example: build/src/test/fork-example.o $(CONFIG)
$(CC) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -lmesh -Wl,-rpath,"$(PWD)"
src/test/local-alloc: src/test/local-alloc.c $(CONFIG)
$(CC) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -lmesh -Wl,-rpath,"$(PWD)"
src/test/big-alloc: src/test/big-alloc.c $(CONFIG)
$(CC) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -lmesh -Wl,-rpath,"$(PWD)"
src/test/big-alloc-hoard: src/test/big-alloc.c $(CONFIG)
$(CC) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -lhoard -Wl,-rpath,"$(PWD)"
src/test/big-alloc-glibc: src/test/big-alloc.c $(CONFIG)
$(CC) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -Wl,-rpath,"$(PWD)"
src/test/thread-example: src/test/thread.cc $(CONFIG)
$(CXX) -std=c++11 -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -o $@ $< -L$(PWD) -lmesh -Wl,-rpath,"$(PWD)" -lpthread
src/test/larson-mesh: src/test/larson.cc $(CONFIG)
$(CXX) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -O3 -DNDEBUG -Isrc -Isrc/vendor/Heap-Layers -o $@ $< -L$(PWD) -lmesh -Wl,-rpath,"$(PWD)" -lpthread
src/test/larson-hoard: src/test/larson.cc $(CONFIG)
$(CXX) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -O3 -DNDEBUG -Isrc -Isrc/vendor/Heap-Layers -o $@ $< -lhoard -lpthread
src/test/larson-tcmalloc: src/test/larson.cc $(CONFIG)
$(CXX) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -O3 -DNDEBUG -Isrc -Isrc/vendor/Heap-Layers -o $@ $< -ltcmalloc_minimal -lpthread
src/test/larson-glibc: src/test/larson.cc $(CONFIG)
$(CXX) -pipe -fno-builtin-malloc -fno-omit-frame-pointer -g -O3 -DNDEBUG -Isrc -Isrc/vendor/Heap-Layers -o $@ $< -lpthread
run: $(LIB) src/test/fork-example
src/test/fork-example
format:
clang-format -i src/*.cc src/*.c src/*.h src/plasma/*.h src/rng/*.h src/static/*.h src/test/*.cc src/test/*.cc src/unit/*.cc
endif
clean:
rm -f src/test/fork-example
rm -f $(UNIT_BIN) $(BENCH_BIN) $(FRAG_BIN) $(LIB)
find . -name '*~' -print0 | xargs -0 rm -f
rm -rf build
distclean: clean
# double $$ in egrep pattern is because we're embedding this shell command in a Makefile
TAGS:
@echo " TAGS"
find . -type f | egrep '\.(cpp|h|cc|hh)$$' | grep -v google | xargs etags -l c++
-include $(ALL_OBJS:.o=.d)
.PHONY: all clean distclean format test test_frag check lib install paper run TAGS