-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.sh
107 lines (93 loc) · 2.27 KB
/
clean.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
# xv6tools: Installation script for xv6 building tools on macOS
# Takuo Watanabe
# (see http://pdos.csail.mit.edu/6.828/2014/tools.html)
usage="Usage: $0 [--clean][--distclean][--sources][--archives][--installation][--prefix]"
thisdir=$(cd $(dirname $0) && pwd)
. $thisdir/defs.sh
clean_sources=
distclean_sources=
remove_sources=
remove_archives=
remove_installation=
remove_prefix=
while [ $# -gt 0 ]; do
case "$1" in
--clean) shift; clean_sources=y; break;;
--distclean) shift; distclean_sources=y; break;;
--sources) shift; remove_sources=y; break;;
--archives) shift; remove_archives=y; break;;
--installation) shift; remove_installation=y; break;;
--prefix) shift; remove_prefix=y; break;;
-*|--*) echo "Unknown option" $1; echo $usage; exit 2;;
*) break;;
esac
done
RM="rm -f"
N=`echo 'foo\c'`
case "$N" in
*c) n=-n c= ;;
*) n= c='\c' ;;
esac
if [ -n "$remove_prefix" ]; then
really_remove_prefix=
echo $n "Note: Removing $PREFIX permanently. Are you sure? [yes/No] $c"
read ans
case "$ans" in
yes|Yes) really_remove_prefix=y;;
esac
if [ -n "$really_remove_prefix" ]; then
$RM -r $PREFIX
fi
exit
fi
ds="bin etc $TARGET include lib libexec share var"
if [ -n "$remove_installation" ]; then
dds="{`echo $ds | tr ' ' ','`}"
really_remove_installation=
echo $n "Note: Removing $PREFIX/$dds permanently. Are you sure? [yes/No] $c"
read ans
case "$ans" in
yes|Yes) really_remove_installation=y;;
esac
if [ -n "$really_remove_installation" ]; then
for d in $ds; do
$RM -r $PREFIX/$d
done
fi
exit
fi
if [ -n "$remove_sources" ]; then
cd $SRCDIR
$RM -r $DIR_BINUTILS
$RM -r $DIR_GCC
$RM -r $DIR_GDB
exit
fi
if [ -n "$remove_archives" ]; then
cd $ARCDIR
$RM $PKG_BINUTILS
$RM $PKG_GCC
$RM $PKG_GDB
exit
fi
if [ -n "$distclean_sources" ]; then
cd $SRCDIR/$DIR_BINUTILS
make distclean
cd $SRCDIR/$DIR_GCC/build
make distclean
cd $SRCDIR/$DIR_GCC
rm -rf build
cd $SRCDIR/$DIR_GDB
make distclean
exit
fi
if [ -n "$clean_sources" ]; then
cd $SRCDIR/$DIR_BINUTILS
make clean
cd $SRCDIR/$DIR_GCC/build
make clean
cd $SRCDIR/$DIR_GDB
make clean
exit
fi