#!/usr/bin/make -f
#export DH_VERBOSE=1
export PYBUILD_NAME=unknown-horizons
export XDG_CONFIG_HOME=$(CURDIR)/.config
export XDG_DATA_HOME=$(CURDIR)/.local/share
export XDG_CACHE_HOME=$(CURDIR)/.cache

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_configure:
	mkdir -p $(CURDIR)/.config/unknown-horizons \
	$(CURDIR)/.local/share/unknown-horizons \
	$(CURDIR)/.cache/unknown-horizons && cp content/settings-template.xml $(CURDIR)/.config
	dh_auto_configure

override_dh_auto_build:
	cp content/gui/images/logos/uh_no_text.svg $(CURDIR)/unknown-horizons.svg
	./setup.py build_i18n
	python3 horizons/engine/generate_atlases.py 2048

override_dh_auto_clean:
	mkdir -p $(CURDIR)/.config/unknown-horizons \
	$(CURDIR)/.local/share/unknown-horizons \
	$(CURDIR)/.cache/unknown-horizons && cp content/settings-template.xml $(CURDIR)/.config
	$(RM) $(CURDIR)/.config/settings-template.xml
	find . -name "*.mo" -delete
	$(RM) content/lang/stats.json
	$(RM) $(CURDIR)/unknown-horizons.svg
	dh_auto_clean

override_dh_auto_test:

execute_after_dh_auto_install:
	find debian/unknown-horizons -name "*.so" -delete
	rm debian/unknown-horizons/usr/share/unknown-horizons/content/fonts/GPL_fontexception\
	 debian/unknown-horizons/usr/share/unknown-horizons/content/fonts/OFL
	# Remove executable bit from files like tm_* and make Lintian happy
	find debian/unknown-horizons/usr/share/unknown-horizons -type f -exec chmod a-x {} \;
