source: branches/ali/Makefile

Last change on this file was 19440, checked in by westram, 21 months ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 87.4 KB
Line 
1# =============================================================== #
2#                                                                 #
3#   File      : Makefile                                          #
4#                                                                 #
5#   Institute of Microbiology (Technical University Munich)       #
6#   http://www.arb-home.de/                                       #
7#                                                                 #
8# =============================================================== #
9
10# -----------------------------------------------------
11# The ARB Makefile is aware of the following defines:
12#
13# CC                    C compiler (should be defined by OS)
14# CXX                   C++ compiler (should be defined by OS)
15#
16# DEVELOPER=name        special compilation (values: ANY,RELEASE,your name)
17# OPENGL=0/1            whether OPENGL is available
18#
19# -----------------------------------------------------
20# Paths for several libraries may be set from config.makefile by using:
21#
22#     export XLIBS=$(shell pkg-config --libs xpm xerces-c)
23#     export XINCLUDES=$(shell pkg-config --cflags x11)
24#     export XAW_LIBS=$(shell pkg-config --libs xaw7)
25#     export XML_INCLUDES=$(shell pkg-config --cflags xerces-c)
26#
27# You make have to explicitely point pkg-config to the *.pc files needed.
28# For example, Xquartz X11 libraries on macOS can be located by adding
29# the following line before those given above:
30#
31#     export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig
32#
33# If you introduce a new variable that is handled as described above,
34# please add to section .@InjectedEnvironment
35#
36# -----------------------------------------------------
37# ARB Makefile and ARB source code are aware of the following defines:
38#
39# $(MACH)               name of the machine (LINUX or DARWIN; see config.makefile)
40# DEBUG                 compiles the DEBUG sections
41# DEBUG_GRAPHICS        all X-graphics are flushed immediately (for debugging)
42# ARB_64=0/1            1=>compile 64 bit version
43# UNIT_TESTS=0/1        1=>compile in unit tests and call them after build
44# COVERAGE=0/1/2        compile in gcov support (useful together with UNIT_TESTS=1)
45#                       0=no, 1+2=compile in, 1=show
46# STABS=0/1             force stabs format? (0 = "use default format")
47# SANITIZE=0/#/all      use Sanitizer? (defaults to 0,
48#                                       1=AddressSanitizer+LeakSanitizer,
49#                                       2=UndefinedBehaviorSanitizer,
50#                                       combine bit-values to activate multiple Sanitizers,
51#                                       specify 'all' to activate all)
52# IGNORE_LEAKS=1        does not abort when leaks are detected (while using SANITIZE=1/all)
53# SHOWTODO=0/1          activate TODO-warnings? (defaults to 0, except for ralf)
54#
55# -----------------------------------------------------
56# The ARB source code is aware of the following defines:
57#
58# NDEBUG                doesn't compile the DEBUG sections
59# DEVEL_$(DEVELOPER)    developer-dependent flag (enables you to have private sections in code)
60#                       DEVELOPER='ANY' (default setting) will be ignored
61#                       configurable in config.makefile
62#
63# -----------------------------------------------------
64
65ifndef ARB_ORG_MAKEFLAGS
66 ARB_ORG_MAKEFLAGS=$(MAKEFLAGS)
67else
68 ifeq ($(ARB_ORG_MAKEFLAGS),)
69  ARB_ORG_MAKEFLAGS=$(MAKEFLAGS)
70 endif
71endif
72
73# Read configuration
74include config.makefile
75CONFIG_MAKEFILE_FOUND=$(strip $(wildcard config.makefile))
76
77# strip spaces from values defined in config.makefile
78# (otherwise they easily have spaces appended)
79ifdef DEVELOPER
80 DEVELOPER := $(strip $(DEVELOPER))
81endif
82ifdef OPENGL
83 OPENGL := $(strip $(OPENGL))
84endif
85ifdef ISINA
86 ISINA := $(strip $(ISINA))
87endif
88ifdef DEBUG
89 DEBUG := $(strip $(DEBUG))
90endif
91ifdef UNIT_TESTS
92 UNIT_TESTS := $(strip $(UNIT_TESTS))
93endif
94ifdef COVERAGE
95 COVERAGE := $(strip $(COVERAGE))
96endif
97ifdef SHOWTODO
98 SHOWTODO := $(strip $(SHOWTODO))
99endif
100ifdef STABS
101 STABS := $(strip $(STABS))
102endif
103ifdef TRACESYM
104 TRACESYM := $(strip $(TRACESYM))
105endif
106ifdef DEBUG_GRAPHICS
107 DEBUG_GRAPHICS := $(strip $(DEBUG_GRAPHICS))
108endif
109
110# set defaults for (or strip) variables commented out in config.makefile:
111ifdef SANITIZE
112 SANITIZE := $(strip $(SANITIZE))
113else
114 SANITIZE:=0
115endif
116ifdef IGNORE_LEAKS
117 IGNORE_LEAKS := $(strip $(IGNORE_LEAKS))
118else
119 IGNORE_LEAKS:=0
120endif
121ifndef DARWIN
122 DARWIN:=0
123else
124 DARWIN := $(strip $(DARWIN))
125endif
126ifndef LINUX
127 LINUX:=0
128else
129 LINUX := $(strip $(LINUX))
130endif
131ifndef DEBIAN
132 DEBIAN:=0
133else
134 DEBIAN := $(strip $(DEBIAN))
135endif
136ifndef ARB_64
137 ARB_64=1#default to 64bit
138else
139 ARB_64 := $(strip $(ARB_64))
140endif
141
142# Variables allowed for injection [InjectedEnvironment]
143# (alternatively initialize them with '?=', e.g. done for XLIBS and XINCLUDES)
144# In both cases add them to SOURCE_TOOLS/export2sub
145ifndef XML_INCLUDES
146 XML_INCLUDES=
147endif
148ifndef XAW_LIBS
149 XAW_LIBS=
150endif
151
152
153ifneq ($(CONFIG_MAKEFILE_FOUND),)
154 ifneq ($(DARWIN)$(LINUX),10)
155  ifneq ($(DARWIN)$(LINUX),01)
156   $(error exactly one of DARWIN=1 or LINUX=1 has to be defined (got:$(DARWIN)$(LINUX)))
157  endif
158 endif
159endif
160
161# compiler settings:
162ifneq ($(CC),use__A_CC__instead_of__CC)
163 A_CC:=$(CC)# compile C
164 A_CXX:=$(CXX)# compile C++
165
166# uncomment to ensure no submakefile uses CC and CXX directly
167 override CC:=use__A_CC__instead_of__CC
168 override CXX:=use__A_CXX__instead_of__CXX
169endif
170
171export CC CXX A_CC A_CXX
172
173# unconditionally prepend $(ARBHOME)/lib to LD_LIBRARY_PATH if not found
174ifeq ($(findstring $(ARBHOME)/lib,$(LD_LIBRARY_PATH)),)
175 LD_LIBRARY_PATH:=${ARBHOME}/lib:$(LD_LIBRARY_PATH)
176endif
177
178# store LD_LIBRARY_PATH to circumvent SIP restrictions:
179ARBBUILD_LIBRARY_PATH:=$(LD_LIBRARY_PATH)
180
181FORCEMASK = umask 002
182NODIR=--no-print-directory
183
184SED:=$(ARBHOME)/SH/arb_sed
185READLINK:=$(ARBHOME)/SH/arb_readlink
186
187# ---------------------- compiler version detection
188
189# supported gcc versions:
190ALLOWED_gcc_VERSIONS=\
191                        4.4.3         4.4.5  4.4.6  4.4.7 \
192                 4.5.2  \
193          4.6.1  4.6.2  4.6.3  4.6.4 \
194          4.7.1  4.7.2  4.7.3  4.7.4 \
195   4.8.0  4.8.1  4.8.2  4.8.3  4.8.4  4.8.5 \
196   4.9.0  4.9.1  4.9.2  4.9.3  4.9.4 \
197   5.1.0  5.2.0  5.3.0  5.4.0  5.5.0 \
198   6.1.0  6.2.0  6.3.0  6.4.0  6.5.0 \
199   7.1.0  7.2.0  7.3.0  7.4.0  7.5.0 \
200   8.1.0  8.2.0  8.3.0  8.4.0  8.5.0 \
201   9.1.0  9.2.0  9.3.0  9.4.0  9.5.0 \
202  10.1.0 10.2.0 10.3.0 10.4.0 10.5.0 \
203
204# Note: starting with version 5, arb silently accepts any subversion number
205# above zero. See SOURCE_TOOLS/arb_compiler_version.pl@acceptSubVersions
206#
207# This may cause problems when manually checking for compiler versions in code
208# (GCC_VERSION_CODE is not affected, GCC_PATCHLEVEL_CODE may cause problems!)
209# ----------------------
210
211COMPILER_INFO:=$(shell SOURCE_TOOLS/arb_compiler_version.pl $(A_CXX))
212COMPILER_NAME:=$(word 1,$(COMPILER_INFO))
213COMPILER_VERSION:=$(word 2,$(COMPILER_INFO))
214
215USE_CLANG:=0
216ifneq ($(COMPILER_NAME),gcc)
217 ifeq ($(COMPILER_NAME),clang)
218  USE_CLANG:=1
219 else
220  ifeq ($(COMPILER_VERSION),4.6.4)
221#  gcc version 4.6.4 segfaults when dumping symbols for detection (silently accept as gcc)
222   COMPILER_NAME:=gcc
223  else
224   $(error failed to detect COMPILER_NAME (got '$(COMPILER_NAME)', expected 'clang' or 'gcc'))
225  endif
226 endif
227endif
228
229ifeq ($(USE_CLANG),1)
230# accept all clang versions:
231 ALLOWED_COMPILER_VERSIONS=$(COMPILER_VERSION)
232else
233 ALLOWED_COMPILER_VERSIONS=$(ALLOWED_gcc_VERSIONS)
234endif
235
236COMPILER_VERSION_ALLOWED=$(strip $(subst ___,,$(foreach version,$(ALLOWED_COMPILER_VERSIONS),$(findstring ___$(version)___,___$(COMPILER_VERSION)___))))
237
238#---------------------- split gcc version
239
240SPLITTED_VERSION:=$(subst ., ,$(COMPILER_VERSION))
241
242USE_GCC_MAJOR:=$(word 1,$(SPLITTED_VERSION))
243USE_GCC_MINOR:=$(word 2,$(SPLITTED_VERSION))
244USE_GCC_PATCHLEVEL:=$(word 3,$(SPLITTED_VERSION))
245
246USE_GCC_452_OR_HIGHER:=
247USE_GCC_46_OR_HIGHER:=
248USE_GCC_47_OR_HIGHER:=
249USE_GCC_48_OR_HIGHER:=
250USE_GCC_49_OR_HIGHER:=
251USE_GCC_50_OR_HIGHER:=
252USE_GCC_60_OR_HIGHER:=
253USE_GCC_70_OR_HIGHER:=
254USE_GCC_80_OR_HIGHER:=
255USE_GCC_90_OR_HIGHER:=
256
257ifeq ($(USE_CLANG),0)
258 ifeq ($(USE_GCC_MAJOR),4)
259  ifeq ($(USE_GCC_MINOR),5)
260   ifneq ('$(findstring $(USE_GCC_PATCHLEVEL),23456789)','')
261    USE_GCC_452_OR_HIGHER:=yes
262   endif
263  else
264   ifneq ('$(findstring $(USE_GCC_MINOR),6789)','')
265    USE_GCC_452_OR_HIGHER:=yes
266    USE_GCC_46_OR_HIGHER:=yes
267    ifneq ($(USE_GCC_MINOR),6)
268     USE_GCC_47_OR_HIGHER:=yes
269     ifneq ($(USE_GCC_MINOR),7)
270      USE_GCC_48_OR_HIGHER:=yes
271       ifneq ($(USE_GCC_MINOR),8)
272        USE_GCC_49_OR_HIGHER:=yes
273       endif
274     endif
275    endif
276   endif
277  endif
278 else
279  # gcc 5.x or higher
280  USE_GCC_452_OR_HIGHER:=yes
281  USE_GCC_46_OR_HIGHER:=yes
282  USE_GCC_47_OR_HIGHER:=yes
283  USE_GCC_48_OR_HIGHER:=yes
284  USE_GCC_49_OR_HIGHER:=yes
285  USE_GCC_50_OR_HIGHER:=yes
286  ifneq ($(USE_GCC_MAJOR),5)
287   # gcc 6.x or higher
288   USE_GCC_60_OR_HIGHER:=yes
289   ifneq ($(USE_GCC_MAJOR),6)
290    # gcc 7.x or higher
291    USE_GCC_70_OR_HIGHER:=yes
292    ifneq ($(USE_GCC_MAJOR),7)
293     # gcc 8.x or higher
294     USE_GCC_80_OR_HIGHER:=yes
295     ifneq ($(USE_GCC_MAJOR),8)
296      # gcc 9.x or higher
297      USE_GCC_90_OR_HIGHER:=yes
298     endif
299    endif
300   endif
301  endif
302 endif
303endif
304
305#---------------------- define special directories for non standard builds
306
307ifeq ($(DARWIN),1)
308 OSX_FW:=/System/Library/Frameworks
309 OSX_FW_OPENGL:=$(OSX_FW)/OpenGL.framework/Versions/A/Libraries
310 OSX_FW_GLUT:=$(OSX_FW)/GLUT.framework/Versions/A/Libraries
311 OSX_FW_IMAGEIO:=$(OSX_FW)/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources
312endif
313
314#---------------------- SSE vectorization
315# for details about vectorization checks see SOURCE_TOOLS/vectorize.README
316
317DISABLE_VECTORIZE_CHECK:=0#         set to 1 to completely disable vectorization checks
318TRACE_MISSED_VECTORIZATIONS:=0#     set to 1 to activate detailed output about failed vectorizations
319#                                   (does also show details about successful vectorized loops, which are not optimal)
320VECTORIZATION_CHECK_CANDIDATES:=0#  set to 1 to show vectorizations that may be checked
321#                                   (for yet unchecked files)
322# Note: TRACE_MISSED_VECTORIZATIONS and VECTORIZATION_CHECK_CANDIDATES cannot be used together!
323
324#---------------------- Support for OPENMP
325
326USE_OPENMP:=1
327ifeq ($(DARWIN),1)
328        USE_OPENMP:=0
329endif
330
331#----------------------
332
333ifeq ($(DARWIN),1)
334 LINK_STATIC=1# link static
335else
336 LINK_STATIC=0# link dynamically
337#  LINK_STATIC=1# link static (testing only)
338endif
339
340shared_cflags :=# flags for shared lib compilation
341clflags :=# linker flags (when passed through gcc)
342extended_warnings :=# warning flags for C and C++-compiler
343extended_cpp_warnings :=# warning flags for C++-compiler only
344
345ifeq ($(DEBUG),0)
346 dflags := -DNDEBUG# defines
347 ifeq ($(USE_CLANG),1)
348  cflags := -O3# compiler flags (C and C++)
349 else
350  clflags += -Wl,-O2# passthrough linker flags
351# ------- standard optimization:
352  cflags := -O3# compiler flags (C and C++)
353# ------- test changed optimization (DISABLE_VECTORIZE_CHECK for -O2 or lower):
354#  cflags := -O2# do not commit uncommented!
355#  DISABLE_VECTORIZE_CHECK:=1
356 endif
357endif
358
359ifeq ($(DEBIAN),1)
360 clflags += -Wl,-rpath=/usr/lib/arb/lib -Wl,-z,relro
361endif
362
363ifeq ($(DEBUG),1)
364 dflags := -DDEBUG
365
366 gdb_common := -g -g3 -ggdb -ggdb3
367
368 DBGOPTI:=-O0
369 ifneq ('$(SANITIZE)','0')
370  # sanitizer report several bogus buffer-overflows when arb is build with -O0 (e.g. with gcc 7.5.0)
371  DBGOPTI:=-O1
372 endif
373
374 ifeq ($(STABS),1)
375  $(error STABS no longer supported)
376 endif
377
378 cflags := $(DBGOPTI) $(gdb_common)
379 # cflags := -O2 $(gdb_common) # use this for callgrind (force inlining)
380
381 ifeq ($(DARWIN),0)
382  clflags += -Wl,-g
383# Note:
384# Previously '-Wl,-noinhibit-exec' was added to 'clflags' here,
385# to fix some issues with launchpad binutils (see [12972]).
386# But that change also caused 'undefined symbols' NOT to be reported as errors
387# at link time, producing executables that fail at runtime :/
388 endif
389
390 ifeq ($(DEBUG_GRAPHICS),1)
391  dflags += -DDEBUG_GRAPHICS
392 endif
393
394endif # DEBUG only
395
396# ------------------------------ POST_COMPILE - control how much you get spammed
397# (please do not change default in SVN)
398POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl
399
400# POST_COMPILE += --original                                  # dont modify compiler output
401# POST_COMPILE += --hide-Noncopyable-advices
402# POST_COMPILE += --show-useless-Weff++
403# POST_COMPILE += --no-warnings
404# POST_COMPILE += --only-first-error
405# POST_COMPILE += --no-warnings --only-first-error
406
407# always pass used compiler version to postcompile:
408POST_COMPILE += --compiler=$(COMPILER_VERSION)
409
410# ------------------------------
411
412# Enable extra warnings
413extended_warnings :=
414extended_cpp_warnings :=
415
416# C and C++
417extended_warnings     += -Wwrite-strings -Wunused -Wno-aggregate-return
418
419ifeq ('$(USE_GCC_50_OR_HIGHER)','yes')
420# disable shadow warnings for gcc 4.8 (and lower)
421# (does e.g. warn if a method-name is used as parameter in another method - even for derived classes. unusable!)
422extended_warnings     += -Wshadow
423endif
424
425# C++ only
426extended_cpp_warnings += -Wnon-virtual-dtor -Wreorder -Wpointer-arith -Wdisabled-optimization -Wmissing-format-attribute
427extended_cpp_warnings += -Wctor-dtor-privacy
428# extended_cpp_warnings += -Wfloat-equal
429
430extended_cpp_warnings += -Wmissing-noreturn
431# extended_cpp_warnings += -Wold-style-cast# (warns about 28405 old-style casts)
432extended_cpp_warnings += -Winit-self
433extended_cpp_warnings += -Wstrict-aliasing
434extended_cpp_warnings += -Wextra
435
436# ------- above only warning-options already available in gcc 4.4.3
437
438#  -Weffc++ broken in 4.7.x series
439# gcc 4.7.3 crashes on GenomeImport.cxx when -Weffc++ is active
440# (bug reported https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56923; apparently wont be fixed for 4.7-series)
441# gcc 4.7.4 crashes on DBwriter.cxx when -Weffc++ is active
442WEFFC_BROKEN:=0
443ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
444 ifneq ('$(USE_GCC_48_OR_HIGHER)','yes')
445  WEFFC_BROKEN:=1
446 endif
447endif
448ifeq ('$(WEFFC_BROKEN)','0')
449 extended_cpp_warnings += -Weffc++
450endif
451
452# turn off -Wmaybe-uninitialized in debug mode (gets activated with -Wextra). too many bogus warnings
453ifeq ($(DEBUG),1)
454 ifeq ($(USE_CLANG),0)
455  extended_cpp_warnings += -Wno-maybe-uninitialized
456 endif
457endif
458
459SUGGEST_FINAL:=
460
461ifeq ('$(USE_GCC_452_OR_HIGHER)','yes')
462 extended_cpp_warnings += -Wlogical-op# gcc 4.5.2
463endif
464ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
465 extended_cpp_warnings += -Wzero-as-null-pointer-constant# gcc 4.7
466endif
467ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
468 extended_cpp_warnings += -Wunused-local-typedefs# available since gcc 4.7 (but fails for each STATIC_ASSERT, so enable only for Cxx11)
469endif
470ifeq ('$(USE_GCC_50_OR_HIGHER)','yes')
471 extended_cpp_warnings += -Wswitch-bool
472 extended_cpp_warnings += -Wlogical-not-parentheses
473 extended_cpp_warnings += -Wsizeof-array-argument
474 extended_cpp_warnings += -Wbool-compare
475
476 SUGGEST_FINAL:=yes
477endif
478ifeq ('$(USE_GCC_60_OR_HIGHER)','yes')
479 extended_cpp_warnings += -Wduplicated-cond
480endif
481ifeq ('$(USE_GCC_80_OR_HIGHER)','yes')
482 extended_cpp_warnings += -Wmultistatement-macros
483endif
484
485# switch off final suggestions for 8.3.0 and 8.4.0:
486ifeq ('$(COMPILER_VERSION)','8.3.0')
487 SUGGEST_FINAL:=no
488endif
489ifeq ('$(COMPILER_VERSION)','8.4.0')
490 SUGGEST_FINAL:=no
491endif
492
493ifeq ($(DEVELOPER),RELEASE)
494# switch off final suggestions in RELEASE:
495 SUGGEST_FINAL:=no
496endif
497# suggest final:
498ifeq ('$(SUGGEST_FINAL)','yes')
499  extended_cpp_warnings += -Wsuggest-final-types
500  extended_cpp_warnings += -Wsuggest-final-methods
501  dflags += -DSUGGESTS_FINAL
502endif
503
504#---------------------- turn off clang bogus warnings
505
506ifeq ($(USE_CLANG),1)
507# -Wmismatched-tags warns about struct/class mismatch in forward declarations (which is explicitely allowed)
508# -Wchar-subscripts reports too many bogus warnings for "array['x']" (when 'x' is known to be in range [0..128])
509# -Wunused-private-field report too many false positives (currently ~ 2 of 3)
510# -Wstring-plus-int warns about common ARB coding practice
511# -Wgnu-static-float-init warns about accepted GNU extension
512 extended_cpp_warnings += -Wno-mismatched-tags -Wno-char-subscripts -Wno-unused-private-field -Wno-string-plus-int
513 ifeq ('$(COMPILER_VERSION)','4.2.1')
514# jenkins build (doesn't know switch -Wno-gnu-static-float-init)
515  extended_cpp_warnings += -Wno-gnu
516 else
517  extended_cpp_warnings += -Wno-gnu-static-float-init
518 endif
519endif
520
521#---------------------- developer
522
523ifneq ($(DEVELOPER),ANY) # ANY=default setting (skip all developer specific code)
524 dflags += -DDEVEL_$(DEVELOPER)# activate developer/release specific code
525endif
526
527#---------------------- activate TODO warnings?
528
529ifndef SHOWTODO
530 ifeq ($(DEVELOPER),RALF)
531  SHOWTODO:=1
532 else
533  SHOWTODO:=0
534 endif
535endif
536ifeq ($(SHOWTODO),1)
537 dflags += -DWARN_TODO# activate "TODO" warnings
538endif
539
540#---------------------- activate threads?
541# only useful if compiler is able to compile Cxx11 or better
542
543ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
544# see also ./TEMPLATES/cxxforward.h@USE_Cxx11
545cflags += -pthread
546clflags += -pthread
547endif
548
549#---------------------- activate Sanitizers?
550
551ASAN_OPTIONS:=handle_segv=0:color=0
552ifeq ($(IGNORE_LEAKS),1)
553 ASAN_OPTIONS+=:detect_leaks=0 # disable leak-detection
554else
555 ASAN_OPTIONS+=:detect_leaks=1 # detect leaks (normal setting)
556endif
557ASAN_OPTIONS+=:check_initialization_order=1
558# ASAN_OPTIONS+=:abort_on_error=1
559
560# suppressions: SOURCE_TOOLS/arb.leaksan.supp
561LSAN_OPTIONS:=max_leaks=3:suppressions=$(ARBHOME)/SOURCE_TOOLS/arb.leaksan.supp
562
563UBSAN_OPTIONS:=print_stacktrace=1
564
565SANITIZE_ADDRESS:=0
566SANITIZE_UNDEFINED:=0
567
568ifneq ($(SANITIZE),0)
569 ifeq ($(SANITIZE),all)
570  SANITIZE:=3
571 endif
572
573 ifeq ($(SANITIZE),1)
574  SANITIZE_ADDRESS:=1
575 else
576  ifeq ($(SANITIZE),2)
577   SANITIZE_UNDEFINED:=1
578  else
579   ifeq ($(SANITIZE),3)
580    SANITIZE_ADDRESS:=1
581    SANITIZE_UNDEFINED:=1
582   else
583    $(error Unknown value '$(SANITIZE)' specified for SANITIZE in config.makefile)
584   endif
585  endif
586 endif
587endif
588
589ifeq ($(SANITIZE_ADDRESS),1)
590 ifneq ('$(USE_GCC_48_OR_HIGHER)','yes')
591  $(info AddressSanitizer not usable with gcc $(COMPILER_VERSION) - disabled)
592  SANITIZE_ADDRESS:=0
593 else
594  ifneq ('$(USE_GCC_49_OR_HIGHER)','yes')
595   $(info LeakSanitizer does not work with gcc $(COMPILER_VERSION) - disabled)
596   # need to disable AddressSanitizer (otherwise build fails; only affects gcc 4.8.x series)
597   SANITIZE_ADDRESS:=0
598  endif
599 endif
600endif
601
602ifeq ($(SANITIZE_UNDEFINED),1)
603 ifneq ('$(USE_GCC_49_OR_HIGHER)','yes')
604  $(info UndefinedBehaviorSanitizer not usable with gcc $(COMPILER_VERSION) - disabled)
605  SANITIZE_UNDEFINED:=0
606 endif
607endif
608
609SANITIZE_ANY:=0
610ifeq ($(SANITIZE_ADDRESS),1)
611 SANITIZE_ANY:=1
612endif
613ifeq ($(SANITIZE_UNDEFINED),1)
614 SANITIZE_ANY:=1
615endif
616
617# vectorization fails if sanitizer active where it normally succeeds -> disable check
618ifeq ($(SANITIZE_ANY),1)
619 $(info disabling vectorize checks. would fail with sanitized code)
620 DISABLE_VECTORIZE_CHECK:=1
621else
622 $(info no sanitizer enabled. reset: SANITIZE=0)
623 SANITIZE:=0
624endif
625
626# deactivate some bogus warnings occurring when sanitizing NDEBUG version
627# (do not disable for future gcc-version >= 8.x -> test again when available)
628ifeq ($(SANITIZE_ANY),1)
629 ifeq ($(DEBUG),0)
630  ifneq ('$(USE_GCC_80_OR_HIGHER)','yes')
631   extended_cpp_warnings += -Wno-format-overflow
632   extended_cpp_warnings += -Wno-maybe-uninitialized
633  endif
634 endif
635endif
636
637#---------------------- 32 or 64 bit
638
639cross_cflags:=
640cross_lflags:=
641cross_clflags:=
642
643ifeq ($(ARB_64),1)
644 dflags += -DARB_64
645 shared_cflags += -fPIC
646 CROSS_LIB:=# empty => autodetect below
647 ifeq ($(DARWIN),1)
648  cross_cflags  += -arch x86_64
649  cross_lflags  += -arch x86_64
650  cross_clflags += -arch x86_64
651 endif
652else
653 CROSS_LIB:=/lib
654endif
655
656cflags  += $(cross_cflags)
657clflags += $(cross_clflags)
658
659ifeq ('$(CROSS_LIB)','')
660# autodetect libdir
661 ifeq ($(ARB_64),1)
662  CROSS_LIB:=$(shell (test -d /lib64 && echo lib64) || echo lib)
663 else
664  CROSS_LIB:=$(shell (test -d /lib32 && echo lib32) || echo lib)
665 endif
666endif
667
668#---------------------- unit tests
669
670ifndef UNIT_TESTS
671 UNIT_TESTS=0#default is "no tests"
672endif
673ifeq ($(UNIT_TESTS),1)
674 dflags += -DUNIT_TESTS
675 UNIT_TESTER_LIB=UNIT_TESTER/UNIT_TESTER.a
676else
677 UNIT_TESTER_LIB=
678endif
679
680#---------------------- use gcov
681
682ifndef COVERAGE
683 COVERAGE=0#default is "no"
684endif
685ifneq ($(COVERAGE),0)
686 GCOV_FLAGS=--coverage
687 $(info disabling vectorize checks. would fail with COVERAGE on)
688 DISABLE_VECTORIZE_CHECK:=1
689else
690 GCOV_FLAGS=
691endif
692
693cflags       += $(GCOV_FLAGS)
694clflags      += $(GCOV_FLAGS)
695cross_lflags += $(GCOV_FLAGS)
696
697#---------------------- other flags
698
699dflags += -D$(MACH) # define machine
700
701ifeq ($(DARWIN),1)
702 shared_cflags += -fno-common
703else
704 dflags +=  $(shell getconf LFS_CFLAGS)
705endif
706
707cflags += -pipe
708cflags += -fmessage-length=0# dont wrap compiler output
709cflags += -fshow-column# show columns
710cflags += -funit-at-a-time
711cflags += -fPIC
712cflags += -fno-common# link all global data into one namespace
713cflags += -fstrict-aliasing# gcc 3.4
714
715
716ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
717 cflags += -fno-diagnostics-show-caret#gcc 4.8 (4.7.?)
718endif
719#cflags += -save-temps# uncomment to see preprocessor output
720
721#---------------------- various sanitizers
722# There are some disabled tests in CORE/arb_misc.cxx@sanitizers
723# which trigger sanitizer reports.
724
725ifeq ($(SANITIZE_ANY),1)
726 cflags  += -ggdb3 -fno-omit-frame-pointer
727endif
728
729SANI_CFLAGS:=
730SANI_CLFLAGS:=
731
732# activate AddressSanitizer+LeakSanitizer?
733ifeq ($(SANITIZE_ADDRESS),1)
734 SANI_CFLAGS += -fsanitize=address
735 SANI_CLFLAGS += -fsanitize=address
736 dflags  += -DLEAKS_SANITIZED
737endif
738
739# activate UndefinedBehaviorSanitizer?
740ifeq ($(SANITIZE_UNDEFINED),1)
741 SANI_CFLAGS += -fsanitize=undefined
742 SANI_CLFLAGS += -fsanitize=undefined
743 dflags  += -DUNDEF_SANITIZED
744 ifeq ('$(USE_GCC_50_OR_HIGHER)','yes')
745   # abort on runtime errors
746   SANI_CFLAGS += -fno-sanitize-recover=all
747 endif
748
749cflags += $(SANI_CFLAGS)
750clflags += $(SANI_CLFLAGS)
751
752#
753# Note: alignment-sanitizer is deactivated for ARBDB and PROBE!
754 ifeq ('$(DEBUG)','1')
755  ifeq ($(USE_GCC_MAJOR),4)
756   ifeq ($(USE_GCC_MINOR),9)
757    ifneq ('$(findstring $(USE_GCC_PATCHLEVEL),01)','')
758# workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63531 for 4.9.0 + 4.9.1
759# (problem is fixed in 4.9.2 release)
760     extended_cpp_warnings:=$(subst -Weffc++,,$(extended_cpp_warnings))
761    endif
762   endif
763  endif
764 endif
765endif
766
767#---------------------- X11 location
768
769ifeq ($(DARWIN),1)
770 XHOME:=$(PREFIX)
771else
772 ifeq ($(DEBIAN),1)
773  XHOME:=$(PREFIX)
774 else
775  XHOME:=/usr/X11R6
776 endif
777endif
778
779XINCLUDES ?= -I$(XHOME)/include
780XLIBS     ?= -L$(XHOME)/$(CROSS_LIB)
781ifeq ($(DARWIN),1)
782 XINCLUDES += -I$(OSX_FW)/GLUT.framework/Headers -I$(OSX_FW)/OpenGL.framework/Headers -I$(OSX_SDK)/usr/include/krb5
783
784 XLIBS += -lXm -lpng -lz -lXt -lX11 -lXext -lXp -lXmu -lXi
785 XLIBS += -Wl,-dylib_file,$(OSX_FW_OPENGL)/libGL.dylib:$(OSX_FW_OPENGL)/libGL.dylib
786 XLIBS += -Wl,-dylib_file,$(OSX_FW_OPENGL)/libGLU.dylib:$(OSX_FW_OPENGL)/libGLU.dylib
787else
788 XLIBS += -lXm -lXpm -lXt -lXext -lX11
789endif
790
791#---------------------- open GL
792
793ifeq ($(OPENGL),1)
794 cflags += -DARB_OPENGL # activate OPENGL code
795 GL     := gl # this is the name of the OPENGL base target
796 GL_LIB_SYS := -lGL -lGLU
797 GL_LIB_ARB := -L$(ARBHOME)/GL/glAW -lglAW
798
799 ifeq ($(DARWIN),1)
800  GL_LIB_SYS += -lpthread
801 endif
802
803 GL_PNGLIBS_ARB := -L$(ARBHOME)/GL/glpng -lglpng_arb
804 GL_PNGLIBS_SYS := -lpng
805
806 GLEWLIB := -lGLEW -lGLw
807 GLUTLIB := -lglut
808
809 GL_LIBS_SYS := $(GL_LIB_SYS) $(GL_PNGLIBS_SYS) $(GLEWLIB) $(GLUTLIB)
810 GL_LIBS_ARB := $(GL_LIB_ARB) $(GL_PNGLIBS_ARB)
811
812 RNA3D_LIB := RNA3D/RNA3D.a
813else
814 GL_LIBS_SYS:=# no opengl -> no libs
815 GL_LIBS_ARB:=# no opengl -> no libs
816 GL:=# dont build ARB openGL libs
817
818 RNA3D_LIB :=
819endif
820
821RNA3D_LIB_4_DEPENDS := RNA3D/RNA3D.a
822
823GL_LIBS:=$(GL_LIBS_ARB) $(GL_LIBS_SYS)
824
825#---------------------- sina:
826
827ifndef ISINA
828 # build sina delivered with arb?
829 ifeq ($(LINUX),1)
830  ifeq ('$(USE_GCC_70_OR_HIGHER)','yes')
831   ISINA := 1# default to 'yes' for linux with gcc>=7
832  endif
833 endif
834 ifndef ISINA
835  ISINA := 0# 'no' otherwise
836 endif
837endif
838
839#---------------------- tiff lib:
840
841TIFFLIBS := -ltiff
842
843#---------------------- XML lib:
844
845XMLLIBS := -lxerces-c
846
847#---------------------- glib:
848
849ARB_NEEDED_GLIB=glib-2.0
850
851ARB_GLIB_INCLUDE:=$(strip $(shell pkg-config --cflags $(ARB_NEEDED_GLIB)))
852ARB_GLIB_LIBS:=$(strip    $(shell pkg-config --libs   $(ARB_NEEDED_GLIB)))
853
854#---------------------- sunrpc lib:
855# Note: sunrpc has been removed from glibc
856# (e.g. in SuSE Leap 15.3 and Fedora 28)
857# see https://fedoraproject.org/wiki/Changes/SunRPCRemoval
858#
859HAVE_LIBTIRPC=$(strip $(shell pkg-config --exists libtirpc && echo libtirpc))
860ifeq ($(HAVE_LIBTIRPC),)
861 ARB_RPC_INCLUDE:=
862 ARB_RPC_LIBS:=
863else
864 ARB_RPC_INCLUDE:=$(strip $(shell pkg-config --cflags $(HAVE_LIBTIRPC)))
865 ARB_RPC_LIBS:=$(strip    $(shell pkg-config --libs   $(HAVE_LIBTIRPC)))
866endif
867
868#---------------------- basic libs:
869
870ARB_CORE_LIBS:=$(ARB_GLIB_LIBS) $(ARB_RPC_LIBS)
871
872SYSLIBS:=
873ifeq ($(DARWIN),1)
874 SYSLIBS += -lstdc++
875else
876 SYSLIBS += -lm $(ARB_CORE_LIBS)
877endif
878
879#---------------------- system dependent commands
880
881ifeq ($(DARWIN),1)
882 TIME:=gtime
883else
884 TIME:=/usr/bin/time
885endif
886
887#---------------------- SSE vectorizer
888# for details see SOURCE_TOOLS/vectorize.README
889
890ifeq ($(DEBUG),0)
891 ifeq ($(USE_GCC_49_OR_HIGHER),yes)
892  ifeq ($(DISABLE_VECTORIZE_CHECK),0)
893   cflags += -fopt-info-vec
894   cflags += -fopt-info-vec-missed
895   ifeq ($(TRACE_MISSED_VECTORIZATIONS),1)
896#   Shows reasons for unsuccessful vectorization:
897    cflags += -ftree-vectorizer-verbose=10
898    POST_COMPILE += --dump-loop-optimization
899    ifeq ($(VECTORIZATION_CHECK_CANDIDATES),1)
900     $(error TRACE_MISSED_VECTORIZATIONS and VECTORIZATION_CHECK_CANDIDATES may not be used together!)
901    endif
902   endif
903   ifeq ($(VECTORIZATION_CHECK_CANDIDATES),1)
904    POST_COMPILE += --loop-optimization-candi
905   endif
906   POST_COMPILE += --check-loop-optimization
907  endif
908 else
909  ifeq ($(USE_GCC_48_OR_HIGHER),yes)
910# no automatic vectorization-check for gcc<4.9.0
911# -> uncomment the next 2 lines and grep the spam it will produce for 'vectorized.*loops'
912#  cflags += -fopt-info -fopt-info-vec-missed
913#  POST_COMPILE += --original
914  endif
915 endif
916endif
917
918#---------------------- stop early on broken flags/compiler combination
919
920ifeq ($(DEBUG),0)
921 ifeq ($(SANITIZE_ANY),1)
922  ifeq ('$(COMPILER_VERSION)','4.9.1')
923   $(error compiling DEBUG=0 + SANITIZE!=0 crashes with gcc $(COMPILER_VERSION) (gcc 4.9.2 works))
924  endif
925 endif
926endif
927
928#---------------------- include symbols?
929
930ifeq ($(TRACESYM),1)
931 ifeq ($(USE_CLANG),0)
932  cflags  += -rdynamic
933  clflags += -rdynamic -Wl,--export-dynamic
934 endif
935endif
936
937#---------------------- warn about duplicate variable definitions
938
939ifeq ($(DARWIN),1)
940clflags += -Wl,-warn_commons
941else
942clflags += -Wl,--warn-common
943endif
944
945#---------------------- differences between linking executables and shared libs:
946
947# executables:
948ifeq ($(DARWIN),1)
949 blflags:=$(clflags)
950else
951 blflags:=$(clflags) -Wl,--no-undefined
952endif
953
954# shared libraries
955llflags:=$(clflags)
956
957# dont use clflags below
958clflags:=
959
960# -------------------------------------------------------------------------
961#       Don't put any machine/version/etc conditionals below!
962#       (instead define variables above)
963# -------------------------------------------------------------------------
964
965cflags += -W -Wall $(dflags) $(extended_warnings)
966cxxflags := $(extended_cpp_warnings)
967
968# add CFLAGS + CPPFLAGS from environment for DEBIAN build
969ifeq ($(DEBIAN),1)
970 cflags := $(CFLAGS) $(cflags)
971 cxxflags += $(CPPFLAGS)
972endif
973
974ifeq ('$(USE_CLANG)','1')
975# none of the following standards works with clang3.3 (under linux) => dont use standard (as done before r15516)
976#  cxxflags += -std=gnu++11
977#  cxxflags += -std=gnu++0x
978else
979 ifeq ('$(USE_GCC_60_OR_HIGHER)','yes')
980  cxxflags += -std=gnu++14# see also TEMPLATES/cxxforward.h@USE_Cxx14
981 else
982  ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
983   cxxflags += -std=gnu++11# see also TEMPLATES/cxxforward.h@USE_Cxx11
984  else
985#  gcc versions between 4.3 (lowest supported) and <4.7
986   cxxflags += -std=gnu++0x
987  endif
988 endif
989endif
990
991LINK_STATIC_LIB := $(AR) -csq# link static lib
992LINK_EXECUTABLE := $(A_CXX) $(blflags) -o# link executable (c++)
993
994ifeq ($(LINK_STATIC),1)
995 SHARED_LIB_SUFFIX = a# static lib suffix
996 LINK_SHARED_LIB := $(LINK_STATIC_LIB)
997else
998 SHARED_LIB_SUFFIX = so# shared lib suffix
999 LINK_SHARED_LIB := $(A_CXX) $(llflags) -shared -o# link shared lib
1000endif
1001
1002ifeq ($(DARWIN),1)
1003 lflags4perl:=
1004else
1005 lflags4perl:=$(cross_lflags) -shared
1006endif
1007
1008# delete variables unused below
1009blflags:=
1010llflags:=
1011
1012# other used tools
1013MAKEDEPEND_PLAIN = makedepend
1014MAKEDEPEND = $(FORCEMASK);$(MAKEDEPEND_PLAIN)
1015
1016SEPNODATE:=--------------------------------------------------------------------------------
1017SEP=[`date +%M:%S.%N`] ------------------------------------------------
1018# to analyse timings run
1019# make -j9 clean; make -j9 all  | grep '^\[' | sort
1020# make -j9 "TIMED_TARGET=perl" clean_timed_target | grep '^\[' | sort
1021
1022# ------------------------------------------------------------ DYNLIBDEFS
1023# various dynamic library definitions for linking executables:
1024#
1025# SYSLIBS:    system libraries needed by database lib
1026# ARBDB_LIB:  database lib
1027# DBSYS_LIBS: executable using database (but no GUI)
1028# GUI_LIBS:   executable using database and GUI (arb gui uses database)
1029#
1030# Note: definitions exported to sub-makefiles are described in SOURCE_TOOLS/parent_make.txt
1031
1032CORE_LIB=-lCORE
1033ARBDB_LIB=-lARBDB $(CORE_LIB)
1034DBSYS_LIBS = $(ARBDB_LIB) $(SYSLIBS)
1035
1036GUI_LIBS_PREFIX:=
1037ifeq ($(DARWIN),1)
1038# this seem to be added at wrong place, since opengl is only needed to link EDIT4
1039 GUI_LIBS_PREFIX:=-framework GLUT -framework OpenGL
1040endif
1041
1042GUI_LIBS=$(GUI_LIBS_PREFIX) $(DBSYS_LIBS) -lAWT -lWINDOW $(XLIBS)
1043
1044LIBPATH = -L$(ARBHOME)/lib
1045
1046DEST_LIB = lib
1047DEST_BIN = bin
1048
1049CC_INCLUDES  := -I. -I$(ARBHOME)/INCLUDE $(XINCLUDES) $(ARB_GLIB_INCLUDE) $(ARB_RPC_INCLUDE)
1050CXX_INCLUDES := $(CC_INCLUDES)
1051MAKEDEPENDFLAGS := -- -DARB_OPENGL -DUNIT_TESTS -D__cplusplus -I. -Y$(ARBHOME)/INCLUDE
1052
1053# ---------------------------------------
1054# wrap main()
1055
1056use_ARB_main=$(ARBHOME)/SOURCE_TOOLS/arb_main_cpp.o
1057use_ARB_main_C=$(ARBHOME)/SOURCE_TOOLS/arb_main_c.o
1058
1059# -----------------------------------------
1060# unique build-id
1061# - different for different calls of make
1062# - constant in recursive calls
1063
1064ifndef ARBBID
1065 ARBBID:=$(shell SOURCE_TOOLS/uniqueID.sh)
1066endif
1067
1068# -----------------------------------------
1069#     export variables to submakefiles
1070
1071include SOURCE_TOOLS/export2sub
1072
1073# do not define (exported) variables below this point
1074
1075# -------------------------
1076#     Main arb targets:
1077# -------------------------
1078
1079first_target:
1080                $(MAKE) checks
1081                @echo $(SEPNODATE)
1082                @echo 'Main targets:'
1083                @echo ''
1084                @echo ' all         - Compile ARB + TOOLs + and copy shared libs + link foreign software'
1085                @echo '               (That is most likely the target you want)'
1086                @echo ''
1087                @echo ' clean       - remove generated files ("SUBDIR/SUBDIR.clean" to clean only SUBDIR)'
1088                @echo ' rebuild     - clean + all'
1089                @echo ' cleanlinked - remove all binaries'
1090                @echo ' relink      - cleanlinked + all (=relink all from objects)'
1091                @echo ''
1092                @echo 'Targets for automated builds:'
1093                @echo ''
1094                @echo ' ALL, REBUILD, TARFILE + TARFILE_QUICK '
1095                @echo '             - same as all, rebuild, tarfile + tarfile_quick'
1096                @echo '             - if errors occur, they are extracted and listed at tail of output'
1097                @echo ''
1098                @echo $(SEPNODATE)
1099                @echo ''
1100                @echo 'Development targets:'
1101                @echo ''
1102                @echo ' depends               - create or update dependencies ("SUBDIR/SUBDIR.depends" to update only SUBDIR)'
1103                @echo ' proto                 - create or update prototypes ("SUBDIR/SUBDIR.proto" to update only SUBDIR)'
1104                @echo ' tags                  - create tags for xemacs'
1105                @echo ' show                  - show available shortcuts (AKA subtargets)'
1106                @echo ' up                    - shortcut for depends+proto+tags'
1107ifeq ($(UNIT_TESTS),1)
1108                @echo ' ut                    - only run tests'
1109                @echo ' "UNIT=..." oneunit    - build one unit and run tests (see also UNIT_TESTER/Makefile.setup.local)'
1110endif
1111ifneq ($(SANITIZE),0)
1112                @echo ' sanitize              - all + run arb_ntree with sanitizer (test.arb + execute _logged)'
1113endif
1114                @echo ' modified              - rebuild files modified in svn checkout (does touch)'
1115                @echo ' touch                 - touch files modified in svn checkout'
1116                @echo ''
1117                @echo 'Some often used sub targets:'
1118                @echo ''
1119                @echo ' arb                   - Just compile ARB (but none of the integrated tools)'
1120                @echo ' menus                 - create lib/gde/arb.menu from GDEHELP/ARB_GDEmenus.source'
1121                @echo ' perl                  - Compile the PERL XSUBS into lib/ARB.so  and create links in lib to perl'
1122                @echo ' binlink               - Create all links in the bin directory'
1123                @echo ''
1124                @echo 'Internal maintenance:'
1125                @echo ''
1126                @echo ' relinfo               - show help on release targets'
1127                @echo ' tarfile               - make rebuild and create arb version tarfile ("tarfile_quick" to skip rebuild)'
1128                @echo ' save                  - save all basic ARB sources into arbsrc_DATE ("savetest" to check filelist)'
1129                @echo ' patch                 - save svn diff to patchfile'
1130                @echo ' source_doc            - create doxygen documentation'
1131                @echo ' relocated             - rebuild partly (use when you have relocated ARBHOME)'
1132                @echo ' check_res             - check resource usage'
1133                @echo ' dep_graph             - Build dependency graphs'
1134                @echo ' clean_cov             - Clean coverage results'
1135                @echo ''
1136                @echo ' clean_opengl_changed  - clean after changing OPENGL setting in config.Makefile'
1137                @echo ' clean_checked_vect    - clean units containing vectorization checks'
1138                @echo ' cleanRelinkable       - similar to cleanlinked (but skips raxml8 to avoid rebuild)'
1139                @echo ''
1140                @echo ' post_commit_check     - Checks whether'
1141                @echo '                         * main make targets work,'
1142                @echo '                         * dependencies and prototypes are up to date,'
1143                @echo '                         * SVN-controlled files remain unaffected by called targets and'
1144                @echo '                         * all generated files are ignored.'
1145                @echo '                       (has to be called in a clean SVN checkout)'
1146                @echo $(SEPNODATE)
1147                @echo ''
1148
1149relinfo:
1150                @echo ''
1151                @echo $(SEPNODATE)
1152                @echo 'Release targets:'
1153                @echo ''
1154                @echo ' inc_candi     - increase RC candidate-number  (only possible in "rc" branch, not needed for RC1)'
1155                @echo ' inc_patch     - increase release patchlevel   (only possible in "stable" branch)'
1156                @echo ' inc_minor     - increase minor version number (only possible in "trunk")'
1157                @echo ' inc_major     - increase MAJOR version number (only possible in "trunk")'
1158                @echo ''
1159                @echo ' show_version  - show version tag'
1160                @echo ''
1161                @echo $(SEPNODATE)
1162                @echo ''
1163
1164# auto-generate config.makefile:
1165
1166config.makefile : config.makefile.template
1167                @echo --------------------------------------------------------------------------------
1168ifeq ($(CONFIG_MAKEFILE_FOUND),)
1169                @cp $< $@
1170                @echo '$(ARBHOME)/$@:1: has been generated.'
1171                @echo 'Please edit $@ to configure your system!'
1172                @echo --------------------------------------------------------------------------------
1173                @false
1174else
1175                @echo '$(ARBHOME)/$<:1: is more recent than'
1176                @echo '$(ARBHOME)/$@:1:'
1177                @ls -al config.makefile*
1178                @echo --------------------------------------------------------------------------------
1179                @echo "Updating $@ (if this fails, check manually)"
1180                SOURCE_TOOLS/update_config_makefile.pl
1181                @echo "Sucessfully updated $@"
1182                @echo --------------------------------------------------------------------------------
1183                @ls -al config.makefile*
1184                @echo --------------------------------------------------------------------------------
1185                @echo "Diff to your old config.makefile:"
1186                @echo --------------------------------------------------------------------------------
1187                -diff $@.bak $@
1188                @echo --------------------------------------------------------------------------------
1189endif
1190
1191# check if everything is configured correctly
1192
1193check_DEVELOPER:
1194ifndef DEVELOPER
1195                @echo 'config.makefile:1: DEVELOPER not defined'
1196                @false
1197endif
1198
1199check_DEBUG:
1200ifndef dflags
1201                @echo 'config.makefile:1: DEBUG has to be defined. Valid values are 0 and 1'
1202                @false
1203endif
1204
1205check_ARB_64:
1206ifndef ARB_64
1207                @echo 'config.makefile:1: ARB_64 has to be defined. Valid values are 0 and 1'
1208                @false
1209endif
1210
1211# ---------------------------------------- check gcc version
1212
1213COMPILER_BROKEN:=0
1214
1215ifeq ('$(COMPILER_VERSION_ALLOWED)', '4.6.4')
1216COMPILER_BROKEN:=1
1217endif
1218ifeq ('$(COMPILER_VERSION_ALLOWED)', '4.8.0')
1219COMPILER_BROKEN:=1
1220endif
1221
1222check_same_GCC_VERSION:
1223                $(ARBHOME)/SOURCE_TOOLS/check_same_compiler_version.pl $(COMPILER_NAME) $(COMPILER_VERSION_ALLOWED)
1224
1225check_GCC_VERSION:
1226                @echo 'Compiler version check:'
1227# see .@ALLOWED_gcc_VERSIONS
1228ifeq ('$(COMPILER_VERSION_ALLOWED)', '')
1229                @echo "  - Your compiler is '$(COMPILER_NAME)' version '$(COMPILER_VERSION)'"
1230                @echo '    This version is not in the list of supported $(COMPILER_NAME)-versions:'
1231                @$(foreach version,$(ALLOWED_COMPILER_VERSIONS),echo '    * $(version)';)
1232                @echo '  - You may either ..'
1233                @echo '    - add your version to ALLOWED_$(COMPILER_NAME)_VERSIONS in the Makefile and try it out or'
1234                @echo '    - switch to one of the allowed versions (see arb_README_gcc.txt for installing'
1235                @echo '      a different version of gcc)'
1236                $(error Unsupported compiler '$(COMPILER_NAME)' version '$(COMPILER_VERSION)')
1237else
1238 ifeq ($(COMPILER_BROKEN),1)
1239                $(error compilation refused for $(COMPILER_NAME) version '$(COMPILER_VERSION_ALLOWED)'. Refer to http://bugs.arb-home.de/wiki/GccVersionInfo for details.)
1240 else
1241                @echo "  - Supported $(COMPILER_NAME) version '$(COMPILER_VERSION_ALLOWED)' detected - fine!"
1242                @echo ''
1243  ifeq ($(USE_CLANG),1)
1244                @echo "Dump clang version:"
1245                $(A_CXX) -v
1246  endif
1247                $(MAKE) check_same_GCC_VERSION
1248 endif
1249endif
1250
1251#---------------------- check ARBHOME
1252
1253# use arb_INSTALL.txt to determine whether ARBHOME points to correct directory
1254ARB_INSTALL_FOUND=$(wildcard $(ARBHOME)/arb_INSTALL.txt)
1255
1256check_ARBHOME:
1257ifeq ($(strip $(ARB_INSTALL_FOUND)),)
1258                @echo ------------------------------------------------------------
1259                @echo "ARBHOME is set to '$(ARBHOME)'"
1260                @echo "The environment variable ARBHOME has to point to the top arb source directory."
1261                @echo "If you use bash enter:"
1262                @echo "          export ARBHOME='`pwd`'"
1263                @echo ------------------------------------------------------------
1264                @false
1265endif
1266
1267ARB_PATH_SET=$(findstring $(ARBHOME)/bin,$(PATH))
1268
1269check_PATH: check_ARBHOME
1270ifeq ($(strip $(ARB_PATH_SET)),)
1271                @echo ------------------------------------------------------------
1272                @echo "The environment variable PATH has to contain $(ARBHOME)/bin"
1273                @echo "If you use bash enter:"
1274                @echo '                 export PATH=$$ARBHOME/bin:$$PATH'
1275                @echo ------------------------------------------------------------
1276                @false
1277endif
1278
1279check_TOOLS:
1280        @util/arb_check_build_env.pl \
1281                "$(A_CC)" \
1282                "$(A_CXX)" \
1283                "$(LINK_SHARED_LIB)" \
1284
1285have_makedepend:
1286        @util/arb_check_build_env.pl --check-only "$(MAKEDEPEND_PLAIN)"
1287
1288check_ENVIRONMENT : check_PATH check_TOOLS
1289                @echo "-------------------- Environment [start]"
1290                @echo "ARBHOME='$(ARBHOME)'"
1291                @echo "PATH='$(PATH)'"
1292                @echo "LD_LIBRARY_PATH='$(LD_LIBRARY_PATH)'"
1293                @echo "-------------------- Environment [end]"
1294
1295check_tabs: check_setup
1296ifeq ($(DEBUG),1)
1297        @SOURCE_TOOLS/tabBrake.pl
1298endif
1299
1300force_tab_check:
1301        @touch -t 198001010000 SOURCE_TOOLS/stamp.tabBrake
1302        @$(MAKE) check_tabs
1303
1304
1305# ---------------------
1306
1307check_setup: check_ENVIRONMENT check_DEBUG check_ARB_64 check_DEVELOPER check_GCC_VERSION
1308                @echo Your setup seems to be ok.
1309
1310checks: check_setup check_tabs
1311        @rm -f SOURCE_TOOLS/postcompile.sav
1312
1313
1314# end test section ------------------------------
1315
1316# ---------------------------------------
1317# List of standard top level directories
1318#
1319# sub-makefiles have to define the targets
1320# - 'depends' and
1321# - 'clean'
1322#
1323# when adding new libraries/subdirs here, also add a dependency vs 'links' or 'links_non_perl' in .@DD_links_non_perl
1324
1325TL_ARCHIVES = \
1326                        AISC/AISC.a \
1327                        ARB_GDE/ARB_GDE.a \
1328                        AWTC/AWTC.a \
1329                        AWTI/AWTI.a \
1330                        CONSENSUS_TREE/CONSENSUS_TREE.a \
1331                        CONVERTALN/CONVERTALN.a \
1332                        DBSERVER/DBSERVER.a \
1333                        DIST/DIST.a \
1334                        EDIT4/EDIT4.a \
1335                        EISPACK/EISPACK.a \
1336                        GENOM/GENOM.a \
1337                        GENOM_IMPORT/GENOM_IMPORT.a \
1338                        ISLAND_HOPPING/ISLAND_HOPPING.a \
1339                        MERGE/MERGE.a \
1340                        MULTI_PROBE/MULTI_PROBE.a \
1341                        NALIGNER/NALIGNER.a \
1342                        NAMES/NAMES.a \
1343                        NAMES_COM/server.a \
1344                        NTREE/NTREE.a \
1345                        PARSIMONY/PARSIMONY.a \
1346                        PHYLO/PHYLO.a \
1347                        PRIMER_DESIGN/PRIMER_DESIGN.a \
1348                        PROBE/PROBE.a \
1349                        PROBE_COM/server.a \
1350                        PROBE_DESIGN/PROBE_DESIGN.a \
1351                        $(RNA3D_LIB) \
1352                        RNACMA/RNACMA.a \
1353                        SECEDIT/SECEDIT.a \
1354                        SEQ_QUALITY/SEQ_QUALITY.a \
1355                        SERVERCNTRL/SERVERCNTRL.a \
1356                        STAT/STAT.a \
1357                        TREEGEN/TREEGEN.a \
1358                        WETC/WETC.a \
1359                        XML/XML.a \
1360
1361TL_SHARED_ARCHIVES = \
1362                        ARBDB/libARBDB.so \
1363                        CORE/libCORE.so \
1364                        AWT/libAWT.so \
1365                        WINDOW/libWINDOW.so \
1366
1367TL_ARCHIV_COLLECTIONS = \
1368                        SL/SL.archColl \
1369
1370TL_TOOLS_COLLECTIONS = \
1371                        AISC_MKPTPS/AISC_MKPTPS.toolColl \
1372                        TOOLS/TOOLS.toolColl \
1373                        PERLTOOLS/PERLTOOLS.toolColl \
1374                        PROBE_SET/PROBE_SET.toolColl \
1375                        READSEQ/READSEQ.toolColl \
1376
1377RECURSIVE_SUBS = \
1378                        GDE/GDE.sub \
1379                        UNIT_TESTER/UNIT_TESTER.sub \
1380
1381SUBDIRS = \
1382        $(RECURSIVE_SUBS) \
1383        $(TL_ARCHIVES:.a=.sub) \
1384        $(TL_SHARED_ARCHIVES:.so=.sub) \
1385        $(TL_ARCHIV_COLLECTIONS:.archColl=.sub) \
1386        $(TL_TOOLS_COLLECTIONS:.toolColl=.sub) \
1387
1388# sub directories inside TL_ARCHIV_COLLECTIONS
1389CL_ARCH_DIRS = $(foreach coll,$(TL_ARCHIV_COLLECTIONS),$(shell find $(dir $(coll)) -maxdepth 1 -mindepth 1 -type d))
1390
1391# archives inside CL_ARCH_DIRS:
1392CL_ARCHIVES = $(foreach adir,$(CL_ARCH_DIRS),$(dir $(adir))$(notdir $(adir))/$(notdir $(adir)).a)
1393
1394# -----------------------
1395#     library packets
1396
1397ARCHS_CLIENT_PROBE = PROBE_COM/client.a
1398ARCHS_CLIENT_NAMES = NAMES_COM/client.a
1399
1400ARCHS_MAKEBIN = AISC_MKPTPS/AISC_MKPTPS.a AISC/AISC.a
1401
1402# communication libs need aisc and aisc_mkpts:
1403
1404AISC/AISC.dummy: proto_tools
1405
1406comtools: AISC/AISC.dummy
1407
1408ARCHS_SEQUENCE = \
1409                SL/SEQUENCE/SEQUENCE.a \
1410                SL/ALIVIEW/ALIVIEW.a \
1411                SL/PRONUC/PRONUC.a \
1412
1413ARCHS_TREE = \
1414                SL/ARB_TREE/ARB_TREE.a \
1415                SL/FILTER/FILTER.a \
1416                $(ARCHS_SEQUENCE) \
1417
1418# parsimony tree (used by NTREE, PARSIMONY, STAT(->EDIT4), DIST(obsolete!))
1419ARCHS_AP_TREE = \
1420                SL/AP_TREE/AP_TREE.a \
1421                $(ARCHS_TREE) \
1422
1423# --------------------------------------------------------------------------------
1424# dependencies for linking shared libs
1425
1426link_core:      core
1427link_db:        db link_core
1428link_aw:        aw link_db
1429link_awt:       awt link_aw
1430
1431#***************************************************************************************
1432#               Individual_Programs_Section
1433#***************************************************************************************
1434
1435arbmainwrapper:
1436        $(MAKE) -C SOURCE_TOOLS -r mainwrapper
1437
1438
1439#***********************************    arb_ntree **************************************
1440NTREE = bin/arb_ntree
1441ARCHS_NTREE = \
1442                NTREE/NTREE.a \
1443                ARB_GDE/ARB_GDE.a \
1444                SL/GROUP_SEARCH/GROUP_SEARCH.a \
1445                SL/SAICALC/SAICALC.a \
1446                SL/DB_UI/DB_UI.a \
1447                AWTC/AWTC.a \
1448                AWTI/AWTI.a \
1449                CONSENSUS_TREE/CONSENSUS_TREE.a \
1450                GENOM_IMPORT/GENOM_IMPORT.a \
1451                GENOM/GENOM.a \
1452                MERGE/MERGE.a \
1453                MULTI_PROBE/MULTI_PROBE.a \
1454                PRIMER_DESIGN/PRIMER_DESIGN.a \
1455                PROBE_DESIGN/PROBE_DESIGN.a \
1456                SEQ_QUALITY/SEQ_QUALITY.a \
1457                SERVERCNTRL/SERVERCNTRL.a \
1458                SL/ALILINK/ALILINK.a \
1459                SL/AW_NAME/AW_NAME.a \
1460                SL/CONSENSUS/CONSENSUS.a \
1461                SL/DB_SCANNER/DB_SCANNER.a \
1462                SL/DB_QUERY/DB_QUERY.a \
1463                SL/QUERY/QUERY.a \
1464                SL/SEQIO/SEQIO.a \
1465                STAT/STAT.a \
1466                SL/GUI_ALIVIEW/GUI_ALIVIEW.a \
1467                SL/HELIX/HELIX.a \
1468                SL/REGEXPR/REGEXPR.a \
1469                SL/REFENTRIES/REFENTRIES.a \
1470                SL/NDS/NDS.a \
1471                SL/ITEM_SHADER/ITEM_SHADER.a \
1472                SL/ITEMS/ITEMS.a \
1473                SL/INSDEL/INSDEL.a \
1474                SL/LOCATION/LOCATION.a \
1475                SL/MACROS/MACROS.a \
1476                SL/PVP/PVP.a \
1477                SL/TRANSLATE/TRANSLATE.a \
1478                SL/TREEDISP/TREEDISP.a \
1479                SL/TREE_ADMIN/TREE_ADMIN.a \
1480                SL/TREE_READ/TREE_READ.a \
1481                SL/TREE_WRITE/TREE_WRITE.a \
1482                SL/XFERGUI/XFERGUI.a \
1483                SL/XFERSET/XFERSET.a \
1484                XML/XML.a \
1485                $(ARCHS_AP_TREE) \
1486
1487ARCHS_NTREE_ALL = $(ARCHS_NTREE) $(ARCHS_CLIENT_PROBE) $(GUI_LIBS) $(XMLLIBS)
1488
1489$(NTREE): $(ARCHS_NTREE:.a=.dummy) link_awt
1490        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_NTREE_ALL) || ( \
1491                echo "$(SEP) Link $@"; \
1492                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NTREE_ALL)" ; \
1493                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NTREE_ALL) && \
1494                echo "$(SEP) Link $@ [done]"; \
1495                )
1496
1497#***********************************    arb_edit4 **************************************
1498EDIT4 = bin/arb_edit4
1499
1500ARCHS_EDIT4 := \
1501                EDIT4/EDIT4.a \
1502                ARB_GDE/ARB_GDE.a \
1503                SL/FAST_ALIGNER/FAST_ALIGNER.a \
1504                AWTC/AWTC.a \
1505                ISLAND_HOPPING/ISLAND_HOPPING.a \
1506                SECEDIT/SECEDIT.a \
1507                SERVERCNTRL/SERVERCNTRL.a \
1508                SL/AW_HELIX/AW_HELIX.a \
1509                SL/AW_NAME/AW_NAME.a \
1510                SL/CONSENSUS/CONSENSUS.a \
1511                SL/ITEMS/ITEMS.a \
1512                STAT/STAT.a \
1513                SL/GUI_ALIVIEW/GUI_ALIVIEW.a \
1514                SL/HELIX/HELIX.a \
1515                SL/TRANSLATE/TRANSLATE.a \
1516                SL/MACROS/MACROS.a \
1517                SL/NDS/NDS.a \
1518                $(ARCHS_AP_TREE) \
1519                XML/XML.a \
1520
1521ifeq ($(OPENGL),1)
1522ARCHS_EDIT4 += RNA3D/RNA3D.a
1523endif
1524
1525ARCHS_EDIT4_ALL = $(ARCHS_EDIT4) $(ARCHS_CLIENT_NAMES) $(GUI_LIBS) $(LIBS_EDIT4)
1526
1527LIBS_EDIT4 := $(GL_LIBS)
1528
1529$(EDIT4): $(ARCHS_EDIT4:.a=.dummy) link_awt
1530        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_EDIT4_ALL) || ( \
1531                echo "$(SEP) Link $@"; \
1532                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_EDIT4_ALL)" ; \
1533                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_EDIT4_ALL) && \
1534                echo "$(SEP) Link $@ [done]"; \
1535                )
1536
1537#***********************************    arb_rnacma **************************************
1538RNACMA = bin/arb_rnacma
1539ARCHS_RNACMA = \
1540                RNACMA/RNACMA.a \
1541
1542ARCHS_RNACMA_ALL = $(ARCHS_RNACMA) $(DBSYS_LIBS)
1543
1544$(RNACMA) : $(ARCHS_RNACMA:.a=.dummy) link_db
1545        @SOURCE_TOOLS/binuptodate.pl $@ $(ARCHS_RNACMA_ALL) || ( \
1546                echo "$(SEP) Link $@"; \
1547                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_RNACMA_ALL)"; \
1548                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_RNACMA_ALL) && \
1549                echo "$(SEP) Link $@ [done]"; \
1550                )
1551
1552#***********************************    arb_wetc **************************************
1553WETC = bin/arb_wetc
1554ARCHS_WETC = \
1555                WETC/WETC.a \
1556                SL/HELIX/HELIX.a \
1557                SL/FILTER/FILTER.a \
1558                XML/XML.a \
1559
1560ARCHS_WETC_ALL = $(ARCHS_WETC) $(GUI_LIBS)
1561
1562$(WETC): $(ARCHS_WETC:.a=.dummy) link_awt
1563        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_WETC_ALL) || ( \
1564                echo "$(SEP) Link $@"; \
1565                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_WETC_ALL)" ; \
1566                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_WETC_ALL) && \
1567                echo "$(SEP) Link $@ [done]"; \
1568                )
1569
1570#***********************************    arb_dist **************************************
1571DIST = bin/arb_dist
1572ARCHS_DIST = \
1573                DIST/DIST.a \
1574                CONSENSUS_TREE/CONSENSUS_TREE.a \
1575                EISPACK/EISPACK.a \
1576                SERVERCNTRL/SERVERCNTRL.a \
1577                SL/GUI_ALIVIEW/GUI_ALIVIEW.a \
1578                SL/HELIX/HELIX.a \
1579                SL/MATRIX/MATRIX.a \
1580                SL/MACROS/MACROS.a \
1581                SL/NDS/NDS.a \
1582                SL/ITEMS/ITEMS.a \
1583                SL/NEIGHBOURJOIN/NEIGHBOURJOIN.a \
1584                XML/XML.a \
1585                $(ARCHS_AP_TREE) \
1586
1587ARCHS_DIST_ALL = $(ARCHS_DIST) $(ARCHS_CLIENT_PROBE) $(GUI_LIBS)
1588
1589$(DIST): $(ARCHS_DIST:.a=.dummy) link_awt
1590        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_DIST_ALL) || ( \
1591                echo "$(SEP) Link $@"; \
1592                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_DIST_ALL)" ; \
1593                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_DIST_ALL) && \
1594                echo "$(SEP) Link $@ [done]"; \
1595                )
1596
1597#***********************************    arb_pars **************************************
1598PARSIMONY = bin/arb_pars
1599ARCHS_PARSIMONY = \
1600                PARSIMONY/PARSIMONY.a \
1601                SERVERCNTRL/SERVERCNTRL.a \
1602                SL/AW_NAME/AW_NAME.a \
1603                SL/GUI_ALIVIEW/GUI_ALIVIEW.a \
1604                SL/HELIX/HELIX.a \
1605                SL/MACROS/MACROS.a \
1606                SL/NDS/NDS.a \
1607                SL/ITEMS/ITEMS.a \
1608                SL/TRANSLATE/TRANSLATE.a \
1609                SL/TREEDISP/TREEDISP.a \
1610                XML/XML.a \
1611                $(ARCHS_AP_TREE) \
1612
1613ARCHS_PARSIMONY_ALL = $(ARCHS_PARSIMONY) $(ARCHS_CLIENT_NAMES) $(GUI_LIBS)
1614
1615$(PARSIMONY): $(ARCHS_PARSIMONY:.a=.dummy) link_awt
1616        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_PARSIMONY_ALL) || ( \
1617                echo "$(SEP) Link $@"; \
1618                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PARSIMONY_ALL)" ; \
1619                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PARSIMONY_ALL) && \
1620                echo "$(SEP) Link $@ [done]"; \
1621                )
1622
1623#*********************************** arb_convert_aln **************************************
1624CONVERT_ALN = bin/arb_convert_aln
1625ARCHS_CONVERT_ALN =     \
1626                CONVERTALN/CONVERTALN.a \
1627
1628ARCHS_CONVERT_ALN_ALL = $(ARCHS_CONVERT_ALN) $(DBSYS_LIBS)
1629
1630$(CONVERT_ALN) : $(ARCHS_CONVERT_ALN:.a=.dummy) link_db
1631        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_CONVERT_ALN_ALL) || ( \
1632                echo "$(SEP) Link $@"; \
1633                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_CONVERT_ALN_ALL)"; \
1634                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_CONVERT_ALN_ALL) && \
1635                echo "$(SEP) Link $@ [done]"; \
1636                )
1637
1638#*********************************** arb_treegen **************************************
1639
1640TREEGEN = bin/arb_treegen
1641ARCHS_TREEGEN = \
1642                TREEGEN/TREEGEN.a \
1643
1644ARCHS_TREEGEN_ALL = $(ARCHS_TREEGEN)
1645
1646$(TREEGEN) :  $(ARCHS_TREEGEN:.a=.dummy)
1647        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main_C) $(ARCHS_TREEGEN_ALL) || ( \
1648                echo "$(SEP) Link $@"; \
1649                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main_C) $(LIBPATH) $(ARCHS_TREEGEN_ALL)" ; \
1650                $(LINK_EXECUTABLE) $@ $(use_ARB_main_C) $(LIBPATH) $(ARCHS_TREEGEN_ALL) && \
1651                echo "$(SEP) Link $@ [done]"; \
1652                )
1653
1654#***********************************    arb_naligner **************************************
1655NALIGNER = bin/arb_naligner
1656ARCHS_NALIGNER = \
1657                NALIGNER/NALIGNER.a \
1658                SERVERCNTRL/SERVERCNTRL.a \
1659                SL/HELIX/HELIX.a \
1660
1661ARCHS_NALIGNER_ALL = $(ARCHS_NALIGNER) $(ARCHS_CLIENT_PROBE) $(DBSYS_LIBS)
1662
1663$(NALIGNER): $(ARCHS_NALIGNER:.a=.dummy) link_db
1664        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_NALIGNER_ALL) || ( \
1665                echo "$(SEP) Link $@"; \
1666                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NALIGNER_ALL)" ; \
1667                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NALIGNER_ALL) && \
1668                echo "$(SEP) Link $@ [done]"; \
1669                )
1670
1671#***********************************    arb_phylo **************************************
1672PHYLO = bin/arb_phylo
1673ARCHS_PHYLO = \
1674                PHYLO/PHYLO.a \
1675                SL/HELIX/HELIX.a \
1676                SL/FILTER/FILTER.a \
1677                SL/MACROS/MACROS.a \
1678                XML/XML.a \
1679
1680ARCHS_PHYLO_ALL = $(ARCHS_PHYLO) $(GUI_LIBS)
1681
1682$(PHYLO): $(ARCHS_PHYLO:.a=.dummy) link_awt
1683        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_PHYLO_ALL) || ( \
1684                echo "$(SEP) Link $@"; \
1685                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PHYLO_ALL)" ; \
1686                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PHYLO_ALL) && \
1687                echo "$(SEP) Link $@ [done]"; \
1688                )
1689
1690#***************************************************************************************
1691#                                       SERVER SECTION
1692#***************************************************************************************
1693
1694#***********************************    arb_db_server **************************************
1695DBSERVER = bin/arb_db_server
1696ARCHS_DBSERVER = \
1697                DBSERVER/DBSERVER.a \
1698                SERVERCNTRL/SERVERCNTRL.a \
1699
1700ARCHS_DBSERVER_ALL = $(ARCHS_DBSERVER) $(ARBDB_LIB) $(ARCHS_CLIENT_PROBE) $(SYSLIBS)
1701
1702$(DBSERVER): $(ARCHS_DBSERVER:.a=.dummy) link_db
1703        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_DBSERVER_ALL) || ( \
1704                echo "$(SEP) Link $@"; \
1705                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_DBSERVER_ALL)" ; \
1706                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_DBSERVER_ALL) && \
1707                echo "$(SEP) Link $@ [done]"; \
1708                )
1709
1710#***********************************    arb_pt_server **************************************
1711PROBE = bin/arb_pt_server
1712
1713ARCHS_PROBE_DEPEND = \
1714                PROBE/PROBE.a \
1715                SL/PTCLEAN/PTCLEAN.a \
1716                SERVERCNTRL/SERVERCNTRL.a \
1717                SL/HELIX/HELIX.a \
1718
1719ARCHS_PROBE_ALL = $(ARCHS_PROBE_DEPEND) $(ARCHS_CLIENT_PROBE) $(ARBDB_LIB) $(SYSLIBS)
1720
1721$(PROBE): $(ARCHS_PROBE_DEPEND:.a=.dummy) link_db
1722        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) config.makefile $(ARCHS_PROBE_ALL) || ( \
1723                echo "$(SEP) Link $@"; \
1724                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PROBE_ALL)" ; \
1725                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_PROBE_ALL) && \
1726                echo "$(SEP) Link $@ [done]"; \
1727                )
1728
1729#***********************************    arb_name_server **************************************
1730NAMES = bin/arb_name_server
1731ARCHS_NAMES = \
1732                NAMES/NAMES.a \
1733                SERVERCNTRL/SERVERCNTRL.a \
1734
1735ARCHS_NAMES_ALL = $(ARCHS_NAMES) $(ARBDB_LIB) $(ARCHS_CLIENT_NAMES) NAMES_COM/server.a $(SYSLIBS)
1736
1737$(NAMES): $(ARCHS_NAMES:.a=.dummy) link_db
1738        @SOURCE_TOOLS/binuptodate.pl $@ $(use_ARB_main) $(ARCHS_NAMES_ALL) || ( \
1739                echo "$(SEP) Link $@"; \
1740                echo "$(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NAMES_ALL)" ; \
1741                $(LINK_EXECUTABLE) $@ $(use_ARB_main) $(LIBPATH) $(ARCHS_NAMES_ALL) && \
1742                echo "$(SEP) Link $@ [done]"; \
1743                )
1744
1745#***********************************    SHARED LIBRARIES SECTION  **************************************
1746
1747prepare_libdir: addlibs
1748
1749addlibs:
1750        (perl $(ARBHOME)/SOURCE_TOOLS/provide_libs.pl \
1751                                "arbhome=$(ARBHOME)" \
1752                                "opengl=$(OPENGL)" \
1753                                "link_static=$(LINK_STATIC)" \
1754        )
1755
1756#***************************************************************************************
1757#                       Recursive calls to sub-makefiles
1758#***************************************************************************************
1759
1760%.depends: have_makedepend
1761        @cp -p $(@D)/Makefile $(@D)/Makefile.old # save old Makefile
1762        @$(MAKE) -C $(@D) -r \
1763                "AUTODEPENDS=1" \
1764                "MAIN=nothing" \
1765                "cflags=noCflagsHere_use_MAKEDEPENDFLAGS" \
1766                "cxxflags=noCxxflagsHere_use_MAKEDEPENDFLAGS" \
1767                depends
1768        @grep "^# DO NOT DELETE" $(@D)/Makefile >/dev/null
1769        @cat $(@D)/Makefile \
1770                | SOURCE_TOOLS/fix_depends.pl "(from main)" \
1771                >$(@D)/Makefile.2
1772        @mv $(@D)/Makefile.old $(@D)/Makefile # restore old Makefile
1773        @$(ARBHOME)/SOURCE_TOOLS/mv_if_diff $(@D)/Makefile.2 $(@D)/Makefile # update Makefile if changed
1774
1775%.proto:
1776        @($(MAKE) -C $(@D) \
1777                "AUTODEPENDS=0" \
1778                "MAIN=nothing" \
1779                "cflags=noCflags" \
1780                "cxxflags=noCxxflags" \
1781                proto 2>&1 ) | $(ARBHOME)/SOURCE_TOOLS/asan2msg.pl
1782
1783%.clean:
1784        @$(MAKE) -C $(@D) \
1785                "AUTODEPENDS=0" \
1786                "MAIN=nothing" \
1787                "cflags=noCflags" \
1788                "cxxflags=noCxxflags" \
1789                clean
1790
1791
1792# stop wrong targets:
1793target_is_missing_lib_prefix:
1794        @echo "Error: Denied to build shared library target with missing 'lib'-prefix"
1795        false
1796
1797ARBDB/ARBDB.dummy:   target_is_missing_lib_prefix
1798CORE/CORE.dummy:     target_is_missing_lib_prefix
1799AWT/AWT.dummy:       target_is_missing_lib_prefix
1800WINDOW/WINDOW.dummy: target_is_missing_lib_prefix
1801
1802# rule to generate main target (normally a library):
1803# @@@ check effect of setting LANG=C below
1804%.dummy:
1805        @( export ID=$$$$; LANG=C; \
1806        (( \
1807            echo "$(SEP) Make $(@D)"; \
1808            $(MAKE) -C $(@D) -r \
1809                "AUTODEPENDS=1" \
1810                "MAIN=$(@F:.dummy=.a)" \
1811                "cflags=$(cflags) -DIN_ARB_$(subst /,_,$(@D))" \
1812                && \
1813            echo "$(SEP) Make $(@D) [done]"; \
1814        ) >$(@D).$$ID.log 2>&1 && (cat $(@D).$$ID.log;rm $(@D).$$ID.log)) || (cat $(@D).$$ID.log;rm $(@D).$$ID.log;false))
1815
1816# Additional dependencies for subtargets:
1817
1818PROBE_COM/PROBE_COM.dummy : comtools
1819NAMES_COM/NAMES_COM.dummy : comtools
1820
1821com: PROBE_COM/PROBE_COM.dummy NAMES_COM/NAMES_COM.dummy
1822
1823# stop wrong more targets:
1824PROBE_COM/server.dummy:
1825        @echo Unwanted request to make target $<
1826        false
1827
1828PROBE_COM/client.dummy:
1829        @echo Unwanted request to make target $<
1830        false
1831
1832NAMES_COM/server.dummy:
1833        @echo Unwanted request to make target $<
1834        false
1835
1836NAMES_COM/client.dummy:
1837        @echo Unwanted request to make target $<
1838        false
1839
1840
1841ARBDB/libARBDB.dummy:                   links
1842CORE/libCORE.dummy:                     links
1843
1844PERLTOOLS/PERLTOOLS.dummy:              core db
1845
1846# all subdirs perl not depends on go here (ADD_links_non_perl)
1847AWT/libAWT.dummy:                       links_non_perl
1848AWTI/AWTI.dummy:                        links_non_perl
1849CONSENSUS_TREE/CONSENSUS_TREE.dummy:    links_non_perl
1850CONVERTALN/CONVERTALN.dummy:            links_non_perl
1851DBSERVER/DBSERVER.dummy:                links_non_perl
1852DIST/DIST.dummy:                        links_non_perl
1853EDIT4/EDIT4.dummy:                      links_non_perl com
1854EISPACK/EISPACK.dummy:                  links_non_perl
1855GDE/GDE.dummy:                          links_non_perl
1856GENOM/GENOM.dummy:                      links_non_perl
1857GENOM_IMPORT/GENOM_IMPORT.dummy:        links_non_perl
1858ISLAND_HOPPING/ISLAND_HOPPING.dummy:    links_non_perl
1859MERGE/MERGE.dummy:                      links_non_perl
1860NTREE/NTREE.dummy:                      links_non_perl
1861PARSIMONY/PARSIMONY.dummy:              links_non_perl
1862PHYLO/PHYLO.dummy:                      links_non_perl
1863PRIMER_DESIGN/PRIMER_DESIGN.dummy:      links_non_perl
1864PROBE_SET/PROBE_SET.dummy:              links_non_perl link_db
1865READSEQ/READSEQ.dummy:                  links_non_perl
1866RNACMA/RNACMA.dummy:                    links_non_perl header_libs
1867SECEDIT/SECEDIT.dummy:                  links_non_perl
1868SEQ_QUALITY/SEQ_QUALITY.dummy:          links_non_perl
1869SERVERCNTRL/SERVERCNTRL.dummy:          links_non_perl com
1870SL/ALILINK/ALILINK.dummy:               links_non_perl
1871SL/ALIVIEW/ALIVIEW.dummy:               links_non_perl
1872SL/AP_TREE/AP_TREE.dummy:               links_non_perl
1873SL/ARB_TREE/ARB_TREE.dummy:             links_non_perl
1874SL/AW_HELIX/AW_HELIX.dummy:             links_non_perl
1875SL/CONSENSUS/CONSENSUS.dummy:           links_non_perl
1876SL/DB_QUERY/DB_QUERY.dummy:             links_non_perl
1877SL/DB_SCANNER/DB_SCANNER.dummy:         links_non_perl
1878SL/DB_UI/DB_UI.dummy:                   links_non_perl
1879SL/FAST_ALIGNER/FAST_ALIGNER.dummy:     links_non_perl
1880SL/FILTER/FILTER.dummy:                 links_non_perl
1881SL/FILTSEQEXP/FILTSEQEXP.dummy:         links_non_perl
1882SL/GROUP_SEARCH/GROUP_SEARCH.dummy:     links_non_perl
1883SL/GUI_ALIVIEW/GUI_ALIVIEW.dummy:       links_non_perl
1884SL/HEADERTESTS/HEADERTESTS.dummy:       links_non_perl
1885SL/HELIX/HELIX.dummy:                   links_non_perl
1886SL/INSDEL/INSDEL.dummy:                 links_non_perl
1887SL/ITEM_SHADER/ITEM_SHADER.dummy:       links_non_perl
1888SL/ITEMS/ITEMS.dummy:                   links_non_perl
1889SL/LOCATION/LOCATION.dummy:             links_non_perl
1890SL/MACROS/MACROS.dummy:                 links_non_perl
1891SL/MATRIX/MATRIX.dummy:                 links_non_perl
1892SL/NDS/NDS.dummy:                       links_non_perl
1893SL/NEIGHBOURJOIN/NEIGHBOURJOIN.dummy:   links_non_perl
1894SL/PRONUC/PRONUC.dummy:                 links_non_perl
1895SL/PTCLEAN/PTCLEAN.dummy:               links_non_perl link_db
1896SL/PVP/PVP.dummy:                       links_non_perl
1897SL/QUERY/QUERY.dummy:                   links_non_perl link_db
1898SL/REFENTRIES/REFENTRIES.dummy:         links_non_perl
1899SL/REGEXPR/REGEXPR.dummy:               links_non_perl
1900SL/SAICALC/SAICALC.dummy:               links_non_perl
1901SL/SEQIO/SEQIO.dummy:                   links_non_perl
1902SL/SEQUENCE/SEQUENCE.dummy:             links_non_perl
1903SL/TRANSLATE/TRANSLATE.dummy:           links_non_perl
1904SL/TREE_ADMIN/TREE_ADMIN.dummy:         links_non_perl
1905SL/TREE_READ/TREE_READ.dummy:           links_non_perl
1906SL/TREE_WRITE/TREE_WRITE.dummy:         links_non_perl
1907SL/TREEDISP/TREEDISP.dummy:             links_non_perl
1908SL/XFERGUI/XFERGUI.dummy:               links_non_perl
1909SL/XFERSET/XFERSET.dummy:               links_non_perl
1910STAT/STAT.dummy:                        links_non_perl
1911TREEGEN/TREEGEN.dummy:                  links_non_perl
1912WETC/WETC.dummy:                        links_non_perl
1913WINDOW/libWINDOW.dummy:                 links_non_perl
1914XML/XML.dummy:                          links_non_perl
1915
1916ifeq ($(OPENGL),1)
1917GL/glAW/glAW.dummy: links_non_perl
1918GL/glpng/glpng.dummy: links_non_perl
1919GL/GL.dummy: GL/glAW/glAW.dummy GL/glpng/glpng.dummy
1920RNA3D/RNA3D.dummy: links_non_perl gl
1921endif
1922
1923UNIT_TESTER/UNIT_TESTER.dummy:          link_db \
1924        SERVERCNTRL/SERVERCNTRL.dummy \
1925
1926# see also TOOLS/Makefile@TOOLSLIBDEPENDS
1927TOOLS/TOOLS.dummy : links_non_perl link_db \
1928        CONSENSUS_TREE/CONSENSUS_TREE.dummy \
1929        SERVERCNTRL/SERVERCNTRL.dummy \
1930        SL/FILTER/FILTER.dummy \
1931        SL/FILTSEQEXP/FILTSEQEXP.dummy \
1932        SL/INSDEL/INSDEL.dummy \
1933        SL/REGEXPR/REGEXPR.dummy \
1934        SL/SEQIO/SEQIO.dummy \
1935        SL/TREE_READ/TREE_READ.dummy \
1936        SL/TREE_WRITE/TREE_WRITE.dummy \
1937        XML/XML.dummy \
1938
1939AWTC/AWTC.dummy :                       com
1940
1941NAMES/NAMES.dummy :                     com
1942SL/AW_NAME/AW_NAME.dummy :              com
1943
1944PROBE/PROBE.dummy :                     com
1945MULTI_PROBE/MULTI_PROBE.dummy :         com
1946PROBE_DESIGN/PROBE_DESIGN.dummy :       com
1947NALIGNER/NALIGNER.dummy :               com
1948
1949ARB_GDE/ARB_GDE.dummy :                 proto_tools menus
1950
1951compile_compatibility: SOURCE_TOOLS/COMPILE_COMPAT/COMPILE_COMPAT.dummy
1952
1953#***************************************************************************************
1954#                       Short aliases to make targets
1955#***************************************************************************************
1956
1957show:
1958                @echo $(SEP)
1959                @echo 'Aliases for often needed targets:'
1960                @echo ''
1961                @echo ' executables:'
1962                @echo ''
1963                @echo '  nt     arb_ntree'
1964                @echo '  e4     arb_edit4 (includes secedit)'
1965                @echo '  di     arb_dist'
1966                @echo '  ph     arb_phylo'
1967                @echo '  pa     arb_parsimony'
1968                @echo '  tg     arb_treegen'
1969                @echo '  ds     arb_dbserver'
1970                @echo '  pt     arb_pt_server'
1971                @echo '  na     arb_name_server'
1972                @echo ''
1973                @echo ' libraries:'
1974                @echo ''
1975                @echo '  com    communication libraries'
1976                @echo '  db     ARB database'
1977                @echo '  aw     GUI lib'
1978                @echo '  awt    GUI toolkit'
1979                @echo '  awtc   general purpose library'
1980                @echo '  awti   import/export library'
1981                @echo '  mp     multi probe library'
1982                @echo '  ge     genome library'
1983                @echo '  pd     probe design lib'
1984                @echo '  prd    primer design lib'
1985                @echo ''
1986                @echo ' other targets:'
1987                @echo ''
1988                @echo '  help   recompile help files'
1989                @echo '  tools  make small tools used by arb'
1990                @echo ''
1991                @echo ' foreign targets:'
1992                @echo ''
1993                @echo '  gde    GDE'
1994                @echo '  agde   ARB_GDE'
1995                @echo ''
1996                @echo 'for other targets inspect $(ARBHOME)/Makefile'
1997                @echo ''
1998                @echo $(SEP)
1999
2000source_doc:
2001        @echo "Remove some links (doxygen crashes otherwise):"
2002        find . \( -name "AISC" -o -name "C" -o -name "GDEHELP" \) -type l -exec rm {} \;
2003        doxygen 2>&1 1>/dev/null
2004        $(MAKE) forcelinks
2005
2006dep_graph:
2007        @echo "Building some dependency graphs"
2008        SOURCE_TOOLS/dependency_graphs.pl
2009
2010help:   HELP_SOURCE/HELP_SOURCE.dummy
2011
2012HELP_SOURCE/HELP_SOURCE.dummy: link_core xml menus
2013
2014db:     ARBDB/libARBDB.dummy
2015core:   CORE/libCORE.dummy
2016aw:     WINDOW/libWINDOW.dummy
2017awt:    AWT/libAWT.dummy
2018awtc:   AWTC/AWTC.dummy
2019awti:   AWTI/AWTI.dummy
2020
2021mp:     MULTI_PROBE/MULTI_PROBE.dummy
2022mg:     MERGE/MERGE.dummy
2023ge:     GENOM/GENOM.dummy
2024prd:    PRIMER_DESIGN/PRIMER_DESIGN.dummy
2025
2026nt:     menus $(NTREE)
2027
2028nal:    $(NALIGNER)
2029
2030di:     $(DIST)
2031ph:     $(PHYLO)
2032pa:     $(PARSIMONY)
2033tg:     $(TREEGEN)
2034
2035ifeq ($(OPENGL),1)
20363d:     RNA3D/RNA3D.dummy
2037gl:     GL/GL.dummy
2038else
2039noopengl:
2040        @echo "invalid target for OPENGL=0"
20413d: noopengl
2042gl: noopengl
2043endif
2044
2045SL/SL.dummy: com
2046
2047ds:     $(DBSERVER)
2048pt:     $(PROBE)
2049pst:    PROBE_SET/PROBE_SET.dummy
2050pd:     PROBE_DESIGN/PROBE_DESIGN.dummy
2051na:     $(NAMES)
2052sq:     SEQ_QUALITY/SEQ_QUALITY.dummy
2053cma:    $(RNACMA)
2054
2055sec:    SECEDIT/SECEDIT.dummy
2056
2057e4:     $(EDIT4) readseq menus
2058
2059gi:     GENOM_IMPORT/GENOM_IMPORT.dummy
2060wetc:   $(WETC)
2061
2062xml:    XML/XML.dummy
2063stat:   STAT/STAT.dummy $(NTREE) $(EDIT4)
2064fa:     SL/FAST_ALIGNER/FAST_ALIGNER.dummy
2065
2066#********************************************************************************
2067
2068up_by_remake: depends proto vectorize_checks
2069
2070up: up_by_remake tags valgrind_update
2071
2072#********************************************************************************
2073
2074touch:
2075        SOURCE_TOOLS/touch_modified.pl
2076
2077modified: touch
2078        $(MAKE) all
2079
2080#********************************************************************************
2081
2082libdepends:
2083        $(MAKE) -C "SOURCE_TOOLS" \
2084                "RNA3D_LIB=$(RNA3D_LIB_4_DEPENDS)" \
2085                libdepends
2086
2087#********************************************************************************
2088
2089# create generated headers:
2090genheaders: TEMPLATES/TEMPLATES.dummy
2091
2092clrdotdepends:
2093        rm PROBE_COM/.depends || true
2094        rm NAMES_COM/.depends || true
2095        rm PERL2ARB/.depends || true
2096
2097comdepends: comtools clrdotdepends have_makedepend
2098        @echo "$(SEP) Partially build com interface"
2099        $(MAKE) PROBE_COM/PROBE_COM.depends NAMES_COM/NAMES_COM.depends
2100        $(MAKE) PROBE_COM/server.depends    NAMES_COM/server.depends
2101
2102depends: genheaders comdepends vectorize_checks have_makedepend
2103        @echo "$(SEP) Updating other dependencies"
2104        $(MAKE) $(subst NAMES_COM/server.depends,,$(subst PROBE_COM/server.depends,,$(SUBDIRS:.sub=.depends))) \
2105                HELP_SOURCE/HELP_SOURCE.depends \
2106                SOURCE_TOOLS/COMPILE_COMPAT/COMPILE_COMPAT.depends \
2107
2108        $(MAKE) libdepends
2109
2110depend: depends
2111
2112# ------------------------------------------------------------
2113# dependency generation tests for AISC code
2114#(all should work w/o creating wrong dependencies;
2115# neither in XXX_COM/Makefile nor in code using AISC interface)
2116dependstest1: silent_clean
2117        $(MAKE) depends
2118dependstest2: silent_clean
2119        $(MAKE) com
2120dependstest3: silent_clean
2121        $(MAKE) aw
2122dependstest4: silent_clean
2123        $(MAKE) pt
2124dependstest5: silent_clean
2125        $(MAKE) na
2126dependstest6: silent_clean
2127        $(MAKE) nt
2128dependstest7: silent_clean
2129        $(MAKE) all
2130# ------------------------------------------------------------
2131
2132vectorize_checks:
2133        $(MAKE) -C SOURCE_TOOLS -r vectorize_checks
2134
2135clean_checked_vect: lib/lib.clean
2136        SOURCE_TOOLS/clean_checked_vectorizations.sh
2137
2138# ------------------------------------------------------------
2139
2140AISC_MKPTPS/AISC_MKPTPS.dummy: links
2141
2142proto_tools: AISC_MKPTPS/AISC_MKPTPS.dummy
2143
2144proto: proto_tools
2145        @echo $(SEP) Updating prototypes
2146        $(MAKE) \
2147                ARBDB/ARBDB.proto \
2148                AISC_COM/AISC_COM.proto \
2149                ARB_GDE/ARB_GDE.proto \
2150                CORE/CORE.proto \
2151                CONVERTALN/CONVERTALN.proto \
2152                NTREE/NTREE.proto \
2153                MERGE/MERGE.proto \
2154                PROBE/PROBE.proto \
2155                SERVERCNTRL/SERVERCNTRL.proto \
2156                SL/SL.proto \
2157
2158#********************************************************************************
2159
2160valgrind_update: links
2161        @echo $(SEP) Updating for valgrind
2162        $(MAKE) -C SOURCE_TOOLS valgrind_update
2163
2164#********************************************************************************
2165
2166TAGFILE=TAGS
2167UTAGS=TAGS.$(ARBBID)
2168TAGFILE_TMP=$(UTAGS).tmp
2169
2170TAG_SOURCE_HEADERS=$(UTAGS).headers.tmp
2171TAG_SOURCE_CODE=$(UTAGS).codefiles.tmp
2172TAG_SOURCE_LISTS=$(TAG_SOURCE_HEADERS) $(TAG_SOURCE_CODE)
2173
2174ETAGS_IGNORE_LIST=SOURCE_TOOLS/etags_ignore.lst
2175
2176ETAGS=ctags -e -I @$(ETAGS_IGNORE_LIST) --sort=no --if0=no --extra=q
2177ETAGS_TYPES=--C-kinds=cgnsut --C++-kinds=cgnsut
2178ETAGS_FUN  =--C-kinds=fm     --C++-kinds=fm
2179ETAGS_REST =--C-kinds=dev    --C++-kinds=dev
2180
2181FILTER_TAGS_SOURCES= \
2182        $(SED) -e 's/^.\///g' | \
2183        grep -vi '^HEADERLIBS\|^GDE/\|/GEN[CH]/'
2184
2185$(TAG_SOURCE_HEADERS): links
2186        @find . \( -name '*.hxx' -o -name "*.h" \) -type f | $(FILTER_TAGS_SOURCES) > $@
2187
2188$(TAG_SOURCE_CODE): links
2189        @find . \( -name '*.cxx' -o -name "*.c" \) -type f | $(FILTER_TAGS_SOURCES) > $@
2190
2191$(UTAGS).1.tmp: $(TAG_SOURCE_HEADERS)
2192        @$(ETAGS) -f $@ $(ETAGS_TYPES) -L $<
2193$(UTAGS).2.tmp: $(TAG_SOURCE_HEADERS)
2194        @$(ETAGS) -f $@ $(ETAGS_FUN) -L $<
2195$(UTAGS).3.tmp: $(TAG_SOURCE_HEADERS)
2196        @$(ETAGS) -f $@ $(ETAGS_REST) -L $<
2197$(UTAGS).4.tmp: $(TAG_SOURCE_CODE)
2198        @$(ETAGS) -f $@ $(ETAGS_TYPES) -L $<
2199$(UTAGS).5.tmp: $(TAG_SOURCE_CODE)
2200        @$(ETAGS) -f $@ $(ETAGS_FUN) -L $<
2201$(UTAGS).6.tmp: $(TAG_SOURCE_CODE)
2202        @$(ETAGS) -f $@ $(ETAGS_REST) -L $<
2203
2204TAGS_ALL_PARTS=$(UTAGS).1.tmp $(UTAGS).2.tmp $(UTAGS).3.tmp $(UTAGS).4.tmp $(UTAGS).5.tmp $(UTAGS).6.tmp
2205
2206$(TAGFILE_TMP) : $(TAGS_ALL_PARTS)
2207        @cat $(TAGS_ALL_PARTS) > $@
2208        @rm $(TAGS_ALL_PARTS) $(TAG_SOURCE_LISTS)
2209
2210cleanOldTags:
2211        @find $(ARBHOME) -name 'TAGS.*.tmp' -ctime +2 -exec rm {} \;
2212
2213tags: $(TAGFILE_TMP) cleanOldTags
2214        @mv_if_diff $(TAGFILE_TMP) $(TAGFILE)
2215
2216#********************************************************************************
2217
2218LINKSTAMP=SOURCE_TOOLS/stamp.generate_all_links
2219
2220links: checks $(LINKSTAMP) arbmainwrapper
2221links_no_checks: $(LINKSTAMP) arbmainwrapper
2222
2223forcelinks:
2224        -rm $(LINKSTAMP)
2225        $(MAKE) links
2226
2227$(LINKSTAMP): SOURCE_TOOLS/generate_all_links.sh genheaders
2228        +SOURCE_TOOLS/generate_all_links.sh
2229        touch $(LINKSTAMP)
2230
2231clean_links:
2232#       avoid to delete linked pts, nas or arb_tcp.dat:
2233        find . -path './lib' -prune -o -type l -exec rm {} \;
2234#       removed obsolete file - refuses to disappear due to 'prune' above
2235        @rm -f lib/help/GDEHELP
2236        @rm -f $(LINKSTAMP) lib/inputMasks/format.readme
2237
2238redo_links: clean_links
2239        $(MAKE) links_no_checks
2240
2241#********************************************************************************
2242
2243header_libs:
2244        @(( \
2245                echo "$(SEP) Make HEADERLIBS"; \
2246                $(MAKE) -C HEADERLIBS all && \
2247                echo "$(SEP) Make HEADERLIBS [done]"; \
2248        ) > HEADERLIBS.log 2>&1 && (cat HEADERLIBS.log;rm HEADERLIBS.log)) || (cat HEADERLIBS.log;rm HEADERLIBS.log;false)
2249
2250#********************************************************************************
2251
2252gde:            GDE/GDE.dummy
2253GDE:            gde
2254agde:           ARB_GDE/ARB_GDE.dummy
2255tools:          TOOLS/TOOLS.dummy
2256convert:        $(CONVERT_ALN)
2257readseq:        READSEQ/READSEQ.dummy
2258
2259#***************************************************************************************
2260#                       Some user commands
2261#***************************************************************************************
2262
2263menus: binlink links
2264        @(( \
2265                echo "$(SEP) Make GDEHELP"; \
2266                $(MAKE) -C GDEHELP -r all && \
2267                echo "$(SEP) Make GDEHELP [done]"; \
2268        ) > GDEHELP.log 2>&1 && (cat GDEHELP.log;rm GDEHELP.log)) || (cat GDEHELP.log;rm GDEHELP.log;false)
2269
2270ifeq ($(DEBUG),1)
2271BIN_TARGET=develall
2272else
2273BIN_TARGET=all
2274endif
2275
2276
2277binlink:
2278        $(MAKE) -C bin $(BIN_TARGET)
2279
2280check_bin_dep: binlink
2281        SOURCE_TOOLS/check_bin_dependencies.pl
2282
2283fig_cure:
2284        SOURCE_TOOLS/sortfig.pl doit
2285
2286preplib:
2287        (cd lib;$(MAKE) all)
2288
2289# --------------------------------------------------------------------------------
2290# This section is quite tricky:
2291#
2292# make 'perl' is a BIG target, so when it has to be made, it has to be started
2293# as early as possible to reduce overall compile time. Since 'make' does not
2294# provide any priorities, i force it to build all 'perl'-prerequisites early, by
2295# adding artificial dependencies to these prerequisites
2296#
2297# That behavior is likely to be system-dependent.
2298# My goal was only to make it work on my current development system,
2299# where this saves about 20% of overall build time.
2300
2301ifeq ($(WITHPERL),1)
2302links_non_perl: PERLTOOLS/PERLTOOLS.dummy
2303perltools:      links_non_perl
2304perl:           realperl
2305else
2306links_non_perl: links
2307perl:           links
2308        $(MAKE) "WITHPERL=1" perl
2309endif
2310
2311# ---------------------------------------- perl
2312
2313realperl: perltools
2314        (( \
2315                echo "$(SEP) Make PERL2ARB" ; \
2316                $(TIME) $(MAKE) -C PERL2ARB -r -f Makefile.main \
2317                        "AUTODEPENDS=1" \
2318                        "dflags=$(dflags)" \
2319                        "cflags4perl=$(cflags) $(cxxflags) $(dflags)" \
2320                        "lflags4perl=$(lflags4perl)" \
2321                        "COMPILER_VERSION=$(COMPILER_VERSION)" \
2322                        all && \
2323                $(MAKE) -C PERL_SCRIPTS/test test && \
2324                echo "$(SEP) Make PERL2ARB [done]" ; \
2325        ) > PERL2ARB.log 2>&1 && (cat PERL2ARB.log;rm PERL2ARB.log)) || (cat PERL2ARB.log;rm PERL2ARB.log;false)
2326
2327perl_clean:
2328        @$(MAKE) -C PERL2ARB -r -f Makefile.main \
2329                "AUTODEPENDS=0" \
2330                clean
2331
2332PERL2ARB/PERL2ARB.clean:
2333        $(MAKE) perl_clean
2334        $(MAKE) -C PERL_SCRIPTS/test clean
2335
2336# ---------------------------------------- bindings to script languages
2337
2338bindings: lib/libCORE.so lib/libARBDB.so
2339        $(MAKE) -C BINDINGS all ARBDEPENDS="$(^:%=../%)" DFLAGS="$(dflags)"
2340
2341bindings_clean:
2342        $(MAKE) -C BINDINGS clean
2343
2344# ---------------------------------------- check resources
2345
2346check_res:
2347        $(ARBHOME)/SOURCE_TOOLS/check_resources.pl
2348
2349# ---------------------------------------- cleaning
2350
2351rmbak:
2352        @echo "[cleanup backup/core files]"
2353        @find . \(      -name '*%' \
2354                        -o -name '*.bak' \
2355                        -o -name '*~' \) \
2356                        -o \( -name 'core' -a \! -type d \) \
2357                -exec rm -v {} \; || \
2358        echo "Warning: target 'rmbak' reported problems when removing misc. backup files (ignored)"
2359        @echo "[cleanup done]"
2360
2361bin_reinit:
2362        $(MAKE) bin/bin.clean
2363        $(MAKE) -C "bin" all
2364
2365clean_directories:
2366        -rm -rf \
2367                $(ARBHOME)/PROBE_SET/bin \
2368                $(ARBHOME)/INCLUDE \
2369
2370libclean:
2371        -find $(ARBHOME) -type f \( -name '*.a' ! -type l \) -exec rm -f {} \;
2372        -find $(ARBHOME) -type f \( -name 'lib*.so' ! -type l \) -exec rm -f {} \;
2373
2374objclean:
2375        -find $(ARBHOME) -type f \( -name '*.o' ! -type l \) -exec rm -f {} \;
2376
2377# bin.clean and HELP_SOURCE.clean interfere
2378clean3:
2379        $(MAKE) bin/bin.clean
2380        $(MAKE) HELP_SOURCE/HELP_SOURCE.clean
2381
2382
2383# delete all binaries (similar to 'cleanlinked')
2384cleanRelinkable: libclean UNIT_TESTER/UNIT_TESTER.clean
2385        $(MAKE) -C bin cleanbinariesRelinkable
2386        $(MAKE) -C PROBE_SET cleanLinked
2387
2388
2389clean2: $(SUBDIRS:.sub=.clean) \
2390                clean3 \
2391                rmbak \
2392                libclean \
2393                objclean \
2394                lib/lib.clean \
2395                GDEHELP/GDEHELP.clean \
2396                HEADERLIBS/HEADERLIBS.clean \
2397                SOURCE_TOOLS/SOURCE_TOOLS.clean \
2398                SOURCE_TOOLS/COMPILE_COMPAT/COMPILE_COMPAT.clean \
2399                UNIT_TESTER/UNIT_TESTER.clean \
2400                TEMPLATES/TEMPLATES.clean \
2401                perl_clean \
2402                clean_directories \
2403
2404        rm -f *.last_gcc *.last_compiler config.makefile.bak
2405
2406# links are needed for cleanup
2407clean: redo_links motif_xpm_hack_clean
2408        $(MAKE) clean2
2409        $(MAKE) clean_cov_all clean_links
2410
2411silent_clean:
2412        $(MAKE) clean >/dev/null
2413
2414# 'relocated' is about 50% faster than 'rebuild'
2415reloc_clean: links
2416        @echo "---------------------------------------- Relocation cleanup"
2417        $(MAKE) \
2418                perl_clean \
2419                GDEHELP/GDEHELP.clean \
2420                HELP_SOURCE/genhelp/genhelp.clean \
2421                bin/bin.clean \
2422                libclean \
2423                objclean
2424
2425relocated: links
2426        $(MAKE) reloc_clean
2427        @echo "---------------------------------------- and remake"
2428        $(MAKE) build
2429
2430# -----------------------------------
2431# some stress tests
2432# (helpful to reveal race conditions with -j)
2433
2434rebuild4ever: rebuild
2435        $(MAKE) rebuild4ever
2436
2437build4ever: build
2438        $(MAKE) build4ever
2439
2440clean4ever: clean
2441        $(MAKE) clean4ever
2442
2443test4ever: ut
2444        $(MAKE) test4ever
2445
2446perl4ever: clean
2447        $(MAKE) links
2448        $(MAKE) perl
2449        $(MAKE) perl4ever
2450
2451help4ever: clean
2452        $(MAKE) help
2453        $(MAKE) help4ever
2454
2455# -----------------------------------
2456
2457cleanlinked: bin/bin.clean libclean
2458
2459relink: cleanlinked
2460        $(MAKE) all
2461
2462# --------------------------------------------------------------------------------
2463# source related targets
2464
2465CLOC=cloc
2466CLOCFLAGS=--no3 --quiet --progress-rate=0
2467CLOCARB=--exclude-dir=GDE .
2468CLOCEXT=GDE
2469CLOCCODE=--force-lang-def=$(ARBHOME)/SOURCE_TOOLS/arb.cloc.code.def
2470CLOCREST=--force-lang-def=$(ARBHOME)/SOURCE_TOOLS/arb.cloc.rest.def
2471CLOCFILT=tail --lines=+4
2472
2473cloc:
2474        @echo 'Arb code:'
2475        @$(CLOC) $(CLOCFLAGS) $(CLOCCODE) $(CLOCARB) | $(CLOCFILT)
2476        @echo 'Arb rest:'
2477        @$(CLOC) $(CLOCFLAGS) $(CLOCREST) $(CLOCARB) | $(CLOCFILT)
2478        @echo 'External code:'
2479        @$(CLOC) $(CLOCFLAGS) $(CLOCCODE) $(CLOCEXT) | $(CLOCFILT)
2480        @echo 'External rest:'
2481        @$(CLOC) $(CLOCFLAGS) $(CLOCREST) $(CLOCEXT) | $(CLOCFILT)
2482
2483
2484# patch generation
2485patch:
2486        SOURCE_TOOLS/arb_create_patch.sh arbPatch --svn
2487
2488# source tarball generation
2489save: sourcetarfile
2490
2491sourcetarfile: rmbak
2492        util/arb_save
2493
2494# test early whether save will work
2495savetest:
2496        @util/arb_srclst.pl >/dev/null
2497
2498testsave: savetest
2499
2500save2: rmbak
2501        util/arb_save ignore
2502
2503save_test: rmbak
2504        @echo "Testing source list.."
2505        @util/arb_srclst.pl > /dev/null
2506
2507save_test_no_error:
2508        @-$(MAKE) save_test
2509
2510# --------------------------------------------------------------------------------
2511# version management
2512
2513inc_candi:
2514        touch SOURCE_TOOLS/inc_candi.stamp
2515        $(MAKE) do_version_update
2516
2517inc_patch:
2518        touch SOURCE_TOOLS/inc_patch.stamp
2519        $(MAKE) do_version_update
2520
2521inc_minor:
2522        touch SOURCE_TOOLS/inc_minor.stamp
2523        $(MAKE) do_version_update
2524
2525inc_major:
2526        touch SOURCE_TOOLS/inc_major.stamp
2527        $(MAKE) do_version_update
2528
2529do_version_update:
2530        @echo Incrementing version information
2531        $(MAKE) savetest
2532        $(MAKE) genheaders # auto upgrades version early
2533
2534show_version:
2535        $(MAKE) genheaders # updates version info
2536        @echo "$(SEP) ARB version info"
2537        @grep ARB_VERSION TEMPLATES/arb_build.h
2538        @echo "$(SEP)"
2539
2540# --------------------------------------------------------------------------------
2541# special cleanups
2542
2543clean_opengl_changed: RNA3D/RNA3D.clean EDIT4/EDIT4.clean WINDOW/WINDOW.clean GL/GL.clean
2544
2545# --------------------------------------------------------------------------------
2546
2547arbapplications: nt pa e4 wetc pt na nal di ph ds wetc cma
2548
2549arb_external: convert tools gde readseq tg pst
2550
2551arb_no_perl: arbapplications help arb_external
2552
2553arb: motif_xpm_hack
2554        $(MAKE) "WITHPERL=1" perl arb_no_perl
2555
2556motif_xpm_hack:
2557        $(MAKE) -r -C "lib/motifHack" all
2558
2559motif_xpm_hack_clean:
2560        $(MAKE) -r -C "lib/motifHack" clean
2561
2562# --------------------------------------------------------------------------------
2563# special targets for SOURCE_TOOLS/remake_after_change.pl
2564
2565rac_arb_dist:           di
2566rac_arb_edit4:          e4
2567rac_arb_ntree:          nt
2568rac_arb_pars:           pa
2569rac_arb_phylo:          ph
2570rac_arb_wetc:           wetc
2571rac_arb_naligner:       nal
2572rac_arb_pt_server:      pt
2573rac_arb_db_server:      ds
2574rac_arb_name_server:    na
2575rac_arb_convert_aln:    convert
2576rac_arb_treegen:        tg
2577rac_arb_rnacma:         cma
2578rac_arb_help2xml:       help
2579
2580rac_arb_a2ps:           tools
2581rac_arb_consensus_tree: tools
2582rac_arb_dnarates:       tools
2583rac_arb_export_rates:   tools
2584rac_arb_export_tree:    tools
2585rac_arb_gene_probe:     tools
2586rac_arb_message:        tools
2587rac_arb_primer:         tools
2588rac_arb_probe:          tools
2589rac_arb_read_tree:      tools
2590
2591# --------------------------------------------------------------------------------
2592# unit testing
2593# @@@ work in progress
2594#
2595# goal is to automatically test all libraries/executables using TESTED_UNITS_AUTO
2596# currently not all test executables link w/o error.
2597# therefor units are organized in three sets:
2598#
2599#   TESTED_UNITS     = testable and contain tests
2600#   UNTESTED_UNITS   = testable, but no tests written yet
2601#   UNTESTABLE_UNITS = not testable
2602
2603# always define OPENGL units manually:
2604OPENGL_TESTS :=
2605ifeq ($(OPENGL),1)
2606OPENGL_TESTS += \
2607        $(subst .a,.test,$(RNA3D_LIB)) \
2608        GL/glAW/libglAW.test \
2609        GL/glpng/libglpng_arb.test \
2610
2611endif
2612
2613UNITS_NOT_AUTODETECTED = \
2614        HELP_SOURCE/HELP_SOURCE.tooltests
2615
2616TESTED_UNITS_AUTO = \
2617        $(OPENGL_TESTS) \
2618        $(TL_ARCHIVES:.a=.test) \
2619        $(TL_SHARED_ARCHIVES:.so=.test) \
2620        $(CL_ARCHIVES:.a=.test) \
2621        $(TL_TOOLS_COLLECTIONS:.toolColl=.tooltests) \
2622        $(UNITS_NOT_AUTODETECTED) \
2623
2624UNTESTED_UNITS = \
2625        $(OPENGL_TESTS) \
2626        EISPACK/EISPACK.test \
2627        GENOM/GENOM.test \
2628        ISLAND_HOPPING/ISLAND_HOPPING.test \
2629        NALIGNER/NALIGNER.test \
2630        NAMES/NAMES.test \
2631        PHYLO/PHYLO.test \
2632        PRIMER_DESIGN/PRIMER_DESIGN.test \
2633        READSEQ/READSEQ.tooltests \
2634        SECEDIT/SECEDIT.test \
2635        SEQ_QUALITY/SEQ_QUALITY.test \
2636        SERVERCNTRL/SERVERCNTRL.test \
2637        SL/ALIVIEW/ALIVIEW.test \
2638        SL/AP_TREE/AP_TREE.test \
2639        SL/ARB_TREE/ARB_TREE.test \
2640        SL/AW_HELIX/AW_HELIX.test \
2641        SL/AW_NAME/AW_NAME.test \
2642        SL/DB_SCANNER/DB_SCANNER.test \
2643        SL/DB_UI/DB_UI.test \
2644        SL/GUI_ALIVIEW/GUI_ALIVIEW.test \
2645        SL/HELIX/HELIX.test \
2646        SL/QUERY/QUERY.test \
2647        SL/REFENTRIES/REFENTRIES.test \
2648        SL/SEQUENCE/SEQUENCE.test \
2649        SL/TREE_ADMIN/TREE_ADMIN.test \
2650        SL/TREE_WRITE/TREE_WRITE.test \
2651        SL/XFERGUI/XFERGUI.test \
2652        STAT/STAT.test \
2653        TREEGEN/TREEGEN.test \
2654        WETC/WETC.test \
2655        XML/XML.test \
2656
2657# untestable units
2658
2659UNTESTABLE_UNITS = \
2660        AISC/AISC.test \
2661        NAMES_COM/server.test \
2662        PROBE_COM/server.test \
2663
2664# --------------------
2665# put all units containing tests into the following 4 sections (see also TESTED_UNITS below)
2666
2667# recent development
2668UNITS_TESTED_FIRST = \
2669        SL/MATRIX/MATRIX.test \
2670        AWTI/AWTI.test \
2671        SL/FILTSEQEXP/FILTSEQEXP.test \
2672        SL/GROUP_SEARCH/GROUP_SEARCH.test \
2673        SL/PVP/PVP.test \
2674        SL/SAICALC/SAICALC.test \
2675        SL/TRANSLATE/TRANSLATE.test \
2676        SL/XFERSET/XFERSET.test \
2677
2678# start units with long duration early
2679UNITS_RUNNING_LONG = \
2680        ARBDB/libARBDB.test \
2681        AWTC/AWTC.test \
2682        TOOLS/TOOLS.tooltests \
2683
2684# plain test-libaries that are not linked anywhere
2685TEST_SANDBOXES = \
2686        SL/CB/CB.test \
2687        SL/HEADERTESTS/HEADERTESTS.test \
2688
2689UNITS_TESTED = \
2690        AISC_MKPTPS/AISC_MKPTPS.tooltests \
2691        ARB_GDE/ARB_GDE.test \
2692        AWT/libAWT.test \
2693        CONSENSUS_TREE/CONSENSUS_TREE.test \
2694        CONVERTALN/CONVERTALN.test \
2695        CORE/libCORE.test \
2696        DBSERVER/DBSERVER.test \
2697        DIST/DIST.test \
2698        EDIT4/EDIT4.test \
2699        GENOM_IMPORT/GENOM_IMPORT.test \
2700        HELP_SOURCE/HELP_SOURCE.tooltests \
2701        MERGE/MERGE.test \
2702        MULTI_PROBE/MULTI_PROBE.test \
2703        NTREE/NTREE.test \
2704        PARSIMONY/PARSIMONY.test \
2705        PERLTOOLS/PERLTOOLS.tooltests \
2706        PROBE/PROBE.test \
2707        PROBE_DESIGN/PROBE_DESIGN.test \
2708        PROBE_SET/PROBE_SET.tooltests \
2709        RNACMA/RNACMA.test \
2710        SL/ALILINK/ALILINK.test \
2711        SL/CONSENSUS/CONSENSUS.test \
2712        SL/DB_QUERY/DB_QUERY.test \
2713        SL/FAST_ALIGNER/FAST_ALIGNER.test \
2714        SL/FILTER/FILTER.test \
2715        SL/INSDEL/INSDEL.test \
2716        SL/ITEM_SHADER/ITEM_SHADER.test \
2717        SL/ITEMS/ITEMS.test \
2718        SL/LOCATION/LOCATION.test \
2719        SL/MACROS/MACROS.test \
2720        SL/NDS/NDS.test \
2721        SL/NEIGHBOURJOIN/NEIGHBOURJOIN.test \
2722        SL/PRONUC/PRONUC.test \
2723        SL/PTCLEAN/PTCLEAN.test \
2724        SL/REGEXPR/REGEXPR.test \
2725        SL/SEQIO/SEQIO.test \
2726        SL/TREE_READ/TREE_READ.test \
2727        SL/TREEDISP/TREEDISP.test \
2728        WINDOW/libWINDOW.test \
2729
2730TESTED_UNITS = \
2731        $(UNITS_TESTED_FIRST) \
2732        $(UNITS_RUNNING_LONG) \
2733        $(TEST_SANDBOXES) \
2734        $(UNITS_TESTED) \
2735
2736# ----------------------------------------
2737
2738ifeq ($(DEVELOPER),RALF)
2739
2740DEFINED_TEST_UNITS = \
2741        $(TESTED_UNITS) \
2742        $(UNTESTED_UNITS) \
2743        $(UNTESTABLE_UNITS) \
2744
2745list_undefined_units:
2746        @UNIT_TESTER/list_undefined_units.pl $(DEFINED_TEST_UNITS) -- $(TESTED_UNITS_AUTO)
2747
2748else
2749
2750list_undefined_units:
2751
2752endif
2753
2754# ----------------------------------------
2755
2756TEST_LOG_DIR = UNIT_TESTER/logs
2757TEST_RUN_SUITE=$(MAKE) $(NODIR) -C UNIT_TESTER -f Makefile.suite -r
2758# -> UNIT_TESTER/Makefile.suite
2759TEST_MAKE_FLAGS=
2760TEST_POST_CLEAN=
2761ifeq ($(COVERAGE),1)
2762TEST_POST_CLEAN=$(MAKE) clean_cov
2763TEST_MAKE_FLAGS+=-j1
2764endif
2765
2766
2767%.test:
2768        -@( export ID=$$$$; mkdir -p $(TEST_LOG_DIR); \
2769        ( \
2770            echo "take[1]: Entering directory \`$(ARBHOME)/UNIT_TESTER'"; \
2771            $(MAKE) -C UNIT_TESTER -f Makefile.test -r \
2772                "UNITDIR=$(@D)" \
2773                "UNITLIBNAME=$(@F:.test=)" \
2774                "COVERAGE=$(COVERAGE)" \
2775                "ARB_PID=$(ARB_PID)_$(@F)" \
2776                runtest; \
2777            echo "take[1]: Leaving directory \`$(ARBHOME)/UNIT_TESTER'"; \
2778            $(TEST_POST_CLEAN) \
2779        ) >$(TEST_LOG_DIR)/$(@F).log 2>&1; \
2780        UNIT_TESTER/log_result.pl $(TEST_LOG_DIR)/$(@F).log )
2781
2782%.notest:
2783        -@( export ID=$$$$; mkdir -p $(TEST_LOG_DIR); \
2784        ( \
2785            echo "take[4]: Entering directory \`$(ARBHOME)/UNIT_TESTER'"; \
2786            $(MAKE) -C UNIT_TESTER -f Makefile.test -r \
2787                "UNITDIR=$(@D)" \
2788                "UNITLIBNAME=$(@F:.notest=)" \
2789                "COVERAGE=0" \
2790                "ARB_PID=$(ARB_PID)_$(@F)" \
2791                check_no_test; \
2792            echo "take[4]: Leaving directory \`$(ARBHOME)/UNIT_TESTER'" \
2793        ) >$(TEST_LOG_DIR)/$(@F).log 2>&1 )
2794
2795
2796# tool test aliases (used to test one or multiple executable(s) in a single subdir):
2797%.tooltests:
2798        $(error please define an explicit tooltest alias for $@)
2799
2800AISC_MKPTPS/AISC_MKPTPS.tooltests : AISC_MKPTPS/mkptypes.test
2801        @echo "aliasing $@ -> $^"
2802PERLTOOLS/PERLTOOLS.tooltests : PERLTOOLS/arb_proto_2_xsub.test
2803        @echo "aliasing $@ -> $^"
2804PROBE_SET/PROBE_SET.tooltests : PROBE_SET/fb_test.test
2805        @echo "aliasing $@ -> $^"
2806HELP_SOURCE/HELP_SOURCE.tooltests : HELP_SOURCE/arb_help2xml.test
2807        @echo "aliasing $@ -> $^"
2808TOOLS/TOOLS.tooltests : TOOLS/arb_consensus_tree.test TOOLS/arb_probe.test TOOLS/arb_test.test
2809        @echo "aliasing $@ -> $^"
2810
2811# aliases for tools w/o tests:
2812READSEQ/READSEQ.tooltests:
2813        @echo "Note: no tests for $@"
2814
2815
2816test_base: $(UNIT_TESTER_LIB:.a=.dummy) $(subst .test,.dummy,$(TEST_SANDBOXES))
2817
2818clean_cov:
2819        find . \( -name "*.gcda" -o -name "*.gcov" -o -name "*.cov" \) -exec rm {} \;
2820
2821clean_cov_all: clean_cov
2822        find . \( -name "*.gcno" \) -exec rm {} \;
2823
2824cleanup_faked_arbpids:
2825        @rm ~/.arb_tmp/tmp/arb_pids_${USER}_${ARB_PID}_* || true
2826
2827cleanup_faked_arbpids_and_fail: cleanup_faked_arbpids
2828        @false
2829
2830NOTESTS_IN_UNTESTED = $(subst .test,.notest,$(UNTESTED_UNITS))
2831
2832run_tests_faked_arbpid:
2833        +@$(TEST_RUN_SUITE) init
2834        @echo "take[2]: Entering directory \`$(ARBHOME)/UNIT_TESTER'"
2835        @$(MAKE) $(TEST_MAKE_FLAGS) $(NODIR) $(TESTED_UNITS) $(NOTESTS_IN_UNTESTED) || $(MAKE) cleanup_faked_arbpids_and_fail
2836        @echo "take[2]: Leaving directory \`$(ARBHOME)/UNIT_TESTER'"
2837        +@$(TEST_RUN_SUITE) cleanup || $(MAKE) cleanup_faked_arbpids_and_fail
2838        @$(MAKE) clean_cov >/dev/null
2839        @$(MAKE) cleanup_faked_arbpids
2840
2841 # @@@ instead of only running UNIT, this should as well run all tests this unit depends on? according to 'needs_libs'
2842 # @@@ 'run_tests_faked_arbpid' does not work for UNIT=ARBDB/libARBDB or UNIT=PARS/PARS -> could be solved via extra suffix, e.g. ARBDB/libARBDB.unit
2843
2844run_onetest_faked_arbpid:
2845        +@$(TEST_RUN_SUITE) init
2846        @echo "take[3]: Entering directory \`$(ARBHOME)/UNIT_TESTER'"
2847        test -n "$(UNIT)" || (echo "Error: UNIT has to be defined for target 'run_onetest_faked_arbpid'!"; false)
2848        $(MAKE) $(TEST_MAKE_FLAGS) $(NODIR) $(UNIT).test || $(MAKE) cleanup_faked_arbpids_and_fail
2849        @echo "take[3]: Leaving directory \`$(ARBHOME)/UNIT_TESTER'"
2850        +@$(TEST_RUN_SUITE) cleanup || $(MAKE) cleanup_faked_arbpids_and_fail
2851        @$(MAKE) clean_cov >/dev/null
2852        @$(MAKE) cleanup_faked_arbpids
2853
2854run_tests: test_base clean_cov
2855        $(MAKE) "ARB_PID=UT_$$$$" run_tests_faked_arbpid list_undefined_units
2856
2857run_oneunitstests: test_base
2858        $(MAKE) "ARB_PID=UT_$$$$" run_onetest_faked_arbpid
2859
2860
2861ut:
2862ifeq ($(UNIT_TESTS),1)
2863        @echo $(MAKE) run_tests
2864        @$(MAKE) run_tests
2865else
2866        @echo "Not compiled with unit tests"
2867endif
2868
2869
2870aut:
2871        +@$(TEST_RUN_SUITE) unskip
2872        $(MAKE) ut
2873
2874# --------------------------------------------------------------------------------
2875
2876TIMELOG=$(ARBHOME)/arb_time.log
2877TIMEARGS=--append --output=$(TIMELOG) --format=" * %E(%S+%U) %P [%C]"
2878TIMECMD=$(TIME) $(TIMEARGS)
2879
2880time_one:
2881ifeq ($(ONE_TIMED_TARGET),)
2882        @echo "Error: You have to pass ONE_TIMED_TARGET to $@"
2883        false
2884else
2885        @echo "$(SEP) $(MAKE) $(ONE_TIMED_TARGET)"
2886        @$(TIMECMD) $(MAKE) $(ONE_TIMED_TARGET)
2887        @echo "$(SEP) $(MAKE) $(ONE_TIMED_TARGET) [done]"
2888endif
2889
2890timed_target:
2891ifeq ($(TIMED_TARGET),)
2892        @echo "Error: You have to pass TIMED_TARGET to $@"
2893        false
2894else
2895        @echo "Build time:" > $(TIMELOG)
2896        $(MAKE) "ONE_TIMED_TARGET=$(TIMED_TARGET)" time_one
2897        @cat $(TIMELOG)
2898        @rm $(TIMELOG)
2899endif
2900
2901timed_target_tested:
2902ifeq ($(TIMED_TARGET),)
2903        @echo "Error: You have to pass TIMED_TARGET to $@"
2904        false
2905else
2906        @echo "Build time:" > $(TIMELOG)
2907        $(MAKE) "ONE_TIMED_TARGET=$(TIMED_TARGET)" time_one
2908        $(MAKE) "ONE_TIMED_TARGET=ut" time_one
2909        @cat $(TIMELOG)
2910        @rm $(TIMELOG)
2911endif
2912
2913clean_timed_target:
2914ifeq ($(TIMED_TARGET),)
2915        @echo "Error: You have to pass TIMED_TARGET to $@"
2916        false
2917else
2918        @echo "Build time:" > $(TIMELOG)
2919        $(MAKE) "ONE_TIMED_TARGET=clean" time_one
2920        $(MAKE) "ONE_TIMED_TARGET=$(TIMED_TARGET)" time_one
2921        @cat $(TIMELOG)
2922        @rm $(TIMELOG)
2923endif
2924
2925# --------------------------------------------------------------------------------
2926
2927CHECKOUT_MODIFIED=0# set to 1 to temporarily skip test for modifications (do not check in if set to 1)
2928
2929check_svn_does_not_contain_generated:
2930ifeq ($(CHECKOUT_MODIFIED),0)
2931        @echo "Testing that build does not modify files in SVN"
2932        @test 0 = `svn status | wc -l` || ( \
2933                echo "The checkout is not/no longer clean:"; \
2934                svn status; \
2935                echo "- if this fails instantly, your checkout is not clean"; \
2936                echo "- if this fails after other targets, these targets modify checked in data"; \
2937                echo "  (a common cause may be that depends are not up to date)"; \
2938                false)
2939else
2940        grep -Hn 'CHECKOUT_MODIFIED' Makefile
2941endif
2942
2943check_svn_ignores_generated:
2944        @test 0 = `svn status | grep '^\?' | wc -l` || ( \
2945                echo "There are svn-unignored files:"; \
2946                svn status | grep '^\?'; \
2947                echo "(all generated files should be svn-ignored)"; \
2948                false)
2949
2950check_svn_state: check_svn_does_not_contain_generated
2951        $(MAKE) check_svn_ignores_generated
2952        $(MAKE) savetest
2953
2954things_that_always_should_work: depends proto
2955
2956post_commit_check:
2957        @echo "---------------------------------------- [Initial]"
2958        $(MAKE) check_svn_state
2959
2960        $(MAKE) clean
2961        @echo "---------------------------------------- [After 'make clean']"
2962        $(MAKE) check_svn_state
2963
2964        $(MAKE) things_that_always_should_work
2965        @echo "---------------------------------------- [After 'make things_that_always_should_work']"
2966        $(MAKE) check_svn_state
2967
2968        $(MAKE) all
2969        @echo "---------------------------------------- [After 'make all']"
2970        $(MAKE) check_svn_state
2971
2972        $(MAKE) things_that_always_should_work
2973        @echo "---------------------------------------- [Final]"
2974        $(MAKE) check_svn_state
2975
2976# --------------------------------------------------------------------------------
2977# sanitize arb_ntree; also works for clients (arb_edit4, ...) started from there.
2978
2979sanitize: all
2980        ( \
2981                export "LSAN_OPTIONS=max_leaks=30:suppressions=$(ARBHOME)/SOURCE_TOOLS/arb.leaksan.supp"; \
2982                echo "sake[1]: Entering directory \`$(ARBHOME)'"; \
2983                $(ARBHOME)/bin/arb_ntree --execute _logged ~/data/test.arb 2>&1 ; \
2984                echo "sake[1]: Leaving directory \`$(ARBHOME)'" \
2985        ) | $(ARBHOME)/SOURCE_TOOLS/asan2msg.pl
2986
2987# --------------------------------------------------------------------------------
2988# build and test one unit:
2989
2990build_oneunit:
2991        $(MAKE) "WITHPERL=1" $(UNIT).dummy
2992
2993oneunit:
2994ifndef UNIT
2995        @echo "Please define UNIT, e.g. using"
2996        @echo "      make \"UNIT=ARBDB/libARBDB\"       oneunit"
2997        @echo "      make \"UNIT=SL/TREEDISP/TREEDISP\" oneunit"
2998        @echo "(Note: 1st is a shared library, 2nd isn't)"
2999        false
3000else
3001        @echo "Build time" > $(TIMELOG)
3002        @echo "$(SEP) $(MAKE) build_oneunit"
3003        @$(TIMECMD) $(MAKE) build_oneunit
3004 ifeq ($(UNIT_TESTS),1)
3005        @echo "$(SEP) $(MAKE) run_oneunitstests"
3006        @$(TIMECMD) $(MAKE) run_oneunitstests
3007 endif
3008        @cat $(TIMELOG)
3009        @rm $(TIMELOG)
3010endif
3011
3012# --------------------------------------------------------------------------------
3013# Main targets:
3014
3015tarfile: rebuild
3016        $(MAKE) prepare_libdir
3017        util/arb_compress
3018
3019tarfile_quick: all
3020        $(MAKE) prepare_libdir
3021        util/arb_compress
3022
3023# -----------------------------------
3024
3025build: arb
3026        $(MAKE) check_bin_dep preplib compile_compatibility fig_cure
3027
3028all:
3029        @echo "Build time" > $(TIMELOG)
3030#       $(MAKE) clean_checked_vect # uncomment to rebuild sources where expected vectorization gets tested
3031        @echo "$(SEP) $(MAKE) all"
3032        @$(TIMECMD) $(MAKE) build
3033        @echo $(SEP)
3034        @echo "made 'all' with success."
3035        @echo "to start arb enter 'arb'"
3036ifeq ($(UNIT_TESTS),1)
3037        @echo "$(SEP) $(MAKE) run_tests"
3038        @$(TIMECMD) $(MAKE) run_tests
3039endif
3040        @echo "$(SEP) $(MAKE) all [done]"
3041ifeq ($(DEBUG),1)
3042        @$(MAKE) save_test_no_error >/dev/null # just show hints
3043endif
3044        @cat $(TIMELOG)
3045        @rm $(TIMELOG)
3046
3047rebuild: clean
3048        $(MAKE) all
3049
3050# --------------------------------------------------------------------------------
3051# special targets showing obvious error at bottom
3052# (intended to be used from automated builds)
3053
3054BUILD_LOG=build.log
3055SHELL=bash
3056REDIRECT_KEEP_EXITCODE = tee $(BUILD_LOG) ; exit "$${PIPESTATUS[0]}"
3057EXTRACT_ERROR_SUMMARY  = (./SOURCE_TOOLS/short_error_summary.pl $(BUILD_LOG); false)
3058
3059ALL:
3060        @(($(MAKE) all 2>&1) | $(REDIRECT_KEEP_EXITCODE)) || $(EXTRACT_ERROR_SUMMARY)
3061
3062REBUILD:
3063        @(($(MAKE) rebuild 2>&1) | $(REDIRECT_KEEP_EXITCODE)) || $(EXTRACT_ERROR_SUMMARY)
3064
3065TARFILE:
3066        @(($(MAKE) tarfile 2>&1) | $(REDIRECT_KEEP_EXITCODE)) || $(EXTRACT_ERROR_SUMMARY)
3067
3068TARFILE_QUICK:
3069        @(($(MAKE) tarfile_quick 2>&1) | $(REDIRECT_KEEP_EXITCODE)) || $(EXTRACT_ERROR_SUMMARY)
3070
Note: See TracBrowser for help on using the repository browser.