File getfem.spec of Package getfem

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


%ifarch x86_64
%bcond_without octave
%else
# octave part of test suite segfaults
%bcond_with    octave
%endif

%define libname libgetfem5
Name:           getfem
Version:        5.4.3
Release:        0
Summary:        A generic C++ finite element library
License:        LGPL-3.0-or-later
Group:          Development/Libraries/C and C++
URL:            https://getfem.org
Source0:        https://download-mirror.savannah.gnu.org/releases/getfem/stable/getfem-%{version}.tar.gz
# PATCH-FIX-UPSTREAM getfem-octave-installation-destdir-support.patch badshah400@gmail.com -- Allow octave to install to DESTDIR, otherwise we end up with permission denied issues when building RPMs
Patch1:         getfem-octave-installation-destdir-support.patch
# PATCH-FIX-UPSTREAM getfem-toolbox-without-matlab.patch badshah400@gmail.com -- Do not install getfem toolbox when matlab is not available
Patch2:         getfem-toolbox-without-matlab.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  blas-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  lapack-devel
BuildRequires:  libtool
BuildRequires:  metis-devel
BuildRequires:  mumps-devel
BuildRequires:  muparser-devel
%if %{with octave}
BuildRequires:  octave-devel
%endif
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-scipy
BuildRequires:  python3-setuptools
BuildRequires:  qhull_r-devel
BuildRequires:  superlu-devel

%description
GetFEM++ is basically a generic C++ finite element library which aims
to offer the widest range of finite element methods and elementary
matrix computations for the approximation of linear or non-linear
problems, possibly in hybrid form and possibly coupled.

%package -n %{libname}
Summary:        A generic C++ finite element library
Group:          System/Libraries

%description -n %{libname}
GetFEM++ is basically a generic C++ finite element library which aims
to offer the widest range of finite element methods and elementary
matrix computations for the approximation of linear or non-linear
problems, possibly in hybrid form and possibly coupled.

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

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package -n python3-%{name}
Summary:        A generic C++ finite element library
Group:          Development/Libraries/Python
Requires:       python3-numpy
Requires:       python3-scipy

%description -n python3-%{name}
GetFEM++ is basically a generic C++ finite element library which aims
to offer the widest range of finite element methods and elementary
matrix computations for the approximation of linear or non-linear
problems, possibly in hybrid form and possibly coupled.

%package -n octave-%{name}
Summary:        Octave bindings for getfem - a finite element library
Requires:       octave-cli

%description -n octave-%{name}
GetFEM++ is basically a generic C++ finite element library which aims
to offer the widest range of finite element methods and elementary
matrix computations for the approximation of linear or non-linear
problems, possibly in hybrid form and possibly coupled.

This package provides octave bindings for GetFEM++.

%prep
%autosetup -p1
sed -i 's|#!/usr/bin/env python3|#!%__python3|g' bin/extract_doc
# Fix libtool version-info screwup -- https://savannah.nongnu.org/bugs/index.php?66621
sed -i 's/"-version-info .*"/"-version-info $((${MAJOR_VERSION} + ${MINOR_VERSION})):${PATCH_VERSION}:${MINOR_VERSION}"/' \
    configure.ac

%build
autoreconf -fiv
grep version-info configure
# Note: We need to build the static lib to enable and build octave bindings, but we do not need to install it
%configure --enable-shared \
           --with-pic \
           --enable-superlu \
           --enable-python3 \
           --enable-qhull \
           --with-mumps-include-dir=%{_includedir}/mumps \
           --enable-matlab=no \
           --enable-octave=%{?with_octave:yes}%{!?with_octave:no} \
           --with-octave-toolbox-dir=%{octlib_dir}/%{name}
%make_build
# Build tests without running them
%make_build check TESTS=

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print

# Remove static lib
find %{buildroot}%{_libdir}/ -name *.a -delete

%fdupes %{buildroot}%{python3_sitelib}
%if "%{python3_sitearch}" != "%{python3_sitelib}"
%fdupes %{buildroot}%{python3_sitearch}
%endif

%check
%make_build check

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

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

%files devel
%license COPYING GNU_LGPL_V3 GNU_GCC_RUNTIME_EXCEPTION
%doc AUTHORS NEWS README
%{_bindir}/%{name}-config
%{_includedir}/*
%{_libdir}/*.so

%files -n python3-%{name}
%{python3_sitelib}/%{name}
%if "%{python3_sitearch}" != "%{python3_sitelib}"
%{python3_sitearch}/%{name}
%endif

%if %{with octave}
%files -n octave-%{name}
%license COPYING GNU_LGPL_V3 GNU_GCC_RUNTIME_EXCEPTION
%{octlib_dir}/%{name}/
%endif

%changelog
openSUSE Build Service is sponsored by