include ../../encodings.inc
include dictionaries.mk.inc


spcr	   =	tr -s ' ' '\n'
LC_ALL	   =	LC_ALL=$(LOCALE)
sort	   =	$(LC_ALL) sort

dict	   = 	$(INDICT)
dictionary =	uk_words.lst

CLEANFILES =	uk_words.lst spaced.tmp *.old


all:	uk_words.lst


uk_words.lst: $(dict)
	cat $(SPACED) | $(LC_ALL) grep -vE "^[#[:space:]]" | $(spcr) > spaced.tmp
	cat $(NOTSPACED) spaced.tmp | $(sort) > $@
	rm -f spaced.tmp


sort:
	@for ff in $(SORTED) ; do \
	    (mv -f $$ff $$ff.old && \
	    $(sort) < $$ff.old | uniq > $$ff && \
	    rm -f $$ff.old) ; \
	done


clean:
	rm -f $(CLEANFILES)

.PHONY: clean all sort
