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

%define exec_texhash  [ -x %{_bindir}/texhash     ] && PATH=%{_bindir}:$PATH %{_bindir}/texhash 2>/dev/null
%define exec_updmap   [ -x %{_bindir}/updmap-sys  ] && PATH=%{_bindir}:$PATH %{_bindir}/updmap-sys --nostop 2>/dev/null
%define exec_fmtutil  [ -x %{_bindir}/fmtutil-sys ] && PATH=%{_bindir}:$PATH %{_bindir}/fmtutil-sys --all >/dev/null
%define vartexfonts %{_var}/lib/texmf

Summary: A WYSIWYM (What You See Is What You Mean) frontend to LaTeX
Summary(ja): LaTeX形式でも保存できる簡易ワープロ
Name: lyx
Version: 1.6.5
Release: 1%{?_dist_release}
License: GPLv2+
Group: Applications/Editors
URL: http://www.lyx.org/
Source: ftp://ftp.lyx.org/pub/lyx/stable/%{name}-%{version}.tar.bz2
#Source1: http://www.ring.gr.jp/pub/text/CTAN/macros/latex/contrib/koma-script/koma-script.tds.zip

Source10: lyx.desktop
Source11: lyxrc.dist
Patch0: lyx-1.6.5-xdg_open.patch

# vine
Patch10: lyx-1.6.3-customize-vine.patch

# BuildRequires: aiksaurus-devel
BuildRequires:   aspell-devel
BuildRequires:   libboost-devel
BuildRequires:   libboost-filesystem
BuildRequires:   libboost-signals
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:        tetex
Requires(post):  tetex
Requires:        ghostscript
Requires:        dvipdfmx
Requires:        xdvik
Requires:        python
Requires:        qt4
Requires:        latex-xft-fonts

Requires(hint):  xdg-utils
Requires(hint):  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形式で出力もできる簡易ワープロです。数式の入力も簡単にできます。
特別な知識が無くても、最小限の努力でプロ並の出力を得られるように設計
してあります。


%prep
%setup -q
%patch0 -p1 -b .xdg_open

%patch10 -p1 -b .vine


%build
%configure \
    --enable-build-type=release \
    --disable-dependency-tracking \
    --disable-rpath \
    --disable-debug \
    --enable-optimization="%{optflags}" \
    --enable-shared \
    --disable-static \
    \
    --with-frontend=qt4 \
    --without-aiksaurus \
    --with-aspell \
    ;
#    --without-included-boost \
%__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

# for pdf: ps2pdf, pdf3: dvipdfmx
(cd ${RPM_BUILD_ROOT}%{_datadir}/lyx/images
    ln -sf buffer-update_pdf2.png buffer-update_pdf.png
    ln -sf buffer-update_pdf2.png buffer-update_pdf3.png
    ln -sf buffer-view_pdf2.png buffer-view_pdf.png
    ln -sf buffer-view_pdf2.png buffer-view_pdf3.png
)

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

# latex
%__mkdir_p %{build_texmf}/tex/latex
%__mv -f ${RPM_BUILD_ROOT}%{_datadir}/lyx/tex %{build_texmf}/tex/latex/lyx

## it semms the newest Japanese translations already included in the upstream...
#%__install -m 644 layouts/* ${RPM_BUILD_ROOT}%{_datadir}/lyx/layouts/
#%__install -m 644 1.3.3/* ${RPM_BUILD_ROOT}%{_datadir}/lyx/doc/

# # it semms the newest Japanese translations already included in the upstream...
# install -m 644 %{SOURCE3} ${RPM_BUILD_ROOT}%{_datadir}/locale/ja/LC_MESSAGES/lyx.mo

# 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
touch %{buildroot}%{_datadir}/lyx/doc/LaTeXConfig.lyx

# unpackaged files
rm -rf %{buildroot}%{_datadir}/lyx/fonts

%find_lang %{name}


%clean
%__rm -rf ${RPM_BUILD_ROOT}


%post
%{exec_texhash} >& /dev/null
if [ -d %{_datadir}/lyx ]; then
    cd %{_datadir}/lyx
    echo -n "  "
    echo "Configuring LyX for your system..."
    %__python ./configure.py >& /dev/null || :
fi

update-desktop-database -q &> /dev/null
touch --no-create %{_datadir}/icons/hicolor &> /dev/null || :
gtk-update-icon-cache %{_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


%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


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

