File libsc.spec of Package libsc

#
# spec file for package libsc
#
# 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/
#


%define SONUM 2_8_5
Name:           libsc
Version:        2.8.5
Release:        0
Summary:        Support library for parallel scientific applications
License:        LGPL-2.1-or-later
Group:          System/Libraries
URL:            https://www.p4est.org/
Source:         https://github.com/cburstedde/libsc/releases/download/v%{version}/libsc-%{version}.tar.gz#/libsc-%{version}.tar.gz
# PATCH-FIX-UPSTREAM
Patch0:         https://github.com/cburstedde/libsc/pull/120/commits/fad3a1ad9489ac482eb95b32fb48e48d94262cd0.patch#/fix_zlib_linking.patch
# PATCH-FIX-UPSTREAM
Patch1:         https://github.com/cburstedde/libsc/commit/bd2529069b8f74053f6d21cf8aed8285c651e1d2.patch#/fix_getopt_install.patch
# PATCH-FIX-UPSTREAM
Patch2:         https://github.com/tim-griesbach/libsc/commit/00ac61cd897f5bec353b98e83d0af7f6564d2730.patch#/fix_getopt_install2.patch
BuildRequires:  cmake >= 3.13
BuildRequires:  gcc
BuildRequires:  pkgconfig(zlib)

%description 
The SC Library provides support for parallel scientific applications.

%package  -n libsc%{SONUM}
Summary:        Support library for parallel scientific applications

%description -n libsc%{SONUM}
The SC Library provides support for parallel scientific applications.

%package devel
Summary:        Development files for libsc
Group:          Development/Libraries/C and C++
Requires:       libsc%{SONUM} = %{version}

%description devel
Header files and cmake config files for libsc.

%prep
%autosetup -p1
# https://github.com/cburstedde/libsc/issues/106 + 122
sed -i -e 's@DESTINATION lib@DESTINATION %{_lib}@' CMakeLists.txt cmake/*.cmake
# Fix install path of CMake configs
sed -i -e 's@DESTINATION cmake@DESTINATION %{_lib}/cmake/SC@' CMakeLists.txt cmake/install.cmake

%build
# Awkward naming of "zlib" option, "OFF" ^= use system zlib
%cmake \
  -Dzlib:BOOL=OFF \
  %{nil}
%cmake_build

%install
%cmake_install

# Remove duplicate COPYING
rm -Rf %{buildroot}/%{_datadir}/docs
# Remove irrelevant FindSC.cmake
rm %{buildroot}/%{_libdir}/cmake/SC/FindSC.cmake
# Remove broken pkgconfig file
rm %{buildroot}%{_libdir}/pkgconfig/*.pc
# Remove internal headers
rm -Rf %{buildroot}/%{_includedir}/sc_builtin/
rm -Rf %{buildroot}/%{_includedir}/sc_puff.h

%post -n libsc%{SONUM} -p /sbin/ldconfig
%postun -n libsc%{SONUM} -p /sbin/ldconfig

%files -n libsc%{SONUM}
%license COPYING
%{_libdir}/libsc.so.*

%files devel
%{_includedir}/sc*h
%{_libdir}/cmake/SC
%{_libdir}/libsc.so

%changelog

openSUSE Build Service is sponsored by