#!/usr/bin/make -f

%:
	dh $@ --with python3

override_dh_auto_clean:
	dh_auto_clean
	cd ptuxrepo.d && python3 setup.py clean -a
	cd src && python3 setup.py clean -a

override_dh_auto_build:
	dh_auto_build
	cd ptuxrepo.d && python3 setup.py build --force
	cd src && python3 setup.py build --force

devscripts_bin := debian/devscripts-ptux/usr/bin/
devscripts_share := debian/devscripts-ptux/usr/share/devscripts-ptux
templates := dh-make-ptux/templates-native-gpl3
ptuxrepo_lib := debian/ptuxrepo/usr/lib/ptuxrepo

override_dh_auto_install:
	dh_auto_install
	cd ptuxrepo.d && python3 setup.py install \
		--force \
		--root=../debian/ptuxrepo \
		--no-compile \
		-O0 \
		--install-layout=deb
	mkdir -p $(ptuxrepo_lib)
	cp -a ptuxrepo.d/aptly $(ptuxrepo_lib)

	cd src && python3 setup.py install \
		--force \
		--root=../debian/devscripts-ptux \
		--no-compile \
		-O0 \
		--install-layout=deb

	install -d $(devscripts_bin)
	find . -maxdepth 1 -type f -name 'ptux*' | xargs install -t $(devscripts_bin)
	install dh-make-ptux/dh-make-ptux $(devscripts_bin)
	install -d $(devscripts_share)/$(templates)
	install -m644 $(templates)/* $(devscripts_share)/$(templates)
	install -m644 ptux.conf $(devscripts_share)
