source: branches/help/Makefile

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