# $Id: PKGBUILD 94606 2010-10-08 18:17:20Z andyrtr $
# Maintainer: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=sqlite3
pkgver=3.7.3
pkgrel=1
pkgdesc="A C library that implements an SQL database engine"
arch=('i686' 'x86_64')
license=('custom')
url="http://www.sqlite.org/"
depends=('readline>=6.0.00')
makedepends=('tcl')
conflicts=('sqlite')
replaces=('sqlite')
source=(http://www.sqlite.org/sqlite-$pkgver.tar.gz
	license.txt)
options=(!libtool)
md5sums=('5437978aae90350cf984993091e0d695'
         'c1cdbc5544034d9012e421e75a5e4890')

build() {
  cd ${srcdir}/sqlite-${pkgver}
  export LTLINK_EXTRAS="-ldl"
  export CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY"
  ./configure --prefix=/usr \
	--enable-threadsafe \
	--enable-threads-override-locks \
	--enable-cross-thread-connections \
	--disable-static \
	--enable-load-extension

  # rpath removal
  sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
  sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

  make || return 1
}

package() {
  cd ${srcdir}/sqlite-${pkgver}
  make DESTDIR=${pkgdir} install
  install -Dm0644 sqlite3.1 ${pkgdir}/usr/share/man/man1/sqlite3.1

  # license
  install -Dm644 ${srcdir}/license.txt ${pkgdir}/usr/share/licenses/${pkgname}/license.txt
}