-
Notifications
You must be signed in to change notification settings - Fork 75
/
Makefile
230 lines (196 loc) · 6.79 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Makefile for mercury
#
export OPTFLAGS
# definitions for colorized output
COLOR_RED = "\033[0;31m"
COLOR_GREEN = "\033[0;32m"
COLOR_YELLOW = "\033[0;33m"
COLOR_OFF = "\033[0m"
INSTALL = /usr/bin/install -c
INSTALLDATA = /usr/bin/install -c -m 644
.PHONY: mercury
mercury:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd src && $(MAKE)
endif
.PHONY: install install-no-systemd
install: install-mercury install-resources install-etc-config install-systemd
install-nosystemd: install-mercury install-resources install-etc-config
.PHONY: install-mercury
install-mercury:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd src && $(MAKE) install
$(INSTALLDATA) mercury /usr/share/bash-completion/completions/ # note: completion script has same name as binary
endif
.PHONY: install-resources
install-resources:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd resources && $(MAKE) install
endif
# leave this variable empty; we want to force the user to set it, as a
# reminder that they should create a usable local configuration
MERCURY_CFG =
.PHONY: install-etc-config
install-etc-config:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
ifneq ($(MERCURY_CFG),)
$(INSTALL) -d /etc/mercury
$(INSTALLDATA) $(MERCURY_CFG) /etc/mercury/mercury.cfg
else
@echo $(COLOR_RED) "error: you must specify the configuration file; run as 'make install MERCURY_CFG=filename'" $(COLOR_OFF)
@echo $(COLOR_RED) "where 'filename' is the configuration file you want to use for this installation. You can" $(COLOR_OFF)
@echo $(COLOR_RED) "use mercury.cfg as a template, but you *must* change the interface line to the appropriate" $(COLOR_OFF)
@echo $(COLOR_RED) "network interface for your system. (Use 'cat /proc/net/dev' to see Linux interfaces.)" $(COLOR_OFF)
@/bin/false
endif
endif
.PHONY: install-systemd
install-systemd: install-etc-config
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
$(INSTALLDATA) install_mercury/mercury.service /etc/systemd/system/
systemctl start mercury
systemctl enable mercury
endif
.PHONY: install-nonroot
install-nonroot:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd src && $(MAKE) install-nonroot
cd resources && $(MAKE) install-nonroot
endif
.PHONY: install-certtools
install-certtools:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd src && $(MAKE) install-certtools
endif
.PHONY: uninstall
uninstall: uninstall-mercury uninstall-systemd uninstall-certtools
.PHONY: uninstall-mercury
uninstall-mercury:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
rm -f /etc/mercury/mercury.cfg
rm -rf /etc/mercury
cd src && $(MAKE) uninstall
cd resources && $(MAKE) uninstall
endif
.PHONY: uninstall-systemd
uninstall-systemd:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
systemctl stop mercury
systemctl disable mercury
rm /etc/systemd/system/mercury.service
userdel mercury
endif
.PHONY: uninstall-certtools
uninstall-certtools:
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
cd src && $(MAKE) uninstall-certtools
endif
# the target libs builds three versions of libmerc.so, and copies them
# to the folder libs/
.PHONY: libs
libs:
$(MAKE) --directory=src clean
$(MAKE) --directory=src stripped-libmerc
$(MAKE) --directory=src clean
$(MAKE) --directory=src debug-libmerc
$(MAKE) --directory=src clean
$(MAKE) --directory=src unstripped-libmerc
.PHONY: test
test:
cd src && $(MAKE) test
.PHONY: test_strict
test_strict:
cd src && $(MAKE) test
.PHONY: test_libmerc_so
test_libmerc_so: unit_tests
cd test && $(MAKE) test_libmerc_so
.PHONY: unit_tests
unit_tests:
cd unit_tests && $(MAKE)
.PHONY: coverage_report
coverage_report: clean
cd unit_tests && $(MAKE) libmerc_driver_coverage
cd unit_tests && $(MAKE) run
cd unit_tests && gcovr -r ../src/libmerc
.PHONY: doc
doc: doc/mercury.pdf sphinx
doc/mercury.pdf:
doxygen
cd doc/latex; make; mv refman.pdf ../mercury.pdf
.PHONY: sphinx sphinx-clean
sphinx:
cd doc/sphinx && $(MAKE) html
sphinx-clean:
cd doc/sphinx && $(MAKE) clean
.PHONY:
clean: sphinx-clean
for file in Makefile README.md configure.ac Doxyfile; do if [ -e "$$file~" ]; then rm -f "$$file~" ; fi; done
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
@/bin/false
else
cd src && $(MAKE) clean
cd test && $(MAKE) clean
cd unit_tests && $(MAKE) clean
rm -rf doc/latex
endif
.PHONY: distclean
distclean: clean
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
@/bin/false
else
cd src && $(MAKE) distclean
cd test && $(MAKE) distclean
cd resources && $(MAKE) distclean
rm -rf autom4te.cache config.log config.status Makefile_helper.mk
rm -f lib/*.so
endif
.PHONY: package-deb
package-deb: mercury
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
./build_pkg.sh -t deb
endif
.PHONY: package-rpm
package-rpm: mercury
ifneq ($(wildcard src/Makefile), src/Makefile)
@echo $(COLOR_RED) "error: run ./configure before running make (src/Makefile is missing)" $(COLOR_OFF)
else
./build_pkg.sh -t rpm
endif
.PHONY: format
format:
./utils/indent_files.sh src/*.{c,h} src/python-inference/*.py python/*.py python/*/*.py python/*/*/*.py
.PHONY: increment-patchlevel increment-minor-version increment-major-version
increment-patchlevel:
cd src; make increment-patchlevel
echo $(COLOR_GREEN) "created git tag; ready for 'git push origin <tagname>'"
increment-minor-version:
cd src; make increment-minor-version
echo $(COLOR_GREEN) "created git tag; ready for 'git push origin <tagname>'"
increment-major-version:
cd src; make increment-major-version
echo $(COLOR_GREEN) "created git tag; ready for 'git push origin <tagname>'"
# EOF