forked from ccache/ccache
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dev.mk.in
244 lines (211 loc) · 7.73 KB
/
dev.mk.in
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
# GNU make syntax reigns in this file.
all_cflags += -Werror
all_cppflags += -MD -MP -MF .deps/$(subst .._,,$(subst /,_,$(subst $(srcdir)/,,$<))).d -MQ $@
all_cxxflags += -Werror
A2X = a2x
ASCIIDOC = asciidoc
CLANG_FORMAT = clang-format
CLANG_TIDY = clang-tidy
COMPILEDB = compiledb
CPPCHECK = cppcheck
CPPCHECK_SUPPRESSIONS = misc/cppcheck-suppressions.txt
DOCKER = docker
SCAN_BUILD = scan-build
SHELLCHECK = shellcheck
SHELLCHECK_EXCLUDES = misc/shellcheck-excludes.txt
TEST = test
git := git --git-dir=$(srcdir)/.git
version := \
$(shell ($(git) describe --exact-match \
|| echo "$$($(git) rev-parse --abbrev-ref HEAD).$$($(git) rev-parse HEAD | cut -c1-8)") 2>/dev/null \
| sed -re 's/^v([0-9].+)/\1/')
dist_dir = ccache-$(version)
dist_archives = \
ccache-$(version).tar.gz \
ccache-$(version).tar.xz
generated_docs = \
LICENSE.html \
doc/AUTHORS.html \
doc/MANUAL.html \
doc/NEWS.html \
doc/ccache.1
built_dist_files = $(generated_sources) $(generated_docs)
non_third_party_headers_without_cpp = \
src/Checksum.hpp \
src/File.hpp \
src/FormatNonstdStringView.hpp \
src/NonCopyable.hpp \
src/NullCompressor.hpp \
src/NullDecompressor.hpp \
src/ProgressBar.hpp \
src/ScopeGuard.hpp \
src/Stat.hpp \
src/StdMakeUnique.hpp \
src/ThreadPool.hpp \
src/exceptions.hpp \
src/macroskip.hpp \
src/system.hpp \
unittest/framework.hpp \
unittest/util.hpp
non_third_party_headers = $(subst .cpp,.hpp,$(non_third_party_sources)) \
$(non_third_party_headers_without_cpp)
third_party_headers = \
src/third_party/catch.hpp \
src/third_party/fmt/core.h \
src/third_party/fmt/format-inl.h \
src/third_party/fmt/format.h \
src/third_party/getopt_long.h \
src/third_party/minitrace.h \
src/third_party/nonstd/optional.hpp \
src/third_party/nonstd/string_view.hpp \
src/third_party/xxhash.h
headers = $(non_third_party_headers) $(third_party_headers)
files_to_clean += *.tar.gz *.tar.xz *.xml doc/*.xml .deps/* perfdir.*
files_to_clean += compile_commands.json
files_to_distclean += $(built_dist_files) src/version.cpp
files_to_distclean += .deps dev.mk
source_dist_files = \
$(non_third_party_sources) \
$(third_party_sources) \
$(headers) \
$(test_sources) \
CONTRIBUTING.md \
GPL-3.0.txt \
LICENSE.adoc \
Makefile.in \
README.md \
autogen.sh \
config.guess \
config.h.in \
config.sub \
configure \
configure.ac \
dev.mk.in \
doc/AUTHORS.adoc \
doc/MANUAL.adoc \
doc/NEWS.adoc \
install-sh \
m4 \
src/main.cpp \
src/third_party/minitrace.c \
test/run \
test/suites/*.bash \
unittest/catch2_tests.cpp \
unittest/catch2_tests.hpp
dist_files = \
$(addprefix $(srcdir)/, $(source_dist_files)) \
$(built_dist_files)
ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' src/version.cpp 2>/dev/null),$(version))
$(shell echo 'extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "$(version)";' >src/version.cpp)
endif
src/version.o: src/version.cpp
.PHONY: dist
dist: $(dist_archives)
$(dist_archives): $(dist_files)
tmpdir=$$(mktemp -d /tmp/tmp-ccache-dist.XXXXXX) && \
dir=$$tmpdir/$(dist_dir) && \
mkdir $$dir && \
(cd $(srcdir) && \
rsync -r --relative $(source_dist_files) $$dir) && \
cp $(srcdir)/doc/INSTALL-from-release-archive.md $$dir/INSTALL.md && \
(cd $(builddir) && \
rsync -r --relative $(built_dist_files) $$dir) && \
echo "Remove this file to enable developer mode." >$$dir/dev_mode_disabled && \
(cd $$tmpdir && \
tarcompression= && \
case $@ in \
*.gz) tarcompression=-z ;; \
*.xz) tarcompression=-J ;; \
esac && \
tar -c $$tarcompression -f $(CURDIR)/$@ $(dist_dir)) && \
rm -rf $$tmpdir
# $(1): extra configure options
define do_distcheck
tmpdir=$$(mktemp -d /tmp/tmp-ccache-distcheck.XXXXXX) && \
(cd $$tmpdir && \
tar xf $(CURDIR)/$< && \
mkdir -p $(dist_dir)/build && \
chmod -R a-w $(dist_dir) && \
chmod u+w $(dist_dir)/build && \
cd $(dist_dir)/build && \
../configure --enable-more-warnings --prefix=$$tmpdir/root --sysconfdir=/etc $(1) && \
$(MAKE) install V=1 && \
$(MAKE) installcheck V=1) && \
chmod -R u+w $$tmpdir/$(dist_dir) && \
rm -rf $$tmpdir
endef
.PHONY: distcheck
distcheck: $(firstword $(dist_archives))
$(call do_distcheck, CFLAGS=-Werror CXXFLAGS=-Werror)
$(call do_distcheck, --with-libzstd-from-internet --with-libb2-from-internet)
$(call do_distcheck, CC=clang CXX=clang++)
.PHONY: docs
docs: $(generated_docs)
%.html: %.adoc
@mkdir -p $(@D)
$(if $(quiet),@echo " ASCIIDOC $@")
$(Q)$(ASCIIDOC) -o $@ -a revnumber=$(version) -a toc -b xhtml11 $<
%.xml: %.adoc
@mkdir -p $(@D)
# Make literals stand out as bold in the man page:
$(if $(quiet),@echo " ASCIIDOC $@")
$(Q)$(ASCIIDOC) -a revnumber=$(version) -d manpage -b docbook -o - $< | \
perl -pe 's!<literal>(.*?)</literal>!<emphasis role="strong">\1</emphasis>!g' >$@
doc/ccache.1: doc/MANUAL.xml
$(if $(quiet),@echo " A2X $@")
$(Q)$(A2X) --doctype manpage --format manpage $<
.PHONY: update-authors
update-authors:
git log --pretty=format:"%H %aN%n%(trailers:only)" \
| grep -Ev 'd7c5056beda5483fcd5c098165fffd9be86fe98d|http|Conflicts:' \
| grep '^[^ ]' \
| sed -r -e 's/[^ ]+/*/' -e 's/<.*//' -e 's/ *$$//' \
| sort -u \
| perl -00 -p -i -e 's/^\*.*/<STDIN> . "\n"/es' doc/AUTHORS.adoc
.PHONY: check-syntax
check-syntax:
$(CC) $(all_cppflags) -I. $(all_cxxflags) -S -o /dev/null $(CHK_SOURCES)
.PHONY: cppcheck
cppcheck:
cd $(srcdir) && $(CPPCHECK) --suppressions-list=$(CPPCHECK_SUPPRESSIONS) \
--inline-suppr -q --enable=all --force -I $(CURDIR) \
--template='cppcheck: warning: {id}:{file}:{line}: {message}' \
$(non_third_party_sources) src/main.cpp $(test_sources)
.PHONY: shellcheck
shellcheck: test/suites/*.bash
$(SHELLCHECK) --shell=bash --exclude=$(shell sed -e 's/:.*//' <$(SHELLCHECK_EXCLUDES) | grep -v '#' | tr '\n' ',' | sed -e 's/,$$//') $^
.PHONY: format
format:
@cd $(srcdir) && echo $(non_third_party_headers) $(non_third_party_sources) $(test_sources) | xargs -n1 -P8 \
misc/run-clang-format
# Not using parallel execution because target is most likely being run on non-interactive CI system,
# so no user is waiting for immediate results, and it avoids possibly interleaved output.
.PHONY: check_format
check_format:
@[ -t 1 ] && export cf_diff_color="--color=always"; \
cd $(srcdir) && echo $(non_third_party_headers) $(non_third_party_sources) $(test_sources) | xargs -n1 -P1 \
misc/run-clang-format --check || \
{ echo; echo "Error: Sources are not formatted with clang-format."; \
echo 'Run "make format" or apply the above diff.'; }
# pip install compiledb
compile_commands.json:
$(COMPILEDB) -n $(MAKE) all unittest
.PHONY: tidy
tidy: compile_commands.json
$(CLANG_TIDY) $(all_sources)
.PHONY: analyze
analyze:
$(SCAN_BUILD) --use-cc="$(CC)" --use-c++="$(CXX)" $(srcdir)/configure
$(SCAN_BUILD) --use-cc="$(CC)" --use-c++="$(CXX)" --status-bugs $(MAKE) -B
BUILDENV = ubuntu
DOCKER_IMAGE_TAG = ccache/build:$(BUILDENV)
.PHONY: docker
docker: buildenv/$(BUILDENV)/Dockerfile
$(DOCKER) inspect $(DOCKER_IMAGE_TAG) >/dev/null || $(DOCKER) build -t $(DOCKER_IMAGE_TAG) buildenv/$(BUILDENV)
$(DOCKER) run --rm -v $(PWD):/build -w /build $(DOCKER_IMAGE_TAG) misc/build.sh $(TEST)
.PHONY: travis
travis: .travis/Dockerfile
$(DOCKER) inspect travis-build >/dev/null || $(DOCKER) build -t travis-build .travis
$(DOCKER) run --rm --volume $(PWD):/src --tmpfs /dst:rw,exec --env ASAN_OPTIONS='$(ASAN_OPTIONS)' travis-build \
sh -c "cd /src && ./autogen.sh && cd /dst && CC=$(CC) CFLAGS='$(CFLAGS)' CXX=$(CXX) CXXFLAGS='$(CXXFLAGS)' LDFLAGS='$(LDFLAGS)' /src/configure $(CONFIGURE) && CC=$(CC) CFLAGS='$(CFLAGS)' make V=$(V) && CC=$(CC) make V=$(V) $(TEST)"
-include .deps/*.d