#!/usr/bin/make -f

export CARGO_HOME = $(CURDIR)/debian/cargo
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Don't use paths that may change between builds.
# No need to care about $HOME
# because Cargo will not place any source in ~/.cargo.
# The build directory is a subdirectory of the source directory,
# so it doesn't need to be explicitly taken care of.
RUSTFLAGS = --remap-path-prefix=$(CURDIR)=/remap-pwd

ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	RUSTFLAGS += -C opt-level=3
endif

export RUSTFLAGS

distrel := $(shell lsb_release --codename --short)
ifneq (,$(filter $(distrel),sid))
	newer = true
else
	newer = false
endif

%:
	dh $@ --builddirectory=_build --buildsystem=meson

# The Debian version of linked-hash-map doesn't provide any hash,
# causing Cargo to refuse to build with a crates.io copy
override_dh_auto_configure:
	[ ! -f Cargo.lock ] || rm Cargo.lock
	dh_auto_configure -- -Dnewer=$(newer) -Donline=false

override_dh_autoreconf:
