#!/usr/bin/make -f

export CSYNC_DIR=/usr/include/ocsync
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')

%:
	dh $@ --parallel --with sphinxdoc --with pkgkde_symbolshelper

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	mkdir obj-$(DEB_HOST_GNU_TYPE)/config
	XDG_CONFIG_HOME=$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/config dh_auto_test --max-parallel=1
	rm -r obj-$(DEB_HOST_GNU_TYPE)/config
else
	@echo "** tests disabled"
endif

override_dh_auto_configure-arch:
	dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr -DUNIT_TESTING=ON -DDEBIAN_VERSION=$(DEBVERS)

override_dh_auto_configure-indep:
	dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr -DWITH_DOC=ON -DUNIT_TESTING=ON -DDEBIAN_VERSION=$(DEBVERS)

override_dh_auto_build-arch:
	dh_auto_build --
	dh_auto_build -- doc-man

override_dh_install:
	dh_install --list-missing \
		-Xusr/share/doc/mirall/latex \
		-Xusr/share/doc/mirall/qthelp \
		-Xusr/share/doc/mirall/html \
		-Xusr/share/man/man/owncloudcmd.1 \
		-Xusr/share/man/man/owncloud.1

override_dh_sphinxdoc-arch:

build: build-indep
