forked from flightaware/dump1090
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
270 lines (222 loc) · 8.54 KB
/
Makefile
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
PROGNAME=dump1090
DUMP1090_VERSION ?= unknown
CFLAGS ?= -O3 -g
DUMP1090_CFLAGS := -std=c11 -fno-common -Wall -Wmissing-declarations -Werror -Wformat-signedness -W
DUMP1090_CPPFLAGS := -I. -D_POSIX_C_SOURCE=200112L -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\"
LIBS = -lpthread -lm
SDR_OBJ = cpu.o sdr.o fifo.o sdr_ifile.o dsp/helpers/tables.o
# Try to autodetect available libraries via pkg-config if no explicit setting was used
PKGCONFIG=$(shell pkg-config --version >/dev/null 2>&1 && echo "yes" || echo "no")
ifeq ($(PKGCONFIG), yes)
ifndef RTLSDR
ifdef RTLSDR_PREFIX
RTLSDR := yes
else
RTLSDR := $(shell pkg-config --exists librtlsdr && echo "yes" || echo "no")
endif
endif
ifndef BLADERF
BLADERF := $(shell pkg-config --exists libbladeRF && echo "yes" || echo "no")
endif
ifndef HACKRF
HACKRF := $(shell pkg-config --exists libhackrf && echo "yes" || echo "no")
endif
ifndef LIMESDR
LIMESDR := $(shell pkg-config --exists LimeSuite && echo "yes" || echo "no")
endif
ifndef SOAPYSDR
SOAPYSDR := $(shell pkg-config --exists SoapySDR && echo "yes" || echo "no")
endif
else
# pkg-config not available. Only use explicitly enabled libraries.
RTLSDR ?= no
BLADERF ?= no
HACKRF ?= no
LIMESDR ?= no
SOAPYSDR ?= no
endif
BUILD_UNAME := $(shell uname)
BUILD_ARCH := $(shell uname -m)
UNAME ?= $(BUILD_UNAME)
ARCH ?= $(BUILD_ARCH)
ifeq ($(UNAME), Linux)
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
LIBS += -lrt
LIBS_USB += -lusb-1.0
LIBS_CURSES := -lncurses
CPUFEATURES ?= yes
endif
ifeq ($(UNAME), Darwin)
ifneq ($(shell sw_vers -productVersion | egrep '^10\.([0-9]|1[01])\.'),) # Mac OS X ver <= 10.11
DUMP1090_CPPFLAGS += -DMISSING_GETTIME
COMPAT += compat/clock_gettime/clock_gettime.o
endif
DUMP1090_CPPFLAGS += -DMISSING_NANOSLEEP
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
ifeq ($(PKGCONFIG), yes)
LIBS_SDR += $(shell pkg-config --libs-only-L libusb-1.0)
endif
LIBS_USB += -lusb-1.0
LIBS_CURSES := -lncurses
# cpufeatures reportedly does not work (yet) on darwin arm64
ifneq ($(ARCH),arm64)
CPUFEATURES ?= yes
endif
endif
ifeq ($(UNAME), OpenBSD)
DUMP1090_CPPFLAGS += -DMISSING_NANOSLEEP
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
LIBS_USB += -lusb-1.0
LIBS_CURSES := -lncurses
endif
ifeq ($(UNAME), FreeBSD)
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
LIBS += -lrt
LIBS_USB += -lusb
LIBS_CURSES := -lncurses
endif
ifeq ($(UNAME), NetBSD)
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
LIBS += -lrt
LIBS_USB += -lusb-1.0
LIBS_CURSES := -lcurses
endif
CPUFEATURES ?= no
ifeq ($(CPUFEATURES),yes)
include Makefile.cpufeatures
DUMP1090_CPPFLAGS += -DENABLE_CPUFEATURES -Icpu_features/include
endif
RTLSDR ?= yes
BLADERF ?= yes
ifeq ($(RTLSDR), yes)
SDR_OBJ += sdr_rtlsdr.o
DUMP1090_CPPFLAGS += -DENABLE_RTLSDR
ifdef RTLSDR_PREFIX
DUMP1090_CPPFLAGS += -I$(RTLSDR_PREFIX)/include
ifeq ($(STATIC), yes)
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic $(LIBS_USB)
else
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -lrtlsdr $(LIBS_USB)
endif
else
# some packaged .pc files are massively broken, try to handle it
# FreeBSD's librtlsdr.pc includes -std=gnu89 in cflags
# some linux librtlsdr packages return a bare -I/ with no path in --cflags
RTLSDR_CFLAGS := $(shell pkg-config --cflags librtlsdr)
RTLSDR_CFLAGS := $(filter-out -std=%,$(RTLSDR_CFLAGS))
RTLSDR_CFLAGS := $(filter-out -I/,$(RTLSDR_CFLAGS))
DUMP1090_CFLAGS += $(RTLSDR_CFLAGS)
# some linux librtlsdr packages return a bare -L with no path in --libs
# which horribly confuses things because it eats the next option on the command line
RTLSDR_LFLAGS := $(shell pkg-config --libs-only-L librtlsdr)
ifeq ($(RTLSDR_LFLAGS),-L)
LIBS_SDR += $(shell pkg-config --libs-only-l --libs-only-other librtlsdr)
else
LIBS_SDR += $(shell pkg-config --libs librtlsdr)
endif
endif
endif
ifeq ($(BLADERF), yes)
SDR_OBJ += sdr_bladerf.o
DUMP1090_CPPFLAGS += -DENABLE_BLADERF
DUMP1090_CFLAGS += $(shell pkg-config --cflags libbladeRF)
LIBS_SDR += $(shell pkg-config --libs libbladeRF)
endif
ifeq ($(HACKRF), yes)
SDR_OBJ += sdr_hackrf.o
DUMP1090_CPPFLAGS += -DENABLE_HACKRF
DUMP1090_CFLAGS += $(shell pkg-config --cflags libhackrf)
LIBS_SDR += $(shell pkg-config --libs libhackrf)
endif
ifeq ($(LIMESDR), yes)
SDR_OBJ += sdr_limesdr.o
DUMP1090_CPPFLAGS += -DENABLE_LIMESDR
DUMP1090_CFLAGS += $(shell pkg-config --cflags LimeSuite)
LIBS_SDR += $(shell pkg-config --libs LimeSuite)
endif
ifeq ($(SOAPYSDR), yes)
SDR_OBJ += sdr_soapy.o
DUMP1090_CPPFLAGS += -DENABLE_SOAPYSDR
DUMP1090_CFLAGS += $(shell pkg-config --cflags SoapySDR)
LIBS_SDR += $(shell pkg-config --libs SoapySDR)
endif
##
## starch (runtime DSP code selection) mix, architecture-specific
##
ifneq ($(CPUFEATURES),yes)
# need to be able to detect CPU features at runtime to enable any non-standard compiler flags
STARCH_MIX := generic
DUMP1090_CPPFLAGS += -DSTARCH_MIX_GENERIC
else
ifeq ($(ARCH),x86_64)
# AVX, AVX2
STARCH_MIX := x86
DUMP1090_CPPFLAGS += -DSTARCH_MIX_X86
else ifeq ($(ARCH),amd64)
# this is the Debian naming of x86_64
STARCH_MIX := x86
DUMP1090_CPPFLAGS += -DSTARCH_MIX_X86
else ifeq ($(findstring aarch,$(ARCH)),aarch)
STARCH_MIX := aarch64
DUMP1090_CPPFLAGS += -DSTARCH_MIX_AARCH64
else ifeq ($(findstring arm64,$(ARCH)),arm64)
# Apple calls this arm64, not aarch64
STARCH_MIX := aarch64
DUMP1090_CPPFLAGS += -DSTARCH_MIX_AARCH64
else ifeq ($(findstring arm,$(ARCH)),arm)
# ARMv7 NEON
STARCH_MIX := arm
DUMP1090_CPPFLAGS += -DSTARCH_MIX_ARM
else
STARCH_MIX := generic
DUMP1090_CPPFLAGS += -DSTARCH_MIX_GENERIC
endif
endif
all: showconfig dump1090 view1090 starch-benchmark
ALL_CCFLAGS := $(CPPFLAGS) $(DUMP1090_CPPFLAGS) $(CFLAGS) $(DUMP1090_CFLAGS)
STARCH_COMPILE := $(CC) $(ALL_CCFLAGS) -c
include dsp/generated/makefile.$(STARCH_MIX)
showconfig:
@echo "Building with:" >&2
@echo " Version string: $(DUMP1090_VERSION)" >&2
@echo " Architecture: $(ARCH)" >&2
@echo " DSP mix: $(STARCH_MIX)" >&2
@echo " RTLSDR support: $(RTLSDR)" >&2
@echo " BladeRF support: $(BLADERF)" >&2
@echo " HackRF support: $(HACKRF)" >&2
@echo " LimeSDR support: $(LIMESDR)" >&2
@echo " SoapySDR support: $(SOAPYSDR)" >&2
%.o: %.c *.h
$(CC) $(ALL_CCFLAGS) -c $< -o $@
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o ais_charset.o adaptive.o $(SDR_OBJ) $(COMPAT) $(CPUFEATURES_OBJS) $(STARCH_OBJS)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR) $(LIBS_CURSES)
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o ais_charset.o sdr_stub.o $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_CURSES)
faup1090: faup1090.o anet.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o ais_charset.o sdr_stub.o $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
starch-benchmark: cpu.o dsp/helpers/tables.o $(CPUFEATURES_OBJS) $(STARCH_OBJS) $(STARCH_BENCHMARK_OBJ)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
clean:
rm -f *.o oneoff/*.o compat/clock_gettime/*.o compat/clock_nanosleep/*.o cpu_features/src/*.o dsp/generated/*.o dsp/helpers/*.o $(CPUFEATURES_OBJS) dump1090 view1090 faup1090 cprtests crctests oneoff/convert_benchmark oneoff/decode_comm_b oneoff/dsp_error_measurement oneoff/uc8_capture_stats starch-benchmark
test: cprtests
./cprtests
cprtests: cpr.o cprtests.o
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
crctests: crc.c crc.h
$(CC) $(ALL_CCFLAGS) -g -DCRCDEBUG -o $@ $<
benchmarks: oneoff/convert_benchmark
oneoff/convert_benchmark
oneoff/convert_benchmark: oneoff/convert_benchmark.o convert.o util.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm -lpthread
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o ais_charset.o
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
oneoff/dsp_error_measurement: oneoff/dsp_error_measurement.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
oneoff/uc8_capture_stats: oneoff/uc8_capture_stats.o
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
starchgen:
dsp/starchgen.py .
.PHONY: wisdom.local
wisdom.local: starch-benchmark
./starch-benchmark -i 5 -o wisdom.local mean_power_u16 mean_power_u16_aligned magnitude_uc8 magnitude_uc8_aligned
./starch-benchmark -i 5 -r wisdom.local -o wisdom.local