%define _fontdir %{_datadir}/fonts/%{name}

%define texmf		%{_datadir}/texmf
%define build_texmf	%{buildroot}%{texmf}

%define exec_texhash  [ -x %{_bindir}/texhash     ] && PATH=%{_bindir}:$PATH %{_bindir}/texhash 2>/dev/null

Summary: WYSIWYM (What You See Is What You Mean) word processor with LaTeX output
Summary(ja): LaTeX 形式で保存できるワードプロセッサ
Name: lyx
Version: 2.0.6
Release: 1%{?_dist_release}
License: GPLv2+
Group: Applications/Editors
URL: http://www.lyx.org/
Source0: ftp://ftp.lyx.org/pub/lyx/stable/lyx-%{version}.tar.xz

Source1: lyxrc.dist
Source10: lyx.desktop

## upstreamable patches
# submitted, but upstream rejected it.  we currently agree to disagree.
Patch50: lyx-2.0.6-xdg_open.patch

## vine
# reverted checkLatex to lyx-1.6.5
Patch100: lyx-2.0.1-configurepy-vine.patch


# BuildRequires: aiksaurus-devel
# BuildRequires:   aspell-devel
BuildRequires:   enchant-devel
BuildRequires:   hunspell-devel
BuildRequires:   libboost-devel
BuildRequires:   libboost-filesystem
BuildRequires:   libboost-signals
BuildRequires:   libboost-regex
BuildRequires:   desktop-file-utils
BuildRequires:   gettext
BuildRequires:   python
BuildRequires:   xorg-x11-devel
BuildRequires:   qt4-devel
BuildRequires:   libpng-devel
BuildRequires:   glib2-devel
BuildRequires:   zlib-devel

Requires(post):  texlive-common
Requires(postun): texlive-common
Requires:        ghostscript
Requires:        python

# optional minimal qt4 dep
%{?_qt_version:Requires: qt4 >= %{_qt4_version}}

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

Requires:        xdg-utils
Requires:        rcs

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

Vendor:       Project Vine
Distribution: Vine Linux


%description
LyX is a modern approach to writing documents which breaks with the
obsolete "typewriter paradigm" of most other document preparation
systems.

It is designed for people who want professional quality output
with a minimum of time and effort, without becoming specialists in
typesetting.

The major innovation in LyX is WYSIWYM (What You See Is What You Mean).
That is, the author focuses on content, not on the details of formatting.
This allows for greater productivity, and leaves the final typesetting
to the backends (like LaTeX) that are specifically designed for the task.

With LyX, the author can concentrate on the contents of his writing,
and let the computer take care of the rest.

This is LyX built with the Qt frontend.

%description -l ja
LaTeX形式で出力もできるワードプロセッサです。数式の入力も簡単にできます。
特別な知識が無くても、最小限の努力でプロ並の出力を得られるように設計
してあります。


%package fonts
Summary: Lyx/MathML fonts
Group:   User Interface/X
# The actual license says "The author of these fonts, Basil K. Malyshev, has
# kindly granted permission to use and modify these fonts."
# One of the font files (wasy10) is separately licensed GPL+.
License: Copyright only and GPL+
Obsoletes:       latex-xft-fonts
BuildArch: noarch
%description  fonts
A collection of Math symbol fonts for %{name}.


%prep
%setup -q

%patch50 -p1 -b .xdg_open
%patch100 -p1 -b .vine

#./autogen.sh


%build
%configure \
    --disable-dependency-tracking \
    --disable-rpath \
    --enable-build-type=release \
    --disable-debug \
    --enable-optimization="%{optflags}" \
    --without-included-boost \
    --disable-stdlib-debug \
    --enable-shared \
    --disable-static \
    \
    --with-frontend=qt4 \
    --without-aiksaurus \
    --with-enchant \
    --with-hunspell \
    ;
%__make %{?_smp_mflags}

# # make sure all .gmo files are regenerated from .po files
# (cd po; make update-gmo)


%install
%__rm -rf ${RPM_BUILD_ROOT}
%__make DESTDIR=${RPM_BUILD_ROOT} install

# misc/extras
%__install -p -m644 -D %{SOURCE1} %{buildroot}%{_datadir}/lyx/lyxrc.dist

# Set up the lyx-specific class files where TeX can see them
%__mkdir_p %{build_texmf}/tex/latex
%__mv %{buildroot}%{_datadir}/lyx/tex %{build_texmf}/tex/latex/lyx

# desktop & icon
desktop-file-install --vendor="vine" \
  --dir="${RPM_BUILD_ROOT}%{_datadir}/applications" %{SOURCE10}
%__install -p -D -m644 lib/images/lyx.png \
  %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/lyx.png

# ghost'd files
touch %{buildroot}%{_datadir}/lyx/lyxrc.defaults
touch %{buildroot}%{_datadir}/lyx/{packages,textclass}.lst

# fonts
install -m 0755 -d %{buildroot}%{_fontdir}
mv %{buildroot}%{_datadir}/lyx/fonts/*.ttf %{buildroot}%{_fontdir}/
rm -rf %{buildroot}%{_datadir}/lyx/fonts

%find_lang %{name}

%check
# tests/test_filetools error bogus ( see http://bugzilla.redhat.com/723938 )
%__make -k check ||:


%clean
%__rm -rf ${RPM_BUILD_ROOT}


%post
touch --no-create %{_datadir}/icons/hicolor &> /dev/null || :

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

%posttrans
%{exec_texhash} >& /dev/null
update-desktop-database -q &> /dev/null
touch --no-create %{_datadir}/icons/hicolor &> /dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null || :

%post fonts
%__font_install_post %{_fontdir}

%postun fonts
%__font_install_postun %{_fontdir}


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc ABOUT-NLS ANNOUNCE COPYING README UPGRADING NEWS lib/CREDITS
%{_bindir}/*
%{_datadir}/lyx/
%{texmf}/tex/latex/lyx/
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/*/*
%{_mandir}/man*/*
%config(noreplace) %{_datadir}/lyx/lyxrc.dist
%ghost %{_datadir}/lyx/lyxrc.defaults
%ghost %{_datadir}/lyx/*.lst
%ghost %{_datadir}/lyx/doc/LaTeXConfig.lyx

%files fonts
%defattr(-,root,root,-)
%dir %{_fontdir}/
%{_fontdir}/*.ttf


%changelog
* Sat Dec 28 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.0.6-1
- update to 2.0.6
- update Patch50 (lyx-2.0.6-xdg_open.patch)

* Sun Mar 11 2012 Munehiro Yamamoto <munepi@vinelinux.org> 2.0.2-2
- rebuild with hunspell-devel

* Thu Jan 26 2012 Munehiro Yamamoto <munepi@vinelinux.org> 2.0.2-1
- new upstream release
- added subpackage "lyx-fonts"
  - added Obsoletes: latex-xft-fonts

* Sat Oct 01 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2.0.1-2
- applied lyx-2.0.1-configurepy-vine.patch
  - reverted checkLatex to lyx-1.6.5

* Fri Sep 09 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2.0.1-1
- new upstream release

* Sat Jun 25 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2.0.0-1
- new upstream release
- dropped BuildRequires: aspell-devel
- added BuildRequires: 
  - libboost-regex
  - enchant-devel
  - hunspell-devel

* Thu Dec 23 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.6.8-1
- new upstream release

* Sun Aug 08 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.6.7-1
- new upstream release
- TeX Live 2009
  - dropped Requires: xdvik, dvipdfmx

* Sun Jan 10 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.6.5-1
- new upstream release
- updated Patch0: lyx-1.6.5-xdg_open.patch

* Sun Jul 26 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.6.3-1
- new upstream release
  - dropped old source files
- change License: GPLv2+
- added lyx.desktop
- added BuildRequires: 
  - aspell-devel
  - desktop-file-utils
  - gettext
  - python
  - qt4-devel
  - zlib-devel
  - libboost-devel
  - libboost-filesystem
  - libboost-signals
  - libpng-devel
  - glib2-devel
- added Requires: 
  - ghostscript
  - dvipdfmx
  - xdvik
  - qt4
  - xdg-utils
- optimized some configure options

* Fri Oct 03 2008 Shu KONNO <owa@bg.wakwak.com> 1.4.4-1vl5
- applied new versioning policy, spec in utf-8

* Sat Apr 07 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.4.4-0vl1
- updated to 1.4.4 with the most recent CJK patch
- updated Patch1

* Sat Dec 30 2006 USAMI Kosuke <usami-k@yc5.so-net.ne.jp> - 1.4.2-0vl1
- base spec file : Vine Linux BTS #219
  * Mon Nov  6 2006 M.H
  - new upstream release
  - base spec file CJK-LyX-qt.spec and VinePlus lyx.spec

* Wed Sep 13 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 1.3.4-0vl3
- changed Group to Applications/Editors

* Sat Jan 28 2006 Yasumichi Akahoshi <yasumichi@vinelinux.org>
- rebuild with qt-3.3.5

* Sun Jun 13 2004 USAMI Kosuke <usami-k@yc5.so-net.ne.jp> - 1.3.4-0vl1
- new upstream version
- change frontend, xforms -> qt
- require tetex, qt, latex-xft-fonts
- change applnk file
- change Group

* Thu Aug 21 2003 USAMI Kosuke <usami-k@yc5.so-net.ne.jp> - 1.1.6fix4-0vl1
- new upstream version
- add mime-info
- minor change in spec file

* Sat Nov 11 2000 Masato Bito <masato@nets.ce.hiroshima-cu.ac.jp>
- 1.0.3_jp-4
- added BuildPrereq:

* Thu Sep 21 2000 Jun Nishii <jun@vinelinux.org>
- 1.0.3_jp-3
- minor change in spec file
- build for Vine Linux 2.1

* Wed Jan  5 2000 Jun Nishii <jun@vinelinux.org>
- change group

* Wed Dec 22 1999 Jun Nishii <jun@vinelinux.org>
- updated to lyx-1.0.3
- rebuild for Vine Linux 2.0

* Wed May 5 1999 Jun Nishii <jun@vinelinux.org>
- merged Japanese Documents

* Tue May 4 1999 Jun Nishii <jun@vinelinux.org>
- first build

