#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND=-DUSE_IPV6
export DEB_CFLAGS_MAINT_APPEND=-fno-strength-reduce -fsigned-char

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

include /usr/share/dpkg/buildtools.mk
export CC

DESTDIR=$(CURDIR)/debian/tetrinetx/

%:
	dh $@

override_dh_auto_configure:
	cp debian/config.h src/

override_dh_auto_build: bin/tetrinetx

bin/tetrinetx: $(wildcard src/*.[ch])
	$(CC) $(CPPFLAGS) $(CFLAGS) src/main.c -o $@ $(LDFLAGS) -ladns

execute_before_dh_clean:
	rm -f src/.deps/main.P bin/tetrinetx

execute_after_dh_auto_install:
	install -o games -g games -m 0755 bin/tetrinetx $(DESTDIR)/usr/games/tetrinetx
	install -o games -g games -m 0644 bin/game.motd bin/game.pmotd bin/game.conf $(DESTDIR)etc/tetrinetx
	install -o games -g games -m 0600 bin/game.secure $(DESTDIR)etc/tetrinetx

execute_after_dh_fixperms:
	chown -R games:games $(DESTDIR)etc/tetrinetx
