#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

%:
	dh $@ --parallel --sourcedirectory=src

override_dh_auto_clean:
	$(MAKE) -C src/ clean-client clean-server
	rm -rf enet

override_dh_auto_build:
	mkdir -p enet/include
	dh_auto_build -- \
		CXXFLAGS="$(CXXFLAGS) $(CPPFLAGS) -ffast-math" \
		LIBENET="" \
		client server

override_dh_auto_install:
	$(MAKE) -C src/ \
		LIBENET="" \
		DESTDIR=$(CURDIR)/debian/tmp \
		prefix=/usr games=/games gamesbin=/games \
		system-install-client system-install-server \
		system-install-common system-install-docs system-install-menus

override_dh_install:
	dh_install -predeclipse
	dh_install -predeclipse-server
	dh_install -predeclipse-common --exclude=play.cfg

override_dh_compress:
	dh_compress --exclude=.cfg --exclude=guidelines.txt

get-orig-source:
	uscan --noconf --rename --repack --compression xz --force-download --download-current-version --destdir=.
