%define _prefix /opt/freeware
%define _defaultdocdir %{_prefix}/doc
%define glib2_version 2.12.4
%define freetype2_version 2.1.4
#%define pkgconfig_version @pkgconfig_version@

Summary: 	System for layout and rendering of internationalized text.
Name: 		pango
Version: 	1.14.5
Release: 	4
License: 	LGPL
Group: 		System Environment/Libraries
Source: 	ftp://ftp.gtk.org/pub/gtk/v2.1/pango-%{version}.tar.bz2

Patch0:		pango-1.14.5-aix.patch
Patch1:		pango-1.14.5-autotools.patch

URL: 		http://www.pango.org
BuildRoot: 	%{_tmppath}/%{name}-%{version}-root

# We need to prereq this so we can run pango-querymodules
Prereq: glib2 >= %{glib2_version}
Requires: freetype2 >= %{freetype2_version}

BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: freetype2-devel >= %{freetype2_version}
Obsoletes: pango-gtkbeta, fribidi-gtkbeta

# 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
Pango is a system for layout and rendering of internationalized text.

%package devel
Summary: 	System for layout and rendering of internationalized text.
Group: 		Development/Libraries
Requires: 	pango = %{PACKAGE_VERSION}
Requires: 	glib2-devel >= %{glib2_version}
Requires: 	freetype2-devel >= %{freetype2_version}
Obsoletes: fribidi-gtkbeta-devel, pango-gtkbeta-devel

%description devel
The pango-devel package includes the static libraries, header files,
and developer docs for the pango package.

Install pango-devel if you want to develop programs which will use
pango.

%post
%{_prefix}/bin/pango-querymodules > %{_prefix}/etc/pango/pango.modules

%prep
%setup -q

if test x$PATCH = x ; then
  PATCH=patch ;
fi
$PATCH -p2 -s < %{_sourcedir}/pango-1.14.5-aix.patch
$PATCH -p2 -s < %{_sourcedir}/pango-1.14.5-autotools.patch

# Prep 64-bit build in 64bit subdirectory
%if %{BUILD64} == 1
mkdir 64bit
cd 64bit
bzip2 -dc %{SOURCE0} | tar -xf -
cd pango-1.14.5
$PATCH -p2 -s < %{_sourcedir}/pango-1.14.5-aix.patch
$PATCH -p2 -s < %{_sourcedir}/pango-1.14.5-autotools.patch
%endif

%build
# now build the 32-bit version
export OBJECT_MODE=32
export CC="xlc_r -q32"
PATH=%{_bindir}:$PATH ./configure --prefix=%{_prefix} --disable-gtk-doc
LIBPATH=%{_libdir} PATH=%{_bindir}:$PATH make

# now build the 64-bit version
%if %{BUILD64} == 1
cd 64bit/pango-1.14.5
export OBJECT_MODE=64
export CC="xlc_r -q64"
PATH=%{_bindir}:$PATH ./configure --prefix=%{_prefix} --disable-gtk-doc
LIBPATH=%{_libdir} PATH=%{_bindir}:$PATH make

# Go back to 32-bit library and add our 64bit shared object
# into same archive
cd ../..
pwd
/usr/bin/ar -X32_64 -q ./pango/.libs/libpango-1.0.a ./64bit/pango-1.14.5/pango/.libs/libpango-1.0.so.0
/usr/bin/ar -X32_64 -q ./pango/.libs/libpangox-1.0.a ./64bit/pango-1.14.5/pango/.libs/libpangox-1.0.so.0
/usr/bin/ar -X32_64 -q ./pango/.libs/libpangoft2-1.0.a ./64bit/pango-1.14.5/pango/.libs/libpangoft2-1.0.so.0
/usr/bin/ar -X32_64 -q ./pango/.libs/libpangocairo-1.0.a ./64bit/pango-1.14.5/pango/.libs/libpangocairo-1.0.so.0
/usr/bin/ar -X32_64 -q ./pango/.libs/libpangoxft-1.0.a ./64bit/pango-1.14.5/pango/.libs/libpangoxft-1.0.so.0
/usr/bin/ar -X32_64 -q ./modules/arabic/.libs/libpango-arabic-fc.a ./64bit/pango-1.14.5/modules/arabic/.libs/libpango-arabic-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/basic/.libs/libpango-basic-fc.a ./64bit/pango-1.14.5/modules/basic/.libs/libpango-basic-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/basic/.libs/libpango-basic-x.a ./64bit/pango-1.14.5/modules/basic/.libs/libpango-basic-x.so.0
/usr/bin/ar -X32_64 -q ./modules/hangul/.libs/libpango-hangul-fc.a ./64bit/pango-1.14.5/modules/hangul/.libs/libpango-hangul-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/hebrew/.libs/libpango-hebrew-fc.a ./64bit/pango-1.14.5/modules/hebrew/.libs/libpango-hebrew-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/indic/.libs/libpango-indic-fc.a ./64bit/pango-1.14.5/modules/indic/.libs/libpango-indic-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/khmer/.libs/libpango-khmer-fc.a ./64bit/pango-1.14.5/modules/khmer/.libs/libpango-khmer-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/syriac/.libs/libpango-syriac-fc.a ./64bit/pango-1.14.5/modules/syriac/.libs/libpango-syriac-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/thai/.libs/libpango-thai-fc.a ./64bit/pango-1.14.5/modules/thai/.libs/libpango-thai-fc.so.0
/usr/bin/ar -X32_64 -q ./modules/tibetan/.libs/libpango-tibetan-fc.a ./64bit/pango-1.14.5/modules/tibetan/.libs/libpango-tibetan-fc.so.0
%endif #BUILD64


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

# Small hack to package the XftConfig file
cp XftConfig %{buildroot}%{_sysconfdir}/XftConfig

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

#Add links for 64-bit library members
%if %{BUILD64} == 1
(
   mkdir -p $RPM_BUILD_ROOT/%{prefix64}/lib
   cd $RPM_BUILD_ROOT/%{prefix64}/lib
   ln -s ../../lib/*.a .
)
%endif

%files
%defattr(-, root, system)
%doc README AUTHORS COPYING ChangeLog TODO
%doc examples/HELLO.utf8
%{_prefix}/bin/pango-querymodules
/usr/bin/*
%{_prefix}/lib/libpango*-*.a
/usr/lib/libpango*-*.a
%{_prefix}/lib/pango
%{_mandir}/man1/*
%config %{_sysconfdir}/pango/pangox.aliases
%config %{_sysconfdir}/XftConfig
# %ghost %{_sysconfdir}/pango/pango.modules

%files devel
%defattr(-, root, system)
%{_prefix}/lib/libpango*.la
%{_prefix}/include/*
/usr/include/*
%{_prefix}/lib/pkgconfig/*
%{_prefix}/share/gtk-doc/*

%changelog
*  Fri Nov 17 2006  BULL
 - Release  1
 - New version  version: 1.14.5
 - gnome 2.16.1

*  Mon Sep 18 2006  BULL
 - Release  5
 - support 64 bits

*  Thu Jul 20 2006  BULL
 - Release  4
 - built with ORBit 2.14

*  Thu Jul 10 2006  BULL
 - Release  3
 - New version  version: 1.12.0

*  Tue Jan 17 2006  BULL
 - Release  3

*  Fri Dec 23 2005  BULL
 - Release 2
 - Prototype gtk 64 bit
*  Tue Nov 15 2005  BULL
 - Release  1
 - New version  version: 1.10.0

*  Wed Aug 10 2005  BULL
 - Release  3

*  Mon May 30 2005  BULL
 - Release  2
 - .o removed from lib
*  Wed May 25 2005  BULL
 - Release  1
 - New version  version: 1.8.1
 - Fix Xscreensaver-demo core at initialisation on AIX

*  Tue Nov 23 2004  BULL
 - Release  1
 - New version  version: 1.6.0

*  Wed Jul 28 2004  BULL
 - Release  2
 - fix bug causing the generation of a core file

