#!/usr/bin/make -f
# Build sshpilot with Meson, the upstream build system. Meson installs the
# launcher, the Python package, the compiled GResource, the desktop entry and
# AppStream metainfo (merged from the .in templates), the icon and
# sshpilot-agent, so none of that is replayed by hand here.

#export DH_VERBOSE = 1

include /usr/share/dpkg/architecture.mk

%:
	dh $@ --with python3 --buildsystem=meson

# dh_auto_test runs `meson test`, i.e. the desktop-entry and AppStream
# validators. The upstream pytest suite is a GUI/integration suite needing a
# display and optional backends, and Meson does not run it, so no override is
# needed here any more.

# Use the system xterm.js from libjs-xterm rather than the bundled copy: drop
# the bundled assets from the binary package (the app resolves the system
# /usr/share/javascript/xterm at runtime). Runs after dh_python3 has finalised
# the dist-packages layout so the path is stable. Keeps the .deb free of
# embedded JavaScript.
execute_after_dh_python3:
	rm -rf debian/sshpilot/usr/lib/python3*/dist-packages/sshpilot/vendor/pyxtermjs/xterm

# The bundled gtk4-frdp in /usr/lib/<triplet>/sshpilot is private to the app:
# no shlibs file for it, its libraries go into Recommends rather than Depends
# (rdp_tab.py falls back to FreeRDP's window when it cannot load), and the
# unversioned .so link is a development file nothing here uses.
override_dh_makeshlibs:
	dh_makeshlibs -Xusr/lib/$(DEB_HOST_MULTIARCH)/sshpilot

override_dh_shlibdeps:
	dh_shlibdeps -- -dRecommends

execute_after_dh_auto_install:
	rm -f debian/sshpilot/usr/lib/$(DEB_HOST_MULTIARCH)/sshpilot/libgtk4-frdp-4.0.so
