-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconfigure
executable file
·3284 lines (3029 loc) · 123 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/env 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 $BuildToolsRoot=undef;
my $BuildPlatform='';
my $TargetPlatforms='';
# 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 @packageCfgNames;
my @CPPFLAGS = qw ();
my @CPPFLAGS2Remove = qw ();
my $CPPFLAGS_Overridden = false;
my @CFLAGS = qw ();
my @CFLAGS2Remove = qw ();
my $CFLAGS_Overridden = false;
my @CXXFLAGS = qw ();
my @CXXFLAGS2Append = 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 $gAssertionsEnabled = DEFAULT_BOOL_OPTIONS;
my $ENABLE_GLIBCXX_DEBUG = DEFAULT_BOOL_OPTIONS;
my $MACOSX_DEPLOYMENT_TARGET = undef;
my $CPPSTD_VERSION_FLAG = '';
my $CXXWARNING_FLAGS = undef;
# gcc visibility flag - -fvisible=hidden (see https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html for explanation)
# setting = 'hidden' used to silence a warning on MacOS with boost, but no longer needed --LGP 2023-12-04
my $SharedSymbolVisibility = undef;
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 /ZI (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 (make -jN seems to get errors, despite adding -FS flag)
### @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_CXXWARNING_FLAGS_SAFE_COMMON_ = '-Wall ';
$DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ . '-Wno-switch '; # This warning needed because of pattern with eEnd being injected into enums but not looked for in switch
$DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ . '-Wno-sign-compare '; # someday tackle this, but I'm not sure its helpful
$DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ . '-Wno-unused-function '; # we have many of these - review if makes sense warning?
$DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_ . '-Wno-psabi '; # never want to see "note: parameter passing for argument" cuz we statically link
my $DEFAULT_CXXWARNING_FLAGS_GCC = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_;
my $DEFAULT_CXXWARNING_FLAGS_CLANG = $DEFAULT_CXXWARNING_FLAGS_SAFE_COMMON_;
$DEFAULT_CXXWARNING_FLAGS_CLANG = $DEFAULT_CXXWARNING_FLAGS_CLANG . '-Wno-unused-local-typedef '; ### really needed - get alot of them - e.g. using inherited = ... - (maybe can use [[maybe_unused]])
$DEFAULT_CXXWARNING_FLAGS_CLANG = $DEFAULT_CXXWARNING_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 = undef;
my $FEATUREFLAG_boost = undef;
my $FEATUREFLAG_OpenSSL = undef;
my $FEATUREFLAG_OpenSSLExtraArgs = "";
my $FEATUREFLAG_WinHTTP = undef;
my $FEATUREFLAG_ATLMFC = undef;
my $FEATUREFLAG_Xerces = undef;
my $FEATUREFLAG_libxml2 = undef;
my $FEATUREFLAG_GoogleTest = undef;
my $FEATUREFLAG_ZLib = undef;
my $FEATUREFLAG_sqlite = undef;
my $FEATUREFLAG_LZMA = undef;
my $FEATUREFLAG_fmtlib = undef;
my $FEATUREFLAG_librt = undef;
my $FEATUREFLAG_WIX = undef;
my $TargettingValgrind = undef;
my $qCompiler_SanitizerDoubleLockWithConditionVariables_Buggy = undef;
my $qCompiler_ValgrindLTO_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 $LinkerArgs_ExtraPrefix = "";
my $LinkerArgs_ExtraSuffix = "";
my $RunPrefix = ""; # 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 @LinkerArgs_LibPath = qw();
my $LinkerArgs_LibPath_SET = false;
my @LinkerArgs_LibPath_ADD = qw();
my @LinkTime_CopyFilesToEXEDir = qw();
my $LinkerArgs_LibDependencies = undef; # space separated list
my @LinkerArgs_LibDependencies_ADD = qw();
my $STDCXXLIB = undef;
my $TOOLS_PATH_ADDITIONS = undef;
my $lsb_release = trim (`lsb_release -rs 2>/dev/null`);
my $DoSetThirdPartyComponentsParameterFromCommandLine = 'fill-in-defaults';
#
# DoSetThirdPartyComponents_ ('all-available')
# DoSetThirdPartyComponents_ ('default')
# DoSetThirdPartyComponents_ ('fill-in-defaults')
# DoSetThirdPartyComponents_ ('none')
#
sub DoSetThirdPartyComponents_
{
my $x = shift(@_);
if ($x eq "all-available") {
## Basically the same as fill-in-defaults, except for xerces is included now
my $xercesAlreadySet = defined($FEATUREFLAG_Xerces);
DoSetThirdPartyComponents_('fill-in-defaults');
if (!$xercesAlreadySet) {
$FEATUREFLAG_Xerces = $LIBFEATUREFLAG_UseStaticTPP;
}
}
elsif ($x eq "default") {
$FEATUREFLAG_ATLMFC = undef;
$FEATUREFLAG_boost = undef;
$FEATUREFLAG_LIBCURL = undef;
$FEATUREFLAG_libxml2 = undef;
$FEATUREFLAG_Xerces = undef;
$FEATUREFLAG_LZMA = undef;
$FEATUREFLAG_fmtlib = undef;
$FEATUREFLAG_OpenSSL = undef;
$FEATUREFLAG_sqlite = undef;
$FEATUREFLAG_WinHTTP = undef;
$FEATUREFLAG_ZLib = undef;
$FEATUREFLAG_GoogleTest = undef;
}
elsif ($x eq "fill-in-defaults") {
# Called late enuf that other variables have been filled in...
if (!defined $FEATUREFLAG_ATLMFC) {
if ($BuildPlatform eq "VisualStudio.Net-2022") {
# 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;
}
}
if (!defined $FEATUREFLAG_ATLMFC) {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_No;
}
}
if (!defined $FEATUREFLAG_boost) {
$FEATUREFLAG_boost = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_LIBCURL) {
if (("$^O" eq "linux") or ("$^O" eq "darwin")) {
$FEATUREFLAG_LIBCURL = $LIBFEATUREFLAG_UseStaticTPP;
}
else {
$FEATUREFLAG_LIBCURL = $LIBFEATUREFLAG_No;
}
}
if (!defined $FEATUREFLAG_libxml2) {
$FEATUREFLAG_libxml2 = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_Xerces) {
# if we have libxml2 being used, then DEFAULT to not including xerces (takes a long time to build and libxml2 better(?))
if ($FEATUREFLAG_libxml2 eq $LIBFEATUREFLAG_No) {
$FEATUREFLAG_Xerces = $LIBFEATUREFLAG_UseStaticTPP;
}
else {
$FEATUREFLAG_Xerces = $LIBFEATUREFLAG_No;
}
}
if (!defined $FEATUREFLAG_LZMA) {
$FEATUREFLAG_LZMA = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_fmtlib) {
if (NeedsFmtLib_ ()) {
$FEATUREFLAG_fmtlib = $LIBFEATUREFLAG_UseStaticTPP;
}
else {
$FEATUREFLAG_fmtlib = $LIBFEATUREFLAG_No;
}
}
if (!defined $FEATUREFLAG_OpenSSL) {
$FEATUREFLAG_OpenSSL = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_sqlite) {
$FEATUREFLAG_sqlite = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_WinHTTP) {
if ("$^O" eq "cygwin" or "$^O" eq "msys") {
$FEATUREFLAG_WinHTTP = $LIBFEATUREFLAG_UseSystem;
}
else {
$FEATUREFLAG_WinHTTP = $LIBFEATUREFLAG_No;
}
}
if (!defined $FEATUREFLAG_ZLib) {
$FEATUREFLAG_ZLib = $LIBFEATUREFLAG_UseStaticTPP;
}
if (!defined $FEATUREFLAG_GoogleTest) {
$FEATUREFLAG_GoogleTest = $LIBFEATUREFLAG_UseStaticTPP;
}
}
elsif ($x eq "none") {
if (!defined $FEATUREFLAG_ATLMFC) {
$FEATUREFLAG_ATLMFC = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_boost) {
$FEATUREFLAG_boost = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_LIBCURL) {
$FEATUREFLAG_LIBCURL = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_libxml2) {
$FEATUREFLAG_libxml2 = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_Xerces) {
$FEATUREFLAG_Xerces = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_LZMA) {
$FEATUREFLAG_LZMA = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_fmtlib) {
$FEATUREFLAG_fmtlib = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_OpenSSL) {
$FEATUREFLAG_OpenSSL = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_sqlite) {
$FEATUREFLAG_sqlite = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_WinHTTP) {
$FEATUREFLAG_WinHTTP = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_ZLib) {
$FEATUREFLAG_ZLib = $LIBFEATUREFLAG_No;
}
if (!defined $FEATUREFLAG_GoogleTest) {
$FEATUREFLAG_GoogleTest = $LIBFEATUREFLAG_No; }
}
else {
die ("Bad argument to DoSetThirdPartyComponents_")
}
}
#
# 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'} = '*';
}
# 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(" --build-platform {PLATFORM} /* Specifies the BuildPlatform (currently supported: Unix (even on macos), VisualStudio.Net-2022) - usually auto-detected (was ProjectPlatformSubDir in Stroika v2.1) */\n");
print(" --target-platforms {TargetPlatforms} /* Specifies the TargetPlatforms- system compiling Stroika for - (set of ENUM where ENUM=(Windows, POSIX, Linux, MacOS)) - usually auto-detected */\n");
print(" --build-tools-root {BuildToolsRoot} /* Specifies the BuildToolsRoot (makefile variable) - initially just for visual studio - usually auto-detected */\n");
print(" --assertions { enable|disable|default } /* Enables/disable assertion feature (setting qStroika_Foundation_Debug_AssertionsChecked) */\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 */\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++20, c++2a, c++2b, c++23 */\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(" --libxml2 {build-only|use|use-system|no} /* Enables/disables use of libxml2 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(" --all-available-third-party-components /* equivilent to --Xerces (etc) use - for all that are available on this platform */\n");
print(" --default-third-party-components /* reset third party settings to their default value (maybe less than all-available-third-party-components) */\n");
print(" --no-third-party-components /* equivilent to --StrawberryPerl no --LibCurl 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; effectively defines for CFLAGS and 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 LinkerArgs_LibPath variable (':' separated, since unix standard and allows spaces; separated on windows hosts) */\n");
print(" --append-libs-path {ARG} /* Appends ARG to 'LinkerArgs_LibPath */\n");
print(" --lib-dependencies {ARG} /* Sets LinkerArgs_LibDependencies variable (space separated) */\n");
print(" --append-lib-dependencies {ARG} /* Appends ARG to 'LinkerArgs_LibDependencies */\n");
print(" --linktime-copy-files-2-EXEDir {ARG} /* Sets LinkTime_CopyFilesToEXEDir variable (' ' separated) */\n");
print(" --append-linktime-copy-files-2-EXEDir {ARG} /* Appends ARG to 'LinkTime_CopyFilesToEXEDir */\n");
print(" --run-prefix {ARG} /* Sets variable RunPrefix 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 RunPrefix: 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 RunPrefix */\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, BuildPlatform, TargetPlatforms, 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(@_);
my $fullString = trim(shift(@_));
if (defined $fullString) {
my $v = trim (`./ScriptsLib/GetGCCVersion $x`);
return $v;
}
else {
my $v = trim (`./ScriptsLib/GetGCCVersion $x -i`);
if ($v eq '') {
return 0;
}
return $v * 1; # times one to convert to number
}
}
#return number
sub GetClangVersion_
{
my $x = trim(shift(@_));
my $fullString = trim(shift(@_));
if (defined $fullString) {
my $v = trim (`./ScriptsLib/GetClangVersion $x`);
return $v;
}
else {
my $v = trim (`./ScriptsLib/GetClangVersion $x -i`);
if ($v eq '') {
return 0;
}
return $v * 1; # times one to convert to number
}
}
sub IsMSVCCompiler_
{
my $x = shift(@_);
return ($x =~ /.*cl.exe.*/);
}
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 getUbuntuVersion
{
my $a = trim (`(. /etc/os-release ; echo \"\$VERSION_ID\") 2>/dev/null`) ;
if ($a eq "") {
return 0;
}
else {
return $a * 1;
}
}
sub getMacOSVersion
{
return trim (`/usr/bin/sw_vers | grep ProductVersion | awk 'END {print \$2}'`);
}
sub getXCodeVersion_
{
my $a = trim (`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version: | awk 'END {print \$2}' | grep -E -o '[0-9]+\.[0-9]' | head -1`) ;
if ($a eq "") {
return 0;
}
else {
return $a + 0; ## convert to a number
}
}
sub IsTargettingSanitizer_
{
my $x = shift(@_);
my %already = map { $_ => 1 } @sanitizerFlags;
if(exists($already{$x})) {
return true;
}
return false;
}
sub NeedsFmtLib_
{
if (IsClangPlusPlus_($COMPILER_DRIVER)) {
my $itsVersion = GetClangVersion_ ($COMPILER_DRIVER);
if ("$^O" eq "darwin") {
my $xcodeVer = getXCodeVersion_ ();
return $xcodeVer < 15.3; ## seems to work as of xcode 15.3, but not 15.2
}
else {
# For <format> support - in clang++15 - appears good enuf (if you enable --experimental...) - but that is sometimes unvailable, so dont count on it
if ($itsVersion < 16.0) {
return true;
}
}
}
if (IsGCCOrGPlusPlus_($COMPILER_DRIVER)) {
my $itsVersion = GetGCCVersion_ ($COMPILER_DRIVER);
# Builtin supports works for gcc as of gcc 13
if ($itsVersion < 13.0) {
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_libxml2 eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LIBCURL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_boost eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_OpenSSL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_ZLib eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_GoogleTest eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_sqlite eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LZMA eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_fmtlib 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 ($BuildPlatform =~ /^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 $LinkerArgs_LibPath_SET;
if ($includeAutomaticDependencies) {
if (
$FEATUREFLAG_Xerces eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_libxml2 eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LIBCURL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_boost eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_OpenSSL eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_ZLib eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_GoogleTest eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_sqlite eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_LZMA eq $LIBFEATUREFLAG_UseStaticTPP ||
$FEATUREFLAG_fmtlib eq $LIBFEATUREFLAG_UseStaticTPP
) {
push @LinkerArgs_LibPath_ADD, trim (`realpath --canonicalize-missing Builds/$configurationName/ThirdPartyComponents/lib/`) . "/";
}
@LinkerArgs_LibPath = qw ();
if ($BuildPlatform =~ /^VisualStudio.Net/) {
my $x = GetMSVCVarName_ ("LIB");
for my $i (split /;/, $x) {
push @LinkerArgs_LibPath, $i;
}
}
}
my $var;
foreach $var (@LinkerArgs_LibPath_ADD) {
push @LinkerArgs_LibPath, $var;
}
}
sub PortablyAddLibToLibDependencies_
{
my $libBaseName = trim(shift(@_));
if ($BuildPlatform =~ /^VisualStudio.Net/) {
$LinkerArgs_LibDependencies .= "$libBaseName.lib ";
}
else {
$LinkerArgs_LibDependencies .= "-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 ($LinkerArgs_LibDependencies);
if (!defined ($LinkerArgs_LibDependencies)) {
$LinkerArgs_LibDependencies = "";
}
my $mustAppendDefaults = false;
if ($LinkerArgs_LibDependencies eq "") {
$mustAppendDefaults = true;
}
my $var;
foreach $var (@LinkerArgs_LibDependencies_ADD) {
$LinkerArgs_LibDependencies .= $var . " ";
}
if ($includeAutomaticLibDependencies) {
if ($FEATUREFLAG_Xerces ne $LIBFEATUREFLAG_No) {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
if ($gAssertionsEnabled) {
PortablyAddLibToLibDependencies_("xerces-c_3D");
}
else {
PortablyAddLibToLibDependencies_("xerces-c_3");
}
}
else {
PortablyAddLibToLibDependencies_("xerces-c");
}
push @CPPFLAGS, '-DXML_LIBRARY=1'; # cannot use pkg-config for this because then wouldn't be seen in .vscode etc
push @CPPFLAGS, '-DXERCES_STATIC_LIBRARY=1'; # ""
}
if ($FEATUREFLAG_libxml2 ne $LIBFEATUREFLAG_No) {
push (@packageCfgNames, "libxml-2.0");
}
# $ pkg-config --static --libs openssl
# which produces
# -lssl -ldl -lcrypto -ldl
if ($FEATUREFLAG_OpenSSL ne $LIBFEATUREFLAG_No) {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
#???dont thnik needed cuz of pragma comment link...
}
else {
push (@packageCfgNames, "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 ($BuildPlatform =~ /^VisualStudio.Net/) {
#???dont thnik needed cuz of pragma comment link...
}
else {
push (@packageCfgNames, "libcurl");
}
}
if ($FEATUREFLAG_fmtlib ne $LIBFEATUREFLAG_No) {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
#???dont thnik needed cuz of pragma comment link...
}
else {
push (@packageCfgNames, "fmt");
}
}
if ($FEATUREFLAG_LZMA ne $LIBFEATUREFLAG_No) {
PortablyAddLibToLibDependencies_("lzma");
}
if ($FEATUREFLAG_sqlite ne $LIBFEATUREFLAG_No) {
PortablyAddLibToLibDependencies_("sqlite");
}
if ($FEATUREFLAG_ZLib ne $LIBFEATUREFLAG_No) {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
if ($gAssertionsEnabled) {
PortablyAddLibToLibDependencies_("zlibstaticd");
}
else {
PortablyAddLibToLibDependencies_("zlibstatic");
}
}
else {
push (@packageCfgNames, "zlib");
#PortablyAddLibToLibDependencies_("z");
}
}
if ($FEATUREFLAG_GoogleTest ne $LIBFEATUREFLAG_No) {
# if ($BuildPlatform =~ /^VisualStudio.Net/) {
# PortablyAddLibToLibDependencies_("zlibstatic");
# }
# else {
### @todo lets see if thsi works on windows
push (@packageCfgNames, "gtest");
#PortablyAddLibToLibDependencies_("z");
# }
}
}
if ($mustAppendDefaults == true) {
if (index ($TargetPlatforms, "Windows") != -1) {
$LinkerArgs_LibDependencies .= "urlmon.lib ";
$LinkerArgs_LibDependencies .= "rpcrt4.lib ";
$LinkerArgs_LibDependencies .= "kernel32.lib ";
$LinkerArgs_LibDependencies .= "user32.lib ";
$LinkerArgs_LibDependencies .= "gdi32.lib ";
$LinkerArgs_LibDependencies .= "winspool.lib ";
$LinkerArgs_LibDependencies .= "comdlg32.lib ";
$LinkerArgs_LibDependencies .= "advapi32.lib ";
$LinkerArgs_LibDependencies .= "shell32.lib ";
$LinkerArgs_LibDependencies .= "ole32.lib ";
$LinkerArgs_LibDependencies .= "oleaut32.lib ";
$LinkerArgs_LibDependencies .= "uuid.lib ";
$LinkerArgs_LibDependencies .= "odbc32.lib ";
$LinkerArgs_LibDependencies .= "odbccp32.lib ";
}
if (index ($TargetPlatforms, "POSIX") != -1) {
$LinkerArgs_LibDependencies .= "-lpthread ";
$LinkerArgs_LibDependencies .= "-lm ";
if ($FEATUREFLAG_librt eq $LIBFEATUREFLAG_UseSystem) {
$LinkerArgs_LibDependencies .= "-lrt ";
}
}
}
}
sub FillInToolsPathAdditionsIfNeeded_
{
my $includeAutomaticDependencies = !defined ($TOOLS_PATH_ADDITIONS);
if ($includeAutomaticDependencies) {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
my $x = GetMSVCVarName_ ("TOOLS_PATH_ADDITIONS");
$TOOLS_PATH_ADDITIONS = trim (`cygpath --mixed --path \"$x)\"`);
$VSVARS_VSINSTALLDIR = GetMSVCVarName_('VSINSTALLDIR');
$VSVARS_WindowsSdkDir = GetMSVCVarName_('WindowsSdkDir');
if ($VSVARS_WindowsSdkDir eq "") {
print STDERR "WARNING: VSVARS_WindowsSdkDir empty\n";
}
$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');
}
}
}
### Initial defaults before looking at command-line arguments
sub SetInitialDefaults_
{
if ($TargetPlatforms eq "") {
if ("$^O" eq "linux") {
$TargetPlatforms = 'Linux POSIX';
}
elsif ("$^O" eq "darwin") {
$TargetPlatforms = 'MacOS POSIX';
}
elsif ("$^O" eq "cygwin" or "$^O" eq "msys") {
$TargetPlatforms = 'Windows';
}
}
if (("$^O" eq "linux") or ("$^O" eq "darwin")) {
$BuildPlatform = 'Unix';
}
if ("$^O" eq "cygwin" or "$^O" eq "msys") {
my $PROGRAMFILESDIR= trim (`cygpath \"$ENV{'PROGRAMFILES'}\"`);
my $PROGRAMFILESDIR2= trim (`cygpath \"$ENV{'ProgramFiles(x86)'}\"`);
if ($BuildPlatform eq "") {
my @files = glob("'$PROGRAMFILESDIR/Microsoft Visual Studio/2022/*/VC'");
if (scalar(@files) != 0) {
$BuildPlatform = 'VisualStudio.Net-2022';
}
@files = glob("'$PROGRAMFILESDIR2/Microsoft Visual Studio/2022/*/VC'");
if (scalar(@files) != 0) {
$BuildPlatform = 'VisualStudio.Net-2022';
}
}
}
# 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++";
#$CXXWARNING_FLAGS = $DEFAULT_CXXWARNING_FLAGS_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 SetDefaultsWhichDependOnCompilerDriverAndApplyDefaultsDebugOrRel_
{
ComputeARCHFlag_();
if ($COMPILER_DRIVER eq "") {
if ($BuildPlatform =~ /^VisualStudio.Net/) {
$COMPILER_DRIVER = GetMSVCVarName_ ("CC");
}
}
if ($COMPILER_DRIVER eq "") {
die ("must set COMPILER_DRIVER before SetDefaultsWhichDependOnCompilerDriverAndApplyDefaultsDebugOrRel_");
}
my $isVisualStudio = ($BuildPlatform =~ /^VisualStudio.Net/);
if ($isVisualStudio eq 1) {
$isVisualStudio = true;
}
else {
$isVisualStudio = false;
}
if ($isVisualStudio) {
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 ($BuildPlatform 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 = getMacOSVersion();
($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++20"
}
elsif (IsClangOrClangPlusPlus_ ($COMPILER_DRIVER)) {
$CPPSTD_VERSION_FLAG="--std=c++20"