Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #! /usr/bin/make -f
  2. #
  3. # Copyright © 2015–2016 Ben Finney <ben+python@benfinney.id.au>
  4. # Part of ‘manpage’, a Python library for making Unix manual documents.
  5. #
  6. # This is free software: you may copy, modify, and/or distribute this work
  7. # under the terms of the GNU General Public License as published by the
  8. # Free Software Foundation; version 3 of that license or any later version.
  9. # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
  10. # Makefile for ‘manpage’ code base.
  11. PACKAGE_NAMES = manpage
  12. PY_MODULE_SUFFIX = .py
  13. PY_MODULE_BYTECODE_SUFFIX = .pyc
  14. package_modules = $(foreach package,${PACKAGE_NAMES}, \
  15. $(shell find ${CURDIR}/${package}/ -name '*${PY_MODULE_SUFFIX}'))
  16. python_modules = $(shell find ${CURDIR}/ -name '*${PY_MODULE_SUFFIX}')
  17. TOX_DIR = .tox
  18. GENERATED_FILES :=
  19. GENERATED_FILES += ${CURDIR}/${TOX_DIR}
  20. GENERATED_FILES += $(patsubst \
  21. %${PY_MODULE_SUFFIX},%${PY_MODULE_BYTECODE_SUFFIX}, \
  22. ${python_modules})
  23. GENERATED_FILES += ${CURDIR}/*.egg-info
  24. GENERATED_FILES += ${CURDIR}/build ${CURDIR}/dist
  25. DISTUTILS_SCRIPT = ${CURDIR}/setup.py
  26. PYTHON ?= /usr/bin/python3
  27. PYTHON_OPTS ?= -tt -bb
  28. PYTHON_UNITTEST = $(PYTHON) ${DISTUTILS_SCRIPT} test
  29. UNITTEST_OPTS ?= --quiet
  30. PYTHON_COVERAGE = $(PYTHON) -m coverage
  31. COVERAGE_RUN_OPTS ?= --branch
  32. COVERAGE_REPORT_OPTS ?=
  33. COVERAGE_TEXT_REPORT_OPTS ?=
  34. COVERAGE_HTML_REPORT_OPTS ?=
  35. .PHONY: all
  36. all:
  37. .PHONY: clean
  38. clean:
  39. $(RM) -r ${GENERATED_FILES}
  40. .PHONY: tags
  41. tags: TAGS
  42. GENERATED_FILES += TAGS
  43. TAGS: ${python_modules}
  44. etags --output "$@" --lang=python ${python_modules}
  45. .PHONY: test
  46. test: test-unittest
  47. .PHONY: test-unittest
  48. test-unittest:
  49. $(PYTHON_UNITTEST) ${UNITTEST_OPTS}
  50. .PHONY: test-coverage
  51. test-coverage: test-coverage-run test-coverage-html test-coverage-report
  52. GENERATED_FILES += .coverage
  53. .PHONY: test-coverage-run
  54. test-coverage-run: coverage_opts = ${COVERAGE_RUN_OPTS}
  55. test-coverage-run:
  56. $(PYTHON_COVERAGE) run ${coverage_opts} \
  57. ${DISTUTILS_SCRIPT} test ${UNITTEST_OPTS}
  58. GENERATED_FILES += htmlcov/
  59. .PHONY: test-coverage-html
  60. test-coverage-html: coverage_opts = ${COVERAGE_REPORT_OPTS}
  61. test-coverage-html: coverage_opts += ${COVERAGE_HTML_REPORT_OPTS}
  62. test-coverage-html:
  63. $(PYTHON_COVERAGE) html ${coverage_opts} ${package_modules}
  64. .PHONY: test-coverage-report
  65. test-coverage-report: coverage_opts = ${COVERAGE_REPORT_OPTS}
  66. test-coverage-report: coverage_opts += ${COVERAGE_TEXT_REPORT_OPTS}
  67. test-coverage-report:
  68. $(PYTHON_COVERAGE) report ${coverage_opts} ${package_modules}
  69. # Local variables:
  70. # coding: utf-8
  71. # mode: make
  72. # End:
  73. # vim: fileencoding=utf-8 filetype=make :