#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

override_dh_auto_install: lib/lexicon
	dh_auto_install
	cd $(CURDIR)/debian/tmp/usr/share/freespeech && rm -f * && cp $(CURDIR)/lib/text710.edin . && gzip text710.edin

ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
override_dh_auto_build-arch:
	dh_auto_build -- -C src
	dh_auto_build -- lexholder -C lib

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

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

else

lib/lexicon:
	dh_auto_build -- lexicon -C lib

endif
