#! /bin/bash
# Define parameters
VERS=3.7.7.1
VERSUNDER="$(echo "${VERS}" | sed 's@\.@_@g')"
VERSZEROS="$(echo "${VERS}" | sed 's@\.\([0-9]\)\.@.0\1.@g;s@\.\([0-9]\)\.@.0\1.@g;s@\.\([0-9]\)$@.0\1@g;s@\.@@g')"
SRC="src/sqlite-${VERS}.tar.gz"
SRCURL="http://www.sqlite.org/sqlite-autoconf-${VERSZEROS}.tar.gz"
BUILDDIR="sqlite-autoconf-${VERSZEROS}"
export VERS SRC SRCURL BUILDDIR
# Load common functions
source ../common.sh
# Do not build if the "tcl" platform has been requested
not_platforms 'tcl'
# Download source
download_src
(
rm -rf build
mkdir -p "${PLATDIR}" >/dev/null 2>/dev/null
mkdir build
cd build/ || exit 1
gzip -dc "../${SRC}" | tar -xf -
cd "${BUILDDIR}" || exit 1
cd "tea" || exit 1
chmod +x tclconfig/install-sh
# Enable FTS3
CPPFLAGS="${CPPFLAGS} -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS"
# Enable RTree
CPPFLAGS="${CPPFLAGS} -DSQLITE_ENABLE_RTREE=1"
export CPPFLAGS
bash ./configure --enable-shared --with-tcl="${TCLCONFIGDIR}" --prefix="${PLATDIR}" --libdir="${PLATDIR}" --bindir="${PLATDIR}" ${CONFIGUREEXTRA}
${MAKE:-make} || exit 1
${MAKE:-make} install-binaries PKG_DIR='' || exit 1
rm -f "${PLATDIR}"/*.a
) || exit 1
../create_teapot "${PLATDIR}/teapot.txt" "sqlite3" "${VERS}" "${SRCURL}" "${PLATFORM}" "Tcl 8.4" "SQLite (with FTS3 and R*Tree)"
exit 0