diff --git a/tools/clean-target.sh b/tools/clean-target.sh index 22d7c1b0ea9fdf9bd03a9476e88ef003c773010c..29b3d78ff9cfb81125b7ee11b5f368b5dd5fe662 100755 --- a/tools/clean-target.sh +++ b/tools/clean-target.sh @@ -1,18 +1,40 @@ #!/bin/sh -if [ "$1" = "" ] -then - echo "Usage: $0 target-directory" - exit 1 -fi +usage() { + echo "Usage: `basename $0` [-l] dir [dir1 dir2 ...]" + echo " -h This help" + echo " -l Clean out the C runtime as well" + echo "" + echo "Cleans out all Lisp fasls from the given directories" + echo "If -l is also given, the C runtime is cleared as well. This includes" + echo "all object files, the lisp binary itself, and any selected configuration" + echo "files. The motif server is also removed." + exit 1 +} -if [ ! -d "$1" ] -then - echo "$1 isn't a directory" - exit 2 +while getopts "h?l" arg +do + case $arg in + l) CLEAN_C=1 ;; + h | \?) usage; exit 1 ;; + esac +done + +shift `expr $OPTIND - 1` + +if [ $# -lt 1 ]; then + usage fi -TARGET="`echo $1 | sed 's:/*$::'`" +for d in "$@" +do + if [ ! -d "$d" ]; then + echo "$d isn't a directory" + exit 2 + fi + D="`echo $d | sed 's:/*$::'`" + TARGET="$TARGET $D" +done find $TARGET -name "*.bytef" -o -name "*.lbytef" -o -name "*.assem" -o \ -name "*.axpf" -o \ @@ -23,6 +45,15 @@ find $TARGET -name "*.bytef" -o -name "*.lbytef" -o -name "*.assem" -o \ -name "*.sparcf" -o \ -name "*.x86f" -o \ -name "*.core" | xargs rm 2> /dev/null -rm -f $TARGET/compile-*.log $TARGET/hemlock/spell-dictionary.bin 2> /dev/null + +set -x +for d in $TARGET +do + rm -f $d/compile-*.log $d/hemlock/spell-dictionary.bin 2> /dev/null + if [ -n "$CLEAN_C" ]; then + rm -f $d/lisp/* $d/motif/server/* + done +done + true