#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

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 $@


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

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

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
	convert -resize 128x128 debian/tmp/usr/share/icons/hicolor/128x128/apps/enlightenment_fprint.png debian/tmp/usr/share/icons/hicolor/128x128/apps/enlightenment_fprint.png
	convert -resize 128x128 debian/tmp/usr/share/icons/hicolor/128x128/apps/enlightenment_paledit.png debian/tmp/usr/share/icons/hicolor/128x128/apps/enlightenment_paledit.png
	install -m 0644 -D debian/enlightenment-portals.conf debian/tmp/usr/share/xdg-desktop-portal/enlightenment-portals.conf
	mv debian/tmp/usr/share/wayland-sessions/enlightenment.desktop \
		debian/tmp/usr/share/wayland-sessions/enlightenment-wayland.desktop

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