Added output of the patch area magnitude and the integral over the patch area magnitude.
[OpenFOAM-1.5.x.git] / wmake / wmake
blobffcd65e089d342be5c06f4df3c69b6eab12af4ba
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 # wmake
29 # Description
30 # General, easy to use make system for multi-platform development.
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 A general, easy-to-use make system for multi-platform development
43 The 'target' is a Makefile target:
44 e.g., Make/linux64GccDPOpt/fvMesh.o
46 or a special target:
47 all all subdirectories
48 exe build statically linked executable
49 lib build statically linked archive lib (.a)
50 libso build dynamically linked lib (.so)
51 libo build statically linked lib (.o)
52 jar build Java jar
54 USAGE
55 exit 1
58 # provide immediate help
59 if [ "$1" = "-h" -o "$1" = "-help" ]
60 then
61 usage
66 # check environment variables
68 for check in WM_OPTIONS WM_LINK_LANGUAGE WM_DIR
70 eval test "\$$check" || {
71 echo "$Script error: environment variable \$$check not set" 1>&2
72 exit 1
74 done
76 # when compiling anything but a standalone exe,
77 # WM_PROJECT and WM_PROJECT_DIR must be set
78 [ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || {
79 echo "$Script error:" 1>&2
80 echo " environment variable \$WM_PROJECT or \$WM_PROJECT_DIR not set" 1>&2
81 echo " while building project library" 1>&2
82 exit 1
86 #------------------------------------------------------------------------------
87 # Select the version of make to be used
88 #------------------------------------------------------------------------------
90 make="make"
92 # set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
93 if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
94 then
95 WM_NCOMPPROCS=$(wmakeScheduler -count)
96 [ $? -eq 0 ] || unset WM_NCOMPPROCS
99 if [ "$WM_NCOMPPROCS" ]
100 then
101 if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
102 then
103 lockDir=$HOME/.wmakeScheduler
105 if [ -d $lockDir ]
106 then
107 rm -f $lockDir/*
108 else
109 mkdir -p $lockDir
112 make="make --no-print-directory -j "$WM_NCOMPPROCS
117 #------------------------------------------------------------------------------
118 # check arguments and change to the directory in which to run wmake
119 #------------------------------------------------------------------------------
121 unset dir makeOption
122 MakeDir=Make
124 if [ $# -ge 1 ]
125 then
126 if [ -d "$1" ]
127 then
128 dir=$1
129 else
130 makeOption=$1
133 if [ $# -ge 2 ]
134 then
135 dir=$2
138 # alternative name for the Make sub-directory
139 if [ $# -ge 3 ]
140 then
141 MakeDir=$3
144 if [ "$dir" ]
145 then
146 cd $dir 2>/dev/null || {
147 echo "$Script error: could not change to directory '$dir'" 1>&2
148 exit 1
154 #------------------------------------------------------------------------------
155 # Recurse the application directories tree
156 #------------------------------------------------------------------------------
158 if [ "$makeOption" = all ]
159 then
160 if [ -e Allwmake ]
161 then
162 ./Allwmake
163 exit $?
164 elif [ ! -d $MakeDir ]
165 then
166 #FOAM_APPS=`find . -maxdepth 1 \( -type d -a ! -name "." -a ! -name "Optional" -a ! -name "Make" \) -printf "%f "`
167 FOAM_APPS=`for d in *; do if [ -d "$d" -a "$d" != "Optional" -a "$d" != "Make" ]; then echo "$d"; fi; done | xargs`
168 $make -k -f $WM_DIR/MakefileApps FOAM_APPS="$FOAM_APPS"
169 exit $?
172 # This is the end of the recursion down the application directories tree
173 # so remove the "all" option so that the call to make builds the application
174 makeOption=
178 #------------------------------------------------------------------------------
179 # Check the existance of the Make directory and files file
180 # If both exist make the wmake derived files
181 #------------------------------------------------------------------------------
183 [ -d $MakeDir ] || {
184 echo "$Script error: '$MakeDir' directory does not exist" 1>&2
185 exit 1
188 [ -r $MakeDir/files ] || {
189 echo "$Script error: file '$MakeDir/files' does not exist" 1>&2
190 exit 1
193 # Spawn a sub-shell and unset MAKEFLAGS in that sub-shell to avoid
194 # files and options being built in parallel
196 cd $MakeDir
197 unset MAKEFLAGS
198 make -s -f $WM_DIR/MakefileOptions
199 make -s -f $WM_DIR/MakefileFiles allFiles
203 #------------------------------------------------------------------------------
204 # Check the $OBJECTS_DIR = $MakeDir/$WM_OPTIONS/objectFiles file
205 # was created successfully
206 #------------------------------------------------------------------------------
208 OBJECTS_DIR=$MakeDir/$WM_OPTIONS
210 [ -r $OBJECTS_DIR/objectFiles ] || {
211 echo "$Script error: file '$OBJECTS_DIR/objectFiles' could not be created" 1>&2
212 exit 1
216 #------------------------------------------------------------------------------
217 # Make the dependency files
218 #------------------------------------------------------------------------------
220 touch $OBJECTS_DIR/dontIncludeDeps
222 case "$makeOption" in
223 lib | libso | libo )
224 $make -s -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/dontIncludeDeps lnInclude/uptodate
226 esac
228 $make -s -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/dontIncludeDeps $OBJECTS_DIR/dependencies
230 retVal=$?
231 if [ $retVal -ne 0 ]
232 then
233 exit $retVal
237 #------------------------------------------------------------------------------
238 # make the object files and link
239 #------------------------------------------------------------------------------
241 cmd="$make -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/includeDeps $makeOption"
242 #echo "cmd=$cmd"
243 exec $cmd
245 #------------------------------------------------------------------------------