summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-02 17:04:36 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-02 17:04:36 +0100
commit82a97066f842f34db2556673d421aa9290ffe757 (patch)
tree656ee9a78e605504fe089ee294b88e264e2246ab
parent3f3114921d643d347c8c9ad1e85de07d101c3e9f (diff)
Keep the build's own flags out of CFLAGS, CPPFLAGS, LDFLAGS and LDLIBS
-rw-r--r--Makefile22
-rw-r--r--Mk/gzip.mk2
-rw-r--r--Mk/release.mk2
-rw-r--r--Mk/tests.mk12
-rw-r--r--Mk/zstd.mk2
5 files changed, 21 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 688a2c4..ddf1e05 100644
--- a/Makefile
+++ b/Makefile
@@ -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
34CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread 34CFLAGS?=-O3
35LDFLAGS+=-pthread 35
36# What the build requires, whatever you do to those.
37OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread
38OT_LDFLAGS+=-pthread
36 39
37OPTS_production=-O3
38OPTS_debug=-D_DEBUG -g -ggdb 40OPTS_debug=-D_DEBUG -g -ggdb
39 41
42COMPILE=$(CPPFLAGS) $(OT_CFLAGS) $(FEATURES)
43LINK=$(LDFLAGS) $(OT_LDFLAGS) $(LDLIBS) $(OT_LDLIBS)
44
40BINARY=opentracker 45BINARY=opentracker
41HEADERS=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 46HEADERS=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
42SOURCES=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 47SOURCES=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
49BUILDSTAMP=.buildstamp 54BUILDSTAMP=.buildstamp
50BUILDDEPS=Makefile $(BUILDSTAMP) 55BUILDDEPS=Makefile $(BUILDSTAMP)
51 56
52CFLAGS_production=$(CFLAGS) $(OPTS_production) $(FEATURES)
53CFLAGS_debug=$(CFLAGS) $(OPTS_debug) $(FEATURES)
54
55all: $(BINARY) $(BINARY).debug 57all: $(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
67clean: 69clean:
68 rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ 70 rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~
diff --git a/Mk/gzip.mk b/Mk/gzip.mk
index 70d6d62..3ae53b3 100644
--- a/Mk/gzip.mk
+++ b/Mk/gzip.mk
@@ -1,4 +1,4 @@
1FEATURES+=-DWANT_COMPRESSION_GZIP 1FEATURES+=-DWANT_COMPRESSION_GZIP
2#FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS 2#FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS
3 3
4LDFLAGS+=-lz 4OT_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
9GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` 9GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'`
10OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` 10OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'`
11 11
12CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" 12OT_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.
13FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE 13FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE
14CFLAGS_test=$(CFLAGS) -I. -g -O1 $(FEATURES_test) 14CFLAGS_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.
17CC_sanitize?=clang 17CC_sanitize?=clang
18CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer 18CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer
19LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined 19LDFLAGS_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.
25PYTHON?=python3 25PYTHON?=python3
26FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1 26FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1
27CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer 27CFLAGS_integration=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer
28LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined 28LDFLAGS_integration=$(LINK) -fsanitize=address,undefined
29CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer 29CFLAGS_tsan=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer
30LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread 30LDFLAGS_tsan=$(LINK) -fsanitize=thread
31 31
32BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan 32BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan
33 33
diff --git a/Mk/zstd.mk b/Mk/zstd.mk
index 2bb56be..8c1fc40 100644
--- a/Mk/zstd.mk
+++ b/Mk/zstd.mk
@@ -1,3 +1,3 @@
1FEATURES+=-DWANT_COMPRESSION_ZSTD 1FEATURES+=-DWANT_COMPRESSION_ZSTD
2#FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS 2#FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS
3LDFLAGS+=-lzstd 3OT_LDLIBS+=-lzstd