#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

ifeq ($(DEB_HOST_ARCH_BITS),32)
export DEB_BUILD_OPTIONS += optimize=+lto
endif

%:
	dh $@ --buildsystem cargo --with shell_completions

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/debian/manpages $(CURDIR)/debian/build_artifacts

override_dh_auto_install:
	install -D -m 0644 $(CURDIR)/man/page $(CURDIR)/debian/manpages/broot.1
	sed -i -e "s/#version/$(DEB_VERSION_UPSTREAM)/g" -e "s/#date/$(shell date --utc --date="@$(SOURCE_DATE_EPOCH)" +'%Y')/g" \
		$(CURDIR)/debian/manpages/broot.1
	dh_auto_install

override_dh_auto_test:
	dh_auto_test -- test --all
