#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND =

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
export VALAFLAGS:=$(foreach w,$(CPPFLAGS) $(CFLAGS) $(LDFLAGS),-X $(w))

%:
	dh $@

# Remove broken upstream-installed man page
execute_before_dh_installman:
	rm -f debian/timeshift/usr/share/man/man1/timeshift.1*

execute_after_dh_auto_install:
	rm -rf debian/timeshift/usr/share/man/man1
	rmdir debian/timeshift/usr/share/man
	rm -f debian/timeshift/usr/bin/timeshift-uninstall

# MX don't need no stinkin' dbgsyms
override_dh_strip:
	dh_strip --no-automatic-dbgsym


# Adjust version number to reflect changes made by MX
DEB_BUILD_VERSION := $(shell dpkg-parsechangelog -S Version)
override_dh_auto_build:
	sed -i~ 's/AppVersion = .*/AppVersion = "$(DEB_BUILD_VERSION)";/' src/Gtk/AppGtk.vala src/Console/AppConsole.vala
	cp -af timeshift.pot timeshift.pot~
	dh_auto_build

# Clean build changes in source
execute_after_dh_builddeb:
	@echo Cleanup source in execute_after_dh_builddeb
	for F in timeshift.pot po/*.po src/Gtk/AppGtk.vala src/Console/AppConsole.vala; do test -f "$$F~" && mv -f "$$F~" "$$F"; done

override_dh_auto_clean:
	dh_auto_clean
	cp -af timeshift.pot timeshift.pot~
