#!/usr/bin/make -f

ARCH=$(shell dpkg-architecture -q DEB_HOST_ARCH)

%:
	dh $@

# The license terms don't allow the distribution of modified binaries,
# so stripping is out of the question.
override_dh_strip:

override_dh_install-arch: debian/dwarf-fortress.install
	dh_install

override_dh_install-indep:
	dh_install
# The data directory contains some empty directories. There is no point in installing them.
	find debian/dwarf-fortress-data/usr/share/games/dwarf-fortress/gamedata/ -type d -empty -delete
# The license text of the embedded font copy is not needed, as we replace it with a Debian
# version of the font via dh_link
	rm 'debian/dwarf-fortress-data/usr/share/games/dwarf-fortress/gamedata/data/art/font license.txt'
# The information from these files has been incorporated into debian/copyright and having
# documentation in data directories is generally not very useful
	rm debian/dwarf-fortress-data/usr/share/games/dwarf-fortress/gamedata/data/readme.txt
	rm debian/dwarf-fortress-data/usr/share/games/dwarf-fortress/gamedata/raw/readme.txt

override_dh_installdocs-arch: debian/dwarf-fortress.docs
	dh_installdocs

override_dh_installman-arch: debian/dwarf-fortress.6
	dh_installman

override_dh_clean:
	rm -f debian/dwarf-fortress.install
	rm -f debian/dwarf-fortress.docs
	rm -f debian/dwarf-fortress.6
	dh_clean

debian/dwarf-fortress.install:
	sed -e "s/#ARCH#/${ARCH}/" debian/dwarf-fortress.install.in > debian/dwarf-fortress.install

debian/dwarf-fortress.docs:
	sed -e "s/#ARCH#/${ARCH}/" debian/dwarf-fortress.docs.in > debian/dwarf-fortress.docs

debian/%.6: debian/%.6.md
	pandoc -s -f markdown -t man "$<" > "$@"
