]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
update and remove XXX comments
[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                 # XXX JEH perl_makemaker comes before makefile, so
25                 # couldn't it instead just test for Makefile.PL?
26                 if (-e "Makefile" &&
27                     system('grep -q "generated automatically by MakeMaker" Makefile') == 0) {
28                         return 1;
29                 }
30         }
31         # XXX JEH why test for configure here? If building or cleaning, and
32         # a Makefile.PL exists, we know this class can handle those
33         # actions -- it does so by inheriting from the makefile class.
34         elsif ($action eq "configure") {
35                 return -e "Makefile.PL";
36         }
37         else {
38                 return 0;
39         }
40 }
41
42 sub new {
43         my $cls=shift;
44         my $self=$cls->SUPER::new(@_);
45         $self->enforce_in_source_building();
46         return $self;
47 }
48
49 sub configure {
50         my $self=shift;
51         # If set to a true value then MakeMaker's prompt function will
52         # # always return the default without waiting for user input.
53         $ENV{PERL_MM_USE_DEFAULT}=1;
54         doit("perl", "Makefile.PL", "INSTALLDIRS=vendor", @_);
55 }
56
57 sub install {
58         my $self=shift;
59         my $destdir=shift;
60         # XXX JEH this test seems redundant with the one in
61         # is_auto_buildable, if we get here we know that one succeeded.
62         if (-e "Makefile" &&
63             system('grep -q "generated automatically by MakeMaker" Makefile') == 0) {
64                 $self->SUPER::install($destdir, "PREFIX=/usr", @_);
65         }
66         else {
67                 $self->SUPER::install($destdir, @_);
68         }
69 }
70
71 1;