-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
74 lines (59 loc) · 2.15 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
DEBUG ?= 0
STATIC ?= 0
# Submodules
PWD = $(shell pwd)
SDSL_ROOT ?= ${PWD}/src/sdslLite/
EBROOTHTSLIB ?= ${PWD}/src/htslib/
JLIB ?= ${PWD}/src/jlib/
# Install dir
prefix = ${PWD}
exec_prefix = $(prefix)
bindir ?= $(exec_prefix)/bin
# Flags
CXX=g++
CXXFLAGS += -std=c++17 -isystem ${JLIB} -isystem ${EBROOTHTSLIB} -isystem ${SDSL_ROOT}/include -pedantic -W -Wall
LDFLAGS += -L${EBROOTHTSLIB} -L${EBROOTHTSLIB}/lib -L${SDSL_ROOT}/lib -lboost_iostreams -lboost_filesystem -lboost_system -lboost_program_options -lboost_date_time -ldl -lpthread
ifeq (${STATIC}, 1)
LDFLAGS += -static -static-libgcc -pthread -lhts -lz -llzma -lbz2 -ldeflate
else
LDFLAGS += -lhts -lz -llzma -lbz2 -Wl,-rpath,${EBROOTHTSLIB}
endif
ifeq (${DEBUG}, 1)
CXXFLAGS += -g -O0 -fno-inline -DDEBUG
else ifeq (${DEBUG}, 2)
CXXFLAGS += -g -O0 -fno-inline -DPROFILE
LDFLAGS += -lprofiler -ltcmalloc
else
CXXFLAGS += -O3 -fno-tree-vectorize -DNDEBUG
endif
ifeq (${EBROOTHTSLIB}, ${PWD}/src/htslib/)
SUBMODULES += .htslib
endif
ifeq (${SDSL_ROOT}, ${PWD}/src/sdslLite/)
SUBMODULES += .sdsl
endif
# External sources
SDSLSOURCES = $(wildcard src/xxsds/lib/*.cpp)
SOURCES = $(wildcard src/*.cpp) $(wildcard src/*.h)
HTSLIBSOURCES = $(wildcard src/htslib/*.c) $(wildcard src/htslib/*.h)
PBASE=$(shell pwd)
# Targets
BUILT_PROGRAMS = src/dicey
TARGETS = ${SUBMODULES} ${BUILT_PROGRAMS}
all: $(TARGETS)
.sdsl: $(SDSLSOURCES)
if [ -r src/xxsds/install.sh ]; then cd src/xxsds/ && ./install.sh ${PBASE}/src/sdslLite && cd ../../ && touch .sdsl; fi
.htslib: $(HTSLIBSOURCES)
if [ -r src/htslib/Makefile ]; then cd src/htslib && autoreconf -i && ./configure --disable-s3 --disable-gcs --disable-libcurl --disable-plugins && $(MAKE) && $(MAKE) lib-static && cd ../../ && touch .htslib; fi
src/dicey: ${SUBMODULES} ${SOURCES}
$(CXX) $(CXXFLAGS) [email protected] -o $@ $(LDFLAGS)
install: ${BUILT_PROGRAMS}
mkdir -p ${bindir}
install -p ${BUILT_PROGRAMS} ${bindir}
clean:
if [ -r src/htslib/Makefile ]; then cd src/htslib && $(MAKE) clean; fi
if [ -r src/xxsds/install.sh ]; then rm -rf src/sdslLite/; fi
rm -f $(TARGETS) $(TARGETS:=.o) ${SUBMODULES}
distclean: clean
rm -f ${BUILT_PROGRAMS}
.PHONY: clean distclean install all