forked from MPLLang/mpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean
executable file
·60 lines (51 loc) · 1.06 KB
/
clean
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -e
MAKE=${MAKE:-make}
RM=${RM:-rm -rf}
die () {
echo >&2 "$1"
exit 1
}
usage () {
die "usage: $name [--exclude <path> ...]"
}
name=$(basename "$0")
dir=$(dirname "$0")
root=$(cd "$dir/.." && pwd)
bin="$root/bin"
declare -a exclude
while [ "$#" -gt 0 ]; do
case "$1" in
"--exclude")
shift
if [ "$#" -gt 0 ]; then
exclude+=("$1");
shift
fi
;;
*)
usage
;;
esac
done
doit () {
# rm -rf '.#'* .*~ *~ *.a *.o .cm core mlmon.out svn-commit.*
"$bin/find-ignore" -exec ${RM} '{}' +
for f in *; do
if [ -d "$f" ]; then
for ((i=0; i < ${#exclude[*]}; i++)); do
if [ "$f" == "${exclude[$i]}" ]; then
continue 2
fi
done
cd "$f"
if [ -r Makefile ]; then
${MAKE} clean || doit
else
doit
fi
cd ..
fi
done
}
doit