forked from canonical/netplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (75 loc) · 3.46 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
BUILDFLAGS = \
-std=c99 \
-D_XOPEN_SOURCE=500 \
-Wall \
-Werror \
$(NULL)
SYSTEMD_GENERATOR_DIR=$(shell pkg-config --variable=systemdsystemgeneratordir systemd)
SYSTEMD_UNIT_DIR=$(shell pkg-config --variable=systemdsystemunitdir systemd)
BASH_COMPLETIONS_DIR=$(shell pkg-config --variable=completionsdir bash-completion || echo "/etc/bash_completion.d")
ROOTPREFIX ?= /
PREFIX ?= /usr
ROOTLIBEXECDIR ?= $(ROOTPREFIX)/lib
SBINDIR ?= $(PREFIX)/sbin
DATADIR ?= $(PREFIX)/share
DOCDIR ?= $(DATADIR)/doc
MANDIR ?= $(DATADIR)/man
PYCODE = netplan/ $(wildcard src/*.py) $(wildcard tests/*.py)
# Order: Fedora/Mageia/openSUSE || Debian/Ubuntu || null
PYFLAKES3 ?= $(shell which pyflakes-3 || which pyflakes3 || echo true)
PYCODESTYLE3 ?= $(shell which pycodestyle-3 || which pycodestyle || which pep8 || echo true)
NOSETESTS3 ?= $(shell which nosetests-3 || which nosetests3 || echo true)
default: generate doc/netplan.html doc/netplan.5 doc/netplan-generate.8 doc/netplan-apply.8 doc/netplan-try.8
generate: src/generate.[hc] src/parse.[hc] src/util.[hc] src/networkd.[hc] src/nm.[hc] src/validation.[hc] src/error.[hc]
$(CC) $(BUILDFLAGS) $(CFLAGS) -o $@ $(filter %.c, $^) `pkg-config --cflags --libs glib-2.0 gio-2.0 yaml-0.1 uuid`
clean:
rm -f generate doc/*.html doc/*.[1-9]
rm -f *.gcda *.gcno generate.info
rm -rf test-coverage .coverage
check: default linting
tests/cli.py
$(NOSETESTS3) -v --with-coverage
tests/validate_docs.sh
linting:
$(PYFLAKES3) $(PYCODE)
$(PYCODESTYLE3) --max-line-length=130 $(PYCODE)
coverage: | pre-coverage c-coverage python-coverage
pre-coverage:
rm -f .coverage
$(MAKE) CFLAGS="-g -O0 --coverage" clean check
mkdir -p test-coverage/C test-coverage/python
check-coverage: coverage
@if grep headerCovTableEntryHi test-coverage/C/index.html | grep -qv '100.*%'; then \
echo "FAIL: Test coverage not 100%!" >&2; exit 1; \
fi
python3-coverage report --omit=/usr* --show-missing --fail-under=100
c-coverage:
lcov --directory . --capture -o generate.info
lcov --remove generate.info "/usr*" -o generate.info
genhtml -o test-coverage/C/ -t "generate test coverage" generate.info
python-coverage:
python3-coverage html -d test-coverage/python --omit=/usr* || true
python3-coverage xml --omit=/usr* || true
install: default
mkdir -p $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(ROOTLIBEXECDIR)/netplan $(DESTDIR)/$(SYSTEMD_GENERATOR_DIR)
mkdir -p $(DESTDIR)/$(MANDIR)/man5 $(DESTDIR)/$(MANDIR)/man8
mkdir -p $(DESTDIR)/$(DOCDIR)/netplan/examples
mkdir -p $(DESTDIR)/$(DATADIR)/netplan/netplan
install -m 755 generate $(DESTDIR)/$(ROOTLIBEXECDIR)/netplan/
find netplan/ -name '*.py' -exec install -Dm 644 "{}" "$(DESTDIR)/$(DATADIR)/netplan/{}" \;
install -m 755 src/netplan.script $(DESTDIR)/$(DATADIR)/netplan/
ln -srf $(DESTDIR)/$(DATADIR)/netplan/netplan.script $(DESTDIR)/$(SBINDIR)/netplan
ln -srf $(DESTDIR)/$(ROOTLIBEXECDIR)/netplan/generate $(DESTDIR)/$(SYSTEMD_GENERATOR_DIR)/netplan
install -m 644 doc/*.html $(DESTDIR)/$(DOCDIR)/netplan/
install -m 644 examples/*.yaml $(DESTDIR)/$(DOCDIR)/netplan/examples/
install -m 644 doc/*.5 $(DESTDIR)/$(MANDIR)/man5/
install -m 644 doc/*.8 $(DESTDIR)/$(MANDIR)/man8/
install -D -m 644 src/[email protected] $(DESTDIR)/$(SYSTEMD_UNIT_DIR)/[email protected]
install -T -D -m 644 netplan.completions $(DESTDIR)/$(BASH_COMPLETIONS_DIR)/netplan
%.html: %.md
pandoc -s --toc -o $@ $<
doc/netplan.5: doc/manpage-header.md doc/netplan.md doc/manpage-footer.md
pandoc -s -o $@ $^
%.8: %.md
pandoc -s -o $@ $^
.PHONY: clean