From d0d2507b0b34770c26e18ae86a68fd8abe9dedfe Mon Sep 17 00:00:00 2001
From: Alex Gough <alex@earth.li>
Date: Mon, 6 Jun 2011 18:28:53 +1200
Subject: [PATCH] Now works on Win32 with mpich 1.1.1

---
 Makefile.PL |  4 ++--
 test.pl     | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile.PL b/Makefile.PL
index 2891e91..a50377a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -67,8 +67,8 @@ else { # windows, look for mpich2
   foreach my $try (@potential) {
     if (-f "$try\\bin\\mpiexec.exe") {
       $mpirun = "$try\\bin\\mpiexec.exe";
-      $libs = qq{-L "$try\\lib\\" -lmpi};
-      $ccflags = qq{-I "$try\\include\\" -L "$try\\lib" -lmpi};
+      $libs = qq{"-L$try\\lib" -lmpi};
+      $ccflags = qq{"-I$try\\include" "-L$try\\lib" -lmpi};
     }
   }
 }
diff --git a/test.pl b/test.pl
index 98001a9..a55463e 100644
--- a/test.pl
+++ b/test.pl
@@ -1,15 +1,15 @@
-my $mpirun = "mpirun"; # fallback
+my $mpirun = "";
 foreach my $mpi_try (qw(mpiexec mpirun)) {
-    my $test = join("",`$mpi_try -n 1 echo test`);
-    $mpirun = $mpi_try unless $! =~ /No such file or directory/;
+    my $test = join("",`$mpi_try -n 1 perl -e "print qq{honk},qq{honk\n}"`);
+    $mpirun = $mpi_try if $test =~ /honkhonk/;
     last if $mpirun;
 }
-
+$mpirun = $mpirun || "mpirun"; # fallback
 my $incs;
 $incs .= " -I$_" foreach @INC;
 my @newout = sort {
     (($a =~ /(\d+)/g)[0] <=> ($b =~ /(\d+)/g)[0])
-} `mpirun -np 2 $^X $incs ic.pl`;
+} `$mpirun -np 2 $^X $incs ic.pl`;
 print "1..24\n";
 if (@newout < 24) {
     print "not ok 1 # mpirun failed.  Do you need to start mpd?\n";
-- 
2.39.5