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