#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
# export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
include /usr/share/debhelper/dh_package_notes/package-notes.mk

%:
	dh "${@}" --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build -- \
		-DWITH_BINDINGS:BOOL=ON \
		-DWITH_GTKDOC:BOOL=ON \
		-DWITH_HTML:BOOL=ON \
		-DWITH_MAN:BOOL=ON \
		-DENABLE_RHSM_SUPPORT:BOOL=OFF \
		-DENABLE_SOLV_URPMREORDER:BOOL=OFF \
		-DWITH_ZCHUNK:BOOL=OFF \
		-DCMAKE_INSTALL_PREFIX:PATH="/usr" \
		-DLIB:STRING="lib/$(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)"

	sed -i -e '/^@LIBSMARTCOLS_COMPAT@/s/^@LIBSMARTCOLS_COMPAT@/\/\//' 'libdnf/utils/smartcols/Cell.hpp'; \

override_dh_auto_build:
	dh_auto_build --builddirectory=build -- all doc-html doc-gtk doc

override_dh_auto_install:
	dh_auto_install --builddirectory=build

	# Remove doctree files (redundant, conflicts with reproducible builds)
	rm -rfv 'build/docs/hawkey/html/.doctrees'

	# Use system-provides files.
	rm -fv 'build/docs/hawkey/html/_static/jquery.js' \
	       'build/docs/hawkey/html/_static/underscore.js' \
	       'build/docs/hawkey/html/_static/doctools.js' \
	       'build/docs/hawkey/html/_static/language_data.js' \
	       'build/docs/hawkey/html/_static/searchtools.js'

override_dh_auto_clean:
	rm -f 'libdnf/dnf-version.h'
	dh_auto_clean --builddirectory=build

override_dh_auto_test:
	#mkdir -p '$(CURDIR)/debian/tests-home'
	#LC_ALL=C HOME='$(CURDIR)/debian/tests-home' dh_auto_test --builddirectory=build -- ARGS='-V'

override_dh_installchangelogs:
	# Do not try to install a history directory within docs.
	dh_installchangelogs -Xhistory
