%define exec_texhash	[ -x %{_bindir}/texhash ] && %{_bindir}/env - %{_bindir}/texhash 2> /dev/null
%define texmf		%{_datadir}/texmf
%define build_texmf	%{buildroot}%{texmf}

%define altplatex	platex --kanji=euc
%define makepdf(%1)	%altplatex %1 && %altplatex %1 && %altplatex %1 && dvipdfmx %1;

Summary: TeX Live macro packages of writing manuscript for the Institute of Electronics, Information and Communication Engineers
Summary(ja): TeX Live で使うマクロパッケージ 電子情報通信学会論文原稿、技術研究報告作成用
Name: texmacro-ieice
Version: 1.5
Release: 2%{?_dist_release}
BuildArch: noarch
Source0: http://www.ieice.org/ftp/tex/ieicej/LaTeX2e/ieicej15.tar.gz
Source1: http://www.ieice.org/ftp/tex/ieice/LaTeX2e/latex2e.tar.gz
URL: http://www.ieice.org/ftp/
License: distributable
Group: Applications/Publishing
BuildRequires: texlive-common
Requires: texlive-common
Requires(post): texlive
Requires(postun): texlive
Buildroot: %{_tmppath}/%{name}-%{version}-root

Distribution: Vine Linux
Vendor: Project Vine

%description
TeX Live macro packages of writing manuscript for the 
Institute of Electronics, Information and Communication Engineers.
Users can use this macro specifying "ieicej" class (in Japanese) 
or "ieice" class (in English).
Including
	ieice.cls
	ieicej.cls

%description -l ja
電子情報通信学会の技術研究報告(研究会発表論文)和・英論文誌 原稿作成用
の TeX Live で用いる追加マクロパッケージです。
和文は ieicej クラスを、英文は ieice クラスを指定します。
以下のマクロが含まれています
	ieice.cls
	ieicej.cls


%prep
%setup -T -c %{name}-%{version}

tar xzf %{SOURCE0}
mv ieicej15/UNIXEUC jp
rm -rf ieicej15

tar xzf %{SOURCE1}
mv latex2e/UNIXEUC en
rm -rf latex2e

%build

( cd jp
for i in readme tecrep chklist ; do
	# platex $i
	# platex $i
	# dvips $i
	%makepdf $i
	rm -f *.{aux,dvi,log}
done )

( cd en
for i in readme-e readme-j ; do
	# platex $i
	# platex $i
	# dvips $i
	%makepdf $i
	rm -f *.{aux,dvi,log}
done )

%install
rm -rf %{buildroot}

#InstallClass(){
#target=$1; shift
#(cd $target
#bzip2 -dc ${RPM_SOURCE_DIR}/$target.tar.bz2 | tar xf - -C %{build_texmf}/packages/
#rm %{build_texmf}/packages/$target/*.{ins,def,bst,rtx,sty,cls,ltx,fnt,cyr,fdd} || :
#if [ -f src/$target.ins ]; then
#    cp src/* .
#fi
#latex $target.ins
#mkdir -p %{build_texmf}/tex/latex/$target
#cp *.{ldf,sty,def,cls,rtx} %{build_texmf}/tex/latex/$target || :
#if [ ! -z "$*" ]; then 
#    cp -d $* %{build_texmf}/tex/latex/$target || :
#fi
#if [ -n "`ls *.bst`" ]; then
#    mkdir -p %{build_texmf}/bibtex/bst/$target
#    cp *.bst %{build_texmf}/bibtex/bst/$target || :
#fi
#)
#}
#
#mkdir -p %{build_texmf}/packages/

mkdir -p %{build_texmf}/ptex/platex/ieice
mv */*.cls %{build_texmf}/ptex/platex/ieice

mkdir -p %{build_texmf}/bibtex/bst/ieice
mv en/*.bst %{build_texmf}/bibtex/bst/ieice

%post
%{exec_texhash}
exit 0

%postun
%{exec_texhash}
exit 0

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc jp
%doc en
%{texmf}/ptex/platex/ieice
%{texmf}/bibtex/bst/ieice


%changelog 
* Sun Jul 03 2011 Munehiro Yamamoto <munepi@vinelinux.org> 1.5-2
- TeX Live 2009

* Sun Mar 29 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 1.5-1
- update sources
- new versioning policy
- spec in utf8

* Tue Apr 27 2004 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.3-0vl1
- update sources
- drop tech_2e_euc.tgz
- drop BuildRequires: nkf
- install ieicetr.bst
- s/Copyright/License/
- use %%{_bindir} instead of %%{_prefix}/bin
- use %%{_datadir} instead of %%{_prefix}/share

* Thu Jan 30 2003 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl2
- fix file access permissions
- use %%{texmf} at %%files instead of /usr/share/texmf

* Sat Jan 18 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.1-0vl1
- update Source2

* Mon Sep 10 2001 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.0-0vl1
- first release