#!/usr/bin/make -f
# -*- makefile -*-
#export DH_VERBOSE=1

INSTALL_DIR = $(CURDIR)/debian/dub/
DEB_VERSION := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }')

export GITVER=$(DEB_VERSION)

export DFLAGS=-frelease -fall-instantiations

%:
	dh $@

override_dh_auto_build:
	gdmd -run $(CURDIR)/build.d \
		-g -O -wi -release

	# create manual pages
	cd $(CURDIR)/bin/ && \
		DFLAGS="-frelease -fall-instantiations -Wno-error=deprecated" \
		./dub $(CURDIR)/scripts/man/gen_man.d

override_dh_install:
	dh_install

	# install shell completions
	mkdir -p $(INSTALL_DIR)/usr/share/bash-completion/completions/
	cp $(CURDIR)/scripts/bash-completion/dub.bash $(INSTALL_DIR)/usr/share/bash-completion/completions/dub
	mkdir -p $(INSTALL_DIR)/usr/share/fish/completions/
	cp $(CURDIR)/scripts/fish-completion/dub.fish $(INSTALL_DIR)/usr/share/fish/completions/

override_dh_auto_clean:
	dh_auto_clean
	rm -f $(CURDIR)/scripts/man/*.1
