]> git.donarmstrong.com Git - deb_pkgs/libstatistics-r-perl.git/blob - inc/Module/Install/External.pm
New upstream version 0.34
[deb_pkgs/libstatistics-r-perl.git] / inc / Module / Install / External.pm
1 #line 1
2 package Module::Install::External;
3
4 # Provides dependency declarations for external non-Perl things
5
6 use strict;
7 use Module::Install::Base ();
8
9 use vars qw{$VERSION $ISCORE @ISA};
10 BEGIN {
11         $VERSION = '1.16';
12         $ISCORE  = 1;
13         @ISA     = qw{Module::Install::Base};
14 }
15
16 sub requires_xs {
17         my $self = shift;
18
19         # First check for the basic C compiler
20         $self->requires_external_cc;
21
22         # We need a C compiler that can build XS files
23         unless ( $self->can_xs ) {
24                 print "Unresolvable missing external dependency.\n";
25                 print "This package requires perl's header files.\n";
26                 print STDERR "NA: Unable to build distribution on this platform.\n";
27                 exit(0);
28         }
29
30         1;
31 }
32
33 sub requires_external_cc {
34         my $self = shift;
35
36         # We need a C compiler, use the can_cc method for this
37         unless ( $self->can_cc ) {
38                 print "Unresolvable missing external dependency.\n";
39                 print "This package requires a C compiler.\n";
40                 print STDERR "NA: Unable to build distribution on this platform.\n";
41                 exit(0);
42         }
43
44         # Unlike some of the other modules, while we need to specify a
45         # C compiler as a dep, it needs to be a build-time dependency.
46
47         1;
48 }
49
50 sub requires_external_bin {
51         my ($self, $bin, $version) = @_;
52         if ( $version ) {
53                 die "requires_external_bin does not support versions yet";
54         }
55
56         # Load the package containing can_run early,
57         # to avoid breaking the message below.
58         $self->load('can_run');
59
60         # Locate the bin
61         print "Locating bin:$bin...";
62         my $found_bin = $self->can_run( $bin );
63         if ( $found_bin ) {
64                 print " found at $found_bin.\n";
65         } else {
66                 print " missing.\n";
67                 print "Unresolvable missing external dependency.\n";
68                 print "Please install '$bin' seperately and try again.\n";
69                 print STDERR "NA: Unable to build distribution on this platform.\n";
70                 exit(0);
71         }
72
73         # Once we have some way to specify external deps, do it here.
74         # In the mean time, continue as normal.
75
76         1;
77 }
78
79 1;
80
81 __END__
82
83 #line 171