%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define version 2.25.6
%define release 0vl2
%define vfontcaps vine-vfontcaps-3.0
%define fortest fortest-1.1

Summary: Vector Font Library
Summary(ja): �٥��ȥ�ե���ȡ��饤�֥��
Name: VFlib
Version: %{version}
Release: %{release}
Group: System Environment/Libraries
License: GPL

URL: http://typehack.aial.hiroshima-u.ac.jp/VFlib/
Source0: ftp://TypeHack.aial.hiroshima-u.ac.jp/pub/TypeHack/VFlib2-2.25.6.tar.gz
Source1: %{vfontcaps}.tar.bz2
Source2: install-sh
Source3: config.sub
Source4: %{fortest}.tar.gz

Patch9: VFlib2-2.25.6-gcc33.patch

Patch20: VFlib2-2.25.6-config.sub-x86_64.patch
Patch21: VFlib2-2.25.6-ltconfig-compat32.patch

BuildPreReq: freetype-devel >= 1.2, XFree86-devel
Requires: freetype >= 1.2, TrueTypeFonts_jp
Buildroot: %{_tmppath}/%{name}-%{version}-root
Vendor: Project Vine
Distribution: Vine Linux

%description
A package of VFlib, a library to use vector fonts.  It is used by xdvi,
GhostScript, etc... 

%description -l ja
�٥����ե���Ȥ����Ѥ��뤿��Υ饤�֥��VFlib �����ܸ��б��ǤǤ���
xdvi, Ghostscript �������Ѥ���ޤ���

%package utils
Summary: Several utilities to manipulate and examine VFlib.
Summary(ja): VFlib ��������¹Ԥ����ꤹ��桼�ƥ���ƥ���
Group: Applications/Publishing
Requires: XFree86-libs

%description utils
This package contains several utilities which allow you to manupulate
VFlib.  They are mainly useful for debugging and testing purposes,
and are not required for using the VFlib.

%description utils -l ja
���Υѥå������ˤϡ�VFlib ��������¹Ԥ����ꤹ��桼�ƥ���ƥ���
�����Ĥ��ޤޤ�Ƥ��ޤ����ǥХå���ƥ��Ȥ������Ǥ�����VFlib �λ��Ѥ�
ɬ�פʤ�ΤǤϤ���ޤ���

%package devel
Summary: Header files and library for development with VFlib.
Summary(ja): VFlib �γ�ȯ���å�
Group: Development/Libraries

%description devel
This package is only needed if you intend to develop or
compile applications which rely on the VFlib.
If you simply want to run existing applications, you won't
need this package.

%description -l devel
���Υѥå�������VFlib���Ѥ������ץꥱ��������ȯ�����ꥳ��ѥ���
�����ꤹ��Ȥ��ˤΤ�ɬ�פˤʤ�ޤ���VFlib ���Ѥ������ץꥱ�������
��ñ�˼¹Ԥ�����ˤ�ɬ�פ���ޤ���


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: Vector Font Library
Group: System Environment/Libraries
Requires: freetype >= 1.2, TrueTypeFonts_jp
%description -n compat32-%{name}
A package of VFlib, a library to use vector fonts.  It is used by xdvi,
GhostScript, etc... 

%package -n compat32-%{name}-devel
Summary: Header files and library for development with VFlib.
Group: Development/Libraries
Requires: compat32-%{name} = %{version}
%description -n compat32-%{name}-devel
This package is only needed if you intend to develop or
compile applications which rely on the VFlib.
If you simply want to run existing applications, you won't
need this package.


%prep
%setup -q -a 1 4 -n VFlib2-%{version}
%patch9 -p1 -b .gcc33
%patch20 -p1 -b .x86_64
%if %{build_compat32}
%patch21 -p1 -b .compat32
%endif
find . -type d -name CVS | xargs -r rm -frv

#cp $RPM_SOURCE_DIR/{install-sh,config.sub} .
#chmod 755 install-sh config.sub

%build
%if %{build_compat32}
export CC='gcc -m32'
%endif
%ifarch alpha
./configure --prefix=%{_prefix} --exec-prefix=%{_prefix} \
	--with-freetype --host=alpha-pc-linux
%else
##./configure --prefix=%{_prefix} --exec-prefix=%{_prefix} --with-freetype
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--exec-prefix=%{_prefix} \
	--enable-static \
	--enable-shared \
	--with-freetype \
	--with-freetype-libdir=%{_libdir} \
	--with-x \
	--x-libraries=/usr/X11R6/%{_lib}
%endif

%if %{build_compat32}
# to be changed imake result
pushd src
	make default_vfontcap=/etc/vfontcap
popd
pushd tools
	imake -DUseInstalled -I/usr/X11R6/lib/X11/config
	mv Makefile Makefile.x64_86
	sed "s|lib64|lib|g" Makefile.x64_86 > Makefile
	make default_vfontcap=/etc/vfontcap
popd
make default_vfontcap=/etc/vfontcap
%else
make default_vfontcap=/etc/vfontcap
%endif

%install
rm -rf $RPM_BUILD_ROOT
#make prefix=$RPM_BUILD_ROOT%{_prefix} exec_prefix=$RPM_BUILD_ROOT%{_prefix} install
make \
	prefix=$RPM_BUILD_ROOT%{_prefix} \
	exec_prefix=$RPM_BUILD_ROOT%{_prefix} \
	libdir=$RPM_BUILD_ROOT%{_libdir} \
	install

# /usr/share/VFlib contains only documents
rm -rf $RPM_BUILD_ROOT%{_datadir}/VFlib

# install vfontcaps
(cd %{vfontcaps}
make DESTDIR=$RPM_BUILD_ROOT install
)

# prepare docs
cp -p tools/README README.ktest
rm -f doc/*~

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%if %{build_compat32}
%post -n compat32-%{name} -p /sbin/ldconfig
%postun -n compat32-%{name} -p /sbin/ldconfig
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%if !%{build_compat32}
%files
%defattr(-,root,root)
%doc CHANGES COPYING{,.LIB} DISTRIB.txt INSTALL README.txt{,.JP_EUC}
#%doc README.ktest dynafont doc fortest
%doc README.ktest dynafont doc
# vfontcap is included in truetype-fonts-ja
%config /etc/vfontcap
%{_datadir}/fonts/TrueType/vfontcap.ttf
%{_datadir}/fonts/zeit/vfontcap.zeit
%{_libdir}/libVFlib2.la
%{_libdir}/libVFlib2.so.*

%files utils
%defattr(-,root,root)
%{_bindir}/ttindex
%{_bindir}/bdfindex
%{_bindir}/fwindex
%{_bindir}/ktest

%files devel
%defattr(-,root,root)
%{_includedir}/VF.h
%{_libdir}/libVFlib2.so
%endif

## to build compat32 for x86_64 architecture support
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root)
%{_libdir}/libVFlib2.la
%{_libdir}/libVFlib2.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/libVFlib2.so
%endif

%changelog
* Wed Feb 15 2006 Shu KONNO <owa@bg.wakwak.com> 2.25.6-0vl2
- dropt fortest in %doc (because which is not found)
- added VFlib2-2.25.6-config.sub-x86_64.patch
- added --with-freetype-libdir, --x-libraries to configure
- added compat32-* packages for x86_64 architecture support
- added VFlib2-2.25.6-ltconfig-compat32.patch
- added current updating scripts of tools/Makefile for compat32

* Sun Jan 16 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 2.25.6-0vl1
- new upstream release
- added entry for dynacomware fonts in vfontcap
- use License tag instead of Copyright

* Mon Mar 25 2002 Jun Nishii <jun@vinelinux.org> 2.25.2-0vl2
- added entry for ricoh fonts in vfontcap
- update fortest

* Sat Jan 13 2001 Lisa Sagami <czs14350@mb.infoweb.ne.jp>
- 2.24.2-8

* Sat Jan 13 2001 Lisa Sagami <czs14350@mb.infoweb.ne.jp>
- minor spec fixes
- dont pack CVS directory

* Sun Nov 19 2000 Satoshi MACHINO <machino@vinelinux.org> 2.24.2-7
- build with gcc-2.95.3
- partially used rpmmacros

* Fri Jan 21 2000 Jun Nishii <jun@vinelinux.org>
- rel.6
- modify vine-vfontcaps-1.0
- merge vfontcaps for dyna and free
- more Japanese Summary and description

* Tue Nov 23 1999 Norihito Ohmori <ohmori@flatout.org>
- modified for Vine Linux. 

* Thu Nov 18 1999 Toru Hoshina <t@kondara.org>
- add alphaev6 support.

* Thu Nov 18 1999 Norihito Ohmori <nono@kondara.org>
- add defattr(-,root,root) in utils & devel (jitter #108)

* Mon Nov 8 1999 Toru Hoshina <t@kondara.org>
- be a NoSrc :-P

* Sat Oct 30 1999 Norihito Ohmori <ohmori@flatout.org>
- change dependency from TrueTypeFonts_jp to truetype-fonts-ja

* Fri Oct 29 1999 Norihito Ohmori <ohmori@flatout.org>
- add defattr.

* Fri Oct 15 1999 Norihito Ohmori <ohmori@flatout.org>
- sprit VFlib, VFlib-devel and  VFlib-utils

* Mon Oct 11 1999 Norihito Ohmori <ohmori@flatout.org>
- rebuild for FreeType-1.3

* Sat Sep 4 1999 Norihito Ohmori <ohmori@flatout.org>
- Add BuildPreReq: Tag for FreeType

* Mon Jul 26 1999 Jun Nishii <jun@flatout.org>
- updated to 2.24.2
- build for Vine-1.9

* Fri Jul 9 1999 Norihito Ohmori <ohmori@flatout.org>
- spec file fix (patch rejected).

* Tue Jun 29 1999 Norihito Ohmori <ohmori@flatout.org>
- if DynaFont was already installed, use it

* Mon May 24 1999 Norihito Ohmori <ohmori@flatout.org>
- Comment "GS-" entry in vfontcap
 
* Tue May 19 1999 Norihito Ohmori <ohmori@flatout.org>
- add "GS-" entry for Ghostscript xfont extention

* Fri Dec 11 1998 Hideya Hane <pje@linux.or.jp>
- Requires TrueTypeFonts_jp(change from xtt_fonts)

* Sun Nov 29 1998 Jun Nishii <jun@flatout.org>
- dynamic link libttf to libVFlib

* Wed Nov 25 1998 Jun Nishii <jun@flatout.org>
- fix wrong symbolic link of /etc/vfontcap

* Tue Nov 24 1998 Jun Nishii <jun@flatout.org>
- use ttf as default fonts

* Tue Nov 10 1998 Jun Nishii <jun@flatout.org>
- for version 2.24 release 1

* Tue Nov 10 1998 Jun Nishii <jun@flatout.org>
- add descrption -l ja
- tiny bug fix when building vflib

* Fri Sep 25 1998 Jun Nishii <jun@flatout.org>
- first release