summaryrefslogtreecommitdiffstats
path: root/scripts/pruneemptydirs
blob: 90e443b5ac0b7b641baa6cbff46f0d972d22b5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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=`tqfind . -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=`tqfind $i -type f | egrep -v  '.svn|CVS/|Makefile$|Makefile.in$|Makefile.rules.in$|Makefile.calls.in$|\.o$|\.lo$|\.rpo$|\.la$|\.tqmoc|/\.#' `
  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