Better bounding on topo change
[foam-extend-3.2.git] / wmake / wclean
blobc6041853206b179dcb81465c511ac08ff141d5cd
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 3.2
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # wclean
28 # Description
29 # Clean up the wmake control directory Make and remove the include
30 # directories generated for libraries.
32 #------------------------------------------------------------------------------
33 Script=${0##*/}
35 usage() {
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
37 cat<<USAGE
38 usage: $Script [dir]
39 $Script target [dir [MakeDir]]
41 Clean up the wmake control directory Make and remove the include
42 directories generated for libraries.
44 The targets correspond to a subset of the 'wmake' special targets:
45 all all subdirectories
46 exe cleans dir/Make
47 lib cleans dir/Make and dir/lnInclude
48 libso cleans dir/Make and dir/lnInclude
49 libo cleans dir/Make and dir/lnInclude
51 USAGE
52 exit 1
55 # provide immediate help
56 if [ "$1" = "-h" -o "$1" = "-help" ]
57 then
58 usage
62 #------------------------------------------------------------------------------
63 # check arguments and change to the directory in which to run wmake
64 #------------------------------------------------------------------------------
66 unset dir makeOption
67 MakeDir=Make
69 if [ $# -ge 1 ]
70 then
72 if [ -d "$1" ]
73 then
74 dir=$1
75 else
76 makeOption=$1
79 if [ $# -ge 2 ]
80 then
81 dir=$2
84 # alternative name for the Make sub-directory
85 if [ $# -ge 3 ]
86 then
87 MakeDir=$3
90 if [ "$dir" ]
91 then
92 cd $dir 2>/dev/null || {
93 echo "$Script error: could not change to directory '$dir'" 1>&2
94 exit 1
98 # provide some feedback
99 echo "$Script ${dir:-./}"
102 #------------------------------------------------------------------------------
103 # Recurse the directories tree
104 #------------------------------------------------------------------------------
106 if [ "$makeOption" = all ]
107 then
108 if [ -e Allclean ]
109 then
110 ./Allclean
111 exit $?
112 elif [ ! -d $MakeDir ]
113 then
114 for dir in `find . \( -type d -a -name Make \) -printf "%h "`
116 $0 $dir
117 done
118 exit 0
121 # This is the end of the recursion down the application directories tree
122 # so remove the "all" option so that the call to make builds the application
123 makeOption=
126 #------------------------------------------------------------------------------
127 # Check the existance of the Make directory
128 #------------------------------------------------------------------------------
130 if [ ! -d $MakeDir ]
131 then
132 echo "$Script error: '$MakeDir' directory does not exist" 1>&2
133 exit 1
136 # -----------------------------------------------------------------------------
138 rm -rf $MakeDir/$WM_OPTIONS $MakeDir/classes 2>/dev/null
140 find . -name "*.dep" -exec rm {} \;
142 case "$makeOption" in
143 lib | libso | libo )
144 rm -rf lnInclude 2>/dev/null
146 esac
148 rm -rf ii_files Templates.DB 2>/dev/null
149 rm -f so_locations
151 #------------------------------------------------------------------------------