# SliTaz package receipt.

PACKED_SIZE="328.0K"
UNPACKED_SIZE="740.0K"
PACKAGE="sqlite"
_realver=3180000
VERSION="${_realver:0:1}.${_realver:1:2}.${_realver:3:1}"
CATEGORY="office"
SHORT_DESC="Small SQL database engine."
MAINTAINER="pankso@slitaz.org"
LICENSE="PublicDomain"
TARBALL="$PACKAGE-src-${_realver}.zip"
WEB_SITE="http://www.sqlite.org/"
WGET_URL="http://www.sqlite.org/2017/$TARBALL"
EXTRA_SOURCE_FILES="mysql2sqlite.sh"
HOST_ARCH="i486 arm"

DEPENDS="libsqlite"
BUILD_DEPENDS="tcl-dev"

# Rules to configure and make the package.
compile_rules()
{
	case "$ARCH" in
		arm*) ARCH_ARGS="--with-tcl=/cross/arm/sysroot/usr/lib" ;;
	esac
	[ -s "$SOURCES_REPOSITORY/mysql2sqlite.sh" ] ||
		wget -O "$SOURCES_REPOSITORY/mysql2sqlite.sh" \
			https://gist.github.com/esperlu/943776/raw/dd87f4088f6d5ec7563478f7a28a37ba02cf26e2/mysql2sqlite.sh
	export CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DTCLSH=1"
	./configure \
		--prefix=/usr \
		--disable-readline \
		--enable-load-extension \
		LDFLAGS="$LDFLAGS -ldl" \
		$ARCH_ARGS \
		$CONFIGURE_ARGS &&
		make && make install
}

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