File klatexformula.spec of Package klatexformula

#
# spec file for package klatexformula
#
# Copyright (c) 2011 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/
#


# * Library version
%define	libversion		3.2
%define libversionpkgsuffix	3_2
# * Set Group corresponding to the correct openSuSE version
%if 0%{?suse_version} >= 1130
%define texgroup Productivity/Publishing/TeX/Frontends
%define apidocgroup Documentation/HTML
%else
%define texgroup Productivity/Publishing/TeX
%define apidocgroup Development/Documentation
%endif
# * Set whether to compile with debug information or not, depending on ability to create debug packages
%if 0%{?suse_version} < 1120
# # OpenSuse <= 11.1 complains about unpackaged debug files (?), so disable debug information...
# define cmake_build_type "Release"
# define makeinstall_target install/strip
%define cmake_build_type "RelWithDebInfo"
%define makeinstall_target install
%define want_explicit_debug_package 0
%define want_explicit_buildarch 1
%else
%define cmake_build_type "RelWithDebInfo"
%define makeinstall_target install
%define want_explicit_debug_package 0
%define want_explicit_buildarch 0
%endif
# * Set CMake Common compilation options
#   Note: KLF_CMAKE_DEBUG only turns on KLF's CMake debugging messages, it has no effect upon the build itself.
%define cmake_common_options -DKLF_CMAKE_DEBUG=ON -DCMAKE_INSTALL_PREFIX="/usr" -DKLF_INSTALL_LIB_DIR=%{_libdir} -DKLF_INSTALL_BIN_DIR=%{_bindir}
%define build_ktexteditorplugin 0%{?suse_version} > 1110
%if %build_ktexteditorplugin
  %define cmake_buildktexteditorplugin -DKLF_BUILD_KTEXTEDITORPLUGIN=ON
%else
  %define cmake_buildktexteditorplugin -DKLF_BUILD_KTEXTEDITORPLUGIN=OFF
%endif
# -------------------------
#
#  Package Header
#  --------------

Name:           klatexformula
Version:        3.2.2
Release:        1
Summary:        An easy-to-use graphical application for generating images from LaTeX equations
License:        GPLv2+
Url:            http://klatexformula.sourceforge.net/
Source0:        klatexformula-%{version}.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Group:          Productivity/Publishing/TeX/Frontends
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
# NOTE: kdelibs4 is required for the ktexteditor plugin only, not klatexformula itself
BuildRequires:  cmake >= 2.6.4 doxygen fdupes graphviz graphviz-gd gs help2man kdelibs4 libkde4-devel libqt4 >= 4.4.0 libqt4-devel libstdc++-devel qt3 >= 3.3 qt3-devel >= 3.3 shared-mime-info texlive-latex update-desktop-files
Requires:       libklfbackend%libversionpkgsuffix = %{version}, libklftools%libversionpkgsuffix = %{version}, shared-mime-info
Obsoletes:      KLatexFormula < 3.2, klatexformula-plugins < 3.2.2
Provides:       KLatexFormula = %{version}, klatexformula-plugins = %{version}

%description
KLatexFormula is an easy-to-use graphical user interface for generating images
from LaTeX equations. These images can be dragged and dropped or copied and
pasted into external applications (presentations, text documents, graphics...),
or can be saved to disk in a variety of formats (PNG, JPG, BMP, EPS, PDF, etc.).

If package cm-unicode is installed, KLatexFormula can use LaTeX' Computer Modern
Sans Serif font as default application font.

%package -n libklfbackend%libversionpkgsuffix


Summary:        KLatexFormula backend library (Qt4)
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       texlive-latex, gs
Provides:       libklfbackend = %{version}

%description -n libklfbackend%libversionpkgsuffix
A C++/Qt library to generate images (PNG, EPS, PDF, plus all Qt-supported image
formats) from LaTeX equations.

This library implements the base functionality of KLatexFormula. This library
is compiled for Qt 4.

See also packages klatexformula and libklfbackend-qt3.

%package -n libklfbackend-qt3-%libversionpkgsuffix


Summary:        KLatexFormula backend library (Qt3)
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       qt3 >= 3.3, texlive-latex, gs
Provides:       libklfbackend-qt3 = %{version}

%description -n libklfbackend-qt3-%libversionpkgsuffix
A C++/Qt library to generate images (PNG, EPS, PDF, plus all Qt-supported image
formats) from LaTeX equations.

This library implements the base functionality of KLatexFormula. This library
is compiled for Qt 3.

See also packages klatexformula and libklfbackend.

%package -n libklfbackend-devel
License:        GPLv2+
Summary:        KLatexFormula backend library (development files)
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       libklfbackend = %{version}

%description -n libklfbackend-devel
A C++/Qt library to generate images (PNG, EPS, PDF, plus all Qt-supported image
formats) from LaTeX equations.

This library implements the base functionality of KLatexFormula.

This package contains the needed files for development. Contains: headers,
static library.

See also packages klatexformula-devel and libklfbackend-qt3-devel

%package -n libklfbackend-qt3-devel
License:        GPLv2+
Summary:        KLatexFormula backend library (development files) (Qt3)
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       libklfbackend-devel = %{version}, libklfbackend-qt3 = %{version}

%description -n libklfbackend-qt3-devel
A C++/Qt library to generate images (PNG, EPS, PDF, plus all Qt-supported image
formats) from LaTeX equations.

This library implements the base functionality of KLatexFormula. This library
is compiled for Qt 3.

This package contains the needed files for development. Contains: static
library.

See also packages klatexformula-devel and libklfbackend-devel.

%package -n libklftools%libversionpkgsuffix


Summary:        KLatexFormula tools library
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Provides:       libklftools = %{version}

%description -n libklftools%libversionpkgsuffix
A C++/Qt4 library containing general-purpose GUI tools.

These tools were originially written for use by klatexformula, but they have
been promoted to a library for use in any application.

%package -n libklftools-devel
License:        GPLv2+
Summary:        KLatexFormula tools library (development files)
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       libklftools = %{version}

%description -n libklftools-devel
A C++/Qt4 library containing general-purpose GUI tools.

These tools were originially written for use by klatexformula, but they have
been promoted to a library for use in any application.

This package contains the needed files for development. Contains: headers,
static library.

%package devel
License:        GPLv2+
Summary:        Development files for KLatexFormula
Group:          Development/Libraries/C and C++
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
Requires:       klatexformula = %{version}, libklfbackend-devel = %{version}, libklftools-devel = %{version}

%description devel
KLatexFormula is an easy-to-use graphical user interface for generating images
from LaTeX equations. These images can be dragged and dropped or copied and
pasted into external applications (presentations, text documents, graphics...),
or can be saved to disk in a variety of formats (PNG, JPG, BMP, EPS, PDF, etc.).

This package contains the needed files for development. Contains: headers of
the main application library itself, unversioned shared library.

%package apidoc
License:        GPLv2+
Summary:        API documentation for KLatexFormula
Group:          Documentation/HTML
BuildArch:      noarch
Requires:       klatexformula = %{version}

%description apidoc
KLatexFormula is an easy-to-use graphical user interface for generating images
from LaTeX equations. These images can be dragged and dropped or copied and
pasted into external applications (presentations, text documents, graphics...),
or can be saved to disk in a variety of formats (PNG, JPG, BMP, EPS, PDF, etc.).

This package contains the API documentation of the libraries libklfbackend,
libklftool and libklfapp which are the different components of klatexformula.

%if %build_ktexteditorplugin

%package ktexteditor-plugin
License:        GPLv2+
Summary:        KLatexFormula integration into KDE4's text editor
Group:          Productivity/Publishing/TeX/Frontends
%if %want_explicit_buildarch
BuildArch:      %{_arch}
%endif
%kde4_runtime_requires
Requires:       klatexformula = %{version}

%description ktexteditor-plugin
KLatexFormula is an easy-to-use graphical user interface for generating images
from LaTeX equations. These images can be dragged and dropped or copied and
pasted into external applications (presentations, text documents, graphics...),
or can be saved to disk in a variety of formats (PNG, JPG, BMP, EPS, PDF, etc.).

This package contains a KLatexFormula integration plugin for KDE4's KTextEditor
interface. This makes KLatexFormula integrate into Kate, Kile, and any other
KDE4 application using KTextEditor.

%endif

# Explicit debug package for opensuse <= 11.1
%if 0%{?want_explicit_debug_package}
%endif

%prep
%setup -q

%build

# Create a shared version in build-shared/, install runtime
mkdir build-shared
cd build-shared && cmake .. -DCMAKE_BUILD_TYPE=%cmake_build_type \
	-DKLF_LIBKLFBACKEND_STATIC=OFF -DKLF_LIBKLFTOOLS_STATIC=OFF -DKLF_LIBKLFAPP_STATIC=OFF \
	%cmake_common_options %cmake_buildktexteditorplugin \
	-DKLF_INSTALL_RUNTIME=ON -DKLF_INSTALL_DEVEL=OFF \
	-DKLF_INCLUDE_FONTS="" -DKLF_INSTALL_DESKTOP_CATEGORIES="Qt;Office;Utility;Viewer;DesktopUtility;" \
	-DKLF_INSTALL_DESKTOP_ICON="klatexformula" -DKLF_INSTALL_SHARE_PIXMAPS_DIR="" \
	-DKLF_INSTALL_ICON_THEME="share/icons/hicolor" -DKLF_INSTALL_RUN_POST_INSTALL=OFF \
	-DKLF_INSTALL_APIDOC_DIR="share/doc/klatexformula-api" \
        -DKLF_INSTALL_SHARE_MAN1_DIR=%{_mandir}/man1
pwd #debug specfile
make %{?_smp_mflags}
cd ..
pwd #debug specfile

# Create a static version in build-static/, install devel
mkdir build-static
# Run CMake
# Note: we don't want the binaries, install them somewhere harmless (/tmp)
cd build-static && cmake .. -DCMAKE_BUILD_TYPE=%cmake_build_type \
	 -DKLF_LIBKLFBACKEND_STATIC=ON -DKLF_LIBKLFTOOLS_STATIC=ON -DKLF_LIBKLFAPP_STATIC=ON \
	%cmake_common_options -DKLF_BUILD_KTEXTEDITORPLUGIN=OFF \
 	-DKLF_INSTALL_RUNTIME=ON -DKLF_INSTALL_DEVEL=ON \
	-DKLF_INSTALL_KLFAPP_STATIC_LIBS=OFF \
	-DKLF_INSTALL_KLATEXFORMULA_BIN=OFF -DKLF_INSTALL_KLATEXFORMULA_CMDL=OFF \
	-DKLF_INSTALL_DESKTOP=OFF -DKLF_INSTALL_RUN_POST_INSTALL=OFF -DKLF_BUILD_PLUGINS=OFF \
	-DKLF_BUILD_KTEXTEDITORPLUGIN=OFF
pwd #debug specfile
make %{?_smp_mflags}
cd ..

# Create a Qt3 shared version in build-qt3-shared/
mkdir build-qt3-shared
# Run CMake
cd build-qt3-shared && cmake .. -DCMAKE_BUILD_TYPE=%cmake_build_type \
	-DKLF_QT_VERSION=3 -DKLF_LIBKLFBACKEND_STATIC=OFF %cmake_common_options
make %{?_smp_mflags}
cd ..

# Create a Qt3 static version in build-qt3-static/
mkdir build-qt3-static
# Run CMake
cd build-qt3-static && cmake .. -DCMAKE_BUILD_TYPE=%cmake_build_type \
	-DKLF_QT_VERSION=3 -DKLF_LIBKLFBACKEND_STATIC=ON %cmake_common_options
make %{?_smp_mflags}
cd ..

%install
# NOTE: If not creating debuginfo packages, use 'make install/strip'
# Install shared + executables
cd build-shared && make %makeinstall_target DESTDIR=%{buildroot} ; cd ..
# Install static libs
cd build-static && make %makeinstall_target DESTDIR=%{buildroot} ; cd ..
# Install Qt3 klfbackend shared library
cd build-qt3-shared && make %makeinstall_target DESTDIR=%{buildroot} ; cd ..
# Install Qt3 klfbackend static library
cd build-qt3-static && make %makeinstall_target DESTDIR=%{buildroot} ; cd ..

# Doxygen doc generates some duplicate files in the big lot ...
%fdupes %{buildroot}/usr/share/doc/klatexformula-api
# Man pages are duplicates
%fdupes -s %{buildroot}%{_mandir}

%suse_update_desktop_file klatexformula
%if %build_ktexteditorplugin
  %suse_update_desktop_file %{buildroot}/usr/share/kde4/services/ktexteditor_klf.desktop
  %suse_update_desktop_file %{buildroot}/usr/share/kde4/services/ktexteditor_klf_config.desktop
%endif

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING CMUFONTS_COPYING README
%{_bindir}/klatexformula
%{_bindir}/klatexformula_cmdl
%{_libdir}/libklfapp.so.%libversion
/usr/share/applications/klatexformula.desktop
/usr/share/icons/*/*/*/*
/usr/share/mime/packages/klatexformula-mime.xml
/usr/share/man/man1/klatexformula.1.gz
/usr/share/man/man1/klatexformula_cmdl.1.gz
/usr/share/klatexformula/
#/usr/share/klatexformula/rccresources/
#/usr/share/klatexformula/rccresources/klfbaseplugins.rcc

%post
update-mime-database /usr/share/mime
ldconfig

%postun
update-mime-database /usr/share/mime
ldconfig

%files -n libklfbackend%libversionpkgsuffix
%defattr(-,root,root,-)
%{_libdir}/libklfbackend.so.%libversion

%post -n libklfbackend%libversionpkgsuffix
ldconfig

%postun -n libklfbackend%libversionpkgsuffix
ldconfig

%files -n libklfbackend-qt3-%libversionpkgsuffix
%defattr(-,root,root,-)
%{_libdir}/libklfbackend-qt3.so.%libversion

%post -n libklfbackend-qt3-%libversionpkgsuffix
ldconfig

%postun -n libklfbackend-qt3-%libversionpkgsuffix
ldconfig

%files -n libklfbackend-qt3-devel
%defattr(-,root,root,-)
%{_libdir}/libklfbackend-qt3.so
%{_libdir}/libklfbackend-qt3.a

%files -n libklfbackend-devel
%defattr(-,root,root,-)
%{_libdir}/libklfbackend.so
%{_libdir}/libklfbackend.a
/usr/include/klfbackend/
#/usr/include/klfbackend/*.h

%post -n libklfbackend-devel
ldconfig

%postun -n libklfbackend-devel
ldconfig

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

%post -n libklftools%libversionpkgsuffix
ldconfig

%postun -n libklftools%libversionpkgsuffix
ldconfig

%files -n libklftools-devel
%defattr(-,root,root,-)
%{_libdir}/libklftools.so
%{_libdir}/libklftools.a
/usr/include/klftools/
#/usr/include/klftools/*.h

%post -n libklftools-devel
ldconfig

%postun -n libklftools-devel
ldconfig

%files devel
%defattr(-,root,root,-)
%{_libdir}/libklfapp.so
/usr/include/klfapp/
#/usr/include/klfapp/*.h

%post devel
ldconfig

%postun devel
ldconfig

%files apidoc
%defattr(-,root,root,-)
/usr/share/doc/klatexformula-api
#/usr/share/doc/klatexformula-api/*
#/usr/share/doc/klatexformula-api/*/html
#/usr/share/doc/klatexformula-api/*/html/*
#/usr/share/doc/klatexformula-api/*/html/*/*

%if %build_ktexteditorplugin

%files ktexteditor-plugin
%defattr(-,root,root,-)
%{_libdir}/kde4/ktexteditor_klf.so
/usr/share/kde4/apps/ktexteditor_klf/
#/usr/share/kde4/apps/ktexteditor_klf/klfkatepluginui.rc
/usr/share/kde4/services/ktexteditor_klf.desktop
/usr/share/kde4/services/ktexteditor_klf_config.desktop
%endif

%changelog