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 %{_lib}
%define petsc_ver 3.22
%define so_ver 3_24

%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}

Name:           slepc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Version:        3.24.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
BuildRequires:  libpetsc3_24-%{mpi_family}%{?mpi_ext}
BuildRequires:  arpack-ng-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

if [ "%{_lib}" != "lib" ]; then
  pushd "${RPM_BUILD_DIR}/slepc-%{version}"
    mv "lib" "%{_lib}"
  popd
fi

sed -i -e 's#/lib/#/%{_lib}/#g' `find "${RPM_BUILD_DIR}/slepc-%{version}" -type f`
sed -e "s#'lib'#'%{_lib}'#g" -i ./config/*.py
sed -e "s#'lib'#'%{_lib}'#g" -i ./config/*/*.py

export SLEPC_DIR="${RPM_BUILD_DIR}/slepc-%{version}"
export PETSC_DIR="%{my_prefix}"
%if 0%{?mpi_family:1}
export PATH=$PATH:%{my_prefix}/bin
%endif

%if %{without mpi}

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

%else

python%{python_ver} ./configure \
    --prefix=%{my_prefix} \
    --with-arpack=1 \
    --with-primme=1 \
    --with-primme-dir=%{my_prefix}
%endif

cat installed-arch-linux2-cxx-opt/lib64/slepc/conf/configure.log

%make_build

%install
export SLEPC_DIR=${RPM_BUILD_DIR}/slepc-%{version}
export PETSC_DIR="%{my_prefix}"
%make_install
cp installed-*/lib/libslepc.so.%{version} %{buildroot}/%{my_libdir}/
ln -sf %{my_libdir}/libslepc.so.%{version}  %{buildroot}/%{my_libdir}/libslepc.so

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

%files -n %{libname %so_ver}
%{my_libdir}/libslepc.so.%{version}

%files devel
%dir %{my_libdir}/slepc

%{my_prefix}/share/slepc
%{my_prefix}/include/*
%{my_libdir}/slepc/conf
%{my_libdir}/pkgconfig/*
%{my_libdir}/libslepc.so

%changelog
openSUSE Build Service is sponsored by