#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

override_dh_auto_build-arch:
ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
	dh_auto_build -- -C src
	dh_auto_build -- lexholder -C lib
	test -e lib/lexicon && touch lib/lexicon || true
else
	test -e lib/lexicon && touch lib/lexicon || true
	dh_auto_build -a
endif

override_dh_auto_build-indep: lib/lexicon
	: # Dummy command to force the target to always be run

override_dh_auto_install-arch:
	$(MAKE) -C src install prefix=$(CURDIR)/debian/tmp/usr
	cp -p lib/lexholder $(CURDIR)/debian/tmp/usr/bin/lexholder-en

lib/lexicon:
	test -e lib/lexholder && mv lib/lexholder lib/lexholder.saved || true
	$(MAKE) CC=gcc CPPFLAGS= CFLAGS= LDFLAGS= LIBS=-ldb-5.3 -C lib
	test -e lib/lexholder.saved && mv -f lib/lexholder.saved lib/lexholder || true
