diff --git a/build.sh b/build.sh index c1cfe43d8d..3f82a882da 100755 --- a/build.sh +++ b/build.sh @@ -1,17 +1,10 @@ #!/bin/bash set -eu -uname_s=$(uname -s) -if [[ ${uname_s} == Darwin ]]; then - UFS_MODEL_DIR=$(greadlink -f -n "${BASH_SOURCE[0]}") - UFS_MODEL_DIR=$(dirname "${UFS_MODEL_DIR}") - UFS_MODEL_DIR=$(cd "${UFS_MODEL_DIR}" && pwd -P) -else - UFS_MODEL_DIR=$(readlink -f -n "${BASH_SOURCE[0]}") - UFS_MODEL_DIR=$(dirname "${UFS_MODEL_DIR}") - UFS_MODEL_DIR=$(cd "${UFS_MODEL_DIR}" && pwd -P) -fi -echo "UFS MODEL DIR: ${UFS_MODEL_DIR}" + +SCRIPT_REALPATH=$(realpath "${BASH_SOURCE[0]}") +UFS_MODEL_DIR=$(dirname "${SCRIPT_REALPATH}") readonly UFS_MODEL_DIR +echo "UFS MODEL DIR: ${UFS_MODEL_DIR}" export CC=${CC:-mpicc} export CXX=${CXX:-mpicxx} @@ -26,4 +19,4 @@ for i in ${CMAKE_FLAGS}; do ARR_CMAKE_FLAGS+=("${i}") ; done cmake "${UFS_MODEL_DIR}" "${ARR_CMAKE_FLAGS[@]}" # Turn off OpenMP threading for parallel builds # to avoid exhausting the number of user processes -OMP_NUM_THREADS=1 make -j "${BUILD_JOBS:-4}" "VERBOSE=${BUILD_VERBOSE:-}" \ No newline at end of file +OMP_NUM_THREADS=1 make -j "${BUILD_JOBS:-4}" "VERBOSE=${BUILD_VERBOSE:-}" diff --git a/tests/compile.sh b/tests/compile.sh index 458d985a88..8ab0f60b82 100755 --- a/tests/compile.sh +++ b/tests/compile.sh @@ -12,14 +12,8 @@ function trim { SECONDS=0 -uname_s=$(uname -s) -if [[ ${uname_s} == Darwin ]]; then - greadlnk=$(greadlink -f -n "${BASH_SOURCE[0]}" ) - MYDIR=$(cd "$(dirname "${greadlnk}" )" && pwd -P) -else - readlnk=$(readlink -f -n "${BASH_SOURCE[0]}" ) - MYDIR=$(cd "$(dirname "${readlnk}" )" && pwd -P) -fi +SCRIPT_REALPATH=$(realpath "${BASH_SOURCE[0]}") +MYDIR=$(dirname "${SCRIPT_REALPATH}") readonly MYDIR # ----------------------------------------------------------------------