On 11 May 2010 14:49, Bill Moseley <[email protected]> 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 approach,
> 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 = qw( ... );
my @copy_files = qw( ... );

WriteMakefile(
...
);

package MY;

sub postamble {
    my $s = <<'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 .= "\t\$(MKPATH) \$(C_APPDIR)/$path\n";
    }

    # add copy file command lines to the my_install target
    for my $path (@copy_files) {
        $s .= "\t\$(CP) $path \$(C_APPDIR)/$path\n";
    }

    return $s;
}

# add dependency my_install to target install, to call postamble target
sub install {
    my $class = shift;
    my $basic = $class->SUPER::install(@_);
    $basic =~ s/^(install :: .*)$/$1 my_install/m;
    return $basic;
}

sub my_config_vars {
    return {
       C_APPDIR => '/some/path/',
    };
};

# add variables for use in postamble my_install target
sub constants {
    my $class = shift;
    my $basic = $class->SUPER::constants(@_);

    my $vars = $my_config_vars;
    my @prepend = map { "$_ = $vars->{$_}" } sort keys %$vars;

    return join("\n",@prepend) . "\n" . $basic;
}


Regards, Peter
http://perl.dragonstaff.co.uk
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to