-
Notifications
You must be signed in to change notification settings - Fork 17
/
make_bin_dist.sh
executable file
·62 lines (46 loc) · 2.02 KB
/
make_bin_dist.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
#!/bin/sh
die()
{
BASE=$(basename "$0")
echo "$BASE error: $1" >&2
exit 1
}
GITID=$(./config/git-version-gen .tarball-version) || die "Failed to get GIT ID"
TARBALL=lobSTR-${GITID}.tar.gz
[ -e "$TARBALL" ] || die "can't find source code tarball file '$TARBALL' (did you run 'make_src_dist.sh'?)"
MACHINE=$(uname -m) || die "uname -m failed"
KERNEL=$(uname -s) || die "uname -s failed"
# new temporary directory, into which we'll extract the files
BUILD_ROOT_DIR=$(mktemp -d build.XXXXXXX) || die "mktemp failed"
BUILD_ROOT_DIR="$PWD/$BUILD_ROOT_DIR"
# the source code directory, extracted from the Tarball
BUILD_SRC_DIR="$BUILD_ROOT_DIR/lobSTR-${GITID}"
# The target prefix directory for "./configure"
LOBSTR_BIN_PREFIX="lobSTR-bin-${KERNEL}-${MACHINE}-${GITID}"
BUILD_BIN_DIR="$BUILD_ROOT_DIR/$LOBSTR_BIN_PREFIX"
# Extract the source code files
tar -xzf "$TARBALL" -C "$BUILD_ROOT_DIR" || die "tar -xf ../$TARBALL failed"
# Build lobSTR, with special static options
cd "$BUILD_SRC_DIR" || die "cd $BUILD_SRC_DIR failed"
./configure --enable-all-static --prefix "$BUILD_BIN_DIR" || die "Configure failed, check logs in $BUILD_SRC_DIR"
make || die "make failed, check logs in $BUILD_SRC_DIR"
make install || die "make install failed, check logs in $BUILD_SRC_DIR"
## The compiled binary files are now in "$BUILD_BIN_DIR"
# Strip the binaries to reduce their size
find "$BUILD_BIN_DIR/bin" -type f | xargs -L 1 strip
# No need to distribute the M4 macroes
rm -rf "$BUILD_BIN_DIR/share/aclocal"
# Pack the binaries for a distribution
cd "$BUILD_ROOT_DIR" || die "cd $BUILD_ROOT_DIR failed"
BINTARBALL="../${LOBSTR_BIN_PREFIX}.tar.gz"
rm -f "$BINTARBALL"
tar -czf "$BINTARBALL" "$LOBSTR_BIN_PREFIX" || die "tar -czf failed"
## Back to the source code directory
cd .. || die "cd .. failed"
rm -r "$BUILD_ROOT_DIR" || die "cleanup failed (rm -r $BUILD_ROOT_DIR)"
echo
echo "Binary Distribution for lobSTR version $GITID for $KERNEL-$MACHINE is ready"
echo ""
echo "Upload the following file to github/releases:"
echo " $LOBSTR_BIN_PREFIX.tar.gz"
echo ""