File mathgl.spec of Package mathgl

#
# spec file for package mathgl
#
# Copyright (c) 2012 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 http://bugs.opensuse.org/
#


%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

Name:           mathgl
%define libname lib%{name}
Version:        2.1.1
Release:        0
%define somajor 7
Summary:        Cross-platform library for making high-quality scientific graphics
License:        GPL-3.0
Group:          Productivity/Scientific/Other
Url:            http://mathgl.sourceforge.net
Source:         http://downloads.sourceforge.net/mathgl/%{name}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM mathgl-fltk.patch -- Correct typo in fltk's include statements
Patch0:         mathgl-fltk.patch
# PATCH-FIX-UPSTREAM mathgl-libpath.patch -- Allow setting installed libraries location using a cmake variable
Patch1:         mathgl-libpath.patch
# PATCH-FIX-UPSTREAM mathgl-fix-python-module-path.patch -- Make python modules install arch-depended
Patch2:         mathgl-fix-python-module-path.patch
# PATCH-FEATURE-UPSTREAM mathgl-examples-install.patch -- Enable examples install
Patch3:         mathgl-examples-install.patch
# PATCH-FIX-OPENSUSE mathgl-doc-path.patch -- Locate documentation to right place
Patch4:         mathgl-doc-path.patch
# PATCH-FIX-OPENSUSE udav-help-path.patch -- fix path to documentation directory
Patch5:         udav-help-path.patch
BuildRequires:  cmake
BuildRequires:  fltk-devel
BuildRequires:  freeglut-devel
BuildRequires:  gcc-c++
BuildRequires:  giflib-devel
BuildRequires:  gsl-devel
BuildRequires:  hdf5-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  libqt4-devel
BuildRequires:  libtiff-devel
BuildRequires:  libtool
BuildRequires:  octave-devel
# BuildRequires:  openmpi-devel
BuildRequires:  python-devel
BuildRequires:  python-numpy-devel
BuildRequires:  swig
BuildRequires:  texinfo
BuildRequires:  texlive-latex
BuildRequires:  wxWidgets-devel
%define _use_internal_dependency_generator 0
%define __find_requires %wx_requires

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?fedora_version}
BuildRequires:  fltk-fluid
BuildRequires:  libXmu-devel
BuildRequires:  texi2html
BuildRequires:  texinfo-tex
%define _defaultdocdir %{_datadir}/doc/packages
%endif

%description
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

%package -n     %{libname}%{somajor}
Summary:        Cross-platform library for making high-quality scientific graphics
Group:          System/Libraries
Requires:       %{name}-fonts

%description -n %{libname}%{somajor}
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

%package        devel
Summary:        Libraries and header files for %{name} library
Group:          Development/Libraries/Other
Requires:       %{libname}%{somajor} = %{version}
%if 0%{?suse_version}
Recommends:     %{name}-doc
%endif

%description    devel
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

This package contains libraries and header files for developing
applications that use mathgl.

%package        tools
Summary:        Command line tools for %{name} library
Group:          Productivity/Scientific/Other
Requires:       %{libname}%{somajor} = %{version}

%description    tools
This package contains command line tools for making high-quality scientific graphics.

%package        fonts
Summary:        Fonts for %{name} library
Group:          System/X11/Fonts
BuildArch:      noarch

%description    fonts
This package contains command fonts for mathgl library.

%package        examples
Summary:        Examples for %{name} library
Group:          Productivity/Scientific/Other
Requires:       %{libname}%{somajor} = %{version}

%description    examples
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

This package contains examples of using mathgl.

%package        doc
Summary:        Documentation for %{name}
Group:          Documentation/Other
Requires:       %{libname}%{somajor} = %{version}
BuildArch:      noarch

%description    doc
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

This package provides the documentation for mathgl.

%package -n     python-mathgl
Summary:        Libraries and header files for %{name} library
Group:          Productivity/Scientific/Other
Requires:       %{libname}%{somajor} = %{version}
Requires:       python-base

%description -n python-mathgl
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

This package provides the python bindings for mathgl.

%package -n     octave-mathgl
Summary:        Octave interface for %{name} library
Group:          Productivity/Scientific/Other
Requires:       %{libname}%{somajor} = %{version}
Requires:       octave

%description -n octave-mathgl
Mathgl is a cross-platform library for making high-quality scientific
graphics. It provides fast data plotting and handling of large data
arrays, as well as  window and console modes and for easy embedding
into other programs. Mathgl integrates into fltk, qt and
opengl applications.

This package provides octave interface for mathgl.

%package -n     udav
Summary:        Data handling and plotting tool
Group:          Productivity/Scientific/Other
Requires:       %{libname}%{somajor} = %{version}

%description -n udav
UDAV is cross-platform program for data arrays visualization based
on MathGL library. It support wide spectrum of graphics,
simple script language and visual data handling and editing. It has
window interface for data viewing, changing and plotting.Also it
can execute MGL scripts, setup and rotate graphics and so on.


%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1

# Correct octave-mathgl version
sed -i 's/2.0/%{version}/' lang/DESCRIPTION

# Correct location of numpy/arrayobject.h header file
numpy_h=%{python_sitearch}/numpy/core/include/numpy/arrayobject.h
sed -i "s|<numpy/arrayobject.h>|\"${numpy_h}\"|" lang/numpy.i

# convert EOL encodings, maintaining timestames
sed -i 's/\r$//' AUTHORS README

%build
cmake   \
        -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix}  \
        -DLIB_INSTALL_DIR:PATH=%{_lib}          \
        -Denable-double=on                      \
        -Denable-mpi=off                        \
        -Denable-pthread=off                    \
        -Denable-gsl=on                         \
        -Denable-jpeg=on                        \
        -Denable-png=on                         \
        -Denable-zlib=on                        \
        -Denable-pdf=off                        \
        -Denable-gif=on                         \
        -Denable-hdf5=on                        \
        -Denable-opengl=on                      \
        -Denable-glut=on                        \
        -Denable-fltk=on                        \
        -Denable-wx=on                          \
        -Denable-qt=on                          \
        -Denable-python=on                      \
        -Denable-octave=on                      \
        -Denable-octave-install=off             \
        -Denable-doc=on                         \
        .

make %{?_smp_mflags}

%install
%make_install

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}%{_libdir}
# Install octave-mathgl
mkdir -p %{buildroot}%{_libdir}/octave/packages
mkdir -p %{buildroot}%{_datadir}/octave/packages
octave --eval "pkg prefix %{buildroot}%{_datadir}/octave/packages %{buildroot}%{_libdir}/octave/packages; pkg install lang/%{name}.tar.gz"
rm %{buildroot}%{_datadir}/octave/packages/*/packinfo/.autoload
# remove octave module archive
rm %{buildroot}%{_datadir}/%{name}/%{name}.tar.gz

# Remove static library files
rm %{buildroot}/%{_libdir}/*.a

# Install docs
install -m 644 {AUTHORS,ChangeLog.txt,README,COPYING} %{buildroot}%{_docdir}/%{name}/

%post doc
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}_en.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}_en.info-1.gz
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}_en.info-2.gz

%postun doc
%install_info_delete --info-dir=%_infodir %{_infodir}/%{name}_en.info.gz
%install_info_delete --info-dir=%_infodir %{_infodir}/%{name}_en.info-1.gz
%install_info_delete --info-dir=%_infodir %{_infodir}/%{name}_en.info-2.gz

%post -n %{libname}%{somajor} -p /sbin/ldconfig

%postun -n %{libname}%{somajor} -p /sbin/ldconfig

%post -n octave-mathgl
octave -qf --eval "pkg rebuild -auto mathgl"

%postun -n octave-mathgl
octave -qf --eval "pkg rebuild"

%files -n %{libname}%{somajor}
%defattr(-,root,root)
%{_libdir}/*.so.%{somajor}*

%files fonts
%defattr(-,root,root)
%{_datadir}/%{name}/

%files devel
%defattr(-,root,root)
%{_includedir}/mgl2/
%{_libdir}/*.so

%files tools
%defattr(-,root,root)
%{_bindir}/mglconv
%{_bindir}/mglview
%{_bindir}/mgl.cgi
%{_mandir}/man1/*.gz
%{_mandir}/man5/*.gz

%files doc
%defattr(-,root,root)
%doc %{_defaultdocdir}/mathgl/
%{_infodir}/%{name}_en.info*.gz

%files examples
%defattr(-,root,root)
%{_bindir}/mgl*example

%files -n python-mathgl
%defattr(-,root,root)
%{python_sitearch}/*

%files -n octave-mathgl
%defattr(-,root,root)
%{_datadir}/octave/packages/%{name}-*/
%{_libdir}/octave/packages/%{name}-*/

%files -n udav
%defattr(-,root,root)
%{_bindir}/udav
%{_datadir}/pixmaps/udav.png
%{_datadir}/applications/udav.desktop
%{_datadir}/udav/

%changelog
openSUSE Build Service is sponsored by