forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1835 lines (1633 loc) · 58.3 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;
require File::Temp;
use File::Temp ();
use FileHandle;
use Cwd;
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.1';
# 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 %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'},
},
'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>',
],
},
);
sub targetUsage {
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 "\t\t$line\n";
}
}
}
}
exit 1;
}
## arg processing and usage
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, ...]
(
['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',
],
['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',
'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!', 'Use the DOC Group release of TAO',
],
['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 (if MPC is run)',
],
['Optional dependencies for OpenDDS:',
'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 source, "non-CMake" based (use WIRESHARK_SRC)',
'wireshark_cmake:s', 'Wireshark built with CMake, requires wireshark_build and wireshark_lib (use WIRESHARK_SRC)',
'wireshark_build:s', 'Wireshark CMake Build Location',
'wireshark_lib:s', 'Wireshark CMake libraries location, relative to wireshark_build',
'glib:s', 'GLib for Wireshark (use GLIB_ROOT or system pkg)',
'rapidjson:s', 'RapidJSON for Wireshark Sample Dissection (optional)',
'qt:s', 'Qt (use QTDIR or system pkg)',
'qt-include:s', 'Qt include dir (use QT4_INCDIR or QTDIR/include)',
'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 (optional)',
'openssl:s', 'OpenSSL for DDS Security (optional)',
'cmake:s', 'Path to cmake binary for compiling Google Test Framework (optional)',
'gtest:s', 'Path to Google Test Framework (optional)',
],
['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 (yes)',
'security!', 'DDS Security plugin (no)',
],
);
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];
my ($optkey) = ($opt =~ /([\w-]+)/);
&$callback(${$group}[0], $opt, $descr, $optkey, @_);
}
}
}
sub usage {
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 .= '...' if $opt =~ /s\@$/;
my $pad = 27 - length $optkey;
print "--$optkey" . ' ' x (($pad > 0) ? $pad : 0) . " $descr\n";
}
);
exit 1;
}
sub parseArgs {
my @getopts = ();
iterate(sub {
my ($group, $opt, $descr, $optkey) = @_;
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();
usage() if $opts->{'help'};
targetUsage() if $opts->{'target-help'};
if ($opts->{'verbose'}) {
print "Options:\n";
new Dumpvalue()->dumpValue($opts);
}
return $opts;
}
my $cross_compile = 0;
my %opts = %{parseArgs()};
$opts{'host'} = perlOS_to_host() unless $opts{'host'};
my ($slash, $exeext) = ($opts{'host'} eq 'win32') ? ('\\', '.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()) {
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';
}
if ($opts{'host'} ne $opts{'target'} || $opts{'safety-profile'}) {
print "Setting cross-compile build\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/;
}
## 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" . ($slash eq '\\' ? " 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";
}
open(CL, "\"$opts{'compiler'}\" /v 2>&1 |");
while (<CL>) {
if (/version (\d+)\.(\d+)\.[\d]+ for (x\d+)/i) { # match i18n version strings
my $ver = ($2 == 0) ? $1 : "$1.$2";
my $arch = "$3";
$ver =~ s/0+$// unless $2 == 0;
$ver =~ s/\.(\d)\d*/.$1/; # only keep one digit after .
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'};
}
last;
}
}
close CL;
if (!$opts{'compiler_version'}) {
die "ERROR: Could not detect Visual C++ version, try running this script ".
"from the Visual Studio Command Prompt.\nStopped";
}
$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|0y|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 $slash eq '\\';
$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) {
my $urlbase;
my $file;
my $download_message;
if ($opts{'doc_group'}) {
$urlbase = 'http://download.dre.vanderbilt.edu/previous_versions/';
$file = 'ACE+TAO-src-' . $doc_tao_version . '.'
. ($slash eq '/' ? 'tar.gz' : 'zip');
$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.'
. ($slash eq '/' ? 'tar.gz' : 'zip');
$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 $urlbase$file -o $file\n";
}
elsif (system("curl $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 ($slash eq '/') {
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) {
my $backup = (-e $file . '.bak') ? ($file . '.bak') : $file . ".bak.$$";
copy($file, $backup);
print "WARNING: overwriting existing $file (saved a backup copy as " .
"$backup)\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 ($slash eq '/' ||
($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)', "\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";
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'};
$plat =~ s/\$COMP/($opts{'compiler'} =~ m!CC!) ? 'sunc++' : 'g++'/e;
$plat =~ s/\$NONSTDCOMP/($opts{'compiler'} =~ m!clang!) ? 'clang' : ''/e;
$plat =~ s/_$//;
}
$plat .= '_' . $opts{'host_version'} if $opts{'host_version'};
print $PMG "include \$(ACE_ROOT)/include/makeinclude/platform_$plat.GNU\n";
if ($opts{'nonstdcompiler'} && !$macro_cross_compile) {
for my $var ('CC', 'CXX', 'LD') {
print $PMG "$var = $opts{'compiler'}\n";
}
}
$PMG->close;
print "Wrote $buildEnv{'ACE_ROOT'}/.../platform_macros.GNU\n"
if $opts{'verbose'};
dump_and_unlink($PMG) if $opts{'dry-run'};
}
}
## Optional OpenDDS dependencies
my %optdep =
# %opts key => [env var, sanity check, MPC feature]
('java' => ['JAVA_HOME', 'include/jni.h', 'java'],
'jboss' => ['JBOSS_HOME', 'lib/jboss-common.jar'],
'ant' => ['ANT_HOME', 'bin/ant'],
'wireshark' => ['WIRESHARK_SRC', 'epan/packet.h', 'wireshark'],
'wireshark_cmake' =>['WIRESHARK_SRC', 'epan/packet.h', 'wireshark_cmake'],
'wireshark_build' =>
['WIRESHARK_BUILD', 'config.h'],
'wireshark_lib' =>
['WIRESHARK_LIB'],
'glib' => ['GLIB_ROOT', 'include/glib-2.0/glib.h'],
'rapidjson' => ['RAPIDJSON_ROOT', 'include/rapidjson/rapidjson.h', 'no_itl=0'],
'qt' => ['QTDIR', '', 'qt4'],
'boost' => ['BOOST_ROOT', 'include/boost/version.hpp', 'boost'],
'xerces3' => ['XERCESCROOT', 'include/xercesc/dom/DOM.hpp', 'xerces3'],
'openssl' => ['SSL_ROOT', 'include/openssl/opensslv.h', 'ssl'],
);
# Use this to check if tests are enabled (instead of $opts{'tests'} directly).
my $tests = !exists $opts{'tests'} || $opts{'tests'};
my @ace_features = ('xerces3');
if (exists $opts{'java'}) {
if ($opts{'static'}) {
die "ERROR: --static can't be used with --java\nStopped";
}
setEnv('JAVA_PLATFORM', perlOS_to_java_platform());
}
$opts{'qt'} = '' if exists $opts{'qt-include'} && !exists $opts{'qt'};
$opts{'boost'} = '' if exists $opts{'boost-version'} && !exists $opts{'boost'};
# Default to Wireshark Development Package if installed and a path wasn't
# supplied.
my $wireshark_install = '/usr/include/wireshark';
if (exists $opts{'wireshark'} && !defined $ENV{'WIRESHARK_SRC'} && $opts{'wireshark'} eq '') {
if (-d $wireshark_install) {
$opts{'wireshark'} = $wireshark_install;
} else {
die "ERROR: --wireshark must be given a value because there is not a " .
"development package installed at " . $wireshark_install . ", stopped";
}
}
my $wireshark_lib_defaulted = 0;
if (exists $opts{'wirehshark_cmake'} && !exists $opts{'wireshark_lib'}) {
if ($^O =~ /MSWin32/) {
$opts{'wirehshark_lib'} = "run\\RelWithDebInfo";
} elsif ($^O =~ /darwin/) {
$opts{'wirehshark_lib'} = "run/Wireshark.app/Contents/Frameworks";
} elsif ($^O =~ /linux/) {
$opts{'wirehshark_lib'} = "";
} else {
die "ERROR: --wireshark_lib is needed because we couldn't decide on a default value";
}
$wireshark_lib_defaulted = 1;
}
if ($opts{'security'}) {
unless (exists $opts{'openssl'}) {
$opts{'openssl'} = '';
print "Forcing --openssl (security dependency)\n" if $opts{'verbose'};
}
unless (exists $opts{'xerces3'}) {
$opts{'xerces3'} = '';
print "Forcing --xerces3 (security dependency)\n" if $opts{'verbose'};
}
if ($tests) {
unless (exists $opts{'gtest'}) {
$opts{'gtest'} = '';
print "Forcing --gtest (security tests dependency)\n" if $opts{'verbose'};
}
# CMake is required in order to compile the Google Test Framework.
unless ($opts{'cmake'}) {
print "--cmake not specified by user; searching path...\n" if $opts{'verbose'};
$opts{'cmake'} = which('cmake');
unless ($opts{'cmake'}) {
print "CMake not found in path; searching default location...\n"
if $opts{'verbose'};
my $cmake_default =
(is_windows() ?
(-f $ENV{'ProgramFiles'} . '\\CMake\\bin\\cmake.exe' ?
$ENV{'ProgramFiles'} . '\\CMake\\bin\\cmake.exe' :
$ENV{'ProgramFiles(x86)'} . '\\CMake\\bin\\cmake.exe') :
'/usr/bin/cmake');
$opts{'cmake'} = $cmake_default;
}
}
die "ERROR: CMake program does not exist..." unless -f $opts{'cmake'};
print "Using CMake '$opts{'cmake'}' to compile Google Test Framework\n"
if $opts{'verbose'};
}
}
sub targets_win64 {
my $arch = exists $opts{'compiler_target_architecture'} ?
$opts{'compiler_target_architecture'} : '';
return $arch eq 'x64';
}
sub system_default_install_dir {
if (is_windows()) {
# When the host is 32-bit.
return $ENV{'ProgramFiles'}
if ! exists $ENV{'ProgramFiles(x86)'};
return targets_win64() ? $ENV{'ProgramFiles'} : $ENV{'ProgramFiles(x86)'};
}
return '/usr';
}
if (exists $opts{'gtest'}) {
my $sanity = 'include/gtest/gtest.h';
if ($opts{'gtest'}) {
die "ERROR: '$sanity' not found in supplied gtest directory '$opts{'gtest'}'"
if ! -f File::Spec->catfile($opts{'gtest'}, $sanity);
# It is expected that the user has already compiled gtest since
# they have a custom location in mind...
$opts{'gtest-precompiled'} = 1;
env_from_opt('gtest', 'GTEST_ROOT');
} else {
my $sm_dir = Cwd::abs_path('./tests/googletest');
my $sm_src = File::Spec->catdir($sm_dir, 'googletest');
my $sys_dir = File::Spec->catdir((system_default_install_dir(),
is_windows() ? 'googletest-distribution' : ''));
if (-f File::Spec->catfile($sm_src, $sanity)) {
$opts{'gtest-precompiled'} = 0;
$opts{'gtest'} = $sm_dir;
# No need to set env. variable with submodule.
} elsif (-f File::Spec->catfile($sys_dir, $sanity)) {
$opts{'gtest-precompiled'} = 1;
$opts{'gtest'} = $sys_dir;
env_from_opt('gtest', 'GTEST_ROOT');
}