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 $make -k -f $WM_DIR/MakefileApps \
167 FOAM_APPS
="`find . -maxdepth 1 \( -type d -a ! -name ".
" -a ! -name "Optional
" -a ! -name "Make
" \) -printf "%f
"`"
171 # This is the end of the recursion down the application directories tree
172 # so remove the "all" option so that the call to make builds the application
177 #------------------------------------------------------------------------------
178 # Check the existance of the Make directory and files file
179 # If both exist make the wmake derived files
180 #------------------------------------------------------------------------------
183 echo "$Script error: '$MakeDir' directory does not exist" 1>&2
187 [ -r $MakeDir/files
] ||
{
188 echo "$Script error: file '$MakeDir/files' does not exist" 1>&2
192 # Spawn a sub-shell and unset MAKEFLAGS in that sub-shell to avoid
193 # files and options being built in parallel
197 make -s -f $WM_DIR/MakefileOptions
198 make -s -f $WM_DIR/MakefileFiles allFiles
202 #------------------------------------------------------------------------------
203 # Check the $OBJECTS_DIR = $MakeDir/$WM_OPTIONS/objectFiles file
204 # was created successfully
205 #------------------------------------------------------------------------------
207 OBJECTS_DIR
=$MakeDir/$WM_OPTIONS
209 [ -r $OBJECTS_DIR/objectFiles
] ||
{
210 echo "$Script error: file '$OBJECTS_DIR/objectFiles' could not be created" 1>&2
215 #------------------------------------------------------------------------------
216 # Make the dependency files
217 #------------------------------------------------------------------------------
219 touch $OBJECTS_DIR/dontIncludeDeps
221 case "$makeOption" in
223 $make -s -f $WM_DIR/Makefile MAKE_DIR
=$MakeDir INCLUDE_DEPS
=$OBJECTS_DIR/dontIncludeDeps lnInclude
/uptodate
227 $make -s -f $WM_DIR/Makefile MAKE_DIR
=$MakeDir INCLUDE_DEPS
=$OBJECTS_DIR/dontIncludeDeps
$OBJECTS_DIR/dependencies
236 #------------------------------------------------------------------------------
237 # make the object files and link
238 #------------------------------------------------------------------------------
240 cmd
="$make -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/includeDeps $makeOption"
244 #------------------------------------------------------------------------------