diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 17:02:39 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 17:02:39 +0100 |
| commit | 3f3114921d643d347c8c9ad1e85de07d101c3e9f (patch) | |
| tree | 270eadb8a3a787ddc789919c4f1989f658303096 /Mk | |
| parent | 28d6bf03e1bb8c38fb7e09ade3c5a9c58d68182e (diff) | |
Split the Makefile into Mk fragments and fix the default target
Diffstat (limited to 'Mk')
| -rw-r--r-- | Mk/gzip.mk | 4 | ||||
| -rw-r--r-- | Mk/proxy.mk | 25 | ||||
| -rw-r--r-- | Mk/release.mk | 27 | ||||
| -rw-r--r-- | Mk/tests.mk | 72 | ||||
| -rw-r--r-- | Mk/zstd.mk | 3 |
5 files changed, 131 insertions, 0 deletions
diff --git a/Mk/gzip.mk b/Mk/gzip.mk new file mode 100644 index 0000000..70d6d62 --- /dev/null +++ b/Mk/gzip.mk | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_GZIP | ||
| 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS | ||
| 3 | |||
| 4 | LDFLAGS+=-lz | ||
diff --git a/Mk/proxy.mk b/Mk/proxy.mk new file mode 100644 index 0000000..2e876e9 --- /dev/null +++ b/Mk/proxy.mk | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # The proxy relays sync traffic between trackers and between multicast domains | ||
| 2 | # that cannot reach each other. It does not build; see the note at the top of | ||
| 3 | # proxy.c. Scheduled for v1.1.0, when these rules come back. | ||
| 4 | # | ||
| 5 | # LIBOWFAT_HEADERS=$(PREFIX)/libowfat | ||
| 6 | # LIBOWFAT_LIBRARY=$(PREFIX)/libowfat | ||
| 7 | # CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) | ||
| 8 | # LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat | ||
| 9 | # | ||
| 10 | # SOURCES_proxy=proxy.c ot_batch.c ot_fdstate.c ot_vector.c ot_mutex.c ot_random.c ot_scan.c ot_ip.c ot_socket.c | ||
| 11 | # CFLAGS_proxy=$(CFLAGS_production) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 12 | # CFLAGS_proxy_debug=$(CFLAGS_debug) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 13 | # | ||
| 14 | # BINARIES+=proxy proxy.debug | ||
| 15 | # | ||
| 16 | # proxy: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 17 | # $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 18 | # proxy.debug: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 19 | # $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 20 | |||
| 21 | proxy proxy.debug: | ||
| 22 | @echo "$@ is out of service until v1.1.0, see the note at the top of proxy.c" | ||
| 23 | @false | ||
| 24 | |||
| 25 | .PHONY: proxy proxy.debug | ||
diff --git a/Mk/release.mk b/Mk/release.mk new file mode 100644 index 0000000..63429ad --- /dev/null +++ b/Mk/release.mk | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # .tarball-version is what dist wrote into the tarball | ||
| 2 | # In a checkout it is absent and git answers instead. A release is always | ||
| 3 | # tagged, so in a tarball both of these are that tag, and the gitweb link | ||
| 4 | # is to it. Between releases there is no tag and the version is the commit. | ||
| 5 | VERSION=1.0.0 | ||
| 6 | |||
| 7 | TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v" | ||
| 8 | HAVE_GIT=command -v git >/dev/null && test -d .git | ||
| 9 | GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` | ||
| 10 | OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` | ||
| 11 | |||
| 12 | CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" | ||
| 13 | |||
| 14 | # Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by | ||
| 15 | # construction, so the working tree it was rolled from does not enter into it. | ||
| 16 | DISTNAME=opentracker-$(VERSION) | ||
| 17 | |||
| 18 | dist: | ||
| 19 | @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \ | ||
| 20 | { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; } | ||
| 21 | rm -rf $(DISTNAME) $(DISTNAME).tar.gz | ||
| 22 | git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - | ||
| 23 | git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version | ||
| 24 | tar -czf $(DISTNAME).tar.gz $(DISTNAME) | ||
| 25 | rm -rf $(DISTNAME) | ||
| 26 | |||
| 27 | .PHONY: dist | ||
diff --git a/Mk/tests.mk b/Mk/tests.mk new file mode 100644 index 0000000..d542044 --- /dev/null +++ b/Mk/tests.mk | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | BUILDDEPS+=Mk/tests.mk | ||
| 2 | |||
| 3 | # The modules under test are compiled straight into the test binary, so a test | ||
| 4 | # may reach a static function by including the source. tests/stubs.c supplies | ||
| 5 | # the few symbols those modules reference but the tests never reach. | ||
| 6 | TESTBIN=tests/runner | ||
| 7 | TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_urlencoded.c tests/t_iovec.c tests/t_vector.c tests/t_random.c tests/t_hex.c tests/t_accesslist.c tests/t_scan.c tests/t_buf.c tests/t_ip.c tests/t_socket.c tests/t_mutex.c tests/t_trackerlogic.c tests/t_workqueue.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c tests/t_fmt.c | ||
| 8 | TEST_UNITS=ot_urlencoded.c ot_fmt.c ot_event.c ot_batch.c ot_fdstate.c ot_buf.c ot_ip.c ot_socket.c ot_iovec.c ot_vector.c ot_random.c ot_hex.c ot_scan.c ot_accesslist.c ot_mutex.c ot_workqueue.c trackerlogic.c | ||
| 9 | TEST_HEADERS=tests/test.h $(HEADERS) | ||
| 10 | |||
| 11 | # A test binary is not a production binary, so it is built with the features | ||
| 12 | # the tests need to reach. | ||
| 13 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | ||
| 14 | CFLAGS_test=$(CFLAGS) -I. -g -O1 $(FEATURES_test) | ||
| 15 | |||
| 16 | # clang over $(CC) because the two toolchains do not check the same things. | ||
| 17 | CC_sanitize?=clang | ||
| 18 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 19 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | ||
| 20 | |||
| 21 | # Black box tests drive the real binary over the wire, so they cover the event | ||
| 22 | # loop and the parsers working together. The client timeout is cut right down | ||
| 23 | # so a test can reach the expiry sweep; tests/integration/test_expiry.py | ||
| 24 | # mirrors these two numbers. | ||
| 25 | PYTHON?=python3 | ||
| 26 | FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1 | ||
| 27 | CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 28 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined | ||
| 29 | CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | ||
| 30 | LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread | ||
| 31 | |||
| 32 | BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan | ||
| 33 | |||
| 34 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 35 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) | ||
| 36 | |||
| 37 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 38 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) | ||
| 39 | |||
| 40 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 41 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | ||
| 42 | |||
| 43 | opentracker.integration: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 44 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | ||
| 45 | |||
| 46 | opentracker.tsan: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 47 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) | ||
| 48 | |||
| 49 | check: $(TESTBIN) $(BINARY) | ||
| 50 | ./$(TESTBIN) | ||
| 51 | |||
| 52 | check-poll: $(TESTBIN).poll | ||
| 53 | ./$(TESTBIN).poll ot_event | ||
| 54 | |||
| 55 | check-sanitize: $(TESTBIN).sanitize | ||
| 56 | ./$(TESTBIN).sanitize | ||
| 57 | |||
| 58 | check-integration: opentracker.integration | ||
| 59 | OPENTRACKER=./opentracker.integration $(PYTHON) -m unittest discover -s tests/integration | ||
| 60 | |||
| 61 | check-tsan: opentracker.tsan | ||
| 62 | OPENTRACKER=./opentracker.tsan $(PYTHON) -m unittest discover -s tests/integration | ||
| 63 | |||
| 64 | # Cheapest first, so a quick failure comes back quickly. | ||
| 65 | check-all: | ||
| 66 | $(MAKE) check | ||
| 67 | $(MAKE) check-poll | ||
| 68 | $(MAKE) check-sanitize | ||
| 69 | $(MAKE) check-integration | ||
| 70 | $(MAKE) check-tsan | ||
| 71 | |||
| 72 | .PHONY: check check-poll check-sanitize check-integration check-tsan check-all | ||
diff --git a/Mk/zstd.mk b/Mk/zstd.mk new file mode 100644 index 0000000..2bb56be --- /dev/null +++ b/Mk/zstd.mk | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD | ||
| 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS | ||
| 3 | LDFLAGS+=-lzstd | ||
