Blob Blame History Raw
%{!?tcl_version: %global tcl_version %(echo 'puts $tcl_version' | tclsh)}
%{!?tcl_sitearch: %global tcl_sitearch %{_libdir}/tcl%{tcl_version}}

# Don't abort on compilation errors of the example python snippets
%global _python_bytecompile_errors_terminate_build 0

%if 0%{?el6}
	%ifarch ppc64
		%global build_mpich 0
	%else
		%global build_mpich 1
	%endif
%else
	%global build_mpich 1
%endif

# Upstream stopped releasing source tarballs, generating directly via snapshot at commit (see Source0)....
# Get commits for version at https://sourceforge.net/p/netgen-mesher/git/ci/master/tree/
%global commit  94fd57154f556450a04808b244eb8c83e7a95fb6
%global shortcommit %(c=%{commit}; echo ${c:0:7})

%global togl_ver 2.1

Name:           netgen-mesher
Version:        6.2
Release:        0.5.git%{shortcommit}%{?dist}
Summary:        Automatic mesh generation tool

License:        LGPLv2
URL:            http://sourceforge.net/projects/netgen-mesher/
Source0:        https://sourceforge.net/code-snapshots/git/n/ne/netgen-mesher/git.git/netgen-mesher-git-%{commit}.zip
Source1:        netgen-mesher.png
Source2:        netgen-mesher.desktop

# Don't try to install pybind files
Patch1:         0001-Don-t-install-pybind-files.patch
# Rename shared libaries (the original names are often way too generic), add library version
Patch2:         0002-Rename-libraries-add-library-versions.patch
# Set a default NETGENDIR appropriate for the Fedora packaging
Patch3:         0003-Set-default-NETGENDIR.patch
# Make some includes relative (needed for when headers are in -private subpackage)
Patch4:         0004-Make-some-includes-relative.patch
# Make bin, lib and python sitearch installation directories configurable
Patch5:         0005-Make-bin-lib-and-pysitearch-dirs-configurable.patch
# Unbundle togl (see also %%prep)
Patch6:         0006-Unbundle-togl.patch
# SuperBuild.cmake fails to propagate USE_JPEG
Patch7:         0007-Add-missing-USE_JPEG-propagation.patch
# Add missing -ldl
Patch8:         0008-Add-missing-ldl.patch
# Only include immintrin.h on x86 arches
Patch9:         0009-immintrin.patch

# TODO Re-evaluate: Some fixes to the code (taken from salome netgen plugin)
# Patch10:        netgen-5.3.0_fixes.patch
# Rename binary in cmake so that exported modules work correctly
Patch10:        0010-rename-netgen-binary.patch


BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  tk-devel
BuildRequires:  OCE-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  tcl-togl-devel = %{togl_ver}
BuildRequires:  metis-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  libXmu-devel
BuildRequires:  desktop-file-utils
BuildRequires:  dos2unix
%if %{build_mpich}
BuildRequires:  mpich-devel
%endif
BuildRequires:  openmpi-devel
BuildRequires:  python3-devel
BuildRequires:  pybind11-devel


Requires:       %{name}-common = %{version}-%{release}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description
NETGEN is an automatic 3d tetrahedral mesh generator. It accepts input from
constructive solid geometry (CSG) or boundary representation (BRep) from STL
file format. The connection to a geometry kernel allows the handling of IGES
and STEP files. NETGEN contains modules for mesh optimization and hierarchical
mesh refinement.

%package        common
Summary:        Common files for netgen
Requires:       hicolor-icon-theme
Requires:       tix
BuildArch:      noarch

%description    common
Common files for netgen.

%package        libs
Summary:        Netgen libraries

%description    libs
Netgen libraries.

%package        devel
Summary:        Development files for netgen
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
Development files for netgen.

%package        devel-private
Summary:        Private headers of netgen
Requires:       %{name}-devel%{?_isa} = %{version}-%{release}

%description    devel-private
Private headers of netgen, needed to build certain netgen based software
packages.

%package -n     python3-%{name}
Summary:        Python3 interface for netgen
%{?python_provide:%python_provide python3-netgen}
Requires:       %{name}-openmpi-libs%{?_isa} = %{version}-%{release}

%description -n python3-%{name}
Python3 interface for netgen.

###############################################################################

%package        openmpi
Summary:        Netgen compiled against openmpi
# Require explicitly for dir ownership and to guarantee the pickup of the right runtime
Requires:       %{name}-common = %{version}-%{release}
Requires:       %{name}-openmpi-libs%{?_isa} = %{version}-%{release}

%description    openmpi
Netgen compiled against openmpi.

%package        openmpi-libs
Summary:        Netgen libraries compiled against openmpi

%description    openmpi-libs
Netgen libraries compiled against openmpi.

%package        openmpi-devel
Summary:        Development files for Netgen compiled against openmpi
# Require explicitly for dir ownership
Requires:       openmpi-devel
Requires:       %{name}-openmpi%{?_isa} = %{version}-%{release}

%description    openmpi-devel
Development files for Netgen compiled against openmpi.

%package -n     python3-%{name}-openmpi
Summary:        Python3 interface for netgen compiled against openmpi
%{?python_provide:%python_provide python3-netgen-openmpi}
Requires:       %{name}-openmpi-libs%{?_isa} = %{version}-%{release}

%description -n python3-%{name}-openmpi
Python3 interface for netgen compiled against openmpi.

###############################################################################

%if %{build_mpich}
%package        mpich
Summary:        Netgen compiled against mpich
# Require explicitly for dir ownership and to guarantee the pickup of the right runtime
Requires:       %{name}-common = %{version}-%{release}
Requires:       %{name}-mpich-libs%{?_isa} = %{version}-%{release}

%description    mpich
Netgen compiled against mpich.

%package        mpich-libs
Summary:        Netgen libraries compiled against mpich

%description    mpich-libs
Netgen libraries compiled against mpich.

%package        mpich-devel
Summary:        Development files for Netgen compiled against mpich
# Require explicitly for dir ownership
Requires:       mpich-devel
Requires:       %{name}-mpich%{?_isa} = %{version}-%{release}

%description    mpich-devel
Development files for Netgen compiled against mpich.

%package -n     python3-%{name}-mpich
Summary:        Python3 interface for netgen compiled against mpich
%{?python_provide:%python_provide python3-netgen-mpich}
Requires:       %{name}-openmpi-libs%{?_isa} = %{version}-%{release}

%description -n python3-%{name}-mpich
Python3 interface for netgen compiled against mpich.

%endif

###############################################################################

%prep
%autosetup -p1 -n netgen-mesher-git-%{commit}

# Remove bundled togl
rm -rf ng/Togl-1.7
rm -rf ng/Togl2.1
rm -f ng/togl_1_7.h


%build
### serial version ###
mkdir serial
(cd serial
%cmake -DINSTALL_DIR=%{_prefix} \
  -DUSE_NATIVE_ARCH=OFF \
  -DINCDIR=%{_includedir}/%{name} \
  -DUSE_JPEG=1 -DUSE_OCC=1 \
  -DPYBIND_INCLUDE_DIR=%{_includedir} \
  -DLIBTOGL=%{_libdir}/libTogl%{togl_ver}.so \
  -DOpenGL_GL_PREFERENCE=GLVND \
  ..
%make_build
)

### openmpi version ###
%{_openmpi_load}
export CXX=mpicxx
mkdir openmpi
(cd openmpi
%cmake -DINSTALL_DIR=%{_prefix} \
  -DUSE_NATIVE_ARCH=OFF \
  -DINCDIR=%{_includedir}/openmpi/%{name} \
  -DBINDIR=%{_libdir}/openmpi/bin/ \
  -DLIBDIR=%{_libdir}/openmpi/lib/ \
  -DPYTHON_PACKAGES_INSTALL_DIR=%{_libdir}/openmpi/python%{python3_version}/site-packages \
  -DUSE_JPEG=1 -DUSE_OCC=1 -DUSE_MPI=1 \
  -DPYBIND_INCLUDE_DIR=%{_includedir} \
  -DLIBTOGL=%{_libdir}/libTogl%{togl_ver}.so ..
%make_build
)
%{_openmpi_unload}

### mpich version ###
%if %{build_mpich}
%{_mpich_load}
export CXX=mpicxx
mkdir mpich
(cd mpich
%cmake -DINSTALL_DIR=%{_prefix} \
  -DUSE_NATIVE_ARCH=OFF \
  -DINCDIR=%{_includedir}/mpich/%{name} \
  -DBINDIR=%{_libdir}/mpich/bin/ \
  -DLIBDIR=%{_libdir}/mpich/lib/ \
  -DPYTHON_PACKAGES_INSTALL_DIR=%{_libdir}/mpich/python%{python3_version}/site-packages \
  -DUSE_JPEG=1 -DUSE_OCC=1 -DUSE_MPI=1 \
  -DPYBIND_INCLUDE_DIR=%{_includedir} \
  -DLIBTOGL=%{_libdir}/libTogl%{togl_ver}.so ..
%make_build
)
%{_mpich_unload}
%endif


%install
%define writepkgconfig() \
install -d -m 0755 %{buildroot}/$MPI_LIB/pkgconfig; \
cat > %{buildroot}/$MPI_LIB/pkgconfig/%{name}.pc << EOF\
prefix=%{_prefix}\
exec_prefix=${prefix}\
libdir=$MPI_LIB\
includedir=$MPI_INCLUDE/%{name}\
\
Name: %{name}\
Description:  %{summary}\
Version: %{version}\
Libs: -L\\\${libdir} -lnglib\
Libs.private: -lngcgs -lnggeom2d -lngmesh -lngocc -lngstl\
Cflags: -I\\\${includedir}\
EOF\
%{nil}

### openmpi version ###
%{_openmpi_load}
%make_install -C openmpi
%writepkgconfig
# Avoid conflicts with netgen, remove data files (are correctly installed below)
rm -f %{buildroot}/$MPI_BIN/*.tcl
rm -f %{buildroot}/$MPI_BIN/*.ocf
%{_openmpi_unload}

### mpich version ###
%if %{build_mpich}
%{_mpich_load}
%make_install -C mpich
%writepkgconfig
# Avoid conflicts with netgen, remove data files (are correctly installed below)
rm -f %{buildroot}/$MPI_BIN/*.tcl
rm -f %{buildroot}/$MPI_BIN/*.ocf
%{_mpich_unload}
%endif

### serial version ###
%make_install -C serial
export MPI_LIB=%{_libdir}
export MPI_INCLUDE=%{_includedir}
%writepkgconfig
# move data files to correct place
mv %{buildroot}%{_bindir}/*.tcl %{buildroot}%{_bindir}/*.ocf %{buildroot}%{_datadir}/%{name}
chmod -x %{buildroot}%{_datadir}/%{name}/*.tcl %{buildroot}%{_datadir}/%{name}/*.ocf

# Install icon and desktop file
install -Dpm 0644 %SOURCE1 %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
desktop-file-install --dir %{buildroot}/%{_datadir}/applications/ %SOURCE2

# Delete the doc folder, the files are in %%doc below
rm -rf %{buildroot}/%{_prefix}/doc

# Install private headers
(
cd libsrc
find \( -name *.hpp -or -name *.hxx -or -name *.h -or -name *.ixx -or -name *.jxx \) -exec install -Dpm 0644 {} %{buildroot}%{_includedir}/%{name}/private/{} \;
)

# Install the nglib.h header
install -Dpm 0644 nglib/nglib.h %{buildroot}%{_includedir}/%{name}/nglib.h


%post common
update-desktop-database &> /dev/null || :
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun common
update-desktop-database &> /dev/null || :
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans common
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :


%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%post openmpi-libs -p /sbin/ldconfig

%postun openmpi-libs -p /sbin/ldconfig


%if %{build_mpich}
%post mpich-libs -p /sbin/ldconfig

%postun mpich-libs -p /sbin/ldconfig
%endif


%files common
%doc AUTHORS doc/ng4.pdf
%license LICENSE
%{_datadir}/%{name}/
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop

%files
%{_bindir}/*

%files libs
%{_libdir}/*.so.*

%files devel
%{_includedir}/%{name}
%exclude %{_includedir}/%{name}/private
%{_libdir}/*.so
%exclude %{_libdir}/libngpy.so
%{_libdir}/pkgconfig/%{name}.pc
%{_datadir}/cmake/*.cmake

%files devel-private
%{_includedir}/%{name}/private

%files -n python3-%{name}
%{python3_sitearch}/netgen/
%{_libdir}/libngpy.so

%files openmpi
%{_libdir}/openmpi/bin/*

%files openmpi-libs
%{_libdir}/openmpi/lib/*.so.*

%files openmpi-devel
%{_includedir}/openmpi*/%{name}
%{_libdir}/openmpi/lib/*.so
%exclude %{_libdir}/openmpi/lib/libngpy.so
%{_libdir}/openmpi/lib/pkgconfig/%{name}.pc

%files -n python3-%{name}-openmpi
%{_libdir}/openmpi/python%{python3_version}/site-packages/netgen/
%{_libdir}/openmpi/lib/libngpy.so

%if %{build_mpich}
%files mpich
%{_libdir}/mpich/bin/*

%files mpich-libs
%{_libdir}/mpich/lib/*.so.*

%files mpich-devel
%{_includedir}/mpich*/%{name}
%{_libdir}/mpich/lib/*.so
%exclude %{_libdir}/mpich/lib/libngpy.so
%{_libdir}/mpich/lib/pkgconfig/%{name}.pc

%files -n python3-%{name}-mpich
%{_libdir}/mpich/python%{python3_version}/site-packages/netgen/
%{_libdir}/mpich/lib/libngpy.so
%endif


%changelog
* Wed May 02 2018 Sandro Mani <manisandro@gmail.com> - 6.2-0.5.git94fd571
- Rename netgen binary at CMake level to prevent breaking cmake config module (#1573330)

* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 6.2-0.4.git94fd571
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 6.2-0.3.git94fd571
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Thu May 11 2017 Sandro Mani <manisandro@gmail.com> - 6.2.0-0.2.git94fd571
- Install the nglib.h header

* Thu May 11 2017 Sandro Mani <manisandro@gmail.com> - 6.2.0-0.1.git94fd571
- Update to 6.2.0 snapshot

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.1-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Oct 21 2016 Orion Poplawski <orion@cora.nwra.com> - 5.3.1-12
- Rebuild for openmpi 2.0

* Thu Apr  7 2016 Richard Shaw <hobbes1069@gmail.com> - 5.3.1-11
- Rebuild for updated OCE.

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Sep 15 2015 Orion Poplawski <orion@cora.nwra.com> - 5.3.1-9
- Rebuild for openmpi 1.10.0

* Sat Aug 15 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.3.1-8
- Rebuild for MPI provides

* Sun Jul 26 2015 Sandro Mani <manisandro@gmail.com> - 5.3.1-7
- Rebuild for RPM MPI Requires Provides Change

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.3.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 5.3.1-5
- Rebuilt for GCC 5 C++11 ABI change

* Thu Mar 12 2015 Sandro Mani <manisandro@gmail.com> - 5.3.1-4
- Rebuild (GCC5 ABI change)

* Sat Dec 13 2014 Sandro Mani <manisandro@gmail.com> - 5.3.1-3
- Fix library in -devel package

* Tue Oct 07 2014 Sandro Mani <manisandro@gmail.com> - 5.3.1-2
- Fix soname, use -release instead of -version-info

* Mon Oct 06 2014 Sandro Mani <manisandro@gmail.com> - 5.3.1-1
- Update to 5.3.1

* Mon Sep 01 2014 Sandro Mani <manisandro@gmail.com> - 5.3.0-1
- Update to 5.3.0

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Tue Jul 29 2014 Sandro Mani <manisandro@gmail.com> - 5.1-10
- Rebuild (OCE)

* Thu Jun 19 2014 Sandro Mani <manisandro@gmail.com> - 5.1-9
- Add missing mpich-devel BR

* Thu Jun 19 2014 Sandro Mani <manisandro@gmail.com> - 5.1-8
- Fix escaping of pkg-config variables

* Sat Jun 14 2014 Sandro Mani <manisandro@gmail.com> - 5.1-7
- Rename subpackage private -> devel-private

* Sat Jun 14 2014 Sandro Mani <manisandro@gmail.com> - 5.1-6
- Add netgen-5.1_relative-includes.patch

* Sat Jun 14 2014 Sandro Mani <manisandro@gmail.com> - 5.1-5
- Add subpackage for private headers
- Add patches from salome
- Make common package noarch
- Add missing %%{?_isa}

* Fri Jun 13 2014 Sandro Mani <manisandro@gmail.com> - 5.1-4
- Update netgen-5.1_build.patch
- Add netgen-5.1_msc-ver.patch

* Thu Jun 12 2014 Sandro Mani <manisandro@gmail.com> - 5.1-3
- Fix libgnlib soname

* Thu Jun 12 2014 Sandro Mani <manisandro@gmail.com> - 5.1-2
- Split off libraries in libs subpackages
- Rename shared libraries to less generic names

* Thu Jun 12 2014 Sandro Mani <manisandro@gmail.com> - 5.1-1
- Initial package