#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CPPFLAGS_MAINT_APPEND := -D_GNU_SOURCE

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		--disable-gdkpixbuf-plugin \
		--disable-pulseaudio

ifeq ($(DEB_HOST_ARCH),sh4)
execute_before_dh_auto_build:
	# GCC 16 fails to allocate a register in JESS stars_create_state on sh4.
	# Prebuild only this object with -O1; the normal build reuses it.
	# Revisit when sh4 buildds default to GCC 17 or a fixed GCC 16.
	# Remove this hook after verifying a build with normal -O2 flags.
	dh_auto_build -- -C plugins/actor/JESS draw.lo \
		CFLAGS="$(shell dpkg-buildflags --get CFLAGS) -O1"
endif

execute_before_dh_auto_install:
	cd po && make de.gmo

execute_after_dh_auto_install:
	find debian/libvisual-0.4-plugins -name '*.la' -exec rm -f {} \;
