165 lines
4.6 KiB
Bash
Executable file
165 lines
4.6 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Install script inspired by the ebuild system of Gentoo Linux
|
|
#
|
|
# Christoph Niethammer <niethammer@hlrs.de> (C) 2011
|
|
#
|
|
|
|
# exit on any error!
|
|
set -e
|
|
|
|
SIT_PATH=$(dirname $PWD/$0)
|
|
SIT_CONFIG_FILE=$SIT_PATH/etc/sit.conf
|
|
|
|
# Reading in global configuration file
|
|
if [[ -e $SIT_CONFIG_FILE ]] ; then
|
|
source $SIT_CONFIG_FILE
|
|
fi
|
|
source "$SIT_PATH/functions.sh"
|
|
|
|
|
|
# compiler to use
|
|
# (gnu|intel|pgi)
|
|
COMPILER=${COMPILER:=system}
|
|
# use specific compiler version
|
|
COMPILER_VERSION=${COMPILER_VERSION:=}
|
|
|
|
|
|
# add a descriptor at the end of the installation path e.g. for special config options etc.
|
|
PACKAGE_DESCRIPTOR=${PACKAGE_DESCRIPTOR:+-$PACKAGE_DESCRIPTOR}
|
|
|
|
|
|
# Compiler specifications
|
|
|
|
if [ "$COMPILER" == "system" ] ; then
|
|
echo "Using system default compiler"
|
|
else
|
|
if [ -z "$COMPILER_VERSION" ] ; then
|
|
COMPILER_MODULE=compiler/${COMPILER}
|
|
else
|
|
COMPILER_MODULE=compiler/${COMPILER}/${COMPILER_VERSION}
|
|
fi
|
|
|
|
echo "Loading compiler module ${COMPILER_MODULE}"
|
|
module load ${COMPILER_MODULE}
|
|
fi
|
|
|
|
case ${COMPILER} in
|
|
system)
|
|
COMPILER="" # prevent any compiler specs in the prefix
|
|
;;
|
|
gnu)
|
|
COMPILER_OPTS="CC=gcc CXX=g++ FC=gfortran F77=gfortran"
|
|
if [ "x${COMPILER_VERSION}" == "x" ] ; then
|
|
COMPILER_VERSION=$(gcc -dumpversion)
|
|
fi
|
|
;;
|
|
intel)
|
|
COMPILER_OPTS="CC=icc CXX=icpc FC=ifort F77=ifort"
|
|
if [ "x${COMPILER_VERSION}" == "x" ] ; then
|
|
COMPILER_VERSION=$(icc -dumpversion)
|
|
fi
|
|
;;
|
|
pgi)
|
|
COMPILER_OPTS="CC=pgcc CXX=pgCC FC=pgf95 F77=pgf77"
|
|
if [ "x${COMPILER_VERSION}" == "x" ] ; then
|
|
COMPILER_VERSION=$(pgcc -V | awk '/pgcc/{print $2}')
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Unknown compiler ${COMPILER}."
|
|
;;
|
|
esac
|
|
|
|
# make the compiler variables CC, CXX, FC and F77 available
|
|
if [ ! -z "$COMPILER_OPTS" ] ; then
|
|
export ${COMPILER_OPTS}
|
|
fi
|
|
|
|
if [ ! -z "$MPI" ] ; then
|
|
MPI_MODULE="mpi/$MPI"
|
|
if [ ! -z "$MPI_VERSION" ] ; then
|
|
MPI_VERSION_NUM=${MPI_VERSION%%-*}
|
|
MPI_MODULE=${MPI_MODULE}${MPI_VERSION_NUM:+"/${MPI_VERSION_NUM}-$COMPILER-$COMPILER_VERSION"}
|
|
fi
|
|
echo "Loading MPI module ${MPI_MODULE}"
|
|
module load $MPI_MODULE
|
|
MPI_DIR=${MPI_DIR:=$(dirname $(dirname $(which mpicc)))}
|
|
fi
|
|
|
|
|
|
SCLASSFILE=$1
|
|
ACTION=$2
|
|
|
|
if [ -f $SCLASS_DIR/$SCLASSFILE ] ; then
|
|
source $SCLASS_DIR/$SCLASSFILE
|
|
else
|
|
sit_fail "Could not find file $SCLASS_DIR/$SCLASSFILE"
|
|
fi
|
|
|
|
|
|
# construct the final installation directory path
|
|
PREFIX="${PREFIX_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}"
|
|
PREFIX_SUFFIX=${MPI:+"-$MPI"}${MPI_VERSION_NUM:+"-$MPI_VERSION_NUM"}
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${COMPILER:+"-$COMPILER"}${COMPILER_VERSION:+"-$COMPILER_VERSION"}
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${PACKAGE_DESCRIPTOR}
|
|
|
|
|
|
PREFIX=$PREFIX${PREFIX_SUFFIX:+"$PREFIX_SUFFIX"}
|
|
|
|
# final working directory path
|
|
WORKDIR=${WORKDIR_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}$PREFIX_SUFFIX
|
|
|
|
# path to the source code directory
|
|
SRCDIR=${WORKDIR}/${P}
|
|
|
|
# build directory (should be different from source directory):
|
|
BUILDDIR=${WORKDIR}/build
|
|
|
|
# logfile directory
|
|
LOGDIR=${WORKDIR}
|
|
|
|
|
|
# source the package class file a second time, so we can modify variables
|
|
# using their default values. (Defaults depend on other vairables in
|
|
# the class file like CATEGORY or PACKAGE)
|
|
source $SCLASS_DIR/$SCLASSFILE
|
|
|
|
echo "Installation PREFIX: $PREFIX"
|
|
echo "Working dir: $WORKDIR"
|
|
echo "Source dir: $SRCDIR"
|
|
echo "Build dir: $BUILDDIR"
|
|
echo "Logfile dir: $LOGDIR"
|
|
|
|
sit_countdown 2
|
|
|
|
if [ -d ${WORKDIR} ] ; then
|
|
sit_info "Removing existing working directory ${WORKDIR}"
|
|
sit_countdown 5
|
|
rm -rf ${WORKDIR}
|
|
fi
|
|
mkdir -p ${WORKDIR}
|
|
mkdir -p ${BUILDDIR}
|
|
mkdir -p ${LOGDIR}
|
|
|
|
sit_unpack 2>&1 | tee "$LOGDIR/unpack.log"; ( exit ${PIPESTATUS} )
|
|
sit_prepare 2>&1 | tee "$LOGDIR/prepare.log"; ( exit ${PIPESTATUS} )
|
|
sit_configure 2>&1 | tee "$LOGDIR/configure.log"; ( exit ${PIPESTATUS} )
|
|
sit_build 2>&1 | tee "$LOGDIR/make.log"; ( exit ${PIPESTATUS} )
|
|
sit_pretest 2>&1 | tee "$LOGDIR/pretest.log"; ( exit ${PIPESTATUS} )
|
|
sit_install 2>&1 | tee "$LOGDIR/make_install.log"; ( exit ${PIPESTATUS} )
|
|
sit_posttest 2>&1 | tee "$LOGDIR/posttest.log"; ( exit ${PIPESTATUS} )
|
|
sit_copy_logs
|
|
sit_setperms
|
|
|
|
|
|
cat <<EOF
|
|
##############################################################################
|
|
# IMPORTANT!
|
|
##############################################################################
|
|
# Do not forget to provide a module file!
|
|
##############################################################################
|
|
EOF
|
|
|
|
exit 0
|
|
|