Hello,

On ketvirtadienis 21 Liepa 2011 12:23:29 Gregory Hainaut wrote:
> Well in this corner-case situation the idea was to remove the buildir, not
> to call `make clean`. Actually the current code never call `make clean`
> because rmdir_builddir nukes the builddir that contains the makefile.
> Previous patch will not change this behavior. In my opinion for cmake
> rmdir_builddir is enough but I wanted to keep change as small as possible.
> 
> The current use case:
> 1/ run dh_auto_configure but interrupt before the end (error or manually
> interrupt). It will create a builddir but without makefile. The builddir
> will contains various files (binary and text).
> ...
> 2/ then do dh_auto_clean (rebuild of package for example). For the moment
> the builddir is left untouched actually dh_auto_build will do nothing
> because it call the default clean function (from memory, inside
> BuildSystem.pm). Note, if dh_auto_configure finished sucessfully, the
> buildir is properly remove during dh_auto_clean (this time clean comes from
> makefile.pm).

Well, ok. In either case, the second hunk of your patch is redundant. That 
"clean" code is already implicit due to inheritance from makefile buildsystem.

However, this bug is not about cmake actually. I think it applies to autoconf 
(or any other buildsystem inheriting from makefile) as well. So ideally it 
should be solved at makefile buildsystem level. Maybe something like an 
attached patch.

-- 
Modestas Vainius <mo...@debian.org>
From d04fc959415b7b8f27636b8bab1414de69339a10 Mon Sep 17 00:00:00 2001
From: Modestas Vainius <mo...@debian.org>
Date: Thu, 21 Jul 2011 14:48:57 +0300
Subject: [PATCH] makefile.pm: remove build directory even if Makefile does
 not exist yet.

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.
---
 Debian/Debhelper/Buildsystem/makefile.pm |   22 +++++++++++++++++-----
 t/buildsystems/buildsystem_tests         |    2 +-
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm
index d4b68e4..f38387b 100644
--- a/Debian/Debhelper/Buildsystem/makefile.pm
+++ b/Debian/Debhelper/Buildsystem/makefile.pm
@@ -69,11 +69,23 @@ sub check_auto_buildable {
 	my $this=shift;
 	my ($step) = @_;
 
-	# This is always called in the source directory, but generally
-	# Makefiles are created (or live) in the the build directory.
-	return (-e $this->get_buildpath("Makefile") ||
-	        -e $this->get_buildpath("makefile") ||
-	        -e $this->get_buildpath("GNUmakefile")) ? 1 : 0;
+	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 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 {
diff --git a/t/buildsystems/buildsystem_tests b/t/buildsystems/buildsystem_tests
index c6f23ca..3b45ac5 100755
--- a/t/buildsystems/buildsystem_tests
+++ b/t/buildsystems/buildsystem_tests
@@ -256,7 +256,7 @@ touch "$tmpdir/configure", 0755;
 test_check_auto_buildable($bs{autoconf}, "configure", { configure => 1 });
 
 touch "$tmpdir/CMakeLists.txt";
-test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", { configure => 1 });
+test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", { configure => 1, clean => 1 });
 
 touch "$tmpdir/Makefile.PL";
 test_check_auto_buildable($bs{perl_makemaker}, "Makefile.PL", { configure => 1 });
-- 
1.7.5.4

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to