-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
173 lines (137 loc) · 4.92 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
#CC = gcc
CFLAGS = -std=gnu99 -Wall -O3 -Wno-unused-variable -Wno-unused-function -Wno-misleading-indentation -DUSE_SIMDE -DSIMDE_ENABLE_NATIVE_ALIASES
# for debug
ifneq ($(debug),)
DFLAGS = -D __DEBUG__
endif
# for gdb
ifneq ($(gdb),)
CFLAGS = -g -Wall ${DFLAGS}
else
CFLAGS += ${DFLAGS}
endif
# for gprof
ifneq ($(pg),)
PG_FLAG = -pg
CFLAGS += -pg
endif
CPPFLAGS = $(CFLAGS)
#TODO different -I for different .c
BIN_DIR = ./bin
SRC_DIR = ./src
LIB_DIR = ./lib
LIB = -lm -lz -lpthread
INCLUDE = -IabPOA/include/simde
ifneq ($(BUILD_PREFIX),)
INCLUDE_FLAG = "INCLUDE=-I$(BUILD_PREFIX)/include"
LIB_FLAG = "-L$(BUILD_PREFIX)/lib"
endif
# edlib
EDLIB_DIR = ./edlib
EDLIB_INCLUDE = ./edlib/include
EDLIB = $(EDLIB_DIR)/src/edlib.o
#INCLUDE += -I$(EDLIB_INCLUDE)
# SIMD
FLAG_SSE4 = -msse4
FLAG_AVX2 = -mavx2
FLAG_AVX512F = -mavx512f
FLAG_AVX512BW = -mavx512bw
# abPOA
ABPOA_DIR = ./abPOA
ABPOA_INCLUDE = $(ABPOA_DIR)/include
ABPOALIB = ./lib/libabpoa.a
INCLUDE += -I$(ABPOA_INCLUDE)
ABPOA_SIMD_FLAG =
# ksw2
# TODO flag with sse
KSW2_DIR = ./ksw2
KSW2_INCLUDE = ./ksw2
#INCLUDE += -I$(KSW2_INCLUDE)
KSW2_SIMD_FLAG = -msse4.1
ifneq ($(sse2),)
KSW2_SIMD_FLAG = -msse2 -mno-sse4.1
ABPOA_SIMD_FLAG = "sse2=1"
else ifneq ($(sse41),)
KSW2_SIMD_FLAG = -msse4.1
ABPOA_SIMD_FLAG = "sse41=1"
else ifneq ($(sse4),)
KSW2_SIMD_FLAG = -msse4.1
ABPOA_SIMD_FLAG = "sse41=1"
else ifneq ($(avx2),)
KSW2_SIMD_FLAG = -msse4.1
ABPOA_SIMD_FLAG = "avx2=1"
endif
ifneq ($(armv7),) # for ARMv7
KSW2_SIMD_FLAG = -march=armv7-a -mfpu=neon -D__AVX2__
else
ifneq ($(armv8),) # for ARMv8
ifneq ($(aarch64),) # for Aarch64
KSW2_SIMD_FLAG = -march=armv8-a+simd -D__AVX2__
else # for Aarch32
KSW2_SIMD_FLAG = -march=armv8-a+simd -mfpu=auto -D__AVX2__
endif
endif
endif
CSOURCE = $(wildcard $(SRC_DIR)/*.c)
CSOURCE += $(wildcard $(KSW2_DIR)/*.c)
CPPSOURCE = $(wildcard $(SRC_DIR)/*.cpp)
CPPSOURCE += $(EDLIB_DIR)/src/edlib.cpp
SOURCE = $(CSOURCE) $(CPPSOURCE)
DSOURCE = $(SOURCE)
OBJS = $(CSOURCE:.c=.o) $(CPPSOURCE:.cpp=.o)
#OBJS += $(EDLIB)
BIN = $(BIN_DIR)/TideHunter
ifneq ($(gdb),)
BIN = $(BIN_DIR)/gdb_TideHunter
endif
# dependencies
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
.cpp.o:
$(CXX) -c $(CPPFLAGS) $(INCLUDE) $< -o $@
all: $(MINMAP2LIB) $(BIN)
TideHunter: $(BIN)
$(BIN): $(OBJS) $(ABPOALIB) Makefile
if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR); fi
$(CXX) $(CFLAGS) $(OBJS) $(ABPOALIB) $(INCLUDE) $(LIB) -o $@ $(PG_FLAG)
# edlib
$(EDLIB): $(EDLIB_DIR)/src/edlib.cpp $(EDLIB_DIR)/include/edlib.h
$(CXX) $(CFLAGS) -c $< $(INCLUDE) -I $(EDLIB_INCLUDE) -o $@
$(SRC_DIR)/edlib_align.o: $(SRC_DIR)/edlib_align.c $(SRC_DIR)/edlib_align.h
$(CC) -c $(CFLAGS) $< $(INCLUDE) -I $(EDLIB_INCLUDE) -o $@
# abPOA
$(ABPOALIB):
if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR); fi
cd $(ABPOA_DIR); \
make libabpoa PREFIX=$(PWD) $(ABPOA_SIMD_FLAG) $(INCLUDE_FLAG) CFLAGS="$(LIB_FLAG) $(CFLAGS)"
# ksw2
$(KSW2_DIR)/ksw2_extz2_sse.o: $(KSW2_DIR)/ksw2_extz2_sse.c $(KSW2_DIR)/ksw2.h
$(CC) -c $(CFLAGS) $(KSW2_SIMD_FLAG) $(INCLUDE) $< -o $@
$(KSW2_DIR)/ksw2_gg2_sse.o: $(KSW2_DIR)/ksw2_gg2_sse.c $(KSW2_DIR)/ksw2.h
$(CC) -c $(CFLAGS) $(KSW2_SIMD_FLAG) $(INCLUDE) $< -o $@
#$(SRC_DIR)/abpoa_cons.o: $(SRC_DIR)/abpoa_cons.c $(ABPOA)
# $(CC) -c $(CFLAGS) $< -I $(ABPOA_INCLUDE) $(INCLUDE) -o $@
# ksw2
$(SRC_DIR)/ksw2_align.o: $(SRC_DIR)/ksw2_align.c $(SRC_DIR)/ksw2_align.h
$(CC) -c $(CFLAGS) $< -I $(KSW2_INCLUDE) $(INCLUDE) -o $@
clean:
rm -f $(SRC_DIR)/*.o $(BIN)
clean_abPOA:
rm -f $(ABPOALIB); \
cd $(ABPOA_DIR); make clean; \
clean_ksw2:
rm -f $(KSW2_DIR)/*.o
clean_edlib:
rm -f $(EDLIB)
clean_all: clean clean_abPOA clean_ksw2 clean_edlib
$(SRC_DIR)/abpoa_cons.o: $(SRC_DIR)/tidehunter.h $(SRC_DIR)/seq.h $(ABPOA_INCLUDE)/abpoa.h $(ABPOA_INCLUDE)/simd_instruction.h
$(SRC_DIR)/edlib_align.o: $(SRC_DIR)/edlib_align.h $(SRC_DIR)/utils.h
$(SRC_DIR)/gen_cons.o: $(SRC_DIR)/utils.h $(SRC_DIR)/tidehunter.h $(SRC_DIR)/edlib_align.h $(SRC_DIR)/abpoa_cons.h $(SRC_DIR)/ksw2_align.h $(ABPOA_INCLUDE)/abpoa.h
$(SRC_DIR)/ksw2_align.o: $(SRC_DIR)/utils.h
$(SRC_DIR)/main.o: $(SRC_DIR)/utils.h $(SRC_DIR)/tidehunter.h $(SRC_DIR)/kseq.h $(SRC_DIR)/abpoa_cons.h $(ABPOA_INCLUDE)/abpoa.h
$(SRC_DIR)/partition.o: $(SRC_DIR)/utils.h $(SRC_DIR)/edlib_align.h $(SRC_DIR)/abpoa_cons.h $(SRC_DIR)/ksw2_align.h $(SRC_DIR)/tandem_chain.h
$(SRC_DIR)/seq.o: $(SRC_DIR)/utils.h $(SRC_DIR)/seq.h $(SRC_DIR)/kseq.h
$(SRC_DIR)/tandem_chain.o: $(SRC_DIR)/utils.h $(SRC_DIR)/tandem_chain.h $(SRC_DIR)/tandem_hit.h $(SRC_DIR)/tidehunter.h
$(SRC_DIR)/tandem_hit.o: $(SRC_DIR)/utils.h $(SRC_DIR)/ksort.h $(SRC_DIR)/tandem_hit.h $(SRC_DIR)/tidehunter.h
$(SRC_DIR)/tidehunter.o: $(SRC_DIR)/utils.h $(SRC_DIR)/tidehunter.h $(SRC_DIR)/tandem_chain.h $(SRC_DIR)/tandem_hit.h $(SRC_DIR)/partition.h $(SRC_DIR)/gen_cons.h $(SRC_DIR)/seq.h
$(SRC_DIR)/utils.o: $(SRC_DIR)/utils.h $(SRC_DIR)/ksort.h