File dolfin.spec of Package dolfin
#
# spec file for package dolfin
#
# 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}
%if 0%{?sle_version} >= 150200
%define DisOMPI1 ExclusiveArch: do_not_build
%endif
%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150200
%define DisOMPI3 ExclusiveArch: do_not_build
%endif
# Disable petsc/slepc for now, dolfin is incompatible with current petsc
%bcond_with petsc
# Disable parmetis for now, dolfin is incompatible with current parmetis
%bcond_with parmetis
# Trilinos cmake files are defect, disable for now
%bcond_with trilinos
# Bindings have been changed to pybind11, recheck
%bcond_with python
%define sname dolfin
%define lname libdolfin2019_1
%if "%flavor" == ""
%define package_name %{sname}
ExclusiveArch: do_not_build
%endif
%if "%flavor" == "documentation"
%define package_name %{sname}-documentation
%endif
%if "%flavor" == "serial"
%define my_prefix %{_prefix}
%endif
%if "%flavor" == "openmpi4"
%define mpi_family openmpi
%define mpi_ver 4
%endif
%if "%flavor" == "openmpi5"
%define mpi_family openmpi
%define mpi_ver 5
%endif
%define mpi_ext %{?mpi_ver}
%if 0%{?mpi_family:1}
%{bcond_without mpi}
%define my_prefix %{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ext}
%else
%{bcond_with mpi}
%endif
%if 0%{!?package_name:1}
%define package_name %{sname}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
%endif
%define lib_name %{lname}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Name: %{package_name}
Version: 2019.1.0.post0
%global main_version 2019.1.0
Release: 0
Summary: An open source CFD software
License: LGPL-3.0-or-later
Group: Development/Libraries/C and C++
Url: https://fenicsproject.org/
Source0: https://bitbucket.org/fenics-project/%{sname}/downloads/%{sname}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE
Patch0: 0001-Fix-linker-error-due-to-missing-lpthread.patch
# PATCH-FIX-OPENSUSE -- https://bitbucket.org/fenics-project/dolfin/issues/1115/compile-error-min_element-is-not-member-of
Patch1: 0001-Add-missing-algorithm-include-for-std-min_element-co.patch
# PATCH-FIX-OPENSUSE -- https://bitbucket.org/fenics-project/dolfin/issues/1116/boost-detail-endianhpp-no-longer-available
Patch2: 0001-Use-__BYTE_ORDER__-instead-of-removed-Boost-endian.h.patch
# PATCH-FIX-OPENSUSE
Patch3: 0001-Use-correct-type-for-index_to_position-value-tempora.patch
BuildRequires: fdupes
%if "%{flavor}" != "documentation"
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_chrono-devel
BuildRequires: libboost_headers-devel >= 1.56
BuildRequires: libboost_iostreams-devel
BuildRequires: libboost_program_options-devel
BuildRequires: libboost_regex-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_timer-devel
BuildRequires: cmake >= 3.5
BuildRequires: cppunit-devel
BuildRequires: eigen3-devel >= 3.2.90
BuildRequires: gcc-c++
BuildRequires: gmp-devel
BuildRequires: hdf5%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
BuildRequires: lapack-devel
BuildRequires: libxml2-devel
BuildRequires: hwloc-devel
BuildRequires: pkg-config
BuildRequires: python3-FFC = %{main_version}
BuildRequires: python3-FIAT = %{main_version}
BuildRequires: python3-setuptools
BuildRequires: python3-ufl = %{main_version}
%if %{with python}
BuildRequires: python3-pybind11
%endif
BuildRequires: suitesparse-devel
%if %{with trilinos}
BuildRequires: trilinos%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel >= 12.4.0
%endif
%if %{with petsc}
BuildRequires: petsc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel >= 3.7
BuildRequires: slepc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
%endif
%if %{with mpi}
BuildRequires: Modules
BuildRequires: %{mpi_family}%{?mpi_ext}-devel
BuildRequires: ptscotch-%{mpi_family}%{?mpi_ext}-devel
%if %{with parmetis}
BuildRequires: ptscotch-parmetis-%{mpi_family}%{?mpi_ext}-devel >= 4.0.2
%endif
#!BuildIgnore: metis-devel
Requires: %{mpi_family}%{?mpi_ext}
%endif
%else
BuildRequires: doxygen
BuildRequires: graphviz
%endif
%description
dolphin is an open source CFD software (FLOW solvER, literally)
written in C++. It is mainly devoted to the resolution of the
turbulent unsteady incompressible Navier-Stokes equations.
%package devel
Summary: Development and header files for %{name}
Group: Development/Libraries/C and C++
Provides: pkgconfig(DOLFIN)
Provides: %{name}-devel = %{main_version}
Requires: eigen3-devel
Requires: lapack-devel
Requires: libboost_headers-devel
Requires: %{lib_name} = %{version}
Requires: libxml2-devel
%if %{with mpi}
Requires: %{mpi_family}%{?mpi_ext}-devel
Requires: pastix%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
Requires: ptscotch-%{mpi_family}%{?mpi_ext}-devel
%endif
%if %{with petsc}
Requires: petsc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
Requires: slepc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
%endif
Requires: suitesparse-devel
%description devel
The %{name}-devel package contains header files for developing
applications that use %{name}.
%package -n %{lib_name}
Summary: A package for solving large sparse systems of linear equations
Group: System/Libraries
%description -n %{lib_name}
dolphin is an open source CFD software (FLOW solvER, literally)
written in C++. It is mainly devoted to the resolution of the
turbulent unsteady incompressible Navier-Stokes equations.
%package -n python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Summary: A package for solving large sparse systems of linear equations
Group: Development/Languages/Python
Provides: python3-dolfin_utils = %{main_version}
Obsoletes: python3-dolfin_utils < %{main_version}
Provides: python3-dolfin_utils = %{version}
%description -n python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
dolphin is an open source CFD software (FLOW solvER, literally)
written in C++. It is mainly devoted to the resolution of the
turbulent unsteady incompressible Navier-Stokes equations.
%package -n python3-dolfin%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Summary: A package for solving large sparse systems of linear equations
Group: Development/Languages/Python
Requires: python3-FFC = %{main_version}
Requires: python3-FIAT = %{main_version}
Requires: python3-sympy
Requires: python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}} = %{version}
%{?with_mpi:Requires: python3-mpi4py}
Requires: python3-ply
Requires: python3-ufl = %{main_version}
Provides: python3-dolfin = %{main_version}
Obsoletes: python3-dolfin < %{main_version}
Provides: python3-dolfin = %{version}
%description -n python3-dolfin%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
dolphin is an open source CFD software (FLOW solvER, literally)
written in C++. It is mainly devoted to the resolution of the
turbulent unsteady incompressible Navier-Stokes equations.
This package contains the python-dolfin module.
%package doc
Summary: Documentation files for %{name}
Group: Documentation/HTML
BuildArch: noarch
%description doc
The %{name}-doc package contains documentation files for developing
applications that use %{name}.
%prep
%autosetup -p1 -n %{sname}-%{version}
%build
%if "%{flavor}" != "documentation"
%if %{with petsc}
%define petsc_ver %(rpm -q petsc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel --queryformat %%{VERSION})
# PETSC_DIR/SLEPC_DIR have to be set in the environment
export PETSC_DIR=%{my_prefix}/%_lib/petsc/%{petsc_ver}/linux-gnu-c-opt
export SLEPC_DIR=%{my_prefix}/%_lib/slepc/%{petsc_ver}/linux-gnu-c-opt
%endif
export PKG_CONFIG_PATH=%{my_prefix}/%_lib/pkgconfig:$PKG_CONFIG_PATH
%define hdf5bin %{?with_mpi:h5p}%{!?with_mpi:h5}
# Force usage of HDF5 1.10 API
export CXXFLAGS="-DH5_USE_110_API %optflags"
%cmake -DCMAKE_INSTALL_PREFIX=%{my_prefix} \
-DCMAKE_EXE_LINKER_FLAGS="-L%{my_prefix}/%_lib" \
-DDOLFIN_LIB_DIR:PATH="%_lib" \
-DDOLFIN_PKGCONFIG_DIR:PATH="%_lib/pkgconfig" \
-DDOLFIN_ENABLE_MPI:BOOL=%{?with_mpi:ON}%{!?with_mpi:OFF} \
-DDOLFIN_ENABLE_PARMETIS:BOOL=%{?with_parmetis:ON}%{!?with_parmetis:OFF} \
-DDOLFIN_ENABLE_SCOTCH:BOOL=ON \
-DDOLFIN_ENABLE_TRILINOS:BOOL=%{?with_trilinos:ON}%{!?with_trilinos:OFF} \
-DHDF5_C_COMPILER_EXECUTABLE=%{my_prefix}/bin/%{hdf5bin}cc \
-DHDF5_CXX_COMPILER_EXECUTABLE=%{my_prefix}/bin/%{hdf5bin}cc \
-DHDF5_Fortran_COMPILER_EXECUTABLE=%{my_prefix}/bin/%{hdf5bin}fc \
-DHDF5_DIFF_EXECUTABLE=%{my_prefix}/bin/h5diff \
-DSCOTCH_LIBRARY=%{my_prefix}/%_lib/libscotch.so \
-DSCOTCH_INCLUDE_DIRS=%{my_prefix}/include \
-DPTSCOTCHERR_LIBRARY=%{my_prefix}/%_lib/libptscotcherr.so \
-DPTSCOTCH_LIBRARY=%{my_prefix}/%_lib/libptscotch.so \
-DDOLFIN_SKIP_BUILD_TESTS:BOOL=ON \
..
%cmake_build
%else
(cd doc; doxygen -u && doxygen)
%endif
%install
%if "%{flavor}" != "documentation"
%cmake_install
%fdupes -s %{buildroot}%{my_prefix}/share/%{sname}
sed -i -e '1 s#/usr/bin/env python#/usr/bin/python#' %{buildroot}%{my_prefix}/bin/*
%else
mkdir -p %{buildroot}%{_docdir}/%{sname}-devel
cp -ar doc/html %{buildroot}%{_docdir}/%{sname}-devel/
%fdupes -s %{buildroot}%{_docdir}/%{sname}-devel
%endif
%check
%if %{with python} && "%{flavor}" != "documentation"
export PYTHONPATH=%{buildroot}%{my_prefix}/lib/python%{py3_ver}/site-packages:%{buildroot}%{my_prefix}/%_lib/python%{py3_ver}/site-packages
export LD_LIBRARY_PATH=%{buildroot}%{my_prefix}/%{_lib}:%{my_prefix}/%{_lib}
python3 -c "import dolfin"
%endif
%post -n %{lib_name} -p /sbin/ldconfig
%postun -n %{lib_name} -p /sbin/ldconfig
%if "%{flavor}" != "documentation"
%files
%license COPYING COPYING.LESSER
%doc AUTHORS ChangeLog.rst README.rst
%{my_prefix}/bin/*
%if %{with python}
%files -n python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
%if "%{my_prefix}" != "%{_prefix}"
%if "%{_lib}" != "lib"
%dir %{my_prefix}/lib
%endif
%dir %{my_prefix}/lib/python%{py3_ver}
%dir %{my_prefix}/lib/python%{py3_ver}/site-packages
%endif
%{my_prefix}/lib/python%{py3_ver}/site-packages/dolfin_utils
%files -n python3-dolfin%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
%dir %{my_prefix}/%_lib/python%{py3_ver}
%dir %{my_prefix}/%_lib/python%{py3_ver}/site-packages
%{my_prefix}/%_lib/python%{py3_ver}/site-packages/dolfin
%{my_prefix}/%_lib/python%{py3_ver}/site-packages/fenics
%endif
%files -n %{lib_name}
%{my_prefix}/%_lib/*.so.*
%files devel
%if "%{my_prefix}" != "%{_prefix}"
%dir %{my_prefix}/%_lib/pkgconfig
%endif
%{my_prefix}/include/*
%{my_prefix}/%_lib/*.so
%{my_prefix}/share/%{sname}
%{my_prefix}/%_lib/pkgconfig/*.pc
%else
%files doc
%{_docdir}/%{sname}-devel
%endif
%changelog