#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

UPSTREAM_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -e 's/^0.0~repack//' | sed -e 's/-[^-]*$$//')
UPSTREAM_URL=https://www.mdbg.net/chinese/dictionary?page=cedict

%:
	dh $@

override_dh_auto_build:
	dh_auto_build
	./debian/convert_dictd.py cedict_ts.u8 > cc-cedict-utf8.txt
	dictfmt -u '$(UPSTREAM_URL)' -s "CC-CEDICT Chinese-English dictionary version $(UPSTREAM_VERSION)" -f --utf8 --headword-separator %%% --break-headwords --index-data-separator ^^^ --without-headword --without-time cc-cedict < cc-cedict-utf8.txt
	dictzip -n cc-cedict.dict