-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathMakefile.common
163 lines (133 loc) · 5.34 KB
/
Makefile.common
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
## This Makefile store variable declarations shared for all libs/executables
##ROOT?=.
##################################################
## Third-party libs.
TABIX_INC = $(ROOT)/third/tabix
TABIX_LIB = $(ROOT)/third/tabix/libtabix.a
EIGEN_INC = $(ROOT)/third/eigen
EIGEN_LIB = # Eigen are header files only
PCRE_INC = $(ROOT)/third/pcre/include
PCRE_LIB = $(ROOT)/third/pcre/lib/libpcreposix.a $(ROOT)/third/pcre/lib/libpcre.a
GSL_INC = $(ROOT)/third/gsl/include
GSL_LIB = $(ROOT)/third/gsl/lib/libgsl.a
ZLIB_INC = $(ROOT)/third/zlib
ZLIB_LIB = $(ROOT)/third/zlib/libz.a
BZIP2_INC = $(ROOT)/third/bzip2
BZIP2_LIB = $(ROOT)/third/bzip2/libbz2.a
NLOPT_INC = $(ROOT)/third/nlopt/include
NLOPT_LIB = $(ROOT)/third/nlopt/lib/libnlopt.a
BCF_INC = $(ROOT)/third/samtools/bcftools
BCF_LIB = $(ROOT)/third/samtools/bcftools/libbcf.a
SAMTOOLS_INC = $(ROOT)/third/samtools
SAMTOOLS_LIB = $(ROOT)/third/samtools/libbam.a
RAPIDJSON_INC = $(ROOT)/third/rapidjson/include
RAPIDJSON_LIB = # We only use its headers
SQLITE_INC = $(ROOT)/third/sqlite/include
SQLITE_LIB = $(ROOT)/third/sqlite/lib/libsqlite3.a
ZSTD_INC = $(ROOT)/third/zstd/lib
ZSTD_LIB = $(ROOT)/third/zstd/lib/libzstd.a
CNPY_INC = $(ROOT)/third/cnpy
CNPY_LIB = $(ROOT)/third/cnpy/libcnpy.a
THIRD_INC = $(BCF_INC) $(SAMTOOLS_INC) $(TABIX_INC) $(EIGEN_INC) $(PCRE_INC) $(GSL_INC) $(ZLIB_INC) $(BZIP2_INC) $(NLOPT_INC) $(RAPIDJSON_INC) $(SQLITE_INC) $(ZSTD_INC) $(CNPY_INC)
THIRD_LIB = $(BCF_LIB) $(SAMTOOLS_LIB) $(TABIX_LIB) $(PCRE_LIB) $(GSL_LIB) $(ZLIB_LIB) $(BZIP2_LIB) $(NLOPT_LIB) $(SQLITE_LIB) $(ZSTD_LIB) $(CNPY_LIB)
##################################################
## Our libs.
BASE_INC = $(ROOT)/base
BASE_LIB = $(ROOT)/base/lib-base.a
BASE_LIB_DBG = $(ROOT)/base/lib-dbg-base.a
VCF_INC = $(ROOT)/libVcf
VCF_LIB = $(ROOT)/libVcf/lib-vcf.a
VCF_LIB_DBG = $(ROOT)/libVcf/lib-dbg-vcf.a
BGEN_INC = $(ROOT)/libBgen
BGEN_LIB = $(ROOT)/libBgen/lib-bgen.a
BGEN_LIB_DBG = $(ROOT)/libBgen/lib-dbg-bgen.a
REGRESSION_INC = $(ROOT)/regression
REGRESSION_LIB = $(ROOT)/regression/lib-regression.a
REGRESSION_LIB_DBG = $(ROOT)/regression/lib-dbg-regression.a
GONCALO_INC = $(ROOT)/libsrc
GONCALO_LIB = $(ROOT)/libsrc/lib-goncalo.a
GONCALO_LIB_DBG = $(ROOT)/libsrc/lib-dbg-goncalo.a
##################################################
## Common compiler options
CXX ?= g++
DEFAULT_CXXFLAGS = -D__STDC_LIMIT_MACROS -std=c++0x -Wall -Wno-unused-function $(OPENMP_FLAG) -DGIT_VERSION="\"$(GIT_VERSION)\""
INCLUDE = $(THIRD_INC) $(REGRESSION_INC) $(VCF_INC) $(BGEN_INC) $(BASE_INC) $(GONCALO_INC)
LIB = $(REGRESSION_LIB) $(VCF_LIB) $(BGEN_LIB) $(BASE_LIB) $(GONCALO_LIB) $(THIRD_LIB)
LIB_DBG = $(REGRESSION_LIB_DBG) $(VCF_LIB_DBG) $(BGEN_LIB_DBG) $(BASE_LIB_DBG) $(GONCALO_LIB_DBG) $(THIRD_LIB)
CXX_INCLUDE = $(addprefix -I, $(INCLUDE)) -I. -I$(ROOT)
CXX_LIB = $(LIB) -lm -lpthread
CXX_LIB_DBG = $(LIB_DBG) -lm -lpthread
##################################################
## Win32
ifneq ($(WIN32),)
CXX_LIB += -lws2_32
CXX_LIB_DBG += -lws2_32
endif
##################################################
## MKL library
USE_MKL ?=
MKL_ROOT = /home/zhanxw/intel/compilers_and_libraries
MKL_INCDIR = $(MKL_ROOT)/linux/mkl/include
MKL_LIBDIR = $(MKL_ROOT)/linux/mkl/lib/intel64/
MKL_RT_LIBDIR = $(MKL_ROOT)/linux/lib/intel64/
MKL_INC_FLAGS = -I $(MKL_INCDIR)
ifeq ($(USE_MKL), dynamic)
MKL_LINK_FLAGS = -L $(MKL_LIBDIR) \
-L $(MKL_RT_LIBDIR) \
-Wl,--start-group -lmkl_gnu_thread -lmkl_core -lmkl_intel_lp64 -Wl,--end-group \
-fopenmp -lm -ldl
else ifeq ($(USE_MKL), static)
MKL_LINK_FLAGS = -Wl,--start-group \
${MKL_ROOT}/linux/mkl/lib/intel64/libmkl_intel_lp64.a \
${MKL_ROOT}/linux/mkl/lib/intel64/libmkl_core.a \
${MKL_ROOT}/linux/mkl/lib/intel64/libmkl_intel_thread.a \
/home/zhanxw/intel/compilers_and_libraries_2016.3.210/linux/compiler/lib/intel64/libiomp5.a \
-Wl,--end-group -fopenmp -lpthread -lm -ldl
else ifeq ($(USE_MKL),)
else
$(error "Unsupported paramter for USE_MKL")
endif
ifneq ($(USE_MKL),)
DEFAULT_CXXFLAGS += -DEIGEN_USE_MKL_ALL
DEFAULT_CXXFLAGS += $(MKL_INC_FLAGS)
CXX_INCLUDE += -DEIGEN_USE_MKL_ALL
CXX_INCLUDE += $(MKL_INC_FLAGS)
CXX_LIB += $(MKL_LINK_FLAGS)
endif
##################################################
## BLAS library
USE_BLAS =
ifneq ($(USE_BLAS),)
DEFAULT_CXXFLAGS += -DEIGEN_USE_BLAS #-DEIGEN_USE_LAPACKE
DEFAULT_CXXFLAGS +=
CXX_INCLUDE += -DEIGEN_USE_BLAS #-DEIGEN_USE_LAPACKE
CXX_INCLUDE +=
CXX_LIB += /home/zhanxw/software/OpenBLAS-0.2.18/libopenblas.a
endif
##################################################
## Platform dependent variables
ARCH := $(firstword $(shell uname -m))
SYS := $(firstword $(shell uname -s))
ifeq ($(SYS), Linux)
STATIC_FLAG ?= -static
OPENMP_FLAG = -fopenmp
endif
ifeq ($(SYS), Darwin)
DEFAULT_CXXFLAGS += -m64
endif
##################################################
## format
##################################################
.PHONY: format
format: *.cpp *.h
clang-format -i -style google $^
##################################################
## lint
##################################################
.PHONY: lint
lint: *.cpp *.h
cpplint.py --filter=-legal/copyright $^
##################################################
## Git version
##################################################
GIT_VERSION := $(shell git rev-parse HEAD || echo Unknown)