#!/usr/bin/make -f

# dolphin does not work with -fPIE
export DEB_BUILD_MAINT_OPTIONS := hardening=+all,-pie

# distributor is used by the opt-in analytics
ifeq ($(shell dpkg-vendor --derives-from Ubuntu; echo $$?),0)
	DISTRIBUTOR := ubuntu.com
else
	DISTRIBUTOR := debian.org
endif

CMAKE_OPTIONS := \
	-Dbindir=/usr/games \
	-Ddatadir=/usr/share/games/dolphin-emu \
	-DDISTRIBUTOR=$(DISTRIBUTOR) \
	-DUSE_SHARED_ENET=ON \
	-DUSE_DISCORD_PRESENCE=0 \
	-DUSE_MGBA=1 \
	-DENABLE_TESTS=1 \
	-DGTEST_DIR=/usr/src/gtest \
	-DDOLPHIN_WC_BRANCH=master -DDOLPHIN_WC_DESCRIBE=5.0-17995-g8bad821019 -DDOLPHIN_WC_REVISION=8bad821019721b9b72701b495da95656ace5fea5

%:
	dh $@ -Bbuild

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_OPTIONS)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	CTEST_OUTPUT_ON_FAILURE=1 $(MAKE) -C build unittests
endif
