File Coverage

alienfile
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1 1     1   289694 use alienfile;
  1         3  
  1         9  
2             #use File::Which qw( which );
3             #use Capture::Tiny qw( capture );
4             #use List::Util qw( all );
5             #use Sort::Versions qw( versioncmp );
6              
7             #configure {
8             # requires 'File::Which';
9             # requires 'Capture::Tiny';
10             # requires 'Sort::Versions';
11             #};
12              
13             probe sub {
14             my($build) = @_;
15              
16             # my %tools;
17             #
18             # foreach my $tool (qw( autoconf autoheader autom4te autoreconf autoscan autoupdate ifnames ))
19             # {
20             # $tools{$tool} = 0;
21             # my $exe = which $tool;
22             # if($exe)
23             # {
24             # my(undef, undef, $stdout) = capture {
25             # `$tool --version`;
26             # };
27             #
28             # if($stdout =~ /GNU Autoconf/ && $stdout =~ /([0-9\.]+)$/)
29             # {
30             # my $version = $1;
31             # if(versioncmp($version, '2.69') >= 0)
32             # {
33             # $tools{$tool} = $version;
34             # }
35             # }
36             # }
37             # }
38             #
39             # if(all { $_ != 0 } values %tools)
40             # {
41             # my($version) = values %tools;
42             # if(all { $_ == $version } values %tools)
43             # {
44             # $build->install_prop->{my_version} = $version;
45             # return 'system';
46             # }
47             # }
48              
49             'share';
50             };
51              
52             share {
53             requires 'Alien::m4' => '0.11';
54             requires 'Path::Tiny' => 0;
55              
56             if($^O eq 'MSWin32')
57             {
58             meta->prop->{env}->{PERL} = '/usr/bin/perl';
59             }
60             else
61             {
62             meta->prop->{env}->{PERL} = $^X;
63             }
64              
65             plugin Download => (
66             url => 'https://ftp.gnu.org/gnu/autoconf',
67             filter => qr/^autoconf-.*\.tar\.gz$/,
68             version => qr/([0-9\.]+)/,
69             );
70             plugin Extract => 'tar.gz',
71              
72             plugin 'Build::Autoconf' => ( msys_version => '0.08' );
73              
74             meta->before_hook(
75             gather_share => sub {
76             my($build) = @_;
77             my $bin = Path::Tiny->new('bin');
78              
79             # patch executables
80             foreach my $exe ($bin->children)
81             {
82             my($shebang, @lines) = $exe->lines;
83             if($shebang =~ /^#!.*perl/)
84             {
85             @lines = (
86             "BEGIN {\n",
87             " use strict;\n",
88             " use warnings;\n",
89             " use File::Spec;\n",
90             " my(\$v,\$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));\n",
91             " my \@d = File::Spec->splitdir(\$d);\n",
92             " pop \@d for 1..2;\n",
93             " my \$dist_dir = File::Spec->catpath(\$v,File::Spec->catdir(\@d), '');\n",
94             " \$ENV{AUTOM4TE} ||= File::Spec->catfile(\$dist_dir, 'bin/autom4te');\n",
95             " \$ENV{autom4te_perllibdir} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf');\n",
96             " \$ENV{AC_MACRODIR} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf');\n",
97             " \$ENV{AUTOCONF} ||= File::Spec->catfile(\$dist_dir, 'bin/autoconf');\n",
98             " \$ENV{AUTOHEADER} ||= File::Spec->catfile(\$dist_dir, 'bin/autoheader');\n",
99             " \$ENV{AUTOM4TE_CFG} ||= File::Spec->catfile(\$dist_dir, 'share/autoconf/autom4te.blib.cfg')\n",
100             " if \$d[-5] eq 'lib' && \$d[-6] eq 'blib';\n",
101             " \$ENV{trailer_m4} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf/autoconf/trailer.m4');\n",
102             "}\n",
103             @lines
104             );
105             $exe->spew($shebang, @lines);
106             $exe->chmod("0755");
107             }
108             elsif($shebang =~ /^#!.*sh/)
109             {
110             @lines = (
111             ": \${AUTOM4TE=`alien_autoconf_root`'/bin/autom4te'}\n",
112             ": \${trailer_m4=`alien_autoconf_root`'/share/autoconf/autoconf/trailer.m4'}\n",
113             @lines
114             );
115             $exe->spew($shebang, @lines);
116             $exe->chmod("0755");
117             }
118             }
119              
120             # patch autom4te config
121             {
122             my $orig = Path::Tiny->new('share/autoconf/autom4te.cfg');
123             my $new = Path::Tiny->new('share/autoconf/autom4te.blib.cfg');
124             my $stage = Path::Tiny->new($build->install_prop->{stage})->child('share/autoconf')->stringify;
125             $orig->copy($new);
126             $new->edit_lines(sub {
127             s/--prepend-include '(.*)'/--prepend-include '$stage'/;
128             });
129             }
130              
131             # script to compute path to autoconf root
132             {
133             my $exe = Path::Tiny->new('bin/alien_autoconf_root');
134             my $perl = $ENV{PERL} || '/usr/bin/perl';
135             $exe->spew(
136             "#!$perl\n",
137             "use File::Spec;\n",
138             "my(\$v,\$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));\n",
139             "my \@d = File::Spec->splitdir(\$d);\n",
140             "pop \@d for 1..2;\n",
141             "my \$dist_dir = File::Spec->catpath(\$v,File::Spec->catdir(\@d), '');\n",
142             "print \$dist_dir\n",
143             );
144             $exe->chmod('0700');
145             }
146             },
147             );
148             };
149              
150             #sys {
151             #
152             # gather sub {
153             # my($build) = @_;
154             # $build->runtime_prop->{version} = $build->install_prop->{my_version};
155             # };
156             #
157             #};