#!/usr/bin/make -f

# Language models: <component>/<name>.gram
GRAMS = hans/zh-hans-t-essay-bgw hans/zh-hans-t-essay-bgc \
        hant/zh-hant-t-essay-bgw hant/zh-hant-t-essay-bgc

%:
	dh $@

# The upstream .gram files are raw memory images in little-endian byte order.
# Dump them to text and rebuild them with rime_build_grammar (librime-bin), so
# that each architecture gets models in its native format.
override_dh_auto_build:
	mkdir -p build
	set -e; for g in $(GRAMS); do \
	    n=$$(basename $$g); \
	    python3 debian/dump_gram.py $$g.gram > build/$$n.txt; \
	    (cd build && rime_build_grammar $$n < $$n.txt); \
	    rm build/$$n.txt; \
	done
