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

# Include for DEB_VERSION_UPSTREAM below
include /usr/share/dpkg/pkg-info.mk

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
CFLAGS+=$(CPPFLAGS)
CXXFLAGS+=$(CPPFLAGS)

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


%:
	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
	rm -f libmass/libmass.a
	rm -f libmassgui/libmassgui.a
	rm -f compile_commands.json
	rm -f doc/user-manual/DC-user-manual
	rm -f doc/user-manual/minexpert2-doc.pdf

override_dh_auto_configure:
	mkdir -p debian/build
	mkdir -p debian/tmp
	cd debian/build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_USER_MANUAL=1 -DCMAKE_INSTALL_PREFIX=/usr ../..

override_dh_auto_build:
	cd debian/build && make
	cd debian/build && make user-manual

override_dh_compress:
	dh_compress -X.pdf

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