#!/usr/bin/make -f

HUGO := obj-$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)/bin/hugo

%:
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_build:
	dh_auto_build -O--buildsystem=golang
	
	$(HUGO) gen autocomplete --completionfile=debian/hugo.bash-completion
	
	$(HUGO) gen man --dir=debian/man
	# Fix man page rendering problem until the following pull request is
	# merged and packaged: https://github.com/cpuguy83/go-md2man/pull/16
	sed -e "s/^'/\\\\\\&'/" -i debian/man/hugo-server.1
	
	# TODO: Add "hugo-docs" package in the future
	$(HUGO) -s docs -d public/html --uglyURLs

override_dh_auto_install:
	dh_auto_install -O--buildsystem=golang
	dh_bash-completion -O--buildsystem=golang
