ENH: indexedOctree: initialise point even if no match
[OpenFOAM-2.0.x.git] / wmake / wclean
blob088bfda52a4909ef5aa57d380667c23a5f345ded
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # wclean
28 # Description
29 # Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
30 # lnInclude directories generated for libraries.
32 #------------------------------------------------------------------------------
33 Script=${0##*/}
35 usage() {
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
37 cat<<USAGE
39 Usage: $Script [OPTION] [dir]
40 $Script [OPTION] target [dir [MakeDir]]
42 options:
43 -s | -silent ignored - for compatibility with wmake
44 -help print the usage
46 Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
47 lnInclude directories generated for libraries.
49 The targets correspond to a subset of the 'wmake' special targets:
50 all all subdirectories, uses any Allwclean or Allclean
51 files if they exist
52 exe | lib | libo | libso
53 clean Make, any *.dep files and lnInclude directories
55 USAGE
56 exit 1
60 # parse options
61 while [ "$#" -gt 0 ]
63 case "$1" in
64 -h | -help)
65 usage
67 -s | -silent) # ignored - for compatibility with wmake
68 shift
70 -*)
71 usage "unknown option: '$*'"
74 break
76 esac
77 done
80 #------------------------------------------------------------------------------
81 # check arguments and change to the directory in which to run wclean
82 #------------------------------------------------------------------------------
84 unset dir makeType
85 MakeDir=Make
87 if [ $# -ge 1 ]
88 then
90 if [ -d "$1" ]
91 then
92 dir=$1
93 else
94 makeType=$1
97 # specified directory name:
98 [ $# -ge 2 ] && dir=$2
100 # specified alternative name for the Make sub-directory:
101 [ $# -ge 3 ] && MakeDir=$3
103 if [ "$dir" ]
104 then
105 cd $dir 2>/dev/null || {
106 echo "$Script error: could not change to directory '$dir'" 1>&2
107 exit 1
111 # provide some feedback
112 echo "$Script ${dir:-./}"
115 #------------------------------------------------------------------------------
116 # Recurse the directories tree
117 #------------------------------------------------------------------------------
119 if [ "$makeType" = all ]
120 then
121 if [ -e Allwclean ] # consistent with Allwmake
122 then
123 ./Allwclean
124 exit $?
125 elif [ -e Allclean ] # often used for tutorial cases
126 then
127 ./Allclean
128 exit $?
129 elif [ ! -d $MakeDir ]
130 then
131 for dir in `find . \( -type d -a -name Make \)`
133 $0 ${dir%/Make} # parent directory - trim /Make from the end
134 done
135 exit 0
139 # makeType is not needed beyond this point
140 unset makeType
143 #------------------------------------------------------------------------------
144 # Require the existence of the 'Make' directory
145 #------------------------------------------------------------------------------
147 [ -d $MakeDir ] || {
148 echo "$Script error: '$MakeDir' directory does not exist" 1>&2
149 exit 1
153 # -----------------------------------------------------------------------------
155 rm -rf $MakeDir/$WM_OPTIONS $MakeDir/classes 2>/dev/null
157 find . -name "*.dep" -exec rm {} \;
159 # always safe to remove lnInclude
160 rm -rf lnInclude 2>/dev/null
162 rm -rf ii_files Templates.DB 2>/dev/null
163 rm -f so_locations 2>/dev/null
165 #------------------------------------------------------------------------------