Alien-autoconf
view release on metacpan or search on metacpan
url => 'https://ftp.gnu.org/gnu/autoconf',
filter => qr/^autoconf-.*\.tar\.gz$/,
version => qr/([0-9\.]+)/,
);
plugin Extract => 'tar.gz',
plugin 'Build::Autoconf' => ( msys_version => '0.08' );
meta->before_hook(
gather_share => sub {
my($build) = @_;
my $bin = Path::Tiny->new('bin');
# patch executables
foreach my $exe ($bin->children)
{
my($shebang, @lines) = $exe->lines;
if($shebang =~ /^#!.*perl/)
{
@lines = (
"BEGIN {\n",
" use strict;\n",
" use warnings;\n",
" use File::Spec;\n",
" my(\$v,\$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));\n",
" my \@d = File::Spec->splitdir(\$d);\n",
" pop \@d for 1..2;\n",
" my \$dist_dir = File::Spec->catpath(\$v,File::Spec->catdir(\@d), '');\n",
" \$ENV{AUTOM4TE} ||= File::Spec->catfile(\$dist_dir, 'bin/autom4te');\n",
" \$ENV{autom4te_perllibdir} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf');\n",
" \$ENV{AC_MACRODIR} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf');\n",
" \$ENV{AUTOCONF} ||= File::Spec->catfile(\$dist_dir, 'bin/autoconf');\n",
" \$ENV{AUTOHEADER} ||= File::Spec->catfile(\$dist_dir, 'bin/autoheader');\n",
" \$ENV{AUTOM4TE_CFG} ||= File::Spec->catfile(\$dist_dir, 'share/autoconf/autom4te.blib.cfg')\n",
" if \$d[-5] eq 'lib' && \$d[-6] eq 'blib';\n",
" \$ENV{trailer_m4} ||= File::Spec->catdir(\$dist_dir, 'share/autoconf/autoconf/trailer.m4');\n",
"}\n",
@lines
);
$exe->spew($shebang, @lines);
$exe->chmod("0755");
}
elsif($shebang =~ /^#!.*sh/)
{
@lines = (
": \${AUTOM4TE=`alien_autoconf_root`'/bin/autom4te'}\n",
": \${trailer_m4=`alien_autoconf_root`'/share/autoconf/autoconf/trailer.m4'}\n",
@lines
);
$exe->spew($shebang, @lines);
$exe->chmod("0755");
}
}
# patch autom4te config
{
my $orig = Path::Tiny->new('share/autoconf/autom4te.cfg');
my $new = Path::Tiny->new('share/autoconf/autom4te.blib.cfg');
my $stage = Path::Tiny->new($build->install_prop->{stage})->child('share/autoconf')->stringify;
$orig->copy($new);
$new->edit_lines(sub {
s/--prepend-include '(.*)'/--prepend-include '$stage'/;
});
}
# script to compute path to autoconf root
{
my $exe = Path::Tiny->new('bin/alien_autoconf_root');
my $perl = $ENV{PERL} || '/usr/bin/perl';
$exe->spew(
"#!$perl\n",
"use File::Spec;\n",
"my(\$v,\$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));\n",
"my \@d = File::Spec->splitdir(\$d);\n",
"pop \@d for 1..2;\n",
"my \$dist_dir = File::Spec->catpath(\$v,File::Spec->catdir(\@d), '');\n",
"print \$dist_dir\n",
);
$exe->chmod('0700');
}
},
);
};
#sys {
#
# gather sub {
# my($build) = @_;
# $build->runtime_prop->{version} = $build->install_prop->{my_version};
# };
#
#};
( run in 1.304 second using v1.01-cache-2.11-cpan-119454b85a5 )