chiark / gitweb /
Provide new tg2quilt target tg-cleanexport to recreate debian/patches.
[topgit.git] / debian / tg2quilt.mk
index 031d7b1ae92e70f2bb06f1ba76e582aa380afbda..5a041b9f79a8fd63d340ec7a8ecf6a2d606b01dc 100644 (file)
@@ -5,8 +5,9 @@
 # a quilt series.
 #
 # It is intended to be included from debian/rules files of TopGit-using
-# packages, like so:
+# packages after including the quilt rules, like so:
 #
+#   include /usr/share/quilt/quilt.make
 #   -include /usr/share/topgit/tg2quilt.mk
 #
 # The snippet exports the following targets. These targets only perform the
@@ -33,6 +34,9 @@
 #                  removed. This means that edits to the series file are
 #                  likely to vanish.
 #
+#  tg-cleanexport: recreates the debian/patches directory from scratch, using
+#                  tg-rmdir and tg-export.
+#
 #   tg-forceclean: cleans the source tree, just like the debian/rules clean
 #                  target, and forcefully removes the debian/patches
 #                  directory in doing so. Yes, *force*-fully. WHAM!
 ifeq ($(shell tg summary -t),)
   # This is not a TopGit branch, so just blubber a bit.
 
-  tg-export tg-clean tg-forceclean tg-rmdir:
+  tg-export tg-clean tg-forceclean tg-rmdir tg-cleanexport:
        @echo "E: The $@ target only works from a TopGit repository." >&2
 else
 
 # We are in a TopGit branch, so let the fun begin.
 
-PATCHES_DIR ?= debian/patches
+PATCHES_DIR ?= $(QUILT_PATCH_DIR)
 
 # Hook tg-export into quilt's make(1) snippet such that it gets executed
 # before quilt patches or unpatches.
-debian/stamp-patched: tg-export
+$(QUILT_STAMPFN): tg-export
 unpatch: __tg-temp-export
 __tg-temp-export:
        @echo "Exporting TopGit branches to series so that quilt can clean up..." >&2
-       $(MAKE) $(MAKEFLAGS) -f debian/rules tg-export
+       $(MAKE) --no-print-directory -f debian/rules tg-export
+.PHONY: __tg-temp-export
 
 # Set some tg-export-specific variables, e.g. default TG_BRANCHES to all
 # TopGit branches
@@ -119,13 +124,17 @@ endif
 
 # Make sure that we try to clean up the patches directory last
 tg-clean: clean
-       $(MAKE) $(MAKEFLAGS) -f debian/rules tg-rmdir
+       $(MAKE) --no-print-directory -f debian/rules tg-rmdir
 
 tg-forceclean: clean
-       test -d debian/patches && rm -r $(PATCHES_DIR) || :
+       test -d $(PATCHES_DIR) && rm -r $(PATCHES_DIR) || :
+
+tg-cleanexport: tg-rmdir
+       $(MAKE) --no-print-directory -f debian/rules tg-export
 
 endif
 
 .PHONY: tg-clean tg-export tg-forceclean tg-rmdir
 
 # vim:ft=make:ts=8:noet
+# -*- Makefile -*-, you silly Emacs! (shamelessly stolen from quilt)