123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- .POSIX:
- #
- # DO NOT EDIT THIS FILE. YOUR CHANGES MAY GET OVERWRITTEN.
- # Edit Makefile.in instead and then re-generate the Makefile
- # with python3 -mmacrop Makefile.in Makefile.
- #
- #
- # Special targets
- #
- .PHONY: \
- check \
- clean \
- coverage \
- dependcheck \
- dist \
- distcheck \
- distclean \
- deb \
- debupload \
- docs \
- install \
- install-comp \
- install-man \
- install-strip \
- install-module \
- installdirs \
- lint \
- maintainer-clean \
- mostlyclean \
- virtinstall \
- wheelupload \
- pre-install \
- post-uninstall \
- quickcheck \
- quicklint \
- uninstall \
- uninstall-module \
- uninstallfiles \
- userinstall
- .SUFFIXES:
- all:
- :
- #
- # Macros
- #
- BANDIT = bandit
- BANDITFLAGS = -qc pyproject.toml
- COVERAGE = coverage
- CTAGS = ctags
- CURL = curl
- DESTDIR =
- DPKG_DEB = dpkg-deb
- FLAKE8 = flake8
- GPG = gpg -ab
- GPGFLAGS = -q --batch --yes
- SHELL = /bin/sh
- INSTALL = install
- JQ = jq
- LINTIAN = lintian
- # TODO: Add pedantic and warning, once changelos are to spec.
- LINTIANFLAGS = --cfg deb/lintian.cfg --fail-on error
- MYPY = mypy
- PATHCHK = pathchk
- PYLINT = pylint
- PYRIGHT = pyright
- PYTHON = python3
- PIP = pip
- PIPFLAGS = --root=$(DESTDIR) --prefix=$(prefix)
- PREFIX = /usr/local
- PYPI_UPLOAD = $(TWINE) upload $(TWINEFLAGS)
- RUFF = ruff
- RUFFFLAGS = --quiet
- SPHINX = sphinx-build
- VENV = $(PYTHON) -m venv
- VERMIN = vermin
- VULTURE = vulture
- VPATH = .
- SAFETY = safety
- SAFETYFLAGS = --disable-optional-telemetry --policy-file=$(safetypolicy)
- TAR = pax -ws '/^/$(distname)\//' -x ustar
- TWINE = twine
- TWINEFLAGS = -s -rtestpypi
- UNTAR = tar -x
- UNZIP = gunzip -c
- ZIP = gzip
- bashcompdir = $(datarootdir)/bash-completion/completions
- bindir = $(exec_prefix)/bin
- checks = discover
- copyright = COPYRIGHT
- datarootdir = $(prefix)/share
- debdir = deb/$(package)_$(version)-0_all
- deburl = $(forgejo_url)/debian/pool/bullseye/main/upload
- deb = $(debdir).deb
- distar = $(distname).tgz
- distfiles = \
- INSTALL.rst \
- LICENSE.rst \
- NEWS.rst \
- README.rst \
- comp/sievemgr.bash \
- comp/sievemgr.zsh \
- deb/control.in \
- deb/copyright.in \
- deb/lintian.cfg \
- docs/Makefile \
- docs/_static/custom.css \
- docs/changelog.rst \
- docs/command.rst \
- docs/conf.py \
- docs/config.rst \
- docs/contrib.rst \
- docs/feedback.rst \
- docs/index.rst \
- docs/install.rst \
- docs/license.rst \
- docs/module.rst \
- docs/security.rst \
- docs/sphinx.txt \
- examples/sievepatch \
- linters.txt \
- Makefile \
- Makefile.in \
- macrop.py \
- man/sieve.cf.5 \
- man/sievemgr.1 \
- pyproject.toml \
- setup.cfg \
- sievemgr.py \
- tests/__init__.py \
- tests/test_acap.py \
- tests/test_backup.py \
- tests/test_log.py \
- tests/test_sasl.py \
- tests/test_sieve.py \
- tests/test_term.py
- distname = $(module)-$(version)
- exec_prefix = $(prefix)
- forgejo_url = https://codeberg.org/api/packages/$(forgejo_user)
- forgejo_user = odkr
- installdirs = \
- $(DESTDIR)$(man1dir) \
- $(DESTDIR)$(man5dir) \
- $(DESTDIR)$(bashcompdir) \
- $(DESTDIR)$(zshcompdir)
- instlog = install.log
- mandir = $(datarootdir)/man
- man1dir = $(mandir)/man1
- man5dir = $(mandir)/man5
- man1ext = .1
- man5ext = .5
- module = $(package)
- package = ${__name__}
- prefix = $(PREFIX)
- safetypolicy = safety.yml
- srcs = \
- sievemgr.py \
- $(tests)
- tests = \
- tests/__init__.py \
- tests/test_acap.py \
- tests/test_backup.py \
- tests/test_log.py \
- tests/test_sasl.py \
- tests/test_sieve.py \
- tests/test_term.py
- venvdir = /opt/odkr/$(module)
- version = ${__version__}
- zshcompdir = $(datarootdir)/zsh-completions
- badgeurl = https://img.shields.io/badge/coverage-{}%25-lightgrey
- coverage = docs/_static/coverage.svg docs/_static/coverage/index.html
- #
- # Build system
- #
- .SUFFIXES: .in
- Makefile: sievemgr.py Makefile.in
- .in:
- $(PYTHON) -mmacrop $@.in $@
- #
- # Installation
- #
- install: pre-install install-module install-man install-comp
- install-man: \
- installdirs \
- $(DESTDIR)$(man1dir)/sievemgr$(man1ext) \
- $(DESTDIR)$(man5dir)/sieve.cf$(man5ext)
- uninstall: uninstall-module uninstallfiles uninstalldirs post-uninstall
- install-comp: \
- installdirs \
- $(DESTDIR)$(bashcompdir)/sievemgr.bash \
- $(DESTDIR)$(zshcompdir)/_sievemgr
- install-strip: install
- virtinstall: $(venvdir)/bin/pip
- install-module:
- $(NORMAL_INSTALL)
- $(PIP) install $(PIPFLAGS) .
- printf 'pip: %s\n' '$(PIP)' >>$(instlog)
- pre-install:
- $(PRE_INSTALL)
- set -C && : >$(instlog)
- installdirs: $(installdirs)
- userinstall:
- $(MAKE) -e PIPFLAGS=--user prefix="$$$$HOME/.local" install
- virtinstall:
- @echo 'Installing SieveManager to $(venvdir) ...'
- $(MAKE) -e PIP=$(venvdir)/bin/pip PIPFLAGS= \
- PREFIX='$(venvdir)' install
- uninstall-module:
- $(NORMAL_UNINSTALL)
- -"$$$$(sed -n 's/pip: //p' $(instlog))" uninstall -y $(module)
- uninstalldirs:
- $(POST_UNINSTALL)
- - sed -n 's/^dir: //p' $(instlog) | xargs -E '' rmdir -pv
- uninstallfiles:
- $(POST_UNINSTALL)
- sed -n 's/^file: //p' $(instlog) | xargs -E '' rm -f
- post-uninstall:
- $(POST_UNINSTALL)
- rm $(instlog)
- $(DESTDIR)$(man1dir)/sievemgr$(man1ext): man/sievemgr.1
- $(POST_INSTALL)
- $(INSTALL) -m u=rw,go=r man/sievemgr.1 '$@'
- printf 'file: %s\n' '$@' >>$(instlog)
- $(DESTDIR)$(man5dir)/sieve.cf$(man5ext): man/sieve.cf.5
- $(POST_INSTALL)
- $(INSTALL) -m u=rw,go=r man/sieve.cf.5 '$@'
- printf 'file: %s\n' '$@' >>$(instlog)
- $(DESTDIR)$(bashcompdir)/sievemgr.bash: comp/sievemgr.bash
- $(POST_INSTALL)
- $(INSTALL) -m u=rw,go=r comp/sievemgr.bash '$@'
- printf 'file: %s\n' '$@' >>$(instlog)
- $(DESTDIR)$(zshcompdir)/_sievemgr: comp/sievemgr.zsh
- $(POST_INSTALL)
- $(INSTALL) -m u=rw,go=r comp/sievemgr.zsh '$@'
- printf 'file: %s\n' '$@' >>$(instlog)
- $(installdirs):
- $(PRE_INSTALL)
- mkdir -pm0755 $@
- printf 'dir: %s\n' '$@' >>$(instlog)
- $(venvdir)/bin/pip:
- @echo 'Creating a Python virtual environment in $(venvdir) ...'
- $(PYTHON) -mvenv $(venvdir)
- #
- # Documentation
- #
- .coverage: sievemgr.py $(tests)
- $(COVERAGE) run -m --include sievemgr.py unittest discover
- coverage: $(coverage)
- docs: man/sievemgr.1 man/sieve.cf.5
- . ./bin/activate && cd docs && $(MAKE) -e html
- docs/_static/coverage/index.html: .coverage
- $(GCOVR) $(GCOVRFLAGS) --html-self-contained --html-details $@
- $(COVERAGE) html --include sievemgr.py -d docs/_static/coverage
- docs/_static/coverage.svg: .coverage
- $(COVERAGE) json -o - | $(JQ) .totals.percent_covered_display -r | \
- xargs -I '{}' $(CURL) -o $@ $(badgeurl)
- man/sievemgr.1: docs/command.rst
- man/sieve.cf.5: docs/config.rst
- man/sievemgr.1.gz: man/sievemgr.1
- man/sieve.cf.5.gz: man/sieve.cf.5
- man/sievemgr.1 man/sieve.cf.5:
- . ./bin/activate && $(SPHINX) $(SPHINXFLAGS) -bman docs man
- #
- # Distribution
- #
- dist: dependcheck $(distar) $(distar).asc
- distcheck: dist
- $(distar): lint check $(distfiles)
- $(distar).asc: $(distar)
- dependcheck:
- $(SAFETY) scan $(SAFETYFLAGS) || [ $$$$? -eq 127 ]
- distcheck:
- $(UNZIP) $(distar) | $(UNTAR)
- cd $(distname) && $(MAKE) -e check
- rm -rf $(distname)
- $(distar):
- $(PATHCHK) $(PATHCHKFLAGS) -Pp $(distfiles)
- $(TAR) $(TARFLAGS) $(distfiles) | $(ZIP) $(ZIPFLAGS) >$(distar)
- $(distar).asc:
- $(GPG) $(GPGFLAGS) $(distar)
- #
- # PyPI
- #
- build: lint check
- $(PYTHON) -m build
- wheelupload: build
- $(PYPI_UPLOAD) dist/$(distname).tar.gz dist/$(distname)-py3-none-any.whl
- #
- # Debian package
- #
- deb: $(deb)
- debupload: $(deb)
- $(deb): \
- lint \
- check \
- $(debdir)/usr/lib/python3/dist-packages/sievemgr.py \
- $(debdir)/usr/share/man/man1/sievemgr.1.gz \
- $(debdir)/usr/share/man/man5/sieve.cf.5.gz \
- $(debdir)/usr/share/bash-completion/completions/sievemgr.bash \
- $(debdir)/usr/share/zsh-completions/_sievemgr \
- $(debdir)/DEBIAN/control \
- $(debdir)/usr/share/doc/$(package)/copyright \
- $(debdir)/usr/share/doc/$(package)/changelog.gz
- $(DPKG_DEB) $(DPKG_DEBFLAGS) --root-owner-group --build $(debdir)
- $(LINTIAN) $(LINTIANFLAGS) $@ || [ $$$$? -eq 127 ]
- GPG_TTY=$$$$(tty) debsigs --sign=maint $@
- $(debdir)/usr/lib/python3/dist-packages/sievemgr.py:
- /usr/bin/pip3 install --root=$(debdir) --prefix=/usr --no-deps .
- if [ -e $(debdir)/usr/local ]; \
- then \
- mv $(debdir)/usr/local/* $(debdir)/usr; \
- rmdir $(debdir)/usr/local; \
- fi
- pydir="$$$$(ls -d $(debdir)/usr/lib/python*)"; \
- debpydir="$$$${pydir%.*}"; \
- if [ -e "$$$$pydir" ]; \
- then mv "$$$$pydir" "$$$$debpydir"; \
- fi
- if [ -e "$$$$debpydir/site-packages" ]; \
- then mv "$$$$debpydir/site-packages" "$$$$debpydir/dist-packages"; \
- fi
- find $(debdir) -type d -name __pycache__ -exec rm -rf '{}' ';' -prune
- $(debdir)/usr/share/man/man1/sievemgr.1.gz: man/sievemgr.1
- mkdir -pm0755 $$$$(dirname $@)
- gzip -9n <man/sievemgr.1 >$@
- $(debdir)/usr/share/man/man5/sieve.cf.5.gz: man/sieve.cf.5
- mkdir -pm0755 $$$$(dirname $@)
- gzip -9n <man/sieve.cf.5 >$@
- $(debdir)/DEBIAN/control: deb/control
- mkdir -pm0755 $$$$(dirname $@)
- $(INSTALL) -m u=rw,go=r deb/control $@
- $(debdir)/usr/share/doc/$(package)/copyright: deb/copyright
- mkdir -pm0755 $$$$(dirname $@)
- $(INSTALL) -m u=rw,go=r deb/copyright $@
- $(debdir)/usr/share/doc/$(package)/changelog.gz: NEWS.rst
- mkdir -pm0755 $$$$(dirname $@)
- gzip -9n <NEWS.rst >$@
- $(debdir)/usr/share/bash-completion/completions/sievemgr.bash:
- mkdir -pm0755 $$$$(dirname $@)
- $(INSTALL) -m u=rw,go=r comp/sievemgr.bash $@
- $(debdir)/usr/share/zsh-completions/_sievemgr:
- mkdir -pm0755 $$$$(dirname $@)
- $(INSTALL) -m u=rw,go=r comp/sievemgr.zsh $@
- deb/control: sievemgr.py deb/control.in
- deb/copyright: sievemgr.py deb/copyright.in
- debupload:
- GPG_TTY=$$$$(tty) debsigs --sign=origin $(deb)
- curl -n --netrc-file .netrc -T$(deb) $(deburl)
- #
- # Cleanup
- #
- maintainer-clean: distclean
- @echo '$@ is for maintainers only!'
- @echo 'It deletes files that cannot be built with standard tools.'
- rm -f deb/control deb/copyright Makefile man/sievemgr.1 man/sieve.cf.5
- distclean: clean
- rm -f $(instlog) tags
- clean: mostlyclean
- find . '(' -name '*.deb' -o -name '*.asc' -o -name '*.tgz' ')' \
- -exec rm -f '{}' +
- rm -rf $(package).egg-info .*_cache build deb/$(package)_*
- mostlyclean:
- find . -type d -name __pycache__ | xargs -E '' rm -rf
- find . -type f -name '*.bak' -exec rm '{}' +
- rm -f $(package)-*.tgz $(package)-*.tgz.asc deb/$(package)_*.deb dist/*
- #
- # Tags
- #
- TAGS: tags
- tags: $(srcs)
- $(CTAGS) $(CTAGSFLAGS) $(srcs)
- #
- # Tests
- #
- check:
- $(PYTHON) -m unittest $(checks)
- quickcheck:
- QUICKTEST=y $(PYTHON) -m unittest $(checks)
- #
- # Linters
- #
- lint: quicklint
- lint:
- $(PYRIGHT) $(PYRIGHTFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(FLAKE8) $(FLAKE8FLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(VERMIN) $(VERMINFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(RUFF) check $(RUFFFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(PYLINT) $(PYLINTFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(VULTURE) $(VULTUREFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- quicklint:
- $(MYPY) $(MYPYFLAGS) $(srcs) || [ $$$$? -eq 127 ]
- $(BANDIT) $(BANDITFLAGS) $(srcs) || [ $$$$? -eq 127 ]
|