forked from ni/nilrt-snac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (92 loc) · 3.05 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
# SPDX-License-Identifier: MIT
.DEFAULT_GOAL := all
# PROJECT VARIABLES #
export PACKAGE = nilrt-snac
export VERSION := $(shell git describe)
# INSTALL PATHS #
export prefix ?= /usr/local
export exec_prefix ?= $(prefix)
export bindir ?= $(exec_prefix)/bin
export datarootdir ?= $(prefix)/share
export datadir ?= $(datarootdir)
export docdir ?= $(datarootdir)/doc
export libdir ?= $(exec_prefix)/lib
export sbindir ?= $(exec_prefix)/sbin
export sysconfdir ?= $(prefix)/etc
# BINARIES #
export PYTHON ?= python3
export PYTEST ?= $(PYTHON) -m pytest
export SHELL ?= /bin/sh
# FILES #
PYNILRT_SNAC_FILES = \
$(shell find nilrt_snac -name \*.py -or -name \*.txt)
TEST_FILES = \
$(shell find tests/ -type f | git check-ignore -vn --stdin | cut -f2)
SRC_FILES = \
src/nilrt-snac-conflicts/control \
src/ni-wireguard-labview/ni-wireguard-labview.initd \
src/ni-wireguard-labview/wglv0.conf \
src/nilrt-snac \
DIST_FILES = \
$(SRC_FILES) \
$(PYNILRT_SNAC_FILES) \
LICENSE \
README.md \
Makefile \
# REAL TARGETS #
################
$(PACKAGE)-$(VERSION).tar.gz : $(DIST_FILES)
tar -czf $@ $(DIST_FILES)
src/nilrt-snac-conflicts/nilrt-snac-conflicts.ipk :
make -C src/nilrt-snac-conflicts $(@F)
# PHONY TARGETS #
#################
.PHONY : all clean dist install installcheck mkinstalldirs uninstall
all : src/nilrt-snac-conflicts/nilrt-snac-conflicts.ipk
clean :
rm -f ./$(PACKAGE)-*.tar.gz
make -C src/nilrt-snac-conflicts clean
dist : $(PACKAGE)-$(VERSION).tar.gz
install : all mkinstalldirs $(DIST_FILES)
# binaries
install --mode=0755 -t "$(DESTDIR)$(sbindir)" src/nilrt-snac
# license files
install --mode=0444 -t "$(DESTDIR)$(docdir)/$(PACKAGE)" \
LICENSE \
README.md
# install conflicts IPK
install --mode=0644 -t "$(DESTDIR)$(datarootdir)/$(PACKAGE)" \
src/nilrt-snac-conflicts/nilrt-snac-conflicts.ipk
# ni-wireguard-labview
install --mode=0660 \
src/ni-wireguard-labview/wglv0.conf \
"$(DESTDIR)$(sysconfdir)/wireguard"
install --mode=0754 \
src/ni-wireguard-labview/ni-wireguard-labview.initd \
"$(DESTDIR)$(sysconfdir)/init.d/ni-wireguard-labview"
# install python library
for pyfile in $(PYNILRT_SNAC_FILES); do \
install -D "$${pyfile}" "$(DESTDIR)$(libdir)/$(PACKAGE)/$${pyfile}"; \
done
# integration tests
for file in $(TEST_FILES); do \
install -D "$${file}" "$(DESTDIR)$(libdir)/$(PACKAGE)/$${file}"; \
done
installcheck :
$(PYTEST) -v "$(realpath $(DESTDIR)$(libdir)/$(PACKAGE)/tests/integration)"
mkinstalldirs :
mkdir -p --mode=0700 "$(DESTDIR)$(sysconfdir)/wireguard"
mkdir -p --mode=0755 "$(DESTDIR)$(sysconfdir)/init.d"
mkdir -p "$(DESTDIR)$(datarootdir)/$(PACKAGE)"
mkdir -p "$(DESTDIR)$(docdir)/$(PACKAGE)"
mkdir -p "$(DESTDIR)$(libdir)/$(PACKAGE)"
mkdir -p "$(DESTDIR)$(sbindir)"
uninstall :
# directories
rm -rvf "$(DESTDIR)$(datarootdir)/$(PACKAGE)"
rm -rvf "$(DESTDIR)$(docdir)/$(PACKAGE)"
rm -rvf "$(DESTDIR)$(libdir)/$(PACKAGE)"
# files
rm -vf "$(DESTDIR)$(sysconfdir)/init.d/ni-wireguard-labview"
rm -vf "$(DESTDIR)$(sysconfdir)/wireguard"/wglv0.*
rm -vf "$(DESTDIR)$(sbindir)/nilrt-snac"