File Coverage

example/gmake.alienfile
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1 1     1   9 use alienfile;
  1         3  
  1         5  
2 1     1   7 use Capture::Tiny qw( capture );
  1         2  
  1         427  
3              
4             configure {
5             # Because we use Capture::Tiny in
6             # the alienfile itself, we need to register it
7             # as a configure time require (that is it needs
8             # to be installed before we even attempt to load
9             # this alienfile).
10             requires 'Capture::Tiny';
11             };
12              
13             # probe for GNU Make by trying the usual names for
14             # it. Because 'make' could be some other make, we
15             # try running it with --version and see if it looks
16             # like the GNU version.
17             plugin 'Probe::CommandLine' => (
18             command => $_,
19             args => ['--version'],
20             match => qr/GNU Make/,
21             ) for qw( gmake make );
22              
23             share {
24              
25             # items in the share block relate to building the package
26             # from source. It is called share because it will be
27             # installed into a dist level share directory in your
28             # perl lib.
29              
30             # The Download negotiator picks the best method for
31             # downloading the package. It uses the version
32             # regex to parse out the version number from the
33             # tarball so that it can pick the most recent
34             # version.
35             start_url 'http://ftp.gnu.org/gnu/make';
36             plugin 'Download' => (
37             version => qr/^make-([0-9\.]+)\.tar\.gz$/,
38             );
39              
40             # The Extract negotiator picks the best method for
41             # extracting from the tarball. We give it a hint
42             # here that we expect the tarball to be .gz compressed
43             # in case it needs to load extra modules to
44             # decompress.
45             plugin 'Extract' => 'tar.gz';
46              
47              
48             # The Autoconf plugin builds using the standard
49             # configure and make tools. It uses a DESTDIR
50             # ( https://www.gnu.org/prep/standards/html_node/DESTDIR.html )
51             # to ensure that the prefix during the build
52             # (ie when you install the Alien::xz module)
53             # matches the prefix during runtime
54             # (ie when you use it from XZ::XS).
55             plugin 'Build::Autoconf';
56              
57             # unlike the xz alienfile, we need to explicitly specify
58             # the commands used to build. For this package it is
59             # because we need to specify --program-prefix=g so that
60             # the gmake executable will be 'gmake' and will not conflict
61             # with the system provided 'make' which may not be compatible.
62             build [
63             '%{configure} --program-prefix=g --disable-shared',
64             '%{make}',
65             '%{make} install',
66             sub {
67             my($build) = @_;
68             $build->runtime_prop->{command} = 'gmake';
69             },
70             ];
71              
72             # This package doesn't build a dynamic library, but if
73             # it did this would make sure that it wasn't used with XS.
74             # (See Alien::Build::Manual::AlienAuthor for details).
75             plugin 'Gather::IsolateDynamic';
76              
77             };
78              
79             # For either a 'share' or 'system' install we try to get
80             # the version number from make --version output. But if
81             # for whatever reason we are not able to parse it out, it
82             # is more important to just have gmake, so we will set
83             # version to unknown.
84             gather sub {
85             my($build) = @_;
86             my($stdout) = capture {
87             system($build->runtime_prop->{command}, '--version');
88             };
89             my($version) = $stdout =~ /GNU Make ([0-9\.]+)/;
90             $build->runtime_prop->{version} = $version || 'unknown';
91             };
92