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


export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@

build-indep:
	# pass

override_dh_clean-arch:
	dh_clean -a
	$(RM) DDNet*.png

override_dh_auto_configure-arch:
	dh_auto_configure -a -- \
		-DMYSQL=ON -DWEBSOCKETS=ON -DPREFER_BUNDLED_LIBS=OFF

override_dh_auto_install-arch:
	cd obj-$(DEB_BUILD_GNU_TYPE) && DESTDIR=$(CURDIR)/debian/tmp cmake -DCOMPONENT=portable -P cmake_install.cmake

override_dh_install-indep:
	dh_install -i
	for f in languages/license.txt languages/scripts; do \
		rm -rf "debian/ddnet-data/usr/share/games/ddnet/data/$$f"; \
	done
	for exe in DDNet; do \
		icns2png -x other/icons/$${exe}.icns; \
		for px in 16 32 48 128 256 512; do \
			size=$${px}x$${px}; \
			fn=$${exe}_$${size}x32.png; \
			if [ -f $${fn} ]; then \
				dir=debian/ddnet-data/usr/share/icons/hicolor/$${size}/apps/; \
				mkdir -p $${dir}; \
				mv $${fn} $${dir}/$${exe}.png; \
			fi; \
		done; \
	done
