intersection with triangle plane for miss
[OpenFOAM-1.5.x.git] / wmake / wmakeLnInclude
blob066b6346fd0ae6d56a05e2ed559ed8e2ed524453
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2008 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
50 * Use '-f' to force an update when the lnInclude directory already exists.
52 USAGE
53 exit 1
56 #------------------------------------------------------------------------------
58 # simple option parsing
59 unset forceUpdate
60 unset findOpt
62 # simple parse options
63 while [ "$#" -gt 0 ]
65 case "$1" in
66 -h | -help) # provide immediate help
67 usage
69 -f)
70 shift
71 forceUpdate=1
73 -*)
74 usage "unknown option/argument: '$*'"
77 break
79 esac
80 done
82 baseDir=$1
83 # convert incorrect path/dir/lnInclude to something sensible
84 while [ "${baseDir##*/}" = lnInclude ]
86 baseDir="${baseDir%/*}"
87 if [ "$baseDir" = lnInclude ]
88 then
89 baseDir="."
91 done
92 incDir=$baseDir/lnInclude
95 if [ $# -eq 1 ]
96 then
97 lnOpt="-s"
98 elif [ $# -eq 2 ]
99 then
100 lnOpt="$2"
101 else
102 usage "ERROR: incorrect number of arguments"
106 if [ ! -d $baseDir ]
107 then
108 echo "$Script error: base directory $baseDir does not exist" 1>&2
109 exit 2
112 if [ -d $incDir ]
113 then
114 if [ ! "$forceUpdate" ]
115 then
116 # echo "$Script error: include directory $incDir already exists" 1>&2
117 exit 0
119 else
120 mkdir $incDir
123 if [ ! -d $incDir ]
124 then
125 echo "$Script error: failed to create include directory $incDir" 1>&2
126 exit 0
129 cd $incDir || exit 1
132 # Link include files
133 # ~~~~~~~~~~~~~~~~~~
134 echo "$Script: linking include files to $incDir"
137 # remove any broken links first (this helps when file locations have moved)
139 find -L . -type l -exec rm \{\} \;
142 # create links, avoid recreating links unless necessary
144 find .. $findOpt \
145 \( -name lnInclude -o -name Make -o -name config \) -prune \
146 -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \
147 -a ! -name ".#*" \
148 -print | \
149 while read src
151 link=$(readlink ${src##*/})
152 if [ "$link" != "$src" ]
153 then
154 rm $link 2>/dev/null
155 ln $lnOpt $src .
157 done
159 #------------------------------------------------------------------------------