-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_source.sh
More file actions
executable file
·504 lines (454 loc) · 14.4 KB
/
Copy pathbuild_source.sh
File metadata and controls
executable file
·504 lines (454 loc) · 14.4 KB
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
#!/usr/bin/env bash
# Stop execution on any error
# Note: we can override this in the Dockerfile RUN command with an || true.
# which is useful for debugging
set -e
manifestJsonFile="${WORKDIR:-$PWD}/generated_build_manifest.json"
manifestJsonVersionsFile="${WORKDIR:-$PWD}/generated_build_versions_manifest.json"
OS_NAME=$(uname -s)
is_ubuntu=false
is_alpine=false
if [[ "$OS_NAME" == "Linux" ]]; then
if grep -q "Ubuntu" /etc/os-release; then
is_ubuntu=true
elif grep -q "Alpine Linux" /etc/alpine-release; then
is_alpine=true
fi
fi
######################### Callback build functions #########################
build_libopencore-amr() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libx264() {
./configure --prefix="${PREFIX}" --enable-shared --enable-pic --disable-cli
make
make install
}
build_libx265() {
cd build/linux
sed -i "/-DEXTRA_LIB/ s/$/ -DCMAKE_INSTALL_PREFIX=\${PREFIX}/" multilib.sh
sed -i "/^cmake/ s/$/ -DENABLE_CLI=OFF/" multilib.sh
./multilib.sh
make -C 8bit install
}
build_libogg() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libopus() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libvorbis() {
./configure --prefix="${PREFIX}" --with-ogg="${PREFIX}" --enable-shared
make
make install
# https://gitlab.xiph.org/xiph/vorbis
# cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX="${PREFIX}" .
# make
# make install
}
build_libvpx() {
local data=$(jq -r '.[] | select(.library_name == "libvpx")' $manifestJsonFile)
local dir=$(echo "$data" | jq -r '.build_dir')
local vpx_version=$(jq -r '.["libvpx"]' $manifestJsonVersionsFile)
if [ -n "$vpx_version" ] && [[ "$vpx_version" != "null" ]]; then
echo "Building [libvpx-${vpx_version}] in [${dir}]"
else
echo "Error: libvpx version is empty or unset"
fi
version="v${vpx_version}"
git -C libvpx pull 2> /dev/null || git clone --branch ${version} --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
pwd
./configure --prefix="${PREFIX}" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --enable-pic --enable-shared --as=yasm
make
make install
}
build_libwebp() {
./configure --prefix="${PREFIX}" --enable-shared && \
make && \
make install
}
build_libmp3lame() {
./configure --prefix="${PREFIX}" --bindir="${PREFIX}/bin" --enable-shared --enable-nasm --disable-frontend && \
make && \
make install
}
build_libxvid() {
# read doc/INSTALL
cd build/generic
./configure --help
echo "Configuring"
./configure --prefix="${PREFIX}" --bindir="${PREFIX}/bin" --enable-shared
make
make install
}
build_libfdk-aac() {
autoreconf -fiv && \
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_openjpeg() {
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_freetype() {
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_libvidstab() {
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_fribidi() {
# Currently broken, need to fix
# sed -i 's/^SUBDIRS =.*/SUBDIRS=gen.tab charset lib bin/' Makefile.am
# ./bootstrap --no-config --auto
./configure --prefix="${PREFIX}" --disable-static --enable-shared
make -j1
make install
}
build_fontconfig() {
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_libass() {
./autogen.sh && \
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_kvazaar() {
# ./autogen.sh && \
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
# aom is a git clone ( to get source, so not in the loop using the callback function)
build_aom() {
local data=$(jq -r '.[] | select(.library_name == "aom")' $manifestJsonFile)
local dir=$(echo "$data" | jq -r '.build_dir')
local aom_version=$(jq -r '.["aom"]' $manifestJsonVersionsFile) # Access value with key "aom"
if [ -n "$aom_version" ] && [[ "$aom_version" != "null" ]]; then
echo "Building [aom-${aom_version}] in [${dir}]"
else
echo "Error: aom version is empty or unset"
fi
version="v${aom_version}"
git clone --branch ${version} --depth 1 https://aomedia.googlesource.com/aom ${dir} && \
cd ${dir} && \
mkdir -p ./aom_build && \
cd ./aom_build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DBUILD_SHARED_LIBS=1 -DENABLE_NASM=on .. && \
make && \
make install
}
build_nvidia-codec-headers() {
local dir=${1}
# git clone https://github.com/FFmpeg/nv-codec-headers ${dir}
# git checkout n${NVIDIA_HEADERS_VERSION}
make PREFIX="${PREFIX}"
make install PREFIX="${PREFIX}"
}
build_libsvtav1() {
cd Build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF .. && \
make && \
make install
}
build_xorg-macros() {
dir=${1}
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_xproto() {
dir=${1}
cp /usr/share/misc/config.guess . && \
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_libxau() {
dir=${1}
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_libpthread-stubs() {
./configure --prefix="${PREFIX}" && \
make && \
make install
}
build_libxml2() {
./autogen.sh --prefix="${PREFIX}" --with-ftp=no --with-http=no --with-python=no && \
make && \
make install
}
build_libbluray() {
## libbluray - Requires libxml, freetype, and fontconfig
./configure --prefix="${PREFIX}" --disable-examples --disable-bdjava-jar --disable-static --enable-shared && \
make && \
make install
}
build_libzmq() {
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
make && \
make install
}
# another special, code clone situation ( actually currently using the tarball build approach )
build_libpng() {
local dir="/tmp/png"
# local libpng_version=$(jq -r '.["libpng"]' $manifestJsonVersionsFile) # Access value with key "libpng"
# git clone https://git.code.sf.net/p/libpng/code ${dir} -b v${libpng_version} --depth 1 && \
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
make check && \
make install
}
build_libaribb24() {
autoreconf -fiv && \
./configure CFLAGS="-I${PREFIX}/include -fPIC" --prefix="${PREFIX}" && \
make && \
make install
}
build_zimg() {
./autogen.sh && \
./configure --prefix="${PREFIX}" --enable-shared && \
make && \
make install
}
# Dependancy on libogg
build_libtheora() {
if [ "$is_ubuntu" = true ]; then
cp /usr/share/misc/config.guess .
fi
./configure --prefix="${PREFIX}" --with-ogg="${PREFIX}" --enable-shared --disable-examples
make
make install
}
build_libsrt() {
# requires libssl-dev
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_libvmaf() {
# https://github.com/Netflix/vmaf/issues/788#issuecomment-756098059
mkdir ./libvmaf/build
cd ./libvmaf/build
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static --prefix "${PREFIX}" .. && \
# meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=shared --prefix "${PREFIX}" ..
ninja
ninja install
}
build_whisper() {
local libdir="lib"
if [[ -d "${PREFIX}/lib64" ]] || [[ "${PREFIX}" == /opt/* ]]; then
libdir="lib64"
fi
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DCMAKE_INSTALL_LIBDIR="${libdir}" \
-DGGML_STATIC=OFF \
-DWHISPER_BUILD_SHARED_LIB=ON \
-DWHISPER_NO_SHARED=OFF \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=OFF \
-DWHISPER_BUILD_SERVER=OFF \
-DGGML_BACKEND_DL=ON \
-DGGML_VULKAN=ON \
-DGGML_OPENCL=OFF \
-DGGML_HIP=OFF \
-DGGML_CUDA=OFF
cmake --build build -j"$(nproc)"
cmake --install build
}
build_ffmpeg() {
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PREFIX}/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH:-}"
export LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/lib64:/usr/local/lib64:/usr/local/lib:${LD_LIBRARY_PATH:-}"
local -a flags=(
--prefix="${PREFIX}"
--extra-cflags="-I${PREFIX}/include"
--extra-cflags="-I/usr/local/include"
--extra-ldflags="-L/usr/local/lib64"
--extra-ldflags="-L/usr/local/lib"
--extra-ldflags="-L${PREFIX}/lib64"
--extra-ldflags="-L${PREFIX}/lib"
--extra-ldflags="-Wl,-rpath,${PREFIX}/lib:${PREFIX}/lib64:/usr/local/lib64:/usr/local/lib"
--enable-gpl
--enable-version3
--enable-nonfree
--enable-lto
--enable-shared
--disable-static
--enable-libfontconfig
--enable-libfreetype
--enable-libfribidi
--enable-libharfbuzz
--enable-libass
--enable-libplacebo
--enable-libshaderc
--enable-libdrm
--enable-libv4l2
--enable-opengl
--enable-vulkan
--enable-opencl
--enable-libx264
--enable-libx265
--enable-libxvid
--enable-libaom
--enable-libsvtav1
--enable-librav1e
--enable-libvpx
--enable-libwebp
--enable-libjxl
--enable-libdav1d
--enable-libopenjpeg
--enable-libvorbis
--enable-libopus
--enable-libmp3lame
--enable-libtheora
--enable-libfdk-aac
--enable-libtwolame
--enable-libvo-amrwbenc
--enable-libopencore-amrwb
--enable-libopencore-amrnb
--enable-libspeex
--enable-libgsm
--enable-libilbc
--enable-liblc3
--enable-libsoxr
--enable-libflite
--enable-libmysofa
--enable-libvidstab
--enable-libvmaf
--enable-liblensfun
--enable-lcms2
--enable-libsnappy
--enable-librubberband
--enable-libmodplug
--enable-libopenmpt
--enable-libgme
--enable-libbs2b
--enable-libcaca
--enable-libcdio
--enable-libbluray
--enable-libdvdnav
--enable-libdvdread
--enable-libxml2
--enable-libzimg
--enable-libtesseract
--enable-libsrt
--enable-librist
--enable-librtmp
--enable-librabbitmq
--enable-libssh
--enable-libsmbclient
--enable-libzmq
--enable-libpulse
--enable-openal
--enable-libjack
--enable-libaribb24
--enable-libaribcaption
--enable-libklvanc
--enable-libiec61883
--enable-libdc1394
--enable-librsvg
--enable-libopencv
--enable-vapoursynth
--enable-libzvbi
--enable-libqrencode
--enable-chromaprint
--enable-frei0r
--enable-ladspa
--enable-lv2
--enable-libopenh264
--enable-sdl2
--enable-whisper
--enable-libvpl
--enable-amf
--enable-openssl
--enable-gcrypt
--enable-libxeve
--enable-libxevd
)
./configure "${flags[@]}" && \
make && \
make install && \
make tools/zmqsend && cp -av tools/zmqsend ${PREFIX}/bin/ && \
hash -r && \
cd tools && \
make qt-faststart && cp qt-faststart ${PREFIX}/bin/
}
######################### Helper functions #########################
extract_tarball() {
local tarball_name=$1
# grab the extension of the tarball
local extension="${tarball_name##*.}"
# tar extraction args: -z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
if [ "$extension" == "gz" ]; then
tar -zx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "bz2" ]; then
tar -jx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "xz" ]; then
tar -Jx --strip-components=1 -f ${tarball_name}
else
echo "Error while extract_tarball, got an unknown extension: $extension"
fi
}
build_support_libraries() {
local librariesRaw="$(jq -r '.[] | .library_name' $manifestJsonFile)"
local libs=( $librariesRaw )
for i in "${!libs[@]}"; do
lib_name=${libs[$i]}
# handle the clone source case's ( there are only two )
# if [ "$lib_name" == "libsvtav1" ]; then
# echo "-------------------- Running callback: build_aom --------------------"
# echo "Building 'aom' before we build $lib_name"
# build_aom
# fi
# ffmpeg is in the lib_name string then the callback name is build_ffmpeg
callback_lib_name=${lib_name}
if [[ "$lib_name" == *"ffmpeg"* ]]; then
# take out the version numbers
callback_lib_name="ffmpeg"
fi
local data=$(jq -r '.[] | select(.library_name == "'${lib_name}'")' $manifestJsonFile)
build_dir=$(echo "$data" | jq -r '.build_dir')
tarball_name=$(echo "$data" | jq -r '.tarball_name')
sha256sum=$(echo "$data" | jq -r '.sha256sum')
echo "Building $lib_name"
cd "$build_dir"
if [[ -n "$tarball_name" && "$tarball_name" != "null" ]]; then
echo " extracting $tarball_name"
extract_tarball "$tarball_name"
if [[ -n "$sha256sum" && "$sha256sum" != "null" ]]; then
echo "Checking sha256sum for $tarball_name"
echo "$sha256sum" | sha256sum --check
fi
else
echo " no tarball, assuming source tree already present"
fi
# make a callback function to build the library
# if anything fails, we will exit with a non-zero status
echo "-------------------- Running callback: build_${lib_name} --------------------"
build_${callback_lib_name} ${build_dir}
echo "Finished building $lib_name removing build directory [${build_dir}]"
cd "$(dirname "$manifestJsonFile")"
rm -rf $build_dir
done
}
build_support_libraries