%define _noVersionedDependencies        1
%define prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")

Name:          yatex
Version:       1.74
Release:       1%{?_dist_release}
License:       Distributable
Source0:       http://www.yatex.org/yatex%{version}.tar.gz 
#Source0:       http://www.yatex.org/yatex10203151806.tar.gz 
Source1:       %{name}-install.sh
Source2:       %{name}-remove.sh
Source3:       %{name}-init.el
Source4:       vine-default-%{name}.el

## pre-formatted info files here
Source10:      yatexe
Source11:      yatexj
Source12:      yahtmle
Source13:      yahtmlj

## Vine Patch(es)
Patch0:        yatex-info.diff
Patch1:        yatexhlp-emacs.diff
Patch2:        yatex-make.diff
# based on a patch at http://www.nekolinux.2y.net/nekomemo/yahtml01.html
# and modified to suit 1.70 release
Patch3:        yahtml-1.70-timestamp.patch

URL:           http://www.yatex.org/
Group:         Applications/Editors/Emacs
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Summary:       YaTeX - Yet Another TeX mode for Emacs
Summary(ja):   野鳥(YaTeX) - Yet Another TeX mode for Emacs
BuildArch:     noarch

PreReq:        emacsen
%prereq_ge     emacsen-common
BuildRequires: emacsen-common
Obsoletes:     yatex-xemacs

Distribution:  Vine Linux
Vendor:        Project Vine


%description
YaTeX is an intelligent, acquisitive and integrated package which reduces
your efforts of composing LaTeX source on GNU Emacs.

%description -l ja
YaTeX(野鳥)とは、EmacsでLaTeXソースを書くときに生ずる手間を軽減
してくれる、LaTeX 入力支援環境です。


%prep
%setup -n yatex%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1


%build

( cd docs
  chmod 644 *
  install -v -m 644 %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} .
)


%install

[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}
mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/install
mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/remove
mkdir -p ${RPM_BUILD_ROOT}%{_infodir}


#
# install el files
#

cp -a *.el makefile help ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
cp -a %{SOURCE3} %{SOURCE4} \
    ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}/

#
# install info files
#

install -m 644 docs/{yahtmle,yahtmlj,yatexe,yatexj} \
   ${RPM_BUILD_ROOT}%{_infodir}


#
# install script (bytecompile el and install elc, remove)
#

%_installemacsenscript %{name} %{SOURCE1}

%_removeemacsenscript  %{name} %{SOURCE2}


%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


%post
#
# bytecompile and install
#

if [ "$1" = 2 ] ; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}


/sbin/install-info %{_infodir}/yatexe.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info %{_infodir}/yatexj.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info %{_infodir}/yahtmle.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info %{_infodir}/yahtmlj.gz %{_infodir}/dir \
  --section="Emacs"


%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

/sbin/install-info --delete %{_infodir}/yatexe.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info --delete %{_infodir}/yatexj.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info --delete %{_infodir}/yahtmle.gz %{_infodir}/dir \
  --section="Emacs"
/sbin/install-info --delete %{_infodir}/yahtmlj.gz %{_infodir}/dir \
  --section="Emacs"

fi


%files
%defattr(-,root,root)
%doc 00readme install manifest yatex.new
%doc docs

%{_datadir}/emacs/site-lisp/yatex/
%{_infodir}/*
%{emacsen_pkgdir}/install/%{name}
%{emacsen_pkgdir}/remove/%{name}


%changelog 
* Mon Jan 04 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.74-1
- new upstream release

* Sun Oct 18 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.73-7
- updated vine-default-yatex.el
  - dropped (setq YaTeX-no-begend-shortcut t)
- use %{emacsen_pkgdir}

* Sun May 17 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-6
- updated vine-default-yatex.el
  - (setq tex-command "platex -kanji=utf8 -src-specials") [VineSeed:17572]

* Wed May 06 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-5
- updated yatex-install.sh
  - *-init.el: changed from hard copy to symbolic link 
    on /etc/emacs-XX.YY/site-start.d

* Tue Apr 21 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-4
- fixed yatex-init.el

* Sat Apr 11 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-3
- added yatex-init.el, vine-default-yatex.el
- updated yatex-install.sh, yatex-remove.sh for vine-default-yatex.el

* Sun Mar 29 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.73-2
- spec in utf8

* Sat Jun 14 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.73-1
- applied new versioning policy

* Wed Aug 08 2007 KOBAYASHI Taizo <tkoba@vinelinux.org> 1.73-0vl1
- new upstream release

* Mon Sep 11 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.72-0vl2
- s/Copyright/License/
- changed Group to Applications/Editors/Emacs <BTS:VineLinux:163>

* Sun Feb 01 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.72-0vl1
- update yatex-1.72

* Wed May 07 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.71-0vl1
- update yatex-1.71

* Fri Jul 17 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.70-0vl2
- added Patch3 to add hhmts timestamp feature

* Tue May 27 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.70-0vl1
- update yatex-1.70

* Tue May 21 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.69-0vl0.1
- update yatex10203151806

* Wed Mar 13 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.68-0vl4
- fixed: bytecompile yatex19

* Fri Dec 28 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.68-0vl3
- now emacsen-common aware
- FIXME: newer upstream 1.69.2 do not work fine with xemacs-21.1.14

* Wed Oct 11 2000 Jun Nishii <jun@vinelinux.org>
- 1.68-0vl2
- no kanji code conversion of documents

* Tue Sep 19 2000 T.R. Kobayashi <tkoba@ike-dyn.ritsumei.ac.jp>
- 1.68-0vl1
- update to 1.68

* Wed Jul 05 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl5
- YATEXHLP.{jp,eng} moved to appropriate dir

* Thu Jun 23 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl3
- rebuilt for emacs-20.7

* Thu May 11 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl2
- oops ... fixed target dir for help files

* Tue May 09 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.67-6vl1
- rebuilt for emacs-20.6

* Tue Jan 11 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-6
- included forgotten info file for YaHTML

* Fri Jan 07 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-5
- updated for emacs-20.5a release

* Wed Dec  1 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-4
- change Group to Applications/Editors/EmacsLisp

* Sun Nov 28 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-3
- %post and %preun section modified

* Thu Sep 23 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-2
- fixed minor problem in the %files section

* Sat Sep 18 1999 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rins.st.ryukoku.ac.jp>
- 1.67-1
- updated to 1.67 release
- rebuilt for emacs-20.4 on Vine Linux 1.9
- updated URL for the new web site of YaTeX
- some typo fix

* Tue May  4 1999 Daisuke SUZUKI <daisuke@linux.or.jp>
- Initial Release
