#!/usr/bin/make -f

# use local fork of debcargo and dh-cargo
PATH := $(CURDIR)/debian/dh-cargo/bin:$(PATH)
PERL5LIB = $(CURDIR)/debian/dh-cargo/lib
export PATH PERL5LIB

%:
	dh $@ --buildsystem cargo

# TODO: teach dh-cargo to avoid non-main crates in main crate
# and mangle Cargo.toml for non-main crates
execute_after_dh_auto_install:
	rm -rf debian/librust-lazy-regex-dev/usr/share/cargo/registry/lazy-regex-2.*/src/proc_macros
	perl -0777 -p -i \
		-e 's/path = "src\/proc_macros"\n//;' \
		-e 's/\[workspace\][^\n]*(\n[^\[\n][^\n]*)*//g;' \
		debian/librust-lazy-regex-dev/usr/share/cargo/registry/lazy-regex-2.*/Cargo.toml
