source: branches/help/Makefile

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