Debian Codegraph @

Makefile

raw symbols SCIP
1 PYTHON = python
2 SED = sed
3 ETAGS = etags
4 INCLUDE_DIR := $(shell pkg-config --variable=includedir libsystemd)
5 INCLUDE_FLAGS := $(shell pkg-config --cflags libsystemd)
6 VERSION := $(shell $(PYTHON) setup.py --version)
7 TESTFLAGS = -v
8
9 define buildscript
10 import sys, sysconfig, setuptools
11 sversion = int(setuptools.__version__.split(".")[0])
12 end = sys.implementation.cache_tag if sversion >= 61 else "{}.{}".format(*sys.version_info[:2])
13 print("build/lib.{}-{}".format(sysconfig.get_platform(), end))
14 endef
15
16 builddir := $(shell $(PYTHON) -c '$(buildscript)')
17
18 all: build
19
20 .PHONY: update-constants
21 update-constants: update-constants.py $(INCLUDE_DIR)/systemd/sd-messages.h
22 $(PYTHON) $+ systemd/id128-defines.h | \
23 sort -u | \
24 tee systemd/id128-defines.h.tmp | \
25 $(SED) -n -r 's/,//g; s/#define (SD_MESSAGE_[A-Z0-9_]+)\s.*/add_id(m, "\1", \1) JOINER/p' | \
26 sort -u >systemd/id128-constants.h.tmp
27 mv systemd/id128-defines.h{.tmp,}
28 mv systemd/id128-constants.h{.tmp,}
29 ($(SED) 9q <docs/id128.rst && \
30 sed -n -r 's/#define (SD_MESSAGE_[A-Z0-9_]+) .*/ .. autoattribute:: systemd.id128.\1/p' \
31 systemd/id128-defines.h) >docs/id128.rst.tmp
32 mv docs/id128.rst{.tmp,}
33
34 build:
35 $(PYTHON) setup.py build_ext $(INCLUDE_FLAGS)
36 $(PYTHON) setup.py build
37
38 install:
39 $(PYTHON) setup.py install --skip-build $(if $(DESTDIR),--root $(DESTDIR))
40
41 dist:
42 $(PYTHON) setup.py sdist
43
44 sign: dist/systemd-python-$(VERSION).tar.gz
45 gpg --detach-sign -a dist/systemd-python-$(VERSION).tar.gz
46
47 clean:
48 rm -rf build systemd/*.so systemd/*.py[co] *.py[co] systemd/__pycache__
49
50 distclean: clean
51 rm -rf dist MANIFEST
52
53 SPHINXOPTS += -D version=$(VERSION) -D release=$(VERSION)
54 sphinx-%: build
55 cd build && \
56 PYTHONPATH=../$(builddir) $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $*
57 @echo Output has been generated in build/$*
58
59 doc: sphinx-html
60
61 check: build
62 (cd $(builddir) && $(PYTHON) -m pytest . ../../docs $(TESTFLAGS))
63
64 www_target = www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd/python-systemd
65 doc-sync:
66 rsync -rlv --delete --omit-dir-times build/html/ $(www_target)/
67
68 upload: dist/systemd-python-$(VERSION).tar.gz dist/systemd-python-$(VERSION).tar.gz.asc
69 twine-3 upload $+
70
71 TAGS: $(shell git ls-files systemd/*.[ch])
72 $(ETAGS) $+
73
74 shell:
75 # we change the directory because python insists on adding $CWD to path
76 (cd $(builddir) && $(PYTHON))
77
78 .PHONY: build install dist sign upload clean distclean TAGS doc doc-sync shell