Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions build_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# the compiler/MPI combination
#
# sample usage:
# build_stack.sh -p "prefix" -c "config.sh" -y "stack.yaml" -m
# build_stack.sh -p "prefix" -c "config.sh" -y "stack.yaml" -l "library" -m
# build_stack.sh -h

set -eu
Expand All @@ -12,32 +12,31 @@ set -eu
export HPC_STACK_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# ==============================================================================

usage() {
set +x
echo
echo "Usage: $0 -p <prefix> | -c <config> | -y <yaml> -m -h"
echo "Usage: $0 -p <prefix> | -c <config> | -y <yaml> | -l <library> -m -h"
echo
echo " -p installation prefix <prefix> DEFAULT: $HOME/opt"
echo " -c use configuration file <config> DEFAULT: config/config_custom.sh"
echo " -y use yaml file <yaml> DEFAULT: config/stack_custom.yaml"
echo " -m use modules DEFAULT: NO"
echo " -l library to install <library> DEFAULT: ALL"
echo " -h display this message and quit"
echo
exit 1
}

# ==============================================================================

[[ $# -eq 0 ]] && usage

# Defaults:
library=""
export PREFIX="$HOME/opt"
config="${HPC_STACK_ROOT}/config/config_custom.sh"
yaml="${HPC_STACK_ROOT}/config/stack_custom.yaml"
export MODULES=false

while getopts ":p:c:y:mh" opt; do
while getopts ":p:c:y:l:mh" opt; do
case $opt in
p)
export PREFIX=$OPTARG
Expand All @@ -48,6 +47,9 @@ while getopts ":p:c:y:mh" opt; do
y)
yaml=$OPTARG
;;
l)
library=$OPTARG
;;
m)
export MODULES=true
;;
Expand All @@ -58,12 +60,10 @@ while getopts ":p:c:y:mh" opt; do
done

# ==============================================================================

# Source helper functions
source "${HPC_STACK_ROOT}/stack_helpers.sh"

#===============================================================================

# Source the config file
if [[ -e $config ]]; then
source $config
Expand All @@ -81,21 +81,10 @@ else
fi

# ==============================================================================

compilerName=$(echo $HPC_COMPILER | cut -d/ -f1)
compilerVersion=$(echo $HPC_COMPILER | cut -d/ -f2)

mpiName=$(echo $HPC_MPI | cut -d/ -f1)
mpiVersion=$(echo $HPC_MPI | cut -d/ -f2)

echo "Compiler: $compilerName/$compilerVersion"
echo "MPI: $mpiName/$mpiVersion"

# install with root permissions?
[[ $USE_SUDO =~ [yYtT] ]] && export SUDO="sudo" || export SUDO=""

# ==============================================================================

# create build directory if needed
pkgdir=${HPC_STACK_ROOT}/${PKGDIR:-"pkg"}
mkdir -p $pkgdir
Expand All @@ -105,7 +94,6 @@ logdir=$HPC_STACK_ROOT/${LOGDIR:-"log"}
mkdir -p $logdir

# ==============================================================================

# start with a clean slate
if $MODULES; then
source $MODULESHOME/init/bash
Expand All @@ -118,9 +106,18 @@ else
fi

# ==============================================================================
# Echo build information
# Echo compiler, mpi and build information
compilermpi_info
build_info

# ==============================================================================
# Is this a single library build or the entire stack?
if [ -n "${library:-""}" ]; then
build_lib $library
echo "build_stack.sh: SUCCESS!"
exit 0
fi

# ==============================================================================
#----------------------
# Compiler and MPI
Expand Down
18 changes: 7 additions & 11 deletions setup_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ usage() {

#===============================================================================

[[ $# -eq 0 ]] && usage

# Defaults:
PREFIX="$HOME/opt"
config="${HPC_STACK_ROOT}/config/config_custom.sh"
Expand All @@ -57,6 +55,10 @@ while getopts ":p:c:h" opt; do
esac
done

# ==============================================================================
# Source helper functions
source "${HPC_STACK_ROOT}/stack_helpers.sh"

#===============================================================================

# Source the config file
Expand All @@ -68,16 +70,10 @@ else
fi

#===============================================================================
# Echo compiler, mpi and build information
compilermpi_info

compilerName=$(echo $HPC_COMPILER | cut -d/ -f1)
compilerVersion=$(echo $HPC_COMPILER | cut -d/ -f2)

mpiName=$(echo $HPC_MPI | cut -d/ -f1)
mpiVersion=$(echo $HPC_MPI | cut -d/ -f2)

echo "Compiler: $compilerName/$compilerVersion"
echo "MPI: $mpiName/$mpiVersion"

#===============================================================================
# install with root permissions?
[[ $USE_SUDO =~ [yYtT] ]] && SUDO="sudo" || SUDO=""

Expand Down
14 changes: 14 additions & 0 deletions stack_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ function build_info() {
echo "=========================="
}

function compilermpi_info() {
local compiler=$HPC_COMPILER
local mpi=$HPC_MPI
local compilerName=$(echo $compiler | cut -d/ -f1)
local compilerVersion=$(echo $compiler | cut -d/ -f2)

local mpiName=$(echo $mpi | cut -d/ -f1)
local mpiVersion=$(echo $mpi | cut -d/ -f2)

echo "Compiler: $compilerName/$compilerVersion"
echo "MPI: $mpiName/$mpiVersion"
}

export -f update_modules
export -f no_modules
export -f set_pkg_root
Expand All @@ -255,3 +268,4 @@ export -f build_lib
export -f build_nceplib
export -f parse_yaml
export -f build_info
export -f compilermpi_info