%define with_dvipdfm_compat_mode 0

%define texmf		%{_datadir}/texmf
%define mapdir		%{texmf}/fonts/map/dvipdfmx
%define cmapdir		%{texmf}/fonts/cmap/dvipdfmx
%define build_texmf	%{buildroot}%{texmf}
%define build_mapdir	%{buildroot}%{mapdir}
%define build_cmapdir	%{buildroot}%{cmapdir}
%define dvipdfmconfig	%{texmf}/dvipdfm/config

%define exec_texhash	[ -x %{_bindir}/texhash ] && %{_bindir}/env - %{_bindir}/texhash 2> /dev/null
%define exec_updmap     [ -x %{_bindir}/updmap-sys ] && %{_bindir}/env - %{_bindir}/updmap-sys --nostop 2> /dev/null
%define exec_upddeffont    [ -x %{_sbindir}/update-defaultfont ] && %{_sbindir}/update-defaultfont 2> /dev/null

Summary: dvipdfmx is a DVI (TeX) to PDF translator
Summary(ja): DVI から PDF へ変換
Name: dvipdfmx
Version: 20090522
Release: 4%{?_dist_release}
Source0: http://project.ktug.or.kr/dvipdfmx/snapshot/%{name}-%{version}.tar.gz
Source1: dvipdfmx.cfg.vine

## EUC-UCS2 CMap file
## http://cvs.ktug.or.kr/viewcvs/dvipdfmx/data/EUC-UCS2?view=co
Source10: EUC-UCS2

Patch0: dvipdfmx-20090522-ebb-to-ebbx.patch
Patch10: dvipdfmx-20090522-dropped-dvipdfm-compat-mode.patch
Patch11: dvipdfmx-20090506-ebb-to-ebbx.patch

URL: http://project.ktug.or.kr/dvipdfmx/
License: GPL
Buildroot: %{_tmppath}/%{name}-%{version}-root
Group: Applications/Publishing
BuildRequires: tetex >= 3.0, openssl-devel, ghostscript >= 8.63
BuildRequires: libpaper-devel
BuildRequires: libkpathsea-devel
Requires: libpaper
Requires: tetex >= 3.0-3
Requires: ghostscript >= 8.63
Requires: jvf
Requires: fontconfig >= 2.6.0-2
Requires(post,postun): fontconfig >= 2.6.0-2
Obsoletes: dvipdfm
Autoreq: 0
Requires(post): coreutils
Requires(post,postun): tetex >= 3.0
Requires(post): vutils >= 2.0.5
Vendor: Project Vine
Distribution: Vine Linux

%description
The dvipdfmx (formerly dvipdfm-cjk) project provides an eXtended
version of the dvipdfm, a DVI to PDF translator developed by Mark
A. Wicks. The primary goal of this project is to support multi-byte
character encodings and large character sets for East Asian languages
by CID-keyed font technology. The secondary goal is to support as many
features as pdfTeX developed by Han The Thanh. This project is a
combined work of the dvipdfm-jpn project by Shunsaku Hirata and its
modified one, dvipdfm-kor, by Jin-Hwan Cho.

%description -l ja
  dvidpfmx（旧 dvipdfm-cjk）プロジェクトは、Mark A. Wicks による DVI 
から PDF へのコンバータである dvipdfm の拡張バージョンを開発します。
  このプロジェクトの第一の目標は CID フォントによって東アジア言語のマ
ルチバイト文字エンコードと多くの文字セットを使えるようにすることです。
第二の目標は Han The Thanh による pdfTeX と同じくらいたくさんの機能を
使えるようにすることです。
  このプロジェクトは、平田さんの dvipdfm-jpn と、その派生バージョンの 
Jin-Hwan Cho の dvipdfm-kor との共同作業です。


%prep
rm -rf $RPM_BUILD_ROOT

%setup -q
%if %{with_dvipdfm_compat_mode}
%patch0 -p1
%else
%patch10 -p1
%patch11 -p1
%endif
cp -a %{SOURCE1} data/dvipdfmx.cfg

%build
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix} --datadir=%{_datadir} --mandir=%{_mandir}
make

%install
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{_prefix} datadir=$RPM_BUILD_ROOT%{_datadir} mandir=$RPM_BUILD_ROOT%{_mandir} install-strip

mkdir -p %{build_texmf}/fonts/truetype
mkdir -p %{build_mapdir}
mkdir -p %{build_cmapdir}

rm -f %{build_mapdir}/cid-x.map
touch %{build_mapdir}/vine.map

ln -s dvipdfmx %{buildroot}%{_bindir}/dvipdfm

#install -p -m 644 %{SOURCE10} %{build_cmapdir}

%pre
## check CIDFont dir
if [ -d %{texmf}/dvipdfm/CIDFont ] && ! [ -L %{texmf}/dvipdfm/CIDFont ]; then
	echo "clear %{texmf}/dvipdfm/CIDFont directory."
	rm -rf %{texmf}/dvipdfm/CIDFont
fi

%post
# Create our own cid-x.map
( %{exec_upddeffont} ) ||:

%{exec_texhash} ||:
if [ -x %{_bindir}/updmap-sys ]; then
	%{_bindir}/updmap-sys --enable KanjiMap vine.map 2> /dev/null
fi
( %{exec_updmap} ) ||:
exit 0

%postun
if [ "$1" = 0 ]; then
    for i in %{texmf}/fonts/truetype/*
    do
    if [ -L "$i" ]; then
	rm -f "$i"
    fi
    done
    %{exec_texhash}
    %{exec_updmap}
fi
exit 0


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_bindir}/*
%dir %{texmf}/dvipdfmx
%config %{texmf}/dvipdfmx/dvipdfmx.cfg
%{texmf}/fonts/map/glyphlist/*
%{mapdir}/vine.map
%{cmapdir}/EUC-UCS2
%doc COPYING ChangeLog INSTALL README

%changelog
* Thu Feb 04 2010 Munehiro Yamamoto <munepi@vinelinuc.org> 20090522-4
- added Requires: libpaper [BTS:792]

* Thu Oct 01 2009 Munehiro Yamamoto <munepi@vinelinuc.org> 20090522-3
- added BuildRequires: 
  - libpaper-devel
  - libkpathsea-devel

* Mon Jun 08 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 20090522-2
- dropped dvipdfm compatibility mode
  - applied dvipdfmx-20090522-dropped-dvipdfm-compat-mode.patch, 
    dvipdfmx-20090506-ebb-to-ebbx.patch
  - almost sync with dvipdfmx-20090506 contained in ptetex3-20090607
    (except src/dpxconf.c, data/dvipdfmx.cfg)

* Wed May 27 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 20090522-1
- new upstream release

* Sat May 09 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 20090506-1
- new upstream release
  - revived EUC-UCS2 in THE DVIPDFMX Project CVS HEAD

* Sat Apr 04 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 20080607-4
- use update-defaultfont instead of old vinefont.sh

* Tue Mar 17 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 20080607-3
- reverted EUC-UCS2 from old version (See [VineSeed:16930])

* Sun Jan 11 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 20080607-2
- add Requires: jvf

* Tue Jan 06 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 20080607-1
- new upstream release
- update vinefont.sh (for Vine5CR fonts)
- require fontconfig

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

* Tue Oct 09 2007 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20070518-0vl2
- build for VineSeed

* Tue May 29 2007 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20070518-0vl1
- new upstream release

* Wed May 09 2007 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20070409-0vl1
- new upstream release

* Sat May 27 2006 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl6
- modified vinefont.sh: cid-x is obsolete [ptetex3-20060320]

* Thu May 25 2006 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl5
- modified postun section: remove fonts' symlinks at uninstall

* Fri May 12 2006 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl4
- resync with ptetex-20060506
- move vinefont.sh from %{_bindir} to /usr/share/vine

* Thu Nov 17 2005 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl3
- modified post section: added exec_updmap

* Thu Nov 10 2005 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl2
- added PreReq tetex >= 3.0

* Sat Nov 05 2005 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050831-0vl1
- source update
- modified for teTeX3 (based on Tshucimura-san's ptetex-20051102)

* Wed Aug 31 2005 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050830-0vl1
- source update

* Sat Jun 18 2005 KOBAYASHI Taizo <tkoba@vinelinuc.org> 20050307-0vl1
- source update
- modified for teTeX3 (based on Tshucimura-san's ptetex-20050614)

* Mon Dec 27 2004 KOBAYASHI R. Taizo <tkoba@vinelinuc.org> 20040411-0vl4
- built on behalf of Tsuchimura-san [VineSeed:09639]
  - added dvipdfmx-20040411-jpeg.patch

* Mon Nov 29 2004 KOBAYASHI R. Taizo <tkoba@vinelinuc.org> 20040411-0vl3
- added dvipdfm symlink to dvipdfmx

* Sat Jul 24 2004 KOBAYASHI R. Taizo <tkoba@vinelinuc.org> 20040411-0vl2
- move Copyright to License
- Oops! the spec file was skipped!
  merged Tsuchimura-san's update
  * Thu Jul 15 2004 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20040411-0vl1
  - updated dvipdfmx-20040411.

* Wed Feb 04 2004 KOBAYASHI R. Taizo <tkoba@vinelinuc.org> 20031207-0vl1
- new upstream release

* Sat Oct 11 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 20031009-0vl1
- new upstream release

* Wed Apr 23 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20030313-0vl2
- removed adobe-cmaps-200204.tar.gz instead of BuildRequires: ghostscript >= 7.0

* Fri Apr 18 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20030313-0vl1
- update dvipdfmx-20030313.
- build with tetex-2.0.2 for VineSeed.
- removed useless dvipdfmx-20021230.tate.patch.

* Tue Feb 25 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20021230-0t1
- dvipdfmx.
- build with tetex-2.0.1.
- added dvipdfmx-20021230.tate.patch.

* Mon Aug 19 2002 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20020605-0vl1
- update dvipdfm-cjk-20020605

* Fri Aug  9 2002 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 20020531-0vl1
- dvipdfm-cjk

* Mon Jun 17 2002 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 0.13.2c-0vl8
- rebuild against dvipdfm-2002-03-29.zip

* Wed Oct 10 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.13.2c-0vl7
- simply increased release number (VinePlus's package had the same release!)

* Wed Sep 19 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 0.13.2c-0vl6
- rebuild against dvipdfm.zip (2001-09-14)

* Fri Sep 14 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 0.13.2c-0vl5
- rebuild against dvipdfm.zip (2001-09-09)
- update out2uni.c (2001-09-11, for gcc-3.0/glibc-2.2)
- removed require: pxfonts, txfonts

* Thu Aug 02 2001 Satoshi MACHINO <machino@vinelinux.org> 0.13.2c-0vl4
- pTeX to tetex

* Wed Jul 04 2001 Satoshi MACHINO <machino@vinelinux.org> 0.13.2c-0vl3
- added require: pxfonts, txfonts

* Tue Jul 03 2001 Satoshi MACHINO <machino@vinelinux.org> 0.13.2c-0vl2
- rebuild for VineSeed
- changed mandir /usr/share/man 
- used rpmmacros

* Sat Jun 30 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp>
- 0.13.2c-0vl1
- update 0.13.2c, apply jpatch-p0d patch.

* Wed Jun 27 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp>
- 0.13.2b-5
- apply bgcolor, colorname, gcc30 patch.

* Thu Jun 21 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp>
- 0.13.2b-4
- apply jpatch-p0c patch.

* Fri Jun 15 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp>
- 0.13.2b-3
- add out2uni
- apply printf and pagesize patch.

* Tue Jun 12 2001 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp>
- 0.13.2b-2
- apply patch-psspecial.c and jpatch-p0b.
