-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
173 lines (136 loc) · 2.91 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
PREFIX ?= /usr
CFLAGS = \
-Wall \
-ggdb \
-fPIC \
-I. \
-I$(PREFIX)/include \
-I$(PREFIX)/include/asn1c
LDFLAGS = \
-L$(PREFIX)/lib \
-losmocore \
-losmogsm \
-lasn1c \
-lm \
-losmo-asn1-rrc
OBJ = \
address.o \
assignment.o \
bit_func.o \
ccch.o \
cch.o \
chan_detect.o \
crc.o \
umts_rrc.o \
diag_input.o \
gprs.o \
gsm_interleave.o \
cell_info.o \
l3_handler.o \
output.o \
process.o \
punct.o \
rand_check.o \
rlcmac.o \
sch.o \
session.o \
sms.o \
tch.o \
viterbi.o \
lte_nas_eps.o \
lte_nas_eps_mm.o \
lte_nas_eps_sm.o \
lte_nas_eps_info.o
TOOLS = diag_import
ifeq ($(TARGET),host)
CC = gcc
AR = ar
TOOLS += hex_import gsmtap_import analyze.sh
CFLAGS += -O3
else ifeq ($(TARGET),android)
CC = $(CROSS_COMPILE)-gcc
AR = $(CROSS_COMPILE)-ar
CFLAGS += \
-O2 \
-fPIE \
-nostdlib \
--sysroot=$(SYSROOT) \
-DUSE_AUTOTIME=1 \
-DMSG_VERBOSE=1 \
-DRATE_LIMIT=1 \
LDFLAGS += \
-fPIE \
-pie \
-lcompat \
--sysroot $(SYSROOT) \
-L.
LIBRARIES += \
libcompat.so
else
ifneq ($(MAKECMDGOALS),clean)
$(error Unsupported target: $(TARGET))
endif
endif
ifeq ($(MYSQL),1)
ifneq ($(TARGET),host)
$(error MYSQL supported for host builds only)
endif
CFLAGS += -DUSE_MYSQL $(shell mysql_config --cflags)
LDFLAGS += $(shell mysql_config --libs)
OBJ += mysql_api.o
TOOLS += db_import
endif
ifeq ($(SQLITE),1)
ifneq ($(TARGET),host)
$(error SQLITE supported for host builds only)
endif
CFLAGS += -DUSE_SQLITE
LDFLAGS += -lsqlite3
OBJ += sqlite_api.o
endif
ifeq ($(PCAP),1)
CFLAGS += -DUSE_PCAP
endif
CFLAGS += $(EXTRA_CFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
%.o: %.c %.h
$(CC) -c -o $@ $< $(CFLAGS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
all: $(TOOLS)
install: $(TOOLS) $(LIBRARIES) sm_2g.sql sm_3g.sql doc/data/mcc.sql doc/data/mnc.sql doc/data/hlr_info.sql doc/sm.sql
install -d $(DESTDIR)
install $^ $(DESTDIR)
sm_2g.sql: doc/sm_2.4.sql
cpp -DSQLITE -w $< | grep -ve "^#" > [email protected]
mv [email protected] $@
sm_3g.sql: doc/sm_3G_0.9.sql
cpp -DSQLITE -w $< | grep -ve "^#" > [email protected]
mv [email protected] $@
libmetagsm.so: $(OBJ)
$(CC) -o $@ $^ -shared -fPIC $(LDFLAGS)
# Use $EXTRA_LDFLAGS here since $LDFLAGS already contains libcompat.so
libcompat.so: compat.o
$(CC) -o $@ $^ -shared -fPIC --sysroot $(SYSROOT) $(EXTRA_LDFLAGS) -lc
libmetagsm.a: $(OBJ)
$(AR) rcs $@ $^
hex_import: hex_import.o libmetagsm.a
$(CC) -o $@ $^ $(LDFLAGS)
diag_import: diag_import.o libmetagsm.a $(LIBRARIES)
$(CC) -o $@ diag_import.o libmetagsm.a $(LDFLAGS)
gsmtap_import: gsmtap_import.o libmetagsm.a
$(CC) -o $@ $^ $(LDFLAGS) -lpcap
db_import: db_import.o libmetagsm.a
$(CC) -o $@ $^ $(LDFLAGS)
analyze.sh: analyze_header.in cell_info.sql si.sql sms.sql analyze_footer.in
cat $^ >> $@
chmod 755 $@
clean:
@rm -f *.o libmetagsm* *.so
@rm -f $(TOOLS)
database:
@rm metadata.db
@sqlite3 metadata.db < si.sql
@sqlite3 metadata.db < sms.sql
@sqlite3 metadata.db < cell_info.sql
.PHONY: all clean database