%define _prefix /opt/freeware

%define name		cairo
%define release	        1

Summary:	Cairo provides anti-aliased vector-based rendering for X.
Name:     	%{name}
Version: 	1.8.8
Release:	%{release}
License:	GPL
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Group:		Development/Graphics
URL:		http://www.cairographics.org
Source:		%{name}-%{version}.tar.bz2
BuildRequires:	pkg-config
BuildRequires:	fontconfig-devel
BuildRequires:	zlib-devel
BuildRequires:	libpng-devel >= 1.2
Requires:	freetype2
Requires:	fontconfig
Requires:	libpng >= 1.2

# Use --define 'no64 1' on the command line to disable 64bit build
%{!?no64:%define BUILD64 1}
%{?no64:%define BUILD64 0}
%define prefix64 %{_prefix}/64

%description
Cairo provides anti-aliased vector-based rendering for
X. Paths consist of line segments and cubic splines and
can be rendered at any width with various join and cap
styles. All colors may be specified with optional
translucence (opacity/alpha) and combined using the
extended Porter/Duff compositing algebra as found in the X
Render Extension.

%package -n cairo-devel
Summary:	Headers for Cairo
Group:		Development/Graphics
Requires:	%{name} = %{version}

%description -n cairo-devel
Headers for Cairo

%prep
%setup -q 

%if %{BUILD64} == 1
# Prep 64-bit build in 64bit subdirectory
##########################################
# Test whether we can run a 64bit command so we don't waste our time
/usr/bin/locale64 >/dev/null 2>&1
mkdir 64
cd 64
bunzip2 -dc %{_sourcedir}/%{name}-%{version}.tar.bz2 |tar xf -
cd %{name}-%{version}
%endif


%build
autoreconf --install
export OBJECT_MODE=32
PATH=%{_bindir}:$PATH ./configure --prefix=%{_prefix} --enable-gtk-doc
PATH=%{_bindir}:$PATH make

%if %{BUILD64} == 1
# Now build again as 64bit
###########################
cd 64/%{name}-%{version}
export OBJECT_MODE=64

autoreconf --install
PATH=%{_bindir}:$PATH ./configure --prefix=%{_prefix} --enable-gtk-doc
PATH=%{_bindir}:$PATH make

# Go back to 32-bit library and add our 64bit shared object
#  into same archive
cd ../..

/usr/bin/ar -q src/.libs/libcairo.a 64/%{name}-%{version}/src/.libs/libcairo.so.2

%endif #BUILD64


%install
if test "%{buildroot}" != "/"; then
rm -rf %{buildroot}
fi
mkdir -p %{buildroot}
make DESTDIR=%{buildroot} install-strip

# make links
cd %{buildroot}
for dir in lib include
do
        mkdir -p usr/$dir
        cd usr/$dir
        ln -sf ../..%{_prefix}/$dir/* .
        cd -
done

%if %{BUILD64} == 1
#Add links for 64-bit library members
(

 mkdir -p %{buildroot}%{_prefix}/64/lib
 cd %{buildroot}%{_prefix}/64/lib
 ln -sf ../../../..%{_prefix}/lib/* .
)
%endif


%files
%defattr(-, root, system)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO
%{_libdir}/*.a

%if %{BUILD64} == 1
%{_prefix}/64/lib/*.a
%endif

/usr/lib/*.a

%files -n cairo-devel
%defattr(-, root, root)
%{_includedir}/cairo/*.h
%{_libdir}/*.la
%{_libdir}/pkgconfig/cairo.pc
%{_libdir}/pkgconfig/cairo-xlib-xrender.pc
%{_libdir}/pkgconfig/cairo-xlib.pc
%{_datadir}/gtk-doc/html/cairo/

%changelog
*  Wed Oct 04 2006  BULL
 - Release  6
 - package fixes Licence MPL
*  Mon Apr 03 2006  BULL
 - Release  5
 - link /usr/lib/libcairo.a added

*  Mon Feb 13 2006  BULL
 - Release 4 
 - Prototype gtk 64 bit - build with type CARD32 = unsigned int 
*  Fri Dec 23 2005  BULL
 - Release 3
 - Prototype gtk 64 bit
*  Tue Nov 15 2005  BULL
 - Release  2

*  Fri Nov 04 2005  BULL
 - Release  1
 - New version  version: 1.0.0

