#!/bin/bash
#
# Copyright 2004, 2007-2008 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Copyright 2005, 2006, 2007 Scott Harmon
# Available under the terms of the GNU GPL.
#

NAME="pango"
VERSION="1.32.1"
REVISION="1"

PKG_SOURCEURL='ftp://ftp.gnome.org/mirror/gnome.org/sources/$NAME/$VER_MAJ.$VER_MIN/$NAME-$VERSION.tar.xz'

PKG_PATCH[0]="update-pango-querymodules"
PKG_PATCH[1]="pango-etc-host-location.diff"

. $DLG_ROOT/etc/config
. $DLG_ROOT/lib/dl-base

PKG_SANIFYNOTOUCH="needed"
# Copy only the last ChangeLog
PKG_DOCFILES=`echo "$PKG_DOCFILES" | sed -e 's/ChangeLog\*/ChangeLog/'`

cflags
cxxflags
prepare

# Apply slackware patch for $ARCH fixes
applypatch 1 1

analyzesource

# Here we begin adding Slackware style of update for pango modules.
spewdo "cd $PKG_SRCROOT; sed -i -e 's=linux|linux-gnu|=linux|linux|=' config.sub"

if [ "$DLG_ARCH" == "x86-64" ]; then
	host="x86_64-slackware-linux"
	configure --build=$host --host=$host --target=$host
else
	host="i486-slackware-linux"
	configure --build=$host --host=$host --target=$host
fi

make

# Check the host value that is passed to the compile to the one in this script:
compile_host=$(grep 'host_triplet =' $PKG_SRCROOT/pango/Makefile | sed "s/.* = //")
if [ "x$compile_host" != "x$host" ]; then
	die "Host mismatch: compile='$compile_host', Build='$host'"
fi
makeinstall install-strip

findpatch filename ${PKG_PATCH[0]}
spewdo "install -m 0755 $filename $PKG_STAGEROOT$PKG_PREFIX/bin/"
spewdo "rm -f $PKG_STAGEROOT$PKG_SYSCONFDIR/pango/pango.modules"
# Create the dirs based on previously defined $host.
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/pango/$host
spewdo "touch $PKG_STAGEROOT$PKG_SYSCONFDIR/pango/$host/pango.modules"

# We need to have separate 32-bit and 64-bit binaries
# for places where we have two copies of the GTK+ package installed.
# (we might have x86_64 and i486 packages on the same system, for example.)
if [ "$DLG_ARCH" == "x86-64" ]; then
	spewdo "mv $PKG_STAGEROOT$PKG_PREFIX/bin/pango-querymodules $PKG_STAGEROOT$PKG_PREFIX/bin/pango-querymodules-64"
	spewdo "cd $PKG_STAGEROOT$PKG_PREFIX/bin; ln -s pango-querymodules-64 pango-querymodules"
else
	spewdo "mv $PKG_STAGEROOT$PKG_PREFIX/bin/pango-querymodules $PKG_STAGEROOT$PKG_PREFIX/bin/pango-querymodules-32"
	spewdo "cd $PKG_STAGEROOT$PKG_PREFIX/bin; ln -s pango-querymodules-32 pango-querymodules"
fi

tidydocumentation

spewdo "ln -s $PKG_DATADIR/gtk-doc/html/pango $PKG_STAGEROOT$PKG_DOCDIR/html"

analyzebinaries
finalizepackage
packagize
cleanup
