forked from wexiangis/wmix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·314 lines (280 loc) · 8.14 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# 平台选择(即 platform 内的子文件夹名称)
# alsa: 通用平台(ubuntu,ARM,树莓派等) --> 基于alsa
# hi3516: 海思hi3516平台 --> 不支持 MAKE_ALSA MAKE_AAC
# t31: 君正T31平台 --> 不支持 MAKE_ALSA MAKE_MP3
PLATFORM ?= alsa
# 说明 ?= 表示前面没有赋过值则使用当前赋值
##### 通用平台alsa配置 #####
ifeq ("$(PLATFORM)","alsa")
# 平台交叉编译器选择
# cross ?= arm-linux-gnueabihf
endif
##### 海思hi3516平台配置 #####
ifeq ("$(PLATFORM)","hi3516")
# 平台交叉编译器选择
cross ?= arm-himix200-linux
# cross ?= arm-himix100-linux
# 平台依赖库配置 -l
CFLAGS +=
# 不支持
MAKE_ALSA = 0
MAKE_AAC = 0
# 选配
MAKE_WEBRTC_AEC = 0
endif
##### 君正T31平台配置 #####
ifeq ("$(PLATFORM)","t31")
# 平台交叉编译器选择
cross ?= mips-linux-gnu
# 平台依赖库配置 -l
CFLAGS += -laudioProcess -limp -lalog # 这里要注意顺序
CFLAGS += -Wl,-gc-sections -lrt -ldl
# 不支持
MAKE_ALSA = 0
MAKE_MP3 = 0
# 选配
MAKE_AAC = 1
MAKE_WEBRTC_VAD = 0
MAKE_WEBRTC_AEC = 0
MAKE_WEBRTC_NS = 0
MAKE_WEBRTC_AGC = 0
endif
# 置1时编译外部alsa库,否则使用编译器自带
MAKE_ALSA ?= 1
# 启用mp3播放支持 0/关 1/启用
MAKE_MP3 ?= 1
# 启用aac播放/录音 0/关 1/启用
MAKE_AAC ?= 1
# 启用webrtc_vad人声识别 0/关 1/启用
MAKE_WEBRTC_VAD ?= 1
# 启用webrtc_aec回声消除 0/关 1/启用
# (需启用 MAKE_WEBRTC_VAD, 否则编译 wmix 时报错)
MAKE_WEBRTC_AEC ?= 1
# 启用webrtc_ns噪音抑制 0/关 1/启用
MAKE_WEBRTC_NS ?= 1
# 启用webrtc_agc自动增益 0/关 1/启用
MAKE_WEBRTC_AGC ?= 1
# speex开源音频库 [测试中...]
MAKE_SPEEX ?= 0
# speexbeta3.aec回声消除库,请和 MAKE_WEBRTC_AEC 互斥启用 [测试中...]
MAKE_SPEEX_BETA3 ?= 0
# 启用FFT(快速傅立叶变换)采样点个数,0/关闭,其它/开启 [测试中...]
# 必须为2的x次方,如4,8,16...512,1024
MAKE_MATH_FFT ?= 0 #1024
# UI文件编译 [测试中...]
MAKE_UI ?= 0
# 根目录
ROOT = $(shell pwd)
# ALSA LIB
ifeq ($(MAKE_ALSA),1)
TARGET-LIBS += libalsa
CFLAGS += -lasound -ldl
endif
# MP3 LIB
ifeq ($(MAKE_MP3),1)
CFLAGS += -lmad
TARGET-LIBS += libmad
endif
# AAC LIB
ifeq ($(MAKE_AAC),1)
CFLAGS += -lfaac -lfaad
TARGET-LIBS += libfaac libfaad
endif
# WEBRTC_VAD LIB
ifeq ($(MAKE_WEBRTC_VAD),1)
CFLAGS += -lwebrtcvad
TARGET-LIBS += libwebrtcvad
endif
# WEBRTC_AEC LIB
ifeq ($(MAKE_WEBRTC_AEC),1)
TARGET-LIBS += libwebrtcaec
CFLAGS += -lwebrtcaec -lwebrtcaecm
endif
# WEBRTC_NS LIB
ifeq ($(MAKE_WEBRTC_NS),1)
CFLAGS += -lwebrtcns
TARGET-LIBS += libwebrtcns
endif
# WEBRTC_AGC LIB
ifeq ($(MAKE_WEBRTC_AGC),1)
CFLAGS += -lwebrtcagc
TARGET-LIBS += libwebrtcagc
endif
# SPEEX LIB
ifeq ($(MAKE_SPEEX),1)
CFLAGS += -lspeex
TARGET-LIBS += libspeex
endif
# SPEEX_BETA3 LIB
ifeq ($(MAKE_SPEEX_BETA3),1)
CFLAGS += -logg -lspeex -lspeexdsp
TARGET-LIBS += libogg libspeexbeta3
endif
# MATH_FFT
ifeq ($(MAKE_MATH_FFT),1)
SRC += ${wildcard $(ROOT)/math/*.c}
endif
# UI
ifeq ($(MAKE_UI),1)
SRC += ${wildcard $(ROOT)/ui/*.c}
endif
# 传递宏给代码
DEF += -DMAKE_MP3=$(MAKE_MP3)
DEF += -DMAKE_AAC=$(MAKE_AAC)
DEF += -DMAKE_WEBRTC_VAD=$(MAKE_WEBRTC_VAD)
DEF += -DMAKE_WEBRTC_AEC=$(MAKE_WEBRTC_AEC)
DEF += -DMAKE_WEBRTC_NS=$(MAKE_WEBRTC_NS)
DEF += -DMAKE_WEBRTC_AGC=$(MAKE_WEBRTC_AGC)
DEF += -DMAKE_SPEEX=$(MAKE_SPEEX)
DEF += -DMAKE_SPEEX_BETA3=$(MAKE_SPEEX_BETA3)
DEF += -DMAKE_MATH_FFT=$(MAKE_MATH_FFT)
DEF += -DMAKE_MATH_UI=$(MAKE_MATH_UI)
# system
GCC ?= gcc
GPP ?= g++
HOST =
ifdef cross
HOST = $(cross)
GCC = $(cross)-gcc
GPP = $(cross)-g++
endif
# 其它库路径
ifdef LIBSPATH
CINC += -I$(LIBSPATH)/include
CLIBS += -L$(LIBSPATH)/lib
else
CINC += -I../libs/include
CLIBS += -L../libs/lib
endif
# wmix
SRC += ${wildcard $(ROOT)/src/*c}
# wmixMsg
SRC-MSG += ${wildcard $(ROOT)/srcMsg/*}
# 平台文件夹三件套
SRC += ${wildcard $(ROOT)/platform/$(PLATFORM)/*.c}
CINC += -I$(ROOT)/platform/$(PLATFORM)
CINC += -I$(ROOT)/platform/$(PLATFORM)/include
CLIBS += -L$(ROOT)/platform/$(PLATFORM)/lib
# -Ixxx
CINC += -I$(ROOT)/src
CINC += -I$(ROOT)/ui
CINC += -I$(ROOT)/math
CINC += -I$(ROOT)/libs/include
# -Lxxx
CLIBS += -L$(ROOT)/libs/lib
# -lxxx
CFLAGS += -lm -lpthread
# tools
SRC-RTPSENDPCM += $(ROOT)/tools/rtpSendPCM.c
SRC-RTPSENDPCM += $(ROOT)/src/rtp.c
SRC-RTPSENDPCM += $(ROOT)/src/g711codec.c
SRC-RTPSENDPCM += $(ROOT)/src/wav.c
SRC-RTPSENDPCM += $(ROOT)/src/delay.c
SRC-RTPRECVPCM += $(ROOT)/tools/rtpRecvPCM.c
SRC-RTPRECVPCM += $(ROOT)/src/rtp.c
SRC-RTPRECVPCM += $(ROOT)/src/g711codec.c
SRC-RTPRECVPCM += $(ROOT)/src/wav.c
SRC-RTPSENDACC += $(ROOT)/tools/rtpSendAAC.c
SRC-RTPSENDACC += $(ROOT)/src/rtp.c
SRC-RTPSENDACC += $(ROOT)/src/aacType.c
SRC-RTPRECVACC += $(ROOT)/tools/rtpRecvAAC.c
SRC-RTPRECVACC += $(ROOT)/src/rtp.c
SRC-RTPRECVACC += $(ROOT)/src/aacType.c
all: msg
@$(GCC) -Wall -o $(ROOT)/wmix $(SRC) $(CINC) $(CLIBS) $(CFLAGS) $(DEF) && \
echo "make wmix success"
msg:
@$(GCC) -Wall -o $(ROOT)/wmixMsg $(SRC-MSG) -lpthread && \
echo "make wmixMsg success"
rtpTest:
@$(GCC) -Wall -o $(ROOT)/rtpSendPCM $(SRC-RTPSENDPCM) -I$(ROOT)/src
@$(GCC) -Wall -o $(ROOT)/rtpRecvPCM $(SRC-RTPRECVPCM) -I$(ROOT)/src
@$(GCC) -Wall -o $(ROOT)/rtpSendAAC $(SRC-RTPSENDACC) -I$(ROOT)/src -L$(ROOT)/libs/lib -I$(ROOT)/libs/include -lfaac -lfaad
@$(GCC) -Wall -o $(ROOT)/rtpRecvAAC $(SRC-RTPRECVACC) -I$(ROOT)/src -L$(ROOT)/libs/lib -I$(ROOT)/libs/include -lfaac -lfaad
clean:
@rm -rf $(ROOT)/wmix* $(ROOT)/rtp*
cleanall: clean
@rm -rf $(ROOT)/libs/*
libs: $(TARGET-LIBS)
@rm -rf $(ROOT)/libs/lib/*.la && \
echo "make libs success"
libalsa:
@tar -xjf $(ROOT)/pkg/alsa-lib-1.1.9.tar.bz2 -C $(ROOT)/libs && \
cd $(ROOT)/libs/alsa-lib-1.1.9 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/alsa-lib-1.1.9 -rf
libmad:
@tar -xzf $(ROOT)/pkg/libmad-0.15.1b.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/libmad-0.15.1b && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) --enable-speed && \
sed -i 's/-fforce-mem//g' ./Makefile && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/libmad-0.15.1b -rf
libfaac:
@tar -xzf $(ROOT)/pkg/faac-1.29.9.2.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/faac-1.29.9.2 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/faac-1.29.9.2 -rf
libfaad:
@tar -xzf $(ROOT)/pkg/faad2-2.8.8.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/faad2-2.8.8 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) && \
make -j4 && make install && \
sed -i '/#pragma message/c // ignore update tips' $(ROOT)/libs/include/faad.h && \
cd - && \
rm $(ROOT)/libs/faad2-2.8.8 -rf
libwebrtcvad:
@tar -xzf $(ROOT)/pkg/webrtc_cut.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/webrtc_cut && \
bash ./build_vad_so.sh $(GCC) && \
cp ./install/* ../ -rf && \
cd - && \
rm $(ROOT)/libs/webrtc_cut -rf
libwebrtcaec:
@tar -xzf $(ROOT)/pkg/webrtc_cut.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/webrtc_cut && \
bash ./build_aec_so.sh $(GCC) && \
bash ./build_aecm_so.sh $(GCC) && \
cp ./install/* ../ -rf && \
cd - && \
rm $(ROOT)/libs/webrtc_cut -rf
libwebrtcns:
@tar -xzf $(ROOT)/pkg/webrtc_cut.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/webrtc_cut && \
bash ./build_ns_so.sh $(GCC) && \
cp ./install/* ../ -rf && \
cd - && \
rm $(ROOT)/libs/webrtc_cut -rf
libwebrtcagc:
@tar -xzf $(ROOT)/pkg/webrtc_cut.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/webrtc_cut && \
bash ./build_agc_so.sh $(GCC) && \
cp ./install/* ../ -rf && \
cd - && \
rm $(ROOT)/libs/webrtc_cut -rf
libspeex:
@tar -xzf $(ROOT)/pkg/speex-1.2.0.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/speex-1.2.0 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/speex-1.2.0 -rf
libspeexbeta3:
@tar -xzf $(ROOT)/pkg/speex-1.2beta3.tar.gz -C $(ROOT)/libs && \
cd $(ROOT)/libs/speex-1.2beta3 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) --with-ogg=$(ROOT)/libs && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/speex-1.2beta3 -rf
libogg:
@tar -xJf $(ROOT)/pkg/libogg-1.3.4.tar.xz -C $(ROOT)/libs && \
cd $(ROOT)/libs/libogg-1.3.4 && \
./configure --prefix=$(ROOT)/libs --host=$(HOST) && \
make -j4 && make install && \
cd - && \
rm $(ROOT)/libs/libogg-1.3.4 -rf