diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 31 |
1 files changed, 20 insertions, 11 deletions
| @@ -67,6 +67,15 @@ LDFLAGS+=-pthread | |||
| 67 | CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) | 67 | CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) |
| 68 | LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat | 68 | LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat |
| 69 | 69 | ||
| 70 | # Record feature flags as a dep to allow rebuild when they change | ||
| 71 | BUILDSTAMP=.buildstamp | ||
| 72 | BUILDDEPS=Makefile $(BUILDSTAMP) | ||
| 73 | |||
| 74 | $(BUILDSTAMP): FORCE | ||
| 75 | @echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" | cmp -s - $@ 2>/dev/null || echo "$(CFLAGS) $(FEATURES) $(LDFLAGS)" > $@ | ||
| 76 | |||
| 77 | FORCE: | ||
| 78 | |||
| 70 | BINARY =opentracker | 79 | BINARY =opentracker |
| 71 | 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 | 80 | 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 |
| 72 | 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 | 81 | 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 |
| @@ -80,14 +89,14 @@ CFLAGS_debug = $(CFLAGS) $(OPTS_debug) $(FEATURES) | |||
| 80 | CFLAGS_proxy = $(CFLAGS_production) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | 89 | CFLAGS_proxy = $(CFLAGS_production) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE |
| 81 | CFLAGS_proxy_debug = $(CFLAGS_debug) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | 90 | CFLAGS_proxy_debug = $(CFLAGS_debug) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE |
| 82 | 91 | ||
| 83 | $(BINARY): $(SOURCES) $(HEADERS) | 92 | $(BINARY): $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 84 | $(CC) -o $@ $(CFLAGS_production) $(SOURCES) $(LDFLAGS) | 93 | $(CC) -o $@ $(CFLAGS_production) $(SOURCES) $(LDFLAGS) |
| 85 | $(STRIP) $@ | 94 | $(STRIP) $@ |
| 86 | $(BINARY).debug: $(SOURCES) $(HEADERS) | 95 | $(BINARY).debug: $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 87 | $(CC) -o $@ $(CFLAGS_debug) $(SOURCES) $(LDFLAGS) | 96 | $(CC) -o $@ $(CFLAGS_debug) $(SOURCES) $(LDFLAGS) |
| 88 | proxy: $(SOURCES_proxy) $(HEADERS) | 97 | proxy: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) |
| 89 | $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | 98 | $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) |
| 90 | proxy.debug: $(SOURCES_proxy) $(HEADERS) | 99 | proxy.debug: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) |
| 91 | $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | 100 | $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) |
| 92 | 101 | ||
| 93 | # Unit tests. The modules under test are compiled straight into the test | 102 | # Unit tests. The modules under test are compiled straight into the test |
| @@ -103,13 +112,13 @@ TEST_HEADERS=tests/test.h $(HEADERS) | |||
| 103 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | 112 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE |
| 104 | CFLAGS_test = $(CFLAGS) -I. -g -O1 $(FEATURES_test) | 113 | CFLAGS_test = $(CFLAGS) -I. -g -O1 $(FEATURES_test) |
| 105 | 114 | ||
| 106 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) | 115 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) |
| 107 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) | 116 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) |
| 108 | 117 | ||
| 109 | check: $(TESTBIN) $(BINARY) | 118 | check: $(TESTBIN) $(BINARY) |
| 110 | ./$(TESTBIN) | 119 | ./$(TESTBIN) |
| 111 | 120 | ||
| 112 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) | 121 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) |
| 113 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) | 122 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) |
| 114 | 123 | ||
| 115 | check-poll: $(TESTBIN).poll | 124 | check-poll: $(TESTBIN).poll |
| @@ -122,7 +131,7 @@ CC_sanitize?=clang | |||
| 122 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | 131 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer |
| 123 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | 132 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined |
| 124 | 133 | ||
| 125 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) | 134 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) |
| 126 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | 135 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) |
| 127 | 136 | ||
| 128 | check-sanitize: $(TESTBIN).sanitize | 137 | check-sanitize: $(TESTBIN).sanitize |
| @@ -139,7 +148,7 @@ FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_B | |||
| 139 | CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | 148 | CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer |
| 140 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined | 149 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined |
| 141 | 150 | ||
| 142 | opentracker.integration: $(SOURCES) $(HEADERS) | 151 | opentracker.integration: $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 143 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | 152 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) |
| 144 | 153 | ||
| 145 | check-integration: opentracker.integration | 154 | check-integration: opentracker.integration |
| @@ -149,7 +158,7 @@ check-integration: opentracker.integration | |||
| 149 | CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | 158 | CFLAGS_tsan=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer |
| 150 | LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread | 159 | LDFLAGS_tsan=$(LDFLAGS) -fsanitize=thread |
| 151 | 160 | ||
| 152 | opentracker.tsan: $(SOURCES) $(HEADERS) | 161 | opentracker.tsan: $(SOURCES) $(HEADERS) $(BUILDDEPS) |
| 153 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) | 162 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) |
| 154 | 163 | ||
| 155 | check-tsan: opentracker.tsan | 164 | check-tsan: opentracker.tsan |
| @@ -163,12 +172,12 @@ check-all: | |||
| 163 | $(MAKE) check-integration | 172 | $(MAKE) check-integration |
| 164 | $(MAKE) check-tsan | 173 | $(MAKE) check-tsan |
| 165 | 174 | ||
| 166 | .PHONY: all check check-poll check-sanitize check-integration check-tsan check-all clean install | 175 | .PHONY: all FORCE check check-poll check-sanitize check-integration check-tsan check-all clean install |
| 167 | 176 | ||
| 168 | BINARIES=opentracker opentracker.debug opentracker.integration opentracker.tsan proxy proxy.debug $(TESTBIN) $(TESTBIN).sanitize $(TESTBIN).poll | 177 | BINARIES=opentracker opentracker.debug opentracker.integration opentracker.tsan proxy proxy.debug $(TESTBIN) $(TESTBIN).sanitize $(TESTBIN).poll |
| 169 | 178 | ||
| 170 | clean: | 179 | clean: |
| 171 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) *.o *~ | 180 | rm -rf $(BINARIES) $(BINARIES:=.dSYM) $(BUILDSTAMP) *.o *~ |
| 172 | 181 | ||
| 173 | install: | 182 | install: |
| 174 | install -m 755 opentracker $(DESTDIR)$(BINDIR) | 183 | install -m 755 opentracker $(DESTDIR)$(BINDIR) |
