]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/autotools.pm
code review, added comments
[debhelper.git] / Debian / Debhelper / Buildsystem / autotools.pm
1 # A buildsystem plugin for handling autotools based projects
2 #
3 # Copyright: © 2008 Joey Hess
4 #            © 2008-2009 Modestas Vainius
5 # License: GPL-2+
6
7 package Debian::Debhelper::Buildsystem::autotools;
8
9 use strict;
10 use File::Spec;
11 use Debian::Debhelper::Dh_Lib;
12 use base 'Debian::Debhelper::Buildsystem::makefile';
13
14 sub DESCRIPTION {
15         "support for building GNU Autotools based packages"
16 }
17
18 sub is_buildable {
19         my $self=shift;
20         my ($action) = @_;
21         if ($action eq "configure") {
22                 return -x "configure";
23         } else {
24                 return $self->SUPER::is_buildable(@_);
25         }
26 }
27
28 sub configure_impl {
29         my $self=shift;
30
31         # Standard set of options for configure.
32         my @opts;
33         push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
34         push @opts, "--prefix=/usr";
35         push @opts, "--includedir=\${prefix}/include";
36         push @opts, "--mandir=\${prefix}/share/man";
37         push @opts, "--infodir=\${prefix}/share/info";
38         push @opts, "--sysconfdir=/etc";
39         push @opts, "--localstatedir=/var";
40         # XXX JEH this is where the sheer evil of Dh_Buildsystem_Chdir
41         # becomes evident. Why is exec_in_topdir needed here?
42         # Because:
43         # - The parent class happens to be derived from Dh_Buildsystem_Chdir.
44         # - sourcepage() happens to, like many other parts of debhelper's
45         #   library, assume it's being run in the top of the source tree,
46         #   and fails if it's not.
47         # Having to worry about interactions like that for every line of
48         # every derived method is simply not acceptable.
49         # Dh_Buildsystem_Chdir must die! -- JEH
50         push @opts, "--libexecdir=\${prefix}/lib/" . $self->exec_in_topdir(\&sourcepackage);
51         push @opts, "--disable-maintainer-mode";
52         push @opts, "--disable-dependency-tracking";
53         # Provide --host only if different from --build, as recommended in
54         # autotools-dev README.Debian: When provided (even if equal) autotools
55         # 2.52+ switches to cross-compiling mode.
56         if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
57             ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
58                 push @opts, "--host=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE");
59         }
60
61         # XXX JEH the reason it needs to use get_toppath here,
62         # but does not need to in the is_buildable method is not clear,
63         # unless one is familiar with the implementation of its parent
64         # class. I think that speaks to a bad design..
65         doit($self->get_toppath("configure"), @opts, @_);
66 }
67
68 1;