[Catalyst] Adding build scripts to Makefile.PL
Peter Edwards
peter at dragonstaff.co.uk
Tue May 11 14:29:11 GMT 2010
On 11 May 2010 14:49, Bill Moseley <moseley at hank.org> wrote:
> I've used postamble to add new targets ("make foo") but I'm not clear how
> to make just "make" depend on them. Maybe that's not the correct approa=
ch,
> but I want our existing tools that build RPMs to run this code as part of
> the normal make process .
>
An EUMM version based on an app I wrote that generates a makefile with a
custom 'make install' target line.
I'll keep out of the MI / MB holy wars, this needed to work in a specific
environment with an old perl setup.
use ExtUtils::MakeMaker;
use ExtUtils::Manifest;
use ExtUtils::Install;
my @make_paths =3D qw( ... );
my @copy_files =3D qw( ... );
WriteMakefile(
...
);
package MY;
sub postamble {
my $s =3D <<'EOM';
my_make ::
# examples of how you could use a script or separate makefile to do the
install
@${PERL} -I$(INST_LIB) bin/my_deploy.pl
\$(MAKE) -f Makefile.my
my_install ::
some commands here
EOM
# add create dir command lines to the my_install target
for my $path (@make_paths) {
$s .=3D "\t\$(MKPATH) \$(C_APPDIR)/$path\n";
}
# add copy file command lines to the my_install target
for my $path (@copy_files) {
$s .=3D "\t\$(CP) $path \$(C_APPDIR)/$path\n";
}
return $s;
}
# add dependency my_install to target install, to call postamble target
sub install {
my $class =3D shift;
my $basic =3D $class->SUPER::install(@_);
$basic =3D~ s/^(install :: .*)$/$1 my_install/m;
return $basic;
}
sub my_config_vars {
return {
C_APPDIR =3D> '/some/path/',
};
};
# add variables for use in postamble my_install target
sub constants {
my $class =3D shift;
my $basic =3D $class->SUPER::constants(@_);
my $vars =3D $my_config_vars;
my @prepend =3D map { "$_ =3D $vars->{$_}" } sort keys %$vars;
return join("\n", at prepend) . "\n" . $basic;
}
Regards, Peter
http://perl.dragonstaff.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100511/cac59=
5ae/attachment.htm
More information about the Catalyst
mailing list