From 9a24bf0f9849428d800799a3d740834b505b5903 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 14 Jul 2014 18:03:00 +0200 Subject: [PATCH] libem.bash: - installation of doc-files simplified - restrict build of module to supported compilers is now possible - cleanup --- lib/libem.bash | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/libem.bash b/lib/libem.bash index e5925b8..b764ccd 100644 --- a/lib/libem.bash +++ b/lib/libem.bash @@ -50,18 +50,10 @@ ENV=VALUE } -# -# the module name might already be set in the build script(!) -#if [[ -z $P ]]; then - P=$(basename $0) - P=${P%.*} -#fi - -# unset the version of the module +P=$(basename $0) +P=${P%.*} _P=$(echo $P | tr [:lower:] [:upper:]) _V=${_P}_VERSION -#unset ${_V} -#fi DEBUG_ON='' FORCE_REBUILD='' @@ -200,12 +192,24 @@ function em.set_runtime_dependencies() { EM_DEPENDENCIES=("$@") } +function em.set_supported_compilers() { + EM_SUPPORTED_COMPILERS=("$@") +} + +function em.set_docfiles() { + EM_DOCFILES=("$@") +} + function _load_build_dependencies() { for m in "${EM_BUILD_DEPENDENCIES[@]}"; do [[ -z $m ]] && continue if [[ ! $m =~ "*/*" ]]; then - local _V=$(echo -n $m | tr [:lower:] [:upper:] )_VERSION - m=$m/${!_V} + local _V=$(echo -n $m | tr [:lower:] [:upper:] )_VERSION + if [[ -n ${!_V} ]]; then + m=$m/${!_V} + else + echo "Warning: No version set for $m. Trying default ..." + fi fi if module load "$m" 2>&1 | grep -q "Unable to locate"; then echo "Module \"$m\" not available, trying to build it..." @@ -368,7 +372,7 @@ function em.post_install() { } function em.install_doc() { - : + install -m0444 ${EM_DOCFILES[*]} "${DOCDIR}" } function _set_link() { @@ -407,12 +411,22 @@ function em.cleanup_src() { ); } +function _check_compiler() { + test -z ${EM_SUPPORTED_COMPILERS} && return 0 + for cc in ${EM_SUPPORTED_COMPILERS[@]}; do + if [[ ${COMPILER}/${COMPILER_VERSION} =~ ${cc} ]]; then + return 0 + fi + done + die 0 "Package cannot be build with ${COMPILER}/${COMPILER_VERSION}." +} function em.make_all() { _set_env if [[ ! -d "${PREFIX}" ]] || [[ ${FORCE_REBUILD} ]]; then echo "Building $P/$V ..." _load_build_dependencies + _check_compiler _prep cd "${EM_SRCDIR}" em.pre_configure