#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_TARGET_MULTIARCH ?= $(shell dpkg-architecture -qDEB_TARGET_MULTIARCH)
export MESON_BUILD_DIR=obj-$(DEB_HOST_GNU_TYPE)


%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --verbose -- \
		-Dwl=true

execute_before_dh_lintian:
	# meson puts the arch-specific module dir in config.h
	E_MODULE_ARCH=`awk '/MODULE_ARCH/{print $$3}' $(MESON_BUILD_DIR)/config.h | xargs echo`; \
	sed -e "s/MULTIARCH/$(DEB_TARGET_MULTIARCH)/" \
		-e "s/ARCH_PATH/$$E_MODULE_ARCH/" \
		debian/enlightenment.lintian-overrides.in > debian/enlightenment.lintian-overrides

execute_before_dh_install:
	rm -f debian/tmp/usr/share/enlightenment/COPYING
	gzip -9n debian/tmp/usr/share/enlightenment/doc/*.txt
	convert -resize 128x128 debian/tmp/usr/share/icons/hicolor/128x128/apps/emixer.png debian/tmp/usr/share/icons/hicolor/128x128/apps/emixer.png

execute_after_dh_fixperms-arch:
	chmod 4755 debian/enlightenment/usr/lib/*/enlightenment/utils/enlightenment_sys \
		debian/enlightenment/usr/lib/*/enlightenment/utils/enlightenment_system \
		debian/enlightenment/usr/lib/*/enlightenment/utils/enlightenment_ckpasswd

execute_after_dh_clean:
	rm -f debian/enlightenment.lintian-overrides