-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
267 lines (217 loc) · 5.76 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
#
# Makefile
#
# Copyright (C) 2023 Studio.Link Sebastian Reimers
# Variables (make CC=gcc V=1):
# V Verbose mode (example: make V=1)
# CC Override CC (default clang)
# CI Set CI=1 for CI pipeline
#
include versions.mk
CC := clang
CI := 0
MAKE += -j CC=$(CC)
ifeq ($(V),)
HIDE=@
MAKE += --no-print-directory
endif
##############################################################################
#
# Main
#
.PHONY: all
all: third_party external
$(HIDE)[ -d build ] || cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug
$(HIDE)cmake --build build -j
##############################################################################
#
# Third Party section
#
.PHONY: openssl
openssl: third_party/openssl
.PHONY: opus
opus: third_party/opus
.PHONY: portaudio
portaudio: third_party/portaudio
.PHONY: samplerate
samplerate: third_party/libsamplerate
.PHONY: lmdb
lmdb: third_party/lmdb
.PHONY: libvpx
libvpx: third_party/libvpx
.PHONY: cacert
cacert: third_party/cacert.pem
.PHONY: third_party_dir
third_party_dir:
mkdir -p third_party/include
mkdir -p third_party/lib
.PHONY: third_party
third_party: third_party_dir libvpx openssl opus samplerate portaudio lmdb \
cacert
third_party/libvpx:
$(HIDE)cd third_party && \
git clone --depth=1 --branch=${VPX_VERSION} ${VPX_MIRROR} && \
mkdir build_vpx && cd build_vpx && \
../libvpx/configure --prefix=../ --enable-realtime-only \
--disable-unit-tests --disable-vp9 --disable-tools --disable-shared \
--enable-runtime-cpu-detect \
--disable-install-docs --disable-examples && \
make -j4 && \
make install
third_party/openssl:
$(HIDE)cd third_party && \
wget ${OPENSSL_MIRROR}/openssl-${OPENSSL_VERSION}.tar.gz && \
tar -xzf openssl-${OPENSSL_VERSION}.tar.gz && \
mv openssl-${OPENSSL_VERSION} openssl
@rm -f third_party/openssl-${OPENSSL_VERSION}.tar.gz
$(HIDE)cd third_party/openssl && \
CC=$(CC) ./config no-shared && \
make -j build_libs && \
cp *.a ../lib && \
cp -a include/openssl ../include/
third_party/opus:
$(HIDE)cd third_party && \
wget ${OPUS_MIRROR}/opus-${OPUS_VERSION}.tar.gz && \
tar -xzf opus-${OPUS_VERSION}.tar.gz && \
mv opus-${OPUS_VERSION} opus
$(HIDE)cd third_party/opus && \
CC=$(CC) ./configure --with-pic --enable-dred \
--enable-deep-plc --enable-osce && \
make -j && \
cp .libs/libopus.a ../lib/ && \
mkdir -p ../include/opus && \
cp include/*.h ../include/opus/
third_party/portaudio:
$(HIDE)cd third_party && \
git clone ${PORTAUDIO_MIRROR}/portaudio.git && \
cd portaudio && \
CC=$(CC) cmake -B build -DBUILD_SHARED_LIBS=0 && \
cmake --build build -j && \
cp -a build/libportaudio.a ../lib/ && \
cp include/*.h ../include/
third_party/libsamplerate:
$(HIDE)cd third_party && \
git clone ${SAMPLERATE_MIRROR}/libsamplerate.git && \
cd libsamplerate && \
./autogen.sh && \
CC=$(CC) ./configure --enable-static && \
make -j && \
cp src/.libs/libsamplerate.a ../lib/ && \
cp include/samplerate.h ../include/
third_party/lmdb:
$(HIDE)cd third_party && \
git clone https://github.com/LMDB/lmdb && \
cd lmdb/libraries/liblmdb && \
make CC=$(CC) -j && \
cp liblmdb.a ../../../lib/ && \
cp lmdb.h ../../../include/
third_party/cacert.pem:
wget https://curl.se/ca/cacert.pem -O third_party/cacert.pem
.PHONY: external_dir
external_dir:
mkdir -p external
external: external_dir external/re external/baresip
external/re:
$(HIDE) [ ! -d external/re ] && \
git -C external clone -b $(LIBRE_VERSION) --depth=1 \
https://github.com/baresip/re.git
external/baresip:
$(HIDE) [ ! -d external/baresip ] && \
git -C external clone -b $(BARESIP_VERSION) --depth=1 \
https://github.com/baresip/baresip.git
##############################################################################
#
# Tools & Cleanup
#
.PHONY: clean
clean:
$(HIDE)rm -Rf build
.PHONY: cleaner
cleaner: clean
$(HIDE)rm -Rf external
.PHONY: distclean
distclean: clean cleaner
$(HIDE)rm -Rf third_party
.PHONY: ccheck
ccheck:
test/ccheck.py libsl Makefile test app
.PHONY: tree
tree:
tree -L 4 -I "third_party|node_modules|build*|external" -d .
.PHONY: test
test: all
cppcheck libsl app test
build/test/test
#test/integration.sh
.PHONY: test_debug
test_debug: all
gdb -batch -ex "run" -ex "bt" build/test/test
.PHONY: watch
watch:
$(HIDE)while true; do \
inotifywait -qr -e modify libsl test; \
make test; sleep 0.5; \
done
r: run
.PHONY: run
run: all
build/app/cli/studiolink
.PHONY: dev
dev: all
build/app/cli/studiolink --headless
.PHONY: release
release:
make cleaner
make external
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release
make all
.PHONY: linux_debug
linux_debug: all
readelf -d build/app/cli/studiolink | grep NEEDED
.PHONY: macos_debug
macos_debug: all
otool -L build/app/cli/studiolink
##############################################################################
#
# Sanitizers
#
.PHONY: run_san
run_san:
ASAN_OPTIONS=fast_unwind_on_malloc=0 \
TSAN_OPTIONS="suppressions=tsan.supp" \
make run
.PHONY: test_san
test_san:
ASAN_OPTIONS=fast_unwind_on_malloc=0 \
TSAN_OPTIONS="suppressions=tsan.supp" \
make test
.PHONY: asan
asan: external
make clean
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=undefined,address \
-fno-omit-frame-pointer" \
-DHAVE_THREADS=
make all
.PHONY: tsan
tsan: external
make clean
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=undefined,thread \
-fno-omit-frame-pointer" \
-DHAVE_THREADS=
make all
.PHONY: msan
msan:
make clean
make external
cd third_party/openssl && \
make clean && \
CC=$(CC) ./config no-shared enable-msan && \
make -j build_libs && \
cp *.a ../lib && \
cp -a include/openssl ../include/
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=undefined,memory -fno-omit-frame-pointer" \
-DHAVE_THREADS=
make all