#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed

# The following was previously used when building with local libkipi, libkexiv2, and libkdcraw implementation
#CONFLICTS_SUBSTVAR := libkipi-data, libkexiv2-data, libkdcraw-data, libksane-data

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Augment path to find gphoto2-config; workaround for #826166
export PATH := $(PATH):/usr/lib/$(DEB_HOST_MULTIARCH)/libgphoto2-dev/bin

%:
	dh $@ --with kf5 --parallel

override_dh_clean:
ifneq (,$(findstring git,$(DEB_VERSION_UPSTREAM)))
	# When building a git snapshot adjust the tarball to include the entire
	# Digikam software collection, just like a release tarball would.
	ruby debian/git_extend_orig.rb
	# There are no translations for git builds alas
	sed -i '/locale/d' debian/digikam-data.install
endif
	rm -f core/data/about/js/bootstrap.min.js core/data/about/js/jquery.min.js
	dh_clean

override_dh_auto_configure:
	dh_auto_configure --buildsystem=kde -- \
	  -DDIGIKAMSC_COMPILE_DOC=on \
	  -DDIGIKAMSC_COMPILE_PO=on \
	  -DENABLE_MYSQLSUPPORT=ON \
	  -DENABLE_APPSTYLES=ON \
	  -DENABLE_INTERNALMYSQL=ON \
	  -DENABLE_MEDIAPLAYER=ON

override_dh_auto_install:
	dh_auto_install
	find debian/tmp/usr/lib -type l -name '*.so' -exec rm --verbose {} \;

override_dh_install:
	dh_install --fail-missing

override_dh_gencontrol:
	dh_gencontrol -- -Vdigikam:Conflicts='$(CONFLICTS_SUBSTVAR)'

# auto tests require user interaction - override
override_dh_auto_test:
