PYTHON ?= python3
VERSION := $(shell cat VERSION)
NAME := phs-security-suite-$(VERSION)

.PHONY: compile test check package rpm clean

compile:
	$(PYTHON) -m compileall -q phs phs-security.py service-runner.py

test:
	PYTHONPATH=. $(PYTHON) -m unittest discover -s tests -v

check: compile test
	bash -n install.sh uninstall.sh build-rpm.sh install-whm-plugin.sh uninstall-whm-plugin.sh deploy-fleet.sh hotfix-dns-1.1.1.sh phs-security-ui-hotfix-1.2.0.sh
	$(PYTHON) -m py_compile whm-plugin/cgi/index.cgi

package: check
	cd .. && tar --exclude='__pycache__' --exclude='*.pyc' -czf $(NAME).tar.gz $(NAME)

rpm: check
	./build-rpm.sh

clean:
	find . -type d -name __pycache__ -prune -exec rm -rf {} +
	find . -type f -name '*.pyc' -delete
	rm -rf build dist
