%define _noVersionedDependencies 1

%define TeXdir	%(cd `kpsewhich -expand-var '$TEXMFMAIN'`/../..; pwd)
%define	texdir	%(cd `kpsewhich -expand-var '$TEXMFMAIN'`; pwd)
%define	name	jadetex
%define	ver	3.12
%define	rel	9%{?_dist_release}

Summary:	TeX macros used by Jade TeX output.
Name:		%{name}
Version:	%{ver}
Release:	%{rel}
Group:		Applications/Publishing
License:	Distributable
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildArch:	noarch
PreReq:		tetex >= 3.0, tetex-extra >= 3.0
Requires:	sgml-common >= 0.5
Requires:	jade
BuildPreReq:	unzip
BuildPreReq:	tetex >= 0.9 tetex-extra >= 0.9
Url: http://sourceforge.net/projects/jadetex/

#Source0: http://www.tug.org/applications/jadetex/jadetex.zip
Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Source1: jadefmtutil.cnf
Source2: jadeptex.sh
Source3: jadefmtutil.cnf.ptex
Patch0: jadetex-3.12-theta.patch
Patch1: jadetex-tetex3.patch
Patch10: jadetex-3.12-jadeptex.patch

%description
JadeTeX contains the additional LaTeX macros necessary for taking Jade
TeX output files and processing them as TeX files (to obtain DVI,
PostScript, or PDF files, for example).

%prep
%setup -q
cp %{SOURCE1} .
cp %{SOURCE2} .
cp %{SOURCE3} .
%patch0 -p1 -b .theta
%patch1 -p1 -b .tetex3
%patch10 -p1 -b .jadeptex

%build
make


%install
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT

DESTDIR=$RPM_BUILD_ROOT
mkdir -p $DESTDIR
make install DESTDIR=$DESTDIR

mkdir -p ${DESTDIR}%{texdir}/tex/jadetex
cp *.ini ${DESTDIR}%{texdir}/tex/jadetex
cp *.sty ${DESTDIR}%{texdir}/tex/jadetex
cp *.cnf ${DESTDIR}%{texdir}/tex/jadetex
cp *.cnf.ptex ${DESTDIR}%{texdir}/tex/jadetex

mkdir -p ${DESTDIR}%{_bindir}
install -m 0755 jadeptex.sh ${DESTDIR}%{_bindir}/jadeptex
ln -s etex ${DESTDIR}%{_bindir}/jadetex
ln -s pdfetex ${DESTDIR}%{_bindir}/pdfjadetex


%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT


%post
/usr/bin/env - PATH=$PATH:%{TeXdir}/bin texhash > /dev/null 2>&1
/usr/bin/env - PATH=$PATH:%{TeXdir}/bin fmtutil-sys --cnffile %{texdir}/tex/jadetex/jadefmtutil.cnf --all > /dev/null 2>&1
/usr/bin/env - PATH=$PATH:%{TeXdir}/bin fmtutil-sys --cnffile %{texdir}/tex/jadetex/jadefmtutil.cnf.ptex --all > /dev/null 2>&1
exit 0


%files
%defattr (-,root,root)
%ghost %{texdir}/web2c/jadetex.fmt
%ghost %{texdir}/web2c/pdfjadetex.fmt
%{texdir}/tex/jadetex/dsssl.def
%{texdir}/tex/jadetex/jadetex.ltx
%{texdir}/tex/jadetex/jadetex.ini
%{texdir}/tex/jadetex/pdfjadetex.ini
%{texdir}/tex/jadetex/dummyels.sty
%{texdir}/tex/jadetex/mlnames.sty
%{texdir}/tex/jadetex/ucharacters.sty
%{texdir}/tex/jadetex/uentities.sty
%{texdir}/tex/jadetex/unicode.sty
%{texdir}/tex/jadetex/jadefmtutil.cnf
%{texdir}/tex/jadetex/jadefmtutil.cnf.ptex
%{_bindir}/jadetex
%{_bindir}/pdfjadetex
%{_bindir}/jadeptex

%changelog
* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 3.12-9vl5
- applied new versioning policy

* Thu Sep 21 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 3.12-9vl3
- fix %%post script

* Tue Sep 19 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 3.12-9vl2
- add Patch3 to support tetex3
- fix broken symlinks (<BTS:124>)
- use License: instead of Copyright:

* Sun Apr 13 2003 IWAI Masaharu <iwai@alib.jp> 3.12-9vl1
- sync Rawhide 3.12-9
   - drop jadetex-makefile.patch and jadetex-emergency.patch
     ( upstream merged )
   - add jadetex-3.12-theta.patch (Patch0)
- add jadeptex from http://www.netfort.gr.jp/~ohura/jadetex/
   - add jadeptex.sh (Source2)
   - add jadefmtutil.cnf.ptex (Source3)
   - add jadetex-3.12-jadeptex.patch (Patch10)
   - add %%post script for jadefmtutil.cnf.ptex
- add Url tag

* Mon May 20 2002 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.6-4vl3
- rebuild for VineSeed

* Mon May 20 2002 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.6-4vl2
- add PreReq: tetex >= 0.9 tetex-extra >= 0.9
- add BuildPreReq: tetex >= 0.9 tetex-extra >= 0.9
- add %define _noVersionedDependencies 1

* Fri Oct 12 2001 Akira TAGOH <tagoh@gnome.gr.jp> 3.6-4vl1
- Rebuild for Vine.

* Tue Aug 14 2001 Tim Powers <timp@redhat.com>
- rebuilt to hopefully fix rpm verify problems

* Thu Aug  9 2001 Tim Waugh <twaugh@redhat.com> 3.6-3
- Use %%ghost for the fmt files, since they get recreated (bug #49580).

* Wed Aug  1 2001 Tim Waugh <twaugh@redhat.com> 3.6-2
- Use emergencystretch (bug #47345).

* Mon Jun  4 2001 Tim Waugh <twaugh@redhat.com> 3.6-1
- 3.6.

* Mon Feb 12 2001 Tim Waugh <twaugh@redhat.com> 3.3-1
- 3.3.  Redo jadetex-makefile.patch.

* Fri Jan 19 2001 Tim Waugh <twaugh@redhat.com>
- Earlier change was wrong; jade should be required, not openjade
- Require sgml-common >= 0.5.

* Wed Jan 17 2001 Tim Waugh <twaugh@redhat.com>
- Make tetex a %%post requirement.
- Silence %%post output.
- Don't play so many macro games.
- Build requires unzip.

* Fri Jan 12 2001 Tim Waugh <twaugh@redhat.com>
- Make symlinks relative.

* Mon Jan 08 2001 Tim Waugh <twaugh@redhat.com>
- Change group.
- Require openjade not jade.
- rm before install.
- Use %%{_tmppath}.
- Require tetex-latex.
- Change Copyright: to License:.
- Remove Packager: line.

* Mon Jan 08 2001 Tim Waugh <twaugh@redhat.com>
- Based on Eric Bischoff's new-trials packages.
