-# kmod tools/scripts require %{name} directory with kernel modules
-%define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
+# kmod tools/scripts require "name" directory with kernel modules
+
+%if 0%{?rhel} >= 9
+%define _configure eval ./configure
+%define eval_configure %configure
+%else
+%define eval_configure %(echo -n '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
+%endif
+
+%if %{with mpi}
+%if "%{mpi_name}" == "mpich"
+%{?_mpich_load}
+%endif
+%if "%{mpi_name}" == "openmpi"
+%{?_openmpi_load}
+%endif
+# mpi
+%endif
+
+%if %{with mofed}
+ o2ib_path=$(find /usr/src/ofa_kernel/ -type d -name ofed_scripts | xargs dirname)
+ if [ -z "$o2ib_path" ]; then
+ echo "ERROR: could not find OFED devel headers"
+ exit 1
+ fi
+ if [ $(echo $o2ib_path | wc -w) -ge 2 ]; then
+ echo "ERROR: multiple OFED versions installed"
+ exit 1
+ fi
+%endif