-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
2601 lines (2148 loc) · 73.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# =============================================================== #
# #
# File : Makefile #
# #
# Institute of Microbiology (Technical University Munich) #
# http://www.arb-home.de/ #
# #
# =============================================================== #
# -----------------------------------------------------
# The ARB Makefile is aware of the following defines:
#
# CC C compiler (should be defined by OS)
# CXX C++ compiler (should be defined by OS)
#
# BUILDHOST_64=0/1 1=>compile on 64 bit platform (defaults to ARB_64)
# DEVELOPER=name special compilation (values: ANY,RELEASE,your name)
# OPENGL=0/1 whether OPENGL is available
#
# -----------------------------------------------------
# Paths for several libraries may be set from config.makefile by using:
#
# export XLIBS=$(shell pkg-config --libs xpm xerces-c)
# export XAW_LIBS=$(shell pkg-config --libs xaw7)
# export XML_INCLUDES=$(shell pkg-config --cflags xerces-c)
#
# -----------------------------------------------------
# ARB Makefile and ARB source code are aware of the following defines:
#
# $(MACH) name of the machine (LINUX or DARWIN; see config.makefile)
# DEBUG compiles the DEBUG sections
# DEBUG_GRAPHICS all X-graphics are flushed immediately (for debugging)
# ARB_64=0/1 1=>compile 64 bit version
# UNIT_TESTS=0/1 1=>compile in unit tests and call them after build
# COVERAGE=0/1/2 compile in gcov support (useful together with UNIT_TESTS=1)
# 0=no, 1+2=compile in, 1=show
# STABS=0/1 force stabs format? (0 = "use default format")
# SANITIZE=0/#/all use Sanitizer? (defaults to 0,
# 1=AddressSanitizer+LeakSanitizer,
# 2=UndefinedBehaviorSanitizer,
# combine bit-values to activate multiple Sanitizers,
# specify 'all' to activate all)
# SHOWTODO=0/1 activate TODO-warnings? (defaults to 0, except for ralf)
#
# -----------------------------------------------------
# The ARB source code is aware of the following defines:
#
# NDEBUG doesn't compile the DEBUG sections
# DEVEL_$(DEVELOPER) developer-dependent flag (enables you to have private sections in code)
# DEVELOPER='ANY' (default setting) will be ignored
# configurable in config.makefile
#
# -----------------------------------------------------
# Read configuration
include config.makefile
# set defaults for variables commented out in config.makefile:
ifndef DARWIN
DARWIN:=0
endif
ifndef LINUX
LINUX:=0
endif
ifndef DEBIAN
DEBIAN:=0
endif
ifndef REDHAT
REDHAT:=0
endif
ifndef ARB_64
ARB_64=1#default to 64bit
endif
# compiler settings:
ifneq ($(CC),use__A_CC__instead_of__CC)
A_CC:=$(CC)# compile C
A_CXX:=$(CXX)# compile C++
# uncomment to ensure no submakefile uses CC and CXX directly
override CC:=use__A_CC__instead_of__CC
override CXX:=use__A_CXX__instead_of__CXX
endif
export CC CXX A_CC A_CXX
# unconditionally prepend $(ARBHOME)/lib to LD_LIBRARY_PATH if not found
ifeq ($(findstring $(ARBHOME)/lib,$(LD_LIBRARY_PATH)),)
LD_LIBRARY_PATH:=${ARBHOME}/lib:$(LD_LIBRARY_PATH)
endif
# store LD_LIBRARY_PATH to circumvent SIP restrictions:
ARBBUILD_LIBRARY_PATH:=$(LD_LIBRARY_PATH)
FORCEMASK = umask 002
NODIR=--no-print-directory
SED:=$(ARBHOME)/SH/arb_sed
READLINK:=$(ARBHOME)/SH/arb_readlink
# ---------------------- compiler version detection
# supported gcc versions:
ALLOWED_gcc_VERSIONS=\
4.3.1 4.3.2 4.3.3 4.3.4 \
4.4.1 4.4.3 4.4.5 4.4.6 4.4.7 \
4.5.2 \
4.6.1 4.6.2 4.6.3 4.6.4 \
4.7.1 4.7.2 4.7.3 4.7.4 \
4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 \
4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 \
5.1.0 5.2.0 5.3.0 5.3.1 5.4.0 \
6.1.0 6.2.0 \
# ----------------------
COMPILER_INFO:=$(shell SOURCE_TOOLS/arb_compiler_version.pl $(A_CXX))
COMPILER_NAME:=$(word 1,$(COMPILER_INFO))
COMPILER_VERSION:=$(word 2,$(COMPILER_INFO))
USE_CLANG:=0
ifneq ($(COMPILER_NAME),gcc)
ifeq ($(COMPILER_NAME),clang)
USE_CLANG:=1
else
$(error failed to detect COMPILER_NAME (got '$(COMPILER_NAME)', expected 'clang' or 'gcc'))
endif
endif
ifeq ($(USE_CLANG),1)
# accept all clang versions:
ALLOWED_COMPILER_VERSIONS=$(COMPILER_VERSION)
else
ALLOWED_COMPILER_VERSIONS=$(ALLOWED_gcc_VERSIONS)
endif
COMPILER_VERSION_ALLOWED=$(strip $(subst ___,,$(foreach version,$(ALLOWED_COMPILER_VERSIONS),$(findstring ___$(version)___,___$(COMPILER_VERSION)___))))
#---------------------- split gcc version
SPLITTED_VERSION:=$(subst ., ,$(COMPILER_VERSION))
USE_GCC_MAJOR:=$(word 1,$(SPLITTED_VERSION))
USE_GCC_MINOR:=$(word 2,$(SPLITTED_VERSION))
USE_GCC_PATCHLEVEL:=$(word 3,$(SPLITTED_VERSION))
USE_GCC_452_OR_HIGHER:=
USE_GCC_46_OR_HIGHER:=
USE_GCC_47_OR_HIGHER:=
USE_GCC_48_OR_HIGHER:=
USE_GCC_49_OR_HIGHER:=
USE_GCC_50_OR_HIGHER:=
ifeq ($(USE_CLANG),0)
ifeq ($(USE_GCC_MAJOR),4)
ifeq ($(USE_GCC_MINOR),5)
ifneq ('$(findstring $(USE_GCC_PATCHLEVEL),23456789)','')
USE_GCC_452_OR_HIGHER:=yes
endif
else
ifneq ('$(findstring $(USE_GCC_MINOR),6789)','')
USE_GCC_452_OR_HIGHER:=yes
USE_GCC_46_OR_HIGHER:=yes
ifneq ($(USE_GCC_MINOR),6)
USE_GCC_47_OR_HIGHER:=yes
ifneq ($(USE_GCC_MINOR),7)
USE_GCC_48_OR_HIGHER:=yes
ifneq ($(USE_GCC_MINOR),8)
USE_GCC_49_OR_HIGHER:=yes
endif
endif
endif
endif
endif
else
USE_GCC_452_OR_HIGHER:=yes
USE_GCC_46_OR_HIGHER:=yes
USE_GCC_47_OR_HIGHER:=yes
USE_GCC_48_OR_HIGHER:=yes
USE_GCC_49_OR_HIGHER:=yes
USE_GCC_50_OR_HIGHER:=yes
endif
endif
#---------------------- define special directories for non standard builds
ifeq ($(DARWIN),1)
OSX_FW:=/System/Library/Frameworks
OSX_FW_OPENGL:=$(OSX_FW)/OpenGL.framework/Versions/A/Libraries
OSX_FW_GLUT:=$(OSX_FW)/GLUT.framework/Versions/A/Libraries
OSX_FW_IMAGEIO:=$(OSX_FW)/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources
endif
#----------------------
ifeq ($(DARWIN),1)
LINK_STATIC=1# link static
else
LINK_STATIC=0# link dynamically
# LINK_STATIC=1# link static (testing only)
endif
shared_cflags :=# flags for shared lib compilation
clflags :=# linker flags (when passed through gcc)
extended_warnings :=# warning flags for C and C++-compiler
extended_cpp_warnings :=# warning flags for C++-compiler only
DISABLE_VECTORIZE_CHECK:=0
ifeq ($(DEBUG),0)
dflags := -DNDEBUG# defines
ifeq ($(USE_CLANG),1)
cflags := -O3# compiler flags (C and C++)
else
clflags += -Wl,-O2# passthrough linker flags
# ------- standard optimization:
cflags := -O3# compiler flags (C and C++)
# ------- test changed optimization (DISABLE_VECTORIZE_CHECK for -O2 or lower):
# cflags := -O2# do not commit uncommented!
# DISABLE_VECTORIZE_CHECK:=1
endif
endif
ifeq ($(DEBIAN),1)
clflags += -Wl,-rpath=/usr/lib/arb/lib -Wl,-z,relro
endif
ifeq ($(DEBUG),1)
dflags := -DDEBUG
gdb_common := -g -g3 -ggdb -ggdb3
DBGOPTI:=-O0
ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
DBGOPTI:=-Og
endif
ifeq ($(STABS),1)
cflags := $(DBGOPTI) $(gdb_common) -gstabs+ # using stabs+ (enable this for bigger debug session: debugs inlines, quick var inspect, BUT valgrind stops working :/)
else
cflags := $(DBGOPTI) $(gdb_common) # (using dwarf - cant debug inlines here, incredible slow on showing variable content)
endif
# cflags := $(DBGOPTI) $(gdb_common) -gdwarf-3 # (specify explicit dwarf format)
# cflags := $(DBGOPTI) $(gdb_common) -gstabs # using stabs (same here IIRC)
# cflags := -O2 $(gdb_common) # use this for callgrind (force inlining)
ifeq ($(DARWIN),0)
clflags += -Wl,-g
# Note:
# Previously '-Wl,-noinhibit-exec' was added to 'clflags' here,
# to fix some issues with launchpad binutils (see [12972]).
# But that change also caused 'undefined symbols' NOT to be reported as errors
# at link time, producing executables that fail at runtime :/
endif
ifeq ($(DEBUG_GRAPHICS),1)
dflags += -DDEBUG_GRAPHICS
endif
endif # DEBUG only
# control how much you get spammed
# (please do not change default in SVN, use developer specific setting as below)
POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --original# dont modify compiler output
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --loop-optimization-candi# show candidates for vectorization check
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --dump-loop-optimization# useful while optimizing code for vectorization
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --hide-Noncopyable-advices
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --show-useless-Weff++
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --no-warnings
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --only-first-error
# POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --no-warnings --only-first-error
ifeq ($(DEVELOPER),ELMAR)
POST_COMPILE := 2>&1 | $(ARBHOME)/SOURCE_TOOLS/postcompile.pl --only-first-error
endif
# Enable extra warnings
extended_warnings :=
extended_cpp_warnings :=
# C and C++
extended_warnings += -Wwrite-strings -Wunused -Wno-aggregate-return -Wshadow
# C++ only
extended_cpp_warnings += -Wnon-virtual-dtor -Wreorder -Wpointer-arith -Wdisabled-optimization -Wmissing-format-attribute
extended_cpp_warnings += -Wctor-dtor-privacy# < gcc 3
# extended_cpp_warnings += -Wfloat-equal# gcc 3.0
# ------- above only warnings available in 3.0
WEFFC_BROKEN:=0
ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
ifneq ('$(USE_GCC_48_OR_HIGHER)','yes')
# -Weffc++ broken in 4.7.x series
# gcc 4.7.3 crashes on GenomeImport.cxx when -Weffc++ is active
# (bug reported https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56923; apparently wont be fixed for 4.7-series)
# gcc 4.7.4 crashes on DBwriter.cxx when -Weffc++ is active
WEFFC_BROKEN:=1
endif
endif
ifeq ('$(WEFFC_BROKEN)','0')
extended_cpp_warnings += -Weffc++# gcc 3.0.1
endif
extended_cpp_warnings += -Wmissing-noreturn# gcc 3.0.2
# extended_cpp_warnings += -Wold-style-cast# gcc 3.0.4 (warn about 28405 old-style casts)
extended_cpp_warnings += -Winit-self# gcc 3.4.0
extended_cpp_warnings += -Wstrict-aliasing# gcc 3.4
extended_cpp_warnings += -Wextra# gcc 3.4.0
ifeq ($(DEBUG),1)
ifeq ($(USE_CLANG),0)
# turn off -Wmaybe-uninitialized in debug mode (gets activated with -Wextra). too many bogus warnings
extended_cpp_warnings += -Wno-maybe-uninitialized
endif
endif
ifeq ('$(USE_GCC_452_OR_HIGHER)','yes')
extended_cpp_warnings += -Wlogical-op# gcc 4.5.2
endif
ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
# extended_cpp_warnings += -Wunused-local-typedefs# gcc 4.7 (fails for each STATIC_ASSERT, enable only for Cxx11)
# extended_cpp_warnings += -Wzero-as-null-pointer-constant# gcc 4.7 #@@@ activate
endif
ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
extended_cpp_warnings += -Wunused-local-typedefs# available since gcc 4.7 (but fails for each STATIC_ASSERT, so enable only for Cxx11)
endif
#---------------------- turn off clang bogus warnings
ifeq ($(USE_CLANG),1)
# -Wmismatched-tags warns about struct/class mismatch in forward declarations (which is explicitely allowed)
# -Wchar-subscripts reports too many bogus warnings for "array['x']" (when 'x' is known to be in range [0..128])
# -Wunused-private-field report too many false positives (currently ~ 2 of 3)
# -Wstring-plus-int warns about common ARB coding practice
# -Wgnu-static-float-init warns about accepted GNU extension
extended_cpp_warnings += -Wno-mismatched-tags -Wno-char-subscripts -Wno-unused-private-field -Wno-string-plus-int -Wno-gnu-static-float-init
endif
#---------------------- developer
ifneq ($(DEVELOPER),ANY) # ANY=default setting (skip all developer specific code)
dflags += -DDEVEL_$(DEVELOPER)# activate developer/release specific code
endif
#---------------------- activate TODO warnings?
ifndef SHOWTODO
ifeq ($(DEVELOPER),RALF)
SHOWTODO:=1
else
SHOWTODO:=0
endif
endif
ifeq ($(SHOWTODO),1)
dflags += -DWARN_TODO# activate "TODO" warnings
endif
#---------------------- activate Sanitizers?
ASAN_OPTIONS:=handle_segv=0:color=0
ASAN_OPTIONS+=:detect_leaks=1 # comment-out to disable leak-detection
ASAN_OPTIONS+=:check_initialization_order=1
# ASAN_OPTIONS+=:abort_on_error=1
# suppressions: SOURCE_TOOLS/arb.leaksan.supp
LSAN_OPTIONS:=max_leaks=3:suppressions=$(ARBHOME)/SOURCE_TOOLS/arb.leaksan.supp
ifndef SANITIZE
SANITIZE:=0
endif
SANITIZE_ADDRESS:=0
SANITIZE_UNDEFINED:=0
ifneq ($(SANITIZE),0)
ifeq ($(SANITIZE),all)
SANITIZE:=3
endif
ifeq ($(SANITIZE),1)
SANITIZE_ADDRESS:=1
else
ifeq ($(SANITIZE),2)
SANITIZE_UNDEFINED:=1
else
ifeq ($(SANITIZE),3)
SANITIZE_ADDRESS:=1
SANITIZE_UNDEFINED:=1
else
$(error Unknown value '$(SANITIZE)' specified for SANITIZE in config.makefile)
endif
endif
endif
endif
ifeq ($(SANITIZE_ADDRESS),1)
ifneq ('$(USE_GCC_48_OR_HIGHER)','yes')
$(info AddressSanitizer not usable with gcc $(COMPILER_VERSION) - disabled)
SANITIZE_ADDRESS:=0
else
ifneq ('$(USE_GCC_49_OR_HIGHER)','yes')
$(warning note that LeakSanitizer does not work with gcc $(COMPILER_VERSION))
endif
endif
endif
ifeq ($(SANITIZE_UNDEFINED),1)
ifneq ('$(USE_GCC_49_OR_HIGHER)','yes')
$(info UndefinedBehaviorSanitizer not usable with gcc $(COMPILER_VERSION) - disabled)
SANITIZE_UNDEFINED:=0
endif
endif
SANITIZE_ANY:=0
ifeq ($(SANITIZE_ADDRESS),1)
SANITIZE_ANY:=1
endif
ifeq ($(SANITIZE_UNDEFINED),1)
SANITIZE_ANY:=1
endif
ifeq ($(SANITIZE_ANY),1)
DISABLE_VECTORIZE_CHECK:=1
endif
#---------------------- 32 or 64 bit
ifndef BUILDHOST_64
BUILDHOST_64:=$(ARB_64)# assume build host is same as version (see config.makefile)
endif
cross_cflags:=
cross_lflags:=
cross_clflags:=
ifeq ($(ARB_64),1)
dflags += -DARB_64 #-fPIC
shared_cflags += -fPIC
ifeq ($(BUILDHOST_64),1)
# build 64-bit ARB version on 64-bit host
CROSS_LIB:=# empty = autodetect below
ifeq ($(DARWIN),1)
cross_cflags += -arch x86_64
cross_lflags += -arch x86_64
cross_clflags += -arch x86_64
endif
else
# build 64-bit ARB version on 32-bit host
CROSS_LIB:=/lib64
cross_cflags += -m64
cross_lflags += -m64 -m elf_x86_64
cross_clflags += -m64 -Wl,-m64,-m,elf_x86_64
endif
else
ifeq ($(BUILDHOST_64),1)
# build 32-bit ARB version on 64-bit host
CROSS_LIB:=# empty = autodetect below
cross_cflags += -m32
cross_lflags += -m32 -m elf_i386
cross_clflags += -m32 -Wl,-m32,-m,elf_i386
else
# build 32-bit ARB version on 32-bit host
CROSS_LIB:=/lib
endif
endif
cflags += $(cross_cflags)
clflags += $(cross_clflags)
ifeq ('$(CROSS_LIB)','')
# autodetect libdir
ifeq ($(ARB_64),1)
CROSS_LIB:=$(shell (test -d /lib64 && echo lib64) || echo lib)
else
CROSS_LIB:=$(shell (test -d /lib32 && echo lib32) || echo lib)
endif
endif
#---------------------- unit tests
ifndef UNIT_TESTS
UNIT_TESTS=0#default is "no tests"
endif
ifeq ($(UNIT_TESTS),1)
dflags += -DUNIT_TESTS
UNIT_TESTER_LIB=UNIT_TESTER/UNIT_TESTER.a
else
UNIT_TESTER_LIB=
endif
#---------------------- use gcov
ifndef COVERAGE
COVERAGE=0#default is "no"
endif
ifneq ($(COVERAGE),0)
GCOVFLAGS=-ftest-coverage -fprofile-arcs
cflags += $(GCOVFLAGS)
EXECLIBS=-lgcov
else
GCOVFLAGS=
EXECLIBS=
endif
#---------------------- other flags
dflags += -D$(MACH) # define machine
ifeq ($(DARWIN),1)
shared_cflags += -fno-common
else
dflags += $(shell getconf LFS_CFLAGS)
endif
cflags += -pipe
cflags += -fmessage-length=0# don't wrap compiler output
cflags += -fshow-column# show columns
cflags += -funit-at-a-time
cflags += -fPIC
cflags += -fno-common# link all global data into one namespace
cflags += -fstrict-aliasing# gcc 3.4
ifeq ('$(USE_GCC_48_OR_HIGHER)','yes')
cflags += -fno-diagnostics-show-caret#gcc 4.8 (4.7.?)
endif
#cflags += -save-temps# uncomment to see preprocessor output
#---------------------- various sanitizers
COMMON_SANITIZE_FLAGS:=-ggdb3 -fno-omit-frame-pointer
# activate AddressSanitizer+LeakSanitizer?
ifeq ($(SANITIZE_ADDRESS),1)
cflags += $(COMMON_SANITIZE_FLAGS) -fsanitize=address
dflags += -DLEAKS_SANITIZED
EXECLIBS += -lasan
# EXECLIBS += -static-libasan
endif
# activate UndefinedBehaviorSanitizer?
ifeq ($(SANITIZE_UNDEFINED),1)
cflags += $(COMMON_SANITIZE_FLAGS) -fsanitize=undefined
# uncomment next line to abort on runtime errors (needs 'rebuild')
#cflags += -fno-sanitize-recover
# Note: alignment-sanitizer is deactivated for ARBDB and PROBE!
ifeq ('$(DEBUG)','1')
ifeq ($(USE_GCC_MAJOR),4)
ifeq ($(USE_GCC_MINOR),9)
ifneq ('$(findstring $(USE_GCC_PATCHLEVEL),01)','')
# workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63531 for 4.9.0 + 4.9.1
# (problem is fixed in 4.9.2 release)
extended_cpp_warnings:=$(subst -Weffc++,,$(extended_cpp_warnings))
endif
endif
endif
endif
EXECLIBS += -lubsan
endif
#---------------------- X11 location
ifeq ($(DARWIN),1)
XHOME:=$(PREFIX)
else
ifeq ($(DEBIAN),1)
XHOME:=$(PREFIX)
else
XHOME:=/usr/X11R6
endif
endif
XINCLUDES ?= -I$(XHOME)/include
XLIBS ?= -L$(XHOME)/$(CROSS_LIB)
ifeq ($(DARWIN),1)
XINCLUDES += -I$(OSX_FW)/GLUT.framework/Headers -I$(OSX_FW)/OpenGL.framework/Headers -I$(OSX_SDK)/usr/include/krb5
XLIBS += -lXm -lpng -lz -lXt -lX11 -lXext -lXp -lXmu -lXi
XLIBS += -Wl,-dylib_file,$(OSX_FW_OPENGL)/libGL.dylib:$(OSX_FW_OPENGL)/libGL.dylib
XLIBS += -Wl,-dylib_file,$(OSX_FW_OPENGL)/libGLU.dylib:$(OSX_FW_OPENGL)/libGLU.dylib
else
XLIBS += -lXm -lXpm -lXt -lXext -lX11
endif
dflags += -DARB_MOTIF
#---------------------- open GL
ifeq ($(OPENGL),1)
cflags += -DARB_OPENGL # activate OPENGL code
GL := gl # this is the name of the OPENGL base target
GL_LIB_SYS := -lGL -lGLU
GL_LIB_ARB := -L$(ARBHOME)/GL/glAW -lglAW
ifeq ($(DARWIN),1)
GL_LIB_SYS += -lpthread
endif
GL_PNGLIBS_ARB := -L$(ARBHOME)/GL/glpng -lglpng_arb
GL_PNGLIBS_SYS := -lpng
GLEWLIB := -lGLEW -lGLw
ifeq ($(DARWIN),1)
GLUTLIB := -glut
else
GLUTLIB := -lglut
endif
GL_LIBS_SYS := $(GL_LIB_SYS) $(GL_PNGLIBS_SYS) $(GLEWLIB) $(GLUTLIB)
GL_LIBS_ARB := $(GL_LIB_ARB) $(GL_PNGLIBS_ARB)
RNA3D_LIB := RNA3D/RNA3D.a
else
GL_LIBS_ARB:=# no opengl -> no libs
GL_LIBS_SYS:=# no opengl -> no libs
GL:=# don't build ARB openGL libs
RNA3D_LIB :=
endif
RNA3D_LIB_4_DEPENDS := RNA3D/RNA3D.a
GL_LIBS:=$(GL_LIBS_ARB) $(GL_LIBS_SYS)
#---------------------- tiff lib:
TIFFLIBS := -ltiff
#---------------------- XML lib:
XMLLIBS := -lxerces-c
#---------------------- glib:
ARB_NEEDED_GLIB=glib-2.0
ARB_GLIB_INCLUDE:=$(strip $(shell pkg-config --cflags $(ARB_NEEDED_GLIB)))
ARB_GLIB_LIBS:=$(strip $(shell pkg-config --libs $(ARB_NEEDED_GLIB)))
#---------------------- basic libs:
SYSLIBS:=
ifeq ($(DARWIN),1)
SYSLIBS += -lstdc++
else
SYSLIBS += -lm $(ARB_GLIB_LIBS)
endif
#---------------------- include symbols?
ifeq ($(TRACESYM),1)
ifeq ($(USE_CLANG),0)
cflags += -rdynamic
clflags += -rdynamic -Wl,--export-dynamic
endif
endif
#---------------------- system dependent commands
ifeq ($(DARWIN),1)
TIME:=gtime
else
TIME:=/usr/bin/time
endif
#---------------------- SSE vectorizer
BROKEN_VECTORIZATION:=0
ifeq ('$(COMPILER_VERSION)','6.1.0')
BROKEN_VECTORIZATION:=1
endif
ifeq ('$(COMPILER_VERSION)','6.2.0')
BROKEN_VECTORIZATION:=1
endif
ifeq ('$(BROKEN_VECTORIZATION)','1')
# see http://bugs.arb-home.de/ticket/700
cflags += -fno-tree-loop-vectorize
DISABLE_VECTORIZE_CHECK:=1
endif
ifeq ($(DEBUG),0)
ifeq ($(USE_GCC_49_OR_HIGHER),yes)
ifeq ($(DISABLE_VECTORIZE_CHECK),0)
# cflags += -fopt-info
cflags += -fopt-info-vec
# Shows reasons for unsuccessful vectorization:
# cflags += -fopt-info-vec-missed
POST_COMPILE += --check-loop-optimization
endif
else
ifeq ($(USE_GCC_48_OR_HIGHER),yes)
# no automatic vectorization-check for gcc<4.9.0
# -> uncomment the next 2 lines and grep the spam it will produce for 'vectorized.*loops'
# cflags += -fopt-info -fopt-info-vec-missed
# POST_COMPILE += --original
endif
endif
endif
#---------------------- stop early on broken flags/compiler combination
ifeq ($(DEBUG),0)
ifeq ($(SANITIZE_ANY),1)
ifeq ('$(COMPILER_VERSION)','4.9.1')
$(error compiling DEBUG=0 + SANITIZE!=0 crashes with gcc $(COMPILER_VERSION) (gcc 4.9.2 works))
endif
endif
endif
#---------------------- differences between linking executables and shared libs:
# executables:
ifeq ($(DARWIN),1)
blflags:=$(clflags)
else
blflags:=$(clflags) -Wl,--no-undefined
endif
# shared libraries
llflags:=$(clflags)
# dont use clflags below
clflags:=
# -------------------------------------------------------------------------
# Don't put any machine/version/etc conditionals below!
# (instead define variables above)
# -------------------------------------------------------------------------
cflags += -W -Wall $(dflags) $(extended_warnings)
cxxflags := $(extended_cpp_warnings)
# add CFLAGS + CPPFLAGS from environment for DEBIAN build
ifeq ($(DEBIAN),1)
cflags := $(CFLAGS) $(cflags)
cxxflags += $(CPPFLAGS)
endif
ifeq ('$(USE_GCC_47_OR_HIGHER)','yes')
cxxflags += -std=gnu++11# see also TEMPLATES/cxxforward.h@USE_Cxx11
else
# only use for gcc versions between 4.3 and <4.7 (4.7++ adds -Wc++11-compat above)
HAVE_GNUPP0X=`SOURCE_TOOLS/requireVersion.pl 4.3 $(COMPILER_VERSION)`
ifeq ($(HAVE_GNUPP0X),1)
# ensure compatibility with upcoming C++ standard
cxxflags += -std=gnu++0x
endif
endif
LINK_STATIC_LIB := ar -csq# link static lib
LINK_EXECUTABLE := $(A_CXX) $(blflags) -o# link executable (c++)
ifeq ($(LINK_STATIC),1)
SHARED_LIB_SUFFIX = a# static lib suffix
LINK_SHARED_LIB := $(LINK_STATIC_LIB)
else
SHARED_LIB_SUFFIX = so# shared lib suffix
LINK_SHARED_LIB := $(A_CXX) $(llflags) -shared $(GCOVFLAGS) -o# link shared lib
endif
ifeq ($(DARWIN),1)
lflags4perl:=
else
lflags4perl:=$(cross_lflags) -shared
endif
# delete variables unused below
blflags:=
llflags:=
# other used tools
MAKEDEPEND_PLAIN = makedepend
MAKEDEPEND = $(FORCEMASK);$(MAKEDEPEND_PLAIN)
#SEP:=--------------------------------------------------------------------------------
SEP=[`date +%M:%S.%N`] ------------------------------------------------
# to analyse timings run
# make -j9 clean; make -j9 all | grep '^\[' | sort
# make -j9 "TIMED_TARGET=perl" clean_timed_target | grep '^\[' | sort
CORE_LIB=-lCORE
ARBDB_LIB=-lARBDB $(CORE_LIB)
LIBS = $(ARBDB_LIB) $(SYSLIBS)
GUI_LIBS_PREFIX:=
ifeq ($(DARWIN),1)
# this seem to be added at wrong place, since opengl is only needed to link EDIT4
GUI_LIBS_PREFIX:=-framework GLUT -framework OpenGL
endif
GUI_LIBS=$(GUI_LIBS_PREFIX) $(LIBS) -lAWT -lWINDOW
GUI_LIBS+=$(XLIBS)
LIBPATH = -L$(ARBHOME)/lib
DEST_LIB = lib
DEST_BIN = bin
CC_INCLUDES := -I. -I$(ARBHOME)/INCLUDE $(XINCLUDES) $(ARB_GLIB_INCLUDE)
CXX_INCLUDES := $(CC_INCLUDES)
MAKEDEPENDFLAGS := -- -DARB_OPENGL -DUNIT_TESTS -D__cplusplus -I. -Y$(ARBHOME)/INCLUDE
# -------------------------------
# old PTSERVER or PTPAN?
ifeq ($(PTPAN),1)
# PTPAN only libs
ARCHS_PT_SERVER = \
ptpan/PROBE.a
else
ifeq ($(PTPAN),2)
# special mode to compile both servers (developers only!)
ARCHS_PT_SERVER = \
ptpan/PROBE.a \
PROBE/PROBE.a
ARCHS_PT_SERVER_LINK = PROBE/PROBE.a# default to old ptserver
else
# PT-server only libs
ARCHS_PT_SERVER = \
PROBE/PROBE.a
endif
endif
ifndef ARCHS_PT_SERVER_LINK
ARCHS_PT_SERVER_LINK = $(ARCHS_PT_SERVER)
endif
# ---------------------------------------
# wrap main()
use_ARB_main=$(ARBHOME)/SOURCE_TOOLS/arb_main_cpp.o
use_ARB_main_C=$(ARBHOME)/SOURCE_TOOLS/arb_main_c.o
# -----------------------------------------
# export variables to submakefiles
include SOURCE_TOOLS/export2sub
# do not define (exported) variables below this point
# -------------------------
# Main arb targets:
# -------------------------
first_target:
$(MAKE) checks
@echo $(SEP)
@echo 'Main targets:'
@echo ''
@echo ' all - Compile ARB + TOOLs + and copy shared libs + link foreign software'
@echo ' (That is most likely the target you want)'
@echo ''
@echo ' clean - remove generated files ("SUBDIR/SUBDIR.clean" to clean only SUBDIR)'
@echo ' rebuild - clean + all'
@echo ' cleanlinked - remove all binaries'
@echo ' relink - cleanlinked + all (=relink all from objects)'
@echo ''
@echo 'Some often used sub targets (make all makes them all):'
@echo ''
@echo ' arb - Just compile ARB (but none of the integrated tools)'
@echo ' menus - create lib/gde/arb.menu from GDEHELP/ARB_GDEmenus.source'
@echo ' perl - Compile the PERL XSUBS into lib/ARB.so and create links in lib to perl'
@echo ' binlink - Create all links in the bin directory'
@echo ''
@echo 'Development targets:'
@echo ''
@echo ' depends - create or update dependencies ("SUBDIR/SUBDIR.depends" to update only SUBDIR)'
@echo ' proto - create or update prototypes ("SUBDIR/SUBDIR.proto" to update only SUBDIR)'
@echo ' tags - create tags for xemacs'
@echo ' show - show available shortcuts (AKA subtargets)'
@echo ' up - shortcut for depends+proto+tags'
ifeq ($(UNIT_TESTS),1)
@echo ' ut - only run tests'
endif
ifneq ($(SANITIZE),0)
@echo ' sanitize - all + run arb_ntree with sanitizer (test.arb + execute _logged)'
endif
@echo ' modified - rebuild files modified in svn checkout (does touch)'
@echo ' touch - touch files modified in svn checkout'
@echo ''
@echo 'Internal maintenance:'
@echo ''
@echo ' relinfo - show help on release targets'
@echo ' tarfile - make rebuild and create arb version tarfile ("tarfile_quick" to skip rebuild)'
@echo ' save - save all basic ARB sources into arbsrc_DATE ("savetest" to check filelist)'
@echo ' patch - save svn diff to patchfile'
@echo ' source_doc - create doxygen documentation'
@echo ' relocated - rebuild partly (use when you have relocated ARBHOME)'
@echo ' check_res - check resource usage'
@echo ' dep_graph - Build dependency graphs'
@echo ' clean_cov - Clean coverage results'
@echo ''
@echo ' post_commit_check - Checks whether'
@echo ' * main make targets work,'
@echo ' * dependencies and prototypes are up to date,'
@echo ' * SVN-controlled files remain unaffected by called targets and'
@echo ' * all generated files are ignored.'
@echo ' (has to be called in a clean SVN checkout)'
@echo $(SEP)
@echo ''
relinfo:
@echo ''
@echo $(SEP)
@echo 'Release targets:'
@echo ''
@echo ' inc_candi - increase RC candidate-number (only possible in "rc" branch, not needed for RC1)'
@echo ' inc_patch - increase release patchlevel (only possible in "stable" branch)'
@echo ' inc_minor - increase minor version number (only possible in "trunk")'
@echo ' inc_major - increase MAJOR version number (only possible in "trunk")'
@echo ''
@echo ' show_version - show version tag'
@echo ''
@echo $(SEP)
@echo ''
# auto-generate config.makefile:
CONFIG_MAKEFILE_FOUND=$(wildcard config.makefile)
config.makefile : config.makefile.template
@echo --------------------------------------------------------------------------------
ifeq ($(strip $(CONFIG_MAKEFILE_FOUND)),)
@cp $< $@
@echo '$(ARBHOME)/$@:1: has been generated.'
@echo 'Please edit $@ to configure your system!'
@echo --------------------------------------------------------------------------------
@false
else
@echo '$(ARBHOME)/$<:1: is more recent than'
@echo '$(ARBHOME)/$@:1:'
@ls -al config.makefile*
@echo --------------------------------------------------------------------------------
@echo "Updating $@ (if this fails, check manually)"
SOURCE_TOOLS/update_config_makefile.pl
@echo "Sucessfully updated $@"
@echo --------------------------------------------------------------------------------
@ls -al config.makefile*
@echo --------------------------------------------------------------------------------
@echo "Diff to your old config.makefile:"
@echo --------------------------------------------------------------------------------
-diff $@.bak $@
@echo --------------------------------------------------------------------------------
endif
# check if everything is configured correctly
check_DEVELOPER:
ifndef DEVELOPER
@echo 'config.makefile:1: DEVELOPER not defined'
@false
endif
check_DEBUG:
ifndef dflags
@echo 'config.makefile:1: DEBUG has to be defined. Valid values are 0 and 1'
@false
endif
check_ARB_64:
ifndef ARB_64
@echo 'config.makefile:1: ARB_64 has to be defined. Valid values are 0 and 1'
@false
endif
# ---------------------------------------- check gcc version
COMPILER_BROKEN:=0
# gcc 4.8.0 produces invalid code (see #617)
ifeq ('$(COMPILER_VERSION_ALLOWED)', '4.8.0')
COMPILER_BROKEN:=1
endif
check_same_GCC_VERSION:
$(ARBHOME)/SOURCE_TOOLS/check_same_compiler_version.pl $(COMPILER_NAME) $(COMPILER_VERSION_ALLOWED)
check_GCC_VERSION:
@echo 'Compiler version check:'
# see .@ALLOWED_gcc_VERSIONS
ifeq ('$(COMPILER_VERSION_ALLOWED)', '')
@echo " - Your compiler is '$(COMPILER_NAME)' version '$(COMPILER_VERSION)'"
@echo ' This version is not in the list of supported $(COMPILER_NAME)-versions:'
@$(foreach version,$(ALLOWED_COMPILER_VERSIONS),echo ' * $(version)';)
@echo ' - You may either ..'
@echo ' - add your version to ALLOWED_$(COMPILER_NAME)_VERSIONS in the Makefile and try it out or'
@echo ' - switch to one of the allowed versions (see arb_README_gcc.txt for installing'
@echo ' a different version of gcc)'
$(error Unsupported compiler '$(COMPILER_NAME)' version '$(COMPILER_VERSION)')
else