#!/usr/bin/make -f
# Based on the initial work of Joey Hess and Craig Small.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# Set path to this directory so that our tweaked fop script is used.
PATH := $(CURDIR)/doc/user-manuals/scripts:$(PATH)
$(info PATH: $(PATH))


#!/usr/bin/make -f
%:
	dh $@

# Required to stop it from calling my convenience Makefile that is only used for
# my day-to-day work.
override_dh_auto_clean:

override_dh_clean:
	dh_clean
	rm -rf debian/build
	rm -rf debian/tmp

override_dh_auto_configure:
	mkdir -p debian/build
	mkdir -p debian/tmp
	cd debian/build && cmake -DOPENMP=1 -DDEBUG=1 -DDEVMODE=0 -DBUILD_USER_MANUALS=1 -DTESTS=0 -DCMAKE_INSTALL_PREFIX=/usr ../..

	# Ensure that the fop.xconf file is found in the DC* files
	# that are located in $(CURDIR)/doc/user-manuals
	cd doc/user-manuals/massxpert && \
		sed -i 's|/home/rusconi/.fop/fop.xconf|$(CURDIR)/doc/user-manuals/fop.xconf|' DC-massxpert-user-manual

	cd doc/user-manuals/minexpert && \
		sed -i 's|/home/rusconi/.fop/fop.xconf|$(CURDIR)/doc/user-manuals/fop.xconf|' DC-minexpert-user-manual

override_dh_auto_build:
	cd debian/build && make

override_dh_auto_install:
	cd debian/build && DESTDIR=../tmp make install
	dh_install
