0.9.4.72:
[sbcl.git] / clean.sh
1 #!/bin/sh
2 set -e
3
4 # Remove everything in directories which are only used for output.
5 # In most cases, we can remove the directories, too.
6 #
7 # (We don't remove all the directories themselves for a stupid technical
8 # reason: "gmake clean" in the src/runtime directory gets unhappy if the
9 # output/ directory doesn't exist, because it tries to build Depends
10 # before it cleans itself, and src/c-runtime/sbcl.h is a symlink into
11 # the output/ directory, and it gets the gcc dependency processing gets
12 # all confused trying to figure out a header file which is a symlink
13 # into a directory which doesn't exist. We'd like to be able to run
14 # this script (including "gmake clean" in the src/runtime directory)
15 # several times in a row without failure.. so we leave the output/
16 # directory in place.)
17 rm -rf obj/* output/* src/runtime/genesis/
18
19 # Ensure that we know GNUMAKE.
20 . ./find-gnumake.sh
21 find_gnumake
22
23 # Ask some other directories to clean themselves up.
24 original_pwd=`pwd`
25 for d in tools-for-build; do
26     cd ./$d > /dev/null
27     # I hope the -s option is standard. At least GNU make and BSD make
28     # support it. It silences make, since otherwise the output from
29     # this script is just the operations done by these make's, which
30     # is misleading when this script does lotso other operations too.
31     # -- WHN
32     $GNUMAKE -I ../src/runtime -s clean
33     cd $original_pwd > /dev/null
34 done
35 ( cd ./doc ; sh ./clean.sh )
36
37 # Within all directories, remove things which don't look like source
38 # files. Some explanations:
39 #   (symlinks)
40 #     are never in the sources, so must've been created
41 #   sbcl
42 #     the runtime environment, created by compiling C code
43 #   sbcl.h 
44 #     information about Lisp code needed to build the runtime environment,
45 #     created by running GENESIS
46 #   Config, target
47 #     architecture-dependent or OS-dependent symlinks
48 #   core
49 #     probably a Unix core dump -- not part of the sources anyway
50 #   *.o, *.so, *.lib, *.nm, a.out
51 #     results of C-style linking, assembling, etc.
52 #   *.core, *.map
53 #     looks like SBCL SAVE-LISP-AND-DIE or GENESIS output, and
54 #     certainly not source
55 #   *~, #*#
56 #     common names for editor temporary files
57 #   TAGS, tags
58 #     files created by GNU etags and ctags
59 #   .#*, *.orig, .*.orig, *.rej
60 #     rubbish left behind by CVS updates
61 #   *.htm, *.html
62 #     The system doc sources are mostly texinfo, plus various odds 
63 #     and ends like docstrings embedded in .lisp sources; any HTML is
64 #     automatically-generated output.
65 #   depend
66 #     made by "make depend" (or "gmake depend" or some such thing)
67 #   *.lisp-obj, *.fasl, *.x86f, *.axpf, *.lbytef, *.lib
68 #     typical extensions for fasl files (not just from SBCL, but
69 #     from other Lisp systems which might be used as xc hosts)
70 #   *.tmp, *.lisp-temp
71 #     conventional names for temporary files autogenerated in
72 #     building or testing
73 #   test-passed
74 #     generated by automatic directory-test-thyself procedure
75 find . \( \
76         -type l -o \
77         -name '*~' -o \
78         -name '#*#' -o \
79         -name '.#*' -o \
80         -name '*.orig' -o \
81         -name '.*.orig' -o \
82         -name '*.rej' -o \
83         -name '?*.x86f' -o \
84         -name '?*.axpf' -o \
85         -name '?*.lbytef' -o \
86         -name '?*.fasl' -o \
87         -name 'core' -o \
88         -name '?*.core' -o \
89         -name '*.map' -o \
90         -name '*.nm' -o \
91         -name '*.host-obj' -o \
92         -name '*.lisp-obj' -o \
93         -name '*.target-obj' -o \
94         -name '*.lib' -o \
95         -name '*.tmp' -o \
96         -name '*.lisp-temp' -o \
97         -name '*.o' -o \
98         -name '*.so' -o \
99         -name 'a.out' -o \
100         -name 'sbcl' -o \
101         -name 'sbcl.h' -o \
102         -name 'depend' -o \
103         -name 'TAGS' -o \
104         -name 'tags' -o \
105         -name 'test-passed' -o \
106         -name 'local-target-features.lisp-expr' \) -print | xargs rm -f