#!/usr/bin/make -f
include /usr/share/dpkg/architecture.mk

# Enable full compiler hardening (Stack protector, PIE, Fortify Source, etc.)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_gencontrol:
	# Parse the autogenerated substvars file
	@if [ -f debian/qredshift.substvars ]; then \
		WAYLAND_DEP=$$(grep -oE 'libwayland-client0[^,]*' debian/qredshift.substvars || true); \
		if [ -n "$$WAYLAND_DEP" ]; then \
			# Strip it out of the shlibs variable \
			sed -i -E "s/libwayland-client0[^,]*([, ]*)//g" debian/qredshift.substvars; \
			# Inject it safely as a custom variable \
			echo "custom:WaylandDepends=$$WAYLAND_DEP" >> debian/qredshift.substvars; \
		fi \
	fi
	# Execute the standard control generator passing the variables forward
	dh_gencontrol
	

override_dh_auto_install:
	dh_auto_install -- "INSTALL=install --strip-program="

# Skip steps since there is no autoconf or test suite
override_dh_auto_configure:
override_dh_auto_test:
