#!/usr/bin/make -f

GUIDEDIR=$(CURDIR)/Users_Guide
DOCDIR=$(CURDIR)/debian/publican/usr/share/doc/publican

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure
	if [ ! -f META.yml.dist ]; then cp -f META.yml META.yml.dist; fi

override_dh_auto_build:
	dh_auto_build
	cd $(GUIDEDIR) && \
	perl -I $(CURDIR)/blib/lib $(CURDIR)/blib/script/publican build \
	   --formats=html-desktop --publish --langs=all \
	   --common_config="$(CURDIR)/blib/datadir" \
	   --common_content="$(CURDIR)/blib/datadir/Common_Content"
ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# The tests build files that we install as example, if they are
	# not run do it ourselves
	cd $(GUIDEDIR) && \
	perl -I $(CURDIR)/blib/lib $(CURDIR)/blib/script/publican update_pot
	cd $(GUIDEDIR) && \
	perl -I $(CURDIR)/blib/lib $(CURDIR)/blib/script/publican update_po \
		--langs=de-DE
endif

override_dh_installdocs:
	dh_installdocs
	mv $(GUIDEDIR)/publish $(DOCDIR)/Users_Guide

override_dh_compress:
	# Examples dir contain files that should not be compressed
	# otherwise publican will not recognize them
	dh_compress -X/examples/

override_dh_auto_clean:
	dh_auto_clean
	# Created and not cleaned by t/910.publican.Users_Guide.t
	rm -rf $(GUIDEDIR)/de-DE $(GUIDEDIR)/pot

	# Removed during build process.
	if [ -f META.yml.dist ]; then mv -f META.yml.dist META.yml; fi
