-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_tbw.sh
executable file
·291 lines (227 loc) · 6.55 KB
/
build_tbw.sh
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
#! /bin/bash
id -a
pwd
cd /home/pi/
rm -Rf ToxBlinkenwall/.git # remove previous install
rm -Rf tmp/
echo "using local build from zoff99 repo"
git clone https://github.com/zoff99/toxic tmp
cd tmp
git checkout "master"
cd ..
mkdir -p ToxBlinkenwall/
cp -a tmp/* ToxBlinkenwall/
cp -a tmp/.gitignore ToxBlinkenwall/
cp -a tmp/.git ToxBlinkenwall/
rm -Rf tmp/
cd
export _HOME_="/home/pi/"
echo $_HOME_
cd $_HOME_/ToxBlinkenwall/
export _SRC_=$_HOME_/src/
export _INST_=$_HOME_/inst/
export CF2=" -O3 -ggdb3 "
export CF3="" # " -funsafe-math-optimizations "
export VV1=" VERBOSE=1 V=1 "
sudo rm -Rfv $_SRC_
sudo rm -Rfv $_INST_
mkdir -p $_SRC_
mkdir -p $_INST_
sudo chown -R pi:pi $_SRC_
sudo chown -R pi:pi $_INST_
export LD_LIBRARY_PATH=$_INST_/lib/
export PKG_CONFIG_PATH=$_INST_/lib/pkgconfig:/usr/local/lib/pkgconfig
cd $_SRC_
rm -Rf nasm
# git clone http://repo.or.cz/nasm.git # site is down
git clone https://github.com/unofficial-mirror/nasm
cd nasm
git checkout nasm-2.14.02
./autogen.sh
./configure --prefix=$_INST_
make -j $(nproc) || exit 1
# # seems man pages are not always built. but who needs those
touch nasm.1
touch ndisasm.1
make install
id -a
sudo cp -av $_INST_/bin/nasm /usr/bin/
sudo chmod a+rx /usr/bin/nasm
nasm -v
cd $_SRC_
# rm -Rf x264
git clone https://code.videolan.org/videolan/x264.git
cd x264
git checkout 34c06d1c17ad968fbdda153cb772f77ee31b3095 # stable
./configure --prefix=$_INST_ --disable-opencl --enable-static \
--disable-avs --disable-cli --enable-pic
make clean
make -j $(nproc) || exit 1
make install
cd $_SRC_
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
git checkout n8.1.24.10 # n9.1.23.0
make -j $(nproc) || exit 1
sudo make install
#ls -al /usr/local/include/ffnvcodec
#mkdir -p $_INST_/include/ffnvcodec
#sudo mkdir -p /usr/include/ffnvcodec
#sudo cp -av /usr/local/include/ffnvcodec/* /usr/include/ffnvcodec/
#cp -av /usr/local/include/ffnvcodec/* $_INST_/include/ffnvcodec/
#ls -al /usr/local/lib/pkgconfig
#mkdir -p $_INST_/lib/pkgconfig
#sudo mkdir -p /usr/lib/pkgconfig
#sudo cp -av /usr/local/lib/pkgconfig/* /usr/lib/pkgconfig/
#cp -av /usr/local/lib/pkgconfig/* $_INST_/lib/pkgconfig/
pkg-config --cflags ffnvcodec
pkg-config --libs ffnvcodec
# for ffmpeg --------
export CFLAGS="$CF2 $CF3 -I/usr/local/include"
cd $_SRC_
# rm -Rf libav
git clone --depth=1 --branch=n4.2.1 https://github.com/FFmpeg/FFmpeg libav
cd libav
./configure --prefix=$_INST_ --disable-devices \
--enable-pthreads \
--disable-shared --enable-static \
--disable-doc --disable-avdevice \
\
--disable-network \
--enable-ffmpeg --enable-ffprobe \
--disable-network --disable-everything \
--disable-bzlib \
--disable-libxcb-shm \
--disable-libxcb-xfixes \
--enable-parser=h264 \
--enable-nvenc --enable-encoder=h264_nvenc \
--enable-nvdec --enable-decoder=h264_cuvid \
--enable-protocol=file --enable-protocol=data \
--enable-demuxer=h264 \
--enable-indev=lavfi --enable-filter=testsrc \
--enable-filter=scale \
--enable-muxer=h264 --enable-muxer=matroska \
--enable-runtime-cpudetect \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=rawvideo \
--enable-hwaccel=h264_nvdec --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_vdpau \
--enable-gpl --enable-decoder=h264 || exit 1
# --disable-swscale \
# ./ffmpeg -y -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -vcodec h264_nvenc test.mkv -v 56
make clean
make -j $(nproc) || exit 1
make install
unset CFLAGS
cd $_SRC_
git clone --depth=1 --branch=1.0.18 https://github.com/jedisct1/libsodium.git
cd libsodium
./autogen.sh
res1=$?
if [ $res1 -ne 0 ]; then
echo "retrying to autoconf libsodium"
sleep 61
./autogen.sh || exit 1
fi
export CFLAGS=" $CF2 $CF3 "
export CXXFLAGS=" $CF2 $CF3 "
./configure --prefix=$_INST_ --disable-shared --disable-soname-versions
res=$?
if [ $res -ne 0 ]; then
echo "retrying to configure libsodium"
sleep 61
./autogen.sh
./configure --prefix=$_INST_ --disable-shared --disable-soname-versions || exit 1
fi
make -j $(nproc) || exit 1
make install
cd $_SRC_
git clone --depth=1 --branch=v1.8.1 https://github.com/webmproject/libvpx.git
cd libvpx
make clean
export CFLAGS=" $CF2 $CF3 "
export CXXFLAGS=" $CF2 $CF3 "
./configure --prefix=$_INST_ --disable-examples \
--disable-unit-tests --enable-shared \
--size-limit=16384x16384 \
--enable-onthefly-bitpacking \
--enable-error-concealment \
--enable-runtime-cpu-detect \
--enable-multi-res-encoding \
--enable-postproc \
--enable-vp9-postproc \
--enable-temporal-denoising \
--enable-vp9-temporal-denoising
# --enable-better-hw-compatibility \
make -j $(nproc) || exit 1
make install
cd $_SRC_
git clone --depth=1 --branch=v1.3.1 https://github.com/xiph/opus.git
cd opus
./autogen.sh
export CFLAGS=" $CF2 $CF3 "
export CXXFLAGS=" $CF2 $CF3 "
./configure --prefix=$_INST_ --disable-shared
make -j $(nproc) || exit 1
make install
## --------- build without HW Accceleration ---------
cd $_SRC_
echo "using build from zoff99 repo"
git clone https://github.com/zoff99/c-toxcore
cd c-toxcore
git checkout "zoff99/zoxcore_local_fork"
./autogen.sh
make clean
export CFLAGS=" $CF2 -D_GNU_SOURCE -I$_INST_/include/ -O3 \
--param=ssp-buffer-size=1 -ggdb3 -fstack-protector-all "
export LDFLAGS=-L$_INST_/lib
./configure \
--prefix=$_INST_ \
--disable-soname-versions --disable-testing --disable-shared
make -j $(nproc) || exit 1
make install
cd $_HOME_/ToxBlinkenwall/
make -j $(nproc)
res2=$?
ldd build/toxic
ls -hal build/toxic
file build/toxic
mkdir -p $_HOME_/ToxBlinkenwall/toxblinkenwall/
chown pi:pi $_HOME_/ToxBlinkenwall/toxblinkenwall/
cp -av build/toxic $_HOME_/ToxBlinkenwall/toxblinkenwall/
chown pi:pi $_HOME_/ToxBlinkenwall/toxblinkenwall/toxic
chmod a+rx $_HOME_/ToxBlinkenwall/toxblinkenwall/toxic
echo '#! /bin/bash
export LD_LIBRARY_PATH="/home/pi/inst/lib/"
cd /home/pi/ToxBlinkenwall/toxblinkenwall/
mkdir -p ./db/
while [ 1 == 1 ]; do
su -p --session-command ./toxic -- pi
sleep 4
done
' > $_HOME_/ToxBlinkenwall/toxblinkenwall/start_toxic.sh
chmod a+rx $_HOME_/ToxBlinkenwall/toxblinkenwall/start_toxic.sh
chown pi:pi $_HOME_/ToxBlinkenwall/toxblinkenwall/start_toxic.sh
## --------- build without HW Accceleration ---------
cd $_HOME_
if [ $res2 -eq 0 ]; then
echo "compile: OK"
# echo "clean up of compile files ..."
rm -Rf $_SRC_
## do not cleanup install dir ## rm -Rf $_INST_
echo "... ready"
else
echo "compile: ** ERROR **"
exit 2
fi
echo '
IS_ON=RASPI
HD=RASPIHD
export IS_ON
export HD
PULSE_PROP=filter.want=echo-cancel
export PULSE_PROP
TBW_KILLSWITCH_ENGAGE=1
export TBW_KILLSWITCH_ENGAGE
' >> ~/.profile
echo "build ready"