]> git.donarmstrong.com Git - libparallel-mpi-simple-perl.git/commitdiff
automatically detect mpicc and use it
authorAlex Gough <alex@earth.li>
Mon, 6 Jun 2011 03:45:28 +0000 (04:45 +0100)
committeralex <alex@alex-deb-vm.px.otago.ac.nz>
Mon, 6 Jun 2011 03:46:04 +0000 (04:46 +0100)
Makefile.PL
test.pl

index ad78530af604f2b82bd2925dd9366f81995c3cc6..b6e60a4c48a31dd3a9b27f6cf3ee24780ab37e91 100644 (file)
@@ -7,6 +7,10 @@ use ExtUtils::MakeMaker;
 print <<ENDOFMESSAGE;
 I'm about to build the Makefile for Parallel::MPI::Simple.
 
+If you have mpicc installed, I will attempt to use the arguements
+it suggests to compile and link the module.  You will also have to
+have already started mpd for the tests to work.
+
 If you find you cannot build this module, or that the tests fail, you
 may be on an odd system where you need to do more than pass -lmpi to
 your C compiler to build MPI applications.  If this is the case, rerun
@@ -16,10 +20,35 @@ Also, this module is very new so if you manage to get it working on one
 of the systems not listed in INSTALL I'd love to hear about it.
 ENDOFMESSAGE
 
+my ($libs, $ccflags) = ("", "");
+# try to get this information from mpicc, should quietly fail if not
+{
+    my @lines = `mpicc -help`;
+    foreach my $line (@lines) {
+       if ($line =~ /-link-info/) {
+           my $linkinfo = `mpicc -link-info`;
+           my @entries = split (/\s+/, $linkinfo);
+           $libs = join(" ", grep {/^-[Ll]/} @entries);
+       }
+       if ($line =~ /-compile-info/) {
+           my $compileinfo = `mpicc -compile-info`;
+           my @entries = split (/\s+/, $compileinfo);
+           $ccflags = join(" ", grep {/^-[ILl]/} @entries);
+       }
+    }
+    if ($libs || $ccflags) {
+       print STDERR "guessing values for\n LIBS:$libs\n CCFLAGS:$ccflags\n";
+    }
+    else {
+       print STDERR "Could not determine options for mpicc, using defaults\n";
+    }
+}
+
 # Check that people have tried to define linking and compiling options...
 WriteMakefile(
     'NAME'     => 'Parallel::MPI::Simple',
     'VERSION_FROM' => 'Simple.pm', # finds $VERSION
     'PREREQ_PM' => {Storable => 0},
-    'LIBS' => "-lmpi",
+    'LIBS' => $libs || "-lmpi",
+    'CCFLAGS' => $ccflags || "",
 );
diff --git a/test.pl b/test.pl
index 4832eb370c3ffdcdebe3ec0c47e8e2810193bd69..ea085ff85907022fdb51f9fd4c660e252212def4 100644 (file)
--- a/test.pl
+++ b/test.pl
@@ -3,5 +3,8 @@ $incs .= " -I$_" foreach @INC;
 my @newout = sort {
     (($a =~ /(\d+)/g)[0] <=> ($b =~ /(\d+)/g)[0])
 } `mpirun -np 2 $^X $incs ic.pl`;
-print "1..".scalar(@newout)."\n";
+print "1..24";
+if (@newout < 24) {
+    print "not ok 1 # mpirun failed.  Do you need to start mpd?\n";
+}
 print @newout;