File: Makefile

package info (click to toggle)
proteinortho 6.0.28%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,160 kB
  • sloc: perl: 4,487; cpp: 3,560; python: 655; makefile: 329; ansic: 266; sh: 27
file content (397 lines) | stat: -rw-r--r-- 24,432 bytes parent folder | download
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# This makefile is part of Proteinortho.
##########################################

# Run 'make' for compiling everything in the current directory (using the installed version of lapack in e.g. /usr/lib/, you can install lapack with e.g. apt-get install libatlas3-base or liblapack3)
# Run 'make STATIC=TRUE' for a static version
# Run 'make USELAPACK=FALSE' for a version without(!) LAPACK (only power iteration is used)
# Run 'make USEPRECOMPILEDLAPACK=FALSE' for directly recompiling the provided lapack version 3.8.0 and linking dynamically

# Run 'make CXX=g++-7' for using the g++-7 compiler. See Flags below for more informations
# Run 'make CXX=clang++' for using the clang compiler

# Run 'make install' for installing the compiled files to /usr/local/bin
# Run 'make install PREFIX=/home/paul/bin/' for local installation

############ OPTIONS: ##########################################
## STATIC=TRUE : enable static compiling (default:FALSE) 
## CXX=g++ : the g++ compiler
## CXXFLAGS = compiler flags passed to g++
## CXXLIBRARY = the path to the libs like lapack,... (dont forget the -L)
## CXXINCLUDE = include path (^) (dont forget the -I)
## PREFIX = the installation prefix (only for make install)
################################################################

##########################
## enviroment variables ##
##########################

# ALIAS for PREFIX
INSTALLDIR=/usr/local/bin
# ALIAS for LAPACK
USELAPACK=TRUE
# compile statically
STATIC=FALSE

DEPLOY=FALSE

ifdef static
STATIC=$(static)
endif
ifdef PREFIX
INSTALLDIR=$(PREFIX)
endif
ifdef prefix
INSTALLDIR=$(prefix)
endif
ifdef installdir
INSTALLDIR=$(installdir)
endif
ifdef LAPACK
USELAPACK=$(LAPACK)
endif

ifeq ($(STATIC),true)
STATIC=TRUE
endif

USEPRECOMPILEDLAPACK=TRUE

UNAME_S=$(shell uname -s)_$(shell uname -m)
# output dir of make (make install moves these to PREFIX)
BUILDDIR=src/BUILD/$(UNAME_S)

CC=cc
CXX=g++

IS_COLOR_COMPATIBLE:=$(shell tput color 2>/dev/null)
ifdef IS_COLOR_COMPATIBLE
RED=\033[1;31m
GREEN=\033[1;32m
ORANGE=\033[1;33m
NC=\033[0m
endif

##############
# MAKEFILE : #
##############

dir_guard=@if [ ! -d $(BUILDDIR) ]; then echo "Creating build directory ..."; mkdir -p $(BUILDDIR); fi

.PHONY: all
all:$(BUILDDIR)/proteinortho_extract_from_graph.pl $(BUILDDIR)/proteinortho_compareProteinorthoGraphs.pl $(BUILDDIR)/proteinortho_grab_proteins.pl $(BUILDDIR)/proteinortho_formatUsearch.pl $(BUILDDIR)/proteinortho_do_mcl.pl $(BUILDDIR)/proteinortho2tree.pl $(BUILDDIR)/proteinortho2html.pl $(BUILDDIR)/proteinortho2xml.pl $(BUILDDIR)/proteinortho_singletons.pl $(BUILDDIR)/proteinortho_summary.pl $(BUILDDIR)/proteinortho_ffadj_mcs.py $(BUILDDIR)/proteinortho_clustering $(BUILDDIR)/proteinortho_history.pl $(BUILDDIR)/proteinortho_graphMinusRemovegraph $(BUILDDIR)/proteinortho_cleanupblastgraph $(BUILDDIR)/proteinortho_treeBuilderCore
	@echo "[100%] $(GREEN)Everything is compiled with no errors.$(NC)"

$(BUILDDIR)/proteinortho_extract_from_graph.pl: src/proteinortho_extract_from_graph.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_compareProteinorthoGraphs.pl: src/proteinortho_compareProteinorthoGraphs.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_grab_proteins.pl: src/proteinortho_grab_proteins.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_do_mcl.pl: src/proteinortho_do_mcl.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_formatUsearch.pl: src/proteinortho_formatUsearch.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho2html.pl: src/proteinortho2html.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho2xml.pl: src/proteinortho2xml.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_singletons.pl: src/proteinortho_singletons.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho2tree.pl: src/proteinortho2tree.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_ffadj_mcs.py: src/proteinortho_ffadj_mcs.py
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_history.pl: src/proteinortho_history.pl
	$(dir_guard)
	@cp $< $@

$(BUILDDIR)/proteinortho_summary.pl: src/proteinortho_summary.pl
	$(dir_guard)
	@cp $< $@

echoENV:
	@echo -n "CC = "
	@echo $(CC)
	@echo -n "CCFLAGS = "
	@echo $(CCFLAGS)
	@echo -n "CXX = "
	@echo $(CXX)
	@echo -n "CXXFLAGS = "
	@echo $(CXXFLAGS)
	@echo -n "LDFLAGS = "
	@echo $(LDFLAGS)
	@echo -n "LDLIBS = "
	@echo $(LDLIBS)

# 1. Try to compile statically with LAPACK
# 2. try to compile dynamically with the given lapack lib in src/

$(BUILDDIR)/proteinortho_clustering: src/proteinortho_clustering.cpp
	$(dir_guard)
	@echo "[ 10%] Prepare proteinortho_clustering ..."

ifeq ($(DEPLOY),TRUE)
	@echo "[ 20%] Building **proteinortho_clustering** with LAPACK (dynamic linking, no mtune,march , for gitlab)";
	@echo "$(CXX) -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath" && $(CXX) -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] ) 
else
ifeq ($(USELAPACK),TRUE)
ifeq ($(USEPRECOMPILEDLAPACK),TRUE)
ifeq ($(STATIC),TRUE)
	@echo "[ 20%] Building **proteinortho_clustering** with LAPACK (static linking)";
	@echo "$(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath" && $(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] ) || ( \
		echo "......$(ORANGE)dynamic linking failed too, now I try dynamic linking without -WL,-whole-archive... (this should now work for OSX).$(NC)"; \
			echo "$(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread" && $(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
			echo "......$(ORANGE) failed, I try without them again.$(NC)"; \
			echo "$(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath" && $(CXX) -O2 -static $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -Wl,--allow-multiple-definition -llapack -lblas -lgfortran -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lquadmath && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] ) || ( \
				echo "......$(ORANGE)static linking failed, now I try dynamic linking.$(NC)"; \
				echo "$(CXX) -O2  $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" && $(CXX) -O2  $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
					echo "......$(ORANGE)dynamic linking failed too, now I try dynamic linking without -WL,-whole-archive (this should now work for OSX).$(NC)"; \
					echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
						echo "......$(ORANGE)dynamic linking failed (without -WL,-whole-archive) too too, now I try to openblas.$(NC)"; \
						echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -lopenblas -pthread -lpthread" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -lopenblas -pthread -lpthread && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
							echo "......$(ORANGE)last linking failed too too too, now I try to recompile lapack (v.3.8.0) and then compile proteinortho_clustering with dynamic linking.$(NC)"; \
							echo "......[ 33%] Extracting the LAPACK library"; \
							if [ ! -d src/lapack-3.8.0 ]; then echo "cd src; tar -xzvf lapack-3.8.0.tar.gz"; cd src; tar -xzvf lapack-3.8.0.tar.gz > /dev/null 2>&1; cd ..; fi; \
							echo "......[ 66%] Compiling the LAPACK library (using cmake + make)"; \
							if [ ! -f src/lapack-3.8.0/build/lib/liblapack.a ]; then echo " mkdir src/lapack-3.8.0/build; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX) > /dev/null; make all -j4 "; mkdir src/lapack-3.8.0/build 2> /dev/null; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX) > /dev/null; make all -j4 > /dev/null 2>&1; cd ../../.. ; fi; \
							echo "......[ 99%] Building **proteinortho_clustering** with LAPACK (dynamic linking)"; \
							echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran && echo "......OK dynamic linking was successful for proteinortho_clustering!" || ( echo "" ) ; ) ) ) ) ) )
else
	@echo "[ 20%] Building **proteinortho_clustering** with LAPACK (dynamic linking)";
	@echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
		echo "......$(ORANGE) failed, I try without them again.$(NC)"; \
		echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
			echo "......$(ORANGE)dynamic linking failed too, now I try dynamic linking without -WL,-whole-archive (this should now work for OSX).$(NC)"; \
			echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -llapack -lblas -pthread -lpthread && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
				echo "......$(ORANGE)dynamic linking failed (without -WL,-whole-archive) too too, now I try to openblas.$(NC)"; \
				echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -lopenblas -pthread -lpthread" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp  -o $@ $< $(LDFLAGS) $(LDLIBS) -lopenblas -pthread -lpthread && ([ $$? -eq 0 ] && $@ -test && [ $$? -eq 0 ] && echo "......OK dynamic linking was successful for proteinortho_clustering!";) || ( \
					echo "......$(ORANGE)last linking failed too too too, now I try to recompile lapack (v.3.8.0) and then compile proteinortho_clustering with dynamic linking.$(NC)"; \
					echo "......[ 33%] Extracting the LAPACK library"; \
					if [ ! -d src/lapack-3.8.0 ]; then echo "cd src; tar -xzvf lapack-3.8.0.tar.gz"; cd src; tar -xzvf lapack-3.8.0.tar.gz > /dev/null 2>&1; cd ..; fi; \
					echo "......[ 66%] Compiling the LAPACK library (using cmake + make)"; \
					if [ ! -f src/lapack-3.8.0/build/lib/liblapack.a ]; then echo "mkdir src/lapack-3.8.0/build; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX) > /dev/null; make all -j4"; mkdir src/lapack-3.8.0/build 2> /dev/null; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX) > /dev/null; make all -j4 > /dev/null 2>&1; cd ../../.. ; fi; \
					echo "......[ 99%] Building **proteinortho_clustering** with LAPACK (dynamic linking)"; \
					echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran && echo "......OK dynamic linking was successful for proteinortho_clustering!" || ( echo "" ) ; ) ) ) )
endif
	@if [ ! -e $(BUILDDIR)/proteinortho_clustering ]; then echo "proteinortho_clustering compilation failed. Please visit https://gitlab.com/paulklemm_PHD/proteinortho/wikis/Error%20Codes"; false; fi
else
	@echo "[ 15%] Extracting the LAPACK library";
	@if [ ! -d src/lapack-3.8.0 ]; then echo "cd src; tar -xzvf lapack-3.8.0.tar.gz"; cd src; tar -xzvf lapack-3.8.0.tar.gz > /dev/null 2>&1; cd ..; fi;
	@echo "[ 18%] Compiling the LAPACK library (using cmake + make)";
	@if [ ! -f src/lapack-3.8.0/build/lib/liblapack.a ]; then echo "mkdir src/lapack-3.8.0/build; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX); make all -j4"; mkdir src/lapack-3.8.0/build; cd src/lapack-3.8.0/build; cmake .. -DCMAKE_CXX_COMPILER=$(CXX) > /dev/null 2>&1; make all -j4 > /dev/null 2>&1; cd ../../.. ; fi;
	@echo "[ 20%] Building **proteinortho_clustering** with LAPACK (dynamic linking)";
	@echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ $< -Isrc/lapack-3.8.0/build/include/ -Lsrc/lapack-3.8.0/build/lib/ -llapack -lblas $(LDFLAGS) $(LDLIBS) -lgfortran;
endif
endif
ifeq ($(USELAPACK),FALSE)
	@echo "[ 20%] Building **proteinortho_clustering** WITHOUT(!) LAPACK";
	@echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ src/proteinortho_clustering_nolapack.cpp $(LDFLAGS) $(LDLIBS) -static" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ src/proteinortho_clustering_nolapack.cpp $(LDFLAGS) $(LDLIBS) -static && ([ $$? -eq 0 ] ) || ( \
		echo "......$(ORANGE)static linking failed of proteinortho_clustering_nolapack, now i switch to dynamic linking.$(NC)"; \
		echo "$(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ src/proteinortho_clustering_nolapack.cpp $(LDFLAGS) $(LDLIBS)" && $(CXX) -O2 $(CPPFLAGS) $(CXXFLAGS) -fopenmp -o $@ src/proteinortho_clustering_nolapack.cpp $(LDFLAGS) $(LDLIBS) && echo "......OK dynamic linking was successful for proteinortho_clustering_nolapack!"; )
endif
endif

$(BUILDDIR)/proteinortho_cleanupblastgraph: src/cleanupblastgraph.cpp
	$(dir_guard)
	@echo "[ 50%] Building **cleanupblastgraph**"
ifeq ($(STATIC),TRUE)
	@echo "$(CXX) -std=c++11 $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static" && $(CXX) -std=c++11 $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static && ([ $$? -eq 0 ] ) || ( \
		echo "......$(ORANGE)static linking failed of cleanupblastgraph, now i switch to dynamic linking.$(NC)"; \
		echo "$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)" && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) && echo "......OK dynamic linking was successful of cleanupblastgraph!"; )
else
	@echo "$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)" && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)
endif

$(BUILDDIR)/proteinortho_graphMinusRemovegraph: src/graphMinusRemovegraph.cpp
	$(dir_guard)
	@echo "[ 25%] Building **graphMinusRemovegraph**"
ifeq ($(STATIC),TRUE)
	@echo "$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static" && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static && ([ $$? -eq 0 ] ) || ( \
		echo "......$(ORANGE)static linking failed of graphMinusRemovegraph, now i switch to dynamic linking.$(NC)"; \
		echo "$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $<" && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< && echo "......OK dynamic linking was successful of graphMinusRemovegraph!"; )
else
	@echo "$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)" && $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)
endif

$(BUILDDIR)/proteinortho_treeBuilderCore: src/po_tree.c
	$(dir_guard)
	@echo "[ 75%] Building **po_tree**"
ifeq ($(STATIC),TRUE)
	@echo "$(CC) $(CPPFLAGS) $(CCFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static" && $(CC) $(CPPFLAGS) $(CCFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -static && ([ $$? -eq 0 ] ) || ( \
		echo "......$(ORANGE)static linking failed of po_tree, now i switch to dynamic linking.$(NC)"; \
		echo "$(CC) $(CPPFLAGS) $(CCFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)" && $(CC) $(CPPFLAGS) $(CCFLAGS) $(CFLAGS) -o $@ $<  $(LDFLAGS) $(LDLIBS) && echo "......OK dynamic linking was successful of po_tree!"; )
else
	$(CC) $(CPPFLAGS) $(CCFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS)
endif

.PHONY: install
install: proteinortho6.pl proteinortho $(BUILDDIR)/proteinortho_extract_from_graph.pl $(BUILDDIR)/proteinortho_formatUsearch.pl $(BUILDDIR)/proteinortho_compareProteinorthoGraphs.pl $(BUILDDIR)/proteinortho_do_mcl.pl $(BUILDDIR)/proteinortho2html.pl $(BUILDDIR)/proteinortho2xml.pl $(BUILDDIR)/proteinortho_clustering $(BUILDDIR)/proteinortho_singletons.pl $(BUILDDIR)/proteinortho_ffadj_mcs.py $(BUILDDIR)/proteinortho2tree.pl $(BUILDDIR)/proteinortho_history.pl $(BUILDDIR)/proteinortho_cleanupblastgraph $(BUILDDIR)/proteinortho_graphMinusRemovegraph $(BUILDDIR)/proteinortho_treeBuilderCore $(BUILDDIR)/proteinortho_grab_proteins.pl $(BUILDDIR)/proteinortho_summary.pl $(BUILDDIR)/proteinortho_history.pl 
	@echo "INSTALLING everything to $(INSTALLDIR)"
	@install -v $^ $(INSTALLDIR);
	@echo "$(GREEN)Everything installed successfully to $(INSTALLDIR).$(NC)"
	@echo "If needed you can add $(INSTALLDIR) to \$$PATH with 'export PATH=\$$PATH:$(INSTALLDIR)'."

.PHONY: test
test: proteinortho6.pl test_clean test_step2 test_step3 test_clean2
	@echo "[TEST] All tests $(GREEN)passed$(NC)"

.PHONY: test_step2
test_step2: proteinortho6.pl
	@echo "[TEST] 1. basic proteinortho6.pl -step=2 test. (algorithms that are not present are skipped)"
	@echo -n " [1/12] -p=blastp test: "
	@if [ "$(shell which blastp)" = "" ]; then\
		echo "$(ORANGE)blastp missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_blastp -p=blastp test/*.faa; \
		set -e ; ./src/chk_test.pl test_blastp.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [2/12] -p=blastp+ synteny (PoFF) test: "
	@if [ "$(shell which blastp)" = "" ]; then\
		echo "$(ORANGE)blastp missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_synteny -synteny -singles -p=blastp+ test/*.faa; \
		set -e ; ./src/chk_test.pl test_synteny.proteinortho.tsv; \
		set -e ; ./src/chk_test.pl test_synteny.poff.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [3/12] -p=diamond test: "
	@if [ "$(shell which diamond-aligner)" = "" ]; then\
		echo "$(ORANGE)diamond missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_diamond -p=diamond test/*.faa; \
		set -e ; ./src/chk_test.pl test_diamond.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [4/12] -p=diamond (--moresensitive) test (subparaBlast): "
	@if [ "$(shell which diamond-aligner)" = "" ]; then\
		echo "$(ORANGE)diamond missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_diamondmoresensitive -p=diamond -subparaBlast="--more-sensitive" test/*.faa; \
		set -e ; ./src/chk_test.pl test_diamondmoresensitive.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [5/12] -p=lastp (lastal) test: "
	@if [ "$(shell which lastal)" = "" ]; then\
		echo "$(ORANGE)lastal missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_lastp -p=lastp test/*.faa; \
		set -e ; ./src/chk_test.pl test_lastp.proteinortho.tsv ; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [6/12] -p=topaz test: "
	@if [ "$(shell which topaz)" = "" ]; then\
		echo "$(ORANGE)topaz missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_topaz -p=topaz test/*.faa; \
		set -e ; ./src/chk_test.pl test_topaz.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [7/12] -p=usearch test: "
	@if [ "$(shell which usearch)" = "" ]; then\
		echo "$(ORANGE)usearch missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_usearch -p=usearch test/*.faa; \
		set -e ; ./src/chk_test.pl test_usearch.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [8/12] -p=ublast test: "
	@if [ "$(shell which usearch)" = "" ]; then\
		echo "$(ORANGE)usearch missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_ublast -p=ublast test/*.faa; \
		set -e ; ./src/chk_test.pl test_ublast.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [9/12] -p=rapsearch test: "
	@if [ "$(shell which rapsearch)" = "" ]; then\
		echo "$(ORANGE)rapsearch missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_rapsearch -p=rapsearch test/*.faa; \
		set -e ; ./src/chk_test.pl test_rapsearch.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [10/12] -p=blatp (blat) test: "
	@if [ "$(shell which blat)" = "" ]; then\
		echo "$(ORANGE)blat missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_blatp -p=blatp test/*.faa; \
		set -e ; ./src/chk_test.pl test_blatp.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [11/12] -p=mmseqsp (mmseqs) test: "
	@if [ "$(shell which mmseqs)" = "" ]; then\
		echo "$(ORANGE)mmseqs missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_mmseqsp -p=mmseqsp test/*.faa; \
		set -e ; ./src/chk_test.pl test_blatp.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

	@echo -n " [12/12] -p=autoblast (automatically detect blastp,blastn,...) test: "
	@if [ "$(shell which blastall)" = "" ]; then\
		echo "$(ORANGE)blastall missing, skipping...$(NC)"; \
	else \
		./proteinortho6.pl -silent -force -project=test_autoblast -p=autoblast test/*.faa; \
		set -e ; ./src/chk_test.pl test_autoblast.proteinortho.tsv; \
		echo "$(GREEN)passed$(NC)"; \
	fi

.PHONY: test_step3
test_step3: proteinortho6.pl test_step2
	@echo "[TEST] 2. -step=3 tests (proteinortho_clustering) "
	@echo -n " [1/2] various test functions of proteinortho_clustering (if this fails, try make clean first): "; \
	$(BUILDDIR)/proteinortho_clustering -test> /dev/null 2>&1
	@echo "$(GREEN)passed$(NC)"
	@echo -n " [2/2] Compare results of 'with lapack' and 'without lapack': "; \
	$(BUILDDIR)/proteinortho_clustering -epsilon 0 test_blastp.blast-graph> /dev/null 2>&1; \
	sort remove.graph -o test.A> /dev/null 2>&1; \
	$(BUILDDIR)/proteinortho_clustering -epsilon 0 -lapack 0 test_blastp.blast-graph> /dev/null 2>&1; \
	sort remove.graph -o test.B> /dev/null 2>&1; \
	set -e ; diff test.A test.B;
	@echo "$(GREEN)passed$(NC)"

.PHONY: test_clean
test_clean:
	@echo "[TEST] Clean up all test files..."; \
	rm -rf proteinortho_cache_test_* test.* test_* test/C.faa.* test/E.faa.* test/C2.faa.* test/L.faa.* test/M.faa.*> /dev/null 2>&1;

.PHONY: test_clean2
test_clean2:
	@echo "[TEST] Clean up all test files..."; \
	rm -rf proteinortho_cache_test_* test.* test_* test/C.faa.* test/E.faa.* test/C2.faa.* test/L.faa.* test/M.faa.*> /dev/null 2>&1;

.PHONY: clean
clean:
	rm -rf src/BUILD test/C.faa.* test/E.faa.* test/C2.faa.* test/L.faa.* test/M.faa.*
	rm -rf src/lapack-3.8.0/