#!/usr/bin/make -f

# Noble supplies newer Rust as versioned packages; newer Ubuntu uses its default.
export PATH := /usr/lib/rust-1.91/bin:$(PATH)
export CARGO_HOME = $(CURDIR)/debian/cargo-home
export CARGO_NET_OFFLINE = true
export CARGO_TARGET_DIR = $(CURDIR)/target
export RUSTC_BOOTSTRAP = 1

%:
	dh $@ --buildsystem=none

override_dh_auto_build:
	cargo --config .copr/cargo-config.toml --config .cargo/vendor.toml build --frozen --release --bin dillo

override_dh_auto_test:
	target/release/dillo --help > /dev/null

override_dh_auto_install:
	install -Dm0755 target/release/dillo debian/dillo-vm/usr/bin/dillo

override_dh_installdocs:
	dh_installdocs LICENSE NOTICE
	find vendor -type f \( -iname 'license*' -o -iname 'licence*' -o \
	    -iname 'copying*' -o -iname 'notice*' -o -iname 'copyright*' \) \
	    -exec install -Dm0644 '{}' 'debian/dillo-vm/usr/share/doc/dillo-vm/dependency-licenses/{}' \;

override_dh_auto_clean:
	rm -rf target debian/cargo-home

# Cargo checksums include vendored Cargo.toml.orig files.
override_dh_clean:
	dh_clean -Xvendor/
