-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.pl
executable file
·1210 lines (993 loc) · 38.1 KB
/
autogen.pl
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
#
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
use strict;
use Cwd;
use File::Basename;
use File::Find;
use Data::Dumper;
use Getopt::Long;
#
# Global variables
#
# The m4 file we'll write at the end
my $m4_output_file = "config/autogen_found_items.m4";
my $m4;
# Sanity check file
my $topdir_file = "opal/include/opal_config_bottom.h";
my $dnl_line = "dnl ---------------------------------------------------------------------------";
# Data structures to fill up with all the stuff we find
my $mca_found;
my $mpiext_found;
my $mpicontrib_found;
my @subdirs;
# Command line parameters
my $no_ompi_arg = 0;
my $no_orte_arg = 0;
my $quiet_arg = 0;
my $debug_arg = 0;
my $help_arg = 0;
my $platform_arg = 0;
my $include_arg = 0;
my $exclude_arg = 0;
# Include/exclude lists
my $include_list;
my $exclude_list;
# Minimum versions
my $ompi_automake_version = "1.11.1";
my $ompi_autoconf_version = "2.65";
my $ompi_libtool_version = "2.2.6b";
# Search paths
my $ompi_autoconf_search = "autoconf";
my $ompi_automake_search = "automake";
my $ompi_libtoolize_search = "libtoolize;glibtoolize";
# One-time setup
my $username;
my $hostname;
my $full_hostname;
# Patch program
my $patch_prog = "patch";
# Solaris "patch" doesn't understand unified diffs, and will cause
# autogen.pl to hang with a "File to patch:" prompt. Default to Linux
# "patch", but use "gpatch" on Solaris.
if ($^O eq "solaris") {
$patch_prog = "gpatch";
}
$username = getpwuid($>);
$full_hostname = `hostname`;
chomp($full_hostname);
$hostname = $full_hostname;
$hostname =~ s/^([\w\-]+)\..+/\1/;
##############################################################################
sub verbose {
print @_
if (!$quiet_arg);
}
sub debug {
print @_
if ($debug_arg);
}
sub debug_dump {
my $d = new Data::Dumper([@_]);
$d->Purity(1)->Indent(1);
debug $d->Dump;
}
##############################################################################
sub read_config_params {
my ($filename, $dir_prefix) = @_;
my $dir = dirname($filename);
open(FILE, $filename) ||
die "Can't open $filename";
my $file;
$file .= $_
while(<FILE>);
close(FILE);
# Save all lines of the form "foo = bar" in a hash
my $ret;
while ($file =~ s/^\s*(\w+)\s*=\s*(.+)\s*$//m) {
my $key = $1;
my $val = $2;
# Strip off any leading and trailing "'s
$val = $1
if ($val =~ m/^\"(.+)\"$/);
$ret->{$key} = $val;
}
# Split PARAM_CONFIG_FILES into an array
if (exists($ret->{PARAM_CONFIG_FILES})) {
my @out;
foreach my $f (split(/\s+/, $ret->{PARAM_CONFIG_FILES})) {
push(@out, "$dir_prefix/$f");
}
$ret->{PARAM_CONFIG_FILES} = \@out;
}
debug_dump($ret);
return $ret;
}
##############################################################################
# Process a "subdir", meaning that the directory isn't a component or
# an extension; it probably just needs an autoreconf, autogen, etc.
sub process_subdir {
my ($dir) = @_;
# Chdir to the subdir
print "\n=== Processing subdir: $dir\n";
my $start = Cwd::cwd();
chdir($dir);
# Run an action depending on what we find in that subdir
if (-x "autogen.pl") {
print "--- Found autogen.pl; running...\n";
safe_system("./autogen.pl");
} elsif (-x "autogen.sh") {
print "--- Found autogen.sh; running...\n";
safe_system("./autogen.sh");
} elsif (-f "configure.in" || -f "configure.ac") {
print "--- Found configure.in|ac; running autoreconf...\n";
safe_system("autoreconf -ivf");
print "--- Patching autotools output... :-(\n";
patch_autotools_output($start);
} else {
die "Found subdir, but no autogen.sh or configure.in|ac to do anything";
}
# Ensure that we got a good configure executable.
die "Did not generate a \"configure\" executable in $dir.\n"
if (! -x "configure");
# Chdir back to where we came from
chdir($start);
}
##############################################################################
sub process_autogen_subdirs {
my ($dir) = @_;
my $file = "$dir/autogen.subdirs";
if (-f $file) {
open(FILE, $file) || die "Can't open $file";
while (<FILE>) {
chomp;
$_ =~ s/#.*$//;
$_ =~ s/^\s*//;
$_ =~ s/\s*$//;
if ($_ ne "") {
print " Found subdir: $_ (will process later)\n";
# Note: there's no real technical reason to defer
# processing the subdirs. It's more of an aesthetic
# reason -- don't interrupt the current flow of
# finding mca / ext / contribs (which is a nice, fast
# process). Then process the subdirs (which is a slow
# process) all at once.
push(@subdirs, "$dir/$_");
}
}
close(FILE);
}
}
##############################################################################
sub mca_process_component {
my ($topdir, $project, $framework, $component) = @_;
my $pname = $project->{name};
my $pdir = $project->{dir};
my $cdir = "$topdir/$pdir/mca/$framework/$component";
return
if (! -d $cdir);
# Process this directory (pretty much the same treatment as for
# mpiext, so it's in a sub).
my $found_component;
# Does this directory have a configure.m4 file?
if (-f "$cdir/configure.m4") {
$found_component->{"configure.m4"} = 1;
verbose " Found configure.m4 file\n";
}
$found_component->{"name"} = $component;
# Push the results onto the $mca_found hash array
push(@{$mca_found->{$pname}->{$framework}->{"components"}},
$found_component);
# Is there an autogen.subdirs in here?
process_autogen_subdirs($cdir);
}
##############################################################################
sub ignored {
my ($dir) = @_;
# If this directory does not have .ompi_ignore, or if it has a
# .ompi_unignore that has my username in it, then add it to the
# list of components.
my $ignored = 0;
if (-f "$dir/.ompi_ignore") {
$ignored = 1;
}
if (-f "$dir/.ompi_unignore") {
open(UNIGNORE, "$dir/.ompi_unignore") ||
die "Can't open $dir/.ompi_unignore file";
my $unignore;
$unignore .= $_
while (<UNIGNORE>);
close(UNIGNORE);
$ignored = 0
if ($unignore =~ /^$username$/m ||
$unignore =~ /^$username\@$hostname$/m ||
$unignore =~ /^$username\@$full_hostname$/m);
}
return $ignored;
}
##############################################################################
sub mca_process_framework {
my ($topdir, $project, $framework) = @_;
my $pname = $project->{name};
my $pdir = $project->{dir};
# Does this framework have a configure.m4 file?
my $dir = "$topdir/$pdir/mca/$framework";
if (-f "$dir/configure.m4") {
$mca_found->{$pname}->{$framework}->{"configure.m4"} = 1;
verbose " Found framework configure.m4 file\n";
}
# Did we exclude all components for this framework?
if (exists($exclude_list->{$framework}) &&
$exclude_list->{$framework}[0] eq "AGEN_EXCLUDE_ALL") {
verbose " => Excluded\n";
} else {
# Look for component directories in this framework
if (-d $dir) {
$mca_found->{$pname}->{$framework}->{found} = 1;
opendir(DIR, $dir) ||
die "Can't open $dir directory";
foreach my $d (readdir(DIR)) {
# Skip any non-directory, "base", or any dir that
# begins with "."
next
if (! -d "$dir/$d" || $d eq "base" ||
substr($d, 0, 1) eq ".");
# Skip any component that doesn't have a configure.m4
# or Makefile.am as we couldn't build it anyway
if (! -f "$dir/$d/configure.m4" &&
! -f "$dir/$d/Makefile.am" &&
! -f "$dir/$d/configure.ac" &&
! -f "$dir/$d/configure.in") {
verbose " => No sentinel file found in $dir/$d -> Excluded\n";
next;
}
verbose "--- Found $pname / $framework / $d component\n";
# Skip if specifically excluded
if (exists($exclude_list->{$framework}) &&
$exclude_list->{$framework}[0] eq $d) {
verbose " => Excluded\n";
next;
}
# Skip if the framework is on the include list, but
# doesn't contain this component
if (exists($include_list->{$framework})) {
my $tst = 0;
foreach my $ck (@{$include_list->{$framework}}) {
if ($ck ne $d) {
verbose " => Not included\n";
$tst = 1;
last;
}
}
if ($tst) {
next;
}
}
# Check ignore status
if (ignored("$dir/$d")) {
verbose " => Ignored (found .ompi_ignore file)\n";
} else {
mca_process_component($topdir, $project, $framework, $d);
}
}
}
closedir(DIR);
}
}
##############################################################################
sub mca_process_project {
my ($topdir, $project) = @_;
my $pname = $project->{name};
my $pdir = $project->{dir};
# Does this project have a configure.m4 file?
if (-f "$topdir/$pdir/configure.m4") {
$mca_found->{$pname}->{"configure.m4"} = 1;
verbose " Found $topdir/$pdir/configure.m4 file\n";
}
# Look for framework directories in this project
my $dir = "$topdir/$pdir/mca";
if (-d $dir) {
opendir(DIR, $dir) ||
die "Can't open $dir directory";
my @my_dirs = readdir(DIR);
@my_dirs = sort(@my_dirs);
foreach my $d (@my_dirs) {
# Skip any non-directory, "base", or any dir that begins with "."
next
if (! -d "$dir/$d" || $d eq "base" || substr($d, 0, 1) eq ".");
# If this directory has a $dir.h file and a base/
# subdirectory, or its name is "common", then it's a
# framework.
if ("common" eq $d || !$project->{need_base} ||
(-f "$dir/$d/$d.h" && -d "$dir/$d/base")) {
verbose "\n=== Found $pname / $d framework\n";
mca_process_framework($topdir, $project, $d);
}
}
closedir(DIR);
}
}
##############################################################################
sub mca_run_global {
my ($projects) = @_;
# For each project, go find a list of frameworks, and for each of
# those, go find a list of components.
my $topdir = Cwd::cwd();
foreach my $p (@$projects) {
if (-d "$topdir/$p->{dir}") {
verbose "\n*** Found $p->{name} project\n";
mca_process_project($topdir, $p);
}
}
# Debugging output
debug_dump($mca_found);
#-----------------------------------------------------------------------
$m4 .= "\n$dnl_line
$dnl_line
$dnl_line
dnl MCA information\n";
# Array for all the m4_includes that we'll need to pick up the
# configure.m4's.
my @includes;
# Next, for each project, write the list of frameworks
foreach my $p (@$projects) {
my $pname = $p->{name};
my $pdir = $p->{dir};
if (exists($mca_found->{$pname})) {
my $frameworks_comma;
# Does this project have a configure.m4 file?
push(@includes, "$pdir/configure.m4")
if (exists($mca_found->{$p}->{"configure.m4"}));
# Print out project-level info
my @mykeys = keys(%{$mca_found->{$pname}});
@mykeys = sort(@mykeys);
# Ensure that the "common" framework is listed first
# (if it exists)
my @tmp;
push(@tmp, "common")
if (grep(/common/, @mykeys));
foreach my $f (@mykeys) {
push(@tmp, $f)
if ($f ne "common");
}
@mykeys = @tmp;
foreach my $f (@mykeys) {
$frameworks_comma .= ", $f";
# Does this framework have a configure.m4 file?
push(@includes, "$pdir/mca/$f/configure.m4")
if (exists($mca_found->{$pname}->{$f}->{"configure.m4"}));
# This framework does have a Makefile.am (or at least,
# it should!)
die "Missing $pdir/mca/$f/Makefile.am"
if (! -f "$pdir/mca/$f/Makefile.am");
}
$frameworks_comma =~ s/^, //;
$m4 .= "$dnl_line
dnl Frameworks in the $pname project and their corresponding directories
m4_define([mca_${pname}_framework_list], [$frameworks_comma])
";
# Print out framework-level info
foreach my $f (@mykeys) {
my $components;
my $m4_config_component_list;
my $no_config_component_list;
# Troll through each of the found components
foreach my $comp (@{$mca_found->{$pname}->{$f}->{components}}) {
my $c = $comp->{name};
$components .= "$c ";
# Does this component have a configure.m4 file?
if (exists($comp->{"configure.m4"})) {
push(@includes, "$pdir/mca/$f/$c/configure.m4");
$m4_config_component_list .= ", $c";
} else {
$no_config_component_list .= ", $c";
}
}
$m4_config_component_list =~ s/^, //;
$no_config_component_list =~ s/^, //;
$m4 .= "dnl Components in the $pname / $f framework
m4_define([mca_${pname}_${f}_m4_config_component_list], [$m4_config_component_list])
m4_define([mca_${pname}_${f}_no_config_component_list], [$no_config_component_list])
";
}
}
}
# List out all the m4_include
$m4 .= "$dnl_line
dnl List of configure.m4 files to include\n";
foreach my $i (@includes) {
$m4 .= "m4_include([$i])\n";
}
}
##############################################################################
sub mpiext_process_extension {
my ($topdir, $ext_prefix, $extdir) = @_;
my $edir = "$topdir/$ext_prefix/$extdir";
return
if (! -d $edir);
# Process this directory (pretty much the same treatment as for
# MCA components, so it's in a sub).
my $found_ext;
$found_ext->{"name"} = $extdir;
# Push the results onto the hash array
push(@{$mpiext_found}, $found_ext);
# Is there an autogen.subdirs in here?
process_autogen_subdirs($edir);
}
##############################################################################
sub mpiext_run_global {
my ($ext_prefix) = @_;
my $topdir = Cwd::cwd();
my $dir = "$topdir/$ext_prefix";
opendir(DIR, $dir) ||
die "Can't open $dir directory";
foreach my $d (readdir(DIR)) {
# Skip any non-directory, "base", or any dir that begins with "."
next
if (! -d "$dir/$d" || $d eq "base" || substr($d, 0, 1) eq ".");
# If this directory has a configure.m4, then it's an
# extension.
if (-f "$dir/$d/configure.m4") {
verbose "=== Found $d MPI extension";
# Check ignore status
if (ignored("$dir/$d")) {
verbose " (ignored)\n";
} else {
verbose "\n";
mpiext_process_extension($topdir, $ext_prefix, $d);
}
}
}
closedir(DIR);
debug_dump($mpiext_found);
#-----------------------------------------------------------------------
$m4 .= "\n$dnl_line
$dnl_line
$dnl_line
dnl Open MPI extensions information
$dnl_line\n\n";
# Array for all the m4_includes that we'll need to pick up the
# configure.m4's.
my @includes;
my $m4_config_ext_list;
# Troll through each of the found exts
foreach my $ext (@{$mpiext_found}) {
my $e = $ext->{name};
push(@includes, "$ext_prefix/$e/configure.m4");
$m4_config_ext_list .= ", $e";
}
$m4_config_ext_list =~ s/^, //;
# List the M4 and no configure exts
$m4 .= "dnl List of all MPI extensions
m4_define([ompi_mpiext_list], [$m4_config_ext_list])\n";
# List out all the m4_include
$m4 .= "\ndnl List of configure.m4 files to include\n";
foreach my $i (@includes) {
$m4 .= "m4_include([$i])\n";
}
}
##############################################################################
sub mpicontrib_process {
my ($topdir, $contrib_prefix, $contribdir) = @_;
my $cdir = "$topdir/$contrib_prefix/$contribdir";
return
if (! -d $cdir);
# Process this directory (pretty much the same treatment as for
# MCA components, so it's in a sub).
my $found_contrib;
$found_contrib->{"name"} = $contribdir;
# Push the results onto the hash array
push(@{$mpicontrib_found}, $found_contrib);
# Is there an autogen.subdirs in here?
process_autogen_subdirs($cdir);
}
##############################################################################
sub mpicontrib_run_global {
my ($contrib_prefix) = @_;
my $topdir = Cwd::cwd();
my $dir = "$topdir/$contrib_prefix";
opendir(DIR, $dir) ||
die "Can't open $dir directory";
foreach my $d (readdir(DIR)) {
# Skip any non-directory, "base", or any dir that begins with "."
next
if (! -d "$dir/$d" || $d eq "base" || substr($d, 0, 1) eq ".");
# If this directory has a configure.m4, then it's an
# extension.
if (-f "$dir/$d/configure.m4") {
verbose "=== Found $d MPI contrib";
# Check ignore status
if (ignored("$dir/$d")) {
verbose " (ignored)\n";
} else {
verbose "\n";
mpicontrib_process($topdir, $contrib_prefix, $d);
}
}
}
closedir(DIR);
debug_dump($mpiext_found);
#-----------------------------------------------------------------------
$m4 .= "\n$dnl_line
$dnl_line
$dnl_line
dnl Open MPI contrib information
$dnl_line\n\n";
# Array for all the m4_includes that we'll need to pick up the
# configure.m4's.
my @includes;
my $m4_config_contrib_list;
# Troll through each of the found contribs
foreach my $contrib (@{$mpicontrib_found}) {
my $c = $contrib->{name};
push(@includes, "$contrib_prefix/$c/configure.m4");
$m4_config_contrib_list .= ", $c";
}
$m4_config_contrib_list =~ s/^, //;
# List the M4 and no configure exts
$m4 .= "dnl List of all MPI contribs
m4_define([ompi_mpicontrib_list], [$m4_config_contrib_list])\n";
# List out all the m4_include
$m4 .= "\ndnl List of configure.m4 files to include\n";
foreach my $i (@includes) {
$m4 .= "m4_include([$i])\n";
}
}
##############################################################################
# Find and remove stale files
sub find_and_delete {
foreach my $file (@_) {
my $removed = 0;
if (-f $file) {
unlink($file);
$removed = 1;
}
if (-f "config/$file") {
unlink("config/$file");
$removed = 1;
}
debug " Removed stale copy of $file\n"
if ($removed);
}
}
##############################################################################
# Find a specific executable and ensure that it is a recent enough
# version.
sub find_and_check {
my ($app, $app_name, $req_version) = @_;
my @search_path = split(/;/, $app_name);
my @min_version = split(/\./, $req_version);
my @versions_found = ();
foreach (@search_path) {
verbose " Searching for $_\n";
my $version = `$_ --version`;
if (!defined($version)) {
verbose " $_ not found\n";
next;
}
$version =~ m/\s([\d\w\.]+)$/m;
$version = $1;
verbose " Found $_ version $version; checking version...\n";
push(@versions_found, $version);
my @parts = split(/\./, $version);
my $i = 0;
# Check every component of the version number
while ($i <= $#min_version) {
verbose " Found version component $parts[$i] -- need $min_version[$i]\n";
# Check to see if there are any characters (!) in the
# version number (e.g., Libtool's "2.2.6b" -- #%@#$%!!!).
# Do separate comparisons between the number and any
# trailing digits. You can't just "lt" compare the whole
# string because "10 lt 2b" will return true. #@$@#$#@$
# Libtool!!
$parts[$i] =~ m/(\d+)([a-z]*)/i;
my $pn = $1;
my $pa = $2;
$min_version[$i] =~ m/(\d+)([a-z]*)/i;
my $mn = $1;
my $ma = $2;
# If the version is higher, we're done.
if ($pn > $mn) {
verbose " ==> ACCEPTED\n";
return;
}
# If the version is lower, we're done.
elsif ($pn < $mn ||
($pn == $mn && $pa lt $ma)) {
verbose " ==> Too low! Skipping this version\n";
last;
}
# If the version was equal, keep checking.
++$i;
}
# If we found a good version, return.
if ($i > $#min_version) {
verbose " ==> ACCEPTED\n";
return;
}
}
# if no acceptable version found, reject it
print "
=================================================================
I could not find a recent enough copy of $app.
I need at least $req_version, but only found the following versions:\n\n";
my $i = 0;
foreach (@search_path) {
print " $_: $versions_found[$i]\n";
$i++;
}
print "\nI am gonna abort. :-(
Please make sure you are using at least the following versions of the
GNU tools:
GNU Autoconf: $ompi_autoconf_version
GNU Automake: $ompi_automake_version
GNU Libtool: $ompi_libtool_version
=================================================================\n";
exit(1);
}
##############################################################################
sub safe_system {
my $ret = system(@_);
$ret >>= 8;
if (0 != $ret) {
print "Command failed: @_\n";
exit($ret);
}
$ret;
}
##############################################################################
sub patch_autotools_output {
my ($topdir) = @_;
# Set indentation string for verbose output depending on current directory.
my $indent_str = " ";
if ($topdir eq ".") {
$indent_str = "=== ";
}
# Patch ltmain.sh error for PGI version numbers. Redirect stderr to
# /dev/null because this patch is only necessary for some versions of
# Libtool (e.g., 2.2.6b); it'll [rightfully] fail if you have a new
# enough Libtool that dosn't need this patch. But don't alarm the
# user and make them think that autogen failed if this patch fails --
# make the errors be silent.
if (-f "config/ltmain.sh") {
verbose "$indent_str"."Patching PGI compiler version numbers in ltmain.sh\n";
system("$patch_prog -N -p0 < $topdir/config/ltmain_pgi_tp.diff >/dev/null 2>&1");
unlink("config/ltmain.sh.rej");
}
# Total ugh. We have to patch the configure script itself. See below
# for explainations why.
open(IN, "configure") || die "Can't open configure";
my $c;
$c .= $_
while(<IN>);
close(IN);
# LT <=2.2.6b need to be patched for the PGI 10.0 fortran compiler
# name (pgfortran). The following comes from the upstream LT patches:
# http://lists.gnu.org/archive/html/libtool-patches/2009-11/msg00012.html
# http://lists.gnu.org/archive/html/bug-libtool/2009-11/msg00045.html
# Note that that patch is part of Libtool (which is not in this OMPI
# source tree); we can't fix it. So all we can do is patch the
# resulting configure script. :-(
verbose "$indent_str"."Patching configure for Libtool PGI 10 fortran compiler name\n";
$c =~ s/gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn/gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn/g;
$c =~ s/pgcc\* \| pgf77\* \| pgf90\* \| pgf95\*\)/pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)/g;
$c =~ s/pgf77\* \| pgf90\* \| pgf95\*\)/pgf77* | pgf90* | pgf95* | pgfortran*)/g;
# Similar issue as above -- the PGI 10 version number broke <=LT
# 2.2.6b's version number checking regexps. Again, we can't fix the
# Libtool install; all we can do is patch the resulting configure
# script. :-( The following comes from the upstream patch:
# http://lists.gnu.org/archive/html/libtool-patches/2009-11/msg00016.html
verbose "$indent_str"."Patching configure for Libtool PGI version number regexps\n";
$c =~ s/\*pgCC\\ \[1-5\]\* \| \*pgcpp\\ \[1-5\]\*/*pgCC\\ [1-5]\.* | *pgcpp\\ [1-5]\.*/g;
# Similar issue as above -- fix the case statements that handle the Sun
# Fortran version strings.
#
# Note: we have to use octal escapes to match '*Sun\ F*) and the
# four succeeding lines in the bourne shell switch statement.
# \ = 134
# ) = 051
# * = 052
#
# Below is essentially an upstream patch for Libtool which we want
# made available to Open MPI users running older versions of Libtool
foreach my $tag (("", "_F77", "_FC")) {
# We have to change the search pattern and substitution on each
# iteration to take into account the tag changing
my $search_string = '\052Sun\134 F\052.*\n.*\n\s+' .
"lt_prog_compiler_pic${tag}" . '.*\n.*\n.*\n.*\n';
my $replace_string = "
*Sun\\ Ceres\\ Fortran* | *Sun*Fortran*\\ [[1-7]].* | *Sun*Fortran*\\ 8.[[0-3]]*)
# Sun Fortran 8.3 passes all unrecognized flags to the linker
lt_prog_compiler_pic${tag}='-KPIC'
lt_prog_compiler_static${tag}='-Bstatic'
lt_prog_compiler_wl${tag}=''
;;
*Sun\\ F* | *Sun*Fortran*)
lt_prog_compiler_pic${tag}='-KPIC'
lt_prog_compiler_static${tag}='-Bstatic'
lt_prog_compiler_wl${tag}='-Qoption ld '
;;
";
verbose "$indent_str"."Patching configure for Sun Studio Fortran version strings ($tag)\n";
$c =~ s/$search_string/$replace_string/;
}
# See http://git.savannah.gnu.org/cgit/libtool.git/commit/?id=v2.2.6-201-g519bf91 for details
# Note that this issue was fixed in LT 2.2.8, however most distros are still using 2.2.6b
verbose "$indent_str"."Patching configure for IBM xlf libtool bug\n";
$c =~ s/(\$LD -shared \$libobjs \$deplibs \$)compiler_flags( -soname \$soname)/$1linker_flags$2/g;
open(OUT, ">configure.patched") || die "Can't open configure.patched";
print OUT $c;
close(OUT);
# Use cp so that we preserve permissions on configure
safe_system("cp configure.patched configure");
unlink("configure.patched");
}
##############################################################################
##############################################################################
## main - do the real work...
##############################################################################
##############################################################################
# Command line parameters
my $ok = Getopt::Long::GetOptions("no-ompi" => \$no_ompi_arg,
"no-orte" => \$no_orte_arg,
"quiet|q" => \$quiet_arg,
"debug|d" => \$debug_arg,
"help|h" => \$help_arg,
"platform=s" => \$platform_arg,
"include=s" => \$include_arg,
"exclude=s" => \$exclude_arg,
);
if (!$ok || $help_arg) {
print "Invalid command line argument.\n\n"
if (!$ok);
print "Options:
--no-ompi | -no-ompi Do not build the Open MPI layer
--no-orte | -no-orte Do not build the ORTE layer
--quiet | -q Do not display normal verbose output
--debug | -d Output lots of debug information
--help | -h This help list
--platform | -p Specify a platform file to be parsed for no_build
and only_build directives
--include | -i Comma-separated list of framework-component pairs
to be exclusively built - i.e., all other components
will be ignored and only those specified will be marked
to build
--exclude | -e Comma-separated list of framework or framework-component
to be excluded from the build\n";
exit($ok ? 0 : 1);
}
#---------------------------------------------------------------------------
# Check for project existence
my $project_name_long = "Open MPI";
my $project_name_short = "openmpi";
if (! -e "ompi") {
$no_ompi_arg = 1;
debug "No ompi subdirectory found - will not build MPI layer\n";
}
if (! -e "orte") {
$no_orte_arg = 1;
debug "No orte subdirectory found - will not build ORTE\n";
}
if ($no_ompi_arg) {
$project_name_long = "Open MPI Run Time Environment";
$project_name_short = "open-rte";
}
if ($no_orte_arg) {
$project_name_long = "Open Portability Access Layer";
$project_name_short = "open-pal";
}
#---------------------------------------------------------------------------
$full_hostname = `hostname`;
chomp($full_hostname);
$m4 = "dnl
dnl \$HEADER\$
dnl
$dnl_line
dnl This file is automatically created by autogen.pl; it should not
dnl be edited by hand!!
dnl
dnl Generated by $username at " . localtime(time) . "
dnl on $full_hostname.
$dnl_line\n\n";
#---------------------------------------------------------------------------
my $step = 1;
verbose "Open MPI autogen (buckle up!)
$step. Checking tool versions\n\n";
# Check the autotools revision levels
&find_and_check("autoconf", $ompi_autoconf_search, $ompi_autoconf_version);
&find_and_check("libtool", $ompi_libtoolize_search, $ompi_libtool_version);
&find_and_check("automake", $ompi_automake_search, $ompi_automake_version);
#---------------------------------------------------------------------------
# Save the platform file in the m4
$m4 .= "dnl Platform file\n";
# Process platform arg, if provided
if ($platform_arg) {
$m4 .= "m4_define([autogen_platform_file], [$platform_arg])\n\n";
open(IN, $platform_arg) || die "Can't open $platform_arg";
# Read all lines from the file
while (<IN>) {
my $line = $_;