]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
Modular object-orientied buildsystem implementation (try 2).
[debhelper.git] / Debian / Debhelper / Buildsystem / perl_makemaker.pm
1 # A buildsystem plugin for handling Perl MakeMaker based projects.
2 #
3 # Copyright: © 2008-2009 Joey Hess
4 #            © 2008-2009 Modestas Vainius
5 # License: GPL-2+
6
7 package Debian::Debhelper::Buildsystem::perl_makemaker;
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11 use base 'Debian::Debhelper::Buildsystem::makefile';
12
13 sub DESCRIPTION {
14         "support for building Perl MakeMaker based packages (in-source only)"
15 }
16
17 sub is_auto_buildable {
18         my ($self, $action)=@_;
19
20         # Handles configure, install; the rest - next class
21         if ($action eq "install") {
22                 # This hack is needed to keep full 100% compatibility with previous
23                 # debhelper versions.
24                 if (-e "Makefile" &&
25                     system('grep -q "generated automatically by MakeMaker" Makefile') == 0) {
26                         return 1;
27                 }
28         }
29         elsif ($action eq "configure") {
30                 return -e "Makefile.PL";
31         }
32         else {
33                 return 0;
34         }
35 }
36
37 sub new {
38         my $cls=shift;
39         my $self=$cls->SUPER::new(@_);
40         $self->enforce_in_source_building();
41         return $self;
42 }
43
44 sub configure {
45         my $self=shift;
46         # If set to a true value then MakeMaker's prompt function will
47         # # always return the default without waiting for user input.
48         $ENV{PERL_MM_USE_DEFAULT}=1;
49         doit("perl", "Makefile.PL", "INSTALLDIRS=vendor", @_);
50 }
51
52 sub install {
53         my $self=shift;
54         my $destdir=shift;
55         # XXX JEH This is a really unfortunate breaking of the
56         # encapsulation of the perl_makefile module. Perhaps it would be
57         # better for that module to contain some hack that injects that
58         # test into this one?
59         # XXX MDX Solved. perl_makemaker will need come before makefile in
60         # @BUILDSYSTEMS. See also hack in is_auto_buildable().
61         # This is a safety check needed to keep 100% compatibility with
62         # earlier debhelper behaviour. This if is very unlikely to be false.
63         if (-e "Makefile" &&
64             system('grep -q "generated automatically by MakeMaker" Makefile') == 0) {
65                 $self->SUPER::install($destdir, "PREFIX=/usr", @_);
66         } else {
67                 $self->SUPER::install($destdir, @_);
68         }
69 }
70
71 1;