File pastix.spec of Package pastix

#
# spec file for package pastix
#
# 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 pastix
%define pastix_so_ver 6_2
%define spm_so_ver 1
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects

%if "%{flavor}" == ""
%undefine mpi_family
%endif

%if "%{flavor}" == "openmpi4"
%define mpi_family  openmpi
%define mpi_ver 4
%bcond_with hpc
%endif

%if "%{flavor}" == "openmpi5"
%define mpi_family  openmpi
%define mpi_ver 5
%bcond_with hpc
%endif

%if "%{flavor}" == "mvapich2"
%define mpi_family  mvapich2
%bcond_with hpc
%endif

%{?mpi_family:%{bcond_without mpi}}%{!?mpi_family:%{bcond_with mpi}}
%define mpi_ext %{?mpi_ver}

%if %{without mpi}
%define my_prefix %_prefix
%define my_bindir %_bindir
%define my_libdir %_libdir
%define my_incdir %_includedir
%define my_datadir %_datadir
%else
%define my_suffix  -%{mpi_family}%{?mpi_ext}
%define my_prefix %{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ext}
%define my_bindir %{my_prefix}/bin
%define my_libdir %{my_prefix}/%{_lib}
%define my_incdir %{my_prefix}/include
%define my_datadir %{my_prefix}/share
%endif
%define libname() lib%{1}%{expand:%{%{1}_so_ver}}%{?my_suffix}

Name:           pastix%{?my_suffix}
Summary:        A high performance parallel solver for very large sparse linear systems
License:        CECILL-C
Group:          Development/Libraries/C and C++
Version:        6.2.2
Release:        0
URL:            https://solverstack.gitlabpages.inria.fr/pastix/
Source:         https://gitlab.inria.fr/solverstack/pastix//uploads/d579e932b415103974ced5d216481332/pastix-6.2.2.tar.gz
BuildRequires:  blas-devel
BuildRequires:  cblas-devel
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  hwloc-devel
BuildRequires:  lapack-devel
BuildRequires:  lapacke-devel
BuildRequires:  python3-base
%if %{with mpi}
BuildRequires:  %{mpi_family}%{?mpi_ext}-devel
BuildRequires:  ptscotch%{my_suffix}-devel
%else
BuildRequires:  scotch-devel
%endif

%description
PaStiX (Parallel Sparse matriX package) is a scientific library that
provides a high performance parallel solver for very large sparse
linear systems based on direct methods.

%package -n %{libname pastix}
Summary:        PaStiX share libraries
Group:          System/Libraries

%description -n %{libname pastix}
PaStiX (Parallel Sparse matriX package) is a scientific library that
provides a high performance parallel solver for very large sparse
linear systems based on direct methods.

%package -n %{libname spm}
Summary:        SPM shared library
Group:          System/Libraries

%description -n %{libname spm}
SPM (SParse Matrix package) is a scientific library that provides
basic operation coverage to manipulate sparse matrices in CSC, CSR,
and IJV format.

%package devel
Summary:        Devel files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{libname pastix} = %{version}
Requires:       %{libname spm} = %{version}
%if %{with mpi}
Requires:       %{mpi_family}%{?mpi_ext}-devel
Requires:       ptscotch%{my_suffix}-devel
%else
Requires:       scotch-devel
%endif

%description devel
PaStiX (Parallel Sparse matriX package) is a scientific library that
provides a high performance parallel solver for very large sparse
linear systems based on direct methods.

%prep
%setup -q -n %{pname}-%{version}
# Unfortunately, a mix of $LIB_INSTALL_DIR and "lib" is used
find . -type f -iname \*CMakeLists.txt -exec \
  sed -i -e 's,DESTINATION lib,DESTINATION %{_lib},' '{}' \;

echo 'set_target_properties( pastix_kernels PROPERTIES
  VERSION ${PASTIX_VERSION}
  SOVERSION ${PASTIX_VERSION_MAJOR}.${PASTIX_VERSION_MINOR} )' \
  >> kernels/CMakeLists.txt

%build
%cmake \
  -DCMAKE_INSTALL_PREFIX=%{my_prefix} \
  -DPASTIX_INT64:BOOL=OFF \
  -DPASTIX_WITH_MPI:BOOL=%{?with_mpi:ON}%{!?with_mpi:OFF} \
  -DPASTIX_WITH_FORTRAN:BOOL=OFF \
  -DSPM_WITH_FORTRAN:BOOL=OFF \
  -DLIB_INSTALL_DIR=%{_lib} \
  -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \
  %{nil}
%cmake_build

%install
%cmake_install

# Remove broken pkgconfig files and env setup script
rm -Rf %{buildroot}%{my_prefix}/lib/pkgconfig
rm -Rf %{buildroot}%{my_bindir}/pastix_env.sh

rm -Rf %{buildroot}%{my_prefix}/examples
rm -Rf %{buildroot}%{my_libdir}/{julia,python}

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

%files -n %{libname pastix}
%{my_libdir}/libpas*.so.*

%files -n %{libname spm}
%{my_libdir}/libspm*.so.*

%files devel
%{my_incdir}/*
%{my_libdir}/*.so
%{?with_mpi:%dir %{my_libdir}/cmake}
%{my_libdir}/cmake/pastix
%{my_libdir}/cmake/spm

%changelog
openSUSE Build Service is sponsored by