forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·2302 lines (2062 loc) · 72.2 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
# -*- CPerl -*-
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
# configure script for OpenDDS
# Distributed under the OpenDDS License.
# See: http://www.opendds.org/license.html
use Getopt::Long;
use Dumpvalue;
use File::Spec;
use File::Basename;
use File::Copy;
use File::Path;
require File::Temp;
use File::Temp ();
use FileHandle;
use Cwd;
use POSIX;
use strict;
use warnings;
## Version of OCI's TAO to download
my $oci_tao_version = '2.2a';
## Version of DOC Group ACE/TAO to download, uses the ACE version number
my $doc_tao_version = '6.5.6';
my $backup_timestamp = strftime "%Y-%m-%d-%H-%M-%S", localtime time;
# save args before Getopt modifies them
my @ARGS = @ARGV;
sub perlOS_to_host {
return 'win32' if $^O eq 'MSWin32';
return 'macosx' if $^O eq 'darwin';
return $^O;
}
sub perlOS_to_java_platform {
return 'win32' if $^O eq 'MSWin32';
return $^O;
}
my $targetUsageIndent = "\t\t";
my %platforminfo =
('win32' => {
'compilers' => ['cl'],
'libpath' => 'PATH',
'cl_versions' => {13.1 => 'vc71', 14 => 'vc8', 15 => 'vc9',
16 => 'vc10', 17 => 'vc11', 18 => 'vc12',
19 => 'vc14', 19.1 => 'vs2017',
19.2 => 'vs2019'},
'cl_archs' => {'x64' => 1, 'Win32' => 1, 'ARM64' => 0, 'ARM' => 0}, # 1 if supported
},
'macosx' => {
'compilers' => ['clang++'],
'libpath' => 'DYLD_LIBRARY_PATH',
},
'solaris' => {
'compilers' => ['CC', 'g++'],
'libpath' => 'LD_LIBRARY_PATH',
'aceplatform' => 'sunos5_$COMP', # $COMP = sunc++ or g++
'aceconfig' => 'sunos$UNAMER', # $UNAMER = `uname -r`
},
'linux' => {
'compilers' => ['g++', 'clang', 'clang++'],
'libpath' => 'LD_LIBRARY_PATH',
'aceplatform' => 'linux_$NONSTDCOMP', # $NONSTDCOMP = clang
},
'linux-cross' => {
'libpath' => 'LD_LIBRARY_PATH',
'aceplatform' => 'linux',
'aceconfig' => 'linux',
'no_host' => 1,
'usage' => ['Use --target-compiler to specify the ' .
'cross-compiler binary',
],
},
'freebsd' => {
'compilers' => ['clang++'],
'libpath' => 'LD_LIBRARY_PATH',
},
'lynxos-178' => {
'libpath' => 'LD_LIBRARY_PATH',
'no_host' => 1,
'aceplatform' => 'lynxos',
'compiler_root_env' => 'ENV_PREFIX',
'usage' => ['Set up the cross-compile using '.
'the script from LynxOS',
],
},
'vxworks' => {
'libpath' => 'LD_LIBRARY_PATH',
'no_host' => 1,
'usage' => ['Use the wrenv script before running configure',
'Specify the VSB with --macros=VSB_DIR=<dir>',
],
},
'android' => {
'libpath' => 'LD_LIBRARY_PATH',
'aceplatform' => 'android',
'aceconfig' => 'android',
'no_host' => 1,
'usage' => [
"Use --macros=ANDROID_ABI=<ARCH> to specify the target archtecture.",
"Defaults to armeabi-v7a which is 32-bit ARMv7.",
"See docs/android.md for details.",
],
'needs_i2jrt_corba' => 1,
},
);
sub targetUsage {
my $status = shift;
print "Cross-compile targets: specify --target=TGT where TGT is one of:\n";
for my $k (sort keys %platforminfo) {
if ($platforminfo{$k}->{'no_host'}) {
print "\t$k\n";
if ($platforminfo{$k}->{'usage'}) {
for my $line (@{$platforminfo{$k}->{'usage'}}) {
print "${targetUsageIndent}$line\n";
}
}
}
}
exit $status;
}
## arg processing and usage
my $argPadding = 29;
my $argIndent = "\n " . (' ' x $argPadding);
my @specs = # Array of array-refs, each inner array is an option group which
# has the format [Group Description, Opt1 Spec, Opt1 Description,
# Opt2 Spec, Opt2 Description, ...]
# <default>OPT is a custom token marking a string option that
# defaults to $opts{'OPT'} = '' and can be overridden by opts by passing
# --no-OPT or --OPT with a value.
(
['Options controlling the configure script:',
'help|h|?', 'Show this help and exit',
'target-help', 'Show details of cross-compile target configs',
'verbose|v', 'Trace script execution',
'dry-run|n', 'Don\'t do anything',
'backup!', 'Make backup of build configuration files (yes)',
],
['Build platform and compiler:',
'host=s', 'Host (auto detect: linux, win32, solaris, macosx)',
'compiler=s', 'Compiler (auto detect / guess by searching PATH)',
'std=s', 'C++ standard version (for compilers that use -std)',
'target=s', 'Cross-compile target (none): see --target-help',
'target-compiler=s', 'Compiler for target (if req\'d): see --target-help',
'host-tools=s', 'DDS_ROOT of host tools for cross compile' .
$argIndent . '(build them)',
'host-tools-only!', 'Just build the host tools (no)',
'prefix=s', 'Installation prefix (none)',
],
['Build flags:',
'debug!', 'Debugging (yes)',
'optimize!', 'Optimization (no)',
'inline!', 'Inlining (yes)',
'static!', 'Static libraries (no)',
'ipv6!', 'IPv6 support (no)',
],
['Required dependencies for OpenDDS:',
'ace=s', 'ACE (use ACE_ROOT, ACE_wrappers, or download)',
'tao=s', 'TAO (use TAO_ROOT, ACE_ROOT/TAO, or download)',
'mpc=s', 'MPC (use MPC_ROOT, ACE_ROOT/MPC, or download)',
'doc-group|doc_group!', 'Use the DOC Group release of TAO',
'ace-github-latest!', 'Clone latest ACE/TAO/MPC from GitHub',
],
['Advanced configuration:',
'configh=s@', 'Extra text for config.h',
'macros=s@', 'Extra text for platform_macros.GNU',
'features=s@', 'Extra text for default.features',
'mpcopts=s@', 'Extra command-line args for MPC',
],
['Optional dependencies for OpenDDS (disabled by default unless noted otherwise):',
'java:s', 'Java development kit (use JAVA_HOME)',
'jboss:s', 'JBoss application server (use JBOSS_HOME)',
'ant:s', 'Ant for JBoss (use ANT_HOME or system pkg)',
'wireshark:s',
'Wireshark dev headers or source not built with' .
$argIndent . 'CMake (use WIRESHARK_SRC or system pkg)' .
$argIndent . 'Implies --glib',
'wireshark-cmake|wireshark_cmake:s',
'Wireshark source built with CMake, requires' .
$argIndent . '--wireshark-build. Requires --wireshark-lib if' .
$argIndent . 'guessing fails (use WIRESHARK_SRC)' .
$argIndent . 'Implies --glib',
'wireshark-build|wireshark_build=s', 'Wireshark CMake Build Location',
'wireshark-lib|wireshark_lib=s',
'Optional Wireshark CMake libraries location' .
$argIndent .'relative to wireshark-build (guesses)',
'glib:s', 'GLib for Wireshark (use GLIB_ROOT or system pkg)',
'<default>rapidjson:s',
'RapidJSON for Wireshark dissector and JSON' .
$argIndent . 'Sample Serialization (Enabled by default,' .
$argIndent . 'use git submodle, RAPIDJSON_ROOT, or system pkg)',
'qt:s', 'Qt5 (use QTDIR or system pkg)',
'qt-include:s', 'Qt include dir (use QT5_INCDIR, QTDIR/include,' .
$argIndent . 'or sysytem package)',
'boost:s', 'Boost (use BOOST_ROOT or system pkg)',
'boost-version:s', 'Boost version (only if needed to find headers)',
'xerces3:s', 'Xerces-C++ 3 for QoS XML handling, DDS Security',
'openssl:s', 'OpenSSL for DDS Security',
'cmake:s', 'Path to cmake binary for compiling Google Test' .
$argIndent . 'Framework. (Check Path and Check Normal' .
$argIndent . 'Locations)',
'gtest:s', 'Path to Google Test Framework, required for' .
$argIndent . 'tests (uses GTEST_ROOT or system package)',
],
['Optional OpenDDS features:',
'built-in-topics!', 'Built-in Topics (yes)',
'content-subscription!', 'Content-Subscription Profile (yes)',
'content-filtered-topic!', 'ContentFilteredTopic (CS Profile) (yes)',
'multi-topic!', 'MultiTopic (CS Profile) (yes)',
'query-condition!', 'QueryCondition (CS Profile) (yes)',
'ownership-profile!', 'Ownership Profile (yes)',
'ownership-kind-exclusive!', 'Exclusive Ownership (Ownership Profile) (yes)',
'object-model-profile!', 'Object Model Profile (yes)',
'persistence-profile!', 'Persistence Profile (yes)',
'safety-profile:s', 'Safety Profile: base or extended (none)',
'tests!', 'Build tests, examples, and performance tests' .
$argIndent . '(yes) Implies --gtest as tests require Google' .
$argIndent . 'Test and --cmake',
'security!', 'DDS Security plugin (no) Implies --openssl and' .
$argIndent . '--xerces3',
],
);
sub iterate {
my $callback = shift;
for my $group (@specs) {
for my $n (1 .. (scalar @{$group} / 2)) {
my $opt = ${$group}[$n * 2 - 1];
my $descr = ${$group}[$n * 2];
$opt =~ /(\<\w+\>)?([\w-]+)/;
my $optkey = (defined $1 ? $1 : "") . $2;
&$callback(${$group}[0], $opt, $descr, $optkey, @_);
}
}
}
sub usage {
my $status = shift;
my $current;
my $ver;
open VER, 'dds/Version.h' or die "ERROR: can't open dds/Version.h, stopped";
while (<VER>) {
$ver = $1 if /#define DDS_VERSION "([^"]+)"/;
}
close VER;
print <<"EOT";
Welcome to OpenDDS version $ver
Options for this script are listed below, with the default behavior described
in parenthesis after the option description.
Boolean options can take the form "--opt" or "--no-opt", the more commonly
needed one (the one that changes the default behavior) is shown below.
Options that require arguments are shown as "--opt=VAL" Options with optional
arguments are shown as "--opt[=VAL]". Options that can be repeated with
cumulative effect are shown with a trailing "...". Some third-party
optional dependencies can be automatically located if they are installed in the
expected locations (see entries below marked with "system pkg"). In those
cases, specify the option as --opt without an = to enable the corresponding
feature in OpenDDS and use the default installation location.
EOT
iterate(sub {
my ($group, $opt, $descr, $optkey) = @_;
if (!defined $current || $group ne $current) {
$current = $group;
print "\n$group\n";
}
$optkey .= '=VAL' if $opt =~ /=s/;
$optkey .= '[=VAL]' if $opt =~ /:s/;
$optkey = "[no-]$optkey" if ($opt =~ /!$/ && $descr =~ / \(yes\)/);
$optkey =~ s/^\<default\>(.*)$/\[no-\]$1/g;
$optkey .= '...' if $opt =~ /s\@$/;
my $pad = $argPadding - length $optkey;
print "--$optkey" . ' ' x (($pad > 0) ? $pad : 0) . " $descr\n";
}
);
exit $status;
}
my $defaulted = {};
sub parseArgs {
my @getopts = ();
my @default = ();
iterate(sub {
my ($group, $opt, $descr, $optkey) = @_;
if ($opt =~ /^<default>(.*)$/) {
push @getopts, $1;
$optkey =~ /^<default>(.*)$/;
push @getopts, "no-$1";
push @default, $1;
}
else {
push @getopts, $opt;
}
}
);
if (! -r 'rules.dds.GNU') {
print "ERROR: this script must be run from its own directory\n";
exit 1;
}
my $opts = {};
GetOptions($opts, @getopts) or usage(1);
usage(0) if $opts->{'help'};
targetUsage(0) if $opts->{'target-help'};
if ($opts->{'verbose'}) {
print "Options:\n";
new Dumpvalue()->dumpValue($opts);
}
for my $opt (@default) {
if (!exists $opts->{$opt} && !exists $opts->{"no-$opt"}) {
$opts->{$opt} = '';
$defaulted->{$opt} = 1;
print("By default, --$opt is added to the options\n") if $opts->{'verbose'};
}
}
return $opts;
}
my $cross_compile = 0;
my %opts = %{parseArgs()};
my $debug = exists $opts{'debug'} ? $opts{'debug'} : 1;
my $backup = exists $opts{'backup'} ? $opts{'backup'} : 1;
$opts{'host'} = perlOS_to_host() unless $opts{'host'};
my $is_windows = $opts{'host'} eq 'win32';
my ($slash, $exeext) = $is_windows ? ('\\', '.exe') : ('/', '');
my %specific =
($slash eq '/' ?
('ext' => 'sh', 'export' => 'export', 'pathsep' => ':', 'refpre' => '${',
'refpost' => '}', 'comment' => '#') :
('ext' => 'cmd', 'export' => 'set', 'pathsep' => ';', 'refpre' => '%',
'refpost' => '%', 'comment' => '::')
);
sub which {
my $file = shift;
for my $p (File::Spec->path()) {
next if $p eq '.';
if (-x "$p/$file") {
return "$p/$file";
}
elsif ($exeext ne '' && -x "$p/$file$exeext") {
return "$p/$file$exeext";
}
}
return undef;
}
sub addCurLibPathRef {
my $buildEnvRef = shift;
my $platform = $opts{$buildEnvRef->{'build'}};
my $libpathname = $platforminfo{$platform}->{'libpath'};
my $curLibPathRef = $specific{'refpre'} . $libpathname . $specific{'refpost'};
$buildEnvRef->{$libpathname} = $curLibPathRef;
}
my $curpathRef = $specific{'refpre'} . 'PATH' . $specific{'refpost'};
my %hostEnv = ('build' => 'host', 'PATH' => $curpathRef);
my %targetEnv = ('build' => 'target', 'PATH' => $curpathRef);
my $would_download; # can dry-run assume directories that don't exist yet?
sub locate_mpc {
my $ace_src = shift;
if (defined $opts{'mpc'}) {
setEnv('MPC_ROOT', $opts{'mpc'});
}
elsif (!$ENV{'MPC_ROOT'} && (-r $ace_src . '/MPC/MPC.ico'
|| ($opts{'dry-run'} && $would_download))) {
setEnv('MPC_ROOT', $ace_src . $slash . 'MPC');
}
elsif (!$ENV{'MPC_ROOT'}) {
die "ERROR: Can't find MPC. Please set MPC_ROOT or make sure MPC exists".
"\n in the 'MPC' directory under ACE_ROOT ($ace_src), stopped";
}
else {
$targetEnv{'MPC_ROOT'} = $ENV{'MPC_ROOT'};
}
$hostEnv{'MPC_ROOT'} = $targetEnv{'MPC_ROOT'};
}
if (!exists $platforminfo{$opts{'host'}} ||
$platforminfo{$opts{'host'}}->{'no_host'}) {
die "ERROR: unknown host $opts{'host'}, stopped";
}
print "host system is: $opts{'host'}\n" if $opts{'verbose'};
$opts{'target'} = $opts{'host'} unless $opts{'target'};
if (!exists $platforminfo{$opts{'target'}}) {
die "ERROR: unknown target $opts{'target'}, stopped";
}
# Set initial libpath
addCurLibPathRef(\%hostEnv);
addCurLibPathRef(\%targetEnv);
if (defined $opts{'safety-profile'} && $opts{'safety-profile'} eq '') {
print "Defaulting safety profile to extended\n";
$opts{'safety-profile'} = 'extended';
}
my $build_host_tools;
if ($opts{'host'} ne $opts{'target'} || $opts{'safety-profile'}) {
$build_host_tools = !$opts{'host-tools'};
print "Cross-compile build " .
($build_host_tools ? 'including' : 'excluding') . " host tools\n"
if $opts{'verbose'};
$cross_compile = 1;
}
if ($platforminfo{$opts{'target'}}->{'compiler_root_env'}) {
# This target puts its cross-compiler in the PATH before the host compiler,
# we will need to override (not append to) PATH for the host build.
my $root_env = $platforminfo{$opts{'target'}}->{'compiler_root_env'};
my $root_dir = $ENV{$root_env};
my @oldpath = split /$specific{'pathsep'}/, $ENV{'PATH'};
my $newpath = join($specific{'pathsep'}, grep {!/^$root_dir/} @oldpath);
$hostEnv{'PATH'} =~
s/\Q$specific{'refpre'}\EPATH\Q$specific{'refpost'}\E/$newpath/;
}
if (!exists $platforminfo{$opts{'target'}}->{'needs_i2jrt_corba'}) {
$platforminfo{$opts{'target'}}->{'needs_i2jrt_corba'} = 0;
}
## compiler
if ($opts{'compiler'}) {
my $standard = 0;
for my $stdcomp (@{$platforminfo{$opts{'host'}}->{'compilers'}}) {
$standard = 1 if $opts{'compiler'} eq $stdcomp;
}
$opts{'nonstdcompiler'} = 1 unless $standard;
}
else {
print "Auto-detecting compiler\n" if $opts{'verbose'};
for my $stdcomp (@{$platforminfo{$opts{'host'}}->{'compilers'}}) {
my $path = which($stdcomp);
if ($path) {
print "Found $stdcomp at: $path\n" if $opts{'verbose'};
$opts{'compiler'} = $stdcomp;
last;
}
}
if (!defined $opts{'compiler'}) {
die "ERROR: Can't find a compiler, set PATH or run this script with the ".
"--compiler option.\n" . ($is_windows ? " For Microsoft Visual C++, ".
"run this script from the Visual Studio ".
"Command Prompt.\n" : '') . "Stopped";
}
}
print "compiler is: $opts{'compiler'}\n" if $opts{'verbose'};
if ($opts{'compiler'} =~ /cl(\.exe)?$/i) {
my $savepath = $ENV{'PATH'};
my $clpath = which($opts{'compiler'});
if ($clpath) {
$clpath =~ s/vc\\bin(\\(x86_)?amd64)?/common7\\ide/i;
$ENV{'PATH'} .= ";$clpath";
}
# Have CL Tell Us Its Target Architecture and Version
my ($tmp_fd, $tmp_filename) = File::Temp::tempfile();
my $cl_check = << "EOF";
#ifdef _M_X64
# define ARCH x64
#elif defined(_M_IX86)
# define ARCH Win32
#elif defined(_M_ARM64)
# define ARCH ARM64
#elif defined(_M_ARM)
# define ARCH ARM
#else
# define ARCH Unknown
#endif
CL is _MSC_VER ARCH
EOF
print $tmp_fd $cl_check;
close($tmp_fd);
my $cl_command = "\"$opts{'compiler'}\" /EP $tmp_filename 2>&1";
print "Running $cl_command\n" if $opts{'verbose'};
open(my $cl_out_fd, "-|", $cl_command)
or die "ERROR: Could not detect Visual C++ version, try running this ".
"script from the Visual Studio Command Prompt.\nStopped";
my $ver = 0;
my $arch = '';
while (my $line = <$cl_out_fd>) {
chomp ($line);
print "CL says: $line\n" if $opts{'verbose'};
# Convert _MSC_VER to the form \d+\.\d
if ($line =~ /^CL is (\d+)\d (\w+)$/) {
$ver = int($1) / 10;
$arch = $2;
last;
}
}
close($cl_out_fd);
unlink($tmp_filename)
or warn "Unable to delete temporary file $tmp_filename: $!";
print "CL Version is $ver, architecture is $arch\n" if $opts{'verbose'};
if (!$ver && !$arch) {
die "cl version probe failed, invalid output from cl\nStopped";
}
if ($arch eq 'Unknown') {
die "cl version probe failed, no known architecture macro was defined\nStopped";
}
if (!exists $platforminfo{'win32'}->{'cl_archs'}->{$arch}) {
die "cl version probe failed, invalid architecture \"$arch\"\nStopped";
}
if (!$platforminfo{'win32'}->{'cl_archs'}->{$arch}) {
die "ERROR: Windows for $arch isn't supported\nStopped";
}
if (!exists $platforminfo{'win32'}->{'cl_versions'}->{$ver}) {
die "ERROR: Unknown or unsupported Visual C++ compiler version: $ver\n"
. "Stopped";
}
$opts{'compiler_version'} = $platforminfo{'win32'}->{'cl_versions'}->{$ver};
$opts{'compiler_target_architecture'} = $arch;
if ($ver >= 19) {
push(@{$opts{'features'}}, 'no_cxx11=0');
print "Visual C++ has C++11 support\n" if $opts{'verbose'};
}
$ENV{'PATH'} = $savepath;
print "Detected Visual C++ version: $opts{'compiler_version'}\n"
if $opts{'verbose'};
}
elsif ($opts{'compiler'} =~ /g\+\+/) {
if ($opts{'std'}) {
push(@{$opts{'macros'}}, 'CCFLAGS += -std=' . $opts{'std'});
print "Added platform_macros for -std=$opts{std}\n" if $opts{'verbose'};
}
else {
my $ver = `$opts{'compiler'} --version`;
if ($ver =~ /\(.*\) (\d+)\.\d+/ && $1 >= 6) {
$opts{'std'} = 'gnu++14';
print "Detected GCC >=6, default -std=gnu++14\n" if $opts{'verbose'};
}
}
if ($opts{'std'} && $opts{'std'} =~ /(0x|11|1y|14|1z|17)$/) {
push(@{$opts{'features'}}, 'no_cxx11=0');
print "Compiler has C++11 support\n" if $opts{'verbose'};
}
}
sub looksRelative {
my $val = shift;
return substr($val, 0, 1) ne $slash && ($slash eq '/' || $val !~ /^[a-z]:/i);
}
sub normalizePath {
my $val = shift;
return Cwd::abs_path($val) if $val && -d $val && $val =~ /../;
return $val;
}
sub setSomeEnv {
my($hashref, $name, $val, $notdir) = @_;
$val = Cwd::abs_path($val) if -d $val;
if ($opts{'dry-run'} && !$notdir && looksRelative($val)) {
$val = getcwd . $slash . $val;
}
$val =~ s!/!\\!g if $is_windows;
$hashref->{$name} = $val;
}
sub setEnv {
setSomeEnv(\%targetEnv, @_);
}
sub setHostEnv {
setSomeEnv(\%hostEnv, @_);
}
## ace
my $ace_src;
if ($opts{'ace'}) {
if ($opts{'ace'} ne 'download') {
if (!-r $opts{'ace'} . '/ace/ACE.h') {
die "ERROR: Can't find ACE at $opts{'ace'}.\nStopped";
}
$ace_src = $opts{'ace'};
}
}
elsif ($ENV{'ACE_ROOT'}) {
if (!-r $ENV{'ACE_ROOT'} . '/ace/ACE.h') {
die "ERROR: Can't find ACE at $ENV{'ACE_ROOT'}.\nStopped";
}
$ace_src = $ENV{'ACE_ROOT'};
}
elsif (-r '../ACE_wrappers/ace/ACE.h') {
die "ERROR: Older versions of this script would default to using ACE at " .
"../ACE_wrappers, but this version doesn't. Use the --ace command line " .
"option to override this error. Use --ace=download to have this script " .
"download an ACE+TAO package and expand it to ACE_wrappers.\nStopped";
}
elsif (-r 'ACE_wrappers/ace/ACE.h') {
$ace_src = 'ACE_wrappers';
}
elsif (-r 'ATCD/ACE/ace/ACE.h') {
$ace_src = 'ATCD/ACE';
}
elsif (-r 'ACE_TAO/ACE/ace/ACE.h') {
$ace_src = 'ACE_TAO/ACE';
}
$ace_src = normalizePath($ace_src);
## tao
my $tao_src;
if ($opts{'tao'}) {
if (!-r $opts{'tao'} . '/tao/ORB.h') {
die "ERROR: Can't find TAO at $opts{'tao'}.\nStopped";
}
$tao_src = $opts{'tao'};
}
elsif ($ENV{'TAO_ROOT'}) {
if (!-r $ENV{'TAO_ROOT'} . '/tao/ORB.h') {
die "ERROR: Can't find TAO at $ENV{'TAO_ROOT'}.\nStopped";
}
$tao_src = $ENV{'TAO_ROOT'};
}
elsif (defined $ace_src && -r $ace_src . '/TAO/tao/ORB.h') {
$tao_src = $ace_src . $slash . 'TAO';
}
elsif (defined $ace_src && -r $ace_src . '/../TAO/tao/ORB.h') {
$tao_src = (File::Spec->splitpath($ace_src))[1] .'TAO';
}
$tao_src = normalizePath($tao_src);
if ($opts{'safety-profile'}) {
# convert to lower case
$opts{'safety-profile'} = lc($opts{'safety-profile'});
}
## Download ACE+TAO
if (!$ace_src || !$tao_src) {
if ($opts{'ace-github-latest'}) {
die "ERROR: Git not found in path (required to clone ACE/TAO/MPC)"
if ! which('git');
my $urlbase = 'https://github.com/DOCGroup';
print "Cloning git repo: $urlbase/ACE_TAO\n";
my $err = system("git clone -q --depth 1 $urlbase/ACE_TAO");
die 'ERROR: Failed to clone ACE/TAO from GitHub'
if $err ||
! -r 'ACE_TAO/ACE/ace/ACE.h' ||
! -r 'ACE_TAO/TAO/tao/ORB.h';
my $cur_dir = getcwd;
chdir('ACE_TAO');
system('git --no-pager log -1 --oneline');
chdir($cur_dir);
print "Cloning git repo: $urlbase/MPC into ACE_TAO/ACE/MPC\n";
$err = system("git clone -q --depth 1 $urlbase/MPC ACE_TAO/ACE/MPC");
die 'ERROR: Failed to clone MPC (into ACE_TAO/ACE/MPC) from GitHub'
if $err ||
! -r 'ACE_TAO/ACE/MPC/mwc.pl';
chdir('ACE_TAO/ACE/MPC');
system('git --no-pager log -1 --oneline');
chdir($cur_dir);
$ace_src = normalizePath('ACE_TAO/ACE');
$tao_src = normalizePath('ACE_TAO/TAO');
}
else {
my($urlbase, $file, $download_message);
if ($opts{'doc-group'}) {
my $github_url_tao_version = $doc_tao_version;
$github_url_tao_version =~ s/\./_/g;
$urlbase = 'https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-' . $github_url_tao_version . '/';
$file = 'ACE+TAO-src-' . $doc_tao_version . '.'
. ($is_windows ? 'zip' : 'tar.gz');
$download_message = "Downloading $file";
}
else {
$urlbase = 'http://download.ociweb.com/TAO-' . $oci_tao_version . '/';
$file = 'ACE+TAO-' . $oci_tao_version . '_with_latest_patches_NO_makefiles.'
. ($is_windows ? 'zip' : 'tar.gz');
$download_message =
"Downloading ACE+TAO $oci_tao_version with latest patches";
}
if (-r $file) {
print "Using ACE+TAO source package $file\n" if $opts{'verbose'};
}
else {
$would_download = 1;
eval {
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->env_proxy;
print $download_message . "\n";
if ($opts{'dry-run'}) {
print "Dry-run: would LWP::UserAgent get $urlbase$file\n";
}
else {
my $response = $ua->get($urlbase . $file, ':content_file' => $file);
if ($response->is_error) {
die $response->message . "\nstopped";
}
}
};
if ($@) {
if (which('wget')) {
print $download_message . " (using wget)\n";
if ($opts{'dry-run'}) {
print "Dry-run: would run wget $urlbase$file\n";
}
elsif (system("wget $urlbase$file")) {
die "ERROR from wget, stopped";
}
}
elsif (which('curl')) {
print $download_message . " (using curl)\n";
if ($opts{'dry-run'}) {
print "Dry-run: would run curl -L $urlbase$file -o $file\n";
}
elsif (system("curl -L $urlbase$file -o $file")) {
die "ERROR: from curl, stopped";
}
}
else {
die "ERROR: Can't download ACE+TAO using LWP, wget, or curl.\n" .
"Download ACE+TAO from $urlbase$file, place the file here\n, " .
"and re-run the script.\nStopped";
}
}
}
print "Extracting archive $file\n";
$ENV{'ACTIVEPERL_CONFIG_DISABLE'} = 1 if $^O eq 'MSWin32';
$ENV{'ACTIVEPERL_CONFIG_SILENT'} = 1 if $^O eq 'MSWin32';
eval {require Archive::Extract;};
if ($@) {
my $err = 1;
my $ddsroot = getcwd;
if (!$is_windows) {
if ($opts{'dry-run'}) {
print "Dry-run: would run " . ($^O eq 'solaris' ? 'g' : '') .
"tar xzf $ddsroot/$file\n";
$err = 0;
}
else {
$err = system(($^O eq 'solaris' ? 'g' : '') . "tar xzf $ddsroot/$file");
}
}
else {
# Try Archive::Zip
print "Archive::Extract isn't installed, trying Archive::Zip\n" if $opts{'verbose'};
eval {require Archive::Zip};
if ($@) {
print "Neither Archive::Extract or Archive::Zip are installed\n" if $opts{'verbose'};
}
else {
if ($opts{'dry-run'}) {
print "Dry-run: would Archive::Zip $file\n";
}
else {
my $zip = Archive::Zip->new();
if ($zip->read( $file ) == Archive::Zip::AZ_OK() &&
$zip->extractTree() == Archive::Zip::AZ_OK()) {
$err = 0;
}
}
}
}
if ($err) {
die "ERROR: Can't extract $file, extract it to " . Cwd::abs_path('.') .
"\nand run this script again.\nStopped";
}
}
else {
if ($opts{'dry-run'}) {
print "Dry-run: would Archive::Extract $file\n";
}
else {
if ($^O ne 'MSWin32') {
no warnings 'once';
$Archive::Extract::PREFER_BIN = 1;
}
my $ae = Archive::Extract->new('archive' => $file);
if (!$ae->extract('to' => '.')) {
die $ae->error . "\nstopped";
}
}
}
unlink $file;
print "Removed $file\n" if $opts{'verbose'};
$ace_src = 'ACE_wrappers';
$tao_src = 'ACE_wrappers/TAO';
}
}
print "Using ace_src: $ace_src\n" if $opts{'verbose'};
print "Using tao_src: $tao_src\n" if $opts{'verbose'};
sub clone_host_and_target {
my $source_dir = shift;
locate_mpc($ace_src);
my $cur_dir = getcwd;
if ($source_dir ne '.') {
print "Changing dir to $source_dir\n" if $opts{'verbose'};
chdir($source_dir);
}
print "cloning build tree\n" if $opts{'verbose'};
if (!$opts{'dry-run'}) {
eval {
system("$targetEnv{'MPC_ROOT'}/clone_build_tree.pl host target");
};
}
if ($source_dir ne '.') {
print "Changing dir back to $cur_dir\n" if $opts{'verbose'};
chdir($cur_dir);
}
}
sub backup_and_open {
my $file = shift;
if (!$opts{'dry-run'} && -r $file) {
print "WARNING: overwriting existing $file\n";
if ($backup) {
my $backup_path = $file . '.bak';
$backup_path .= ".$backup_timestamp" if -e $backup_path;
copy($file, $backup_path);
print " (saved a backup copy as $backup_path)\n";
}
unlink $file;
}
if ($opts{'dry-run'}) {
return File::Temp->new();
}
my $fh = new FileHandle;
open $fh, ">$file" or die "ERROR: Can't write to $file, stopped";
return $fh;
}
sub dump_and_unlink { # removes temp files created by dry-run
my $tfile = shift;
if ($opts{'verbose'}) {
open TMP, $tfile;
print <TMP>;
close TMP;
}
unlink $tfile;
}
sub write_config_h {
my %buildEnv = %{shift()};
my $pi = $platforminfo{$opts{$buildEnv{'build'}}};
$opts{'optimize'} = 0 if !exists $opts{'optimize'};
my $CFGH = backup_and_open("$buildEnv{'ACE_ROOT'}/ace/config.h");
if ($buildEnv{'build'} eq 'target') {
for my $line (@{$opts{'configh'}}) {
print $CFGH "$line\n";
}
}
my $cfg = $opts{$buildEnv{'build'}};
if ($pi->{'aceconfig'}) {
$cfg = $pi->{'aceconfig'};
$cfg =~ s/\$UNAMER/my $u = `uname -r`; chomp $u; $u/e;
}
$cfg .= '-' . $opts{'host_version'} if $opts{'host_version'};
print $CFGH "#include \"ace/config-$cfg.h\"\n";
if (defined $opts{'no-opendds-safety-profile'}) {
print $CFGH "#define ACE_FACE_SAFETY_" . uc($opts{'safety-profile'}) . "\n";
if ($opts{'safety-profile'} eq 'extended') {
print $CFGH "#ifndef ACE_HAS_ALLOC_HOOKS\n";
print $CFGH "# define ACE_HAS_ALLOC_HOOKS\n";
print $CFGH "#endif\n";
}
}
close $CFGH;
print "Wrote $buildEnv{'ACE_ROOT'}/ace/config.h\n" if $opts{'verbose'};
dump_and_unlink($CFGH) if $opts{'dry-run'};
}
my $wrote_df = 0;
sub write_default_features {
my %buildEnv = %{shift()};
my @feat;
if ($buildEnv{'build'} eq 'target') {
push(@feat, 'ipv6=1') if $opts{'ipv6'};
push(@feat, @{$opts{'features'}}) if $opts{'features'};
}
elsif ($opts{'java'}) {
push(@feat, 'java=1');
}
if (@feat) {
my $DF = backup_and_open("$buildEnv{'ACE_ROOT'}/bin/MakeProjectCreator" .
"/config/default.features");
$wrote_df = 1;
for my $f (@feat) {
print $DF "$f\n";
}
$DF->close;
print "Wrote $buildEnv{'ACE_ROOT'}/.../default.features\n"
if $opts{'verbose'};
dump_and_unlink($DF) if $opts{'dry-run'};
}
}
my @ace_macros = ('debug',
'optimize',
'inline',
'static',
'ipv6');
my @platformmacros;
sub write_platform_macros {
my %buildEnv = %{shift()};
if (!$is_windows ||
($cross_compile && $buildEnv{'build'} eq 'target')) {
my $pi = $platforminfo{$opts{$buildEnv{'build'}}};
my $PMG = backup_and_open("$buildEnv{'ACE_ROOT'}/include/makeinclude" .
"/platform_macros.GNU");
my $macro_cross_compile = 0;
if ($buildEnv{'build'} eq 'target') {
for my $line (@{$opts{'macros'}}) {
print $PMG "$line\n";
}
for my $key (@ace_macros) {
if (exists $opts{$key}) {
my $macro = ($key eq 'static') ? 'static_libs_only' : $key;
print $PMG "$macro = $opts{$key}\n";
}
}
if ($cross_compile) {
print $PMG 'TAO_IDL = $(HOST_ACE)/bin/tao_idl', "\n";
print $PMG 'TAO_IDL_DEP = $(TAO_IDL)$(HOST_EXE_EXT)', "\n";
print $PMG 'TAO_IDL_PREPROCESSOR = ', $opts{'compiler'}, "\n";
print $PMG 'TAO_IDLFLAGS += -g $(HOST_ACE)/bin/ace_gperf', "\n";
print $PMG 'build_tao_idl_be = 0', "\n";
unless ($build_host_tools) {
print $PMG 'HOST_ACE = $(HOST_DDS)', nested($ace_src, '.'), "\n";
}
if ($opts{'target-compiler'}) {
my $tcomp = $opts{'target-compiler'};
if ($tcomp =~ s/-g([c+])\1$/-/) {
$macro_cross_compile = 1;
print $PMG 'CROSS_COMPILE = ', $tcomp, "\n";
}
else {
$opts{'nonstdcompiler'} = $tcomp;
print $PMG 'LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib', "\n";
}
}
}
}
for my $f (@platformmacros) {
print $PMG ($f =~ /=/ ? $f : "$f=1"), "\n";
}
if ($buildEnv{'build'} eq 'host') {
print $PMG "static_libs_only = 1\n";
print $PMG "java = 1\n" if $opts{'java'};
}
if ($opts{'prefix'}) {
print $PMG "INSTALL_PREFIX=" . $opts{'prefix'} . "\n";
}
my $plat = $opts{$buildEnv{'build'}};
if ($pi->{'aceplatform'}) {
$plat = $pi->{'aceplatform'};