1PROJ=billiard
2PYTHON=python
3GIT=git
4TOX=tox
5NOSETESTS=nosetests
6ICONV=iconv
7FLAKE8=flake8
8FLAKEPLUS=flakeplus
9SPHINX2RST=sphinx2rst
10
11SPHINX_DIR=docs/
12SPHINX_BUILDDIR="${SPHINX_DIR}/_build"
13README=README.rst
14README_SRC="docs/templates/readme.txt"
15CONTRIBUTING=CONTRIBUTING.rst
16CONTRIBUTING_SRC="docs/contributing.rst"
17SPHINX_HTMLDIR="${SPHINX_BUILDDIR}/html"
18DOCUMENTATION=Documentation
19FLAKEPLUSTARGET=2.7
20
21all: help
22
23help:
24	@echo "docs                 - Build documentation."
25	@echo "test-all             - Run tests for all supported python versions."
26	@echo "distcheck ---------- - Check distribution for problems."
27	@echo "  test               - Run unittests using current python."
28	@echo "  lint ------------  - Check codebase for problems."
29	@echo "    apicheck         - Check API reference coverage."
30	@echo "    configcheck      - Check configuration reference coverage."
31	@echo "    readmecheck      - Check README.rst encoding."
32	@echo "    contribcheck     - Check CONTRIBUTING.rst encoding"
33	@echo "    flakes --------  - Check code for syntax and style errors."
34	@echo "      flakecheck     - Run flake8 on the source code."
35	@echo "      flakepluscheck - Run flakeplus on the source code."
36	@echo "readme               - Regenerate README.rst file."
37	@echo "contrib              - Regenerate CONTRIBUTING.rst file"
38	@echo "clean-dist --------- - Clean all distribution build artifacts."
39	@echo "  clean-git-force    - Remove all uncomitted files."
40	@echo "  clean ------------ - Non-destructive clean"
41	@echo "    clean-pyc        - Remove .pyc/__pycache__ files"
42	@echo "    clean-docs       - Remove documentation build artifacts."
43	@echo "    clean-build      - Remove setup artifacts."
44
45clean: clean-docs clean-pyc clean-build
46
47clean-dist: clean clean-git-force
48
49Documentation:
50	(cd "$(SPHINX_DIR)"; $(MAKE) html)
51	mv "$(SPHINX_HTMLDIR)" $(DOCUMENTATION)
52
53docs: Documentation
54
55clean-docs:
56	-rm -rf "$(SPHINX_BUILDDIR)"
57
58lint: flakecheck apicheck configcheck readmecheck
59
60apicheck:
61	(cd "$(SPHINX_DIR)"; $(MAKE) apicheck)
62
63configcheck:
64	(cd "$(SPHINX_DIR)"; $(MAKE) configcheck)
65
66flakecheck:
67	$(FLAKE8) "$(PROJ)"
68
69flakediag:
70	-$(MAKE) flakecheck
71
72flakepluscheck:
73	$(FLAKEPLUS) --$(FLAKEPLUSTARGET) "$(PROJ)"
74
75flakeplusdiag:
76	-$(MAKE) flakepluscheck
77
78flakes: flakediag flakeplusdiag
79
80clean-readme:
81	-rm -f $(README)
82
83readmecheck:
84	$(ICONV) -f ascii -t ascii $(README) >/dev/null
85
86$(README):
87	$(SPHINX2RST) "$(README_SRC)" --ascii > $@
88
89readme: clean-readme $(README) readmecheck
90
91clean-contrib:
92	-rm -f "$(CONTRIBUTING)"
93
94$(CONTRIBUTING):
95	$(SPHINX2RST) "$(CONTRIBUTING_SRC)" > $@
96
97contrib: clean-contrib $(CONTRIBUTING)
98
99clean-pyc:
100	-find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm
101	-find . -type d -name "__pycache__" | xargs rm -r
102
103removepyc: clean-pyc
104
105clean-build:
106	rm -rf build/ dist/ .eggs/ *.egg-info/ .tox/ .coverage cover/
107
108clean-git:
109	$(GIT) clean -xdn
110
111clean-git-force:
112	$(GIT) clean -xdf
113
114test-all: clean-pyc
115	$(TOX)
116
117test:
118	tox -e py
119
120cov:
121	$(NOSETESTS) -xv --with-coverage --cover-html --cover-branch
122
123build:
124	$(PYTHON) setup.py sdist bdist_wheel
125
126distcheck: lint test clean
127
128dist: readme contrib clean-dist build
129