]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_build.pm
Pass CPPFLAGS and LDFLAGS to Makefile.PL and Build.PL
[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 use Config;
13
14 sub DESCRIPTION {
15         "Perl Module::Build (Build.PL)"
16 }
17
18 sub check_auto_buildable {
19         my ($this, $step) = @_;
20
21         # Handles everything
22         my $ret = -e $this->get_sourcepath("Build.PL");
23         if ($step ne "configure") {
24                 $ret &&= -e $this->get_sourcepath("Build");
25         }
26         return $ret ? 1 : 0;
27 }
28
29 sub do_perl {
30         my $this=shift;
31         $this->doit_in_sourcedir("perl", @_);
32 }
33
34 sub new {
35         my $class=shift;
36         my $this= $class->SUPER::new(@_);
37         $this->enforce_in_source_building();
38         return $this;
39 }
40
41 sub configure {
42         my $this=shift;
43         my @flags;
44         $ENV{PERL_MM_USE_DEFAULT}=1;
45         if ($ENV{CFLAGS} && ! compat(8)) {
46                 push @flags, "config=optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}";
47         }
48         if ($ENV{LDFLAGS} && ! compat(8)) {
49                 push @flags, "config=ld=$Config{ld} $ENV{LDFLAGS}";
50         }
51         $this->do_perl("Build.PL", "installdirs=vendor", @flags, @_);
52 }
53
54 sub build {
55         my $this=shift;
56         $this->do_perl("Build", @_);
57 }
58
59 sub test {
60         my $this=shift;
61         $this->do_perl("Build", "test", @_);
62 }
63
64 sub install {
65         my $this=shift;
66         my $destdir=shift;
67         $this->do_perl("Build", "install", "destdir=$destdir", "create_packlist=0", @_);
68 }
69
70 sub clean {
71         my $this=shift;
72         if (-e $this->get_sourcepath("Build")) {
73                 $this->do_perl("Build", "--allow_mb_mismatch", 1, "distclean", @_);
74         }
75 }
76
77 1