#!/usr/bin/make -f

GAMEDIR = debian/bubbros/usr/share/games/bubbros

%:
	dh $@

# the game is a directory of Python files run from where it is
# installed, not a Python module: no build system, only the colored
# sprites to generate
override_dh_auto_configure:

override_dh_auto_build:
	cd bubbob/images && python3 buildcolors.py
	mkdir -p debian/manpages
	cp doc/BubBob.py.1 debian/manpages/bubbros.6
	cp doc/bb.py.1 debian/manpages/bubbros-server.6
	cp doc/Client.py.1 debian/manpages/bubbros-client.6

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	python3 -m unittest discover -v -s tests
endif

override_dh_auto_install:

override_dh_auto_clean:
	cd bubbob/images && python3 buildcolors.py -c
	find . -name __pycache__ -prune -exec rm -rf {} +
	rm -rf debian/manpages

override_dh_python3:
	dh_python3 /usr/share/games/bubbros

execute_after_dh_install:
	find $(GAMEDIR) \( -name CVS -o -name .cvsignore -o -name Makefile \
	   -o -name 'setup.py' -o -name '*.c' -o -name 'test_*.py' \) \
	   -prune -exec rm -rf {} +
	rm -rf $(GAMEDIR)/display/windows $(GAMEDIR)/display/dpy_windows.py \
	   $(GAMEDIR)/display/snd_windows.py $(GAMEDIR)/bubbob/doc \
	   $(GAMEDIR)/bubbob/statesaver.py $(GAMEDIR)/http2/sf
	chmod -x $(GAMEDIR)/bubbob/images/buildcolors.py \
	   $(GAMEDIR)/display/pclient.py $(GAMEDIR)/display/playback.py
	chmod +x $(GAMEDIR)/BubBob.py $(GAMEDIR)/bubbob/bb.py \
	   $(GAMEDIR)/display/Client.py
