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

# Define a macro for calling ../configure instead of ./configure
%global dconfigure %(printf %%s '%configure' | sed 's!\./configure!../configure!g')

Name:           netgen-mesher
Version:        5.1
Release:        7%{?dist}
Summary:        Automatic mesh generation tool

License:        LGPLv2
URL:            http://sourceforge.net/projects/netgen-mesher/
Source0:        http://sourceforge.net/projects/netgen-mesher/files/netgen-mesher/5.1/netgen-%{version}.tar.gz
Source1:        netgen-mesher.png
Source2:        netgen-mesher.desktop
# Fix various configure.ac and Makefiles issues:
# - Fix configure.ac to correctly detect dependencies
# - Fix makefile for togl
# - Rename shared libaries, the original names are often way too generic
# - Add missing libraries to LIBADD
# - Fix nglib invalid soname
Patch0:         netgen-5.1_build.patch
# Some fixes to the code (taken from salome netgen plugin)
Patch1:         netgen-5.1_fixes.patch
# Fix build against recent metis
Patch2:         netgen-5.1_metis.patch
# Set a default NETGENDIR appropriate for the fedora packaging
Patch3:         netgen-5.1_netgendir.patch
# Remove some MSC_VER ifdefs (why are they there?)
Patch4:         netgen-5.1_msc-ver.patch
# Make some includes relative (needed for when headers are in -private subpackage)
Patch5:         netgen-5.1_relative-includes.patch

BuildRequires:  autoconf automake libtool
BuildRequires:  tk-devel
BuildRequires:  OCE-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  tcl-togl-devel
BuildRequires:  metis-devel
BuildRequires:  openmpi-devel
BuildRequires:  mesa-libGLU-devel
BuildRequires:  libXmu-devel
BuildRequires:  desktop-file-utils

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        openmpi
Summary:        Netgen compiled against openmpi
BuildRequires:  openmpi-devel
# Require explicitly for dir ownership and to guarantee the pickup of the right runtime
Requires:       openmpi
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        mpich
Summary:        Netgen compiled against mpich
BuildRequires:  mpich2-devel
# Require explicitly for dir ownership and to guarantee the pickup of the right runtime
Requires:       mpich
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.

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

%prep
%autosetup -p1 -n netgen-%{version}


%build
autoreconf -ifv
### serial version ###
mkdir serial
(cd serial
%dconfigure --enable-occ --with-togl=%{tcl_sitearch}/Togl1.7 --enable-jpeglib \
           --includedir=%{_includedir}/%{name} --datadir=%{_datadir}/%{name}
#          --enable-ffmpeg
# Fix unused-direct-shlib-dependency
sed -i -e 's! -shared ! -Wl,--as-needed\0!g' libtool
make %{?_smp_mflags}
)

### openmpi version ###
%{_openmpi_load}
export CXX=mpicxx
mkdir openmpi
(cd openmpi
%dconfigure --enable-occ --with-togl=%{tcl_sitearch}/Togl1.7 --enable-jpeglib --enable-parallel \
           --bindir=$MPI_BIN --libdir=$MPI_LIB --includedir=$MPI_INCLUDE/%{name} --datadir=%{_datadir}/%{name}
#          --enable-ffmpeg
# Fix unused-direct-shlib-dependency
sed -i -e 's! -shared ! -Wl,--as-needed\0!g' libtool
make %{?_smp_mflags}
)
%{_openmpi_unload}

### mpich version ###
%{_mpich_load}
export CXX=mpicxx
mkdir mpich
(cd mpich
%dconfigure --enable-occ --with-togl=%{tcl_sitearch}/Togl1.7 --enable-jpeglib --enable-parallel \
           --bindir=$MPI_BIN --libdir=$MPI_LIB --includedir=$MPI_INCLUDE/%{name} --datadir=%{_datadir}/%{name}
#          --enable-ffmpeg
# Fix unused-direct-shlib-dependency
sed -i -e 's! -shared ! -Wl,--as-needed\0!g' libtool
make %{?_smp_mflags}
)
%{_mpich_unload}


%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)
mv %{buildroot}/$MPI_BIN/netgen %{buildroot}/$MPI_BIN/%{name}
rm -f %{buildroot}/$MPI_BIN/*.tcl rm -f %{buildroot}/$MPI_BIN/*.ocf
%{_openmpi_unload}

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

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

find %{buildroot} -name '*.la' -exec rm -f {} ';'

# 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}/%{_datadir}/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/{} \;
)


%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


%post mpich-libs -p /sbin/ldconfig

%postun mpich-libs -p /sbin/ldconfig


%files common
%doc AUTHORS doc/ng4.pdf
%{_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
%{_libdir}/pkgconfig/%{name}.pc

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

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

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

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

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

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

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


%changelog
* 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