# SliTaz package receipt.

PACKAGE="sqlite"
_amalgamationver=3070900
_amalgamationver2=${_amalgamationver/00/}
VERSION="${_amalgamationver2//0/.}"
CATEGORY="office"
SHORT_DESC="Small SQL database engine."
MAINTAINER="pankso@slitaz.org"
TARBALL="$PACKAGE-src-${_amalgamationver}.zip"
DEPENDS="libsqlite"
BUILD_DEPENDS="tcl"
WEB_SITE="http://www.sqlite.org/"
WGET_URL="http://www.sqlite.org/$TARBALL"

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	export CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_SECURE_DELETE"
	./configure \
		--prefix=/usr \
		--disable-tcl \
		--disable-readline \
		--enable-load-extension \
		LDFLAGS=-ldl \
		$CONFIGURE_ARGS &&
	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 &&
	make DESTDIR=$DESTDIR install
	# compile lemon here instead of in lemon
	if [ -f $src/lemon ]; then
		rm $src/lemon
	fi
	cp $src/tool/lemon.c .
	sed -i -e 's!lempar.c!/usr/share/lemon/lempar.c!' lemon.c
	echo -n "Compiling lemon..."
	gcc -o lemon lemon.c && status
	mkdir -p $DESTDIR/usr/share/lemon
	cp -a $src/lemon $DESTDIR/usr/bin
	cp -a $src/lempar.c $DESTDIR/usr/share/lemon
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr
	
	cp -a $install/usr/bin $fs/usr
	if [ -f $fs/usr/bin/lemon ]; then
		rm -f $fs/usr/bin/lemon
	fi
}