From 82a97066f842f34db2556673d421aa9290ffe757 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 17:04:36 +0100 Subject: Keep the build's own flags out of CFLAGS, CPPFLAGS, LDFLAGS and LDLIBS --- Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 688a2c4..ddf1e05 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,19 @@ include Mk/gzip.mk # arc4random is part of libc on the BSDs, on macOS and on glibc 2.36 and # newer. On an older glibc or on musl it comes from libbsd instead. -#LDFLAGS+=-lbsd +#OT_LDLIBS+=-lbsd -CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread -LDFLAGS+=-pthread +CFLAGS?=-O3 + +# What the build requires, whatever you do to those. +OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread +OT_LDFLAGS+=-pthread -OPTS_production=-O3 OPTS_debug=-D_DEBUG -g -ggdb +COMPILE=$(CPPFLAGS) $(OT_CFLAGS) $(FEATURES) +LINK=$(LDFLAGS) $(OT_LDFLAGS) $(LDLIBS) $(OT_LDLIBS) + BINARY=opentracker 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 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 BUILDSTAMP=.buildstamp BUILDDEPS=Makefile $(BUILDSTAMP) -CFLAGS_production=$(CFLAGS) $(OPTS_production) $(FEATURES) -CFLAGS_debug=$(CFLAGS) $(OPTS_debug) $(FEATURES) - all: $(BINARY) $(BINARY).debug $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) - $(CC) -o $@ $(CFLAGS_production) $(SOURCES) $(LDFLAGS) + $(CC) -o $@ $(CFLAGS) $(COMPILE) $(SOURCES) $(LINK) $(STRIP) $@ $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) - $(CC) -o $@ $(CFLAGS_debug) $(SOURCES) $(LDFLAGS) + $(CC) -o $@ $(OPTS_debug) $(COMPILE) $(SOURCES) $(LINK) $(BUILDSTAMP): FORCE - @echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" > $@ + @echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@ clean: rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ -- cgit v1.3