Description: dpkg-buildpackage is very picky with changes in the source tree during clean
Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

--- a/Makefile
+++ b/Makefile
@@ -113,7 +113,7 @@
 # The front end binary
 export CYMAKE       = $(BINDIR)/$(CURRYSYSTEM)-frontend
 # The cleancurry binary
-export CLEANCURRY   = $(BINDIR)/cleancurry
+export CLEANCURRY   = debian/bin/cleancurry
 
 # Logfile for make:
 MAKELOG=make.log
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -3,7 +3,7 @@
 ##############################################################################
 
 # the scripts to be installed
-BINS = $(BINDIR)/pakcs $(BINDIR)/cleancurry $(BINDIR)/pakcs-fcypp
+BINS = $(BINDIR)/pakcs ../debian/bin/cleancurry $(BINDIR)/pakcs-fcypp
 
 
 .PHONY: all
@@ -20,6 +20,14 @@
 	 sed "s|^COMPILERVERSION=.*$$|COMPILERVERSION=$(CURRYSYSTEM)-$(VERSION)|" > $@
 	chmod 755 $@
 
+# the cleancurry script must be run from inside debian/ subfolder
+# to keep the original source tree clean while running upstream's
+# make clean
+../debian/bin/%: %.sh
+	mkdir -p $(@D)
+	sed "s|^PAKCSHOME=.*$$|PAKCSHOME=$(ROOT)|" < $< > $@
+	chmod 755 $@
+
 .PHONY: clean
 clean:
 	rm -f $(BINS)
--- a/testsuite/test.sh
+++ b/testsuite/test.sh
@@ -52,7 +52,7 @@
 export PATH
 
 # clean up before
-$CURRYBIN/cleancurry -r
+../debian/bin/cleancurry -r
 
 LOGFILE=xxx$$
 
