-
Notifications
You must be signed in to change notification settings - Fork 10
/
configure
executable file
·2871 lines (2632 loc) · 99 KB
/
configure
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
#!/usr/bin/perl
#
# TODO
#
# @todo Consider adding output variables CFLAGS_ADDITIONS, CXXFLAGS_ADDITIONS, CFLAGS_REMOVEALS, CXXFLAGS_REMOVEALS
# @todo Consider adding support for ASFLAGS (like CFLAGS)
#
use strict;
use warnings;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
BEGIN{ @INC = ( "./", @INC ); }
use constant false => 0;
use constant true => 1;
use constant DEFAULT_BOOL_OPTIONS => -1;
my $configurationFiles = "ConfigurationFiles/";
my $configurationName = undef;
my $MAKE_INDENT_LEVEL = $ENV{'MAKE_INDENT_LEVEL'};
if (!defined $MAKE_INDENT_LEVEL) {
$MAKE_INDENT_LEVEL = 0;
}
sub GetThisScriptDir {
use File::Basename;
use Cwd 'abs_path';
my $p = __FILE__;
my $A = abs_path ($p);
my $dirname = dirname($A);
return $dirname;
}
my $thisScriptDir = GetThisScriptDir ();
sub trim($)
{
my $string = shift;
if (not defined($string)) {
return $string;
}
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub indexOf
{
my @arr = shift;
my $v = shift;
for (my $ii = 0; $ii <= $#arr; $ii++) {
if ($arr[$ii] eq $v) {
return $ii;
}
}
return -1;
}
my $PATH_SEPERATOR=":";
if ("$^O" eq "cygwin" or "$^O" eq "msys") {
$PATH_SEPERATOR=";";
}
my @EXTRA_ARGS = ();
########### CONFIG_Variables ###############
my $ARCH='';
my $BUILD_TOOLS_ROOT=undef;
my $PROJECTPLATFORMSUBDIR='';
my $TARGET_PLATFORMS='';
# Various Visaul Studio defines sometimes (maybe) helpful - somewhat speculative
my $VSVARS_VSINSTALLDIR=undef;
my $VSVARS_WindowsSdkDir=undef;
my $VSVARS_WindowsSDKVersion=undef;
my $VSVARS_VCToolsInstallDir=undef;
my @useExtraCDefines;
my @useExtraMakeDefines;
my @packageConfigLinkLines;
my @CPPFLAGS = qw ();
my @CPPFLAGS2Remove = qw ();
my $CPPFLAGS_Overridden = false;
my @CFLAGS = qw ();
my @CFLAGS2Remove = qw ();
my $CFLAGS_Overridden = false;
my @CXXFLAGS = qw ();
my @CXXFLAGS2Remove = qw ();
my $CXXFLAGS_Overridden = false;
#
# BUILD iff LIBFEATUREFLAG_BuildOnly OR LIBFEATUREFLAG_UseStaticTPP
# HAS_FEATURE iff LIBFEATUREFLAG_UseStaticTPP OR LIBFEATUREFLAG_UseSystem
#
my $LIBFEATUREFLAG_BuildOnly = "build-only";
my $LIBFEATUREFLAG_UseStaticTPP = "use";
my $LIBFEATUREFLAG_UseSystem = "use-system";
my $LIBFEATUREFLAG_No = "no";
my $ENABLE_LTO = DEFAULT_BOOL_OPTIONS;
my $ENABLE_ASSERTIONS = DEFAULT_BOOL_OPTIONS;
my $ENABLE_GLIBCXX_DEBUG = DEFAULT_BOOL_OPTIONS;
my $MACOSX_DEPLOYMENT_TARGET = undef;
my $CPPSTD_VERSION_FLAG = '';
my $CWARNING_FLAGS = undef;
my $SharedSymbolVisibility = undef; # gcc visibility flag - -fvisible=hidden
my $runtimeStackProtectorFlag = DEFAULT_BOOL_OPTIONS;
my $sanitizerFlagsIsDefined = false; #sadly perl arrays cannot be 'undefined'
my $sanitizerFlagsNoneSet = false;
my @sanitizerFlags = ();
my @noSanitizerFlags = ();
my $autoIncludeTSAN_OPTIONSIfAppropriate = true;
my $HasMakefileBugWorkaround_lto_skipping_undefined_incompatible = DEFAULT_BOOL_OPTIONS;
my $ApplyDebugFlags = DEFAULT_BOOL_OPTIONS;
my $ApplyReleaseFlags = DEFAULT_BOOL_OPTIONS;
## /Zi or /Zl (as opposed to using /Z7 for debug info)
## Z7 may use more disk space but less confusing for library to
## not have symbol information written into .pdb file
my $WinFlag_DebugProgramDatabase = false; # ignored except for visual studio
### @todo finish review of what warnings we still want - disable a few more... --LGP 2019-08-29
### FOR COMMON ONES - SEE IF THEY SHOULD REALLY BE GCC SPECIFIC
my $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ = '-Wall ';
$DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ . '-Wno-switch '; # This warning needed because of pattern with eEnd being injected into enums but not looked for in switch
$DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ . '-Wno-sign-compare '; # someday tackle this, but I'm not sure its helpful
$DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_ . '-Wno-unused-function '; # we have many of these - review if makes sense warning?
my $DEFAULT_CWARNING_FLAGS_GCC = $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_;
my $DEFAULT_CWARNING_FLAGS_CLANG = $DEFAULT_CWARNING_FLAGS_SAFE_COMMON_;
$DEFAULT_CWARNING_FLAGS_CLANG = $DEFAULT_CWARNING_FLAGS_CLANG . '-Wno-unused-local-typedef '; ### really needed - get alot of them - e.g. using inherited = ... - (maybe can use [[maybe_unused]])
$DEFAULT_CWARNING_FLAGS_CLANG = $DEFAULT_CWARNING_FLAGS_CLANG . '-Wno-future-compat ';
my $Config_Tag = undef; #see https://stroika.atlassian.net/browse/STK-667 to support plural
my $BuildByDefault = "always"; # for now default to always...
my $FEATUREFLAG_StrawberryPerl = undef;
my $FEATUREFLAG_LIBCURL = $LIBFEATUREFLAG_No; #$LIBFEATUREFLAG_UseStaticTPP; tricky some places because of dependencies - resolve that first
my $FEATUREFLAG_boost = $LIBFEATUREFLAG_UseStaticTPP;
my $FEATUREFLAG_boost_userspecified = 0;
my $FEATUREFLAG_OpenSSL = "";
my $FEATUREFLAG_OpenSSLExtraArgs = "";
my $FEATUREFLAG_WinHTTP = $LIBFEATUREFLAG_No;
my $FEATUREFLAG_ATLMFC = undef;
my $FEATUREFLAG_Xerces = undef;
my $FEATUREFLAG_ZLib = $LIBFEATUREFLAG_UseStaticTPP;
my $FEATUREFLAG_sqlite = $LIBFEATUREFLAG_UseStaticTPP;
my $FEATUREFLAG_LZMA = $LIBFEATUREFLAG_UseStaticTPP;
my $FEATUREFLAG_librt = undef;
my $FEATUREFLAG_WIX = undef;
my $TargettingValgrind = undef;
my $qCompiler_SanitizerDoubleLockWithConditionVariables_Buggy = undef;
my $qCompiler_ValgrindLTO_Buggy = undef;
my $qCompiler_ValgrindDirectSignalHandler_Buggy = undef;
my $qCompiler_HasNoMisleadingIndentation_Flag = undef;
my $ENABLE_TRACE2FILE = DEFAULT_BOOL_OPTIONS;
my $INCLUDE_SYMBOLS_LIB = true;
my $INCLUDE_SYMBOLS_EXE = DEFAULT_BOOL_OPTIONS;
my $MALLOC_GUARD = DEFAULT_BOOL_OPTIONS;
my $COPTIMIZE_FLAGS = "";
my $STATIC_LINK_GCCRUNTIME = DEFAULT_BOOL_OPTIONS;
my $STATIC_LINK_SANITIZERS = DEFAULT_BOOL_OPTIONS;
my $COMPILER_DRIVER = "";
my $COMPILER_DRIVER_C = ""; # @todo allow cmdline option to set _C or _CPlusPlus version
my $COMPILER_DRIVER_CPlusPlus = "";
my $AS = undef;
my $AR = undef;
my $CMAKE = undef;
my $LIBTOOL = undef; # Windows format LIB tool
my $RANLIB = undef;
my $Linker = undef;
my $MIDL = undef;
my $RC = undef;
my $STRIP = undef;
my $EXTRA_PREFIX_LINKER_ARGS = "";
my $EXTRA_SUFFIX_LINKER_ARGS = "";
my $RUN_PREFIX = ""; # for now just used as prefix for stuff like LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libasan.so.3, esp for running tests
my $CrossCompiling = "false";
my $onlyGenerateIfCompilerExists = false; ## Looks for BOTH compiler and assocaited stdlib if std=libc++
my @INCLUDES_PATH = qw();
my $INCLUDES_PATH_SET = false;
my @INCLUDES_PATH_ADD = qw();
my @LIBS_PATH = qw();
my $LIBS_PATH_SET = false;
my @LIBS_PATH_ADD = qw();
my $LIB_DEPENDENCIES = undef; # space separated list
my @LIB_DEPENDENCIES_ADD = qw();
my @LinkTime_CopyFilesToEXEDir = qw();
my $STDCXXLIB = undef;
my $TOOLS_PATH_ADDITIONS = undef;
my $lsb_release = trim (`lsb_release -rs 2>/dev/null`);
#
# Workaround MSYS compatabilty issues with microsoft visual C++ tools.
# Note: MSYS2_ENV_CONV_EXCL doesn't appear necessary (as of 2022-01-25)
#
if ("$^O" eq "msys") {
$ENV{'MSYS2_ARG_CONV_EXCL'} = '*';
}
sub getUbuntuVersion
{
my $a = trim (`(. /etc/os-release ; echo \"\$VERSION_ID\") 2>/dev/null`) ;
if ($a eq "") {
return 0;
}
else {
return $a * 1;
}
}
# More standard to have false, true is the value used in VS2k project files (through 2.1a2)
# for a while in Stroika based apps /EHa versus /EHsc - https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019
# So in Stroika 2.1a2 switch default to more standard (and recommended by MSFT docs above) no structured exceptions
my $Windows_Exceptions_SupportStructuredExceptions = false;
sub DoHelp_
{
my $x = shift(@_);
print("Usage:\n");
print(" configure CONFIGURATION-NAME [OPTIONS]* where options can be:\n");
print(" --arch {ARCH} /* for high level architecture - first section of gcc -machine - e.g. x86, x86_64, arm - usually auto-detected */\n");
print(" [--config-tag {TAG-NAME}]* /* Add TAG-NAME to the list of tags associated with this configuration (for now limit one). Maybe repeated */\n");
print(" --build-by-default never|always|{uname} /* Mark configuration to be built by default always (DEFAULT), never, or only if host uname/uname -o equals ARGUMENT */\n");
print(" --platform {PLATFORM} /* Specifies the ProjectPlatformSubdir (Unix, VisualStudio.Net-2017, VisualStudio.Net-2019, VisualStudio.Net-2022) - usually auto-detected */\n");
print(" --target-platforms {TARGET_PLATFORMS} /* Specifies the target-platforms- system compiling Stroika for - (set of ENUM where ENUM=(Windows, POSIX, Linux, MacOS)) - usually auto-detected */\n");
print(" --build-tools-root {BUILD_TOOLS_ROOT} /* Specifies the BUILD_TOOLS_ROOT - initially just for visual studio - usually auto-detected */\n");
print(" --assertions { enable|disable|default } /* Enables/disable assertion feature (setting qDebug) */\n");
print(" --block-allocation { enable|disable|default } /* Enables/disable block-allocation (a feature that improves performance, but messes up valgrind) */\n");
print(" --valgrind { enable|disable|default } /* Enables/disable valgrind-specific runtime code (so far only needed for clean helgrind use) */\n");
print(" --GLIBCXX_DEBUG { enable|disable|default } /* Enables/Disables GLIBCXX_DEBUG (G++-specific) */\n");
print(" --MACOSX_DEPLOYMENT_TARGET { #|default|none } /* set MACOSX_DEPLOYMENT_TARGET (mac os min version) (macosx target specific) */\n");
print(" --cppstd-version {FLAG} /* Sets can be c++17, or c++2a */\n");
print(" --stdlib {LIB} /* libc++ (clang lib), libstdc++ (gcc and often clang) */\n");
print(" --StrawberryPerl {use|no} /* Enables/disables use of StrawberryPerl (Windows Only) - JUST USED TO BUILD OPENSSL for Windows*/\n");
print(" --LibCurl {build-only|use|use-system|no} /* Enables/disables use of LibCurl for this configuration [default TBD]*/\n");
print(" --boost {build-only|use|use-system|no} /* Enables/disables use of boost for this configuration [default use] */\n");
print(" --OpenSSL {build-only|use|use-system|no} /* Enables/disables use of OpenSSL for this configuration [default use] */\n");
print(" --OpenSSL-ExtraArgs { purify? } /* Optionally configure extra OpenSSL features (see Stroika/OpenSSL makefile) */\n");
print(" --WinHTTP {use-system|no} /* Enables/disables use of WinHTTP for this configuration [default use-system on windows, and no otherwise] */\n");
print(" --ATLMFC {use-system|no} /* Enables/disables use of ATLMFC for this configuration [default use-system on windows, and no otherwise] */\n");
print(" --Xerces {build-only|use|use-system|no} /* Enables/disables use of Xerces for this configuration [default use] */\n");
print(" --sqlite {build-only|use|use-system|no} /* Enables/disables use of sqlite for this configuration [default use] */\n");
print(" --ZLib {build-only|use|use-system|no} /* Enables/disables use of ZLib for this configuration [default use] */\n");
print(" --WIX {use|use-system|no} /* Enables/disables use of WIX (Windows Only) - to build windows installers*/\n");
print(" --lzma {build-only|use|use-system|no} /* Enables/disables use of LZMA SDK for this configuration [default use] */\n");
print(" --no-third-party-components /* equivilent to --StrawberryPerl no --LibCurl no --boost no --OpenSSL no --WinHTTP no --ATLMFC no --Xerces no --sqlite no --ZLib no --WIX no --lzma no */\n");
print(" --trace2file { enable|disable|default } /* Enables/disable trace2file feature */\n");
print(" --static-link-gccruntime { enable|disable } /* Enables/disable gcc runtime static link (only applies if gcc family compiler) */\n");
print(" --make-define {ARG} /* Define makefile define for the given configuration: text of arg appears as line in Configuration.mk */\n");
print(" --compiler-driver {ARG} /* default is gcc */\n");
print(" --ar {ARG} /* default is undefined, but if compiler-driver is gcc or g++, this is gcc-ar */\n");
print(" --as {ARG} /* default is 'as' on unix, and retrieved from visual studio on visual studio */\n");
print(" --ranlib {ARG} /* default is undefined, but if compiler-driver is gcc or g++, this is gcc-ranlib */\n");
print(" --strip {ARG} /* sets program to do stripping; default is undefined, but for POSIX, defaults to strip */\n");
print(" --append-CFLAGS {ARG} /* Appends ARG to CFLAGS */\n");
print(" --remove-CFLAGS {ARG} /* Remove ARG from CFLAGS (including default added args; processed after all adds applied) */\n");
print(" --replace-all-CFLAGS {ARG} /* OVERRIDES DEFAULTS- and sets CFLAGS to just these values */\n");
print(" --append-CPPFLAGS {ARG} /* Appends ARG to CPPFLAGS; alias for append-CFLAGS AND append-CXXFLAGS, elg --append-CPPFLAGS -DA=B */\n");
print(" --remove-CPPFLAGS {ARG} /* Remove ARG from CPPFLAGS (including default added args; processed after all adds applied) */\n");
print(" --replace-all-CPPFLAGS {ARG} /* OVERRIDES DEFAULTS- and sets CPPFLAGS to just these values */\n");
print(" --append-CXXFLAGS {ARG} /* Appends ARG to CXXFLAGS */\n");
print(" --remove-CXXFLAGS {ARG} /* Remove ARG from CXXFLAGS (including default added args; processed after all adds applied) */\n");
print(" --replace-all-CXXFLAGS {ARG} /* OVERRIDES DEFAULTS- and sets CXXFLAGS to just these values */\n");
print(" --SharedSymbolVisibility {ARG} /* alias for append-CFLAGS AND append-CXXFLAGS with -fvisibility=XXX (defaults to hidden on gcc/clang/unix compilers) */\n");
print(" --append-extra-prefix-linker-args {ARG} /* Appends ARG to 'extra prefix linker args */\n");
print(" --append-extra-suffix-linker-args {ARG} /* Appends ARG to 'extra suffix linker args */\n");
print(" --append-extra-compiler-and-linker-args {ARG} /* Appends ARG to 'extra compiler' and 'extra linker' args */\n");
print(" --includes-path {ARG} /* Sets INCLUDES_PATH variable (: separated, since unix standard and allows spaces, ; separated on windows hosts) */\n");
print(" --append-includes-path {ARG} /* Appends ARG to 'INCLUDES_PATH */\n");
print(" --libs-path {ARG} /* Sets LIBS_PATH variable (':' separated, since unix standard and allows spaces; separated on windows hosts) */\n");
print(" --append-libs-path {ARG} /* Appends ARG to 'LIBS_PATH */\n");
print(" --lib-dependencies {ARG} /* Sets LIB_DEPENDENCIES variable (space separated) */\n");
print(" --append-lib-dependencies {ARG} /* Appends ARG to 'LIB_DEPENDENCIES */\n");
print(" --run-prefix {ARG} /* Sets variable RUN_PREFIX with stuff injected before run for built executables,\n");
print(" such as LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libasan.so.3 */\n");
print(" --append-run-prefix {ARG} /* Appends ARG RUN_PREFIX: with stuff injected before run for built executables */\n");
print(" --include-default-TSAN_OPTIONS {true/false} /* if true, and tsan enabled, add TSAN_OPTIONS= guess to RUN_PREFIX */\n");
print(" --pg {ARG} /* Turn on -pg option (profile for UNIX/gcc platform) on linker/compiler */\n");
print(" --lto { enable|disable } /* Turn on link time code gen on linker/compiler (for now only gcc/unix stack) */\n");
print(" --cross-compiling {true|false} /* Defaults generally to false, but set explicitly to control if certain tests will be run */\n");
print(" --apply-default-debug-flags /* */\n");
print(" --apply-default-release-flags /* */\n");
print(" --only-if-has-compiler /* Only generate this configuration if the compiler appears to exist (test run)*/\n");
print(" --debug-symbols {true|false} /* --debug-symbols-lib AND --debug-symbols-exe at the same time */\n");
print(" --debug-symbols-lib {true|false} /* defaults to true, but can be disabled if makes compile/link/etc too big/slow */\n");
print(" --debug-symbols-exe {true|false} /* defaults to true, but can be disabled if makes compile/link/etc too big/slow */\n");
print(" --malloc-guard {true|false} /* defaults to false (for now experimental and only works with GCC) */\n");
print(" --runtime-stack-check {true|false} /* gcc -fstack-protector-all */\n");
print(" --sanitize {none|thread|address|undefined|leak} /* if arg none, reset to none, else adds arg to sanitized feature (gcc/clang only) -\n");
print(" any arg you can pass to -fsanitize=XXXX */\n");
print(" /* see https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc.pdf (search -fsanitize=; eg. --sanitize address,undefined */\n");
print(" --no-sanitize {thread|vptr|etc...} /* any from --sanitize or all; option maybe used to remove a sub-category of tests (like vptr) from larger category like address */\n");
print("\n");
print("Configure's behavior is also influenced by the following environment variables:\n");
print(" CC, CXX, PLATFORM, TARGET_PLATFORMS, ARCH, AS, AR, RANLIB, STRIP; these just simpulate adding the obvoius associated argument to configure\n");
print(" EXTRA_CONFIGURE_ARGS= a space separated list of arguments added to the beginning of the configure command\n");
exit ($x);
}
sub ToBool_
{
my $x = shift(@_);
if ($x eq "true") {
return true;
}
if ($x eq "false") {
return false;
}
die ("expected bool argument to be true/false");
}
sub IsGCCOrGPlusPlus_
{
my $x = shift(@_);
return ($x =~ /gcc[!\/]*/) || (($x =~ /g\+\+[!\/]*/) && !($x =~ /clang\+\+/));
}
sub IsClangOrClangPlusPlus_
{
my $x = shift(@_);
return ($x =~ /clang[!\/]*/);
}
sub IsClangPlusPlus_
{
my $x = shift(@_);
return ($x =~ /clang\+\+[!\/]*/);
}
#return number
sub GetGCCVersion_
{
no warnings; #@todo sometimes gives warning about use of uninitialized variable - not sure why - debug later
my $x = shift(@_);
return trim (`($x --version 2>/dev/null) | head -1 | sed 's/([^)]*)/x/' | awk '{print \$3;}'`) * 1;
}
#return number
sub GetClangVersion_
{
my $x = trim(shift(@_));
my $firstLine = trim (`($x --version 2>/dev/null) | head -1`);
if (not defined($firstLine)) {
return 0;
}
no warnings 'numeric';
if (index($firstLine, "Apple ") == 0) {
my $ver = trim(`echo "$firstLine" | awk '{print \$4}'`);
$ver = $ver * 1;
return $ver;
}
else {
my $ver = trim (`echo "$firstLine" | sed 's/.*LLVM/x/' | sed 's/)//' | awk '{print \$3;}'`);
# Starting in ubuntu 20.10, they switched to the format used by crapple
if ($ver == "version") {
$ver = trim(`echo "$firstLine" | awk '{print \$4}'`);
}
$ver = $ver * 1;
return $ver;
}
}
sub IsMSVCCompiler_
{
my $x = shift(@_);
return ($x =~ /.*cl.exe.*/);
#bad way but best I know for now
# if ("$^O" eq "cygwin" or "$^O" eq "msys") {
# return true;
# }
# return false
}
sub Get_MSVC_CL_Version_
{
my $x = trim(shift(@_));
my $firstLine = trim (`('$x' 2>&1) | head -1`);
if (not defined($firstLine)) {
return 0;
}
no warnings 'numeric';
my $ver = trim(`echo "$firstLine" | awk '{print \$7}' | sed 's/\\.//g'`);
$ver = $ver * 1;
return $ver;
}
sub IsTargettingASAN_
{
my %already = map { $_ => 1 } @sanitizerFlags;
if(exists($already{'address'})) {
return true;
}
return false;
}
sub FillDefaultIncludesPathIfNeeded_
{
#IF we set include path explicitly, then suppress adding include path automatically (based on features etc) - just explicitly added ones from the commandline
my $includeAutomaticDependencies = not $INCLUDES_PATH_SET;
if ($includeAutomaticDependencies) {
if (
$FEATUREFLAG_Xerces eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LIBCURL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_boost eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_OpenSSL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_ZLib eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_sqlite eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LZMA eq $LIBFEATUREFLAG_UseStaticTPP
) {
push @INCLUDES_PATH_ADD, trim (`realpath --canonicalize-missing Builds/$configurationName/ThirdPartyComponents/include/`) . "/";
}
push @INCLUDES_PATH_ADD, trim (`realpath --canonicalize-missing Library/Sources/`) . "/";
push @INCLUDES_PATH_ADD, trim (`realpath --canonicalize-missing IntermediateFiles/$configurationName`) . "/";
@INCLUDES_PATH = qw ();
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
my $x = GetMSVCVarName_ ("INCLUDE");
for my $i (split /;/, $x) {
push @INCLUDES_PATH, $i;
}
}
}
my $var;
foreach $var (@INCLUDES_PATH_ADD) {
push @INCLUDES_PATH, $var;
}
}
sub FillDefaultLibsPathIfNeeded_
{
my $includeAutomaticDependencies = not $LIBS_PATH_SET;
if ($includeAutomaticDependencies) {
if (
$FEATUREFLAG_Xerces eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LIBCURL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_boost eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_OpenSSL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_ZLib eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_sqlite eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LZMA eq $LIBFEATUREFLAG_UseStaticTPP
) {
push @LIBS_PATH_ADD, trim (`realpath --canonicalize-missing Builds/$configurationName/ThirdPartyComponents/lib/`) . "/";
}
@LIBS_PATH = qw ();
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
my $x = GetMSVCVarName_ ("LIB");
for my $i (split /;/, $x) {
push @LIBS_PATH, $i;
}
}
}
my $var;
foreach $var (@LIBS_PATH_ADD) {
push @LIBS_PATH, $var;
}
}
sub PortablyAddLibToLibDependencies_
{
my $libBaseName = trim(shift(@_));
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
$LIB_DEPENDENCIES .= "$libBaseName.lib ";
}
else {
$LIB_DEPENDENCIES .= "-l$libBaseName ";
}
}
sub FillDefaultLibDependencies_
{
#IF we set lib dependencies explicitly, then suppress adding libs automatically (based on features etc) - just explicitly added ones from the commandline
my $includeAutomaticLibDependencies = !defined ($LIB_DEPENDENCIES);
if (!defined ($LIB_DEPENDENCIES)) {
$LIB_DEPENDENCIES = "";
}
my $mustAppendDefaults = false;
if ($LIB_DEPENDENCIES eq "") {
$mustAppendDefaults = true;
}
my $var;
foreach $var (@LIB_DEPENDENCIES_ADD) {
$LIB_DEPENDENCIES .= $var . " ";
}
if ($includeAutomaticLibDependencies) {
if ($FEATUREFLAG_Xerces ne $LIBFEATUREFLAG_No) {
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
if ($ENABLE_ASSERTIONS) {
PortablyAddLibToLibDependencies_("xerces-c_3D");
}
else {
PortablyAddLibToLibDependencies_("xerces-c_3");
}
}
else {
PortablyAddLibToLibDependencies_("xerces-c");
}
}
# $ pkg-config --static --libs openssl
# which produces
# -lssl -ldl -lcrypto -ldl
if ($FEATUREFLAG_OpenSSL ne $LIBFEATUREFLAG_No) {
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
#???dont thnik needed cuz of pragma comment link...
}
else {
push (@packageConfigLinkLines, "PKG_CONFIG_PATH=\$(shell realpath --canonicalize-missing \${StroikaRoot}Builds/\$(CONFIGURATION)/ThirdPartyComponents/lib/pkgconfig) pkg-config --static --libs openssl");
}
}
# PKG_CONFIG_PATH=Builds/Debug/ThirdPartyComponents/lib/pkgconfig/ pkg-config --static --libs libcurl
# which produces
# -L/mnt/c/Sandbox/Stroika/DevRoot/Builds/Debug/ThirdPartyComponents/lib -lcurl -lssl -lcrypto -lssl -lcrypto -ldl -lpthread
if ($FEATUREFLAG_LIBCURL ne $LIBFEATUREFLAG_No) {
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
#???dont thnik needed cuz of pragma comment link...
}
else {
push (@packageConfigLinkLines, "PKG_CONFIG_PATH=\$(shell realpath --canonicalize-missing \${StroikaRoot}Builds/\$(CONFIGURATION)/ThirdPartyComponents/lib/pkgconfig) pkg-config --static --libs libcurl");
}
}
if ($FEATUREFLAG_LZMA ne $LIBFEATUREFLAG_No) {
PortablyAddLibToLibDependencies_("lzma");
}
if ($FEATUREFLAG_sqlite ne $LIBFEATUREFLAG_No) {
PortablyAddLibToLibDependencies_("sqlite");
}
if ($FEATUREFLAG_ZLib ne $LIBFEATUREFLAG_No) {
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
if ($ENABLE_ASSERTIONS) {
PortablyAddLibToLibDependencies_("zlibstaticd");
}
else {
PortablyAddLibToLibDependencies_("zlibstatic");
}
}
else {
PortablyAddLibToLibDependencies_("z");
}
}
}
if ($mustAppendDefaults == true) {
if (index ($TARGET_PLATFORMS, "Windows") != -1) {
$LIB_DEPENDENCIES .= "urlmon.lib ";
$LIB_DEPENDENCIES .= "rpcrt4.lib ";
$LIB_DEPENDENCIES .= "kernel32.lib ";
$LIB_DEPENDENCIES .= "user32.lib ";
$LIB_DEPENDENCIES .= "gdi32.lib ";
$LIB_DEPENDENCIES .= "winspool.lib ";
$LIB_DEPENDENCIES .= "comdlg32.lib ";
$LIB_DEPENDENCIES .= "advapi32.lib ";
$LIB_DEPENDENCIES .= "shell32.lib ";
$LIB_DEPENDENCIES .= "ole32.lib ";
$LIB_DEPENDENCIES .= "oleaut32.lib ";
$LIB_DEPENDENCIES .= "uuid.lib ";
$LIB_DEPENDENCIES .= "odbc32.lib ";
$LIB_DEPENDENCIES .= "odbccp32.lib ";
}
if (index ($TARGET_PLATFORMS, "POSIX") != -1) {
$LIB_DEPENDENCIES .= "-lpthread ";
$LIB_DEPENDENCIES .= "-lm ";
if ($FEATUREFLAG_librt eq $LIBFEATUREFLAG_UseSystem) {
$LIB_DEPENDENCIES .= "-lrt ";
}
}
}
}
sub FillInToolsPathAdditionsIfNeeded_
{
my $includeAutomaticDependencies = !defined ($TOOLS_PATH_ADDITIONS);
if ($includeAutomaticDependencies) {
if ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
my $x = GetMSVCVarName_ ("TOOLS_PATH_ADDITIONS");
$TOOLS_PATH_ADDITIONS = trim (`cygpath --mixed --path \"$x)\"`);
$VSVARS_VSINSTALLDIR = GetMSVCVarName_('VSINSTALLDIR');
$VSVARS_WindowsSdkDir = GetMSVCVarName_('WindowsSdkDir');
$VSVARS_WindowsSDKVersion = GetMSVCVarName_('WindowsSDKVersion');
if (substr ($VSVARS_WindowsSDKVersion,length($VSVARS_WindowsSDKVersion)-1, 1) eq '\\') {
$VSVARS_WindowsSDKVersion = substr ($VSVARS_WindowsSDKVersion,0, length($VSVARS_WindowsSDKVersion)-1);
}
$VSVARS_VCToolsInstallDir = GetMSVCVarName_('VCToolsInstallDir');
}
else {
$TOOLS_PATH_ADDITIONS = "";
}
}
}
### Initial defaults before looking at command-line arguments
sub SetInitialDefaults_
{
if ($TARGET_PLATFORMS eq "") {
if ("$^O" eq "linux") {
$TARGET_PLATFORMS = 'Linux POSIX';
}
elsif ("$^O" eq "darwin") {
$TARGET_PLATFORMS = 'MacOS POSIX';
}
elsif ("$^O" eq "cygwin" or "$^O" eq "msys") {
$TARGET_PLATFORMS = 'Windows';
}
}
if (("$^O" eq "linux") or ("$^O" eq "darwin")) {
$PROJECTPLATFORMSUBDIR = 'Unix';
}
if ("$^O" eq "cygwin" or "$^O" eq "msys") {
my $PROGRAMFILESDIR= trim (`cygpath \"$ENV{'PROGRAMFILES'}\"`);
my $PROGRAMFILESDIR2= trim (`cygpath \"$ENV{'ProgramFiles(x86)'}\"`);
if ($PROJECTPLATFORMSUBDIR eq "") {
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2022/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2022';
}
@files = glob("'$PROGRAMFILESDIR2/Microsoft Visual Studio/2022/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2022';
}
}
# try vs 2k19
if ($PROJECTPLATFORMSUBDIR eq "") {
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2019/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2019';
}
@files = glob("'$PROGRAMFILESDIR2/Microsoft Visual Studio/2019/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2019';
}
}
# try vs 2k17
if ($PROJECTPLATFORMSUBDIR eq "") {
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2017/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2017';
}
@files = glob("'$PROGRAMFILESDIR2/Microsoft Visual Studio/2017/*/VC'");
if (scalar(@files) != 0) {
$PROJECTPLATFORMSUBDIR = 'VisualStudio.Net-2017';
}
}
}
if (("$^O" eq "linux") or ("$^O" eq "darwin")) {
$FEATUREFLAG_LIBCURL = $LIBFEATUREFLAG_UseStaticTPP;
}
if ("$^O" eq "cygwin" or "$^O" eq "msys") {
$FEATUREFLAG_WinHTTP = $LIBFEATUREFLAG_UseSystem;
}
if ("$^O" eq "darwin") {
# hacks so can do initial port/compile
$FEATUREFLAG_librt = $LIBFEATUREFLAG_No;
$STATIC_LINK_GCCRUNTIME = 0;
$COMPILER_DRIVER = "clang";
$COMPILER_DRIVER_C = "clang";
$COMPILER_DRIVER_CPlusPlus = "clang++";
$AR = "ar";
$AS = "as";
$RANLIB = "ranlib";
}
}
sub ReplaceLast_
{
my $srcString = shift(@_);
my $replaceThis = shift(@_);
my $withThis = shift(@_);
#@todo find a better way to safely substitute
my $rreplaceThis = trim (`echo $replaceThis | rev`);
my $rwithThis = trim (`echo $withThis | rev`);
return trim (`echo $srcString | rev | sed 's/$rreplaceThis/$rwithThis/' | rev`);
}
sub SetDefaultForCompilerDriver_
{
my $isVisualStudio = ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/);
if ($isVisualStudio eq 1) {
$isVisualStudio = true;
}
else {
$isVisualStudio = false;
}
if ($isVisualStudio) {
if ($ARCH eq "32" or $ARCH eq "WIN32") {
$ARCH = "x86";
}
if ($ARCH eq "64" or $ARCH eq "WIN64") {
$ARCH = "x86_64";
}
if ($ARCH eq "") {
if ($configurationName =~ /64$/) {
$ARCH = "x86_64";
print STDERR "WARNING: guessing the target arch (x86 or x86_64) from the configuration name: use --arch instead!\n";
}
if ($configurationName =~ /32/) {
$ARCH = "x86";
print STDERR "WARNING: guessing the target arch (x86 or x86_64) from the configuration name: use --arch instead!\n";
}
}
if ($ARCH eq "") {
$ARCH = "x86_64";
print STDERR "WARNING: guessing the target arch x86_64: use --arch (x86 or x86_64) instead!\n";
}
if (!(defined $AS)) {
$AS = GetMSVCVarName_ ("AS");
}
if (!(defined $CMAKE)) {
$CMAKE = GetMSVCVarName_('VSINSTALLDIR') . '/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe';
}
if (($COMPILER_DRIVER_C eq "") ) {
$COMPILER_DRIVER_C = GetMSVCVarName_ ("CC");
}
if (($COMPILER_DRIVER_CPlusPlus eq "")) {
$COMPILER_DRIVER_CPlusPlus = GetMSVCVarName_ ("CC"); # not cxx for msvc
}
#autodetect ATLMFC (Express verison missing it)
if (!defined $FEATUREFLAG_ATLMFC) {
if ($PROJECTPLATFORMSUBDIR eq "VisualStudio.Net-2017") {
my $PROGRAMFILESDIR= trim (`cygpath \"$ENV{'PROGRAMFILES'}\"`);
my $PROGRAMFILESDIR2= trim (`cygpath \"$ENV{'ProgramFiles(x86)'}\"`);
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2017/*/VC/Tools/MSVC/*/atlmfc/include/afxext.h'");
if (scalar(@files) != 0) {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_UseSystem;
}
else {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_No;
}
}
if ($PROJECTPLATFORMSUBDIR eq "VisualStudio.Net-2019") {
my $PROGRAMFILESDIR= trim (`cygpath \"$ENV{'PROGRAMFILES'}\"`);
my $PROGRAMFILESDIR2= trim (`cygpath \"$ENV{'ProgramFiles(x86)'}\"`);
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2019/*/VC/Tools/MSVC/*/atlmfc/include/afxext.h'");
if (scalar(@files) != 0) {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_UseSystem;
}
else {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_No;
}
}
if ($PROJECTPLATFORMSUBDIR eq "VisualStudio.Net-2022") {
if (!defined $VSVARS_VCToolsInstallDir) {
$VSVARS_VCToolsInstallDir = GetMSVCVarName_('VCToolsInstallDir');
}
# in VS2k22, separate checkboxes for ATL and MFC and we need MFC AND ATL
if (-e "$VSVARS_VCToolsInstallDir/atlmfc/include/afxext.h") {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_UseSystem;
}
else {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_No;
}
}
}
}
# I've found almost no docs about this. However, when I first ported to new imac with m1 chip,
# and rebuilt stroika, I found XERCES automatically did something like this to force this
# setting. But rest of my code didn't and I got compiler warnings. So try to find the best
# setting to force to, and allow external settings to override.
# This appears to only be needed when running on m1 hardware, but no easy way I can find to
# tell that so always do this by default
if (!defined $MACOSX_DEPLOYMENT_TARGET && "$^O" eq "darwin") {
my $osVersion = trim (`/usr/bin/sw_vers | grep ProductVersion | awk 'END {print \$2}'`);
($osVersion =~ /^((\d+)\.(\d+))/gm); # force convert to 2-digit form as I've seen in examples but not sure makes much sense
$MACOSX_DEPLOYMENT_TARGET = $1;
}
no warnings; #@todo fix - not sure why we get warning on use of $CPPSTD_VERSION_FLAG
if ($CPPSTD_VERSION_FLAG eq '') {
if (IsGCCOrGPlusPlus_ ($COMPILER_DRIVER)) {
$CPPSTD_VERSION_FLAG="--std=c++17"
}
elsif (IsClangOrClangPlusPlus_ ($COMPILER_DRIVER)) {
$CPPSTD_VERSION_FLAG="--std=c++17"
}
elsif ($PROJECTPLATFORMSUBDIR =~ /^VisualStudio.Net/) {
$CPPSTD_VERSION_FLAG="-std:c++latest"
}
}
if ($PROJECTPLATFORMSUBDIR eq 'Unix') {
if ($STATIC_LINK_GCCRUNTIME == DEFAULT_BOOL_OPTIONS) {
$STATIC_LINK_GCCRUNTIME = 1;
}
}
if ($COMPILER_DRIVER_C eq "") {
$COMPILER_DRIVER_C = $COMPILER_DRIVER;
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER)) {
$COMPILER_DRIVER_C = ReplaceLast_ ($COMPILER_DRIVER, 'g++', 'gcc');
}
elsif (IsClangOrClangPlusPlus_($COMPILER_DRIVER)) {
$COMPILER_DRIVER_C = ReplaceLast_ ($COMPILER_DRIVER, 'clang++', 'clang');
}
}
if ($COMPILER_DRIVER_CPlusPlus eq "") {
$COMPILER_DRIVER_CPlusPlus = $COMPILER_DRIVER;
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER)) {
$COMPILER_DRIVER_CPlusPlus = ReplaceLast_ ($COMPILER_DRIVER, 'gcc', 'g++');
}
elsif (IsClangOrClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
if (!IsClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
$COMPILER_DRIVER_CPlusPlus = ReplaceLast_ ($COMPILER_DRIVER_CPlusPlus, 'clang', 'clang++');
}
}
}
if (! defined $CWARNING_FLAGS) {
$CWARNING_FLAGS = '';
if (IsGCCOrGPlusPlus_ ($COMPILER_DRIVER)) {
$CWARNING_FLAGS = $CWARNING_FLAGS . $DEFAULT_CWARNING_FLAGS_GCC;
}
elsif (IsClangOrClangPlusPlus_($COMPILER_DRIVER)) {
$CWARNING_FLAGS = $CWARNING_FLAGS . $DEFAULT_CWARNING_FLAGS_CLANG;
if ("$^O" eq "darwin") {
if (GetClangVersion_ ($COMPILER_DRIVER_CPlusPlus) >= 14.0) {
$CWARNING_FLAGS = $CWARNING_FLAGS . '-Wno-unqualified-std-cast-call ';
}
}
else {
if (GetClangVersion_ ($COMPILER_DRIVER_CPlusPlus) >= 15.0) {
$CWARNING_FLAGS = $CWARNING_FLAGS . '-Wno-unqualified-std-cast-call ';
}
}
}
}
if ($AS eq "") {
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
$AS = ReplaceLast_ ($COMPILER_DRIVER_CPlusPlus, 'g++', 'as');
$AS =~ s/-as-.*$/-as/;
}
elsif (IsClangOrClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
if (!IsClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
$AS = ReplaceLast_ ($COMPILER_DRIVER_CPlusPlus, 'clang++', 'as');
$AS =~ s/-as-.*$/-as/;
}
}
}
if (! defined $STDCXXLIB) {
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
$STDCXXLIB = "libstdc++";
}
if (IsClangOrClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
$STDCXXLIB = "libc++";
}
}
if (! defined $SharedSymbolVisibility) {
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus) or IsClangOrClangPlusPlus_($COMPILER_DRIVER_CPlusPlus)) {
# harmless either way on Linux but on MacOSX sileneces a warning when linking with boost;
# probably a good idea in general anyhow as a default
# -- LGP 2019-02-09
$SharedSymbolVisibility = "hidden";
}
}
if ($ApplyDebugFlags == true) {
if ($ENABLE_ASSERTIONS == DEFAULT_BOOL_OPTIONS) {
$ENABLE_ASSERTIONS = 1;
}
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus) || IsClangOrClangPlusPlus_ ($COMPILER_DRIVER_CPlusPlus)) {
if ($ENABLE_GLIBCXX_DEBUG == DEFAULT_BOOL_OPTIONS) {
$ENABLE_GLIBCXX_DEBUG = 1;
}
if ($runtimeStackProtectorFlag == DEFAULT_BOOL_OPTIONS) {
$runtimeStackProtectorFlag = true;
}
if (!$sanitizerFlagsNoneSet) {
my %already = map { $_ => 1 } @sanitizerFlags;
if(!exists($already{'address'})) {
push @sanitizerFlags, 'address';
}
if(!exists($already{'undefined'})) {
push @sanitizerFlags, 'undefined';
}
$sanitizerFlagsIsDefined = true;
}
}
### if is msvc and version > 19.29 (which is 16.10), enable asan
if (IsMSVCCompiler_($COMPILER_DRIVER_CPlusPlus) && Get_MSVC_CL_Version_ ($COMPILER_DRIVER_CPlusPlus) >= 192930037) {
# https://stroika.atlassian.net/browse/STK-984
# avoid buggy 17.7 ASAN issue - https://developercommunity.visualstudio.com/t/ASAN-177-clang_rtasan_dynamic-x86_64d/10436682?
my $clVer = Get_MSVC_CL_Version_ ($COMPILER_DRIVER_CPlusPlus);
if (193732822 <= $clVer and $clVer <= 193732822) {
## SKIP by default, but if use force it with sanitzer flag fine - but must do
# export PATH=$PATH:/C:Program\ Files/Microsoft\ Visual\ Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin//Hostx64/x64/"
# or similar to distribute dll
}
else {
if (!$sanitizerFlagsNoneSet) {
my %already = map { $_ => 1 } @sanitizerFlags;
if(!exists($already{'address'})) {
push @sanitizerFlags, 'address';
}
# note ubsan not yet supported --LGP 2022-01-04
# if(!exists($already{'undefined'})) {
# push @sanitizerFlags, 'undefined';
# }
}
$sanitizerFlagsIsDefined = true;
}
}
if ($ENABLE_TRACE2FILE == DEFAULT_BOOL_OPTIONS) {
$ENABLE_TRACE2FILE = 1;
}
if ($INCLUDE_SYMBOLS_EXE == DEFAULT_BOOL_OPTIONS) {
$INCLUDE_SYMBOLS_EXE = true;
}
#helpful to print stack traces in log (not critical, and has performance overhead)
#see Debug::BackTrace ()
if ($PROJECTPLATFORMSUBDIR eq 'Unix') {
$EXTRA_PREFIX_LINKER_ARGS .= " -rdynamic";
}
}
elsif ($ApplyReleaseFlags == true) {
if ($ENABLE_ASSERTIONS == DEFAULT_BOOL_OPTIONS) {
$ENABLE_ASSERTIONS = 0;
}
# https://stroika.atlassian.net/browse/STK-763
if ($ENABLE_LTO == DEFAULT_BOOL_OPTIONS and $lsb_release == "20.04" and $TargettingValgrind == true) {
$ENABLE_LTO = false;
}
if ($ENABLE_LTO == DEFAULT_BOOL_OPTIONS) {
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus) ) {
$ENABLE_LTO = true;
}
if (IsClangOrClangPlusPlus_ ($COMPILER_DRIVER_CPlusPlus)) {
# On ubuntu 18.04 gives error linking libcurl
if (7.0 <= GetClangVersion_ ($COMPILER_DRIVER_CPlusPlus)) {
$ENABLE_LTO = true;
}
}
if ($isVisualStudio) {
$ENABLE_LTO = true;
}
}
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER_CPlusPlus) || IsClangOrClangPlusPlus_ ($COMPILER_DRIVER_CPlusPlus)) {
if ($COPTIMIZE_FLAGS eq "") {
$COPTIMIZE_FLAGS = "-O3";
}
if ($ENABLE_GLIBCXX_DEBUG == DEFAULT_BOOL_OPTIONS) {
$ENABLE_GLIBCXX_DEBUG = 0;
}
}
if (IsMSVCCompiler_ ($COMPILER_DRIVER_CPlusPlus)) {
$COPTIMIZE_FLAGS = "-O2 -Oi -Oy";
}
if ($ENABLE_TRACE2FILE == DEFAULT_BOOL_OPTIONS) {
$ENABLE_TRACE2FILE = 0;
}