-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
181 lines (138 loc) · 8.37 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
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
.PHONY=all tests clean obj update
CXX?=g++
CC?=gcc
MAKE?=make
GMATCH=$(findstring g++,$(CXX))
GIT_VERSION := $(shell git describe --abbrev=4 --always)
WARNINGS=-Wall -Wextra -Wno-char-subscripts \
-Wpointer-arith -Wwrite-strings -Wdisabled-optimization \
-Wformat -Wcast-align -Wno-unused-function -Wno-unused-parameter \
-pedantic -DUSE_PDQSORT -Wunused-variable -Wno-attributes -Wno-cast-align \
-Wno-ignored-attributes -Wno-missing-braces -Wno-array-bounds
EXTRA?=
INCPLUS?=
EXTRA_LD?=
DBG?=-DNDEBUG
OS:=$(shell uname)
FLAGS=
ARCH_STR:="-march=native"
ifneq (,$(findstring g++,$(CXX)))
ifeq ($(shell uname),Darwin)
ifeq (,$(findstring clang,$(CXX)))
POPCNT_CXX:=clang
else
POPCNT_CXX:=$(CXX)
endif
ifeq ($(shell uname -m),aarch64)
ARCH_STR:="-mtune=generic"
endif
else
POPCNT_CXX:=$(CXX)
endif
endif
OPT_MINUS_OPENMP= -O3 -funroll-loops\
-pipe -fno-strict-aliasing $(ARCH_STR) $(FLAGS) $(EXTRA)
OPT=$(OPT_MINUS_OPENMP) -fopenmp
XXFLAGS=-fno-rtti
CXXFLAGS=$(OPT) $(XXFLAGS) -std=c++17 $(WARNINGS) -DBONSAI_VERSION=\"$(GIT_VERSION)\"
CXXFLAGS_MINUS_OPENMP=$(OPT_MINUS_OPENMP) $(XXFLAGS) -std=c++1z $(WARNINGS) -Wno-cast-align -Wno-gnu-zero-variadic-macro-arguments -DBONSAI_VERSION=\"$(GIT_VERSION)\"
CCFLAGS=$(OPT) $(CFLAGS) -std=c11 $(WARNINGS) -DBONSAI_VERSION=\"$(GIT_VERSION)\"
LIB=-lz
LD=-L. $(EXTRA_LD)
OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c) klib/kthread.o) $(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) klib/kstring.o
DOBJS=$(patsubst %.c,%.do,$(wildcard src/*.c) klib/kthread.o) $(patsubst %.cpp,%.do,$(wildcard src/*.cpp)) klib/kstring.o
ZOBJS=$(patsubst %.c,%.zo,$(wildcard src/*.c) klib/kthread.o) $(patsubst %.cpp,%.zo,$(wildcard src/*.cpp)) klib/kstring.o
TEST_OBJS=$(patsubst %.cpp,%.o,$(wildcard test/*.cpp))
ZTEST_OBJS=$(patsubst %.cpp,%.zo,$(wildcard test/*.cpp))
EXEC_OBJS=$(patsubst %.cpp,%.o,$(wildcard bin/*.cpp))
ZW_OBJS=$(patsubst %.c,%.o,$(wildcard zstd/zlibWrapper/*.c)) libzstd.a
EX=$(patsubst bin/%.cpp,bin/%,$(wildcard bin/*.cpp)) fsetsketcher fopsetsketcher opsetsketcher
DEX=$(patsubst %_d,%,$(EX))
STATEX=$(patsubst %,%_s,$(EX))
STATEXZ=$(patsubst %,%_sz,$(EX))
ZSTD_INCLUDE_DIRS=zstd/zlibWrapper zstd/lib/common zstd/lib
ZSTD_INCLUDE=$(patsubst %,-I%,$(ZSTD_INCLUDE_DIRS))
ZFLAGS=-DZWRAP_USE_ZSTD=1
ZCOMPILE_FLAGS= $(ZFLAGS)
ALL_ZOBJS=$(ZOBJS) $(ZW_OBJS)
INCLUDE=-Iclhash/include -I. -I.. -Ihll/include -Ihll/libpopcnt -I.. -Iinclude -Icircularqueue $(ZSTD_INCLUDE) $(INCPLUS) -Ihll/include/vec -Ihll -Ipdqsort -Iinclude/bonsai -Iinclude \
-Ihll/include/vec/blaze -Iinclude/bonsai -Iinclude -Ihll/include/blaze
all: $(OBJS) $(EX) $(ZW_OBJS) unit lib/libbonsai.a $(DEX)
ex: $(EX)
update:
for i in circularqueue clhash hll klib kspp libpopcnt linear pdqsort tinythreadpp; \
do cd $$i && git checkout master && git pull && cd ..; done; \
cd hll/vec && git checkout master && git pull && cd ../..
obj: $(OBJS) $(DOBJS) $(ZOBJS) $(ZW_OBJS)
libzstd.a:
+cd zstd && $(MAKE) lib && cp lib/libzstd.a .. && cd ..
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE) -DNDEBUG -c $< -o $@ $(LIB)
%.do: %.c
$(CC) $(CFLAGS) $(INCLUDE) -g -c $< -o $@ $(LIB)
%.zo: %.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ $(LIB) $(ZCOMPILE_FLAGS)
test/%.o: test/%.cpp $(wildcard include/bonsai/*.h)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) -c $< -o $@ $(LIB) -O1
test/%.zo: test/%.cpp
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) -c $< -o $@ $(ZCOMPILE_FLAGS)
%.o: %.cpp $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) -DNDEBUG -c $< -o $@ $(LIB)
%.do: %.cpp $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) -g -c $< -o $@ $(LIB)
%.zo: %.cpp $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) -c $< -o $@ -DNDEBUG $(LIB) $(ZCOMPILE_FLAGS)
src/popcnt.o: src/popcnt.cpp
$(POPCNT_CXX) $(CXXFLAGS_MINUS_OPENMP) $(DBG) $(INCLUDE) $(LD) -DNDEBUG -c $< -o $@ $(LIB)
src/popcnt.do: src/popcnt.cpp
$(POPCNT_CXX) $(CXXFLAGS_MINUS_OPENMP) $(DBG) $(INCLUDE) $(LD) -c $< -o $@ $(LIB)
src/popcnt.zo: src/popcnt.cpp
$(POPCNT_CXX) $(CXXFLAGS_MINUS_OPENMP) $(DBG) $(INCLUDE) $(LD) -c $< -o $@ $(LIB)
adsetsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -fsanitize=address -DBLAZE_SHAE
pgsetsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -pg
setsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a
fsetsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -DCSETFT=float
opsetsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -DUSE_OPH
fopsetsketcher: bin/setsketcher.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -DCSETFT=float -DUSE_OPH
setsketchindexer: bin/setsketchindexer.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a
fsetsketchindexer: bin/setsketchindexer.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -DCSETFT=float
ad%: bin/%.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -fsanitize=address
bonsai: bin/bonsai.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -Ihll/include $(INCLUDE)
bin/bonsai: bin/bonsai.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -Ihll/include $(INCLUDE)
bin/%: bin/%.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -Ihll/include $(INCLUDE)
bin/errexp: bin/errexp.cpp klib/kthread.o $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h) zlib/libz.a
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a -Ihll/include
bin/kmercnt: bin/kmercnt.cpp klib/kthread.o
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o -DNDEBUG $< -o $@ $(LIB) zlib/libz.a
bin/%_z: bin/%.cpp $(ALL_ZOBJS) $(wildcard include/bonsai/*.h) $(wildcard hll/include/sketch/*.h)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) $(ALL_ZOBJS) -DNDEBUG $< -o $@ $(ZCOMPILE_FLAGS) $(LIB)
%_d: bin/%.cpp $(DOBJS)
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) $(DOBJS) $< -g -o $@ $(LIB)
bonsai/fahist: src/fahist.cpp $(OBJS) klib/kthread.o
$(CXX) $(CXXFLAGS) $(DBG) $(INCLUDE) $(LD) klib/kthread.o $< -o $@ -lz
lib/libbonsai.a: $(OBJS)
ar cr $@ $(OBJS)
zlib/libz.a:
+cd zlib && (./configure || echo "no configure needed") && $(MAKE)
tests: clean unit
unit: $(DOBJS) $(TEST_OBJS)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(TEST_OBJS) $(LD) $(DOBJS) -o $@ $(LIB)
zunit: $(ZOBJS) $(ZTEST_OBJS)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(ZTEST_OBJS) $(LD) $(ALL_ZOBJS) -o $@ $(LIB) $(ZCOMPILE_FLAGS)
clean:
rm -f $(ZOBJS) $(ZTEST_OBJS) $(ZW_OBJS) $(OBJS) $(DEX) $(ZEX) $(EX) $(TEST_OBJS) $(DOBJS) unit lib/*o src/*o
rolling: rolling_multk rolling_multk_sketch
mostlyclean:
rm -f $(ZOBJS) $(ZTEST_OBJS) $(ZW_OBJS) $(OBJS) $(DEX) $(ZEX) $(EX) $(TEST_OBJS) $(DOBJS) unit lib/*o src/*o