dist: refactoring, ship systemd services for Debian, fix section of re6stnet manpage
[re6stnet.git] / Makefile
1 DESTDIR = /
2 PREFIX = /usr/local
3 MANDIR = $(PREFIX)/share/man
4
5 MANPAGELIST := $(patsubst %,docs/%,re6st-conf.1 re6st-registry.1 re6stnet.8)
6 NM = /etc/NetworkManager/dispatcher.d/50re6stnet
7
8 all: $(MANPAGELIST)
9
10 %.1 %.8: %.rst
11 rst2man $< $@
12
13 install: install-noinit
14 for x in daemon/*.service; \
15 do install -Dpm 0644 $$x $(DESTDIR)/lib/systemd/system/$${x##*/}; \
16 done
17
18 install-noinit: install-man
19 set -e $(DESTDIR)$(PREFIX) /bin/re6stnet; [ -x $$1$$2 ] || \
20 python2.7 setup.py install --prefix=$(PREFIX) --root=$(DESTDIR); \
21 install -d $$1/sbin; mv $$1$$2 $$1/sbin
22 install -Dpm 0644 daemon/README.conf $(DESTDIR)/etc/re6stnet/README
23 install -Dpm 0644 daemon/logrotate.conf $(DESTDIR)/etc/logrotate.d/re6stnet
24 install -Dp daemon/network-manager $(DESTDIR)$(NM)
25
26 install-man: $(MANPAGELIST)
27 set -e; for x in $^; \
28 do install -Dpm 0644 $$x $(DESTDIR)$(MANDIR)/man$${x##*.}/$${x##*/}; \
29 done
30
31 install-ifupdown:
32 set -e; for a in up down; do \
33 set $(DESTDIR)/etc/network/if-$$a.d/re6stnet; \
34 install -d $${1%/*}; \
35 printf '#!/bin/sh -e\n[ "$$METHOD" = NetworkManager -o "$$IFACE" = lo ] ||exec $(NM) "$$IFACE" %s\n' $$a >$$1; \
36 chmod +x $$1; \
37 done
38
39 clean:
40 find -name '*.pyc' -delete
41 rm -rf build dist re6stnet.egg-info $(MANPAGELIST)