2010-05-12 13:27:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# ========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / F ield | foam-extend: Open Source CFD
|
2016-06-20 15:00:40 +00:00
|
|
|
# \\ / O peration | Version: 4.0
|
2015-05-17 13:32:07 +00:00
|
|
|
# \\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
# \\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# License
|
2013-12-11 16:09:41 +00:00
|
|
|
# This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
# under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
# Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
# option) any later version.
|
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
# along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# Script
|
|
|
|
# wmake
|
|
|
|
#
|
|
|
|
# Description
|
|
|
|
# General, easy to use make system for multi-platform development.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
Script=${0##*/}
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
|
|
cat<<USAGE
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
|
|
|
|
Usage: $Script [OPTION] [dir]
|
|
|
|
$Script [OPTION] target [dir [MakeDir]]
|
|
|
|
|
|
|
|
options:
|
|
|
|
-s | -silent Run make in 'silent' mode (do not echo commands)
|
|
|
|
-a | -all Run wmake in all subdirectories
|
|
|
|
-h | -help Print the usage
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
A general, easy-to-use make system for multi-platform development
|
|
|
|
|
|
|
|
The 'target' is a Makefile target:
|
|
|
|
e.g., Make/linux64GccDPOpt/fvMesh.o
|
|
|
|
|
|
|
|
or a special target:
|
|
|
|
all all subdirectories
|
|
|
|
exe build statically linked executable
|
|
|
|
lib build statically linked archive lib (.a)
|
|
|
|
libso build dynamically linked lib (.so)
|
|
|
|
libo build statically linked lib (.o)
|
|
|
|
jar build Java jar
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
# Default make is the "make" in the path
|
|
|
|
make="make"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Parse arguments and options
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Default to compiling the local target only
|
|
|
|
all=
|
|
|
|
|
|
|
|
while [ "$#" -gt 0 ]
|
2010-05-12 13:27:55 +00:00
|
|
|
do
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
case "$1" in
|
|
|
|
-h | -help)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
-s | -silent)
|
|
|
|
make="$make -s"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-a | -all | all)
|
|
|
|
all="all"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
usage "unknown option: '$*'"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Check environment variables
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
for envar in WM_OPTIONS WM_LINK_LANGUAGE WM_DIR
|
|
|
|
do
|
|
|
|
eval test "\$$envar" || {
|
|
|
|
echo "$Script error: environment variable \$$envar not set" 1>&2
|
2010-05-12 13:27:55 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
done
|
|
|
|
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
|
|
|
|
# When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR
|
|
|
|
# must be set
|
2010-05-12 13:27:55 +00:00
|
|
|
[ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || {
|
|
|
|
echo "$Script error:" 1>&2
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
echo " environment variable \$WM_PROJECT or " \
|
|
|
|
"\$WM_PROJECT_DIR not set" 1>&2
|
|
|
|
echo " while building project library" 1>&2
|
2010-05-12 13:27:55 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Select the version of make to be used
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
make="make"
|
|
|
|
|
|
|
|
# set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
|
|
|
|
if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
|
|
|
|
then
|
|
|
|
WM_NCOMPPROCS=$(wmakeScheduler -count)
|
|
|
|
[ $? -eq 0 ] || unset WM_NCOMPPROCS
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$WM_NCOMPPROCS" ]
|
|
|
|
then
|
|
|
|
if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
|
|
|
|
then
|
|
|
|
lockDir=$HOME/.wmakeScheduler
|
|
|
|
|
|
|
|
if [ -d $lockDir ]
|
|
|
|
then
|
|
|
|
rm -f $lockDir/*
|
|
|
|
else
|
|
|
|
mkdir -p $lockDir
|
|
|
|
fi
|
|
|
|
|
|
|
|
make="make --no-print-directory -j "$WM_NCOMPPROCS
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# check arguments and change to the directory in which to run wmake
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
unset dir makeOption
|
|
|
|
MakeDir=Make
|
|
|
|
|
|
|
|
if [ $# -ge 1 ]
|
|
|
|
then
|
|
|
|
if [ -d "$1" ]
|
|
|
|
then
|
|
|
|
dir=$1
|
|
|
|
else
|
|
|
|
makeOption=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ge 2 ]
|
|
|
|
then
|
|
|
|
dir=$2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# alternative name for the Make sub-directory
|
|
|
|
if [ $# -ge 3 ]
|
|
|
|
then
|
|
|
|
MakeDir=$3
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$dir" ]
|
|
|
|
then
|
|
|
|
cd $dir 2>/dev/null || {
|
|
|
|
echo "$Script error: could not change to directory '$dir'" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Recurse the application directories tree
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
Vanilla backport
- in FOAM library
updated containers
backported PackedBoolList, hashedWordList, nullObject, wordRe,
backported functions to
backported int32 support
backported tableReaders
backported Function1, TimeFunction1
backported dynamicCode (for codedBCs, ...) -- needs to be mapped out
advanced error macros (FatalIOErrorInFunction, ...) -- needs to be mapped out
backported IOobject::MUST_READ_IF_MODIFIED and added IOobject::READ_IF_PRESENT_IF_MODIFIED (only in FO)
- in postProcessing
backported IO FOs (partialWrite, removeRegisteredObject, writeDictionary, writeRegisteredObject)
backported field FOs (fieldCoordinateSystemTransform, fieldValues, nearWallFields, processorField, readFields, regionSizeDistribution, streamLine, wallBoundedStreamLine)
backported fvTools FOs (calcFvcDiv, calcFvcGrad, calcMag)
backported jobControl FOs (abortCalculation)
backported utilities FOs (ourantNo, Lambda2, Peclet, Q, codedFunctionObject, pressureTools, residuals, scalarTransport, setTimeStep, timeActivatedFileUpdate, turbulenceFields, vorticity, wallShearStress)
2017-04-09 13:11:54 +00:00
|
|
|
if [ "$all" = all ]
|
2010-05-12 13:27:55 +00:00
|
|
|
then
|
|
|
|
if [ -e Allwmake ]
|
|
|
|
then
|
|
|
|
./Allwmake
|
|
|
|
exit $?
|
|
|
|
elif [ ! -d $MakeDir ]
|
|
|
|
then
|
2010-08-24 15:19:39 +00:00
|
|
|
# FOAM_APPS=$(find . -maxdepth 1 \( -type d -a ! -name "." -a ! -name Optional -a ! -name Make \) -printf "%f ")
|
|
|
|
# avoid 'find' with '-printf' ... not entirely portable
|
|
|
|
FOAM_APPS=$(for d in *; do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] && echo "$d"; done | xargs)
|
|
|
|
$make -k -f $WM_DIR/MakefileApps FOAM_APPS="$FOAM_APPS"
|
2010-05-12 13:27:55 +00:00
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Check the existance of the Make directory and files file
|
2010-08-24 15:19:39 +00:00
|
|
|
# If both exist, make the wmake derived files
|
2010-05-12 13:27:55 +00:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
[ -d $MakeDir ] || {
|
|
|
|
echo "$Script error: '$MakeDir' directory does not exist" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -r $MakeDir/files ] || {
|
|
|
|
echo "$Script error: file '$MakeDir/files' does not exist" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Spawn a sub-shell and unset MAKEFLAGS in that sub-shell to avoid
|
|
|
|
# files and options being built in parallel
|
|
|
|
(
|
|
|
|
cd $MakeDir
|
|
|
|
unset MAKEFLAGS
|
|
|
|
make -s -f $WM_DIR/MakefileOptions
|
|
|
|
make -s -f $WM_DIR/MakefileFiles allFiles
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Check the $OBJECTS_DIR = $MakeDir/$WM_OPTIONS/objectFiles file
|
|
|
|
# was created successfully
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OBJECTS_DIR=$MakeDir/$WM_OPTIONS
|
|
|
|
|
|
|
|
[ -r $OBJECTS_DIR/objectFiles ] || {
|
|
|
|
echo "$Script error: file '$OBJECTS_DIR/objectFiles' could not be created" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Make the dependency files
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
touch $OBJECTS_DIR/dontIncludeDeps
|
|
|
|
|
|
|
|
case "$makeOption" in
|
|
|
|
lib | libso | libo )
|
|
|
|
$make -s -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/dontIncludeDeps lnInclude/uptodate
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$make -s -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/dontIncludeDeps $OBJECTS_DIR/dependencies
|
|
|
|
|
|
|
|
retVal=$?
|
|
|
|
if [ $retVal -ne 0 ]
|
|
|
|
then
|
|
|
|
exit $retVal
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# make the object files and link
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
cmd="$make -f $WM_DIR/Makefile MAKE_DIR=$MakeDir INCLUDE_DEPS=$OBJECTS_DIR/includeDeps $makeOption"
|
2010-08-24 15:19:39 +00:00
|
|
|
# echo "cmd=$cmd"
|
2010-05-12 13:27:55 +00:00
|
|
|
exec $cmd
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|