File dolfin.spec of Package dolfin

#
# spec file for package dolfin
#
# Copyright (c) 2019 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 dolfin
%define lname libdolfin2016_2

%if "%flavor" == ""
%define package_name %{pname}
ExclusiveArch:  do_not_build
%endif

%if "%flavor" == "serial"
%define my_prefix %{_prefix}
%endif 

%if "%flavor" == "openmpi"
%define my_prefix %{_libdir}/mpi/gcc/openmpi
%define mpi_family openmpi
%define mpi_vers 1
%endif

%if "%flavor" == "openmpi2"
%define my_prefix %{_libdir}/mpi/gcc/openmpi2
%define mpi_family openmpi
%define mpi_vers 2
%endif

# For compatibility package names
%if "%{mpi_family}" != "openmpi"  || "%{mpi_ver}" != "1"
%define mpi_ext %{?mpi_ver}
%endif

%if 0%{!?package_name:1}
%define package_name  %{pname}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
%endif
%define lib_name  %{lname}%{?with_mpi:-%{mpi_family}%{?mpi_ext}}

%if 0%{?mpi_family:1}
%{bcond_without mpi}
%else
%{bcond_with mpi}
%endif

Name:           %{package_name}
Version:        2016.2.0
Release:        0
Summary:        An open source CFD software
License:        LGPL-3.0+
Group:          Development/Libraries/C and C++
Url:            https://fenicsproject.org/
Source0:        http://bitbucket.org/fenics-project/%{pname}/downloads/%{pname}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE dolfin-1.1.0-suitesparse.patch
Patch0:         dolfin-1.1.0-suitesparse.patch
Patch1:         python3-fixes.patch
# PATCH-FIX-OPENSUSE cmake-check-boostversion-163.patch added from dolfin upstream to find boost version 16.3 in tumbleweed/factory
Patch2:         cmake-check-boostversion-163.patch

BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_headers-devel
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
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gmp-devel
BuildRequires:  java-devel
BuildRequires:  lapack-devel
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  freetype2-devel
BuildRequires:  libX11-devel
BuildRequires:  libXt-devel
BuildRequires:  libxml2-devel
BuildRequires:  hwloc-devel
BuildRequires:  pkg-config
BuildRequires:  trlan-devel
BuildRequires:  python3-FFC = %{version}
BuildRequires:  python3-FIAT = %{version}
BuildRequires:  python3-sympy
BuildRequires:  python3-Sphinx
BuildRequires:  python3-devel
BuildRequires:  python3-instant = %{version}
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-ply
BuildRequires:  python3-ufl = %{version}
BuildRequires:  suitesparse-devel
BuildRequires:  swig >= 3.0
BuildRequires:  ufc-devel
BuildRequires:  slepc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
%if %{without mpi}
BuildRequires:  arpack-devel
BuildRequires:  scotch-devel
%else
BuildRequires:  Modules
BuildRequires:  %{mpi_family}%{?mpi_ext}-devel
BuildRequires:  parpack-%{mpi_family}%{?mpi_ext}-devel
BuildRequires:  pastix%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
BuildRequires:  ptscotch-%{mpi_family}%{?mpi_ext}-devel
BuildRequires:  ptscotch-parmetis-%{mpi_family}%{?mpi_ext}-devel
#!BuildIgnore:  metis-devel
BuildRequires:  python3-mpi4py
Requires:       %{mpi_family}%{?mpi_ext}
%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)
Requires:       boost-devel
Requires:       cmake
Requires:       cppunit-devel
Requires:       eigen3-devel
Requires:       lapack-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
Requires:       petsc%{?with_mpi:-%{mpi_family}%{?mpi_ext}}-devel
Requires:       suitesparse-devel
Requires:       ufc-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 = %{version}
Obsoletes:      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 = %{version}
Requires:       python3-FIAT = %{version}
Requires:       python3-sympy
Requires:       python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
Requires:       python3-instant = %{version}
%{?with_mpi:Requires:       python3-mpi4py}
Requires:       python3-ply
Requires:       python3-ufl = %{version}
Provides:       python3-dolfin = %{version}
Obsoletes:      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
%setup -q -n %{pname}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1

%build
export CXXFLAGS="%{optflags} -fpermissive"
%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
export PKG_CONFIG_PATH=%{my_prefix}/%_lib/pkgconfig:$PKG_CONFIG_PATH
%define hdf5bin %{?with_mpi:h5p}%{!?with_mpi:h5}

# TODO: use %%cmake macro
mkdir build; cd build
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_USE_PYTHON3:BOOL=ON \
       -DDOLFIN_ENABLE_MPI:BOOL=%{?with_mpi:ON}%{!?with_mpi:OFF} \
       -DDOLFIN_ENABLE_PARMETIS:BOOL=OFF \
       -DDOLFIN_ENABLE_PASTIX:BOOL=ON \
       -DDOLFIN_ENABLE_SCOTCH:BOOL=ON \
       -DDOLFIN_ENABLE_TRILINOS:BOOL=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 \
       ..
make %{_smp_mflags} V=1 VERBOSE=1


%install
cd build
make install DESTDIR=%{buildroot}
# remove RPM_BUILD_ROOT in some .pyc files
pushd %{buildroot}%{my_prefix}/lib/python%{py3_ver}/site-packages/dolfin_utils
%py3_compile .
popd
pushd %{buildroot}%{my_prefix}/%_lib/python%{py3_ver}/site-packages/dolfin
%py3_compile .
popd

%fdupes -s %{buildroot}%{my_prefix}/share/%{name}

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}:%{_libdir}/vtk
python3 -c "import dolfin"
pushd doc-old
python3 generate_api_doc.py %{_builddir}/%{name}-%{version} api %{version} 2>&1
popd
make doc
mkdir -p %{buildroot}%{_docdir}/%{name}
mkdir -p %{buildroot}%{_docdir}/%{name}/doc-old/sphinx-cpp
cp -ar doc-old/sphinx-cpp/build/html %{buildroot}%{_docdir}/%{name}/doc-old/sphinx-cpp/html
mkdir -p %{buildroot}%{_docdir}/%{name}/doc-old/sphinx-python
cp -ar doc-old/sphinx-python/build/html %{buildroot}%{_docdir}/%{name}/doc-old/sphinx-cpp/html
cd ..
make -C doc html #latexpdf
mkdir -p %{buildroot}%{_docdir}/%{name}/doc
cp -ar doc/build/html %{buildroot}%{_docdir}/%{name}/doc/html
#cp -ar doc/build/latex/*.pdf %{buildroot}%{_docdir}/%{name}/doc/

%fdupes -s %{buildroot}%{_datadir}/%{name}
%fdupes -s %{buildroot}%{_docdir}/%{name}

%post -n %{lib_name} -p /sbin/ldconfig

%postun -n %{lib_name} -p /sbin/ldconfig

%files
%{my_prefix}/bin/*
%{my_prefix}/share/man/man1/*

%files -n python3-dolfin_utils%{?with_mpi:-%{mpi_family}%{?mpi_ext}}
%ifarch ia64 x86_64 ppc64
%dir %{my_prefix}/lib
%endif
%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_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

%files -n %{lib_name}
%license COPYING COPYING.LESSER
%doc AUTHORS ChangeLog.rst README.rst
%{my_prefix}/%_lib/*.so.*

%files devel
%ifarch ia64 x86_64 ppc64
%dir %{my_prefix}/lib
%endif
%dir %{my_prefix}/%_lib/pkgconfig
%{my_prefix}/include/*
%{my_prefix}/%_lib/*.so
%{my_prefix}/share/%{name}
%{my_prefix}/%_lib/pkgconfig/*.pc

%files doc
%{_docdir}/%{name}

%changelog
openSUSE Build Service is sponsored by