-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (88 loc) · 3.71 KB
/
Copy pathMakefile
File metadata and controls
111 lines (88 loc) · 3.71 KB
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
CC ?= cc
CPPFLAGS ?=
EXTRA_CPPFLAGS ?=
CFLAGS ?= -std=c11 -Wall -Wextra -Wpedantic -O2
LDFLAGS ?=
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
STATIC_LDFLAGS ?=
else
STATIC_LDFLAGS ?= -static
endif
TEST_LDFLAGS ?=
VERSION_BASE ?= $(shell bash .github/scripts/resolve_version.sh --base 2>/dev/null || printf dev)
VERSION ?= $(shell if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then git describe --tags --exact-match --dirty 2>/dev/null || printf '%s-%s%s\n' "$(VERSION_BASE)" "$$(git rev-parse --short HEAD)" "$$(git diff --quiet 2>/dev/null || echo -dirty)"; else printf '%s\n' "$(VERSION_BASE)"; fi)
VERSION_CPPFLAG := -DHOLD_VERSION=\"$(VERSION)\"
# Every translation unit. wildcard is portable in GNU make; one glob per layer
# directory (GNU make has no portable recursive **). main.c sits directly
# under src/; the layers live in src/<layer>/.
SRCS := $(wildcard src/*.c) \
$(wildcard src/core/*.c) \
$(wildcard src/platform/*.c) \
$(wildcard src/store/*.c) \
$(wildcard src/term/*.c) \
$(wildcard src/console/*.c) \
$(wildcard src/access/*.c) \
$(wildcard src/runtime/*.c) \
$(wildcard src/viewer/*.c) \
$(wildcard src/cli/*.c)
# Separate object trees per build "personality" so the test objects (built with
# -DHOLD_TESTING and a different HOLD_BOOT_ID_PATH) can never be linked
# into a release binary, and vice versa.
OBJS := $(patsubst src/%.c,obj/%.o,$(SRCS))
TEST_OBJS := $(patsubst src/%.c,obj-test/%.o,$(SRCS))
INCLUDES := -Iinclude
ALL_CPPFLAGS := $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(INCLUDES) $(VERSION_CPPFLAG)
TEST_CPPFLAGS := -DHOLD_TESTING -DHOLD_BOOT_ID_PATH='"/tmp/hold_test_boot_id"'
all: hold
obj/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
hold: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -o $@ $(OBJS)
hold-dynamic: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o hold-dynamic $(OBJS)
obj-test/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(ALL_CPPFLAGS) $(TEST_CPPFLAGS) $(CFLAGS) -c -o $@ $<
test: $(TEST_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(TEST_LDFLAGS) -o hold $(TEST_OBJS)
@bash tests/test_hold.sh
@$(MAKE) viewer-filter-test
@$(MAKE) logidx-recovery-test
@bash tests/test_version_makefile.sh
@bash tests/test_release_installer.sh
@$(MAKE) test-040
viewer-filter-test:
$(CC) $(ALL_CPPFLAGS) $(TEST_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o viewer-filter-test tests/viewer_filter_test.c src/viewer/filter.c src/core/logidx.c src/core/json.c src/core/util.c src/platform/paths.c
@./viewer-filter-test
logidx-recovery-test:
$(CC) $(ALL_CPPFLAGS) $(TEST_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o logidx-recovery-test tests/logidx_recovery_test.c src/core/logidx.c src/core/json.c src/core/util.c src/platform/paths.c
@./logidx-recovery-test
test-040: hold-dynamic
@HOLD_BIN=./hold-dynamic bash tests/test_040_dockerish.sh
print-version:
@printf '%s\n' '$(VERSION)'
check: test
review-build:
@bash scripts/build_review.sh
review-fixture:
@bash scripts/create_review_fixture.sh
demo:
@bash scripts/demo.sh start
demo-stop:
@bash scripts/demo.sh stop
demo-status:
@bash scripts/demo.sh status
# Full local CI mirror (one command, same rigor as GitHub CI): static + dynamic
# -Werror builds, the regression suite + hash-vector, ASan/UBSan, cppcheck, and
# the layer-dependency lint. Skips (visibly) only what the local toolchain lacks.
ci:
@bash scripts/ci.sh
# Layer dependency-direction lint, shared verbatim with the GitHub CI job.
lint:
@bash scripts/lint_layers.sh
clean:
rm -f hold hold-dynamic viewer-filter-test logidx-recovery-test
rm -rf obj obj-test
.PHONY: all clean test test-040 check ci lint viewer-filter-test logidx-recovery-test print-version review-build review-fixture demo demo-stop demo-status