]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
merge
[debhelper.git] / Debian / Debhelper / Buildsystem / perl_makemaker.pm
1 # A debhelper build system class 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 qw(compat);
11 use base 'Debian::Debhelper::Buildsystem::makefile';
12
13 sub DESCRIPTION {
14         "Perl ExtUtils::MakeMaker (Makefile.PL)"
15 }
16
17 sub check_auto_buildable {
18         my $this=shift;
19         my ($step)=@_;
20
21         # Handles everything if Makefile.PL exists. Otherwise - next class.
22         if (-e $this->get_sourcepath("Makefile.PL")) {
23                 if ($step eq "configure") {
24                         return 1;
25                 }
26                 else {
27                         return $this->SUPER::check_auto_buildable(@_);
28                 }
29         }
30         return 0;
31 }
32
33 sub new {
34         my $class=shift;
35         my $this=$class->SUPER::new(@_);
36         $this->enforce_in_source_building();
37         return $this;
38 }
39
40 sub configure {
41         my $this=shift;
42         # If set to a true value then MakeMaker's prompt function will
43         # # always return the default without waiting for user input.
44         $ENV{PERL_MM_USE_DEFAULT}=1;
45         # This prevents  Module::Install from interactive behavior.
46         $ENV{PERL_AUTOINSTALL}="--skipdeps";
47
48         $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor",
49                 # if perl_build is not tested first, need to pass packlist
50                 # option to handle fallthrough case
51                 (compat(7) ? "create_packlist=0" : ()),
52                 @_);
53 }
54
55 sub install {
56         my $this=shift;
57         my $destdir=shift;
58
59         # Special case for Makefile.PL that uses
60         # Module::Build::Compat. PREFIX should not be passed
61         # for those; it already installs into /usr by default.
62         my $makefile=$this->get_sourcepath("Makefile");
63         if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) {
64                 $this->SUPER::install($destdir, @_);
65         }
66         else {
67                 $this->SUPER::install($destdir, "PREFIX=/usr", @_);
68         }
69 }
70
71 1