Skip to content
Snippets Groups Projects
Commit 7124f736 authored by Henry's avatar Henry
Browse files

wmake: "dwim" option behaviour is now the default if no argument is supplied

i.e. wmake searches up the directory tree to find the Make directory if it is not
in the current directory.
parent 9171a6f0
Branches
Tags
No related merge requests found
......@@ -50,7 +50,6 @@ The 'target' is a Makefile target:
e.g., Make/linux64GccDPOpt/fvMesh.o
or a special target:
dwim search up directories tree for Make sub-directory and build
all all subdirectories, uses any Allwmake files if they exist
exe build statically linked executable
lib build statically linked archive lib (.a)
......@@ -86,9 +85,11 @@ do
esac
done
#
# check environment variables
#
#------------------------------------------------------------------------------
# Check environment variables
#------------------------------------------------------------------------------
for check in WM_OPTIONS WM_LINK_LANGUAGE WM_DIR
do
eval test "\$$check" || {
......@@ -103,13 +104,13 @@ done
[ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || {
echo "$Script error:" 1>&2
echo " environment variable \$WM_PROJECT or \$WM_PROJECT_DIR not set" 1>&2
echo " while building project library" 1>&2
echo " while building project library" 1>&2
exit 1
}
#------------------------------------------------------------------------------
# Select the version of make to be used
# Select the version of make use
#------------------------------------------------------------------------------
# set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
......@@ -169,8 +170,30 @@ then
fi
#------------------------------------------------------------------------------
# Recurse the application directories tree
#------------------------------------------------------------------------------
if [ "$makeType" = all ]
then
if [ -e Allwmake ]
then
./Allwmake
exit $?
elif [ ! -d $MakeDir ]
then
# 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"
exit $?
fi
fi
#------------------------------------------------------------------------------
# Search up directories tree for the Make sub-directory and build there
# Also check the existance of the 'files' file
#------------------------------------------------------------------------------
unset dir
......@@ -189,18 +212,22 @@ find_target()
{
expandpath $1
if [ "$exPath" = "$WM_PROJECT_DIR" -o "$exPath" = "$HOME" -o "$exPath" = "/" ]; then
if [ "$exPath" = "$WM_PROJECT_DIR" -o "$exPath" = "$HOME" -o "$exPath" = "/" ]
then
echo "$Script error: could not find Make directory"
elif [ -d "$1/Make" ]; then
echo Target $1
echo " Found target directory " $1
dir=$1
else
find_target "$1/.."
fi
}
if [ "$makeType" = dwim ]
if [ ! -d $MakeDir ]
then
echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2
echo " Searching up directories tree for Make directory"
find_target .
makeType=
......@@ -214,41 +241,16 @@ then
fi
#------------------------------------------------------------------------------
# Recurse the application directories tree
#------------------------------------------------------------------------------
if [ "$makeType" = all ]
then
if [ -e Allwmake ]
then
./Allwmake
exit $?
elif [ ! -d $MakeDir ]
then
# 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"
exit $?
fi
fi
#------------------------------------------------------------------------------
# Require the existence of the 'Make' directory and 'files' file
#------------------------------------------------------------------------------
[ -d $MakeDir ] || {
echo "$Script error: '$MakeDir' directory does not exist in $PWD" 1>&2
exit 1
}
[ -r $MakeDir/files ] || {
echo "$Script error: file '$MakeDir/files' does not exist in $PWD" 1>&2
exit 1
}
#------------------------------------------------------------------------------
# Transform options
#------------------------------------------------------------------------------
# transform "all" or no option to "libso" if that looks appropriate or remove it
# so that the call to make builds the application
if [ "$makeType" = all -o "$makeType" = "" ]
......@@ -261,8 +263,11 @@ then
fi
#------------------------------------------------------------------------------
# Spawn a sub-shell and unset MAKEFLAGS in that sub-shell to avoid
# files and options being built in parallel
#------------------------------------------------------------------------------
(
cd $MakeDir
unset MAKEFLAGS
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment