]> git.donarmstrong.com Git - libparallel-mpi-simple-perl.git/blob - Makefile.PL
require libopenpmi-dev
[libparallel-mpi-simple-perl.git] / Makefile.PL
1 use ExtUtils::MakeMaker;
2 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
3 # the contents of the Makefile that is written.
4
5 # Make sure people aren't being stupid... it's been known to happen.
6
7 print <<ENDOFMESSAGE;
8 I'm about to build the Makefile for Parallel::MPI::Simple.
9
10 If you have mpicc installed, I will attempt to use the arguements
11 it suggests to compile and link the module.  You will also have to
12 have already started mpd for the tests to work.
13
14 If you find you cannot build this module, or that the tests fail, you
15 may be on an odd system where you need to do more than pass -lmpi to
16 your C compiler to build MPI applications.  If this is the case, rerun
17 perl Makefile.PL with appropriate LDFLAGS= and CCFLAGS= arguments.
18
19 ENDOFMESSAGE
20
21 my $mpirun = "";
22 my ($libs, $ccflags) = ("", "");
23
24 if ($ENV{FORCE_MPIRUN}) {
25     $mpirun = $ENV{FORCE_MPIRUN};
26 }
27 else {
28     foreach my $mpi_try (qw(mpiexec mpirun)) {
29         my $test = join("",`$mpi_try -n 1 echo test`);
30         $mpirun = $mpi_try unless $! =~ /No such file or directory/;
31         last if $mpirun;
32     }
33     
34     if (!$mpirun) {
35         print STDERR "Failed to run `$mpirun -n 1 echo test`: $!\n";
36         print STDERR "It looks like you don't have mpi installed, re-run build with env: FORCE_MPIRUN=1 to ignore\n";
37         exit(0);
38     }
39 }
40
41 # try to get this information from mpicc, should quietly fail if not
42 if ($^O !~ /MSWin32/) {
43     my @lines = `mpicc -help`;
44     foreach my $line (@lines) {
45         if ($line =~ /-link-info/) {
46             my $linkinfo = `mpicc -link-info`;
47             my @entries = split (/\s+/, $linkinfo);
48             $libs = join(" ", grep {/^-[Ll]/} @entries);
49         }
50         if ($line =~ /-compile-info/) {
51             my $compileinfo = `mpicc -compile-info`;
52             my @entries = split (/\s+/, $compileinfo);
53             $ccflags = join(" ", grep {/^-[ILl]/} @entries);
54         }
55     }
56     if ($libs || $ccflags) {
57         print STDERR "guessing values for\n LIBS:$libs\n CCFLAGS:$ccflags\n";
58     }
59     else {
60         print STDERR "Could not determine options for mpicc, using defaults\n";
61     }
62 }
63 else { # windows, look for mpich2
64   my @potential = map {"C:\\$_\\MPICH2"}
65     'Program Files',
66       'Program Files (x86)';
67   foreach my $try (@potential) {
68     if (-f "$try\\bin\\mpiexec.exe") {
69       $mpirun = "$try\\bin\\mpiexec.exe";
70       $libs = qq{"-L$try\\lib" -lmpi};
71       $ccflags = qq{"-I$try\\include" "-L$try\\lib" -lmpi};
72     }
73   }
74 }
75
76 # Check that people have tried to define linking and compiling options...
77 WriteMakefile(
78     'NAME'      => 'Parallel::MPI::Simple',
79     'VERSION_FROM' => 'Simple.pm', # finds $VERSION
80     'PREREQ_PM' => {Storable => 0},
81     'LIBS' => $libs || "-lmpi",
82     'CCFLAGS' => $ccflags || "",
83 );