]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_makemaker.pm
setting OPTIMIZE could in theory lead to breakage, so make it v9
[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         my @flags;
43         # If set to a true value then MakeMaker's prompt function will
44         # # always return the default without waiting for user input.
45         $ENV{PERL_MM_USE_DEFAULT}=1;
46         # This prevents  Module::Install from interactive behavior.
47         $ENV{PERL_AUTOINSTALL}="--skipdeps";
48
49         if ($ENV{CFLAGS} && ! compat(8)) {
50                 push @flags, "OPTIMIZE=$ENV{CFLAGS}";
51         }
52
53         $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor",
54                 # if perl_build is not tested first, need to pass packlist
55                 # option to handle fallthrough case
56                 (compat(7) ? "create_packlist=0" : ()),
57                 @flags, @_);
58 }
59
60 sub install {
61         my $this=shift;
62         my $destdir=shift;
63
64         # Special case for Makefile.PL that uses
65         # Module::Build::Compat. PREFIX should not be passed
66         # for those; it already installs into /usr by default.
67         my $makefile=$this->get_sourcepath("Makefile");
68         if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) {
69                 $this->SUPER::install($destdir, @_);
70         }
71         else {
72                 $this->SUPER::install($destdir, "PREFIX=/usr", @_);
73         }
74 }
75
76 1