-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathMakemodule.am
368 lines (322 loc) · 13.9 KB
/
Makemodule.am
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
program_libs = ${project_libs}
# Programs need to link the c++ runtime if everything was compiled statically.
if !ENABLE_SHARED
program_libs += -lstdc++ -lm
endif
# Install data into /usr/local/bin
dist_bin_SCRIPTS = \
zproject.gsl \
zproject_projects.gsl \
zproject_class_api.gsl \
zproject_skeletons.gsl \
zproject_bench.gsl \
zproject_class.gsl \
zproject_git.gsl \
zproject_valgrind.gsl \
zproject_android.gsl \
zproject_autotools.gsl \
zproject_cmake.gsl \
zproject_cucumber.gsl \
zproject_cygwin.gsl \
zproject_debian.gsl \
zproject_delphi.gsl \
zproject_docker.gsl \
zproject_gh_actions.gsl \
zproject_gyp.gsl \
zproject_ios.gsl \
zproject_java.gsl \
zproject_java_lib.gsl \
zproject_java_msvc.gsl \
zproject_jenkins.gsl \
zproject_lua_ffi.gsl \
zproject_mingw32.gsl \
zproject_nodejs.gsl \
zproject_nuget.gsl \
zproject_obs.gsl \
zproject_python.gsl \
zproject_python_cffi.gsl \
zproject_qml.gsl \
zproject_qt.gsl \
zproject_redhat.gsl \
zproject_rpi.gsl \
zproject_ruby.gsl \
zproject_systemd.gsl \
zproject_travis.gsl \
zproject_vagrant.gsl \
zproject_vs2008.gsl \
zproject_vs20xx.gsl \
zproject_vs20xx_props.gsl \
zproject_known_projects.xml
if ENABLE_ZPROJECT_SELFTEST
# Directories with test fixtures optionally provided by the project,
# and with volatile RW data possibly created by a selftest program.
# It is up to the project authors to populate the RO directory with
# filenames called from the selftest methods, if any. They will be
# EXTRA_DISTed by the recipes generated with with zproject, however,
# and copied into builddir (if different from srcdir) to simplify
# the "distcheck" and similar tests (so selftest can use same paths).
# Note that the RO directory must exist to fulfill EXTRA_DIST, so we
# add a stub file that can be committed to SCM by project developers.
# The RW directory will be automatically wiped by "make distclean".
SELFTEST_DIR_RO = src/selftest-ro
SELFTEST_DIR_RW = src/selftest-rw
# This is recreated on every invocation (as a selftest dependency),
# so tests run in a clean environment
$(top_builddir)/$(SELFTEST_DIR_RW):
rm -rf "$@"
mkdir -p "$@"
# Note: for some reason "$<" misfired in rule below on Travis, so be explicit
if USING_VPATH
$(abs_top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_srcdir)/$(SELFTEST_DIR_RO)
@echo " COPYDIR $(SELFTEST_DIR_RO)"; \
rm -rf "$@"; \
cp -r "$(abs_top_srcdir)/$(SELFTEST_DIR_RO)" "$@"
$(top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_builddir)/$(SELFTEST_DIR_RO)
endif
$(SELFTEST_DIR_RO): $(top_builddir)/$(SELFTEST_DIR_RO)
CLEANFILES += $(top_builddir)/$(SELFTEST_DIR_RW)/*
# Note that this syntax dists the whole directory - including subdirs (if any)
EXTRA_DIST += $(SELFTEST_DIR_RO)
clean-local: clean-local-selftest-ro clean-local-selftest-rw
.PHONY: clean-local-selftest-ro
clean-local-selftest-ro:
@if test "$(top_builddir)" != "$(top_srcdir)" ; then \
if test -d "$(top_builddir)/$(SELFTEST_DIR_RO)" ; then \
chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \
rm -rf "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \
fi; \
fi
# Unlike CLEANFILES setting above, this one whould also wipe created subdirs
.PHONY: clean-local-selftest-rw
clean-local-selftest-rw:
@if test "$(top_builddir)" != "$(top_srcdir)" ; then \
if test -d "$(top_builddir)/$(SELFTEST_DIR_RW)" ; then \
chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \
rm -rf "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \
fi; \
fi
check-empty-selftest-rw:
if test -e $(top_builddir)/$(SELFTEST_DIR_RW) ; then \
if test `find "$(top_builddir)/$(SELFTEST_DIR_RW)" | wc -l` -lt 1 ; then \
echo "FATAL: selftest did not tidy up the data it wrote" >&2 ; \
find "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \
exit 2; \
else true ; fi; \
else true ; fi
check-local: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute $(builddir)/src/zproject_selftest
$(MAKE) check-empty-selftest-rw
check-verbose: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute $(builddir)/src/zproject_selftest -v
$(MAKE) check-empty-selftest-rw
# Run the selftest binary under valgrind to check for memory leaks
memcheck: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute valgrind --tool=memcheck \
--leak-check=full --show-reachable=yes --error-exitcode=1 \
--suppressions=$(srcdir)/src/.valgrind.supp \
$(VALGRIND_OPTIONS) \
$(builddir)/src/zproject_selftest
$(MAKE) check-empty-selftest-rw
memcheck-verbose: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute valgrind --tool=memcheck \
--leak-check=full --show-reachable=yes --error-exitcode=1 \
--suppressions=$(srcdir)/src/.valgrind.supp \
$(VALGRIND_OPTIONS) \
$(builddir)/src/zproject_selftest -v
$(MAKE) check-empty-selftest-rw
# Run the selftest binary under valgrind to check for performance leaks
callcheck: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute valgrind --tool=callgrind \
$(VALGRIND_OPTIONS) \
$(builddir)/src/zproject_selftest
$(MAKE) check-empty-selftest-rw
callcheck-verbose: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute valgrind --tool=callgrind \
$(VALGRIND_OPTIONS) \
$(builddir)/src/zproject_selftest -v
$(MAKE) check-empty-selftest-rw
# Run the selftest binary under gdb for debugging
debug: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute gdb -q \
$(builddir)/src/zproject_selftest
$(MAKE) check-empty-selftest-rw
debug-verbose: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute gdb -q \
--args $(builddir)/src/zproject_selftest -v
$(MAKE) check-empty-selftest-rw
# Run the selftest binary with verbose switch for tracing
animate: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$(LIBTOOL) --mode=execute $(builddir)/src/zproject_selftest -v
$(MAKE) check-empty-selftest-rw
animate-verbose: animate
if WITH_GCOV
coverage: src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
@echo "you had called configure --with-gcov"
lcov --base-directory . --directory . --zerocounters -q
$(MAKE) check
lcov --base-directory . --directory . --capture -o coverage.info
lcov --remove coverage.info "/usr*" -o coverage.info
lcov --remove coverage.info "zproject_selftest.c" -o coverage.info
$(RM) -rf coverage/*
genhtml -o coverage/ -t "zproject test coverage" --num-spaces 4 coverage.info
else
coverage: src/zproject_selftest
@echo "call make clean && configure --with-gcov to enable code coverage"
@exit 1
endif
endif #ENABLE_ZPROJECT_SELFTEST
bindings: python-bindings
python-bindings:
if ENABLE_BINDINGS_PYTHON
-( cd bindings/python && python setup.py install )
else
@echo "Python Bindings not enabled or missing setup.py... skipping"
endif
# A series of tests that the codebase and recipes are pretty, easy
# to maintain and with predictable behavior. These generally are not
# expected to directly expose functional issues in the code, but
# still - there can be many reasons for failing such tests, and
# many lurking issues uncoverable by making code stylish again.
CHECK_STYLE_DEPS = check-gitignore
if WITH_CLANG_FORMAT
CHECK_STYLE_DEPS += clang-format-check
endif
check-style: $(CHECK_STYLE_DEPS)
if WITH_CLANG_FORMAT
ALL_SOURCE_FILES = $(wildcard \
$(top_srcdir)/src/*.c \
$(top_srcdir)/src/*.cc \
$(top_srcdir)/src/*.cpp \
$(top_srcdir)/src/*.h \
$(top_srcdir)/src/*.hpp \
$(top_srcdir)/tests/*.c \
$(top_srcdir)/tests/*.cc \
$(top_srcdir)/tests/*.cpp \
$(top_srcdir)/tests/*.h \
$(top_srcdir)/tests/*.hpp \
$(top_srcdir)/perf/*.c \
$(top_srcdir)/perf/*.cc \
$(top_srcdir)/perf/*.cpp \
$(top_srcdir)/perf/*.h \
$(top_srcdir)/perf/*.hpp \
$(top_srcdir)/tools/*.c \
$(top_srcdir)/tools/*.cc \
$(top_srcdir)/tools/*.cpp \
$(top_srcdir)/tools/*.h \
$(top_srcdir)/tools/*.hpp \
$(top_srcdir)/include/*.h \
$(top_srcdir)/include/*.hpp \
)
# Check if any sources need to be fixed, report the filenames and an error code
clang-format-check: $(ALL_SOURCE_FILES)
@if test -z "$(CLANG_FORMAT)" ; then \
echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
exit 1 ; \
fi
@FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \
for FILE in $(ALL_SOURCE_FILES) ; do \
test -s $$FILE || continue ; \
$(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "<replacement " >/dev/null && \
{ echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \
done; \
if test "$$FAILED" != 0 ; then \
exit 1 ; \
fi
# Change source formatting
clang-format: $(ALL_SOURCE_FILES)
@if test -z "$(CLANG_FORMAT)" ; then \
echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \
exit 1 ; \
fi
$(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES)
# Change source formatting AND report the diff
clang-format-diff: clang-format
git diff $(ALL_SOURCE_FILES)
# A destructive (will change code in workspace) but informative check; this is
# primarily intended for CI temporary workspaces where mutilation is acceptable.
# The envvar/makearg CI_REQUIRE_GOOD_CLANG_FORMAT manages if this test is fatal.
clang-format-check-CI:
@echo "CI-checking code style ..." >&2
@if $(MAKE) clang-format-check ; then \
echo "SUCCESS : Style checks have passed" >&2 ; \
else \
echo "" >&2 ; \
if test -n "$(CLANG_FORMAT)" ; then \
echo "Style mismatches were found by clang-format; detailing below:" >&2 ; \
$(MAKE) VERBOSE=1 clang-format-diff ; \
fi ; \
if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
exit 1 ; \
fi ; \
echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 ; \
fi
else
clang-format clang-format-check clang-format-diff:
@echo "Install the clang-format program, reconfigure and re-run this request"
@exit 1
clang-format-check-CI:
@echo "Install the clang-format program, reconfigure and re-run this request"
@if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \
echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \
exit 1 ; \
fi ; \
echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2
endif
# Note: analysis is not a target executed by default, so there is no
# safety-net for the "cppcheck.xml" recipe; there is one for the wrapper.
# A developer is expected to install tools in build environment, if needed.
# The results can be used to produce some statistics how project quality
# changes over many builds (with a relevant Jenkins plugin, for example).
if WITH_CPPCHECK
cppcheck: cppcheck.xml
else
cppcheck:
@echo "NOT ENABLED: cppcheck static analysis. Please install the toolkit and reconfigure, and/or make cppcheck.xml directly."
endif
cppcheck.xml:
@echo "Performing cppcheck static analysis..."
cppcheck --enable=all --inconclusive --xml --xml-version=2 . 2>"$@"
@echo "The cppcheck static analysis is done"
# Note: this recipe tests that the Git-based workspace reports no changed
# or untracked files - meaning there are no unexpected behaviors in the
# recipes (when checking after a build), and nothing was missed while
# updating the project structure (when checking in the midst of development
# or after regenerating the zproject skeletons), for example. For best
# results, developers are advised to also run this after executing their
# tests, to make sure they are stateless and clean as well. Caller may
# export envvar (or pass make argument) CI_REQUIRE_GOOD_GITIGNORE=false
# to explicitly disable fatality of this check, while still logging it.
# This recipe is "stateless" by itself, not causing any workspace changes:
check-gitignore:
@(if which git >/dev/null 2>&1 ; then \
RES=0; \
echo "Checking for untracked and not-ignored files in the workspace (should have no output below)..."; \
git status -s | egrep '^\?\? ' && RES=1 ; \
echo "Checking for modified tracked files in the workspace (should have no output below)..."; \
git status -s | egrep '^ *M ' && RES=1 && git diff | cat ; \
if [ "$$RES" = 0 ]; then \
echo "PASS: $@"; exit 0 ; \
else \
if [ x"$(CI_REQUIRE_GOOD_GITIGNORE)" = xfalse ] ; then \
echo "WARNING: $@ found newly changed or untracked and not-ignored files (not a test failure due to CI_REQUIRE_GOOD_GITIGNORE==false)"; exit 0 ; \
fi; \
echo "FAIL: $@ (see workspace checks above)"; exit 1; \
fi; \
else \
echo "SKIP: $@ (no git)"; exit 0 ; \
fi )
if ENABLE_ZPROJECT_SELFTEST
# This calls the recipe above after building the project products and
# the selftest binary, and preparing the workspace for self-testing:
check-gitignore-all: all src/zproject_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO)
$@$(MAKE) check-gitignore
endif #ENABLE_ZPROJECT_SELFTEST
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################