2015-07-08 14:47:46 -04:00
|
|
|
PYTHON = python
|
2015-07-05 14:39:14 -04:00
|
|
|
SED = sed
|
2015-07-08 14:47:46 -04:00
|
|
|
SPHINX_BUILD = sphinx-build
|
2015-10-26 22:51:52 -04:00
|
|
|
ETAGS = etags
|
2016-09-21 19:54:45 -04:00
|
|
|
INCLUDE_DIR := $(shell pkg-config --variable=includedir libsystemd)
|
2017-03-19 11:06:48 -04:00
|
|
|
INCLUDE_FLAGS := $(shell pkg-config --cflags libsystemd)
|
2015-07-08 14:47:46 -04:00
|
|
|
VERSION := $(shell $(PYTHON) setup.py --version)
|
2015-10-27 00:12:00 -04:00
|
|
|
TESTFLAGS = -v
|
2015-07-08 14:47:46 -04:00
|
|
|
|
|
|
|
|
define buildscript
|
|
|
|
|
import sys,sysconfig
|
|
|
|
|
print("build/lib.{}-{}.{}".format(sysconfig.get_platform(), *sys.version_info[:2]))
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
builddir := $(shell $(PYTHON) -c '$(buildscript)')
|
2015-07-05 14:39:14 -04:00
|
|
|
|
2015-07-08 14:49:46 -04:00
|
|
|
all: build
|
|
|
|
|
|
2016-09-21 19:54:45 -04:00
|
|
|
.PHONY: update-constants
|
2017-03-25 21:31:16 -04:00
|
|
|
update-constants: update-constants.py $(INCLUDE_DIR)/systemd/sd-messages.h
|
|
|
|
|
$(PYTHON) $+ systemd/id128-defines.h | \
|
2016-09-21 19:54:45 -04:00
|
|
|
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,}
|
2016-09-21 20:56:01 -04:00
|
|
|
($(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,}
|
2016-09-21 19:54:45 -04:00
|
|
|
|
2015-10-15 15:27:57 +02:00
|
|
|
build:
|
2017-03-19 11:06:48 -04:00
|
|
|
$(PYTHON) setup.py build_ext $(INCLUDE_FLAGS)
|
2015-07-08 14:49:46 -04:00
|
|
|
$(PYTHON) setup.py build
|
|
|
|
|
|
2015-07-08 15:29:50 -04:00
|
|
|
install:
|
|
|
|
|
$(PYTHON) setup.py install --skip-build $(if $(DESTDIR),--root $(DESTDIR))
|
|
|
|
|
|
|
|
|
|
dist:
|
|
|
|
|
$(PYTHON) setup.py sdist
|
|
|
|
|
|
2016-12-12 20:15:05 -05:00
|
|
|
sign: dist/systemd-python-$(VERSION).tar.gz
|
|
|
|
|
gpg --detach-sign -a dist/systemd-python-$(VERSION).tar.gz
|
|
|
|
|
|
2015-08-07 11:38:21 -04:00
|
|
|
clean:
|
|
|
|
|
rm -rf build systemd/*.so systemd/*.py[co] *.py[co] systemd/__pycache__
|
|
|
|
|
|
|
|
|
|
distclean: clean
|
2016-09-21 19:54:45 -04:00
|
|
|
rm -rf dist MANIFEST
|
2015-08-07 11:38:21 -04:00
|
|
|
|
2015-07-08 14:47:46 -04:00
|
|
|
SPHINXOPTS = -D version=$(VERSION) -D release=$(VERSION)
|
2015-07-08 14:49:46 -04:00
|
|
|
sphinx-%: build
|
2015-07-08 15:51:06 -04:00
|
|
|
PYTHONPATH=$(builddir) $(SPHINX_BUILD) -b $* $(SPHINXOPTS) docs build/$*
|
2016-09-15 22:31:21 +02:00
|
|
|
@echo Output has been generated in build/$*
|
2015-07-08 14:49:46 -04:00
|
|
|
|
2017-03-19 11:22:10 -04:00
|
|
|
doc: sphinx-html
|
|
|
|
|
|
2015-10-27 00:12:00 -04:00
|
|
|
check: build
|
2016-09-22 20:24:31 -04:00
|
|
|
(cd $(builddir) && $(PYTHON) -m pytest . ../../docs $(TESTFLAGS))
|
2015-10-27 00:12:00 -04:00
|
|
|
|
2016-09-22 09:59:04 -04:00
|
|
|
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)/
|
|
|
|
|
|
2016-12-12 20:15:05 -05:00
|
|
|
upload: dist/systemd-python-$(VERSION).tar.gz dist/systemd-python-$(VERSION).tar.gz.asc
|
|
|
|
|
twine-3 upload $+
|
|
|
|
|
|
2015-10-26 22:51:52 -04:00
|
|
|
TAGS: $(shell git ls-files systemd/*.[ch])
|
|
|
|
|
$(ETAGS) $+
|
|
|
|
|
|
2017-03-19 12:58:41 -04:00
|
|
|
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
|