summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Buildsystem
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2013-11-10 15:23:29 -0400
committerJoey Hess <joeyh@debian.org>2013-11-10 15:23:29 -0400
commit868ba759bb6eec429139205e01f59f494cdaf98b (patch)
tree36d25c13f7c002867e6b5cb0acd70398d79c00e3 /Debian/Debhelper/Buildsystem
debhelper (9.20131110) unstable; urgency=low
* dh_installinit: Revert changes that added versioned dependency on sysv-rc to support upstart, which later grew to a versioned dependency on sysv-rc | file-rc, and which seems to want to continue growing to list other init systems, which there currently seem to be far too many of, for far too little benefit. The sysv-rc dependency is already met in stable. The file-rc dependency is not, so if someone cares about that, they need to find a properly designed solution, which this was not. Closes: #729248 # imported from the archive
Diffstat (limited to 'Debian/Debhelper/Buildsystem')
-rw-r--r--Debian/Debhelper/Buildsystem/ant.pm37
-rw-r--r--Debian/Debhelper/Buildsystem/autoconf.pm75
-rw-r--r--Debian/Debhelper/Buildsystem/cmake.pm77
-rw-r--r--Debian/Debhelper/Buildsystem/makefile.pm152
-rw-r--r--Debian/Debhelper/Buildsystem/perl_build.pm77
-rw-r--r--Debian/Debhelper/Buildsystem/perl_makemaker.pm80
-rw-r--r--Debian/Debhelper/Buildsystem/python_distutils.pm210
-rw-r--r--Debian/Debhelper/Buildsystem/qmake.pm83
-rw-r--r--Debian/Debhelper/Buildsystem/qmake_qt4.pm18
9 files changed, 809 insertions, 0 deletions
diff --git a/Debian/Debhelper/Buildsystem/ant.pm b/Debian/Debhelper/Buildsystem/ant.pm
new file mode 100644
index 00000000..52def4f6
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/ant.pm
@@ -0,0 +1,37 @@
+# A debhelper build system class for handling Ant based projects.
+#
+# Copyright: © 2009 Joey Hess
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::ant;
+
+use strict;
+use base 'Debian::Debhelper::Buildsystem';
+
+sub DESCRIPTION {
+ "Ant (build.xml)"
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ return (-e $this->get_sourcepath("build.xml")) ? 1 : 0;
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ $this->enforce_in_source_building();
+ return $this;
+}
+
+sub build {
+ my $this=shift;
+ $this->doit_in_sourcedir("ant", @_);
+}
+
+sub clean {
+ my $this=shift;
+ $this->doit_in_sourcedir("ant", "clean", @_);
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/autoconf.pm b/Debian/Debhelper/Buildsystem/autoconf.pm
new file mode 100644
index 00000000..20b9fd44
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/autoconf.pm
@@ -0,0 +1,75 @@
+# A debhelper build system class for handling Autoconf based projects
+#
+# Copyright: © 2008 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::autoconf;
+
+use strict;
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat);
+use base 'Debian::Debhelper::Buildsystem::makefile';
+
+sub DESCRIPTION {
+ "GNU Autoconf (configure)"
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ my ($step)=@_;
+
+ # Handle configure; the rest - next class (compat with 7.0.x code path)
+ if ($step eq "configure") {
+ return 1 if -x $this->get_sourcepath("configure");
+ }
+ return 0;
+}
+
+sub configure {
+ my $this=shift;
+
+ # Standard set of options for configure.
+ my @opts;
+ push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
+ push @opts, "--prefix=/usr";
+ push @opts, "--includedir=\${prefix}/include";
+ push @opts, "--mandir=\${prefix}/share/man";
+ push @opts, "--infodir=\${prefix}/share/info";
+ push @opts, "--sysconfdir=/etc";
+ push @opts, "--localstatedir=/var";
+ my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH");
+ if (! compat(8)) {
+ if (defined $multiarch) {
+ push @opts, "--libdir=\${prefix}/lib/$multiarch";
+ push @opts, "--libexecdir=\${prefix}/lib/$multiarch";
+ }
+ else {
+ push @opts, "--libexecdir=\${prefix}/lib";
+ }
+ }
+ else {
+ push @opts, "--libexecdir=\${prefix}/lib/" . sourcepackage();
+ }
+ push @opts, "--disable-maintainer-mode";
+ push @opts, "--disable-dependency-tracking";
+ # Provide --host only if different from --build, as recommended in
+ # autotools-dev README.Debian: When provided (even if equal)
+ # autoconf 2.52+ switches to cross-compiling mode.
+ if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
+ ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
+ push @opts, "--host=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE");
+ }
+
+ $this->mkdir_builddir();
+ eval {
+ $this->doit_in_builddir($this->get_source_rel2builddir("configure"), @opts, @_);
+ };
+ if ($@) {
+ if (-e $this->get_buildpath("config.log")) {
+ $this->doit_in_builddir("tail -v -n +0 config.log");
+ }
+ die $@;
+ }
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm
new file mode 100644
index 00000000..d47821ca
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/cmake.pm
@@ -0,0 +1,77 @@
+# A debhelper build system class for handling CMake based projects.
+# It prefers out of source tree building.
+#
+# Copyright: © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::cmake;
+
+use strict;
+use Debian::Debhelper::Dh_Lib qw(compat);
+use base 'Debian::Debhelper::Buildsystem::makefile';
+
+sub DESCRIPTION {
+ "CMake (CMakeLists.txt)"
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ my ($step)=@_;
+ if (-e $this->get_sourcepath("CMakeLists.txt")) {
+ my $ret = ($step eq "configure" && 1) ||
+ $this->SUPER::check_auto_buildable(@_);
+ # Existence of CMakeCache.txt indicates cmake has already
+ # been used by a prior build step, so should be used
+ # instead of the parent makefile class.
+ $ret++ if ($ret && -e $this->get_buildpath("CMakeCache.txt"));
+ return $ret;
+ }
+ return 0;
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ $this->prefer_out_of_source_building(@_);
+ return $this;
+}
+
+sub configure {
+ my $this=shift;
+ my @flags;
+
+ # Standard set of cmake flags
+ push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
+ push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
+ push @flags, "-DCMAKE_BUILD_TYPE=RelWithDebInfo";
+
+ # CMake doesn't respect CPPFLAGS, see #653916.
+ if ($ENV{CPPFLAGS} && ! compat(8)) {
+ $ENV{CFLAGS} .= ' ' . $ENV{CPPFLAGS};
+ $ENV{CXXFLAGS} .= ' ' . $ENV{CPPFLAGS};
+ }
+
+ $this->mkdir_builddir();
+ eval {
+ $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_);
+ };
+ if ($@) {
+ if (-e $this->get_buildpath("CMakeCache.txt")) {
+ $this->doit_in_builddir("tail -v -n +0 CMakeCache.txt");
+ }
+ die $@;
+ }
+}
+
+sub test {
+ my $this=shift;
+
+ # Unlike make, CTest does not have "unlimited parallel" setting (-j implies
+ # -j1). So in order to simulate unlimited parallel, allow to fork a huge
+ # number of threads instead.
+ my $parallel = ($this->get_parallel() > 0) ? $this->get_parallel() : 999;
+ $ENV{CTEST_OUTPUT_ON_FAILURE} = 1;
+ return $this->SUPER::test(@_, "ARGS+=-j$parallel");
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm
new file mode 100644
index 00000000..2c68a836
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/makefile.pm
@@ -0,0 +1,152 @@
+# A debhelper build system class for handling simple Makefile based projects.
+#
+# Copyright: © 2008 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::makefile;
+
+use strict;
+use Debian::Debhelper::Dh_Lib qw(escape_shell clean_jobserver_makeflags);
+use base 'Debian::Debhelper::Buildsystem';
+
+# make makes things difficult by not providing a simple way to test
+# whether a Makefile target exists. Using -n and checking for a nonzero
+# exit status is not good enough, because even with -n, make will
+# run commands needed to eg, generate include files -- and those commands
+# could fail even though the target exists -- and we should let the target
+# run and propagate any failure.
+#
+# Using -n and checking for at least one line of output is better.
+# That will indicate make either wants to run one command, or
+# has output a "nothing to be done" message if the target exists but is a
+# noop.
+#
+# However, that heuristic is also not good enough, because a Makefile
+# could run code that outputs something, even though the -n is asking
+# it not to run anything. (Again, done for includes.) To detect this false
+# positive, there is unfortunately only one approach left: To
+# look for the error message printed by make when a target does not exist.
+#
+# This could break if make's output changes. It would only break a minority
+# of packages where this latter test is needed. The best way to avoid that
+# problem would be to fix make to have this simple and highly useful
+# missing feature.
+#
+# A final option would be to use -p and parse the output data base.
+# It's more practical for dh to use that method, since it operates on
+# only special debian/rules files, and not arbitrary Makefiles which
+# can be arbitrarily complicated, use implicit targets, and so on.
+sub exists_make_target {
+ my $this=shift;
+ my $target=shift;
+
+ my @opts=("-s", "-n", "--no-print-directory");
+ my $buildpath = $this->get_buildpath();
+ unshift @opts, "-C", $buildpath if $buildpath ne ".";
+
+ my $pid = open(MAKE, "-|");
+ defined($pid) || die "can't fork: $!";
+ if (! $pid) {
+ open(STDERR, ">&STDOUT");
+ $ENV{LC_ALL}='C';
+ exec($this->{makecmd}, @opts, $target, @_);
+ exit(1);
+ }
+
+ local $/=undef;
+ my $output=<MAKE>;
+ chomp $output;
+ close MAKE;
+
+ return defined $output
+ && length $output
+ && $output !~ /\*\*\* No rule to make target (`|')\Q$target\E'/;
+}
+
+sub do_make {
+ my $this=shift;
+
+ # Avoid possible warnings about unavailable jobserver,
+ # and force make to start a new jobserver.
+ clean_jobserver_makeflags();
+
+ # Note that this will override any -j settings in MAKEFLAGS.
+ unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : "");
+
+ $this->doit_in_builddir($this->{makecmd}, @_);
+}
+
+sub make_first_existing_target {
+ my $this=shift;
+ my $targets=shift;
+
+ foreach my $target (@$targets) {
+ if ($this->exists_make_target($target, @_)) {
+ $this->do_make($target, @_);
+ return $target;
+ }
+ }
+ return undef;
+}
+
+sub DESCRIPTION {
+ "simple Makefile"
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ $this->{makecmd} = (exists $ENV{MAKE}) ? $ENV{MAKE} : "make";
+ return $this;
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ my ($step) = @_;
+
+ if (-e $this->get_buildpath("Makefile") ||
+ -e $this->get_buildpath("makefile") ||
+ -e $this->get_buildpath("GNUmakefile"))
+ {
+ # This is always called in the source directory, but generally
+ # Makefiles are created (or live) in the build directory.
+ return 1;
+ } elsif ($step eq "clean" && defined $this->get_builddir() &&
+ $this->check_auto_buildable("configure"))
+ {
+ # Assume that the package can be cleaned (i.e. the build directory can
+ # be removed) as long as it is built out-of-source tree and can be
+ # configured. This is useful for derivative buildsystems which
+ # generate Makefiles.
+ return 1;
+ }
+ return 0;
+}
+
+sub build {
+ my $this=shift;
+ $this->do_make(@_);
+}
+
+sub test {
+ my $this=shift;
+ $this->make_first_existing_target(['test', 'check'], @_);
+}
+
+sub install {
+ my $this=shift;
+ my $destdir=shift;
+ $this->make_first_existing_target(['install'],
+ "DESTDIR=$destdir",
+ "AM_UPDATE_INFO_DIR=no", @_);
+}
+
+sub clean {
+ my $this=shift;
+ if (!$this->rmdir_builddir()) {
+ $this->make_first_existing_target(['distclean', 'realclean', 'clean'], @_);
+ }
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/perl_build.pm b/Debian/Debhelper/Buildsystem/perl_build.pm
new file mode 100644
index 00000000..bfe1c08e
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/perl_build.pm
@@ -0,0 +1,77 @@
+# A build system class for handling Perl Build based projects.
+#
+# Copyright: © 2008-2009 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::perl_build;
+
+use strict;
+use Debian::Debhelper::Dh_Lib qw(compat);
+use base 'Debian::Debhelper::Buildsystem';
+use Config;
+
+sub DESCRIPTION {
+ "Perl Module::Build (Build.PL)"
+}
+
+sub check_auto_buildable {
+ my ($this, $step) = @_;
+
+ # Handles everything
+ my $ret = -e $this->get_sourcepath("Build.PL");
+ if ($step ne "configure") {
+ $ret &&= -e $this->get_sourcepath("Build");
+ }
+ return $ret ? 1 : 0;
+}
+
+sub do_perl {
+ my $this=shift;
+ $this->doit_in_sourcedir("perl", @_);
+}
+
+sub new {
+ my $class=shift;
+ my $this= $class->SUPER::new(@_);
+ $this->enforce_in_source_building();
+ return $this;
+}
+
+sub configure {
+ my $this=shift;
+ my @flags;
+ $ENV{PERL_MM_USE_DEFAULT}=1;
+ if ($ENV{CFLAGS} && ! compat(8)) {
+ push @flags, "--config", "optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}";
+ }
+ if ($ENV{LDFLAGS} && ! compat(8)) {
+ push @flags, "--config", "ld=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}";
+ }
+ $this->do_perl("Build.PL", "--installdirs", "vendor", @flags, @_);
+}
+
+sub build {
+ my $this=shift;
+ $this->do_perl("Build", @_);
+}
+
+sub test {
+ my $this=shift;
+ $this->do_perl("Build", "test", @_);
+}
+
+sub install {
+ my $this=shift;
+ my $destdir=shift;
+ $this->do_perl("Build", "install", "--destdir", "$destdir", "--create_packlist", 0, @_);
+}
+
+sub clean {
+ my $this=shift;
+ if (-e $this->get_sourcepath("Build")) {
+ $this->do_perl("Build", "distclean", "--allow_mb_mismatch", 1, @_);
+ }
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/perl_makemaker.pm b/Debian/Debhelper/Buildsystem/perl_makemaker.pm
new file mode 100644
index 00000000..60cda3d0
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/perl_makemaker.pm
@@ -0,0 +1,80 @@
+# A debhelper build system class for handling Perl MakeMaker based projects.
+#
+# Copyright: © 2008-2009 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::perl_makemaker;
+
+use strict;
+use Debian::Debhelper::Dh_Lib qw(compat);
+use base 'Debian::Debhelper::Buildsystem::makefile';
+use Config;
+
+sub DESCRIPTION {
+ "Perl ExtUtils::MakeMaker (Makefile.PL)"
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ my ($step)=@_;
+
+ # Handles everything if Makefile.PL exists. Otherwise - next class.
+ if (-e $this->get_sourcepath("Makefile.PL")) {
+ if ($step eq "configure") {
+ return 1;
+ }
+ else {
+ return $this->SUPER::check_auto_buildable(@_);
+ }
+ }
+ return 0;
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ $this->enforce_in_source_building();
+ return $this;
+}
+
+sub configure {
+ my $this=shift;
+ my @flags;
+ # If set to a true value then MakeMaker's prompt function will
+ # # always return the default without waiting for user input.
+ $ENV{PERL_MM_USE_DEFAULT}=1;
+ # This prevents Module::Install from interactive behavior.
+ $ENV{PERL_AUTOINSTALL}="--skipdeps";
+
+ if ($ENV{CFLAGS} && ! compat(8)) {
+ push @flags, "OPTIMIZE=$ENV{CFLAGS} $ENV{CPPFLAGS}";
+ }
+ if ($ENV{LDFLAGS} && ! compat(8)) {
+ push @flags, "LD=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}";
+ }
+
+ $this->doit_in_sourcedir("perl", "Makefile.PL", "INSTALLDIRS=vendor",
+ # if perl_build is not tested first, need to pass packlist
+ # option to handle fallthrough case
+ (compat(7) ? "create_packlist=0" : ()),
+ @flags, @_);
+}
+
+sub install {
+ my $this=shift;
+ my $destdir=shift;
+
+ # Special case for Makefile.PL that uses
+ # Module::Build::Compat. PREFIX should not be passed
+ # for those; it already installs into /usr by default.
+ my $makefile=$this->get_sourcepath("Makefile");
+ if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) {
+ $this->SUPER::install($destdir, @_);
+ }
+ else {
+ $this->SUPER::install($destdir, "PREFIX=/usr", @_);
+ }
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/python_distutils.pm b/Debian/Debhelper/Buildsystem/python_distutils.pm
new file mode 100644
index 00000000..c3d58cc0
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/python_distutils.pm
@@ -0,0 +1,210 @@
+# A debhelper build system class for building Python Distutils based
+# projects. It prefers out of source tree building.
+#
+# Copyright: © 2008 Joey Hess
+# © 2008-2009 Modestas Vainius
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::python_distutils;
+
+use strict;
+use Cwd ();
+use Debian::Debhelper::Dh_Lib qw(error);
+use base 'Debian::Debhelper::Buildsystem';
+
+sub DESCRIPTION {
+ "Python Distutils (setup.py)"
+}
+
+sub DEFAULT_BUILD_DIRECTORY {
+ my $this=shift;
+ return $this->canonpath($this->get_sourcepath("build"));
+}
+
+sub new {
+ my $class=shift;
+ my $this=$class->SUPER::new(@_);
+ # Out of source tree building is preferred.
+ $this->prefer_out_of_source_building(@_);
+ return $this;
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ return -e $this->get_sourcepath("setup.py") ? 1 : 0;
+}
+
+sub not_our_cfg {
+ my $this=shift;
+ my $ret;
+ if (open(my $cfg, $this->get_buildpath(".pydistutils.cfg"))) {
+ $ret = not "# Created by dh_auto\n" eq <$cfg>;
+ close $cfg;
+ }
+ return $ret;
+}
+
+sub create_cfg {
+ my $this=shift;
+ if (open(my $cfg, ">", $this->get_buildpath(".pydistutils.cfg"))) {
+ print $cfg "# Created by dh_auto", "\n";
+ print $cfg "[build]\nbuild-base=", $this->get_build_rel2sourcedir(), "\n";
+ close $cfg;
+ return 1;
+ }
+ return 0;
+}
+
+sub pre_building_step {
+ my $this=shift;
+ my $step=shift;
+
+ return unless grep /$step/, qw(build install clean);
+
+ if ($this->get_buildpath() ne $this->DEFAULT_BUILD_DIRECTORY()) {
+ # --build-base can only be passed to the build command. However,
+ # it is always read from the config file (really weird design).
+ # Therefore create such a cfg config file.
+ # See http://bugs.python.org/issue818201
+ # http://bugs.python.org/issue1011113
+ not $this->not_our_cfg() or
+ error("cannot set custom build directory: .pydistutils.cfg is in use");
+ $this->mkdir_builddir();
+ $this->create_cfg() or
+ error("cannot set custom build directory: unwritable .pydistutils.cfg");
+ # Distutils reads $HOME/.pydistutils.cfg
+ $ENV{HOME} = Cwd::abs_path($this->get_buildpath());
+ }
+
+ $this->SUPER::pre_building_step($step);
+}
+
+sub dbg_build_needed {
+ my $this=shift;
+ my $act=shift;
+
+ # Return a list of python-dbg package which are listed
+ # in the build-dependencies. This is kinda ugly, but building
+ # dbg extensions without checking if they're supposed to be
+ # built may result in various FTBFS if the package is not
+ # built in a clean chroot.
+
+ my @dbg;
+ open (CONTROL, 'debian/control') ||
+ error("cannot read debian/control: $!\n");
+ foreach my $builddeps (join('', <CONTROL>) =~
+ /^Build-Depends[^:]*:.*\n(?:^[^\w\n].*\n)*/gmi) {
+ while ($builddeps =~ /(python[^, ]*-dbg)/g) {
+ push @dbg, $1;
+ }
+ }
+
+ close CONTROL;
+ return @dbg;
+
+}
+
+sub setup_py {
+ my $this=shift;
+ my $act=shift;
+
+ # We need to to run setup.py with the default python last
+ # as distutils/setuptools modifies the shebang lines of scripts.
+ # This ensures that #!/usr/bin/python is installed last and
+ # not pythonX.Y
+ # Take into account that the default Python must not be in
+ # the requested Python versions.
+ # Then, run setup.py with each available python, to build
+ # extensions for each.
+
+ my $python_default = `pyversions -d`;
+ if ($? == -1) {
+ error("failed to run pyversions")
+ }
+ my $ecode = $? >> 8;
+ if ($ecode != 0) {
+ error("pyversions -d failed [$ecode]")
+ }
+ $python_default =~ s/^\s+//;
+ $python_default =~ s/\s+$//;
+ my @python_requested = split ' ', `pyversions -r`;
+ if ($? == -1) {
+ error("failed to run pyversions")
+ }
+ $ecode = $? >> 8;
+ if ($ecode != 0) {
+ error("pyversions -r failed [$ecode]")
+ }
+ if (grep /^\Q$python_default\E/, @python_requested) {
+ @python_requested = (
+ grep(!/^\Q$python_default\E/, @python_requested),
+ "python",
+ );
+ }
+
+ my @python_dbg;
+ my @dbg_build_needed = $this->dbg_build_needed();
+ foreach my $python (map { $_."-dbg" } @python_requested) {
+ if (grep /^(python-all-dbg|\Q$python\E)/, @dbg_build_needed) {
+ push @python_dbg, $python;
+ }
+ elsif (($python eq "python-dbg")
+ and (grep /^\Q$python_default\E/, @dbg_build_needed)) {
+ push @python_dbg, $python_default."-dbg";
+ }
+ }
+
+ foreach my $python (@python_dbg, @python_requested) {
+ if (-x "/usr/bin/".$python) {
+ # To allow backports of debhelper we don't pass
+ # --install-layout=deb to 'setup.py install` for
+ # those Python versions where the option is
+ # ignored by distutils/setuptools.
+ if ( $act eq "install" and not
+ ( ($python =~ /^python(?:-dbg)?$/
+ and $python_default =~ /^python2\.[2345]$/)
+ or $python =~ /^python2\.[2345](?:-dbg)?$/ )) {
+ $this->doit_in_sourcedir($python, "setup.py",
+ $act, @_, "--install-layout=deb");
+ }
+ else {
+ $this->doit_in_sourcedir($python, "setup.py",
+ $act, @_);
+ }
+ }
+ }
+}
+
+sub build {
+ my $this=shift;
+ $this->setup_py("build",
+ "--force",
+ @_);
+}
+
+sub install {
+ my $this=shift;
+ my $destdir=shift;
+ $this->setup_py("install",
+ "--force",
+ "--root=$destdir",
+ "--no-compile",
+ "-O0",
+ @_);
+}
+
+sub clean {
+ my $this=shift;
+ $this->setup_py("clean", "-a", @_);
+
+ # Config file will remain if it was created by us
+ if (!$this->not_our_cfg()) {
+ unlink($this->get_buildpath(".pydistutils.cfg"));
+ $this->rmdir_builddir(1); # only if empty
+ }
+ # The setup.py might import files, leading to python creating pyc
+ # files.
+ $this->doit_in_sourcedir('find', '.', '-name', '*.pyc', '-exec', 'rm', '{}', '+');
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/qmake.pm b/Debian/Debhelper/Buildsystem/qmake.pm
new file mode 100644
index 00000000..91e817f8
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/qmake.pm
@@ -0,0 +1,83 @@
+# A debhelper build system class for Qt projects
+# (based on the makefile class).
+#
+# Copyright: © 2010 Kelvin Modderman
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::qmake;
+
+use strict;
+use warnings;
+use Debian::Debhelper::Dh_Lib qw(error);
+use base 'Debian::Debhelper::Buildsystem::makefile';
+
+our $qmake="qmake";
+
+sub DESCRIPTION {
+ "qmake (*.pro)";
+}
+
+sub check_auto_buildable {
+ my $this=shift;
+ my @projects=glob($this->get_sourcepath('*.pro'));
+ my $ret=0;
+
+ if (@projects > 0) {
+ $ret=1;
+ # Existence of a Makefile generated by qmake indicates qmake
+ # class has already been used by a prior build step, so should
+ # be used instead of the parent makefile class.
+ my $mf=$this->get_buildpath("Makefile");
+ if (-e $mf) {
+ $ret = $this->SUPER::check_auto_buildable(@_);
+ open(my $fh, '<', $mf)
+ or error("unable to open Makefile: $mf");
+ while(<$fh>) {
+ if (m/^# Generated by qmake/i) {
+ $ret++;
+ last;
+ }
+ }
+ close($fh);
+ }
+ }
+
+ return $ret;
+}
+
+sub configure {
+ my $this=shift;
+ my @options;
+ my @flags;
+
+ push @options, '-makefile';
+ push @options, '-nocache';
+
+ if ($ENV{CFLAGS}) {
+ push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS} $ENV{CPPFLAGS}";
+ push @flags, "QMAKE_CFLAGS_DEBUG=$ENV{CFLAGS} $ENV{CPPFLAGS}";
+ }
+ if ($ENV{CXXFLAGS}) {
+ push @flags, "QMAKE_CXXFLAGS_RELEASE=$ENV{CXXFLAGS} $ENV{CPPFLAGS}";
+ push @flags, "QMAKE_CXXFLAGS_DEBUG=$ENV{CXXFLAGS} $ENV{CPPFLAGS}";
+ }
+ if ($ENV{LDFLAGS}) {
+ push @flags, "QMAKE_LFLAGS_RELEASE=$ENV{LDFLAGS}";
+ push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}";
+ }
+ push @flags, "QMAKE_STRIP=:";
+ push @flags, "PREFIX=/usr";
+
+ $this->doit_in_builddir($qmake, @options, @flags, @_);
+}
+
+sub install {
+ my $this=shift;
+ my $destdir=shift;
+
+ # qmake generated Makefiles use INSTALL_ROOT in install target
+ # where one would expect DESTDIR to be used.
+ $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_);
+}
+
+1
diff --git a/Debian/Debhelper/Buildsystem/qmake_qt4.pm b/Debian/Debhelper/Buildsystem/qmake_qt4.pm
new file mode 100644
index 00000000..d5bac585
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/qmake_qt4.pm
@@ -0,0 +1,18 @@
+package Debian::Debhelper::Buildsystem::qmake_qt4;
+
+use strict;
+use warnings;
+use Debian::Debhelper::Dh_Lib qw(error);
+use base 'Debian::Debhelper::Buildsystem::qmake';
+
+sub DESCRIPTION {
+ "qmake for QT 4 (*.pro)";
+}
+
+sub configure {
+ my $this=shift;
+ $Debian::Debhelper::Buildsystem::qmake::qmake="qmake-qt4";
+ $this->SUPER::configure(@_);
+}
+
+1