diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions index 1bfc676d83..0262350c20 100755 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -35,7 +35,7 @@ checkEnv() { - for envar in WM_OPTIONS WM_DIR WM_PROJECT_DIR + for envar in WM_OPTIONS WM_LINK_LANGUAGE WM_DIR WM_PROJECT_DIR do eval test "\$$envar" || { echo "$Script error: environment variable \$$envar not set" 1>&2 @@ -79,6 +79,32 @@ findTarget() fi } +cdSource() +{ + if [ ! -d $MakeDir ] + then + echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2 + echo " Searching up directories tree for Make directory" + + findTarget . + targetType= + + if [ "$dir" ] + then + cd $dir 2>/dev/null || { + echo "$Script error: could not change to directory '$dir'" 1>&2 + exit 1 + } + fi + fi + + + [ -r $MakeDir/files ] || { + echo "$Script error: file '$MakeDir/files' does not exist in $PWD" 1>&2 + exit 1 + } +} + findObjectDir() { expandPath $WM_PROJECT_DIR diff --git a/wmake/wclean b/wmake/wclean index 1819582649..fe8156aeb5 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -127,6 +127,15 @@ then fi +#------------------------------------------------------------------------------ +# If target not specified search up the directory tree for the Make +# sub-directory, check the existance of the 'files' file and clean there if +# present +# ------------------------------------------------------------------------------ + +[ -n "$targetType" ] || cdSource + + #------------------------------------------------------------------------------ # Remove empty sub-directories and exit #------------------------------------------------------------------------------ @@ -267,7 +276,7 @@ fi # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage MakeDir #------------------------------------------------------------------------------ diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll index a1673d53ba..2a4a434485 100755 --- a/wmake/wcleanLnIncludeAll +++ b/wmake/wcleanLnIncludeAll @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -34,9 +34,17 @@ ##------------------------------------------------------------------------------ Script=${0##*/} +# Source the wmake functions +. ${0%/*}/scripts/wmakeFunctions + +#------------------------------------------------------------------------------ +# Parse arguments and options +#------------------------------------------------------------------------------ + # Default to the CWD if [ "$#" -eq 0 ] then + # Add the CWD to the arguments set -- . elif [ "$1" = "-h" -o "$1" = "-help" ] then @@ -48,6 +56,20 @@ then fi +#------------------------------------------------------------------------------ +# Search up the directory tree for the Make sub-directory, +# check the existance of the 'files' file and clean there if present +#------------------------------------------------------------------------------ + +# Need to add an option or special logic to control cdSource +# MakeDir=Make +# cdSource + + +#------------------------------------------------------------------------------ +# Search for all lnInclude directories and delete them +#------------------------------------------------------------------------------ + for dir do if [ -d "$dir" ] @@ -64,7 +86,7 @@ done # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script +unset Script MakeDir #------------------------------------------------------------------------------ diff --git a/wmake/wmake b/wmake/wmake index 4998014994..0e42e77196 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -55,6 +55,9 @@ #------------------------------------------------------------------------------ Script=${0##*/} +# Source the wmake functions +. ${0%/*}/scripts/wmakeFunctions + usage() { exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done @@ -192,14 +195,7 @@ 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 - exit 1 - } -done - +checkEnv # When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR # must be set @@ -356,57 +352,7 @@ fi # check the existance of the 'files' file and build there if present #------------------------------------------------------------------------------ -unset dir - -expandPath() -{ - dir=$(dirname $1) - cwd=$PWD - cd $dir - exPath=$PWD - cd $cwd -} - -findTarget() -{ - expandPath $1 - - if [ "$exPath" = "$WM_PROJECT_DIR" \ - -o "$exPath" = "$HOME" \ - -o "$exPath" = "/" \ - ] - then - echo "$Script error: could not find Make directory" 1>&2 - elif [ -d "$1/Make" ]; then - echo " Found target directory " $1 - dir=$1 - else - findTarget "$1/.." - fi -} - -if [ ! -d $MakeDir ] -then - echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2 - echo " Searching up directories tree for Make directory" - - findTarget . - targetType= - - if [ "$dir" ] - then - cd $dir 2>/dev/null || { - echo "$Script error: could not change to directory '$dir'" 1>&2 - exit 1 - } - fi -fi - - -[ -r $MakeDir/files ] || { - echo "$Script error: file '$MakeDir/files' does not exist in $PWD" 1>&2 - exit 1 -} +cdSource #------------------------------------------------------------------------------