File indexing completed on 2024-04-14 05:35:11

0001 #!/bin/sh
0002 # Cleans up a local CVS/SVN tree, by removing directories containing
0003 # remanants of old stuff which has been removed from CVS/SVN
0004 # Those stale dirs often break compilation...
0005 
0006 # Works better with srcdir!=builddir (since it will not remove directories
0007 # containing the old executable...)
0008 
0009 # NOTE: by default the script doesn't remove anything, just prints what to do
0010 # Copy and paste, or use eval in scripts.
0011 # Use '-f' to force it to happen (use with care, no warranties, etc.!)
0012 
0013 # David Faure <faure@kde.org>, script under public domain
0014 
0015 force=0;
0016 if [ "$1" = "-f" ]; then force=1; fi
0017 
0018 # Look for toplevel dirs
0019 dirs=`find . -type d | grep -v CVS\$ | grep -v admin\$ | grep -v .libs\$ | fgrep -v .svn`
0020 toremove="rm -rf";
0021 for i in $dirs; do if test -d $i; then
0022   # Short way out, to avoid a full recursive listing from a toplevel module
0023   if [ -f $i/configure.in.in -o -f $i/Makefile.am ]; then
0024      :
0025   else 
0026     # List their contents and filter out generated files
0027     realfiles=`find $i -type f | egrep -v  'CVS/|Makefile$|Makefile.in$|Makefile.rules.in$|Makefile.calls.in$|\.o$|\.lo$|\.rpo$|\.la$|\.moc|/\.#' `
0028     if [ -z "$realfiles" ]; then
0029       toremove="$toremove $i"
0030     fi
0031   fi
0032 fi; done
0033 
0034 if [ "$toremove" != "rm -rf" ]; then
0035   # Do the same in the builddir, if srcdir != builddir
0036   if [ -n "$OBJ_REPLACEMENT" ]; then
0037     bdir=`echo $PWD | sed -e "$OBJ_REPLACEMENT"`
0038     if test -d $bdir; then
0039       bdcmd="( cd $bdir ; $toremove )"
0040     fi
0041   fi
0042   # Print it or do it
0043   if [ $force -eq 1 ]; then
0044     eval $toremove
0045     eval $bdcmd
0046   else
0047     echo $toremove
0048     echo $bdcmd
0049   fi
0050 fi
0051