]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
b2500ab71d6e78442b453981d3b787d9b6ff9d74
[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 "configure") {
23                         return 1;
24                 }
25                 else {
26                         return $this->SUPER::check_auto_buildable(@_);
27                 }
28         }
29         return 0;
30 }
31
32 sub new {
33         my $class=shift;
34         my $this=$class->SUPER::new(@_);
35         $this->enforce_in_source_building();
36         return $this;
37 }
38
39 sub configure {
40         my $this=shift;
41         # If set to a true value then MakeMaker's prompt function will
42         # # always return the default without waiting for user input.
43         $ENV{PERL_MM_USE_DEFAULT}=1;
44         # This prevents  Module::Install from interactive behavior.
45         $ENV{PERL_AUTOINSTALL}="--skipdeps";
46
47         $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor",
48             "create_packlist=0",
49             @_);
50 }
51
52 sub install {
53         my $this=shift;
54         my $destdir=shift;
55
56         # Special case for Makefile.PL that uses
57         # Module::Build::Compat. PREFIX should not be passed
58         # for those; it already installs into /usr by default.
59         my $makefile=$this->get_sourcepath("Makefile");
60         if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) {
61                 $this->SUPER::install($destdir, @_);
62         }
63         else {
64                 $this->SUPER::install($destdir, "PREFIX=/usr", @_);
65         }
66 }
67
68 1