PN := dunshire
SRCS := $(PN)/*.py test/*.py

# Sphinx tries to keep track of which docs need to be built on its
# own. We could do better, but we would have to duplicate all of the
# information that we already gave Sphinx to make it work. Thus the
# "doc" target will unconditionally invoke sphinx.
.PHONY: doc
doc:
	cd doc && $(MAKE) html

# Run the doctests contained in the sphinx documentation, which aren't
# run as part of the normal test suite (because nobody wants to wait
# for sphinx to run).
.PHONY: doctest
doctest:
	cd doc && $(MAKE) doctest

# Run the test suite once.
.PHONY: check
check:
	PYTHONPATH="." test/__main__.py

# Run the test suite once, loudly. This is used in Gentoo, for example
# where we want users to see the output from the test suite on the off
# chance that it fails and they have to report it.
.PHONY: check-verbose
check-verbose:
	PYTHONPATH="." test/__main__.py --verbose

# Run the test suite forever, but only the parts of it that are
# randomized.
.PHONY: check-loop
check-loop:
	PYTHONPATH="." test/__main__.py --no-doctests --loop

# Run pylint to obtain some unconstructive criticism on my coding style.
.PHONY: lint
lint:
	pylint --rcfile=./.pylintrc $(SRCS)

# Create a source distribution tarball. First we clean up, to make
# sure no junk gets added to the distribution. Then we build the docs
# so that users will get some usable HTML documentation and not just
# the source files.
.PHONY: dist
dist: clean doc
	python setup.py sdist

# Delete urrythang.
.PHONY: clean
clean:
	rm -rf $(PN)/__pycache__ test/__pycache__ doc/build
	rm -rf $(PN).egg-info
	rm -rf dist
