BUG: searchableCylinder nearest not correct for endcaps
[OpenFOAM-1.6.x.git] / wmake / wmakeLnInclude
blob0580893b768bb5660b9766e9c6ebc31dae2129db
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2009 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 the
14 # Free Software Foundation; either version 2 of the License, or (at your
15 # 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, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # Script
27 # wmakeLnInclude
29 # Description
30 # Link all the source files in the <dir> directory into <dir>/lnInclude
32 # Usage: wmakeLnInclude [-f] <dir> [-lnOption]
34 # The desired source files:
35 # *.C *.H *.h *.cpp *.cxx *.hpp *.hxx
37 # Avoid
38 # *.c (C source)
39 # .#* (cvs recovered files)
40 #------------------------------------------------------------------------------
41 Script=${0##*/}
43 usage() {
44 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
45 cat<<USAGE
47 usage: $Script [-f] <dir> [-lnOption]
49 Link all the source files in the <dir> into <dir>/lnInclude
51 Note
52 The '-f' option forces an update when the lnInclude directory already exists
53 and also changes the default linking from 'ln -s' to 'ln -sf'.
55 USAGE
56 exit 1
59 #------------------------------------------------------------------------------
61 # simple option parsing
62 unset forceUpdate
63 unset findOpt
65 # default ln option
66 lnOpt="-s"
68 # simple parse options
69 while [ "$#" -gt 0 ]
71 case "$1" in
72 -h | -help) # provide immediate help
73 usage
75 -f)
76 shift
77 forceUpdate=1
78 lnOpt="-sf"
80 -*)
81 usage "unknown option: '$*'"
84 break
86 esac
87 done
89 if [ $# -eq 1 ]
90 then
91 baseDir=$1
92 elif [ $# -eq 2 ]
93 then
94 baseDir=$1
95 lnOpt="$2"
96 else
97 usage "ERROR: incorrect number of arguments"
101 # convert incorrect path/dir/lnInclude to something sensible
102 while [ "${baseDir##*/}" = lnInclude ]
104 baseDir="${baseDir%/*}"
105 if [ "$baseDir" = lnInclude ]
106 then
107 baseDir="."
109 done
110 incDir=$baseDir/lnInclude
113 if [ ! -d $baseDir ]
114 then
115 echo "$Script error: base directory $baseDir does not exist" 1>&2
116 exit 2
119 if [ -d $incDir ]
120 then
121 if [ ! "$forceUpdate" ]
122 then
123 # echo "$Script error: include directory $incDir already exists" 1>&2
124 exit 0
126 else
127 mkdir $incDir
130 if [ ! -d $incDir ]
131 then
132 echo "$Script error: failed to create include directory $incDir" 1>&2
133 exit 0
136 cd $incDir || exit 1
139 # Link include files
140 # ~~~~~~~~~~~~~~~~~~
141 echo "$Script: linking include files to $incDir"
144 # remove any broken links first (this helps when file locations have moved)
146 find -L . -type l -exec rm {} \;
149 # create links, avoid recreating links unless necessary
150 # things placed in the 'noLink' directory are skipped
152 find .. $findOpt \
153 \( -name lnInclude -o -name Make -o -name config -o -name noLink \) -prune \
154 -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \
155 -exec ln $lnOpt {} . \;
157 #------------------------------------------------------------------------------