-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (143 loc) · 5.47 KB
/
Makefile
File metadata and controls
177 lines (143 loc) · 5.47 KB
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
GCC_CHECK := $(shell gcc --version | head -n 1 | grep -i "clang")
# Check if the OS is macOS or linux
UNAME_S := $(shell uname -s)
ifeq ($(GCC_CHECK),) # gcc
CXXFLAGS = -std=c++11
else # clang
CXXFLAGS = -std=c++11 -stdlib=libc++
endif
# add -fno-tree-vectorize to avoid certain vectorization errors in O3 optimization
# right now, we are using -O3 for the best performance, and no vectorization errors were found
EXTRA_FLAGS = -Wall -Wno-misleading-indentation -Wno-unused-function #-Wno-unused-variable -Wno-alloc-size-larger-than
# Define the version number
VERSION=0.0.10
# Get the Git commit hash
GIT_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null)
ifneq ($(GIT_COMMIT),)
LONGCALLD_VERSION = $(VERSION)-$(GIT_COMMIT)
else
LONGCALLD_VERSION = $(VERSION)
endif
HTSLIB_DIR = ./htslib
HTSLIB = $(HTSLIB_DIR)/libhts.a
EDLIB_DIR = ./edlib
EDLIB_INC_DIR = ./edlib/include
EDLIB = $(EDLIB_DIR)/src/edlib.o
ABPOA_DIR = ./abPOA
ABPOA_LIB = ./abPOA/lib/libabpoa.a
ABPOA_INC_DIR = $(ABPOA_DIR)/include
WFA2_DIR = ./WFA2-lib
WFA2_LIB = $(WFA2_DIR)/lib/libwfa.a
LIB_PATH =
LIB = $(HTSLIB) $(ABPOA_LIB) $(WFA2_LIB) $(LIB_PATH) -lm -lz -lpthread -llzma -lbz2 -lcurl
INCLUDE = -I $(HTSLIB_DIR) -I $(EDLIB_INC_DIR) -I $(ABPOA_INC_DIR) -I $(WFA2_DIR)
# Try linking against libdeflate
ifeq ($(shell echo "int main() {return 0;}" | ${CC} -x c - $(LIB_PATH) -ldeflate >/dev/null 2>&1 && echo "yes"),yes)
LIB += -ldeflate
endif
ifeq ($(UNAME_S),Linux) # Linux
LIB += -lcrypto
ifneq ($(portable),)
LIB += -static-libgcc -static-libstdc++
ifneq ($(opt_lib),)
LIB = $(HTSLIB) $(ABPOA_LIB) $(WFA2_LIB) -static-libgcc -static-libstdc++ -L${opt_lib} -lm -lz -lpthread -llzma -lbz2 -lcurl -lssl -lcrypto -lssh2 -ldeflate -lzstd
else
ifneq ($(OPT_LIB),)
LIB = $(HTSLIB) $(ABPOA_LIB) $(WFA2_LIB) -static-libgcc -static-libstdc++ -L${OPT_LIB} -lm -lz -lpthread -llzma -lbz2 -lcurl -lssl -lcrypto -lssh2 -ldeflate -lzstd
endif
endif
endif
endif
# for debug
ifneq ($(debug),)
EXTRA_FLAGS += -D __DEBUG__
endif
ABPOA_GDB_LIB = ./abPOA/lib/libabpoa_sse41.a
ABPOA_NOR_LIB = ./abPOA/lib/libabpoa.a
WFA_GDB_LIB = ./WFA2-lib/lib/libwfa_gdb.a
WFA_NOR_LIB = ./WFA2-lib/lib/libwfa.a
# for gdb
ifneq ($(gdb),)
OPT_FLAGS = -O0 -g
ABPOA_LIB = $(ABPOA_GDB_LIB)
WFA2_LIB = $(WFA_GDB_LIB)
else
OPT_FLAGS = -O3
ABPOA_LIB = $(ABPOA_NOR_LIB)
WFA2_LIB = $(WFA_NOR_LIB)
endif
CFLAGS = $(OPT_FLAGS) $(EXTRA_FLAGS) -DLONGCALLD_VERSION=\"$(LONGCALLD_VERSION)\"
# for gprof
ifneq ($(pg),)
OPT_FLAGS = -O3
PG_FLAG = -pg
CFLAGS += -pg
endif
ifneq ($(PREFIX),)
OUT_PRE_DIR = $(PREFIX)
else
OUT_PRE_DIR = .
endif
BIN_DIR = $(OUT_PRE_DIR)/bin
INC_DIR = ./include
SRC_DIR = ./src
HTS_ALL = hts_all
EDLIB_ALL = edlib_all
ABPOA_ALL = abpoa_all
WFA2_ALL = wfa2_all
CSOURCE = $(wildcard ${SRC_DIR}/*.c)
CPPSOURCE = $(wildcard $(SRC_DIR)/*.cpp)
CPPSOURCE += $(EDLIB_DIR)/src/edlib.cpp
OBJS = $(CSOURCE:.c=.o) $(CPPSOURCE:.cpp=.o)
BIN = $(BIN_DIR)/longcallD
ifneq ($(gdb),)
BIN = $(BIN_DIR)/gdb_longcallD
endif
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
all: $(HTS_ALL) $(EDLIB) $(ABPOA_LIB) $(WFA2_LIB) $(BIN)
$(HTS_ALL): $(HTSLIB)
$(HTSLIB): $(HTSLIB_DIR)/configure.ac
cd $(HTSLIB_DIR); autoreconf -i; ./configure; make CC=${CC}
$(EDLIB): $(EDLIB_DIR)/src/edlib.cpp $(EDLIB_DIR)/include/edlib.h
$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< $(INCLUDE) -o $@
$(EDLIB_ALL): $(EDLIB)
$(ABPOA_GDB_LIB):
cd $(ABPOA_DIR); make libabpoa gdb=1 sse41=1
$(ABPOA_NOR_LIB):
cd $(ABPOA_DIR); make libabpoa
$(ABPOA_ALL): $(ABPOA_LIB)
$(WFA2_LIB):
cd $(WFA2_DIR); make setup lib_wfa CC_FLAGS="$(CC_FLAGS) -O3"
$(WFA2_ALL): $(WFA2_LIB)
$(BIN): $(OBJS) $(ABPOA_LIB) $(HTSLIB) $(WFA2_LIB)
if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR); fi
$(CXX) $(OBJS) -o $@ $(LIB) $(PG_FLAG)
# $(CC) $(OBJS) -o $@ $(LIB) $(PG_FLAG)
$(SRC_DIR)/align.o: $(SRC_DIR)/align.c $(SRC_DIR)/align.h $(SRC_DIR)/utils.h $(SRC_DIR)/bam_utils.h $(SRC_DIR)/seq.h
$(CC) -c -DUSE_SIMDE -DSIMDE_ENABLE_NATIVE_ALIASES $(CFLAGS) $< $(INCLUDE) -o $@
$(SRC_DIR)/assign_aln_hap.o: $(SRC_DIR)/assign_aln_hap.c $(SRC_DIR)/assign_aln_hap.h $(SRC_DIR)/utils.h $(SRC_DIR)/bam_utils.h
$(SRC_DIR)/bam_utils.o: $(SRC_DIR)/bam_utils.c $(SRC_DIR)/bam_utils.h $(SRC_DIR)/utils.h
$(SRC_DIR)/cgranges.o: $(SRC_DIR)/cgranges.c $(SRC_DIR)/cgranges.h $(SRC_DIR)/khash.h
$(SRC_DIR)/collect_var.o: $(SRC_DIR)/collect_var.c $(SRC_DIR)/collect_var.h $(SRC_DIR)/bam_utils.h
$(SRC_DIR)/kalloc.o: $(SRC_DIR)/kalloc.c $(SRC_DIR)/kalloc.h
$(SRC_DIR)/kmedoids.o : $(SRC_DIR)/kmedoids.c $(SRC_DIR)/kmedoids.h
$(SRC_DIR)/kthread.o: $(SRC_DIR)/kthread.c
$(SRC_DIR)/main.o: $(SRC_DIR)/main.c $(SRC_DIR)/call_var_main.h
$(SRC_DIR)/call_var_main.o: $(SRC_DIR)/bam_utils.c $(SRC_DIR)/call_var_main.c $(SRC_DIR)/call_var_main.h $(SRC_DIR)/main.h $(SRC_DIR)/utils.h $(SRC_DIR)/seq.h \
$(SRC_DIR)/collect_var.h
$(SRC_DIR)/seq.o: $(SRC_DIR)/seq.c $(SRC_DIR)/seq.h $(SRC_DIR)/utils.h
$(SRC_DIR)/sdust.o: $(SRC_DIR)/sdust.c $(SRC_DIR)/sdust.h $(SRC_DIR)/kdq.h $(SRC_DIR)/kvec.h
$(SRC_DIR)/utils.o: $(SRC_DIR)/utils.c $(SRC_DIR)/utils.h $(SRC_DIR)/ksort.h $(SRC_DIR)/kseq.h
$(SRC_DIR)/vcf_utils.o: $(SRC_DIR)/vcf_utils.c $(SRC_DIR)/vcf_utils.h $(SRC_DIR)/utils.h
.PHONY: all hts_all abpoa_all wfa2_all clean clean_all clean_hts clean_abpoa clean_wfa2
clean:
rm -f $(SRC_DIR)/*.o $(BIN)
clean_all:
rm -f $(SRC_DIR)/*.o $(BIN) $(HTSLIB) $(ABPOA_LIB) $(WFA2_LIB)
clean_hts:
rm -f $(HTSLIB)
clean_abpoa:
rm -f $(ABPOA_LIB) $(ABPOA_DIR)/src/*.o
clean_wfa2:
rm -f $(WFA2_LIB)