File primme.spec of Package primme

#
# spec file for package primme
#
# Copyright (c) 2023 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}

%define pname primme
%define so_ver 3

%if "%{flavor}" == ""
%define my_suffix  %{nil}
%define my_prefix %{_prefix}
%define my_bindir %{_bindir}
%define my_libdir %{_libdir}
%define my_includedir %{_includedir}
%endif

%if "%{flavor}" == "openmpi1" && 0%{?suse_version} < 1550
%define mpi_flavor  openmpi
%else
%define mpi_flavor  %{flavor}
%endif

%if "%{?mpi_flavor}" != ""
%define my_suffix  -%{mpi_flavor}
%define mpiprefix %{_libdir}/mpi/gcc/%{mpi_flavor}
%define my_prefix %{mpiprefix}
%define my_bindir %{mpiprefix}/bin
%define my_libdir %{mpiprefix}/%{_lib}
%define my_includedir %{mpiprefix}/include
%endif

Name:           %{pname}%{?my_suffix}
Version:        3.2
Release:        0
Summary:        A PReconditioned Iterative MultiMethod Eigensolver
# library itself is BSD-3-Clause, tests are LGPL-3.0
License:        BSD-3-Clause AND LGPL-3.0-only
Group:          Development/Libraries/C and C++
URL:            https://www.cs.wm.edu/~andreas/software/
Source0:        https://github.com/primme/primme/archive/v%{version}.tar.gz#/%{pname}_v%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  gcc-fortran
%if "%{flavor}" != ""
BuildRequires:  %{mpi_flavor}-devel
Requires:       %{mpi_flavor}
%endif

%description
PRIMME is a C library to find a number of eigenvalues and their corresponding
eigenvectors of a Real Symmetric, or Complex Hermitian matrix A.

%package -n libprimme%{so_ver}%{?my_suffix}
License:        BSD-3-Clause
Summary:        A PReconditioned Iterative MultiMethod Eigensolver
Group:          System/Libraries

%description -n libprimme%{so_ver}%{?my_suffix}
PRIMME is a C library to find a number of eigenvalues and their corresponding
eigenvectors of a Real Symmetric, or Complex Hermitian matrix A.

%package devel
License:        BSD-3-Clause
Summary:        Development and header files for %{name}
Group:          Development/Libraries/C and C++
Requires:       libprimme%{so_ver}%{?my_suffix} = %{version}

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

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

%build
export CFLAGS="$RPM_OPT_FLAGS -fPIC"

%if "%{flavor}" == ""
make solib \
    CC=gcc \
    F77=gfortran \
    CFLAGS="$RPM_OPT_FLAGS -fPIC" \
    FFLAGS="$RPM_OPT_FLAGS -fPIC"

%else
make solib \
    CC=%{my_bindir}/mpicc \
    F77=%{my_bindir}/mpif77 \
    CFLAGS="$RPM_OPT_FLAGS -fPIC" \
    FFLAGS="$RPM_OPT_FLAGS -fPIC"
%endif

%install

make DESTDIR=%{buildroot} \
     PREFIX=%{my_prefix} \
     libdir=%{buildroot}%{my_libdir} install

%fdupes -s %{buildroot}%{my_includedir}


%post -n libprimme%{so_ver}%{?my_suffix} -p /sbin/ldconfig

%postun -n libprimme%{so_ver}%{?my_suffix} -p /sbin/ldconfig

%files -n libprimme%{so_ver}%{?my_suffix}
%{_libdir}/*.so.*

%files devel
%doc readme.txt
%license COPYING.txt
%{my_includedir}/*
%{my_libdir}/*.so

%files -n libprimme%{so_ver}%{?my_suffix}
%{my_libdir}/*.so.*

%changelog
openSUSE Build Service is sponsored by