Blob Blame History Raw
Name:       gmsh
Summary:    A three-dimensional finite element mesh generator
Version:    2.8.5
Release:    1%{?dist}

License:    GPLv2+
URL:        http://geuz.org/gmsh/
# Download source from http://geuz.org/gmsh/src/%%{name}-%%{version}-source.tgz
# Delete contrib/blossoms and contrib/mpeg_encode from source archive
Source0:    %{name}-%{version}-source-fedora.tar.gz
Source1:    %{name}.desktop

# Unbundle most of the bundled libraries, see comments in %%prep
Patch0:     gmsh_unbundle.patch
# Fix include paths for alglib headers
Patch1:     gmsh_alglib.patch
# Rename sign macro which conflicts with sign function in alglib header
Patch2:     gmsh_sign.patch
# Port to newer tetgen
Patch3:     gmsh_tetgen.patch
# Installation paths fixup, allow setting them from command line for MPI compilation
Patch4:     gmsh_install-dirs.patch

BuildRequires: alglib-devel
BuildRequires: ann-devel
BuildRequires: blas-devel
BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: fltk-devel
BuildRequires: gcc-gfortran
BuildRequires: gmm-devel
BuildRequires: gmp-devel
BuildRequires: hdf5-devel
BuildRequires: lapack-devel
BuildRequires: libjpeg-turbo-devel
BuildRequires: liblbfgs-devel
BuildRequires: libpng-devel
BuildRequires: mathex-devel
BuildRequires: mesa-libGLU-devel
# BuildRequires: metis-devel
BuildRequires: mmg3d-devel
BuildRequires: netgen-mesher-devel-private
BuildRequires: OCE-devel
BuildRequires: tetgen-devel
BuildRequires: voro++-devel
BuildRequires: zlib-devel
BuildRequires: openmpi-devel
BuildRequires: mpich-devel
BuildRequires: cgnslib-devel
BuildRequires: med-devel
BuildRequires: python2-devel

Requires:       %{name}-common = %{version}-%{release}

%description
Gmsh is a 3D finite element grid generator with a build-in CAD engine 
and post-processor. Its design goal is to provide a fast, light and 
user-friendly meshing tool with parametric input and advanced 
visualization capabilities. Gmsh is built around four modules: 
geometry, mesh, solver and post-processing. The specification of any 
input to these modules is done either interactively using the 
graphical user interface or in ASCII text files using Gmsh's own scripting 
language.

%package common
Summary:        Common files for %{name}
Requires:       hicolor-icon-theme
BuildArch:      noarch

%description common
Common files for %{name}.


%package libs
Summary:        Libraries provided by %{name}


%description libs
Libraries provided by %{name}. These libraries are not required for 
base %{name} package and are used for development only.


%package devel
Summary:        Development with %{name}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description devel
Header files for development with %{name}.


%package doc
Summary:        Documentation, demos and tutorials for %{name}
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description doc
Documentation, demo projects and tutorials for %{name}.

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

%package        openmpi
Summary:        %{name} compiled against openmpi
# 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
%{name} compiled against openmpi.

%package        openmpi-libs
Summary:        %{name} libraries compiled against openmpi

%description    openmpi-libs
%{name} libraries compiled against openmpi.

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

%description    openmpi-devel
Development files for %{name} compiled against openmpi.

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

%package        mpich
Summary:        %{name} compiled against mpich
# 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
%{name} compiled against mpich.

%package        mpich-libs
Summary:        %{name} libraries compiled against mpich

%description    mpich-libs
%{name} libraries compiled against mpich.

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

%description    mpich-devel
Development files for %{name} compiled against mpich.

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

%prep
%autosetup -p1 -n %{name}-%{version}-source

# Copy these outside the contrib folder (Patch takes care of including these in the build)
cp contrib/Netgen/nglib_gmsh.h contrib/Netgen/nglib_gmsh.cpp Mesh

# Bamg: part of freefem++, modified source code
# Chaco: http://www.cs.sandia.gov/~bahendr/chaco.html - no fedora package, modified source code, see contrib/Chaco/README.txt
# DiscreteIntegration: gmsh internal module
# HighOrderMeshOptimizer: gmsh internal module
# kbipack: Source not available on the net anymore
# onelab: gmsh internal module
# rtree: single header file from http://superliminal.com/sources/sources.htm
ls -1 contrib | \
    grep -v ^bamg$ | \
    grep -v ^Chaco$ | \
    grep -v ^DiscreteIntegration$ | \
    grep -v ^HighOrderMeshOptimizer$ | \
    grep -v ^kbipack$ | \
    grep -v ^onelab$ | \
    grep -v ^rtree$ | \
rm -rf

# Convert to utf-8
for file in tutorial/t12.geo; do
    iconv -f ISO-8859-1 -t UTF-8 -o $file.new $file && \
    touch -r $file $file.new && \
    mv $file.new $file
done

# Fix line endings
sed -i 's|\r||g' demos/component8.step


%build
# mpeg not in fedora due to patent issues
# gmsh only supports metis 4
# blossoms is nonfree, see contrib/blossoms/README.txt

### serial version ###
mkdir build-serial
pushd build-serial
LD_FLAGS="-Wl,--as-needed" %cmake .. \
    -DENABLE_BUILD_LIB=YES \
    -DENABLE_BUILD_SHARED=YES \
    -DENABLE_BUILD_DYNAMIC=YES \
    -DENABLE_MPEG_ENCODE=NO \
    -DENABLE_METIS=NO \
    -DENABLE_BLOSSOM=NO \
    -DENABLE_CGNS=YES \
    -DENABLE_MED=YES

make %{?_smp_mflags}
popd

### openmpi version ###
%{_openmpi_load}
export CXX=mpicxx
mkdir build-openmpi
pushd build-openmpi
LD_FLAGS="-Wl,--as-needed" %cmake .. \
    -DENABLE_BUILD_LIB=YES \
    -DENABLE_BUILD_SHARED=YES \
    -DENABLE_BUILD_DYNAMIC=YES \
    -DENABLE_MPI=YES \
    -DGMSH_BIN=$MPI_BIN \
    -DGMSH_LIB=$MPI_LIB \
    -DGMSH_INCLUDE=$MPI_INCLUDE \
    -DENABLE_MPEG_ENCODE=NO \
    -DENABLE_METIS=NO \
    -DENABLE_BLOSSOM=NO \
    -DENABLE_CGNS=YES \
    -DENABLE_MED=YES

make %{?_smp_mflags}
popd
%{_openmpi_unload}

### mpich version ###
%{_mpich_load}
export CXX=mpicxx
mkdir build-mpich
pushd build-mpich
LD_FLAGS="-Wl,--as-needed" %cmake .. \
    -DENABLE_BUILD_LIB=YES \
    -DENABLE_BUILD_SHARED=YES \
    -DENABLE_BUILD_DYNAMIC=YES \
    -DENABLE_MPI=YES \
    -DGMSH_BIN=$MPI_BIN \
    -DGMSH_LIB=$MPI_LIB \
    -DGMSH_INCLUDE=$MPI_INCLUDE \
    -DENABLE_MPEG_ENCODE=NO \
    -DENABLE_METIS=NO \
    -DENABLE_BLOSSOM=NO \
    -DENABLE_CGNS=YES \
    -DENABLE_MED=YES

make %{?_smp_mflags}
popd
%{_mpich_unload}


# Fix to create correct debuginfo
cp -a Parser/Gmsh.* build-serial
cp -a Parser/Gmsh.* build-openmpi
cp -a Parser/Gmsh.* build-mpich


%install
%make_install -C build-openmpi
%make_install -C build-mpich
%make_install -C build-serial

# Remove static libraries
find %{buildroot} -type f -name libGmsh.a -exec rm -f {} \;

# Install icon and .desktop file
install -Dpm 0644 utils/icons/solid_128x128.png  %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1}

# Add API demo to documentation
install -Dpm 0644 utils/api_demos/mainSimple.cpp %{buildroot}%{_defaultdocdir}/%{name}/api/mainSimple.cpp


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

%postun common
/usr/bin/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 %{_defaultdocdir}/%{name}/CREDITS.txt
%doc %{_defaultdocdir}/%{name}/LICENSE.txt
%doc %{_defaultdocdir}/%{name}/README.txt
%{_mandir}/man1/gmsh.1.gz
%{_datadir}/icons/hicolor/128x128/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%{python2_sitelib}/onelab.py*

%files doc
%doc %{_defaultdocdir}/%{name}/tutorial
%doc %{_defaultdocdir}/%{name}/demos
%doc %{_defaultdocdir}/%{name}/api

%files
%{_bindir}/%{name}

%files devel
%{_includedir}/%{name}/
%{_libdir}/libGmsh.so

%files libs
%doc doc/LICENSE.txt
%{_libdir}/libGmsh.so.*

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

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

%files openmpi-libs
%doc doc/LICENSE.txt
%{_libdir}/openmpi/lib/libGmsh.so.*

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

%files mpich-devel
%{_includedir}/mpich*/%{name}/

%{_libdir}/mpich/lib/libGmsh.so

%files mpich-libs
%doc doc/LICENSE.txt
%{_libdir}/mpich/lib/libGmsh.so.*


%changelog
* Wed Jul 23 2014 Sandro Mani <manisandro@gmail.com> - 2.8.5-1
- Update to 2.8.5
- Fix -doc requires
- Rebase patches

* Tue Jul 22 2014 Sandro Mani <manisandro@gmail.com> - 2.8.4-4
- Rename gmsh-demos to gmsh-doc
- Fix scriptlets for gmsh-common
- Install license file with *-libs subpackages

* Thu Jul 17 2014 Sandro Mani <manisandro@gmail.com> - 2.8.4-3
- Fix encoding of file tutorial/t12.geo
- Fix line endings of demos/component8.step
- Fix incorrect changelog
- Add -Wl,--as-needed
- Add BRs: cgnslib-devel med-devel
- Pass -DENABLE_CGNS=YES -DENABLE_MED=YES to cmake
- Install onelab.py in %%{python2_sitelib}
- Add missing Requires: gmsh-common

* Thu Jun 19 2014 Sandro Mani <manisandro@gmail.com> - 2.8.4-2
- Link executable against library
- Compile with mpi support

* Sat Jun 14 2014 Sandro Mani <manisandro@gmail.com> - 2.8.4-1
- Update to 2.8.3
- Update/add patches for unbundling libraries
- Spec cleanup, add missing scriptlets

* Mon Jan 23 2012 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-6
- Add script to remove prohibited code completely from sources
- Do not set CMake flags because they are set in CMakeLists.txt by the script now

* Mon Nov 14 2011 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-5
- Disable MPEG support because of patent issues
- Add patch to use system ANN instead of built-in one
- Add patch to use system GMM instead of built-in one
- Update CMake soname patch to avoid hardcoded numbers

* Sun Nov 13 2011 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-4
- Add patch for API demo to make it usable

* Sun Nov 13 2011 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-3
- Add desktop files

* Sat Nov 12 2011 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-2
- Break into subpackages

* Thu Nov 10 2011 Alexey Vasyukov <vasyukov@gmail.com> - 2.5.0-1
- Initial build for Fedora