]> git.k1024.org Git - pyxattr.git/blob - Makefile
Switch README file to Markdown and expand it
[pyxattr.git] / Makefile
1 PYTHON        = python3
2 SPHINXOPTS    = -W
3 SPHINXBUILD   = $(PYTHON) -m sphinx
4 DOCDIR        = doc
5 DOCHTML       = $(DOCDIR)/html
6 DOCTREES      = $(DOCDIR)/doctrees
7 ALLSPHINXOPTS = -d $(DOCTREES) $(SPHINXOPTS) $(DOCDIR)
8
9 MODNAME = xattr.so
10 RSTFILES = doc/index.rst doc/module.rst doc/news.rst doc/readme.md doc/conf.py
11 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
12 REPS = 5
13
14 all: doc test
15
16 $(MODNAME): xattr.c
17         $(PYTHON) ./setup.py build_ext --inplace
18
19 $(DOCHTML)/index.html: $(MODNAME) $(RSTFILES)
20         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCHTML)
21         touch $@
22
23 doc: $(DOCHTML)/index.html
24
25 doc/readme.md: README.md
26         ln -s ../README.md doc/readme.md
27
28 doc/news.rst: NEWS
29         ln -s ../NEWS doc/news.rst
30
31 dist:
32         fakeroot $(PYTHON) ./setup.py sdist
33
34 test:
35         @for ver in $(PYVERS); do \
36           for flavour in "" "-dbg"; do \
37             if type python$$ver$$flavour >/dev/null; then \
38               echo Testing with python$$ver$$flavour; \
39               python$$ver$$flavour ./setup.py test -q; \
40             fi; \
41           done; \
42         done;
43         @if type pypy >/dev/null; then \
44           echo Testing with pypy; \
45           pypy ./setup.py test -q; \
46         fi
47
48 benchmark: $(MODNAME)
49         @set -e; \
50         TESTFILE=`mktemp`;\
51         trap 'rm $$TESTFILE' EXIT; \
52         for ver in $(PYVERS) ; do \
53             if type python$$ver >/dev/null; then \
54               echo Benchmarking with python$$ver; \
55               python$$ver ./setup.py build -q; \
56               echo "  - set (with override)"; \
57               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
58               echo "  - list"; \
59               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.list('$$TESTFILE')"; \
60               echo "  - get"; \
61               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
62               echo "  - set + remove"; \
63               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
64             fi; \
65         done;
66
67 coverage:
68         $(MAKE) clean
69         $(MAKE) test CFLAGS="-coverage"
70         lcov --capture --directory . --output-file coverage.info
71         genhtml coverage.info --output-directory out
72
73 clean:
74         rm -rf $(DOCHTML) $(DOCTREES)
75         rm -f doc/readme.md doc/news.rst
76         rm -f $(MODNAME)
77         rm -f *.so
78         rm -rf build
79
80 .PHONY: doc test clean dist coverage