File slepc.spec of Package slepc

#
# spec file for package slepc
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%global flavor @BUILD_FLAVOR@%{nil}

%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150200
%define DisOMPI3
 ExclusiveArch:  do_not_build
%endif

%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150600
%define DisOMPI4
 ExclusiveArch:  do_not_build
%endif

# Use the same version as used by PETSc build
%define python_ver 3

%define petsc_arch linux-gnu-c-opt
%define petsc_ver 3.22
%define so_ver 3_22

%if "%flavor" == ""
ExclusiveArch:  do_not_build
%endif

%if "%flavor" == "serial"
%endif

%if "%flavor" == "openmpi4"
%{?DisOMPI4}
%define mpi_family openmpi
%define mpi_ver 4
%endif

%if "%flavor" == "openmpi5"
%{?DisOMPI5}
%define mpi_family openmpi
%define mpi_ver 5
%endif

%define mpi_ext %{?mpi_ver}

%if 0%{?mpi_family:1}
%define my_prefix %{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ext}
%{bcond_without mpi}
%else
%define my_prefix %{_prefix}
%{bcond_with mpi}
%endif

%define my_libdir %{my_prefix}/%{_lib}
%define my_includedir %{my_prefix}/include

%define libname() libslepc%{so_ver}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}

%define s_prefix %{my_libdir}/slepc/%{version}/%{petsc_arch}

Name:           slepc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Version:        3.22.2
Release:        0
Summary:        A library for solving large scale sparse eigenvalue problems
License:        BSD-2-Clause
Group:          Development/Libraries/C and C++
Url:            https://slepc.upv.es/
Source0:        https://slepc.upv.es/download/distrib/slepc-%{version}.tar.gz
BuildRequires:  blas-devel
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  lapack-devel
%if %{with mpi}
BuildRequires:  petsc-%{mpi_family}%{?mpi_ext}-devel >= %{petsc_ver}
BuildRequires:  parpack-%{mpi_family}%{?mpi_ext}-devel
BuildRequires:  pastix-%{mpi_family}%{?mpi_ext}-devel
#!BuildIgnore:  metis-devel
%else
BuildRequires:  petsc-devel >= %{petsc_ver}
BuildRequires:  arpack-ng-devel
%endif
BuildRequires:  python3-base
BuildRequires:  trlan%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
BuildRequires:  primme-devel > 2.0
BuildRequires:  hwloc-devel

%description
SLEPc is a software library for the solution of large scale sparse
eigenvalue problems on parallel computers. It is an extension of
PETSc and can be used for either standard or generalized eigenproblems,
with real or complex arithmetic. It can also be used for computing a
partial SVD of a large, sparse, rectangular matrix, and to solve
quadratic eigenvalue problems.

%package -n %{libname %so_ver}
Summary:        A library for solving large scale sparse eigenvalue problems
Group:          System/Libraries
%if "%{libname %so_ver}" != "libslepc3"
Provides:       libslepc3 = %{version}
%endif

%description -n %{libname %so_ver}
SLEPc is a software library for the solution of large scale sparse
eigenvalue problems on parallel computers. It is an extension of
PETSc and can be used for either standard or generalized eigenproblems,
with real or complex arithmetic. It can also be used for computing a
partial SVD of a large, sparse, rectangular matrix, and to solve
quadratic eigenvalue problems.

This package contains the serial version of the slepc library.

%package devel
Summary:        Development and header files for %{name}
Group:          Development/Libraries/C and C++
Requires:       petsc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
Requires:       primme-devel
Requires:       trlan%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
Requires:       %{libname %so_ver} = %{version}

%description devel
This package contains the development and header files for %{name}.


%prep
%setup -q -n slepc-%{version}


%build
# Source directory
export SLEPC_DIR=${RPM_BUILD_DIR}/slepc-%{version}
export PETSC_DIR=`echo %{my_libdir}/petsc/3.*/%{petsc_arch}`
ls ${PETSC_DIR}/{,lib/}

%if %{without mpi}
export PETSC_ARCH=''

python%{python_ver} ./configure --prefix=%{s_prefix} \
    --with-arpack=1 \
    --with-primme=1 --with-primme-include=%{_includedir} \
    --with-trlan=1 \
%else

# build parallel version library

python%{python_ver} ./configure  -h

python%{python_ver} ./configure --prefix=%{s_prefix} \
    --with-arpack=1 --with-arpack-include=%{my_includedir} --with-arpack-lib="-lparpack" \
    --with-primme=1 --with-primme-dir=%{_prefix} \
    --with-trlan=1 --with-trlan-dir=%{my_prefix} \
    || cat configure.log
%endif

%make_build


%install
export SLEPC_DIR=${RPM_BUILD_DIR}/slepc-%{version}
export PETSC_DIR=`echo %{my_libdir}/petsc/3.*/%{petsc_arch}`
%make_install

pushd %{buildroot}%{s_prefix}/lib
rm -f slepc/conf/*.log
rm -rf slepc/conf/modules
# Remove, obviously unnecessary, and contains an unordered python dict (unreproducible)
rm -f slepc/conf/uninstall.py

# Remove examples/tests for now ...
rm -Rf %{buildroot}%{s_prefix}/share/slepc/examples

find . -type f -print0 | \
while IFS= read -r -d $'\0' line ; do
   if file -e soft $line | grep -q "text" ; then
     sed -n '\@%{buildroot}@ p' $line
     sed -i 's!%{buildroot}!!g' $line
   fi
done
popd


# Module file
mkdir -p %{buildroot}%{_datadir}/modules/%{name}-%{petsc_arch}
cat << EOF > %{buildroot}%{_datadir}/modules/%{name}-%{petsc_arch}/%{version}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
#%Module
proc ModulesHelp { } {
        global dotversion
        puts stderr "\tLoads the %{name}-%{petsc_arch} %version Environment"
}

module-whatis  "Loads the %{name}-%{petsc_arch} %version Environment."
module load petsc-%{petsc_arch}/%{version}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
conflict %{name}-%{petsc_arch}
setenv PETSC_ARCH %{petsc_arch}
setenv SLEPC_DIR  %{s_prefix}/
prepend-path LD_LIBRARY_PATH %{s_prefix}/lib

EOF


%post -n %{libname %so_ver} -p /sbin/ldconfig
%postun -n %{libname %so_ver} -p /sbin/ldconfig

%files -n %{libname %so_ver}
%dir %{my_libdir}/slepc
%dir %{my_libdir}/slepc/%{version}
%dir %{s_prefix}
%dir %{s_prefix}/lib
%{s_prefix}/lib/*.so.*

%files devel
%dir %{s_prefix}/lib/slepc
%{s_prefix}/lib/slepc/conf
%{s_prefix}/lib/pkgconfig
%{s_prefix}/lib/*.so
%{s_prefix}/include
%dir %{_datadir}/modules/%{name}-%{petsc_arch}
%{_datadir}/modules/%{name}-%{petsc_arch}/%{version}*
%dir %{s_prefix}/share
%{s_prefix}/share/slepc

%changelog
openSUSE Build Service is sponsored by