# $Id: PKGBUILD 89728 2010-09-03 13:08:07Z remy $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Sarah Hay <sarahhay@mb.sympatico.ca>

pkgbase=libgsf
pkgname=('libgsf' 'libgsf-gnome')
pkgver=1.14.18
pkgrel=2
arch=('i686' 'x86_64')
url="http://www.gnome.org/"
license=('GPL' 'LGPL')
makedepends=('libxml2>=2.7.7' 'glib2>=2.24.1' 'bzip2' 'intltool' 'pkgconfig'
             'python2' 'libbonobo>=2.24.3' 'gconf>=2.28.1' 'pygtk')
options=('!libtool' '!emptydirs')
source=(http://ftp.gnome.org/pub/GNOME/sources/${pkgbase}/1.14/${pkgbase}-${pkgver}.tar.bz2)
sha256sums=('16d29e82f7eba68f919f2588ea5328973490fe6d4a7a5f160e8af89b387c9a95')

build() {
  cd "${srcdir}/${pkgbase}-${pkgver}"
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
      --mandir=/usr/share/man --disable-static || return 1
  make || return 1
}

package_libgsf() {
  pkgdesc="The GNOME Structured File Library is a utility library for reading and writing structured file formats"
  depends=('libxml2>=2.7.7' 'glib2>=2.24.1' 'bzip2')
  cd "${srcdir}/${pkgbase}-${pkgver}"
  make DESTDIR="${pkgdir}" GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 install || return 1
  rm -f "${pkgdir}/usr/share/man/man1/gsf-office-thumbnailer.1"
  rm -f "${pkgdir}/usr/lib/libgsf-gnome"*
  rm -rf "${pkgdir}/usr/include/libgsf-1/gsf-gnome/"
  rm -rf "${pkgdir}/etc/gconf"
  rm -f "${pkgdir}/usr/lib/pkgconfig/libgsf-gnome-1.pc"
  rm -f "${pkgdir}/usr/bin/gsf-office-thumbnailer"
  rm -f "${pkgdir}"/usr/lib/python*/site-packages/gsf/gnomemodule.so
}

package_libgsf-gnome() {
  pkgdesc="Libgsf GNOME components"
  depends=("libgsf=${pkgver}" 'libbonobo>=2.24.3' 'gconf>=2.28.1')
  install=libgsf-gnome.install

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C gsf DESTDIR="${pkgdir}" install-libLTLIBRARIES || return 1
  make -C gsf-gnome DESTDIR="${pkgdir}" install || return 1
  make -C thumbnailer DESTDIR="${pkgdir}" install || return 1
  make -C python DESTDIR="${pkgdir}" install || return 1
  make -C doc DESTDIR="${pkgdir}" install-manpageDATA || return 1

  rm -f "${pkgdir}/usr/share/man/man1/gsf.1"
  rm -f "${pkgdir}/usr/share/man/man1/gsf-vba-dump.1"
  rm -f "${pkgdir}"/usr/lib/python*/site-packages/gsf/_*
  rm -f "${pkgdir}"/usr/lib/libgsf-1.so*
  install -m755 -d "${pkgdir}/usr/lib/pkgconfig"
  install -m644 libgsf-gnome-1.pc "${pkgdir}/usr/lib/pkgconfig/" || return 1

  install -m755 -d "${pkgdir}/usr/share/gconf/schemas"
  gconf-merge-schema "${pkgdir}/usr/share/gconf/schemas/libgsf-gnome.schemas" --domain libgsf "${pkgdir}/etc/gconf/schemas/"*.schemas || return 1
  rm -f "${pkgdir}/etc/gconf/schemas/"*.schemas
}