#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export CEF_PATH = /usr/lib/x86_64-linux-gnu
# Add RUNPATH so GPU subprocess finds CEF's ANGLE libraries before Mesa
export RUSTFLAGS = -C link-arg=-Wl,-rpath,/usr/lib/x86_64-linux-gnu/cef
# Generate debug symbols for dbgsym package
export CARGO_PROFILE_RELEASE_DEBUG = true

%:
	dh $@

override_dh_auto_build:
	cargo build --release --features offline-build

# Install binary with stremio-gtk name (dh_install handles the rest via .install file)
override_dh_auto_install:
	install -D -m755 target/release/stremio-linux-shell $(CURDIR)/debian/stremio-gtk/usr/libexec/stremio-gtk/stremio-gtk-bin

override_dh_auto_test:

override_dh_auto_clean:
	rm -rf target

# Preserve *.orig files needed by cargo checksums
# Note: Do NOT call dh_quilt_unpatch explicitly - it runs at wrong time
# in dpkg-buildpackage sequence (after patches applied, before build).
# debhelper handles quilt automatically via dpkg-source --after-build.
override_dh_clean:
	dh_clean -X.orig
