#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export QT_SELECT := 6
export INSTALL_PREFIX  = /usr
export INSTALL_DESTDIR = /debian/tmp$(INSTALL_PREFIX)

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_SKIP_RPATH:BOOL=ON

override_dh_install:
	find $(CURDIR)/ -type f -name '*.so' -or -name 'DigitalClock5'
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/app/DigitalClock5 $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/DigitalClock5
	install -dm 0755 $(CURDIR)$(INSTALL_DESTDIR)/bin
	ln -sf $(INSTALL_PREFIX)/libexec/DigitalClock5/DigitalClock5 $(CURDIR)$(INSTALL_DESTDIR)/bin/DigitalClock5
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/clock_common/libClockCommon.so $(CURDIR)$(INSTALL_DESTDIR)/lib/$(DEB_HOST_MULTIARCH)/libClockCommon.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugin_core/libPluginCore.so $(CURDIR)$(INSTALL_DESTDIR)/lib/$(DEB_HOST_MULTIARCH)/libPluginCore.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/skin_engine/libSkinEngine.so $(CURDIR)$(INSTALL_DESTDIR)/lib/$(DEB_HOST_MULTIARCH)/libSkinEngine.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/any_zoom/any_zoom.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/any_zoom.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/date/date.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/date.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/ip_address/ip_address.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/ip_address.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/quick_note/quick_note.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/quick_note.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/random_position/random_position.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/random_position.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/spectrum_clock/spectrum_clock.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/spectrum_clock.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/stopwatch/stopwatch.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/stopwatch.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/talking_clock/talking_clock.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/talking_clock.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/time_zone/time_zone.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/time_zone.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/var_translucency/var_translucency.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/var_translucency.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/chime/chime.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/chime.so
	install -Dm 0755 $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)/plugins/countdown_timer/countdown_timer.so $(CURDIR)$(INSTALL_DESTDIR)/libexec/DigitalClock5/plugins/countdown_timer.so
	install -dm 0755 $(CURDIR)$(INSTALL_DESTDIR)/share/DigitalClock5/
	unzip -q $(CURDIR)/../SOURCES/skins.zip -d $(CURDIR)$(INSTALL_DESTDIR)/share/DigitalClock5/
	install -dm 0755 $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/
	unzip -q $(CURDIR)/../SOURCES/icons.zip -d $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/
	install -Dm 0644 $(CURDIR)/../SOURCES/DigitalClock5.desktop $(CURDIR)$(INSTALL_DESTDIR)/share/applications/DigitalClock5.desktop
	dh_install --

override_dh_missing:
	dh_missing --fail-missing
