#!/usr/bin/make -f

ARCHITECTURE:=$(shell dpkg-architecture -qDEB_HOST_ARCH)

%:
	dh $@ --with bash-completion

override_dh_auto_clean:
	rm -rf kathara.build
	rm -rf kathara.dist
	find . | grep -E "(__pycache__|\.pyc|\.pyo)$$" | xargs rm -rf

override_dh_auto_configure:
	python3.10 -m venv $(CURDIR)/venv
	$(CURDIR)/venv/bin/pip3.10 install --no-index --find-links $(CURDIR)/debian/pythonLibs_$(ARCHITECTURE)/ $(CURDIR)/debian/pythonLibs_$(ARCHITECTURE)/*

override_dh_auto_build:
	$(CURDIR)/venv/bin/python3.10 -m nuitka --lto=no --show-progress --plugin-enable=pylint-warnings \
		--plugin-enable=multiprocessing --follow-imports --standalone --include-plugin-directory=Kathara --output-filename=kathara kathara.py

override_dh_auto_install:
	rm -rf $(CURDIR)/debian/kathara/usr/lib/kathara/*
	cp -r $(CURDIR)/kathara.dist/* $(CURDIR)/debian/kathara/usr/lib/kathara/
	chmod 400 $(CURDIR)/debian/kathara/usr/lib/kathara/*.so*
	chmod 755 $(CURDIR)/debian/kathara/usr/lib/kathara/kathara

override_dh_strip:
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libbz2.so.1.0
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libexpat.so.1
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libtinfo.so.6
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libz.so.1
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libtinfo.so.5
	rm -f $(CURDIR)/debian/kathara/usr/lib/kathara/libcrypto.so.1.1
