#!/usr/bin/make -f
#export DH_VERBOSE = 1


export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic -O3
export DEB_LDFLAGS_MAINT_APPEND =

include /usr/share/dpkg/architecture.mk

ifeq ($(DEB_HOST_ARCH),ia64)
  # gcc o3 segfault on ia64
  # It's just annoying, not a sign I'll care about ia64
  export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic
endif


%:
	dh $@

build-indep:
	# pass

execute_after_dh_auto_clean-indep:
	$(RM) -r datasrc/__pycache__ datasrc/seven/__pycache__

override_dh_auto_configure-arch:
	dh_auto_configure -a -- \
		-DMYSQL=ON -DAUTOUPDATE=OFF \
		-DTESTRUNNER_ARGS=--gtest_filter=-Jobs.LookupHost

override_dh_auto_test-arch:
	+cd obj-$(DEB_BUILD_GNU_TYPE) && make run_tests

override_dh_auto_install-indep:
	for px in 16 32 48 128 256 512; do \
		size=$${px}x$${px}; \
		fn=other/icons/DDNet_$${size}x32.png; \
		if [ -f $${fn} ]; then \
			dir=debian/tmp/usr/share/icons/hicolor/$${size}/apps/; \
			mkdir -p $${dir}; \
			cp $${fn} $${dir}/ddnet.png; \
		fi; \
	done;

execute_after_dh_install-indep:
	for f in assets/entities/license.txt languages/license.txt maps/license.txt skins/license.txt; do \
		$(RM) "debian/ddnet-data/usr/share/games/ddnet/data/$$f"; \
	done
