summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile73
1 files changed, 57 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 6f9a82b..2587b62 100644
--- a/Makefile
+++ b/Makefile
@@ -18,15 +18,24 @@ LIBOWFAT_LIBRARY=$(PREFIX)/libowfat
18BINDIR?=$(PREFIX)/bin 18BINDIR?=$(PREFIX)/bin
19STRIP?=strip 19STRIP?=strip
20 20
21#FEATURES+=-DWAND_V4_ONLY 21#FEATURES+=-DWANT_V4_ONLY
22#FEATURES+=-DWANT_ACCESSLIST_BLACK 22#FEATURES+=-DWANT_ACCESSLIST_BLACK
23#FEATURES+=-DWANT_ACCESSLIST_WHITE 23#FEATURES+=-DWANT_ACCESSLIST_WHITE
24#FEATURES+=-DWANT_DYNAMIC_ACCESSLIST 24#FEATURES+=-DWANT_DYNAMIC_ACCESSLIST
25 25
26#FEATURES+=-DWANT_SYNC_LIVE 26#FEATURES+=-DWANT_SYNC_LIVE
27#FEATURES+=-DWANT_IP_FROM_QUERY_STRING 27#FEATURES+=-DWANT_IP_FROM_QUERY_STRING
28FEATURES+=-DWANT_COMPRESSION_GZIP 28
29FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS 29# If you want gzip support to be compiled in, uncomment the next include.
30# You can further modify the behaviour by setting DWANT_COMPRESSION_GZIP_ALWAYS
31# in Makefile.gzip
32include Makefile.gzip
33
34# If you want zstd support to be compiled in, uncomment the next include.
35# You can further modify the behaviour by setting DWANT_COMPRESSION_ZSTD_ALWAYS
36# in Makefile.zstd
37#include Makefile.zstd
38
30#FEATURES+=-DWANT_LOG_NETWORKS 39#FEATURES+=-DWANT_LOG_NETWORKS
31#FEATURES+=-DWANT_RESTRICT_STATS 40#FEATURES+=-DWANT_RESTRICT_STATS
32#FEATURES+=-DWANT_IP_FROM_PROXY 41#FEATURES+=-DWANT_IP_FROM_PROXY
@@ -42,37 +51,42 @@ FEATURES+=-DWANT_FULLSCRAPE
42# full scrape transfer, if you rely on an older versions, enable this flag 51# full scrape transfer, if you rely on an older versions, enable this flag
43#FEATURES+=-DWANT_NO_AUTO_FREE 52#FEATURES+=-DWANT_NO_AUTO_FREE
44 53
45# Is enabled on BSD systems by default in trackerlogic.h 54# opentracker takes its randomness from arc4random, which is part of libc on
46# on Linux systems you will need -lbds 55# the BSDs, on macOS and on glibc 2.36 and newer. On an older glibc or on musl
47#FEATURES+=-DWANT_ARC4RANDOM 56# it comes from libbsd instead, so uncomment the next include to link it.
57#LDFLAGS+=-lbsd
48 58
49#FEATURES+=-D_DEBUG_HTTPERROR 59#FEATURES+=-D_DEBUG_HTTPERROR
50#FEATURES+=-D_DEBUG_RANDOMTORRENTS 60#FEATURES+=-D_DEBUG_RANDOMTORRENTS
51 61
62GIT_VERSION=`sh -c 'command -v git >/dev/null && test -d .git && git rev-parse HEAD || echo _git_or_commit_not_found_'`
63
52OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage 64OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage
53OPTS_production=-O3 65OPTS_production=-O3
54 66
55CFLAGS+=-I$(LIBOWFAT_HEADERS) -Wall -pipe -pthread -Wextra #-ansi -pedantic 67CFLAGS+=-I$(LIBOWFAT_HEADERS) -DGIT_VERSION=$(GIT_VERSION) -Wall -pipe -pthread -Wextra #-ansi -pedantic
56LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread -lz 68LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread
57#LDFLAGS+=-lbsd
58 69
59BINARY =opentracker 70BINARY =opentracker
60HEADERS=trackerlogic.h scan_urlencoded_query.h ot_mutex.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 71HEADERS=trackerlogic.h scan_urlencoded_query.h ot_buf.h ot_hex.h ot_ip.h ot_scan.h ot_socket.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
61SOURCES=opentracker.c trackerlogic.c scan_urlencoded_query.c ot_mutex.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 72SOURCES=opentracker.c trackerlogic.c scan_urlencoded_query.c ot_buf.c ot_hex.c ot_ip.c ot_scan.c ot_socket.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
62SOURCES_proxy=proxy.c ot_vector.c ot_mutex.c 73SOURCES_proxy=proxy.c ot_vector.c ot_mutex.c ot_random.c ot_scan.c ot_ip.c ot_socket.c
63 74
64OBJECTS = $(SOURCES:%.c=%.o) 75OBJECTS = $(SOURCES:%.c=%.o)
65OBJECTS_debug = $(SOURCES:%.c=%.debug.o) 76OBJECTS_debug = $(SOURCES:%.c=%.debug.o)
66OBJECTS_proxy = $(SOURCES_proxy:%.c=%.o) 77OBJECTS_proxy = $(SOURCES_proxy:%.c=%.proxy.o)
67OBJECTS_proxy_debug = $(SOURCES_proxy:%.c=%.debug.o) 78OBJECTS_proxy_debug = $(SOURCES_proxy:%.c=%.proxy.debug.o)
68 79
69.SUFFIXES: .debug.o .o .c 80.SUFFIXES: .proxy.debug.o .proxy.o .debug.o .o .c
70 81
71all: $(BINARY) $(BINARY).debug 82all: $(BINARY) $(BINARY).debug
72 83
73CFLAGS_production = $(CFLAGS) $(OPTS_production) $(FEATURES) 84CFLAGS_production = $(CFLAGS) $(OPTS_production) $(FEATURES)
74CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES) 85CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES)
75 86
87CFLAGS_proxy = $(CFLAGS_production) -DWANT_SYNC_LIVE
88CFLAGS_proxy_debug = $(CFLAGS_debug) -DWANT_SYNC_LIVE
89
76$(BINARY): $(OBJECTS) $(HEADERS) 90$(BINARY): $(OBJECTS) $(HEADERS)
77 $(CC) -o $@ $(OBJECTS) $(LDFLAGS) 91 $(CC) -o $@ $(OBJECTS) $(LDFLAGS)
78 $(STRIP) $@ 92 $(STRIP) $@
@@ -83,14 +97,41 @@ proxy: $(OBJECTS_proxy) $(HEADERS)
83proxy.debug: $(OBJECTS_proxy_debug) $(HEADERS) 97proxy.debug: $(OBJECTS_proxy_debug) $(HEADERS)
84 $(CC) -o $@ $(OBJECTS_proxy_debug) $(LDFLAGS) 98 $(CC) -o $@ $(OBJECTS_proxy_debug) $(LDFLAGS)
85 99
100.c.proxy.debug.o : $(HEADERS)
101 $(CC) -c -o $@ $(CFLAGS_proxy_debug) $(<:.proxy.debug.o=.c)
102
103.c.proxy.o : $(HEADERS)
104 $(CC) -c -o $@ $(CFLAGS_proxy) $(<:.proxy.o=.c)
105
86.c.debug.o : $(HEADERS) 106.c.debug.o : $(HEADERS)
87 $(CC) -c -o $@ $(CFLAGS_debug) $(<:.debug.o=.c) 107 $(CC) -c -o $@ $(CFLAGS_debug) $(<:.debug.o=.c)
88 108
89.c.o : $(HEADERS) 109.c.o : $(HEADERS)
90 $(CC) -c -o $@ $(CFLAGS_production) $< 110 $(CC) -c -o $@ $(CFLAGS_production) $<
91 111
112# Unit tests. The modules under test are compiled straight into the test
113# binary, so a test may reach a static function by including the source if it
114# has to. tests/stubs.c supplies the few symbols those modules reference but
115# the tests never reach.
116TESTBIN=tests/runner
117TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_scan_urlencoded_query.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
118TEST_UNITS=scan_urlencoded_query.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
119TEST_HEADERS=tests/test.h $(HEADERS)
120# Tests reach code that sits behind feature flags, so the units under test are
121# built with those features enabled. A test binary is not a production binary.
122FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE
123CFLAGS_test = $(CFLAGS) -I. -g -O1 $(FEATURES_test)
124
125$(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS)
126 $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS)
127
128check: $(TESTBIN)
129 ./$(TESTBIN)
130
131.PHONY: all check clean install
132
92clean: 133clean:
93 rm -rf opentracker opentracker.debug *.o *~ 134 rm -rf opentracker opentracker.debug proxy proxy.debug $(TESTBIN) *.o *~
94 135
95install: 136install:
96 install -m 755 opentracker $(DESTDIR)$(BINDIR) 137 install -m 755 opentracker $(DESTDIR)$(BINDIR)