NAME=pypol

PYTHON=python3
SETUP=$(PYTHON) setup.py
RM=rm -rf

.PHONY: default
default:
	@echo "$(NAME) – A polyhedral library based on ISL"
	@echo
	@echo "Makefile usage:"
	@echo "  make build            build the extension modules"
	@echo "  make test             run the test suite"
	@echo "  make doc              generate the documentation"
	@echo "  make view_doc         open the documentation index"
	@echo "  make clean            remove the generated files"

.PHONY: build
build:
	$(SETUP) build_ext --inplace

.PHONY: test
test: build
	$(PYTHON) -m unittest -v

.PHONY: doc
doc:
	$(MAKE) -C doc html

.PHONY: view_doc
view_doc: doc
	xdg-open doc/_build/html/index.html >/dev/null 2>&1

.PHONY: clean
clean:
	$(RM) build dist MANIFEST venv $(NAME).egg-info $(NAME)/_islhelper.*.so
	find . -name __pycache__ | xargs $(RM)
	$(MAKE) -C doc $@