# Template build file for 'sqlite'.
pkgname=sqlite
version=3.7.17
revision=2
wrksrc=sqlite
create_wrksrc=yes
makedepends="readline-devel"
short_desc="SQL Database Engine in a C Library"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://www.sqlite.org"
license="Public Domain"
_amalgamationver=3071700
distfiles="http://www.sqlite.org/2013/sqlite-autoconf-${_amalgamationver}.tar.gz"
checksum=8ff46d0baa9e64c0815544e829e985f1161c096aa6344c8f430791dbeadc2baf

do_configure() {
	export CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 \
		-DSQLITE_ENABLE_COLUMN_METADATA=1 \
		-DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_SECURE_DELETE"

	cd ${wrksrc}/sqlite-autoconf-${_amalgamationver}
	cp -f ${XBPS_CROSSPFDIR}/config.sub .

	./configure ${configure_args} --enable-threadsafe \
		--enable-readline --enable-dynamic-extensions
}

do_build() {
	cd ${wrksrc}/sqlite-autoconf-${_amalgamationver}
	make ${makejobs}
}

do_install() {
	cd ${wrksrc}/sqlite-autoconf-${_amalgamationver}
	make DESTDIR=${DESTDIR} install

	rm -f ${DESTDIR}/usr/lib/*.a
}

sqlite-devel_package() {
	depends="readline-devel sqlite>=${version}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
	}
}

sqlite_package() {
	pkg_install() {
		vmove usr
	}
}
