2 #------------------------------------------------------------------------------
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
6 # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
8 #-------------------------------------------------------------------------------
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
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
30 # General, easy to use make system for multi-platform development.
32 #------------------------------------------------------------------------------
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
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
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)
58 # provide immediate help
59 if [ "$1" = "-h" -o "$1" = "-help" ]
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
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
86 #------------------------------------------------------------------------------
87 # Select the version of make to be used
88 #------------------------------------------------------------------------------
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" ]
95 WM_NCOMPPROCS
=$
(wmakeScheduler
-count)
96 [ $?
-eq 0 ] ||
unset WM_NCOMPPROCS
99 if [ "$WM_NCOMPPROCS" ]
101 if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
103 lockDir
=$HOME/.wmakeScheduler
112 make="make --no-print-directory -j "$WM_NCOMPPROCS
117 #------------------------------------------------------------------------------
118 # check arguments and change to the directory in which to run wmake
119 #------------------------------------------------------------------------------
138 # alternative name for the Make sub-directory
146 cd $dir 2>/dev
/null ||
{
147 echo "$Script error: could not change to directory '$dir'" 1>&2
154 #------------------------------------------------------------------------------
155 # Recurse the application directories tree
156 #------------------------------------------------------------------------------
158 if [ "$makeOption" = all
]
164 elif [ ! -d $MakeDir ]
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"
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
178 #------------------------------------------------------------------------------
179 # Check the existance of the Make directory and files file
180 # If both exist make the wmake derived files
181 #------------------------------------------------------------------------------
184 echo "$Script error: '$MakeDir' directory does not exist" 1>&2
188 [ -r $MakeDir/files
] ||
{
189 echo "$Script error: file '$MakeDir/files' does not exist" 1>&2
193 # Spawn a sub-shell and unset MAKEFLAGS in that sub-shell to avoid
194 # files and options being built in parallel
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
216 #------------------------------------------------------------------------------
217 # Make the dependency files
218 #------------------------------------------------------------------------------
220 touch $OBJECTS_DIR/dontIncludeDeps
222 case "$makeOption" in
224 $make -s -f $WM_DIR/Makefile MAKE_DIR
=$MakeDir INCLUDE_DEPS
=$OBJECTS_DIR/dontIncludeDeps lnInclude
/uptodate
228 $make -s -f $WM_DIR/Makefile MAKE_DIR
=$MakeDir INCLUDE_DEPS
=$OBJECTS_DIR/dontIncludeDeps
$OBJECTS_DIR/dependencies
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"
245 #------------------------------------------------------------------------------