#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_BUILD_MAINT_OPTIONS=reproducible=-timeless

LD_LIBRARY_PATH += debian/libexpeyes1/usr/lib
export DEB_BUILD_HARDENING=1
#export CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2"

export QT_SELECT := 5

%:
	dh $@ --with python3

HOME = $(CURDIR)/debian/build
override_dh_auto_build-arch:
	mkdir $(CURDIR)/debian/build
	$(MAKE) all_arch HOME=$(HOME)
	rm -rf $(CURDIR)/debian/build

override_dh_auto_build-indep:
	$(MAKE) all_indep

override_dh_auto_clean:
	dh_auto_clean
	# the clean process compiles a few Python scripts
	find . -name __pycache__ | xargs rm -rf
	rm -rf $(HOME)

DocDir = $(CURDIR)/debian/eyes17/usr/share/expeyes/doc
DocDirSource = $(CURDIR)/ExpEYES17/UserManual

override_dh_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	find $(CURDIR)/debian/tmp -name "*.pdf" -exec chmod -x {} \;
	dh_install
	make -C po install DESTDIR=$(CURDIR)/debian/expeyes
	make -C microhope/po install DESTDIR=$(CURDIR)/debian/microhope
	# remove python files from helpFiles subdirectory
	for d in $$(find $(CURDIR)/debian -type d -name helpFiles); do \
	  for f in $$(find $$d -name '*.py'); do \
	    rm -f $$f; \
	  done; \
	done
