#!/usr/bin/make -f

export CARGO_VENDOR_DIR = vendor
export LIBGIT2_NO_VENDOR = 1
export LIBSSH2_SYS_USE_PKG_CONFIG = 1
export LIBSQLITE3_SYS_USE_PKG_CONFIG = 1

%:
	dh $@ --buildsystem cargo

override_dh_auto_configure:
	$(CURDIR)/debian/cargo-prune-checksums vendor/*
	dh_auto_configure

override_dh_auto_test:
	dh_auto_test -- test --all

#use lower debuginfo level on 32-bit to avoid running out of address space.
ifeq ($(DEB_HOST_ARCH_BITS),32)
execute_after_dh_auto_configure:
	sed -i s/debuginfo=2/debuginfo=1/ debian/cargo_home/config*
endif

override_dh_install:
	dh_install
	rm -rf $(CURDIR)/debian/librust-cargo-c-dev/usr/share/cargo/registry/cargo-c-*/vendor
	rm -f $(CURDIR)/debian/librust-cargo-c-dev/usr/share/cargo/registry/cargo-c-*/Cargo.lock
