-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
110 lines (83 loc) · 3.21 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
PROGNAME=readsb
READSB_VERSION='v4.0.4'
RTLSDR ?= no
BLADERF ?= no
PLUTOSDR ?= no
AGGRESSIVE ?= no
HAVE_BIASTEE ?= no
CPPFLAGS += -DMODES_READSB_VERSION=\"$(READSB_VERSION)\" -DMODES_READSB_VARIANT=\"Mictronics\" -D_GNU_SOURCE
DIALECT = -std=c11
CFLAGS += $(DIALECT) -O2 -g -W -D_DEFAULT_SOURCE -Wall -Werror -fno-common -Wmissing-declarations
LIBS = -pthread -lpthread -lm -lrt -lncurses -lprotobuf-c -lrrd
LDFLAGS =
LIBS += $(shell pkg-config --libs tinfo)
# Work around to build with librrd-dev v1.7.2 or v1.8.0+
# librrd-dev doesn't expose its version to the pre-processor.
ifeq ($(shell awk -v a="$(shell pkg-config --modversion librrd | cut -c1-3)" -v b="1.8" 'BEGIN{print(a<b)}'), 1)
CPPFLAGS += -DLIBRRD_VERSION_1_7
endif
ifeq ($(AGGRESSIVE), yes)
CPPFLAGS += -DALLOW_AGGRESSIVE
endif
ifeq ($(RTLSDR), yes)
SDR_OBJ += sdr_rtlsdr.o
CPPFLAGS += -DENABLE_RTLSDR
ifeq ($(HAVE_BIASTEE), yes)
CPPFLAGS += -DENABLE_RTLSDR_BIASTEE
endif
ifdef RTLSDR_PREFIX
CPPFLAGS += -I$(RTLSDR_PREFIX)/include
LDFLAGS += -L$(RTLSDR_PREFIX)/lib
else
CFLAGS += $(shell pkg-config --cflags librtlsdr)
LDFLAGS += $(shell pkg-config --libs-only-L librtlsdr)
endif
ifeq ($(STATIC), yes)
LIBS_SDR += -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0
else
LIBS_SDR += -lrtlsdr -lusb-1.0
endif
endif
ifeq ($(BLADERF), yes)
SDR_OBJ += sdr_bladerf.o sdr_ubladerf.o
CPPFLAGS += -DENABLE_BLADERF
CFLAGS += $(shell pkg-config --cflags libbladeRF)
LIBS_SDR += $(shell pkg-config --libs libbladeRF)
endif
ifeq ($(PLUTOSDR), yes)
SDR_OBJ += sdr_plutosdr.o
CPPFLAGS += -DENABLE_PLUTOSDR
CFLAGS += $(shell pkg-config --cflags libiio libad9361)
LIBS_SDR += $(shell pkg-config --libs libiio libad9361)
endif
all: protoc readsb readsbrrd viewadsb
protoc: readsb.proto
rm -f readsb.pb-c.c readsb.pb-c.h
protoc-c --c_out=. $<
protoc-clean:
rm -f readsb.pb-c.c readsb.pb-c.h
%.o: %.c *.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
readsb.pb-c.o: readsb.proto
protoc-c --c_out=. $<
$(CC) $(CPPFLAGS) $(CFLAGS) -c readsb.pb-c.c -o $@
readsb: readsb.pb-c.o geomag.o readsb.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 fifo.o sdr_ifile.o sdr_beast.o sdr.o ais_charset.o $(SDR_OBJ) $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR)
viewadsb: readsb.pb-c.o geomag.o viewadsb.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 $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
readsbrrd: readsb.pb-c.o readsbrrd.o $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
clean: protoc-clean
rm -f *.o compat/clock_gettime/*.o compat/clock_nanosleep/*.o readsb readsbrrd viewadsb cprtests crctests convert_benchmark
test: cprtests
./cprtests
cprtests: cpr.o cprtests.o
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
crctests: crc.c crc.h
$(CC) $(CPPFLAGS) $(CFLAGS) -g -DCRCDEBUG -o $@ $<
benchmarks: convert_benchmark
./convert_benchmark
oneoff/convert_benchmark: oneoff/convert_benchmark.o convert.o util.o
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o ais_charset.o
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm