-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
235 lines (192 loc) · 5.05 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
#
# Makefile
#
# Copyright (C) 2022 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
samplerate: third_party/lmdb
.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 openssl opus samplerate portaudio lmdb
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 && \
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/
.PHONY: external_dir
external_dir:
mkdir -p external
external: external_dir external/re external/rem external/baresip
external/re:
$(shell [ ! -d external/re ] && \
git -C external clone https://github.com/baresip/re.git)
git -C external/re checkout $(LIBRE_VERSION)
external/rem:
$(shell [ ! -d external/rem ] && \
git -C external clone https://github.com/baresip/rem.git)
git -C external/rem checkout $(LIBREM_VERSION)
external/baresip:
$(shell [ ! -d external/baresip ] && \
git -C external clone \
https://github.com/baresip/baresip.git)
git -C external/baresip checkout $(BARESIP_VERSION)
##############################################################################
#
# 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/linux/studiolink
.PHONY: dev
dev: all
build/app/linux/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/linux/studiolink | grep NEEDED
.PHONY: macos_debug
macos_debug: all
otool -L build/app/macos/studiolink
.PHONY: asan
asan:
make cleaner
make external
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:
make cleaner
make external
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 cleaner
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