-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·88 lines (63 loc) · 2.15 KB
/
build.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
#! /bin/bash
set -exo pipefail
if [[ "$VERSION" == "" ]] || [[ "$URL" == "" ]]; then
export VERSION=21.02
export URL=https://sourceforge.net/projects/sevenzip/files/7-Zip/21.02/7z2102-src.7z/download
echo "\$VERSION and/or \$URL not set, using defaults: $VERSION $URL"
fi
# use RAM disk if possible
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
TEMP_BASE=/dev/shm
else
TEMP_BASE=/tmp
fi
BUILD_DIR="$(mktemp -d -p "$TEMP_BASE" static-7zip-build-XXXXXX)"
cleanup () {
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
trap cleanup EXIT
# store repo root as variable
REPO_ROOT="$(readlink -f "$(dirname "$(dirname "$0")")")"
OLD_CWD="$(readlink -f .)"
pushd "$BUILD_DIR"
if type wget &>/dev/null; then
wget "$URL" -O src.7z
elif type curl &>/dev/null; then
curl "$URL" -o src.7z
else
echo "error: need either curl or wget to download the source code"
exit 1
fi
7za x src.7z
if [[ "$CI" != "" ]]; then
procs="$(nproc --ignore=1)"
else
procs="$(nproc)"
fi
# default makefile, does not build assembler code
makefile="../../cmpl_gcc.mak"
# we can optionally build with the assembler if requested by the user
if [[ "$BUILD_ASM" != "" ]]; then
mkdir asmc
# the repo structure has changed in later releases, therefore we pin a "known working" version
wget https://github.com/nidud/asmc/archive/a99d03231911f73ae40cd9330c43284a3244b912.tar.gz -O - | tar xz -C asmc --strip-components=1
export PATH="$(readlink -f asmc/source/asmc/linux/bin):$PATH"
chmod +x asmc/source/asmc/linux/bin/asmc
makefile="../../cmpl_gcc_x64.mak"
fi
pushd CPP/7zip/UI/Console
# patch to build fully statically (optional)
if [[ "$STATIC_BUILD" != "" ]]; then
sed -i 's|^LDFLAGS_STATIC\s*=\.*|& -static -static-libstdc++ -static-libgcc|g' ../../7zip_gcc.mak
fi
make -f "$makefile" -j "$procs"
cp b/g*/7z "$OLD_CWD"
popd
# the regular binary has a dependency on some 7z.so
# there is some "Alone2" bundle which builds a 7zz binary that does not have such a dependency, therefore we also build this
pushd CPP/7zip/Bundles/Alone2
make -f "$makefile" -j "$procs"
cp b/g*/7zz "$OLD_CWD"
popd