Minor fixes for make_cp2k.sh

- Silence (garbage) output of spack compiler find
- Process only non-empty SED_PATTERN_LIST
- Add -e flag to sed command
This commit is contained in:
Matthias Krack 2026-02-17 16:58:55 +01:00
parent 08977f0e78
commit f5f4884382

View file

@ -816,10 +816,12 @@ if [[ ! -d "${SPACK_BUILD_PATH}" ]]; then
fi
# Apply feature selection to spack configuration file
eval sed -E "${SED_PATTERN_LIST}" -i "${CP2K_CONFIG_FILE}"
if [[ -n "${SED_PATTERN_LIST}" ]]; then
eval sed -E "${SED_PATTERN_LIST}" -i "${CP2K_CONFIG_FILE}"
fi
# Find all compilers
if ! spack compiler find; then
if ! spack compiler find &> /dev/null; then
echo "ERROR: The compiler detection of spack failed"
${EXIT_CMD} 1
fi
@ -827,7 +829,7 @@ if [[ ! -d "${SPACK_BUILD_PATH}" ]]; then
# Retrieve the newest compiler version found by spack
GCC_VERSION_NEWEST="$(spack compilers | awk '/gcc/ {print $2}' | sort -V | tail -n 1)"
echo "The newest GCC compiler version found by spack is ${GCC_VERSION_NEWEST}"
GCC_VERSION_NEWEST="$(echo "${GCC_VERSION_NEWEST}" | sed -E 's/.*@([0-9]+).*/\1/' | cut -d. -f1)"
GCC_VERSION_NEWEST="$(echo "${GCC_VERSION_NEWEST}" | sed -E -e 's/.*@([0-9]+).*/\1/' | cut -d. -f1)"
# Check if the newest compiler version found on the host system is new enough
GCC_VERSION_MINIMUM="10"