Makefile: move list of python versions to a variable
[pyxattr.git] / Makefile
1 SPHINXOPTS    = -W
2 SPHINXBUILD   = sphinx-build
3 DOCDIR        = doc
4 DOCHTML       = $(DOCDIR)/html
5 DOCTREES      = $(DOCDIR)/doctrees
6 ALLSPHINXOPTS = -d $(DOCTREES) $(SPHINXOPTS) $(DOCDIR)
7
8 MODNAME = xattr.so
9 RSTFILES = doc/index.rst doc/module.rst NEWS README.rst doc/conf.py
10 PYVERS = 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7
11
12 all: doc test
13
14 $(MODNAME): xattr.c
15         ./setup.py build_ext --inplace
16
17 $(DOCHTML)/index.html: $(MODNAME) $(RSTFILES)
18         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCHTML)
19         touch $@
20
21 doc: $(DOCHTML)/index.html
22
23 dist:
24         fakeroot ./setup.py sdist
25
26 test:
27         @for ver in $(PYVERS); do \
28           for flavour in "" "-dbg"; do \
29             if type python$$ver$$flavour >/dev/null; then \
30               echo Testing with python$$ver$$flavour; \
31               python$$ver$$flavour ./setup.py test -q; \
32             fi; \
33           done; \
34         done;
35         @if type pypy >/dev/null; then \
36           echo Testing with pypy; \
37           pypy ./setup.py test -q; \
38         fi
39
40 benchmark: $(MODNAME)
41         @set -e; \
42         TESTFILE=`mktemp`;\
43         trap 'rm $$TESTFILE' EXIT; \
44         for ver in $(PYVERS) ; do \
45             if type python$$ver >/dev/null; then \
46               echo Benchmarking with python$$ver; \
47               python$$ver ./setup.py build -q; \
48               echo "  - set (with override)"; \
49               python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
50               echo "  - list"; \
51               python$$ver -m timeit -s 'import xattr' "xattr.list('$$TESTFILE')"; \
52               echo "  - get"; \
53               python$$ver -m timeit -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
54               echo "  - set + remove"; \
55               python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
56             fi; \
57         done;
58
59 coverage:
60         $(MAKE) clean
61         $(MAKE) test CFLAGS="-coverage"
62         lcov --capture --directory . --output-file coverage.info
63         genhtml coverage.info --output-directory out
64
65 clean:
66         rm -rf $(DOCHTML) $(DOCTREES)
67         rm -f $(MODNAME)
68         rm -f *.so
69         rm -rf build
70
71 .PHONY: doc test clean dist coverage