Debian Codegraph @

Makefile

raw ◀ ▶
Source reconstructed at patch state 0 of 4 — not the installed (fully patched) source.
4 Debian patches touch this file
1 #
2
3 # Sub directories containing source code, except for the main programs
4 SUBDIRS := src src/hmm src/thirdparty src/thirdparty/scrappie src/common src/alignment src/pore_model src/io src/basemods
5
6 #
7 # Set libraries, paths, flags and options
8 #
9
10 #Basic flags every build needs
11 LIBS = -lz
12 CXXFLAGS ?= -g -O3
13 CXXFLAGS += -std=c++11 -fopenmp -fsigned-char -D_FILE_OFFSET_BITS=64
14 CFLAGS ?= -O3 -std=c99 -fsigned-char -D_FILE_OFFSET_BITS=64
15 LDFLAGS ?=
16 CXX ?= g++
17 CC ?= gcc
18
19 ifeq ($(zstd),1)
20 LDFLAGS += -lzstd
21 endif
22
23 # Change the value of HDF5, EIGEN, or HTS below to any value to disable compilation of bundled code
24 HDF5 ?= install
25 EIGEN ?= install
26 HTS ?= install
27 MINIMAP2 ?= install
28 SLOW5LIB ?= install
29
30 MACHINE := $(shell gcc -dumpmachine)
31
32 # when building on MacOS we only support gcc, but need to set some paths
33 ifneq (,$(findstring apple,$(MACHINE)))
34 SDK := $(shell xcrun --sdk macosx --show-sdk-path)
35 MAC_FLAGS = -isysroot $(SDK) -L/usr/lib
36 MAC=1
37 CXXFLAGS += $(MAC_FLAGS)
38 CFLAGS += $(MAC_FLAGS)
39 endif
40
41 ARM=0
42
43 # set an ARM-specific flag
44 ifneq (,$(findstring arm64,$(MACHINE)))
45 ARM=1
46 endif
47
48 # set an ARM-specific flag
49 ifneq (,$(findstring aarch64,$(MACHINE)))
50 ARM=1
51 endif
52
53 ifeq ($(MAC), 1)
54 HDF5_VERSION ?= 1.13.0
55 else
56 HDF5_VERSION ?= 1.8.14
57 endif
58
59 EIGEN_VERSION ?= 3.3.7
60
61 # Check operating system, OSX doesn't have -lrt
62 UNAME_S := $(shell uname -s)
63 ifeq ($(UNAME_S),Linux)
64 LIBS += -lrt
65 endif
66
67 # Default to automatically installing hdf5
68 ifeq ($(HDF5), install)
69 H5_LIB = ./lib/libhdf5.a
70 H5_INCLUDE = -I./include
71 LIBS += -ldl
72 else
73 # Use system-wide hdf5
74 H5_LIB =
75 H5_INCLUDE ?=
76 LIBS += -lhdf5
77 endif
78
79 # Default to automatically installing EIGEN
80 ifeq ($(EIGEN), install)
81 EIGEN_CHECK = eigen/INSTALL
82 EIGEN_INCLUDE = -I./eigen/
83 else
84 # Use system-wide eigen
85 EIGEN_CHECK =
86 EIGEN_INCLUDE ?=
87 endif
88
89 # Default to build and link the libhts submodule
90 ifeq ($(HTS), install)
91 HTS_LIB = ./htslib/libhts.a
92 HTS_INCLUDE = -I./htslib
93 else
94 # Use system-wide htslib
95 HTS_LIB =
96 HTS_INCLUDE ?=
97 LIBS += -lhts
98 endif
99
100 # Default to build and link the libminimap2 submodule
101 ifeq ($(MINIMAP2), install)
102 MINIMAP2_LIB = ./minimap2/libminimap2.a
103 MINIMAP2_INCLUDE = -I./minimap2
104 else
105 # Use system-wide htslib
106 MINIMAP2_LIB =
107 MINIMAP2_INCLUDE =
108 LIBS += -lminimap2
109 endif
110
111 # Default to build and link slow5 submodule
112 ifeq ($(SLOW5LIB), install)
113 SLOW5LIB_LIB = ./slow5lib/lib/libslow5.a
114 SLOW5LIB_INCLUDE = -I./slow5lib/include/
115 endif
116
117 ifeq ($(ARM), 1)
118 MINIMAP2_OPT += arm_neon=1
119 endif
120
121 # Include the src subdirectories
122 NP_INCLUDE = $(addprefix -I./, $(SUBDIRS))
123
124 # Add include flags
125 CPPFLAGS += $(H5_INCLUDE) $(HTS_INCLUDE) $(MINIMAP2_INCLUDE) $(NP_INCLUDE) $(EIGEN_INCLUDE) $(SLOW5LIB_INCLUDE)
126
127 # Main programs to build
128 PROGRAM = nanopolish
129 TEST_PROGRAM = nanopolish_test
130
131 .PHONY: all
132 all: depend $(PROGRAM)
133
134 #
135 # Build libhts
136 #
137 htslib/libhts.a:
138 cp etc/htslib_config.h htslib/config.h
139 $(MAKE) -C htslib CFLAGS="$(MAC_FLAGS)" LDFLAGS="$(MAC_FLAGS)" htslib_default_libs="-lz -lm -lbz2" NONCONFIGURE_OBJS="" || exit 255
140
141 minimap2/libminimap2.a:
142 $(MAKE) -C minimap2 $(MINIMAP2_OPT) CFLAGS="$(MAC_FLAGS)" libminimap2.a || exit 255
143
144 slow5lib/lib/libslow5.a:
145 $(MAKE) -C slow5lib CFLAGS="$(MAC_FLAGS)" || exit 255
146 #
147 # If this library is a dependency the user wants HDF5 to be downloaded and built.
148 #
149 lib/libhdf5.a:
150 if [ ! -e hdf5-$(HDF5_VERSION).tar.gz ]; then \
151 version_major_minor=`echo "$(HDF5_VERSION)" | sed -E 's/\.[0-9]+$$//'`; \
152 wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-$${version_major_minor}/hdf5-$(HDF5_VERSION)/src/hdf5-$(HDF5_VERSION).tar.gz; \
153 fi
154
155 tar -xzf hdf5-$(HDF5_VERSION).tar.gz || exit 255
156 cd hdf5-$(HDF5_VERSION) && \
157 ./configure CFLAGS="$(MAC_FLAGS)" CPPFLAGS="$(MAC_FLAGS)" --enable-threadsafe --disable-hl --libdir=`pwd`/../lib --includedir=`pwd`/../include --prefix=`pwd`/.. || exit 255
158 $(MAKE) -C hdf5-$(HDF5_VERSION) && $(MAKE) -C hdf5-$(HDF5_VERSION) install
159
160 # Download and install eigen if not already downloaded
161 eigen/INSTALL:
162 if [ ! -e $(EIGEN_VERSION).tar.bz2 ]; then \
163 wget https://gitlab.com/libeigen/eigen/-/archive/$(EIGEN_VERSION)/eigen-$(EIGEN_VERSION).tar.bz2; \
164 fi
165 tar -xjf eigen-$(EIGEN_VERSION).tar.bz2 || exit 255
166 mv eigen-$(EIGEN_VERSION) eigen || exit 255
167
168 #
169 # Source files
170 #
171
172 # Find the source files by searching subdirectories
173 CPP_SRC := $(foreach dir, $(SUBDIRS), $(wildcard $(dir)/*.cpp))
174 C_SRC := $(foreach dir, $(SUBDIRS), $(wildcard $(dir)/*.c))
175 EXE_SRC = src/main/nanopolish.cpp src/test/nanopolish_test.cpp
176
177 # Automatically generated object names
178 CPP_OBJ = $(CPP_SRC:.cpp=.o)
179 C_OBJ = $(C_SRC:.c=.o)
180
181 # Generate dependencies
182 .PHONY: depend
183 depend: .depend
184
185 .depend: $(CPP_SRC) $(C_SRC) $(EXE_SRC) $(H5_LIB) $(EIGEN_CHECK)
186 rm -f ./.depend
187 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM $(CPP_SRC) $(C_SRC) > ./.depend;
188
189 # Compile objects
190 .cpp.o:
191 $(CXX) -o $@ -c $(CXXFLAGS) $(CPPFLAGS) -fPIC $<
192
193 .c.o:
194 $(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $(H5_INCLUDE) -fPIC $<
195
196 # Link main executable
197 $(PROGRAM): src/main/nanopolish.o $(CPP_OBJ) $(C_OBJ) $(HTS_LIB) $(MINIMAP2_LIB) $(H5_LIB) $(EIGEN_CHECK) $(SLOW5LIB_LIB)
198 $(CXX) -o $@ $(CXXFLAGS) $(CPPFLAGS) -fPIC $< $(CPP_OBJ) $(C_OBJ) $(HTS_LIB) $(MINIMAP2_LIB) $(SLOW5LIB_LIB) $(H5_LIB) $(LIBS) $(LDFLAGS)
199
200 # Link test executable
201 $(TEST_PROGRAM): src/test/nanopolish_test.o $(CPP_OBJ) $(C_OBJ) $(HTS_LIB) $(MINIMAP2_LIB) $(H5_LIB) $(SLOW5LIB_LIB)
202 $(CXX) -o $@ $(CXXFLAGS) $(CPPFLAGS) -fPIC $< $(CPP_OBJ) $(C_OBJ) $(HTS_LIB) $(MINIMAP2_LIB) $(SLOW5LIB_LIB) $(H5_LIB) $(LIBS) $(LDFLAGS)
203
204 .PHONY: test
205 test: $(TEST_PROGRAM)
206 ./$(TEST_PROGRAM)
207
208 .PHONY: clean
209 clean:
210 rm -f $(PROGRAM) $(TEST_PROGRAM) $(CPP_OBJ) $(C_OBJ) \
211 src/main/nanopolish.o src/test/nanopolish_test.o