3 # Copyright © 2015–2016 Ben Finney <ben+python@benfinney.id.au>
5 # This is free software: you may copy, modify, and/or distribute this work
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; version 3 of that license or any later version.
8 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
10 # Makefile for ‘dput’ code base.
12 PYTHON ?
= /usr
/bin
/python2
13 PYTHON_OPTS ?
= -3 -tt
-bb
15 UNITTEST2
= /usr
/bin
/unit2
17 PY_MODULE_SUFFIX
= .py
18 PY_MODULE_BYTECODE_SUFFIX
= .pyc
19 package_modules
= $(shell find
${CURDIR}/dput
/ -name
'*${PY_MODULE_SUFFIX}')
20 python_modules
= $(shell find
${CURDIR}/ -name
'*${PY_MODULE_SUFFIX}')
23 GENERATED_FILES
+= $(patsubst \
24 %${PY_MODULE_SUFFIX},%${PY_MODULE_BYTECODE_SUFFIX}, \
26 GENERATED_FILES
+= ${CURDIR}/*.egg-info
27 GENERATED_FILES
+= ${CURDIR}/build
${CURDIR}/dist
29 UNITTEST_OPTS ?
= --buffer
31 PYTHON_COVERAGE
= $(PYTHON
) -m coverage
32 COVERAGE_RUN_OPTS ?
= --branch
33 COVERAGE_REPORT_OPTS ?
=
34 COVERAGE_TEXT_REPORT_OPTS ?
=
35 COVERAGE_HTML_REPORT_OPTS ?
=
44 $(RM
) -r
${GENERATED_FILES}
50 GENERATED_FILES
+= TAGS
52 TAGS
: ${python_modules}
53 etags
--output
"$@" --lang
=python
${python_modules}
61 $(PYTHON
) -m unittest discover
${UNITTEST_OPTS}
64 test-coverage
: test-coverage-run test-coverage-html test-coverage-report
66 GENERATED_FILES
+= .coverage
68 .PHONY
: test-coverage-run
69 test-coverage-run
: coverage_opts
= ${COVERAGE_RUN_OPTS}
71 $(PYTHON
) -m coverage run
${coverage_opts} \
72 $(UNITTEST2
) discover
${UNITTEST_OPTS}
74 GENERATED_FILES
+= htmlcov
/
76 .PHONY
: test-coverage-html
77 test-coverage-html
: coverage_opts
= ${COVERAGE_REPORT_OPTS} ${COVERAGE_HTML_REPORT_OPTS}
79 $(PYTHON_COVERAGE
) html
${coverage_opts} ${package_modules}
81 .PHONY
: test-coverage-report
82 test-coverage-report
: coverage_opts
= ${COVERAGE_REPORT_OPTS} ${COVERAGE_TEXT_REPORT_OPTS}
84 $(PYTHON_COVERAGE
) report
${coverage_opts} ${package_modules}
91 # vim: fileencoding=utf-8 filetype=make :