summaryrefslogtreecommitdiffstats
path: root/scripts/pruneemptydirs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pruneemptydirs')
-rwxr-xr-xscripts/pruneemptydirs46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/pruneemptydirs b/scripts/pruneemptydirs
new file mode 100755
index 00000000..6f177a0f
--- /dev/null
+++ b/scripts/pruneemptydirs
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Cleans up a local CVS/SVN tree, by removing directories containing
+# remanants of old stuff which has been removed from CVS/SVN
+# Those stale dirs often break compilation...
+
+# Works better with srcdir!=builddir (since it will not remove directories
+# containing the old executable...)
+
+# NOTE: by default the script doesn't remove anything, just prints what to do
+# Copy and paste, or use eval in scripts.
+# Use '-f' to force it to happen (use with care, no warranties, etc.!)
+
+# David Faure <faure@kde.org>, script under public domain
+
+force=0;
+if [ "$1" = "-f" ]; then force=1; fi
+
+# Look for toplevel dirs
+files=`find . -type d | grep -v CVS\$ | grep -v admin\$ | grep -v .libs\$ | fgrep -v .svn`
+toremove="rm -rf";
+for i in $files; do if test -d $i; then
+ # List their contents and filter out generated files
+ realfiles=`find $i -type f | egrep -v '.svn|CVS/|Makefile$|Makefile.in$|Makefile.rules.in$|Makefile.calls.in$|\.o$|\.lo$|\.rpo$|\.la$|\.moc|/\.#' `
+ if [ -z "$realfiles" ]; then
+ toremove="$toremove '$i'"
+ fi
+fi; done
+
+if [ "$toremove" != "rm -rf" ]; then
+ # Do the same in the builddir, if srcdir != builddir
+ if [ -n "$OBJ_REPLACEMENT" ]; then
+ bdir=`echo $PWD | sed -e "$OBJ_REPLACEMENT"`
+ if test -d $bdir; then
+ bdcmd="( cd $bdir ; $toremove )"
+ fi
+ fi
+ # Print it or do it
+ if [ $force -eq 1 ]; then
+ eval $toremove
+ eval $bdcmd
+ else
+ echo $toremove
+ echo $bdcmd
+ fi
+fi
+