#!/usr/bin/make -f

WINDRES=/usr/bin/i686-w64-mingw32-windres

%:
	dh $@

DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
ifeq ($(DEB_HOST_GNU_CPU),i586)
DEB_HOST_GNU_CPU := i386
endif
ifeq ($(DEB_HOST_GNU_CPU),i686)
DEB_HOST_GNU_CPU := i386
endif
ifeq ($(DEB_HOST_GNU_CPU),powerpc64le)
DEB_HOST_GNU_CPU := powerpc64
endif
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

%.res: %.rc
	$(WINDRES) $< $@

%.lrs: %.lfm
	lazres $@ $<

override_dh_auto_build: fpcmagnifier.res magnifier.res startform.lrs
	fpc -S2cgi -O1 -gl -vewnhi -l \
	  -Fu/usr/lib/lazarus/default/lcl/units/$(DEB_HOST_GNU_CPU)-$(DEB_HOST_ARCH_OS)/ \
	  -Fu/usr/lib/lazarus/default/lcl/units/$(DEB_HOST_GNU_CPU)-$(DEB_HOST_ARCH_OS)/gtk2/ \
	  -Fu/usr/lib/lazarus/default/packager/units/$(DEB_HOST_GNU_CPU)-$(DEB_HOST_ARCH_OS)/ \
	  -Fu/usr/lib/lazarus/default/components/lazutils/lib/$(DEB_HOST_GNU_CPU)-$(DEB_HOST_ARCH_OS)/ \
	  -Fu. -o./vmg -dLCL -dLCLgtk2 magnifier.dpr

override_dh_auto_install:
	:

override_dh_auto_clean:
	./clean.sh
	-rm -f magnifier.or *.res *.lrs vmg
