diff --git a/tools/spglib/config/default/.dummy b/tools/spglib/config/default/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/tools/spglib/config/default/build.sh b/tools/spglib/config/default/build.sh new file mode 100644 index 00000000..977103e9 --- /dev/null +++ b/tools/spglib/config/default/build.sh @@ -0,0 +1,4 @@ +set -u + +cd build +make ${MAKE_J} diff --git a/tools/spglib/config/default/install.sh b/tools/spglib/config/default/install.sh new file mode 100644 index 00000000..372d1c6f --- /dev/null +++ b/tools/spglib/config/default/install.sh @@ -0,0 +1,4 @@ +set -u + +cd build +make install diff --git a/tools/spglib/config/default/preprocess.sh b/tools/spglib/config/default/preprocess.sh new file mode 100644 index 00000000..35450a0c --- /dev/null +++ b/tools/spglib/config/default/preprocess.sh @@ -0,0 +1,4 @@ +set -u + +rm -rf build && mkdir -p build && cd build +cmake -DCMAKE_INSTALL_PREFIX=$PREFIX ../ diff --git a/tools/spglib/download.sh b/tools/spglib/download.sh new file mode 100644 index 00000000..5770038c --- /dev/null +++ b/tools/spglib/download.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +SCRIPT_DIR=$(cd "$(dirname $0)"; pwd) +. $SCRIPT_DIR/../../scripts/util.sh +. $SCRIPT_DIR/version.sh +set_prefix + +VERSION_MAJOR=$(echo "${__VERSION__}" | cut -d . -f 1,2) +if [ -f $SOURCE_DIR/${__NAME__}-${__VERSION__}.tar.gz ]; then :; else + check wget -O $SOURCE_DIR/${__NAME__}-${__VERSION__}.tar.gz https://github.com/spglib/spglib/archive/refs/tags/v${__VERSION__}.tar.gz +fi diff --git a/tools/spglib/install.sh b/tools/spglib/install.sh new file mode 100644 index 00000000..10de356f --- /dev/null +++ b/tools/spglib/install.sh @@ -0,0 +1,80 @@ +#!/bin/sh +cat << EOF > config.txt +# configurable variables (e.g. compiler) + +# use default if not defined +export MAKE_J="${MAKE_J:-"-j1"}" + +# export explicitly if defined +test -n "${CC+defined}" && export CC="$CC" + +EOF +. ./config.txt + +set -e + +XTRACED=$(set -o | awk '/xtrace/{ print $2 }') +if [ "$XTRACED" = "off" ]; then + SHFLAG="" +else + SHFLAG="-x" +fi + +mode=${1:-default} +export SCRIPT_DIR=$(cd "$(dirname $0)"; pwd) +CONFIG_DIR=$SCRIPT_DIR/config/$mode +if [ ! -d $CONFIG_DIR ]; then + echo "Error: unknown mode: $mode" + echo "Available list:" + ls -1 $SCRIPT_DIR/config + exit 127 +fi +DEFAULT_CONFIG_DIR=$SCRIPT_DIR/config/default + +export UTIL_SH=$SCRIPT_DIR/../../scripts/util.sh +. $UTIL_SH +. $SCRIPT_DIR/version.sh +set_prefix + +. ${MA_ROOT}/env.sh +export PREFIX="${MA_ROOT}/${__NAME__}/${__NAME__}-${__VERSION__}-${__MA_REVISION__}" +if [ -d $PREFIX ]; then + echo "Error: $PREFIX exists" + exit 127 +fi +export LOG=${BUILD_DIR}/${__NAME__}-${__VERSION__}-${__MA_REVISION__}.log +mv config.txt $LOG + +set +e +. $SCRIPT_DIR/../../tools/openssl/find.sh; if [ ${MA_HAVE_OPENSSL} = "no" ]; then echo "Error: openssl not found"; exit 127; fi +set -e + +rm -rf ${BUILD_DIR}/${__NAME__}-${__VERSION__} +pipefail sh $SHFLAG ${SCRIPT_DIR}/setup.sh \| tee -a $LOG +cd ${BUILD_DIR}/${__NAME__}-${__VERSION__} +start_info | tee -a $LOG + +for process in preprocess build install postprocess; do + if [ -f $CONFIG_DIR/${process}.sh ]; then + echo "[${process}]" | tee -a $LOG + pipefail check sh $SHFLAG $CONFIG_DIR/${process}.sh \| tee -a $LOG + elif [ -f $DEFAULT_CONFIG_DIR/${process}.sh ]; then + echo "[${process}]" | tee -a $LOG + pipefail check sh $SHFLAG $DEFAULT_CONFIG_DIR/${process}.sh \| tee -a $LOG + fi +done + +finish_info | tee -a $LOG + +ROOTNAME=$(toupper ${__NAME__})_ROOT + +cat << EOF > ${BUILD_DIR}/${__NAME__}vars.sh +# ${__NAME__} $(basename $0 .sh) ${__VERSION__} ${__MA_REVISION__} $(date +%Y%m%d-%H%M%S) +export ${ROOTNAME}=$PREFIX +export LD_LIBRARY_PATH=\${${ROOTNAME}}/lib64:\$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=\${${ROOTNAME}}/lib64:\$DYLD_LIBRARY_PATH +EOF +VARS_SH=${MA_ROOT}/${__NAME__}/${__NAME__}vars-${__VERSION__}-${__MA_REVISION__}.sh +rm -f $VARS_SH +cp -f ${BUILD_DIR}/${__NAME__}vars.sh $VARS_SH +cp -f $LOG ${MA_ROOT}/${__NAME__}/ diff --git a/tools/spglib/link.sh b/tools/spglib/link.sh new file mode 100644 index 00000000..5e680dc3 --- /dev/null +++ b/tools/spglib/link.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +SCRIPT_DIR=$(cd "$(dirname $0)"; pwd) +. $SCRIPT_DIR/../../scripts/util.sh +. $SCRIPT_DIR/version.sh +set_prefix + +. $MA_ROOT/env.sh + +VARS_SH=$MA_ROOT/${__NAME__}/${__NAME__}vars-$__VERSION__-$__MA_REVISION__.sh +rm -f $MA_ROOT/env.d/${__NAME__}vars.sh +ln -s $VARS_SH $MA_ROOT/env.d/${__NAME__}vars.sh diff --git a/tools/spglib/setup.sh b/tools/spglib/setup.sh new file mode 100644 index 00000000..8d0ab27d --- /dev/null +++ b/tools/spglib/setup.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +SCRIPT_DIR=$(cd "$(dirname $0)"; pwd) +. $SCRIPT_DIR/../../scripts/util.sh +. $SCRIPT_DIR/version.sh +set_prefix + +sh $SCRIPT_DIR/download.sh + +cd $BUILD_DIR +if [ -d ${__NAME__}-${__VERSION__} ]; then :; else + check tar zxf $SOURCE_DIR/${__NAME__}-${__VERSION__}.tar.gz + if [ -f $SCRIPT_DIR/patch/${__NAME__}-${__VERSION__}.patch ]; then + cd ${__NAME__}-${__VERSION__} + cat $SCRIPT_DIR/patch/${__NAME__}-${__VERSION__}.patch | patch -p1 + fi +fi diff --git a/tools/spglib/version.sh b/tools/spglib/version.sh new file mode 100644 index 00000000..81963838 --- /dev/null +++ b/tools/spglib/version.sh @@ -0,0 +1,6 @@ +SPGLIB_VERSION="2.5.0" +SPGLIB_MA_REVISION="1" + +__NAME__=spglib +__VERSION__=${SPGLIB_VERSION} +__MA_REVISION__=${SPGLIB_MA_REVISION}