#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# one ring to rule them all ...
%:
	dh $@


override_dh_auto_build:
	# first the non-gui parts
	cp common/notgui.inc common/isgui.inc
	# and now the gui parts
	cp common/gui.inc common/isgui.inc
	lazbuild --build-all --ws=qt5 --pcp=/etc/lazarus mricron.lpi
	mv ./MRIcron mricron
	# build icon
	convert iconfinal.ico -resize 32x32 iconfinal.xpm
	mv iconfinal-0.xpm mricron.xpm || mv iconfinal.xpm mricron.xpm

# we want immediately useable docs and example data, they are in a dedicated
# package already
override_dh_compress:
	dh_compress -X.voi
	-find debian/mricron-data/usr/share/mricron/ -type f -exec chmod -x {} \;
	-find debian/mricron-doc/usr/share/doc/mricron/examples -type f -exec chmod -x {} \;

override_dh_dwz:
	echo "Lazarus code does not export debug symbols"

override_dh_clean:
	find . -name '*.o' -delete -o -name '*.ppu' -delete -o -name '*.a' -delete
	find . -name '*.compiled' -delete
	find . -name '*.or' -delete
	-rm mricron.rc mricron.lrs mricron
	-rm iconfinal*.xpm mricron.xpm
	-rm text.lrs
	dh_clean


# there is no way to get previous versions
get-orig-source: get-latest-source
get-latest-source:
	wget http://www.mccauslandcenter.sc.edu/CRNL/sw/mricron/source.zip
	bash debian/repack.sh source.zip
