diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 17:04:36 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 17:04:36 +0100 |
| commit | 82a97066f842f34db2556673d421aa9290ffe757 (patch) | |
| tree | 656ee9a78e605504fe089ee294b88e264e2246ab | |
| parent | 3f3114921d643d347c8c9ad1e85de07d101c3e9f (diff) | |
Keep the build's own flags out of CFLAGS, CPPFLAGS, LDFLAGS and LDLIBS
| -rw-r--r-- | Makefile | 22 | ||||
| -rw-r--r-- | Mk/gzip.mk | 2 | ||||
| -rw-r--r-- | Mk/release.mk | 2 | ||||
| -rw-r--r-- | Mk/tests.mk | 12 | ||||
| -rw-r--r-- | Mk/zstd.mk | 2 |
5 files changed, 21 insertions, 19 deletions
| @@ -29,14 +29,19 @@ include Mk/gzip.mk | |||
| 29 | 29 | ||
| 30 | # arc4random is part of libc on the BSDs, on macOS and on glibc 2.36 and | 30 | # arc4random is part of libc on the BSDs, on macOS and on glibc 2.36 and |
| 31 | # newer. On an older glibc or on musl it comes from libbsd instead. | 31 | # newer. On an older glibc or on musl it comes from libbsd instead. |
| 32 | #LDFLAGS+=-lbsd | 32 | #OT_LDLIBS+=-lbsd |
| 33 | 33 | ||
| 34 | CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread | 34 | CFLAGS?=-O3 |
| 35 | LDFLAGS+=-pthread | 35 | |
| 36 | # What the build requires, whatever you do to those. | ||
| 37 | OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread | ||
| 38 | OT_LDFLAGS+=-pthread | ||
| 36 | 39 | ||
| 37 | OPTS_production=-O3 | ||
| 38 | OPTS_debug=-D_DEBUG -g -ggdb | 40 | OPTS_debug=-D_DEBUG -g -ggdb |
| 39 | 41 | ||
| 42 | COMPILE=$(CPPFLAGS) $(OT_CFLAGS) $(FEATURES) | ||
| 43 | LINK=$(LDFLAGS) $(OT_LDFLAGS) $(LDLIBS) $(OT_LDLIBS) | ||
| 44 | |||
| 40 | BINARY=opentracker | 45 | BINARY=opentracker |
| 41 | HEADERS=trackerlogic.h ot_urlencoded.h ot_batch.h ot_buf.h ot_event.h ot_fdstate.h ot_fmt.h ot_hex.h ot_ip.h ot_config.h ot_scan.h ot_socket.h ot_tcp.h ot_worker.h ot_workqueue.h ot_mutex.h ot_random.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h | 46 | HEADERS=trackerlogic.h ot_urlencoded.h ot_batch.h ot_buf.h ot_event.h ot_fdstate.h ot_fmt.h ot_hex.h ot_ip.h ot_config.h ot_scan.h ot_socket.h ot_tcp.h ot_worker.h ot_workqueue.h ot_mutex.h ot_random.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h |
| 42 | SOURCES=opentracker.c trackerlogic.c ot_urlencoded.c ot_batch.c ot_buf.c ot_event.c ot_fdstate.c ot_fmt.c ot_hex.c ot_ip.c ot_config.c ot_scan.c ot_socket.c ot_tcp.c ot_worker.c ot_workqueue.c ot_mutex.c ot_random.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c | 47 | SOURCES=opentracker.c trackerlogic.c ot_urlencoded.c ot_batch.c ot_buf.c ot_event.c ot_fdstate.c ot_fmt.c ot_hex.c ot_ip.c ot_config.c ot_scan.c ot_socket.c ot_tcp.c ot_worker.c ot_workqueue.c ot_mutex.c ot_random.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c |
| @@ -49,20 +54,17 @@ BINARIES=$(BINARY) $(BINARY).debug | |||
| 49 | BUILDSTAMP=.buildstamp | 54 | BUILDSTAMP=.buildstamp |
| 50 | BUILDDEPS=Makefile $(BUILDSTAMP) | 55 | BUILDDEPS=Makefile $(BUILDSTAMP) |
| 51 | 56 | ||
| 52 | CFLAGS_production=$(CFLAGS) $(OPTS_production) $(FEATURES) | ||
| 53 | CFLAGS_debug=$(CFLAGS) $(OPTS_debug) $(FEATURES) | ||
| 54 | |||
| 55 | all: $(BINARY) $(BINARY).debug | 57 | all: $(BINARY) $(BINARY).debug |
| 56 | 58 | ||
| 57 | $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) | 59 | $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 58 | $(CC) -o $@ $(CFLAGS_production) $(SOURCES) $(LDFLAGS) | 60 | $(CC) -o $@ $(CFLAGS) $(COMPILE) $(SOURCES) $(LINK) |
| 59 | $(STRIP) $@ | 61 | $(STRIP) $@ |
| 60 | 62 | ||
| 61 | $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) | 63 | $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 62 | $(CC) -o $@ $(CFLAGS_debug) $(SOURCES) $(LDFLAGS) | 64 | $(CC) -o $@ $(OPTS_debug) $(COMPILE) $(SOURCES) $(LINK) |
| 63 | 65 | ||
| 64 | $(BUILDSTAMP): FORCE | 66 | $(BUILDSTAMP): FORCE |
| 65 | @echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" > $@ | 67 | @echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@ |
| 66 | 68 | ||
| 67 | clean: | 69 | clean: |
| 68 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ | 70 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ |
| @@ -1,4 +1,4 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_GZIP | 1 | FEATURES+=-DWANT_COMPRESSION_GZIP |
| 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS | 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS |
| 3 | 3 | ||
| 4 | LDFLAGS+=-lz | 4 | OT_LDLIBS+=-lz |
diff --git a/Mk/release.mk b/Mk/release.mk index 63429ad..5c4afe9 100644 --- a/Mk/release.mk +++ b/Mk/release.mk | |||
| @@ -9,7 +9,7 @@ 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; }'` | 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; }'` | 10 | OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` |
| 11 | 11 | ||
| 12 | CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" | 12 | OT_CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" |
| 13 | 13 | ||
| 14 | # Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by | 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. | 15 | # construction, so the working tree it was rolled from does not enter into it. |
diff --git a/Mk/tests.mk b/Mk/tests.mk index d542044..8e63839 100644 --- a/Mk/tests.mk +++ b/Mk/tests.mk | |||
| @@ -11,12 +11,12 @@ TEST_HEADERS=tests/test.h $(HEADERS) | |||
| 11 | # A test binary is not a production binary, so it is built with the features | 11 | # A test binary is not a production binary, so it is built with the features |
| 12 | # the tests need to reach. | 12 | # the tests need to reach. |
| 13 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | 13 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE |
| 14 | CFLAGS_test=$(CFLAGS) -I. -g -O1 $(FEATURES_test) | 14 | CFLAGS_test=-I. -g -O1 $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_test) |
| 15 | 15 | ||
| 16 | # clang over $(CC) because the two toolchains do not check the same things. | 16 | # clang over $(CC) because the two toolchains do not check the same things. |
| 17 | CC_sanitize?=clang | 17 | CC_sanitize?=clang |
| 18 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | 18 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer |
| 19 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | 19 | LDFLAGS_sanitize=$(LINK) -fsanitize=address,undefined |
| 20 | 20 | ||
| 21 | # Black box tests drive the real binary over the wire, so they cover the event | 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 | 22 | # loop and the parsers working together. The client timeout is cut right down |
| @@ -24,10 +24,10 @@ LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | |||
| 24 | # mirrors these two numbers. | 24 | # mirrors these two numbers. |
| 25 | PYTHON?=python3 | 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 | 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 | 27 | CFLAGS_integration=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer |
| 28 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined | 28 | LDFLAGS_integration=$(LINK) -fsanitize=address,undefined |
| 29 | CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | 29 | CFLAGS_tsan=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer |
| 30 | LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread | 30 | LDFLAGS_tsan=$(LINK) -fsanitize=thread |
| 31 | 31 | ||
| 32 | BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan | 32 | BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan |
| 33 | 33 | ||
| @@ -1,3 +1,3 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD | 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD |
| 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS | 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS |
| 3 | LDFLAGS+=-lzstd | 3 | OT_LDLIBS+=-lzstd |
