]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
Merge branch 'master' of ssh://git.debian.org/git/debhelper/debhelper
[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 base 'Debian::Debhelper::Buildsystem::makefile';
11
12 sub DESCRIPTION {
13         "Perl ExtUtils::MakeMaker (Makefile.PL)"
14 }
15
16 sub check_auto_buildable {
17         my $this=shift;
18         my ($step)=@_;
19
20         # Handles everything if Makefile.PL exists. Otherwise - next class.
21         if (-e $this->get_sourcepath("Makefile.PL")) {
22                 if ($step eq "install" || $step eq "configure") {
23                         return 1;
24                 }
25                 else {
26                         # This is backwards compatible (with << 7.3) until build, test and
27                         # clean steps are not reimplemented in the backwards compatibility
28                         # breaking way. However, this is absolutely necessary for
29                         # enforce_in_source_building() to work in corner cases in build,
30                         # test and clean steps as the next class (makefile) does not
31                         # enforce it.
32                         return $this->SUPER::check_auto_buildable(@_);
33                 }
34         }
35         return 0;
36 }
37
38 sub new {
39         my $class=shift;
40         my $this=$class->SUPER::new(@_);
41         $this->enforce_in_source_building();
42         return $this;
43 }
44
45 sub configure {
46         my $this=shift;
47         # If set to a true value then MakeMaker's prompt function will
48         # # always return the default without waiting for user input.
49         $ENV{PERL_MM_USE_DEFAULT}=1;
50         # This prevents  Module::Install from interactive behavior.
51         $ENV{PERL_AUTOINSTALL}="--skipdeps";
52
53         $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor",
54             "create_packlist=0",
55             @_);
56 }
57
58 sub install {
59         my $this=shift;
60         my $destdir=shift;
61
62         # Special case for Makefile.PL that uses
63         # Module::Build::Compat. PREFIX should not be passed
64         # for those; it already installs into /usr by default.
65         my $makefile=$this->get_sourcepath("Makefile");
66         if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) {
67                 $this->SUPER::install($destdir, @_);
68         }
69         else {
70                 $this->SUPER::install($destdir, "PREFIX=/usr", @_);
71         }
72 }
73
74 1