openfoam/Allwmake
Mark Olesen 934d0bd743 ENH: support FOAM_MODULE_PREFIX to guide location of module builds (#1721)
- When compiling additional modules or user code, we need more control
  for the installation locations beyond the usual FOAM_USER_LIBBIN,
  FOAM_SITE_LIBBIN, FOAM_LIBBIN, and wish to have these values be
  modifiable without editing files.

- provide wmake rules for handling standard defaults:
    * GENERAL_RULES/module-path-user
    * GENERAL_RULES/module-path-group
    * GENERAL_RULES/module-path-project
  which are incorporated as follows:

  Make/options:
      include $(GENERAL_RULES)/module-path-user

  Make/files:
      LIB = $(FOAM_MODULE_LIBBIN)/libMyLibrary

  By default these would compile into FOAM_USER_{APPBIN,LIBBIN} but
  could be adjusted at compilation time. For example,

```
wmake -module-prefix=/path/my-install-location
```
Or
```
./Allwmake -module-prefix=/path/my-install-location
./Allwmake -prefix=/path/my-install-location
```
Or
```
FOAM_MODULE_PREFIX=/path/my-install-location ./Allwmake
```

ENH: add -no-recursion option for AllwmakeParseArguments

- more descriptive naming than the -fromWmake option (still supported)

- remove wmake/scripts/wmake.{cmake,wmake}-args since the -prefix
  handling and -no-recursion is now directly handled by AllwmakeParseArguments
2020-06-08 13:51:26 +02:00

121 lines
3.7 KiB
Bash
Executable File

#!/bin/sh
# Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
echo "Argument parse error";
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
fi
#------------------------------------------------------------------------------
# Preamble. Report tools or at least the mpirun location
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/list_tools ]
then . "$WM_PROJECT_DIR"/wmake/scripts/list_tools
else
echo "mpirun=$(command -v mpirun || true)"
fi
echo
# Report compiler information
compiler="$(wmake -show-path-cxx 2>/dev/null || true)"
if [ -x "$compiler" ]
then
echo "compiler=$compiler"
"$compiler" --version 2>/dev/null | sed -ne '1p'
else
echo "compiler=unknown"
fi
echo
echo "========================================"
date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo "========================================"
echo
# Compile tools for wmake
"${WM_DIR:-wmake}"/src/Allmake
# Compile ThirdParty libraries and applications
if [ -d "$WM_THIRD_PARTY_DIR" ]
then
if [ -e "$WM_THIRD_PARTY_DIR"/Allwmake.override ]
then
if [ -x "$WM_THIRD_PARTY_DIR"/Allwmake.override ]
then "$WM_THIRD_PARTY_DIR"/Allwmake.override
fi
elif [ -x "$WM_THIRD_PARTY_DIR"/Allwmake ]
then "$WM_THIRD_PARTY_DIR"/Allwmake
else
echo "Skip ThirdParty (no Allwmake* files)"
fi
else
echo "Skip ThirdParty (no directory)"
fi
echo "========================================"
echo "Compile OpenFOAM libraries"
echo
src/Allwmake $targetType $*
echo "========================================"
echo "Compile OpenFOAM applications"
echo
applications/Allwmake $targetType $*
# Additional components/modules
if [ "$FOAM_MODULE_PREFIX" = false ]
then
echo "========================================"
echo "OpenFOAM modules disabled (prefix=false)"
echo
elif [ -d "$WM_PROJECT_DIR/modules" ]
then
echo "========================================"
echo "Compile OpenFOAM modules"
echo " ignoring possible compilation errors"
echo " make certain to check the output file"
echo
set +e
export WM_CONTINUE_ON_ERROR=true
# Default build into OpenFOAM project locations
: "${FOAM_MODULE_PREFIX:=${FOAM_LIBBIN%/*}}"
export FOAM_MODULE_PREFIX
(cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
fi
# Count files in given directory. Ignore "Test-*" binaries.
_foamCountDirEntries()
{
(cd "$1" 2>/dev/null && find . -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
sed -e '\@/Test-@d' | wc -l
}
# Some summary information
echo
date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
echo "========================================"
echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo
echo " api = $(etc/openfoam -show-api 2>/dev/null)"
echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo
echo "========================================"
#------------------------------------------------------------------------------