#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

TMPDOCDIR := $(CURDIR)/doc/tmp/
XWATCH_YO := $(CURDIR)/doc/xwatch.yo

clean_tmpdocdir:
	$(RM) -rfv $(TMPDOCDIR)

override_dh_auto_build:
	dh_auto_build --sourcedirectory=src -- final "STDLFLAGS=-L/usr/lib" "RGB_FILEFLAG = -DRGB_FILE=\\\"/usr/share/xwatch/rgb.txt\\\""

override_dh_clean: clean_tmpdocdir
	$(MAKE) -C src clean
	dh_clean -X.orig src/build/ debian/xwatch/

execute_before_dh_installdocs:
	(mkdir -p $(TMPDOCDIR)/html/; cd $(TMPDOCDIR); cp $(XWATCH_YO) $(TMPDOCDIR); cp $(XWATCH_YO) $(TMPDOCDIR)/html/; yodl2txt xwatch; cd $(TMPDOCDIR)/html/; yodl2html xwatch; ln -s xwatch.html index.html; $(RM) $(TMPDOCDIR)/html/xwatch.yo )

execute_after_dh_installdocs: clean_tmpdocdir

execute_before_dh_install:
	(mkdir -p $(TMPDOCDIR); cp $(XWATCH_YO) $(TMPDOCDIR); cd $(TMPDOCDIR); yodl2man xwatch )

execute_after_dh_install: clean_tmpdocdir

%:
	dh $@

.PHONY: clean_tmpdocdir
