Commit 28e79822 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: minor build script improvements

- add internal WM_SIZE_OPTIONS variable for reduced typing
- check for wmkdepend and wmkdep for wmake builds
- avoid egrep for getting processor count.
parent 7e5bdfd7
...@@ -20,9 +20,12 @@ ...@@ -20,9 +20,12 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# The normal locations for source, build and installation (prefix-dir) # The normal locations for source, build and installation (prefix-dir)
sourceBASE=$WM_THIRD_PARTY_DIR sourceBASE="$WM_THIRD_PARTY_DIR"
buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER buildBASE="$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER"
installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER installBASE="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Synthetic value combining precision and label size (Eg, DPInt32)
WM_SIZE_OPTIONS="${WM_PRECISION_OPTION}Int${WM_LABEL_SIZE}"
# Dynamic library endings (default is .so) # Dynamic library endings (default is .so)
[ "$(uname -s)" = Darwin ] && SO=dylib || SO=so [ "$(uname -s)" = Darwin ] && SO=dylib || SO=so
...@@ -116,29 +119,32 @@ whichMpicxx() ...@@ -116,29 +119,32 @@ whichMpicxx()
echo "${mpicxx:-mpicxx}" echo "${mpicxx:-mpicxx}"
} }
# The presence of wmkdep etc required for building with wmake # Require wmkdepend etc when building with wmake
requireWMakeToolchain() requireWMakeToolchain()
{ {
local dir="${WM_DIR:-$WM_PROJECT_DIR/wmake}" local wmDir="${WM_DIR:-$WM_PROJECT_DIR/wmake}"
local src="$dir/src" local archDir="$wmDir/platforms/$WM_ARCH$WM_COMPILER"
local bin="$dir/platforms/$WM_ARCH$WM_COMPILER/wmkdep"
test -x $bin || {
echo "Warning: the 'wmkdep' binary is missing - attempting to build it"
( cd $src && make -s )
}
test -x $bin || { if [ -x "$archDir/wmkdepend" ] || [ -x "$archDir/wmkdep" ]
exec 1>&2 then
echo echo "Appear to have {wmkdepend,wmkdep} binary" 1>&2
echo "Error: cannot use wmake build for '${0##*/}" else
echo " The 'wmkdep' binary is missing" echo "Warning: appear to be missing {wmkdepend,wmkdep} binary ... building" 1>&2
echo " Please run the top-level OpenFOAM Allwmake first" ( cd "$wmDir/src" && make -s )
echo
exit 1 [ -x "$archDir/wmkdepend" ] || [ -x "$archDir/wmkdep" ] || {
} exec 1>&2
echo
echo "Error: cannot use wmake build for '${0##*/}"
echo " Missing {wmkdepend,wmkdep} binary"
echo " Please try run the top-level OpenFOAM Allwmake first"
echo
exit 1
}
fi
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Some functions as per OpenFOAM etc/config.sh/functions # Some functions as per OpenFOAM etc/config.sh/functions
...@@ -189,9 +195,7 @@ setBuildSuffix() ...@@ -189,9 +195,7 @@ setBuildSuffix()
# #
unset WM_HOSTS WM_SCHEDULER unset WM_HOSTS WM_SCHEDULER
WM_NCOMPPROCS=$(egrep -c "^processor" /proc/cpuinfo 2>/dev/null) || \ WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || WM_NCOMPPROCS=1
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
WM_NCOMPPROCS=1
: ${WM_NCOMPPROCS:=1} : ${WM_NCOMPPROCS:=1}
export WM_NCOMPPROCS export WM_NCOMPPROCS
......
...@@ -130,7 +130,7 @@ fi ...@@ -130,7 +130,7 @@ fi
# HYPRE_SOURCE_DIR : location of the original sources # HYPRE_SOURCE_DIR : location of the original sources
HYPRE_SOURCE_DIR=$sourceBASE/$hyprePACKAGE HYPRE_SOURCE_DIR=$sourceBASE/$hyprePACKAGE
: ${HYPRE_ARCH_PATH:=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$hyprePACKAGE} : ${HYPRE_ARCH_PATH:=$installBASE$WM_SIZE_OPTIONS/$hyprePACKAGE}
[ -d "$HYPRE_SOURCE_DIR" ] || { [ -d "$HYPRE_SOURCE_DIR" ] || {
echo "Missing sources: '$hyprePACKAGE'" echo "Missing sources: '$hyprePACKAGE'"
......
...@@ -130,7 +130,7 @@ fi ...@@ -130,7 +130,7 @@ fi
# METIS_SOURCE_DIR : location of the original sources # METIS_SOURCE_DIR : location of the original sources
METIS_SOURCE_DIR=$sourceBASE/$metisPACKAGE METIS_SOURCE_DIR=$sourceBASE/$metisPACKAGE
: ${METIS_ARCH_PATH:=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$metisPACKAGE} : ${METIS_ARCH_PATH:=$installBASE$WM_SIZE_OPTIONS/$metisPACKAGE}
[ -d "$METIS_SOURCE_DIR" ] || { [ -d "$METIS_SOURCE_DIR" ] || {
echo "Missing sources: '$metisPACKAGE'" echo "Missing sources: '$metisPACKAGE'"
......
...@@ -96,7 +96,7 @@ fi ...@@ -96,7 +96,7 @@ fi
# MGRIDGEN_ARCH_PATH : installation directory # MGRIDGEN_ARCH_PATH : installation directory
MGRIDGEN_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$mgridgenPACKAGE MGRIDGEN_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$mgridgenPACKAGE
MGRIDGEN_ARCH_PATH=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$mgridgenPACKAGE MGRIDGEN_ARCH_PATH=$installBASE$WM_SIZE_OPTIONS/$mgridgenPACKAGE
: ${FOAM_MPI:=dummy} : ${FOAM_MPI:=dummy}
......
...@@ -130,7 +130,7 @@ fi ...@@ -130,7 +130,7 @@ fi
# PETSC_SOURCE_DIR : location of the original sources # PETSC_SOURCE_DIR : location of the original sources
PETSC_SOURCE_DIR=$sourceBASE/$petscPACKAGE PETSC_SOURCE_DIR=$sourceBASE/$petscPACKAGE
: ${PETSC_ARCH_PATH:=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$petscPACKAGE} : ${PETSC_ARCH_PATH:=$installBASE$WM_SIZE_OPTIONS/$petscPACKAGE}
[ -d "$PETSC_SOURCE_DIR" ] || { [ -d "$PETSC_SOURCE_DIR" ] || {
echo "Missing sources: '$petscPACKAGE'" echo "Missing sources: '$petscPACKAGE'"
...@@ -141,8 +141,8 @@ PETSC_SOURCE_DIR=$sourceBASE/$petscPACKAGE ...@@ -141,8 +141,8 @@ PETSC_SOURCE_DIR=$sourceBASE/$petscPACKAGE
echo "Starting build: $petscPACKAGE ($targetType)" echo "Starting build: $petscPACKAGE ($targetType)"
echo echo
( (
# PETSC arch # PETSC arch - same root as WM_OPTIONS (eg, DPInt32)
archOpt="${WM_PRECISION_OPTION}Int$WM_LABEL_SIZE" archOpt="$WM_SIZE_OPTIONS"
# Configuration options: # Configuration options:
configOpt="--with-cc=$(whichMpicc) --with-cxx=$(whichMpicxx)" configOpt="--with-cc=$(whichMpicc) --with-cxx=$(whichMpicxx)"
...@@ -181,9 +181,9 @@ echo ...@@ -181,9 +181,9 @@ echo
--download-f2cblaslapack=1 \ --download-f2cblaslapack=1 \
$configOpt \ $configOpt \
&& echo "Configured: petsc" \ && echo "Configured: petsc" \
&& make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH=$archOpt all \ && make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH="$archOpt" all \
&& echo "Built: petsc" \ && echo "Built: petsc" \
&& make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH=$archOpt install && make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH="$archOpt" install
&& echo "Installed: petsc" && echo "Installed: petsc"
) || { ) || {
echo "Error building: petsc" echo "Error building: petsc"
......
Markdown is supported
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