]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_build.pm
724e1e07fa63bfb0d2be16873aaf4eabdc771945
[debhelper.git] / Debian / Debhelper / Buildsystem / perl_build.pm
1 # A build system class for handling Perl Build 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_build;
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib qw(compat);
11 use base 'Debian::Debhelper::Buildsystem';
12
13 sub DESCRIPTION {
14         "Perl Module::Build (Build.PL)"
15 }
16
17 sub check_auto_buildable {
18         my ($this, $step) = @_;
19
20         # Handles everything
21         my $ret = -e $this->get_sourcepath("Build.PL");
22         if ($step ne "configure") {
23                 $ret &&= -e $this->get_sourcepath("Build");
24         }
25         return $ret ? 1 : 0;
26 }
27
28 sub do_perl {
29         my $this=shift;
30         $this->doit_in_sourcedir("perl", @_);
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         $ENV{PERL_MM_USE_DEFAULT}=1;
44         if ($ENV{CFLAGS} && ! compat(8)) {
45                 push @flags, "config=optimize=$ENV{CFLAGS}";
46         }
47         $this->do_perl("Build.PL", "installdirs=vendor", @flags, @_);
48 }
49
50 sub build {
51         my $this=shift;
52         $this->do_perl("Build", @_);
53 }
54
55 sub test {
56         my $this=shift;
57         $this->do_perl("Build", "test", @_);
58 }
59
60 sub install {
61         my $this=shift;
62         my $destdir=shift;
63         $this->do_perl("Build", "install", "destdir=$destdir", "create_packlist=0", @_);
64 }
65
66 sub clean {
67         my $this=shift;
68         if (-e $this->get_sourcepath("Build")) {
69                 $this->do_perl("Build", "--allow_mb_mismatch", 1, "distclean", @_);
70         }
71 }
72
73 1