%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
Summary: A free and portable TrueType font rendering engine.
Name: freetype
Version: 1.3.1
Release: 8%{?_dist_release}
License: BSD-like
Group: System Environment/Libraries
URL: http://www.freetype.org
Source: freetype-%{version}.tar.gz
Source1: ttmkfdir.tar.gz
Patch0: freetype-1.2-fixpath.patch
Patch1: freetype-1.3.1-foundrynames.patch
Patch2: freetype-1.3.1-ftdump-gcc3.patch
Patch3: freetype-1.3.1-config.sub-x86_64.patch
Patch4: freetype-1.3.1-ltconfig-compat32.patch

Buildroot: %{_tmppath}/%{name}-%{version}-root
Obsoletes: freetype-utils
BuildRequires:	libX11-devel
BuildRequires:	libXt-devel
BuildRequires:	imake

%description
The FreeType engine is a free and portable TrueType font rendering
engine, developed to provide TrueType support for a variety of
platforms and environments. FreeType is a library which can open and
manages font files as well as efficiently load, hint and render
individual glyphs. FreeType is not a font server or a complete
text-rendering library.

%package utils
Summary: Several utilities to manipulate and examine TrueType fonts.
Group: Applications/Publishing

%description utils
This package contains several utilities which allow you to view and
manipulate TrueType fonts.  They are mainly useful for debugging and
testing purposes, and are not required for using the FreeType
library.

%package devel
Summary: Header files and static library for development with FreeType.
Group: Development/Libraries
Requires:	%{name} = %{version}-%{release}

%description devel
The freetype-devel package contains the header files and static
library needed to develop or compile applications which use the
FreeType TrueType font rendering library. 

Install freetype-devel if you want to develop FreeType
applications. If you simply want to run existing applications, you
won't need this package.

%if %{build_compat32}
## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: A free and portable TrueType font rendering engine.
Group: System Environment/Libraries
%description -n compat32-%{name}
The FreeType engine is a free and portable TrueType font rendering
engine, developed to provide TrueType support for a variety of
platforms and environments. FreeType is a library which can open and
manages font files as well as efficiently load, hint and render
individual glyphs. FreeType is not a font server or a complete
text-rendering library.

%package -n compat32-%{name}-devel
Summary: Header files and static library for development with FreeType.
Group: Development/Libraries
Requires: compat32-%{name} = %{version}
%description -n compat32-%{name}-devel
The freetype-devel package contains the header files and static
library needed to develop or compile applications which use the
FreeType TrueType font rendering library. 

Install freetype-devel if you want to develop FreeType
applications. If you simply want to run existing applications, you
won't need this package.
%endif

%prep
%setup -q
mkdir ttmkfdir
tar xz -C ttmkfdir -f %{SOURCE1}
%patch0 -p1 -b .fixpath
%patch1 -p1 -b .foundrynames
%patch2 -p1 -b .ftdump-gcc3
%patch3 -p1 -b .config.sub-x86_64
%if %{build_compat32}
%patch4 -p1 -b .ltconfig-compat32
%endif

%build
%if %{build_compat32}
export CC='gcc -m32'
%endif
##libtoolize --copy --force
./configure --prefix=%{_prefix} \
	--with-cflags="$RPM_OPT_FLAGS" \
	--disable-debug \
	--enable-static --enable-shared \
	--with-locale-dir=%{_localedir} \
	--libdir=%{_libdir} \
	--x-libraries=%{_libdir} \
	--target=%{_target_platform}

make

%if 0
make -C ttmkfdir CC="gcc $RPM_OPT_FLAGS"

(cd contrib/ttf2pk
./configure --prefix=%{_prefix} \
	--mandir=%{_mandir} \
	--with-cflags="$RPM_OPT_FLAGS"
make
)
%endif

#	--libdir=$RPM_BUILD_ROOT%{_libdir} \
%install
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{_prefix} \
	libdir=$RPM_BUILD_ROOT%{_libdir} \
	install \
	gnulocaledir=$RPM_BUILD_ROOT%{_localedir}
%if 0
install -m 755 ttmkfdir/ttmkfdir $RPM_BUILD_ROOT%{_bindir}
%endif

(cd $RPM_BUILD_ROOT%{_includedir}
for i in freetype/*.h
do
    ln -sf $i .
done
)

%if 0
(cd contrib/ttf2pk
make prefix=$RPM_BUILD_ROOT%{_prefix} \
	mandir=$RPM_BUILD_ROOT%{_mandir} \
        install
mkdir -p $RPM_BUILD_ROOT%{_datadir}/ttf2pk
cp data/* $RPM_BUILD_ROOT%{_datadir}/ttf2pk
)
%endif

# remove unpackaged files
rm -rf $RPM_BUILD_ROOT%{_bindir}

%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

%files
%defattr(-,root,root)
%{_libdir}/libttf.la
%{_libdir}/libttf.so.*
%{_datadir}/locale/*/LC_MESSAGES/*
%doc README  announce docs

%if 0
%files utils
%defattr(-,root,root)
%{_bindir}/*
%{_mandir}/man1/*
%{_datadir}/ttf2pk/
%endif

%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/libttf.so
%{_libdir}/libttf.a

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

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

%changelog
* Mon Feb 20 2012 <munepi@vinelinux.org> 1.5.1-8
- rebuild

* Mon Jun 21 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.5.1-7
- add Requires: %{name} = %{version}-%{release} (devel package)
- add BuildRequires: libX11-devel, libXt-devel, imake
- change configure option
    (from "--x-libraries=%{_prefix}/X11R6/%{_lib}" to "--x-libraries=%{_libdir}")

* Wed Mar 26 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5.1-6
- obsolete freetype-utils

* Thu Feb 23 2006 Shu KONNO <owa@bg.wakwak.com> 1.3.1-5vl5
- fixed libdir to configure and to make install

* Mon Feb 13 2006 Shu KONNO <owa@bg.wakwak.com> 1.3.1-5vl4
- dropt libtoolize
- added freetype-1.3.1-ftdump-gcc3.patch
- added freetype-1.3.1-config.sub-x86_64.patch
- added freetype-1.3.1-ltconfig-compat32.patch
- added options --libdir, --x-libraries, --target to configure
- added URL
- changed Copyright to License
- changed direct path strings to macros

* Sat Mar 15 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.3.1-5vl3
- rebuilt with new toolchains

* Mon Jun 11 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.3.1-5vl2
- rebuilt with new %%{_mandir} for VineSeed

* Wed Aug  2 2000 Jun Nishii <jun@vinelinux.org>
- 1.3.1-5vl1
- follow RHL62

* Sat Jan 22 2000 Jun Nishii <jun@vinelinux.org>
- added %defattr

* Tue Jan 11 2000 Jun Nishii <jun@vinelinux.org>
- added bins from contrib/ttf2pk

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

* Wed Nov 10 1999 Norihito Ohmori <nono@kondara.org>
- add /usr/bin/{ftmetric,ftsbit,ftstrtto} to freetype-utils (jitterbug #88)

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

* Wed Oct 14 1999 Norihito Ohmori <nono@kondara.org>
- freetype-current dated Oct 12 1999.

* Sat Oct 9 1999 Toru Hoshina <t@kondara.org>
- freetype-current dated Oct 3 1999.

* Thu Aug 19 1999 Preston Brown <pbrown@redhat.com>
- newer ttmkfdir that works better, moved ttmkfdir to /usr/bin from /usr/sbin
- freetype utilities moved to subpkg, X dependency removed from main pkg
- libttf.so symlink moved to devel pkg

* Mon Mar 22 1999 Preston Brown <pbrown@redhat.com>
- strip binaries

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 5)

* Thu Mar 18 1999 Cristian Gafton <gafton@redhat.com>
- fixed the %doc file list

* Wed Feb 24 1999 Preston Brown <pbrown@redhat.com>
- Injected new description and group.

* Mon Feb 15 1999 Preston Brown <pbrown@redhat.com>
- added ttmkfdir

* Tue Feb 02 1999 Preston Brown <pbrown@redhat.com>
- update to 1.2

* Thu Jan 07 1999 Cristian Gafton <gafton@redhat.com>
- call libtoolize to sanitize config.sub and get ARM support
- dispoze of the patch (not necessary anymore)

* Wed Oct 21 1998 Preston Brown <pbrown@redhat.com>
- post/postun sections for ldconfig action.

* Tue Oct 20 1998 Preston Brown <pbrown@redhat.com>
- initial RPM, includes normal and development packages.