]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/perl_build.pm
Merge branch 'master' into buildsystems
[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 =head1 NAME
10
11 B<perl_build> - Perl Module::Build (Build.PL)
12
13 =head1 SYNOPSIS
14
15 B<dh_auto_*> [B<--buildsystem>=I<perl_build>] ...
16
17 =head1 DESCRIPTION
18
19 Module::Build is a system for building, testing, and installing Perl modules.
20 It does not require a C<make> on your system - most of the Module::Build code is
21 pure-perl and written in a very cross-platform way. Its only prerequisites are
22 modules that are included with perl 5.6.0. Typically, Module::Build build system
23 can be identified by presence of the F<Build.PL> script in the source
24 directory.
25
26 =head1 DH_AUTO NOTES
27
28 Out of source tree building is not supported. C<MODULEBUILDRC=/dev/null>
29 environment variable is exported in each building step.
30
31 =head1 BUILD PROCESS
32
33 =cut
34
35 use strict;
36 use base 'Debian::Debhelper::Buildsystem';
37
38 sub DESCRIPTION {
39         "Perl Module::Build (Build.PL)"
40 }
41
42 sub check_auto_buildable {
43         my ($this, $step) = @_;
44
45         # Handles everything
46         my $ret = -e $this->get_sourcepath("Build.PL");
47         if ($step ne "configure") {
48                 $ret &&= -e $this->get_sourcepath("Build");
49         }
50         return $ret;
51 }
52
53 sub do_perl {
54         my $this=shift;
55         $ENV{MODULEBUILDRC} = "/dev/null";
56         $this->doit_in_sourcedir("perl", @_);
57 }
58
59 sub new {
60         my $class=shift;
61         my $this= $class->SUPER::new(@_);
62         $this->enforce_in_source_building();
63         return $this;
64 }
65
66 =head2 Configure step
67
68 =over 4
69
70 =item I<Behaviour>
71
72 Execute C<perl Build.PL> passing C<installdirs=vendor> parameter by default.
73 Environment variable C<PERL_MM_USE_DEFAULT> is set before running the script.
74
75 =item I<Auto-selection>
76
77 If F<configure>, F<Makefile.PL>, F<setup.py> do not exist, but F<Build.PL>
78 exists in the source directory.
79
80 =back
81
82 =cut
83 sub configure {
84         my $this=shift;
85         $ENV{PERL_MM_USE_DEFAULT}=1;
86         $this->do_perl("Build.PL", "installdirs=vendor", @_);
87 }
88
89 =head2 Build step
90
91 =over 4
92
93 =item I<Behaviour>
94
95 Execute C<perl Build>.
96
97 =item I<Auto-selection>
98
99 If F<Makefile>, F<makefile>, F<GNUmakefile> (build directory) and F<setup.py>
100 (source directory) do not exist, but F<Build.PL> and F<Build> files exist in
101 the source directory.
102
103 =back
104
105 =cut
106 sub build {
107         my $this=shift;
108         $this->do_perl("Build", @_);
109 }
110
111 =head2 Test step
112
113 =over 4
114
115 =item I<Behaviour>
116
117 Execute C<perl Build test>.
118
119 =item I<Auto-selection>
120
121 If F<Makefile>, F<makefile>, F<GNUmakefile> (build directory) and F<setup.py>
122 (source directory) do not exist, but F<Build.PL> and F<Build> files exist in
123 the source directory.
124
125 =back
126
127 =cut
128 sub test {
129         my $this=shift;
130         $this->do_perl("Build", "test", @_);
131 }
132
133 =head2 Install step
134
135 =over 4
136
137 =item I<Behaviour>
138
139 Execute C<perl Build install destdir=$destdir create_packlist=0>. $destdir is
140 the path to the temporary installation directory (see L<dh_auto_install(1)>).
141
142 =item I<Auto-selection>
143
144 If F<Makefile>, F<makefile>, F<GNUmakefile> (build directory) and F<setup.py>
145 (source directory) do not exist, but F<Build.PL> and F<Build> files exist in
146 the source directory.
147
148 =back
149
150 =cut
151 sub install {
152         my $this=shift;
153         my $destdir=shift;
154         $this->do_perl("Build", "install", "destdir=$destdir", "create_packlist=0", @_);
155 }
156
157 =head2 Clean step
158
159 =over 4
160
161 =item I<Behaviour>
162
163 Execute C<perl Build --allow_mb_mismatch 1 distclean>.
164
165 =item I<Auto-selection>
166
167 If F<Makefile>, F<makefile>, F<GNUmakefile> (build directory) and F<setup.py>
168 (source directory) do not exist, but F<Build.PL> and F<Build> files exist in
169 the source directory.
170
171 =back
172
173 =cut
174 sub clean {
175         my $this=shift;
176         $this->do_perl("Build", "--allow_mb_mismatch", 1, "distclean", @_);
177 }
178
179 =head1 SEE ALSO
180
181 L<dh_auto(7)>
182
183 =head1 AUTHORS
184
185  Joey Hess <joeyh@debian.org>
186  Modestas Vainius <modestas@vainius.eu>
187
188 =cut
189
190 1;