#!/bin/sh
# Cleans up a local CVS tree, by removing directories containing
# remanants of old stuff which has been removed from CVS
# Those stale dirs often break compilation...

# Works better with srcdir!=builddir (since it will not remove directories
# containing the old executable...)

# NOTE: the script doesn't remove anything, just prints what to do
# Copy and paste, or use eval in scripts.

# David Faure <faure@kde.org>, licensed under the one-for-one license
# (all rights granted, if you like it send me a script of yours)

# Look for toplevel dirs
files=`find . -type d | grep -v CVS\$ | grep -v admin\$ | grep -v .libs\$`
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  'CVS/|Makefile$|Makefile.in$|\.o$|\.lo$|\.rpo$|\.la$|\.moc|/\.#' `
  if [ -z "$realfiles" ]; then
    echo "rm -rf $i;"
  fi
fi; done

