blob: d2e0c2ddaba718ef6a89280b673ede6ce0746f1d (
plain)
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
|
PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
MANDIR?=$(PREFIX)/share/man
STRIP?=strip
#FEATURES+=-DWANT_V4_ONLY
#FEATURES+=-DWANT_ACCESSLIST_BLACK
#FEATURES+=-DWANT_ACCESSLIST_WHITE
#FEATURES+=-DWANT_DYNAMIC_ACCESSLIST
#FEATURES+=-DWANT_SYNC_LIVE
#FEATURES+=-DWANT_IP_FROM_QUERY_STRING
#FEATURES+=-DWANT_RESTRICT_STATS
#FEATURES+=-DWANT_IP_FROM_PROXY
#FEATURES+=-DWANT_LOG_NUMWANT
#FEATURES+=-DWANT_MODEST_FULLSCRAPES
#FEATURES+=-DWANT_SPOT_WOODPECKER
#FEATURES+=-DWANT_SYSLOGS
#FEATURES+=-DWANT_DEV_RANDOM
FEATURES+=-DWANT_FULLSCRAPE
# Buckets the torrent table is split into, as a power of two, 8 to 16. More
# buckets make inserting a new torrent cheaper and cost memory, which is worth
# it for a tracker carrying millions of torrents and not for one carrying
# thousands. DESIGN has the measurements.
FEATURES+=-DOT_BUCKET_COUNT_BITS=10
#FEATURES+=-D_DEBUG_HTTPERROR
#FEATURES+=-D_DEBUG_RANDOMTORRENTS
# Compression support, off unless included. Each file carries a second switch
# to compress even where the client did not ask.
include Mk/gzip.mk
#include Mk/zstd.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.
#OT_LDLIBS+=-lbsd
CFLAGS?=-O3
OT_CFLAGS+=-Wall -Wextra -Wwrite-strings -pipe -pthread
OT_LDFLAGS+=-pthread
OPTS_debug=-D_DEBUG -g -ggdb
COMPILE=$(CPPFLAGS) $(OT_CFLAGS) $(FEATURES)
LINK=$(LDFLAGS) $(OT_LDFLAGS) $(LDLIBS) $(OT_LDLIBS)
BINARY=opentracker
HEADERS=src/trackerlogic.h src/ot_urlencoded.h src/ot_batch.h src/ot_buf.h src/ot_event.h src/ot_fdstate.h src/ot_fmt.h src/ot_hex.h src/ot_ip.h src/ot_config.h src/ot_scan.h src/ot_socket.h src/ot_tcp.h src/ot_worker.h src/ot_workqueue.h src/ot_mutex.h src/ot_random.h src/ot_stats.h src/ot_vector.h src/ot_clean.h src/ot_udp.h src/ot_iovec.h src/ot_fullscrape.h src/ot_accesslist.h src/ot_http.h src/ot_livesync.h src/ot_rijndael.h
SOURCES=src/opentracker.c src/trackerlogic.c src/ot_urlencoded.c src/ot_batch.c src/ot_buf.c src/ot_event.c src/ot_fdstate.c src/ot_fmt.c src/ot_hex.c src/ot_ip.c src/ot_config.c src/ot_scan.c src/ot_socket.c src/ot_tcp.c src/ot_worker.c src/ot_workqueue.c src/ot_mutex.c src/ot_random.c src/ot_stats.c src/ot_vector.c src/ot_clean.c src/ot_udp.c src/ot_iovec.c src/ot_fullscrape.c src/ot_accesslist.c src/ot_http.c src/ot_livesync.c src/ot_rijndael.c
BINARIES=$(BINARY) $(BINARY).debug
# Everything is built in one go from sources, so there are no object files to
# carry a flag change over into the next build. The stamp holds the flags the
# last build used, which covers FEATURES passed in the environment and a moved
# HEAD. It is only written when they differ.
BUILDSTAMP=.buildstamp
BUILDDEPS=Makefile $(BUILDSTAMP)
all: $(BINARY) $(BINARY).debug
$(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS)
$(CC) -o $@ $(CFLAGS) $(COMPILE) $(SOURCES) $(LINK)
$(STRIP) $@
$(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS)
$(CC) -o $@ $(OPTS_debug) $(COMPILE) $(SOURCES) $(LINK)
$(BUILDSTAMP): FORCE
@echo "$(CFLAGS) $(COMPILE) $(LINK)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(COMPILE) $(LINK)" > $@
clean:
rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ src/*.o src/*~
install: $(BINARY)
install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man5
install -m 755 $(BINARY) $(DESTDIR)$(BINDIR)
install -m 644 man1/opentracker.1 $(DESTDIR)$(MANDIR)/man1
install -m 644 man5/opentracker.conf.5 $(DESTDIR)$(MANDIR)/man5
FORCE:
.PHONY: all clean install FORCE
include Mk/tests.mk
include Mk/release.mk
include Mk/proxy.mk
|