File zoltan.spec of Package zoltan
#
# spec file for package zoltan
#
# Copyright (c) 2022 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 http://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == ""
%define my_suffix %{nil}
%define my_prefix %_prefix
%define my_bindir %_bindir
%define my_libdir %_libdir
%define my_incdir %_includedir
%define my_datadir %_datadir
%endif
%if "%{flavor}" == "openmpi4"
%{?DisOMPI4}
%define my_suffix -openmpi4
%define mpi_flavor openmpi4
%define mpiprefix %{_libdir}/mpi/gcc/%{mpi_flavor}
%endif
%if "%{flavor}" == "openmpi5"
%{?DisOMPI4}
%define my_suffix -openmpi5
%define mpi_flavor openmpi5
%define mpiprefix %{_libdir}/mpi/gcc/%{mpi_flavor}
%endif
%{?mpi_flavor:%{bcond_without mpi}}%{!?mpi_flavor:%{bcond_with mpi}}
%if %{with mpi}
%define my_prefix %{mpiprefix}
%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 shlib libzoltan3%{?my_suffix}
Name: zoltan%{?my_suffix}
Version: 3.901
Release: 0
Summary: Parallel Partitioning, Load Balancing and Data-Management Services
License: BSD-3-Clause
Group: Development/Libraries/Parallel
URL: https://sandialabs.github.io/Zoltan/
Source0: https://github.com/sandialabs/Zoltan/archive/refs/tags/v%{version}.tar.gz#/zoltan-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: gcc-c++
%if %{with mpi}
BuildRequires: %{mpi_flavor}-devel
BuildRequires: ptscotch-%{mpi_flavor}-devel
%endif
BuildRequires: zlib-devel
BuildRequires: xz
%description
Zoltan is a parallel Partitioning, Load Balancing and Data-Management Services.
This package contains the openmpi serial version of the zoltan library.
%package -n %{shlib}
Summary: Parallel Partitioning, Load Balancing and Data-Management Services
Group: System/Libraries
%description -n %{shlib}
Zoltan is a parallel Partitioning, Load Balancing and Data-Management Services.
This package contains the %{?mpi_flavor:%mpi_flavor}%{!?mpi_flavor:serial} version of the zoltan library.
%package devel
Summary: Development and headers files for %{name}
Group: Development/Libraries/C and C++
Requires: %{shlib} = %{version}
%if %{with mpi}
Requires: %{mpi_flavor}-devel
Requires: ptscotch-%{mpi_flavor}-devel
%endif
%description devel
This package contains the development and headers files for the %{?mpi_flavor:%mpi_flavor}%{!?mpi_flavor:serial}
version of Zoltan.
%prep
%setup -q -n Zoltan-%{version}
%build
# Inject ZHAVE_GZIP, see https://github.com/sandialabs/Zoltan/issues/3
export CFLAGS="$RPM_OPT_FLAGS -fPIC -Wno-error=return-type -DZHAVE_GZIP=1"
mkdir build
cd build
%if %{without mpi}
ln -s ../configure
%configure --includedir=%{my_incdir}/zoltan \
--without-mpi \
--enable-gzip
%make_build
mkdir shared
( cd shared; ar x ../siMPI/pyMPI/siMPI/libsimpi.a)
gcc -shared -Wl,-soname=libsimpi.so.3 -o libsimpi.so.%{version} shared/*.o
ln -s libsimpi.so.%{version} libsimpi.so.3
ln -s libsimpi.so.%{version} libsimpi.so
( rm -f /shared/*.o; cd shared; ar x ../src/libzoltan.a)
gcc -shared -Wl,-soname=libzoltan.so.3 -o libzoltan.so.%{version} shared/*.o -L. -lsimpi -lz -lm
ln -s libzoltan.so.%{version} libzoltan.so.3
ln -s libzoltan.so.%{version} libzoltan.so
%else
# build MPI lib
ln -s ../configure
export LD_LIBRARY_PATH=%{my_libdir}
%configure --prefix=%{_libdir}/mpi/gcc/%{mpi_flavor} \
--libdir=%{_libdir}/mpi/gcc/%{mpi_flavor}/%_lib \
--includedir=%{_libdir}/mpi/gcc/%{mpi_flavor}/include \
--with-mpi=%{_libdir}/mpi/gcc/%{mpi_flavor} \
--with-mpi-libs=" " \
--with-mpi-libdir=%{_libdir}/mpi/gcc/%{mpi_flavor}/%_lib \
--with-scotch \
--with-scotch-libdir=%{_libdir}/mpi/gcc/%{mpi_flavor}/%_lib \
--with-scotch-incdir=%{_libdir}/mpi/gcc/%{mpi_flavor}/include \
--enable-gzip
%make_build
mkdir shared
( cd shared; ar x ../src/libzoltan.a)
%{_libdir}/mpi/gcc/%{mpi_flavor}/bin/mpicc -shared -Wl,-soname=libzoltan.so.3 -o libzoltan.so.%{version} -lptscotch -lptscotcherr -lptscotcherrexit -lz -lm shared/*.o
ln -s libzoltan.so.%{version} libzoltan.so.3
ln -s libzoltan.so.%{version} libzoltan.so
%endif
%install
cd build
%make_install
cp -ap lib*.so* %{buildroot}%{my_libdir}
rm -f %{buildroot}%{my_bindir}/mpirun
rm -f %{buildroot}%{my_libdir}/*.a
%post -n %{shlib} -p /sbin/ldconfig
%postun -n %{shlib} -p /sbin/ldconfig
%files -n %{shlib}
%doc Known_Problems README
%{my_libdir}/*.so.*
%files devel
%{my_libdir}/*.so
%{my_incdir}/*
%changelog