#!/usr/bin/make -f
#-*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
    DDEBUG="--enable-debug"
endif

export CFLAGS += -fno-strict-aliasing \
	-DSQLITE_SECURE_DELETE -DSQLITE_ENABLE_COLUMN_METADATA \
	-DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_SOUNDEX=1 \
	-DSQLITE_ENABLE_UNLOCK_NOTIFY \
	-DSQLITE_OMIT_LOOKASIDE=1 \
	-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 \
	-DSQLITE_MAX_SCHEMA_RETRY=25 \
	-DSQLITE_HAS_CODEC \
	-DHAVE_USLEEP=1
	# -DHAVE_USLEEP may cause issues on some platforms, but as far as I can
	# tell all platfoms debian supports have USLEEP.

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(DDEBUG) \
	  --enable-threadsafe \
	  --enable-load-extension \
	  --enable-tempstore \
	  --enable-fts4 \
	  --enable-fts5 \
	  --enable-json \
	  --disable-tcl

override_dh_install:
	dh_install -Xlibsqlcipher.la
override_dh_missing:
	dh_missing -Xlibsqlcipher.la --fail-missing

override_dh_auto_clean:
	dh_auto_clean
	$(RM) sqlite3session.h config.log mksourceid

# TODO: fix and enable auto tests
override_dh_auto_test:
