-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
135 lines (107 loc) · 4.18 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Makefile for a source distribution of dhcpcanon.
#
# This package is not self-contained and the build products may require other
# dependencies to function; it is given as a reference for distro packagers.
#
# SPDX-FileCopyrightText: 2016, juga <juga at riseup dot net>
# SPDX-License-Identifier: MIT
PACKAGE = dhcpcanon
VERSION = $(shell sh version.sh)
DESTDIR =
THISFILE = $(lastword $(MAKEFILE_LIST))
PYTHON = python3
# GNU command variables
# see http://www.gnu.org/prep/standards/html_node/Command-Variables.html
INSTALL = install
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_PROGRAM = $(INSTALL)
INSTALL_SCRIPT = $(INSTALL)
# GNU directory variables
# see http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
prefix = /usr/local
exec_prefix = $(prefix)
sbindir = $(exec_prefix)/sbin
datarootdir = $(prefix)/share
datadir = $(datarootdir)
sysconfdir = $(prefix)/etc
docdir = $(datarootdir)/doc/$(PACKAGE)
mandir = $(datarootdir)/man
man8dir = $(mandir)/man8
# for systemd
tmpfilesdir=/usr/lib/tmpfiles.d
systemunitdir=/lib/systemd/system
# for systemd udev
networkdir=/lib/systemd/network
# for apparmor
apparmordir=/etc/apparmor.d
srcdir = .
SRC_MAN8 = man/dhcpcanon.8
SRC_SCRIPT = sbin/dhcpcanon-script
SRC_DOC = README.rst LICENSE
SRC_TMPFILES = tmpfiles.d/dhcpcanon.conf
SRC_UNITFILE = systemd/dhcpcanon.service
SRC_APPARMOR = apparmor.d/sbin.dhcpcanon
SRC_LINKFILE = systemd/network/90-dhcpcanon.link
SRC_ALL = $(SRC_SCRIPT) $(SRC_DOC) $(SRC_MAN8)
DST_MAN8 = $(SRC_MAN8)
DST_SCRIPT = $(SRC_SCRIPT)
DST_DOC = $(SRC_DOC)
DST_TMPFILES = $(SRC_TMPFILES)
DST_UNITFILE = $(SRC_UNITFILE)
DST_APPARMOR = $(SRC_APPARMOR)
DST_LINKFILE = $(SRC_LINKFILE)
DST_ALL = $(DST_SCRIPT) $(DST_DOC) $(DST_MAN8)
TEST_PY = dhcpcanon-test.py
all: $(DST_ALL) $(THISFILE)
install: all
@echo $@
mkdir -p $(DESTDIR)$(sbindir)
for i in $(DST_SCRIPT); do $(INSTALL_SCRIPT) "$$i" /sbin; done
mkdir -p $(DESTDIR)$(docdir)
for i in $(DST_DOC); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(docdir); done
mkdir -p $(DESTDIR)$(man8dir)
for i in $(DST_MAN8); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(man8dir); done
$(PYTHON) setup.py install --record installed.txt $(if $(DESTDIR),--root=$(DESTDIR),--install-scripts=/sbin)
if [ -n "$(WITH_SYSTEMD)" ]; then \
adduser --system dhcpcanon; \
mkdir -p $(DESTDIR)$(systemunitdir); \
for i in $(DST_UNITFILE); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(systemunitdir); done; \
mkdir -p $(DESTDIR)$(tmpfilesdir); \
for i in $(DST_TMPFILES); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(tmpfilesdir); done; \
systemctl enable $(DESTDIR)$(systemunitdir)/dhcpcanon.service; \
systemd-tmpfiles --create --root=$(DESTDIR)$(tmpfilesdir)/dhcpcanon.conf; \
systemctl start $(DESTDIR)$(systemunitdir)/dhcpcanon.service; \
systemctl status $(DESTDIR)$(systemunitdir)/dhcpcanon.service; \
fi
if [ -n "$(WITH_SYSTEMD_UDEV)" ]; then \
mkdir -p $(DESTDIR)$(networkdir); \
for i in $(DST_LINKFILE); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(networkdir); done; \
fi
if [ -n "$(WITH_APPARMOR)" ]; then \
mkdir -p $(DESTDIR)$(apparmordir); \
for i in $(DST_APPARMOR); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(apparmordir); done; \
for i in $(DST_APPARMOR); do aa-complain $(DESTDIR)$(apparmordir)/"$$i"; done; \
fi
uninstall:
@echo $@
for i in $(notdir $(DST_SCRIPT)); do rm -f $(DESTDIR)$(sbindir)/"$$i"; done
for i in $(notdir $(DST_DOC)); do rm -f $(DESTDIR)$(docdir)/"$$i"; done
for i in $(notdir $(DST_MAN8)); do rm -f $(DESTDIR)$(man8dir)/"$$i"; done
# it will only work in the case that the file has not been removed
cat installed.txt | xargs rm -rf
# systemd files
for i in $(notdir $(DST_UNITFILE)); do rm -f $(DESTDIR)$(systemunitdir)/"$$i"; done
for i in $(notdir $(DST_TMPFILES)); do rm -f $(DESTDIR)$(tmpfilesdir)/"$$i"; done
for i in $(notdir $(DST_APPARMOR)); do rm -f $(DESTDIR)$(apparmordir)/"$$i"; done
for i in $(notdir $(DST_LINKFILE)); do rm -f $(DESTDIR)$(networkdir)/"$$i"; done
clean:
python setup.py clean
rm -rf *.pyc build dist dhcpcanon.egg-info
distclean: clean
maintainer-clean: distclean
rm -f $(DST_MAN8)
pylint: $(SRC_SCRIPT)
pylint -E $^
check: $(THISFILE)
for i in $(TEST_PY); do $(PYTHON) "$$i"; done
.PHONY: all install uninstall clean distclean maintainer-clean check pylint